diff options
Diffstat (limited to 'framework/src/domain/maillistmodel.cpp')
-rw-r--r-- | framework/src/domain/maillistmodel.cpp | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/framework/src/domain/maillistmodel.cpp b/framework/src/domain/maillistmodel.cpp index 83340f69..0f477624 100644 --- a/framework/src/domain/maillistmodel.cpp +++ b/framework/src/domain/maillistmodel.cpp | |||
@@ -114,9 +114,17 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const | |||
114 | case Date: | 114 | case Date: |
115 | return mail->getDate(); | 115 | return mail->getDate(); |
116 | case Unread: | 116 | case Unread: |
117 | return mail->getProperty("unreadCollected").toList().contains(true); | 117 | if (mIsThreaded) { |
118 | return mail->getProperty("unreadCollected").toList().contains(true); | ||
119 | } else { | ||
120 | return mail->getUnread(); | ||
121 | } | ||
118 | case Important: | 122 | case Important: |
119 | return mail->getProperty("importantCollected").toList().contains(true); | 123 | if (mIsThreaded) { |
124 | return mail->getProperty("importantCollected").toList().contains(true); | ||
125 | } else { | ||
126 | return mail->getImportant(); | ||
127 | } | ||
120 | case Draft: | 128 | case Draft: |
121 | return mail->getDraft(); | 129 | return mail->getDraft(); |
122 | case Sent: | 130 | case Sent: |
@@ -133,7 +141,11 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const | |||
133 | } | 141 | } |
134 | return mail->getMimeMessage(); | 142 | return mail->getMimeMessage(); |
135 | case ThreadSize: | 143 | case ThreadSize: |
136 | return mail->getProperty("count").toInt(); | 144 | if (mIsThreaded) { |
145 | return mail->getProperty("count").toInt(); | ||
146 | } else { | ||
147 | return 1; | ||
148 | } | ||
137 | case Mail: | 149 | case Mail: |
138 | return QVariant::fromValue(mail); | 150 | return QVariant::fromValue(mail); |
139 | case Incomplete: | 151 | case Incomplete: |
@@ -176,6 +188,11 @@ void MailListModel::runQuery(const Sink::Query &query) | |||
176 | setSourceModel(m_model.data()); | 188 | setSourceModel(m_model.data()); |
177 | } | 189 | } |
178 | 190 | ||
191 | bool MailListModel::isThreaded() const | ||
192 | { | ||
193 | return mIsThreaded; | ||
194 | } | ||
195 | |||
179 | void MailListModel::setParentFolder(const QVariant &parentFolder) | 196 | void MailListModel::setParentFolder(const QVariant &parentFolder) |
180 | { | 197 | { |
181 | using namespace Sink::ApplicationDomain; | 198 | using namespace Sink::ApplicationDomain; |
@@ -189,11 +206,33 @@ void MailListModel::setParentFolder(const QVariant &parentFolder) | |||
189 | return; | 206 | return; |
190 | } | 207 | } |
191 | mCurrentQueryItem = folder->identifier(); | 208 | mCurrentQueryItem = folder->identifier(); |
192 | Sink::Query query = Sink::StandardQueries::threadLeaders(*folder); | 209 | if (folder->getSpecialPurpose().contains(Sink::ApplicationDomain::SpecialPurpose::Mail::drafts) || |
210 | folder->getSpecialPurpose().contains(Sink::ApplicationDomain::SpecialPurpose::Mail::sent)) { | ||
211 | mIsThreaded = false; | ||
212 | } else { | ||
213 | mIsThreaded = true; | ||
214 | } | ||
215 | emit isThreadedChanged(); | ||
216 | |||
217 | Sink::Query query = [&] { | ||
218 | if (mIsThreaded) { | ||
219 | return Sink::StandardQueries::threadLeaders(*folder); | ||
220 | } else { | ||
221 | Sink::Query query; | ||
222 | query.setId("threadleaders-unthreaded"); | ||
223 | if (!folder->resourceInstanceIdentifier().isEmpty()) { | ||
224 | query.resourceFilter(folder->resourceInstanceIdentifier()); | ||
225 | } | ||
226 | query.filter<Sink::ApplicationDomain::Mail::Folder>(*folder); | ||
227 | query.sort<Sink::ApplicationDomain::Mail::Date>(); | ||
228 | return query; | ||
229 | } | ||
230 | }(); | ||
193 | if (!folder->getSpecialPurpose().contains(Sink::ApplicationDomain::SpecialPurpose::Mail::trash)) { | 231 | if (!folder->getSpecialPurpose().contains(Sink::ApplicationDomain::SpecialPurpose::Mail::trash)) { |
194 | //Filter trash if this is not a trash folder | 232 | //Filter trash if this is not a trash folder |
195 | query.filter<Sink::ApplicationDomain::Mail::Trash>(false); | 233 | query.filter<Sink::ApplicationDomain::Mail::Trash>(false); |
196 | } | 234 | } |
235 | |||
197 | query.setFlags(Sink::Query::LiveQuery); | 236 | query.setFlags(Sink::Query::LiveQuery); |
198 | query.limit(100); | 237 | query.limit(100); |
199 | query.request<Mail::Subject>(); | 238 | query.request<Mail::Subject>(); |