summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/qml/MailListView.qml18
-rw-r--r--framework/src/domain/maillistmodel.cpp29
-rw-r--r--framework/src/domain/maillistmodel.h7
-rw-r--r--tests/teststore.cpp1
-rw-r--r--views/conversation/main.qml5
5 files changed, 25 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
227bool MailListModel::isThreaded() const
228{
229 return mIsThreaded;
230}
231
232void MailListModel::setParentFolder(const QVariant &parentFolder) 223void 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
40public: 39public:
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
99signals:
100 void isThreadedChanged();
101
102private: 96private:
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};
diff --git a/tests/teststore.cpp b/tests/teststore.cpp
index 07310640..6dbe5622 100644
--- a/tests/teststore.cpp
+++ b/tests/teststore.cpp
@@ -91,6 +91,7 @@ static void createMail(const QVariantMap &object, const QByteArray &folder = {})
91 91
92 auto mail = ApplicationDomainType::createEntity<Mail>(object["resource"].toByteArray()); 92 auto mail = ApplicationDomainType::createEntity<Mail>(object["resource"].toByteArray());
93 mail.setMimeMessage(msg->encodedContent(true)); 93 mail.setMimeMessage(msg->encodedContent(true));
94 mail.setUnread(object["unread"].toBool());
94 if (!folder.isEmpty()) { 95 if (!folder.isEmpty()) {
95 mail.setFolder(folder); 96 mail.setFolder(folder);
96 } 97 }
diff --git a/views/conversation/main.qml b/views/conversation/main.qml
index 2f80abff..9e17a0b6 100644
--- a/views/conversation/main.qml
+++ b/views/conversation/main.qml
@@ -63,6 +63,7 @@ ApplicationWindow {
63 to: ["to@example.org"], 63 to: ["to@example.org"],
64 cc: ["cc@example.org"], 64 cc: ["cc@example.org"],
65 bcc: ["bcc@example.org"], 65 bcc: ["bcc@example.org"],
66 unread: true
66 }, 67 },
67 { 68 {
68 resource: "resource1", 69 resource: "resource1",
@@ -71,6 +72,7 @@ ApplicationWindow {
71 subject: "subject2", 72 subject: "subject2",
72 body: "body2", 73 body: "body2",
73 to: ["to@example.org"], 74 to: ["to@example.org"],
75 unread: true
74 }, 76 },
75 { 77 {
76 resource: "resource1", 78 resource: "resource1",
@@ -79,6 +81,7 @@ ApplicationWindow {
79 subject: "subject3", 81 subject: "subject3",
80 body: "body3\n\n\n\nfoo\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nThe End", 82 body: "body3\n\n\n\nfoo\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nThe End",
81 to: ["to@example.org"], 83 to: ["to@example.org"],
84 unread: true
82 }, 85 },
83 { 86 {
84 resource: "resource1", 87 resource: "resource1",
@@ -87,6 +90,7 @@ ApplicationWindow {
87 subject: "subject4", 90 subject: "subject4",
88 body: "body4", 91 body: "body4",
89 to: ["to@example.org"], 92 to: ["to@example.org"],
93 unread: false
90 }, 94 },
91 { 95 {
92 resource: "resource1", 96 resource: "resource1",
@@ -94,6 +98,7 @@ ApplicationWindow {
94 subject: "UTF-8 Madness Umlauts:öüä Snowflake:❆ Heart:♥", 98 subject: "UTF-8 Madness Umlauts:öüä Snowflake:❆ Heart:♥",
95 body: "UTF-8 Madness Umlauts:öüä Snowflake:❆ Heart:♥", 99 body: "UTF-8 Madness Umlauts:öüä Snowflake:❆ Heart:♥",
96 to: ["öüä@example.org"], 100 to: ["öüä@example.org"],
101 unread: true
97 }, 102 },
98 ] 103 ]
99 }], 104 }],