235 // Delete existing start parameter data |
233 // Delete existing start parameter data |
236 delete mStartParam; |
234 delete mStartParam; |
237 mStartParam=NULL; |
235 mStartParam=NULL; |
238 // Store new start parameter data |
236 // Store new start parameter data |
239 mStartParam=startParam; |
237 mStartParam=startParam; |
240 // Update the model with new parameters |
238 // Disconnect signals from previous model |
|
239 QObject::disconnect(mMessageListModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)), |
|
240 this, SLOT(itemsAdded(const QModelIndex&,int,int))); |
|
241 QObject::disconnect(mMessageListModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)), |
|
242 this, SLOT(itemsRemoved())); |
|
243 QObject::disconnect(mMessageListModel, SIGNAL(setNewParam(NmUiStartParam*)), |
|
244 this, SLOT(reloadViewContents(NmUiStartParam*))); |
|
245 // Update model pointer and refresh mailbox with new model |
241 mMessageListModel = &mUiEngine.messageListModel(startParam->mailboxId(), startParam->folderId()); |
246 mMessageListModel = &mUiEngine.messageListModel(startParam->mailboxId(), startParam->folderId()); |
242 refreshList(); |
247 refreshList(); |
243 // Refresh the mailboxname |
248 // Refresh the mailboxname |
244 setMailboxName(); |
249 setMailboxName(); |
245 } |
250 } |
267 void NmMessageListView::refreshList() |
272 void NmMessageListView::refreshList() |
268 { |
273 { |
269 NM_FUNCTION; |
274 NM_FUNCTION; |
270 |
275 |
271 if (mMessageListModel) { |
276 if (mMessageListModel) { |
272 NmId mailboxId = mMessageListModel->currentMailboxId(); |
277 NmId mailboxId = mMessageListModel->currentMailboxId(); |
273 // In each refresh, e.g. in folder change the UI signals |
278 // In each refresh, e.g. in folder change the UI signals |
274 // lower layer about the folder that has been opened. |
279 // lower layer about the folder that has been opened. |
275 if (mStartParam){ |
280 if (mStartParam){ |
276 mUiEngine.updateActiveFolder(mailboxId, mStartParam->folderId()); |
281 mUiEngine.updateActiveFolder(mailboxId, mStartParam->folderId()); |
277 |
282 |
278 NmFolderType folderType = mUiEngine.folderTypeById(mStartParam->mailboxId(), |
283 NmFolderType folderType = mUiEngine.folderTypeById(mStartParam->mailboxId(), |
279 mStartParam->folderId()); |
284 mStartParam->folderId()); |
280 if (folderType == NmFolderInbox) { // If the new folder is an inbox, first automatic sync should be shown |
285 if (folderType == NmFolderInbox) { // If the new folder is an inbox, first automatic sync should be shown |
281 mIsFirstSyncInMessageList = true; |
286 mIsFirstSyncInMessageList = true; |
282 } |
287 } |
283 } |
288 } |
284 |
289 |
285 // Set item model to message list widget |
290 // Set item model to message list widget |
286 if (mMessageListWidget) { |
291 if (mMessageListWidget) { |
287 mMessageListWidget->setModel(static_cast<QStandardItemModel*>(mMessageListModel)); |
292 mMessageListWidget->setModel(static_cast<QStandardItemModel*>(mMessageListModel)); |
288 QObject::connect(mMessageListModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)), |
293 QObject::connect(mMessageListModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)), |
289 this, SLOT(itemsAdded(const QModelIndex&,int,int))); |
294 this, SLOT(itemsAdded(const QModelIndex&,int,int)),Qt::UniqueConnection); |
290 QObject::connect(mMessageListModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)), |
295 QObject::connect(mMessageListModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)), |
291 this, SLOT(itemsRemoved())); |
296 this, SLOT(itemsRemoved()),Qt::UniqueConnection); |
292 QObject::connect(mMessageListModel, SIGNAL(setNewParam(NmUiStartParam*)), |
297 QObject::connect(mMessageListModel, SIGNAL(setNewParam(NmUiStartParam*)), |
293 this, SLOT(reloadViewContents(NmUiStartParam*))); |
298 this, SLOT(reloadViewContents(NmUiStartParam*)),Qt::UniqueConnection); |
294 |
299 |
295 mPreviousModelCount=mMessageListModel->rowCount(); |
300 mPreviousModelCount=mMessageListModel->rowCount(); |
296 if (mPreviousModelCount==0){ |
301 if (mPreviousModelCount==0){ |
297 showNoMessagesText(); |
302 showNoMessagesText(); |
298 } |
303 } |
299 else{ |
304 else{ |
300 hideNoMessagesText(); |
305 hideNoMessagesText(); |
301 } |
306 } |
302 } |
307 } |
303 } |
308 } |
304 } |
309 } |
305 |
310 |
306 /*! |
311 /*! |
307 Sync state event handling |
312 Sync state event handling |
308 */ |
313 */ |
309 void NmMessageListView::handleSyncStateEvent(NmSyncState syncState, const NmId & mailboxId) |
314 void NmMessageListView::handleSyncStateEvent(NmSyncState syncState, const NmId &mailboxId) |
310 { |
315 { |
311 NM_FUNCTION; |
316 NM_FUNCTION; |
312 if (mMessageListModel && mailboxId == mMessageListModel->currentMailboxId()) { |
317 if (mMessageListModel && mailboxId == mMessageListModel->currentMailboxId()) { |
313 if (syncState == Synchronizing) { |
318 if (syncState == Synchronizing) { |
314 // before first sync inbox id might be zero |
319 // before first sync inbox id might be zero |
320 mStartParam->setFolderId(folderId); |
325 mStartParam->setFolderId(folderId); |
321 } |
326 } |
322 // Show sync icon only for the first automatic sync after opening message list. |
327 // Show sync icon only for the first automatic sync after opening message list. |
323 // Sync icon for manual sync is shown in NmUiEngine::refreshMailbox, not here. |
328 // Sync icon for manual sync is shown in NmUiEngine::refreshMailbox, not here. |
324 if (mIsFirstSyncInMessageList) { |
329 if (mIsFirstSyncInMessageList) { |
325 HbIndicator indicator; |
330 mUiEngine.enableSyncIndicator(true); |
326 indicator.activate(syncIndicatorName, QVariant()); |
|
327 mIsFirstSyncInMessageList = false; |
331 mIsFirstSyncInMessageList = false; |
328 } |
332 } |
329 } |
333 } |
330 } |
334 } |
331 } |
335 } |
332 |
336 |
333 /*! |
337 /*! |
334 folder selection handling within current mailbox |
338 folder selection handling within current mailbox |
335 */ |
339 */ |
336 void NmMessageListView::folderSelected() |
340 void NmMessageListView::folderSelected() |
337 { |
341 { |
338 NM_FUNCTION; |
342 NM_FUNCTION; |
355 } |
359 } |
356 } |
360 } |
357 |
361 |
358 |
362 |
359 /*! |
363 /*! |
360 Long keypress handling |
364 Long keypress handling |
361 */ |
365 */ |
362 void NmMessageListView::showItemContextMenu(HbAbstractViewItem *listViewItem, const QPointF &coords) |
366 void NmMessageListView::showItemContextMenu(HbAbstractViewItem *listViewItem, const QPointF &coords) |
363 { |
367 { |
364 NM_FUNCTION; |
368 NM_FUNCTION; |
365 |
369 |
366 if (listViewItem) { |
370 if (listViewItem) { |
367 // Recreate item context menu each time it is called |
371 // Recreate item context menu each time it is called |
368 if (mItemContextMenu){ |
372 if (mItemContextMenu){ |
369 mItemContextMenu->clearActions(); |
373 mItemContextMenu->clearActions(); |
370 delete mItemContextMenu; |
374 delete mItemContextMenu; |
371 mItemContextMenu=NULL; |
375 mItemContextMenu=NULL; |
372 } |
376 } |
373 mItemContextMenu = new HbMenu(); |
377 mItemContextMenu = new HbMenu(); |
374 // Store long press item for later use with response |
378 // Store long press item for later use with response |
375 mLongPressedItem = mMessageListModel->data( |
379 mLongPressedItem = mMessageListModel->data( |