Small patch for kdf to improve the usability

Raphael Kubo da Costa kubito at gmail.com
Mon Jan 11 17:08:15 CET 2010


On Wednesday 23 December 2009 16:14:36 Wearenotalone wrote:
> Hi there,
> at the moment kdf remembers only the hidden columns. The sortorder of
> the rows and the columns is lost after each close. The following small
> patch saves this information of the QTreeView header:
> 
> --- kdfwidget.cpp       (revision 1065512)
> +++ kdfwidget.cpp       (working copy)
> @@ -162,6 +162,17 @@
>              if( !m_listWidget->isColumnHidden( c.number ) )
>                  config.writeEntry( c.name,
> m_listWidget->columnWidth(c.number) );
>          }
> +
> +        config.writeEntry("SortColumn", m_sortModel->sortColumn());
> +        config.writeEntry("SortOrder", (int)m_sortModel->sortOrder());
> +
> +        //Save the sort order of the QTreeView Header
> +        QHeaderView * header = m_listWidget->header();
> +        QList<int> sectionIndices;
> +        for (int i = 0; i < header->count(); i++) {
> +            sectionIndices.append(header->visualIndex(i));
> +        }
> +        config.writeEntry("HeaderSectionIndices", sectionIndices);
>      }
>      config.sync();
>      updateDF();
> @@ -189,6 +200,24 @@
>              m_listWidget->setColumnHidden( c.number, !visible );
>          }
> 
> +        int sortColumn = config.readEntry("SortColumn",0);
> +        int sortOrder =
> config.readEntry("SortOrder",(int)Qt::AscendingOrder);
> +        m_listWidget->sortByColumn(sortColumn,Qt::SortOrder(sortOrder));
> +
> +        //Load the sort order of the QTreeView Header
> +        //This can also be achieved by header->saveState() and
> header->restoreState(...),
> +        //but this would not be "human-readable" any more...
> +        QHeaderView * header = m_listWidget->header();
> +        QList<int> sectionIndices;
> +        sectionIndices =
> config.readEntry("HeaderSectionIndices",sectionIndices);
> +        if (sectionIndices.count() == header->count()) {
> +            for (int i = 0; i < header->count(); i++) {
> +                int sectionIndex = sectionIndices.at(i);
> +                int oldVisualIndex = header->visualIndex(sectionIndex);
> +                header->moveSection(oldVisualIndex,i);
> +            }
> +        }
> +
>          setUpdateFrequency( mStd.updateFrequency() );
>          updateDF();
>      }
> 
> Unfortunately, I do not know where to send this patch, except to this
> mailing list. Therefore, it would be nice if someone could review and
> possibly commit this patch.

I haven't applied the patch here, but at first glance it looks fine.

Friedrich, do we still have a maintainer for kdf to review the patch more 
thoroughly?


More information about the Kde-utils-devel mailing list