diff -r 997a02608b3a -r 16ed8d08d0b1 emailuis/nmailui/src/nmmessagelistview.cpp --- a/emailuis/nmailui/src/nmmessagelistview.cpp Tue Jul 06 14:04:34 2010 +0300 +++ b/emailuis/nmailui/src/nmmessagelistview.cpp Wed Aug 18 09:37:47 2010 +0300 @@ -23,9 +23,7 @@ #include "nmuiheaders.h" -const QString syncIndicatorName = "com.nokia.nmail.indicatorplugin.sync/1.0"; - -/*! +/*! \class NmMessageListView \brief Message list view */ @@ -148,6 +146,8 @@ // Menu needs one dummy item so that aboutToShow signal is emitted. NmAction *dummy = new NmAction(0); menu()->addAction(dummy); + // Set sync icon if needed + updateSyncIcon(); } else { NM_ERROR(1,"nmailui: resource loading failed"); @@ -204,7 +204,7 @@ */ void NmMessageListView::initTreeView() { - NM_FUNCTION; + NM_FUNCTION; // Get mailbox widget pointer and set parameters if (mMessageListWidget){ @@ -230,18 +230,36 @@ // Check start parameter validity, message view cannot // be updated if given parameter is zero. - if (startParam&&startParam->viewId()==NmUiViewMessageList&& + if (startParam&&startParam->viewId()==NmUiViewMessageList && startParam->folderId()!=0) { // Delete existing start parameter data delete mStartParam; - mStartParam=NULL; + mStartParam = NULL; // Store new start parameter data - mStartParam=startParam; - // Update the model with new parameters + mStartParam = startParam; + // Disconnect signals from previous model + QObject::disconnect(mMessageListModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)), + this, SLOT(itemsAdded(const QModelIndex&,int,int))); + QObject::disconnect(mMessageListModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)), + this, SLOT(itemsRemoved())); + QObject::disconnect(mMessageListModel, SIGNAL(setNewParam(NmUiStartParam*)), + this, SLOT(reloadViewContents(NmUiStartParam*))); + // Update model pointer and refresh mailbox with new model mMessageListModel = &mUiEngine.messageListModel(startParam->mailboxId(), startParam->folderId()); + refreshList(); - // Refresh the mailboxname + + // Refresh the mailbox name setMailboxName(); + + // Store active folder type + mCurrentFolderType = mUiEngine.folderTypeById(startParam->mailboxId(),startParam->folderId()); + + // Update folder name + setFolderName(); + + // Set sync icon if needed + updateSyncIcon(); } else { NM_ERROR(1,"nmailui: invalid message list start parameter"); @@ -250,7 +268,7 @@ } } - + /*! Return view id */ @@ -269,16 +287,16 @@ NM_FUNCTION; if (mMessageListModel) { - NmId mailboxId = mMessageListModel->currentMailboxId(); + NmId mailboxId = mMessageListModel->currentMailboxId(); // In each refresh, e.g. in folder change the UI signals // lower layer about the folder that has been opened. if (mStartParam){ mUiEngine.updateActiveFolder(mailboxId, mStartParam->folderId()); - + NmFolderType folderType = mUiEngine.folderTypeById(mStartParam->mailboxId(), mStartParam->folderId()); if (folderType == NmFolderInbox) { // If the new folder is an inbox, first automatic sync should be shown - mIsFirstSyncInMessageList = true; + mIsFirstSyncInMessageList = true; } } @@ -286,11 +304,11 @@ if (mMessageListWidget) { mMessageListWidget->setModel(static_cast(mMessageListModel)); QObject::connect(mMessageListModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)), - this, SLOT(itemsAdded(const QModelIndex&,int,int))); + this, SLOT(itemsAdded(const QModelIndex&,int,int)),Qt::UniqueConnection); QObject::connect(mMessageListModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)), - this, SLOT(itemsRemoved())); + this, SLOT(itemsRemoved()),Qt::UniqueConnection); QObject::connect(mMessageListModel, SIGNAL(setNewParam(NmUiStartParam*)), - this, SLOT(reloadViewContents(NmUiStartParam*))); + this, SLOT(reloadViewContents(NmUiStartParam*)),Qt::UniqueConnection); mPreviousModelCount=mMessageListModel->rowCount(); if (mPreviousModelCount==0){ @@ -299,14 +317,14 @@ else{ hideNoMessagesText(); } - } + } } } /*! Sync state event handling */ -void NmMessageListView::handleSyncStateEvent(NmSyncState syncState, const NmId & mailboxId) +void NmMessageListView::handleSyncStateEvent(NmSyncState syncState, const NmId &mailboxId) { NM_FUNCTION; if (mMessageListModel && mailboxId == mMessageListModel->currentMailboxId()) { @@ -322,15 +340,14 @@ // Show sync icon only for the first automatic sync after opening message list. // Sync icon for manual sync is shown in NmUiEngine::refreshMailbox, not here. if (mIsFirstSyncInMessageList) { - HbIndicator indicator; - indicator.activate(syncIndicatorName, QVariant()); + mUiEngine.enableSyncIndicator(true); mIsFirstSyncInMessageList = false; } } } } -/*! +/*! folder selection handling within current mailbox */ void NmMessageListView::folderSelected() @@ -350,24 +367,24 @@ // Reload view, ownership of the startparams is passed and old startparams // are deleted within reloadViewContents function reloadViewContents(startParam); - //Set folder text to status bar + // Set folder text to status bar setFolderName(); } } /*! - Long keypress handling + Long keypress handling */ void NmMessageListView::showItemContextMenu(HbAbstractViewItem *listViewItem, const QPointF &coords) { NM_FUNCTION; - + if (listViewItem) { // Recreate item context menu each time it is called if (mItemContextMenu){ mItemContextMenu->clearActions(); - delete mItemContextMenu; + delete mItemContextMenu; mItemContextMenu=NULL; } mItemContextMenu = new HbMenu(); @@ -612,7 +629,7 @@ { NM_FUNCTION; - if (mStartParam&&mFolderLabel){ + if (mStartParam && mFolderLabel){ switch (mCurrentFolderType) { case NmFolderOutbox: { @@ -650,7 +667,7 @@ visible and keeps the scroll position on the top of the list. \param parent Not used. - \param start + \param start \param end Not used. */ void NmMessageListView::itemsAdded(const QModelIndex &parent, int start, int end) @@ -688,7 +705,7 @@ } // Store model count if (mMessageListModel){ - mPreviousModelCount=mMessageListModel->rowCount(); + mPreviousModelCount=mMessageListModel->rowCount(); } } @@ -701,7 +718,7 @@ NM_FUNCTION; // Store model count if (mMessageListModel){ - mPreviousModelCount=mMessageListModel->rowCount(); + mPreviousModelCount=mMessageListModel->rowCount(); } if (mPreviousModelCount == 0){ showNoMessagesText(); @@ -734,3 +751,19 @@ } } +/*! + Updates sync icon based on sync status from the plugin. +*/ +void NmMessageListView::updateSyncIcon() +{ + if (mStartParam) { + NmSyncState syncState = mUiEngine.syncState(mStartParam->mailboxId()); + if (syncState==Synchronizing) { + mUiEngine.enableSyncIndicator(true); + } + else { + mUiEngine.enableSyncIndicator(false); + } + } +} +