summaryrefslogtreecommitdiffstats
path: root/framework/mail/maillistmodel.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-09 12:31:02 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-09 12:31:02 +0100
commita6c557b0d9873014cda4e3bcfedd82b50416ea23 (patch)
tree3922b24de26adaad7d638a3cca811e3844508512 /framework/mail/maillistmodel.cpp
parent207be0e03b18ca2af4949f44b6f8bcadd6220695 (diff)
downloadkube-a6c557b0d9873014cda4e3bcfedd82b50416ea23.tar.gz
kube-a6c557b0d9873014cda4e3bcfedd82b50416ea23.zip
Sort mails by date
Diffstat (limited to 'framework/mail/maillistmodel.cpp')
-rw-r--r--framework/mail/maillistmodel.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/framework/mail/maillistmodel.cpp b/framework/mail/maillistmodel.cpp
index 3ff8efc4..9a55e265 100644
--- a/framework/mail/maillistmodel.cpp
+++ b/framework/mail/maillistmodel.cpp
@@ -30,9 +30,10 @@
30 30
31 31
32MailListModel::MailListModel(QObject *parent) 32MailListModel::MailListModel(QObject *parent)
33 : QIdentityProxyModel() 33 : QSortFilterProxyModel()
34{ 34{
35 35 setDynamicSortFilter(true);
36 sort(0, Qt::DescendingOrder);
36} 37}
37 38
38MailListModel::~MailListModel() 39MailListModel::~MailListModel()
@@ -121,7 +122,14 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const
121 return "Failed to read mail."; 122 return "Failed to read mail.";
122 } 123 }
123 } 124 }
124 return QIdentityProxyModel::data(idx, role); 125 return QSortFilterProxyModel::data(idx, role);
126}
127
128bool MailListModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
129{
130 const QVariant leftData = left.sibling(left.row(), 3).data(Qt::DisplayRole);
131 const QVariant rightData = right.sibling(right.row(), 3).data(Qt::DisplayRole);
132 return leftData.toDateTime() < rightData.toDateTime();
125} 133}
126 134
127void MailListModel::runQuery(const Sink::Query &query) 135void MailListModel::runQuery(const Sink::Query &query)