Version: 1.13.5 (using KDE 4.5.1) OS: Linux in the `find messages' window, messages cannot correctly be sorted by date. instead of being sorted by date, they are sorted by the date string Reproducible: Always Steps to Reproduce: - find messages in folder - hit `search' - try to sort by date
I can confirm this bug. KMail 1.13.5, KDE 4.5.2
I can confirm this bug. KMail 1.13.5, KDE 4.4.5
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...
(In reply to comment #3) > 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). > [...] > In function SearchWindow::slotAddMsg, use this class instead of QTreeWidgetItem > when adding more results. > Maybe I'll test and refine this code later today... My simple code above would not work, as the date strings are localized and not easy to compare. A better implementation would be to use nice model/view approach which has already been implemented in trunk and 4.5beta1 (not tested myself, yet). Therefore I propose to close this bug as soon as Kontact / KMail 4.5 becomes stable. Maybe mark this bug until then as WONTFIX?
I fixed this bug yesterday I close it