117 for (int i(0); i < messageEnvelopeList.count(); i++) { |
117 for (int i(0); i < messageEnvelopeList.count(); i++) { |
118 NmMessageEnvelope *nextMessage = messageEnvelopeList[i]; |
118 NmMessageEnvelope *nextMessage = messageEnvelopeList[i]; |
119 // imap and pop is using common sent, outbox or draft folder |
119 // imap and pop is using common sent, outbox or draft folder |
120 // for all mailboxes, here we want to filter out messages that |
120 // for all mailboxes, here we want to filter out messages that |
121 // are not under this mailbox |
121 // are not under this mailbox |
122 bool insert(true); |
122 if (nextMessage) { |
123 if (nextMessage |
123 bool insert(true); |
124 && (NmFolderSent == mCurrentFolderType |
124 if (NmFolderSent == mCurrentFolderType |
125 || NmFolderOutbox == mCurrentFolderType |
125 || NmFolderOutbox == mCurrentFolderType |
126 || NmFolderDrafts == mCurrentFolderType)) { |
126 || NmFolderDrafts == mCurrentFolderType) { |
127 insert = (mCurrentMailboxId == nextMessage->mailboxId()); |
127 insert = (mCurrentMailboxId == nextMessage->mailboxId()); |
128 } |
128 } |
129 if (insert) { |
129 if (insert) { |
130 if (mDividersActive && |
130 if (mDividersActive && |
131 !messagesBelongUnderSameDivider(insertedMessage, nextMessage)) { |
131 !messagesBelongUnderSameDivider(insertedMessage, nextMessage)) { |
132 insertDividerIntoModel(nextMessage, parentCount); |
132 insertDividerIntoModel(nextMessage, parentCount); |
133 parentCount++; |
133 parentCount++; |
134 childCount = 0; |
134 childCount = 0; |
135 } |
135 } |
136 |
|
137 insertMessageIntoModel(nextMessage, childCount, false); |
136 insertMessageIntoModel(nextMessage, childCount, false); |
138 insertedMessage = nextMessage; |
137 insertedMessage = nextMessage; |
139 childCount++; |
138 childCount++; |
|
139 } |
140 } |
140 } |
141 } |
141 } |
142 } |
142 } |
143 |
143 |
144 |
144 |
216 const QList<NmId> &messageIds, |
216 const QList<NmId> &messageIds, |
217 const NmId &mailboxId) |
217 const NmId &mailboxId) |
218 { |
218 { |
219 NM_FUNCTION; |
219 NM_FUNCTION; |
220 const int idCount = messageIds.count(); |
220 const int idCount = messageIds.count(); |
|
221 NmId inFolderId = mDataManager.getStandardFolderId(mailboxId, NmFolderInbox); |
221 |
222 |
222 // Folder ID does not concern us if this model instance is used for e.g. |
223 // Folder ID does not concern us if this model instance is used for e.g. |
223 // searching messages. |
224 // searching messages. |
224 if (!mIgnoreFolderIds) { |
225 if (!mIgnoreFolderIds) { |
225 if (folderId == 0) { |
226 if (folderId == 0) { |
226 // Const cast is used here because also the input parameter has to |
227 // Const cast is used here because also the input parameter has to |
227 // be changed. |
228 // be changed. |
228 const_cast<NmId&>(folderId) = |
229 const_cast<NmId&>(folderId) = inFolderId; |
229 mDataManager.getStandardFolderId(mailboxId, NmFolderInbox); |
|
230 NmUiStartParam *startParam = |
230 NmUiStartParam *startParam = |
231 new NmUiStartParam(NmUiViewMessageList, mailboxId, folderId); |
231 new NmUiStartParam(NmUiViewMessageList, mailboxId, folderId); |
232 emit setNewParam(startParam); |
232 emit setNewParam(startParam); |
233 } |
233 } |
234 |
234 |
235 if (mCurrentFolderId == 0) { |
235 if (mCurrentFolderId == 0 && folderId == inFolderId) { |
236 // Folder ID was not known at time when the mailbox opened and we |
236 // Folder ID was not known at time when the mailbox opened and we |
237 // know that because of events the subscription is valid only for |
237 // know that because of events the subscription is valid only for |
238 // the current mailbox. |
238 // the current mailbox. |
239 mCurrentFolderId = folderId; |
239 mCurrentFolderId = folderId; |
240 } |
240 } |
277 case NmMessageDeleted: { |
277 case NmMessageDeleted: { |
278 removeMessageFromModel(messageIds[i]); |
278 removeMessageFromModel(messageIds[i]); |
279 break; |
279 break; |
280 } |
280 } |
281 } |
281 } |
|
282 } |
|
283 } |
|
284 |
|
285 /*! |
|
286 Handles the folder deleted events. |
|
287 |
|
288 \param folderId The folder deleted |
|
289 \param mailboxId A related mailbox |
|
290 */ |
|
291 void NmMessageListModel::handleFolderDeletedEvent( |
|
292 const NmId &folderId, |
|
293 const NmId &mailboxId) |
|
294 { |
|
295 NM_FUNCTION; |
|
296 |
|
297 // Folder ID does not concern us if this model instance is used for e.g. |
|
298 // searching messages. |
|
299 if (!mIgnoreFolderIds |
|
300 && mCurrentMailboxId == mailboxId |
|
301 && mCurrentFolderId == folderId) { |
|
302 clear(); |
|
303 mCurrentFolderId = 0; |
|
304 // Go to inbox, but set folderId as 0 to indicate out-of-sync-state. |
|
305 NmUiStartParam *startParam = |
|
306 new NmUiStartParam(NmUiViewMessageList, mailboxId, mCurrentFolderId); |
|
307 emit setNewParam(startParam); |
282 } |
308 } |
283 } |
309 } |
284 |
310 |
285 |
311 |
286 /*! |
312 /*! |