diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-02-22 15:22:22 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-02-22 15:22:22 +0100 |
commit | a9b086954e17d6f2d64ac94b225577cb0e416f4f (patch) | |
tree | e8a8350773a9b91959d9dd00f552e19cc850937c /framework | |
parent | e1242a5f8ad3722661b8d2fb4300736a1892c2e5 (diff) | |
download | kube-a9b086954e17d6f2d64ac94b225577cb0e416f4f.tar.gz kube-a9b086954e17d6f2d64ac94b225577cb0e416f4f.zip |
Use the new changes regarding aggregated properties.
This fixes marking partially unread threads as read.
Diffstat (limited to 'framework')
-rw-r--r-- | framework/qml/MailListView.qml | 18 | ||||
-rw-r--r-- | framework/src/domain/maillistmodel.cpp | 29 | ||||
-rw-r--r-- | framework/src/domain/maillistmodel.h | 7 |
3 files changed, 19 insertions, 35 deletions
diff --git a/framework/qml/MailListView.qml b/framework/qml/MailListView.qml index 69b7d871..35c90618 100644 --- a/framework/qml/MailListView.qml +++ b/framework/qml/MailListView.qml | |||
@@ -35,9 +35,6 @@ FocusScope { | |||
35 | property bool showFilter: false | 35 | property bool showFilter: false |
36 | property string filter: null | 36 | property string filter: null |
37 | 37 | ||
38 | onCurrentMailChanged: { | ||
39 | Kube.Fabric.postMessage(Kube.Messages.markAsRead, {"mail": currentMail}) | ||
40 | } | ||
41 | onParentFolderChanged: { | 38 | onParentFolderChanged: { |
42 | currentMail = null | 39 | currentMail = null |
43 | filterField.clearSearch() | 40 | filterField.clearSearch() |
@@ -130,11 +127,16 @@ FocusScope { | |||
130 | 127 | ||
131 | onCurrentItemChanged: { | 128 | onCurrentItemChanged: { |
132 | if (currentItem) { | 129 | if (currentItem) { |
133 | root.currentMail = currentItem.currentData.mail; | 130 | var currentData = currentItem.currentData; |
134 | root.isDraft = currentItem.currentData.draft; | 131 | root.currentMail = currentData.mail; |
135 | root.isTrash = currentItem.currentData.trash; | 132 | root.isDraft = currentData.draft; |
136 | root.isImportant = currentItem.currentData.important; | 133 | root.isTrash = currentData.trash; |
137 | root.isUnread = currentItem.currentData.unread; | 134 | root.isImportant = currentData.important; |
135 | root.isUnread = currentData.unread; | ||
136 | |||
137 | if (currentData.mail && currentData.unread) { | ||
138 | Kube.Fabric.postMessage(Kube.Messages.markAsRead, {"mail": currentData.mail}) | ||
139 | } | ||
138 | } | 140 | } |
139 | } | 141 | } |
140 | 142 | ||
diff --git a/framework/src/domain/maillistmodel.cpp b/framework/src/domain/maillistmodel.cpp index 0c22b2c8..a1e137b3 100644 --- a/framework/src/domain/maillistmodel.cpp +++ b/framework/src/domain/maillistmodel.cpp | |||
@@ -139,14 +139,14 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const | |||
139 | case Date: | 139 | case Date: |
140 | return mail->getDate(); | 140 | return mail->getDate(); |
141 | case Unread: | 141 | case Unread: |
142 | if (mIsThreaded) { | 142 | if (mail->isAggregate()) { |
143 | return mail->getProperty("unreadCollected").toList().contains(true); | 143 | return mail->getCollectedProperty<Sink::ApplicationDomain::Mail::Unread>().contains(true); |
144 | } else { | 144 | } else { |
145 | return mail->getUnread(); | 145 | return mail->getImportant(); |
146 | } | 146 | } |
147 | case Important: | 147 | case Important: |
148 | if (mIsThreaded) { | 148 | if (mail->isAggregate()) { |
149 | return mail->getProperty("importantCollected").toList().contains(true); | 149 | return mail->getCollectedProperty<Sink::ApplicationDomain::Mail::Important>().contains(true); |
150 | } else { | 150 | } else { |
151 | return mail->getImportant(); | 151 | return mail->getImportant(); |
152 | } | 152 | } |
@@ -166,11 +166,7 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const | |||
166 | } | 166 | } |
167 | return mail->getMimeMessage(); | 167 | return mail->getMimeMessage(); |
168 | case ThreadSize: | 168 | case ThreadSize: |
169 | if (mIsThreaded) { | 169 | return mail->count(); |
170 | return mail->getProperty("count").toInt(); | ||
171 | } else { | ||
172 | return 1; | ||
173 | } | ||
174 | case Mail: | 170 | case Mail: |
175 | return QVariant::fromValue(mail); | 171 | return QVariant::fromValue(mail); |
176 | case Incomplete: | 172 | case Incomplete: |
@@ -224,11 +220,6 @@ void MailListModel::runQuery(const Sink::Query &query) | |||
224 | } | 220 | } |
225 | } | 221 | } |
226 | 222 | ||
227 | bool MailListModel::isThreaded() const | ||
228 | { | ||
229 | return mIsThreaded; | ||
230 | } | ||
231 | |||
232 | void MailListModel::setParentFolder(const QVariant &parentFolder) | 223 | void MailListModel::setParentFolder(const QVariant &parentFolder) |
233 | { | 224 | { |
234 | using namespace Sink::ApplicationDomain; | 225 | using namespace Sink::ApplicationDomain; |
@@ -242,16 +233,14 @@ void MailListModel::setParentFolder(const QVariant &parentFolder) | |||
242 | return; | 233 | return; |
243 | } | 234 | } |
244 | mCurrentQueryItem = folder->identifier(); | 235 | mCurrentQueryItem = folder->identifier(); |
236 | bool isThreaded = true; | ||
245 | if (folder->getSpecialPurpose().contains(Sink::ApplicationDomain::SpecialPurpose::Mail::drafts) || | 237 | if (folder->getSpecialPurpose().contains(Sink::ApplicationDomain::SpecialPurpose::Mail::drafts) || |
246 | folder->getSpecialPurpose().contains(Sink::ApplicationDomain::SpecialPurpose::Mail::sent)) { | 238 | folder->getSpecialPurpose().contains(Sink::ApplicationDomain::SpecialPurpose::Mail::sent)) { |
247 | mIsThreaded = false; | 239 | isThreaded = false; |
248 | } else { | ||
249 | mIsThreaded = true; | ||
250 | } | 240 | } |
251 | emit isThreadedChanged(); | ||
252 | 241 | ||
253 | Sink::Query query = [&] { | 242 | Sink::Query query = [&] { |
254 | if (mIsThreaded) { | 243 | if (isThreaded) { |
255 | return Sink::StandardQueries::threadLeaders(*folder); | 244 | return Sink::StandardQueries::threadLeaders(*folder); |
256 | } else { | 245 | } else { |
257 | Sink::Query query; | 246 | Sink::Query query; |
diff --git a/framework/src/domain/maillistmodel.h b/framework/src/domain/maillistmodel.h index 27e8d036..f83656b9 100644 --- a/framework/src/domain/maillistmodel.h +++ b/framework/src/domain/maillistmodel.h | |||
@@ -35,7 +35,6 @@ class MailListModel : public QSortFilterProxyModel | |||
35 | Q_PROPERTY (bool showInbox READ showInbox WRITE setShowInbox) | 35 | Q_PROPERTY (bool showInbox READ showInbox WRITE setShowInbox) |
36 | 36 | ||
37 | Q_PROPERTY (QString filter READ filter WRITE setFilter) | 37 | Q_PROPERTY (QString filter READ filter WRITE setFilter) |
38 | Q_PROPERTY (bool isThreaded READ isThreaded NOTIFY isThreadedChanged) | ||
39 | 38 | ||
40 | public: | 39 | public: |
41 | enum Status { | 40 | enum Status { |
@@ -53,8 +52,6 @@ public: | |||
53 | bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE; | 52 | bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE; |
54 | bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const Q_DECL_OVERRIDE; | 53 | bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const Q_DECL_OVERRIDE; |
55 | 54 | ||
56 | bool isThreaded() const; | ||
57 | |||
58 | enum Roles { | 55 | enum Roles { |
59 | Subject = Qt::UserRole + 1, | 56 | Subject = Qt::UserRole + 1, |
60 | Sender, | 57 | Sender, |
@@ -96,9 +93,6 @@ public: | |||
96 | void setShowInbox(bool); | 93 | void setShowInbox(bool); |
97 | bool showInbox() const; | 94 | bool showInbox() const; |
98 | 95 | ||
99 | signals: | ||
100 | void isThreadedChanged(); | ||
101 | |||
102 | private: | 96 | private: |
103 | void fetchMail(Sink::ApplicationDomain::Mail::Ptr mail); | 97 | void fetchMail(Sink::ApplicationDomain::Mail::Ptr mail); |
104 | 98 | ||
@@ -106,6 +100,5 @@ private: | |||
106 | bool mFetchMails = false; | 100 | bool mFetchMails = false; |
107 | QSet<QByteArray> mFetchedMails; | 101 | QSet<QByteArray> mFetchedMails; |
108 | QByteArray mCurrentQueryItem; | 102 | QByteArray mCurrentQueryItem; |
109 | bool mIsThreaded = true; | ||
110 | Sink::Query mQuery; | 103 | Sink::Query mQuery; |
111 | }; | 104 | }; |