emailuis/nmailui/src/nmmessagelistview.cpp
changeset 65 478bc57ad291
parent 59 16ed8d08d0b1
child 72 64e38f08e49c
equal deleted inserted replaced
59:16ed8d08d0b1 65:478bc57ad291
   114             mMessageListWidget->setItemRecycling(true);
   114             mMessageListWidget->setItemRecycling(true);
   115             mMessageListWidget->contentWidget()->setProperty("indentation", 0);
   115             mMessageListWidget->contentWidget()->setProperty("indentation", 0);
   116             mMessageListWidget->setScrollDirections(Qt::Vertical);
   116             mMessageListWidget->setScrollDirections(Qt::Vertical);
   117             mMessageListWidget->setClampingStyle(HbScrollArea::BounceBackClamping);
   117             mMessageListWidget->setClampingStyle(HbScrollArea::BounceBackClamping);
   118             mMessageListWidget->setFrictionEnabled(true);
   118             mMessageListWidget->setFrictionEnabled(true);
   119 
   119             mMessageListWidget->setItemPixmapCacheEnabled(true);
       
   120             
   120             // Enable animations to display an email as soon as it is added to
   121             // Enable animations to display an email as soon as it is added to
   121             // the list.
   122             // the list.
   122             mMessageListWidget->setEnabledAnimations(HbAbstractItemView::Appear &
   123             mMessageListWidget->setEnabledAnimations(HbAbstractItemView::Appear &
   123                                                      HbAbstractItemView::Expand);
   124                                                      HbAbstractItemView::Expand);
   124         }
   125         }
   229     NM_FUNCTION;
   230     NM_FUNCTION;
   230 
   231 
   231     // Check start parameter validity, message view cannot
   232     // Check start parameter validity, message view cannot
   232     // be updated if given parameter is zero.
   233     // be updated if given parameter is zero.
   233     if (startParam&&startParam->viewId()==NmUiViewMessageList &&
   234     if (startParam&&startParam->viewId()==NmUiViewMessageList &&
   234         startParam->folderId()!=0) {
   235         startParam->mailboxId() != 0 ) {
   235         // Delete existing start parameter data
   236         // Delete existing start parameter data
   236         delete mStartParam;
   237         delete mStartParam;
   237         mStartParam = NULL;
   238         mStartParam = NULL;
   238         // Store new start parameter data
   239         // Store new start parameter data
   239         mStartParam = startParam;
   240         mStartParam = startParam;
   251         
   252         
   252         // Refresh the mailbox name
   253         // Refresh the mailbox name
   253         setMailboxName();
   254         setMailboxName();
   254         
   255         
   255         // Store active folder type
   256         // Store active folder type
   256         mCurrentFolderType = mUiEngine.folderTypeById(startParam->mailboxId(),startParam->folderId());
   257         mCurrentFolderType=NmFolderInbox;
       
   258         if (startParam->folderId()!=0){
       
   259             mCurrentFolderType = mUiEngine.folderTypeById(startParam->mailboxId(),startParam->folderId());        
       
   260         }
   257 
   261 
   258         // Update folder name
   262         // Update folder name
   259         setFolderName();
   263         setFolderName();
   260         
   264         
   261         // Set sync icon if needed
   265         // Set sync icon if needed
   262         updateSyncIcon();
   266         updateSyncIcon();
       
   267         
       
   268         // Reconstruct the tool bar. This needed because, for example, the
       
   269         // search button needs the new mailbox ID.
       
   270         createToolBar();
   263     }
   271     }
   264     else {
   272     else {
   265         NM_ERROR(1,"nmailui: invalid message list start parameter");
   273         NM_ERROR(1,"nmailui: invalid message list start parameter");
   266         // Unused start parameter needs to be deleted
   274         // Unused start parameter needs to be deleted
   267         delete startParam;
   275         delete startParam;
   277     NM_FUNCTION;
   285     NM_FUNCTION;
   278 
   286 
   279     return NmUiViewMessageList;
   287     return NmUiViewMessageList;
   280 }
   288 }
   281 
   289 
   282 /*!
   290 
   283     Refresh list
   291 /*!
       
   292     Refresh the message list.
   284 */
   293 */
   285 void NmMessageListView::refreshList()
   294 void NmMessageListView::refreshList()
   286 {
   295 {
   287     NM_FUNCTION;
   296     NM_FUNCTION;
   288 
   297 
   289     if (mMessageListModel) {
   298     if (mMessageListModel) {
   290         NmId mailboxId = mMessageListModel->currentMailboxId();
   299         NmId mailboxId = mStartParam->mailboxId();
   291         // In each refresh, e.g. in folder change the UI signals
   300 
   292         // lower layer about the folder that has been opened.
   301         // In each refresh, e.g. in folder change the UI signals lower layer
       
   302         // about the folder that has been opened.
   293         if (mStartParam){
   303         if (mStartParam){
   294             mUiEngine.updateActiveFolder(mailboxId, mStartParam->folderId());
   304             mUiEngine.updateActiveFolder(mailboxId, mStartParam->folderId());
   295 
   305 
   296             NmFolderType folderType = mUiEngine.folderTypeById(mStartParam->mailboxId(),
   306             NmFolderType folderType(NmFolderInbox);
   297                                               mStartParam->folderId());
   307             if (mStartParam->folderId()!= 0){
   298             if (folderType == NmFolderInbox) { // If the new folder is an inbox, first automatic sync should be shown
   308                 folderType = mUiEngine.folderTypeById(mStartParam->mailboxId(),
       
   309                              mStartParam->folderId());
       
   310             }
       
   311 
       
   312             // If the new folder is an inbox, first automatic sync should be shown
       
   313             if (folderType == NmFolderInbox) {
   299                 mIsFirstSyncInMessageList = true;
   314                 mIsFirstSyncInMessageList = true;
   300             }
   315             }
   301         }
   316         }
   302 
   317 
   303         // Set item model to message list widget
   318         // Set item model to message list widget
   304         if (mMessageListWidget) {
   319         if (mMessageListWidget) {
   305             mMessageListWidget->setModel(static_cast<QStandardItemModel*>(mMessageListModel));
   320             mMessageListWidget->setModel(static_cast<QStandardItemModel*>(mMessageListModel));
       
   321 
   306             QObject::connect(mMessageListModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)),
   322             QObject::connect(mMessageListModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)),
   307                     this, SLOT(itemsAdded(const QModelIndex&,int,int)),Qt::UniqueConnection);
   323                 this, SLOT(itemsAdded(const QModelIndex&,int,int)),Qt::UniqueConnection);
   308             QObject::connect(mMessageListModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
   324             QObject::connect(mMessageListModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
   309                     this, SLOT(itemsRemoved()),Qt::UniqueConnection);
   325                 this, SLOT(itemsRemoved()),Qt::UniqueConnection);
   310             QObject::connect(mMessageListModel, SIGNAL(setNewParam(NmUiStartParam*)),
   326             QObject::connect(mMessageListModel, SIGNAL(setNewParam(NmUiStartParam*)),
   311                     this, SLOT(reloadViewContents(NmUiStartParam*)),Qt::UniqueConnection);
   327                 this, SLOT(reloadViewContents(NmUiStartParam*)),Qt::UniqueConnection);
   312 
   328 
   313             mPreviousModelCount=mMessageListModel->rowCount();
   329             mPreviousModelCount=mMessageListModel->rowCount();
   314             if (mPreviousModelCount==0){
   330 
       
   331             if (mPreviousModelCount == 0) {
   315                 showNoMessagesText();
   332                 showNoMessagesText();
   316             }
   333             }
   317             else{
   334             else {
   318                 hideNoMessagesText();
   335                 hideNoMessagesText();
   319             }
   336             }
   320         }
   337         }
   321     }
   338 
   322 }
   339         // Notify the mail agent. 
       
   340         NmUiEventsNotifier::notifyViewStateChanged(NmUiEventsNotifier::NmViewShownEvent,
       
   341                                                    NmUiViewMessageList,
       
   342                                                    mStartParam->mailboxId());
       
   343     }
       
   344 }
       
   345 
   323 
   346 
   324 /*!
   347 /*!
   325     Sync state event handling
   348     Sync state event handling
   326 */
   349 */
   327 void NmMessageListView::handleSyncStateEvent(NmSyncState syncState, const NmId &mailboxId)
   350 void NmMessageListView::handleSyncStateEvent(NmSyncState syncState, const NmId &mailboxId)
   338                 mStartParam->setFolderId(folderId);
   361                 mStartParam->setFolderId(folderId);
   339             }
   362             }
   340             // Show sync icon only for the first automatic sync after opening message list.
   363             // Show sync icon only for the first automatic sync after opening message list.
   341             // Sync icon for manual sync is shown in NmUiEngine::refreshMailbox, not here.
   364             // Sync icon for manual sync is shown in NmUiEngine::refreshMailbox, not here.
   342             if (mIsFirstSyncInMessageList) {
   365             if (mIsFirstSyncInMessageList) {
   343 				mUiEngine.enableSyncIndicator(true);
   366                 // Show the indicator only if the application is in the foreground
       
   367                 if (mApplication.isForeground()) {
       
   368                     mUiEngine.enableSyncIndicator(true);
       
   369                 }
   344                 mIsFirstSyncInMessageList = false;
   370                 mIsFirstSyncInMessageList = false;
   345             }
   371             }
   346         }
   372         }
   347     }
   373     }
   348 }
   374 }
   361         // Create start params
   387         // Create start params
   362         NmUiStartParam* startParam = new NmUiStartParam(NmUiViewMessageList,
   388         NmUiStartParam* startParam = new NmUiStartParam(NmUiViewMessageList,
   363                                                         mSelectedMailboxId,
   389                                                         mSelectedMailboxId,
   364                                                         mSelectedFolderId);
   390                                                         mSelectedFolderId);
   365         // Store active folder type
   391         // Store active folder type
   366         mCurrentFolderType = mUiEngine.folderTypeById(startParam->mailboxId(),startParam->folderId());
   392         mCurrentFolderType=NmFolderInbox;
       
   393         if (startParam->folderId()!=0){
       
   394             mCurrentFolderType = mUiEngine.folderTypeById(startParam->mailboxId(),startParam->folderId());        
       
   395         }
   367         // Reload view, ownership of the startparams is passed and old startparams
   396         // Reload view, ownership of the startparams is passed and old startparams
   368         // are deleted within reloadViewContents function
   397         // are deleted within reloadViewContents function
   369         reloadViewContents(startParam);
   398         reloadViewContents(startParam);
   370         // Set folder text to status bar
   399         // Set folder text to status bar
   371         setFolderName();
   400         setFolderName();