[Bug 251161] wrong date sort order in `find messages' window

Thomas Fischer fischer at unix-ag.uni-kl.de
Tue Nov 23 12:27:58 GMT 2010


https://bugs.kde.org/show_bug.cgi?id=251161


Thomas Fischer <fischer at unix-ag.uni-kl.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fischer at unix-ag.uni-kl.de




--- Comment #3 from Thomas Fischer <fischer unix-ag uni-kl de>  2010-11-23 13:27:56 ---
The problem is that the list widget uses a lexicographical comparison by
default. To solve this issue, instead of using QTreeWidgetItem objects to
represent search results, a new class has to derived here which re-implements
the sorting function (more specifically, how two entries are compared).

My idea would be as follows (not compiled, not tested, may not work at all!):



const int ColumnDate=2;

class MatchListViewItem : public QTreeWidgetItem
{
    private:
        MatchListView *parent;

    public:

MatchListViewItem(MatchListView *p)
: QTreeWidgetItem(p), parent(p)
{
    // empty
};

bool operator<( const QTreeWidgetItem & other ) const
{
    switch(parent->sortColumn()) {
        case ColumnDate:
            return
QDate::fromString(text(ColumnDate)).operator<(QDate::fromString(other.text(ColumnDate)));
        default:
    return QTreeWidgetItem::operator<(other);
    }
}
};


In function SearchWindow::slotAddMsg, use this class instead of QTreeWidgetItem
when adding more results.
Maybe I'll test and refine this code later today...

-- 
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the Kdepim-bugs mailing list