emailuis/nmailui/src/nmmessagesearchlistview.cpp
changeset 43 99bcbff212ad
parent 40 2c62ef3caffd
child 48 10eaf342f539
child 54 997a02608b3a
equal deleted inserted replaced
42:139d4b7b2938 43:99bcbff212ad
    17 
    17 
    18 static const char *NMUI_MESSAGE_SEARCH_LIST_VIEW_XML = ":/docml/nmmessagesearchlistview.docml";
    18 static const char *NMUI_MESSAGE_SEARCH_LIST_VIEW_XML = ":/docml/nmmessagesearchlistview.docml";
    19 static const char *NMUI_MESSAGE_SEARCH_LIST_VIEW = "NmMessageListView";
    19 static const char *NMUI_MESSAGE_SEARCH_LIST_VIEW = "NmMessageListView";
    20 static const char *NMUI_MESSAGE_SEARCH_LIST_TREE_LIST = "MessageTreeList";
    20 static const char *NMUI_MESSAGE_SEARCH_LIST_TREE_LIST = "MessageTreeList";
    21 static const char *NMUI_MESSAGE_SEARCH_LIST_NO_MESSAGES = "MessageListNoMessages";
    21 static const char *NMUI_MESSAGE_SEARCH_LIST_NO_MESSAGES = "MessageListNoMessages";
    22 static const char *NMUI_MESSAGE_SEARCH_LIST_INFO_LABEL = "InfoLabel";
    22 static const char *NMUI_MESSAGE_SEARCH_LIST_INFO_LABEL = "LabelGroupBox";
    23 static const char *NMUI_MESSAGE_SEARCH_LIST_LINE_EDIT = "LineEdit";
    23 static const char *NMUI_MESSAGE_SEARCH_LIST_LINE_EDIT = "LineEdit";
    24 static const char *NMUI_MESSAGE_SEARCH_LIST_PUSH_BUTTON = "PushButton";
    24 static const char *NMUI_MESSAGE_SEARCH_LIST_PUSH_BUTTON = "PushButton";
    25 
    25 
    26 
    26 
    27 #include "nmuiheaders.h"
    27 #include "nmuiheaders.h"
    56   mPushButton(NULL),
    56   mPushButton(NULL),
    57   mLongPressedItem(NULL),
    57   mLongPressedItem(NULL),
    58   mViewReady(false),
    58   mViewReady(false),
    59   mSearchInProgress(false)
    59   mSearchInProgress(false)
    60 {
    60 {
       
    61     NM_FUNCTION;
       
    62     
    61     loadViewLayout();
    63     loadViewLayout();
    62     initTreeView();
    64     initTreeView();
    63 }
    65 }
    64 
    66 
    65 
    67 
    66 /*!
    68 /*!
    67     Class destructor.
    69     Class destructor.
    68 */
    70 */
    69 NmMessageSearchListView::~NmMessageSearchListView()
    71 NmMessageSearchListView::~NmMessageSearchListView()
    70 {
    72 {
       
    73     NM_FUNCTION;
       
    74     
    71     delete mDocumentLoader;
    75     delete mDocumentLoader;
    72 
    76 
    73     mWidgetList.clear();
    77     mWidgetList.clear();
    74 
    78 
    75     if (mItemContextMenu){
    79     if (mItemContextMenu){
    87 
    91 
    88     \return The view ID.
    92     \return The view ID.
    89 */
    93 */
    90 NmUiViewId NmMessageSearchListView::nmailViewId() const
    94 NmUiViewId NmMessageSearchListView::nmailViewId() const
    91 {
    95 {
       
    96     NM_FUNCTION;
       
    97     
    92     return NmUiViewMessageSearchList;
    98     return NmUiViewMessageSearchList;
    93 }
    99 }
    94 
   100 
    95 
   101 
    96 /*!
   102 /*!
    98 
   104 
    99     Does the lazy loading after the view layout has been loaded.
   105     Does the lazy loading after the view layout has been loaded.
   100 */
   106 */
   101 void NmMessageSearchListView::viewReady()
   107 void NmMessageSearchListView::viewReady()
   102 {
   108 {
       
   109     NM_FUNCTION;
       
   110     
   103     if (!mViewReady){
   111     if (!mViewReady){
   104         // Set the mailbox name to the title pane.
   112         // Set the mailbox name to the title pane.
   105         setViewTitle();
   113         setViewTitle();
   106 
   114 
   107         // Refresh the list.
   115         // Refresh the list.
   123 
   131 
   124     \param actionResponse The command details.
   132     \param actionResponse The command details.
   125 */
   133 */
   126 void NmMessageSearchListView::handleActionCommand(NmActionResponse &actionResponse)
   134 void NmMessageSearchListView::handleActionCommand(NmActionResponse &actionResponse)
   127 {
   135 {
       
   136     NM_FUNCTION;
       
   137     
   128     // Handle options menu commands here.
   138     // Handle options menu commands here.
   129     if (actionResponse.menuType() == NmActionOptionsMenu) {
   139     if (actionResponse.menuType() == NmActionOptionsMenu) {
   130         switch (actionResponse.responseCommand()) {
   140         switch (actionResponse.responseCommand()) {
   131             case NmActionResponseCommandUpdateMailboxName: {
   141             case NmActionResponseCommandUpdateMailboxName: {
   132                 setViewTitle();
   142                 setViewTitle();
   143     }
   153     }
   144     // Handle context menu commands here.
   154     // Handle context menu commands here.
   145     if (actionResponse.menuType() == NmActionContextMenu) {
   155     if (actionResponse.menuType() == NmActionContextMenu) {
   146         if (mLongPressedItem){
   156         if (mLongPressedItem){
   147             NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageViewer,
   157             NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageViewer,
   148                 mStartParam->mailboxId(), mStartParam->folderId(),
   158                 mStartParam->mailboxId(), mLongPressedItem->envelope().folderId(),
   149                 mLongPressedItem->envelope().messageId());
   159                 mLongPressedItem->envelope().messageId());
   150 
   160 
   151             mApplication.enterNmUiView(startParam);
   161             mApplication.enterNmUiView(startParam);
   152             mLongPressedItem = NULL;
   162             mLongPressedItem = NULL;
   153        }
   163        }
   160 
   170 
   161     Loads the view layout from the XML file.
   171     Loads the view layout from the XML file.
   162 */
   172 */
   163 void NmMessageSearchListView::loadViewLayout()
   173 void NmMessageSearchListView::loadViewLayout()
   164 {
   174 {
       
   175     NM_FUNCTION;
       
   176     
   165     // Use the document loader to load the view layout.
   177     // Use the document loader to load the view layout.
   166     bool ok(false);
   178     bool ok(false);
   167     setObjectName(QString(NMUI_MESSAGE_SEARCH_LIST_VIEW));
   179     setObjectName(QString(NMUI_MESSAGE_SEARCH_LIST_VIEW));
   168     QObjectList objectList;
   180     QObjectList objectList;
   169     objectList.append(this);
   181     objectList.append(this);
   179         // Get the message list widget.
   191         // Get the message list widget.
   180         mMessageListWidget = qobject_cast<HbTreeView *>(
   192         mMessageListWidget = qobject_cast<HbTreeView *>(
   181             mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_TREE_LIST));
   193             mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_TREE_LIST));
   182 
   194 
   183         if (mMessageListWidget) {
   195         if (mMessageListWidget) {
   184             NMLOG("NmMessageSearchListView: Message list widget loaded.");
   196             NM_COMMENT("NmMessageSearchListView: message list widget loaded");
   185 
   197 
   186             // Set the item prototype.
   198             // Set the item prototype.
   187             mMessageListWidget->setItemPrototype(new NmMessageListViewItem());
   199             mMessageListWidget->setItemPrototype(new NmMessageListViewItem());
       
   200 
       
   201             // Set the list widget properties.
   188             mMessageListWidget->setItemRecycling(true);
   202             mMessageListWidget->setItemRecycling(true);
   189             mMessageListWidget->contentWidget()->setProperty("indentation", 0);
   203             mMessageListWidget->contentWidget()->setProperty("indentation", 0);
   190             mMessageListWidget->setScrollDirections(Qt::Vertical);
   204             mMessageListWidget->setScrollDirections(Qt::Vertical);
   191             mMessageListWidget->setClampingStyle(HbScrollArea::BounceBackClamping);
   205             mMessageListWidget->setClampingStyle(HbScrollArea::BounceBackClamping);
   192             mMessageListWidget->setFrictionEnabled(true);
   206             mMessageListWidget->setFrictionEnabled(true);
       
   207 
       
   208             // We want the search results to appear one by one.
       
   209             mMessageListWidget->setEnabledAnimations(HbAbstractItemView::Appear &
       
   210                                                      HbAbstractItemView::Expand);
   193         }
   211         }
   194 
   212 
   195         // Load the info label.
   213         // Load the info label.
   196         mInfoLabel = qobject_cast<HbLabel *>(
   214         mInfoLabel = qobject_cast<HbGroupBox *>(
   197             mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_INFO_LABEL));
   215             mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_INFO_LABEL));
   198 
   216 
   199         if (mInfoLabel) {
   217         if (mInfoLabel) {
   200             NMLOG("NmMessageSearchListView: Info label loaded.");
   218             NM_COMMENT("NmMessageSearchListView: info label loaded");
   201             mInfoLabel->setPlainText(hbTrId("txt_mail_subhead_inbox"));
       
   202             mInfoLabel->hide();
   219             mInfoLabel->hide();
   203         }
   220         }
   204 
   221 
   205         // Load the no messages label.
   222         // Load the no messages label.
   206         mNoMessagesLabel = qobject_cast<HbLabel *>(
   223         mNoMessagesLabel = qobject_cast<HbLabel *>(
   228             connect(mPushButton, SIGNAL(clicked()), this, SLOT(toggleSearch()));
   245             connect(mPushButton, SIGNAL(clicked()), this, SLOT(toggleSearch()));
   229             mPushButton->setIcon(HbIcon("qtg_mono_search"));
   246             mPushButton->setIcon(HbIcon("qtg_mono_search"));
   230         }
   247         }
   231     }
   248     }
   232     else {
   249     else {
   233         NMLOG("NmMessageSearchListView: Failed to load widgets from XML!");
   250         NM_ERROR(1, "NmMessageSearchListView: failed to load widgets from XML");
   234     }
   251     }
   235 }
   252 }
   236 
   253 
   237 
   254 
   238 /*!
   255 /*!
   239     Initializes the tree view.
   256     Initializes the tree view.
   240 */
   257 */
   241 void NmMessageSearchListView::initTreeView()
   258 void NmMessageSearchListView::initTreeView()
   242 {
   259 {
       
   260     NM_FUNCTION;
       
   261     
   243     // Get the mailbox widget pointer and set the parameters.
   262     // Get the mailbox widget pointer and set the parameters.
   244     if (mMessageListWidget) {
   263     if (mMessageListWidget) {
   245         connect(mMessageListWidget, SIGNAL(activated(const QModelIndex &)),
   264         connect(mMessageListWidget, SIGNAL(activated(const QModelIndex &)),
   246                 this, SLOT(itemActivated(const QModelIndex &)));
   265                 this, SLOT(itemActivated(const QModelIndex &)));
   247 
   266 
   260 /*!
   279 /*!
   261     Sets the title according to the name of the current mailbox.
   280     Sets the title according to the name of the current mailbox.
   262 */
   281 */
   263 void NmMessageSearchListView::setViewTitle()
   282 void NmMessageSearchListView::setViewTitle()
   264 {
   283 {
       
   284     NM_FUNCTION;
       
   285     
   265     if (mStartParam){
   286     if (mStartParam){
   266         NmMailboxMetaData *meta = mUiEngine.mailboxById(mStartParam->mailboxId());
   287         NmMailboxMetaData *meta = mUiEngine.mailboxById(mStartParam->mailboxId());
   267 
   288 
   268         if (meta){
   289         if (meta){
   269             setTitle(meta->name());
   290             setTitle(meta->name());
   279     \param visible If true, will display the "no messages" label. If false,
   300     \param visible If true, will display the "no messages" label. If false,
   280                    will display the message list widget.
   301                    will display the message list widget.
   281 */
   302 */
   282 void NmMessageSearchListView::noMessagesLabelVisibility(bool visible)
   303 void NmMessageSearchListView::noMessagesLabelVisibility(bool visible)
   283 {
   304 {
       
   305     NM_FUNCTION;
       
   306     
   284     if (visible) {
   307     if (visible) {
   285         // Hide the message list widget and display the "no messages" label.
   308         // Hide the message list widget and display the "no messages" label.
   286         if (mMessageListWidget) {
   309         if (mMessageListWidget) {
   287             mMessageListWidget->hide();
   310             mMessageListWidget->hide();
   288         }
   311         }
   303     }
   326     }
   304 }
   327 }
   305 
   328 
   306 
   329 
   307 /*!
   330 /*!
       
   331     Updates the search result count information. If the message list does not
       
   332     contain any items, a "no messages" label is displayed. Otherwise the result
       
   333     count in the information label is updated according to the number of
       
   334     messages in the list.
       
   335 */
       
   336 void NmMessageSearchListView::updateSearchResultCountInfo()
       
   337 {
       
   338     NM_FUNCTION;
       
   339 
       
   340     const int resultCount = mMsgListModel.rowCount();
       
   341 
       
   342     if (resultCount) {
       
   343         if (mInfoLabel) {
       
   344             // Display the result count on the info label.
       
   345             QString resultsString(hbTrId("txt_mail_list_search_results").arg(resultCount));
       
   346             mInfoLabel->setHeading(resultsString);
       
   347 
       
   348             if (!mInfoLabel->isVisible()) {
       
   349                 mInfoLabel->show();
       
   350             }
       
   351         }
       
   352     }
       
   353     else {
       
   354         // No search results!
       
   355         if (mInfoLabel && mInfoLabel->isVisible()) {
       
   356             mInfoLabel->hide();
       
   357         }
       
   358 
       
   359         // Display the "no messages" label and highlight the search term.
       
   360         noMessagesLabelVisibility(true);
       
   361     }
       
   362     
       
   363 }
       
   364 
       
   365 
       
   366 /*!
   308     Sets the mode for the search input.
   367     Sets the mode for the search input.
   309 
   368 
   310     \param mode The mode to set.
   369     \param mode The mode to set.
   311 */
   370 */
   312 void NmMessageSearchListView::setSearchInputMode(NmSearchInputMode mode)
   371 void NmMessageSearchListView::setSearchInputMode(NmSearchInputMode mode)
   313 {
   372 {
       
   373     NM_FUNCTION;
       
   374     
   314     if (!mLineEdit) {
   375     if (!mLineEdit) {
   315         // No line edit widget!
   376         // No line edit widget!
   316         return;
   377         return;
   317     }
   378     }
   318 
   379 
   341     typically used when the view is already open and an external view activation
   402     typically used when the view is already open and an external view activation
   342     occurs for this same view.
   403     occurs for this same view.
   343 */
   404 */
   344 void NmMessageSearchListView::reloadViewContents(NmUiStartParam *startParam)
   405 void NmMessageSearchListView::reloadViewContents(NmUiStartParam *startParam)
   345 {
   406 {
   346     // Check the start parameter's validity; message view cannot be updated if
   407     NM_FUNCTION;
   347     // the given parameter is zero.
   408     
   348     if (startParam&&startParam->viewId() == NmUiViewMessageSearchList &&
   409     if (startParam && startParam->viewId() == NmUiViewMessageSearchList) {
   349         startParam->folderId() != 0) {
       
   350         // Delete the existing start parameter data.
   410         // Delete the existing start parameter data.
   351         delete mStartParam;
   411         delete mStartParam;
   352         mStartParam = NULL;
   412         mStartParam = NULL;
   353 
   413 
   354         // Store the new start parameter data.
   414         // Store the new start parameter data.
   362         setViewTitle();
   422         setViewTitle();
   363     }
   423     }
   364     else {
   424     else {
   365         // Invalid start parameter data! Unused start parameter needs to be
   425         // Invalid start parameter data! Unused start parameter needs to be
   366         // deleted.
   426         // deleted.
   367         NMLOG("NmMessageSearchListView: Invalid message list start parameter!");
   427         NM_ERROR(1, "NmMessageSearchListView: invalid message list start parameter");
   368         delete startParam;
   428         delete startParam;
   369     }
   429     }
   370 }
   430 }
   371 
   431 
   372 
   432 
   377     
   437     
   378     \param text The text in the field after the modification.
   438     \param text The text in the field after the modification.
   379 */
   439 */
   380 void NmMessageSearchListView::criteriaChanged(QString text) 
   440 void NmMessageSearchListView::criteriaChanged(QString text) 
   381 {
   441 {
   382     NMLOG(QString("NmMessageSearchListView::criteriaChanged %1").arg(text));
   442     NM_FUNCTION;
       
   443     NM_COMMENT(QString("NmMessageSearchListView::criteriaChanged %1").arg(text));
   383     
   444     
   384     // Check if the button should be disabled/enabled.
   445     // Check if the button should be disabled/enabled.
   385     bool enabled = mPushButton->isEnabled();
   446     bool enabled = mPushButton->isEnabled();
   386 
   447 
   387     if (!enabled && !text.isEmpty()) {
   448     if (!enabled && !text.isEmpty()) {
   398     list is long pressed.
   459     list is long pressed.
   399 */
   460 */
   400 void NmMessageSearchListView::showItemContextMenu(
   461 void NmMessageSearchListView::showItemContextMenu(
   401     HbAbstractViewItem *listViewItem, const QPointF &coords)
   462     HbAbstractViewItem *listViewItem, const QPointF &coords)
   402 {
   463 {
       
   464     NM_FUNCTION;
       
   465     
   403     // Store long press item for later use with response.
   466     // Store long press item for later use with response.
   404     mLongPressedItem = 
   467     mLongPressedItem = 
   405         mMsgListModel.data(listViewItem->modelIndex(),
   468         mMsgListModel.data(listViewItem->modelIndex(),
   406                            Qt::DisplayRole).value<NmMessageListModelItem*>();
   469                            Qt::DisplayRole).value<NmMessageListModelItem*>();
   407 
   470 
   415         // Fetch the menu actions based on the selected item.
   478         // Fetch the menu actions based on the selected item.
   416         NmMessageEnvelope *envelope = mLongPressedItem->envelopePtr();
   479         NmMessageEnvelope *envelope = mLongPressedItem->envelopePtr();
   417 
   480 
   418         if (envelope){
   481         if (envelope){
   419             NmActionRequest request(this, NmActionContextMenu,
   482             NmActionRequest request(this, NmActionContextMenu,
   420                 NmActionContextViewMessageList, NmActionContextDataMessage,
   483                 NmActionContextViewMessageSearchList, NmActionContextDataMessage,
   421                 mStartParam->mailboxId(), mStartParam->folderId(),
   484                 mStartParam->mailboxId(), envelope->folderId(),
   422                 envelope->messageId(),QVariant::fromValue(envelope));
   485                 envelope->messageId(), QVariant::fromValue(envelope));
   423 
       
   424             extMngr.getActions(request, list);
       
   425         }
       
   426         else{
       
   427             NmActionRequest request(this, NmActionContextMenu,
       
   428                 NmActionContextViewMessageList, NmActionContextDataMessage,
       
   429                 mStartParam->mailboxId(), mStartParam->folderId(),
       
   430                 envelope->messageId());
       
   431 
   486 
   432             extMngr.getActions(request, list);
   487             extMngr.getActions(request, list);
   433         }
   488         }
   434 
   489 
   435         for (int i(0); i < list.count(); ++i) {
   490         for (int i(0); i < list.count(); ++i) {
   448 
   503 
   449     \param index The index of the activated item.
   504     \param index The index of the activated item.
   450 */
   505 */
   451 void NmMessageSearchListView::itemActivated(const QModelIndex &index)
   506 void NmMessageSearchListView::itemActivated(const QModelIndex &index)
   452 {
   507 {
       
   508     NM_FUNCTION;
       
   509     
   453     mActivatedIndex = index;
   510     mActivatedIndex = index;
   454     QMetaObject::invokeMethod(this, "handleSelection", Qt::QueuedConnection);
   511     QMetaObject::invokeMethod(this, "handleSelection", Qt::QueuedConnection);
   455 }
   512 }
   456 
   513 
   457 
   514 
   458 /*!
   515 /*!
   459     If the selected item is a message, will open the message.
   516     If the selected item is a message, will open the message.
   460 */
   517 */
   461 void NmMessageSearchListView::handleSelection()
   518 void NmMessageSearchListView::handleSelection()
   462 {
   519 {
       
   520     NM_FUNCTION;
       
   521     
   463     // Do expand/collapse for title divider items
   522     // Do expand/collapse for title divider items
   464     NmMessageListModelItem* modelItem = mMsgListModel.data(
   523     NmMessageListModelItem* modelItem = mMsgListModel.data(
   465         mActivatedIndex, Qt::DisplayRole).value<NmMessageListModelItem*>();
   524         mActivatedIndex, Qt::DisplayRole).value<NmMessageListModelItem*>();
   466 
   525 
   467     if (modelItem &&
   526     if (modelItem &&
   472             toggleSearch();
   531             toggleSearch();
   473         }
   532         }
   474 
   533 
   475         // Open the message.
   534         // Open the message.
   476         NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageViewer,
   535         NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageViewer,
   477             mStartParam->mailboxId(), mStartParam->folderId(),
   536             mStartParam->mailboxId(), modelItem->envelope().folderId(),
   478             modelItem->envelope().messageId());
   537             modelItem->envelope().messageId());
   479 
   538 
   480         mApplication.enterNmUiView(startParam);
   539         mApplication.enterNmUiView(startParam);
   481     }
   540     }
   482 }
   541 }
   486     Displays the message list widtet if not visible and scrolls to the
   545     Displays the message list widtet if not visible and scrolls to the
   487     appropriate point on the list.
   546     appropriate point on the list.
   488 */
   547 */
   489 void NmMessageSearchListView::itemsAdded(const QModelIndex &parent, int start, int end)
   548 void NmMessageSearchListView::itemsAdded(const QModelIndex &parent, int start, int end)
   490 {
   549 {
   491     NMLOG("nmailui: NmMessageSearchListView::itemsAdded()");
   550     NM_FUNCTION;
   492 
   551     
   493     Q_UNUSED(parent);
   552     Q_UNUSED(parent);
   494     Q_UNUSED(end);
   553     Q_UNUSED(end);
   495 
   554 
   496     // Display the message list widget if not visible.
   555     // The search is an asynchronous operation. If a user stops the search, it
   497     noMessagesLabelVisibility(false);
   556     // might take a short while before the search is actually stopped and during
       
   557     // this time it is possible that messages matching the search are added.
       
   558     // Therefore, update the result count info if items are added after the
       
   559     // search has been stopped by the user.
       
   560     if (!mSearchInProgress) {
       
   561         updateSearchResultCountInfo();
       
   562     }
   498 
   563 
   499     if (!start && mMessageListWidget) {
   564     if (!start && mMessageListWidget) {
   500         QList<HbAbstractViewItem*> items = mMessageListWidget->visibleItems();
   565         QList<HbAbstractViewItem*> items = mMessageListWidget->visibleItems();
   501 
   566 
   502         if (items.count()) {
   567         if (items.count()) {
   503             QModelIndex index = items.at(0)->modelIndex();
   568             QModelIndex index = items.at(0)->modelIndex();
   504 
   569 
   505             if (1 == index.row()) {
   570             while (index.row() > 0) {
   506                 QModelIndex previous = mMessageListWidget->modelIterator()->previousIndex(index);
   571                 QModelIndex previous =
       
   572                     mMessageListWidget->modelIterator()->previousIndex(index);
   507 
   573 
   508                 if (previous.isValid()) {
   574                 if (previous.isValid()) {
   509                     mMessageListWidget->scrollTo(previous);
   575                     mMessageListWidget->scrollTo(previous);
   510                 }
   576                 }
       
   577 
       
   578                 index = previous;
   511             }
   579             }
   512         }
   580         }
   513     }
   581     }
   514 }
   582 }
   515 
   583 
   516 
   584 
   517 /*!
   585 /*!
   518     This method gets called when an item is removed from the list. If the list
   586     This method gets called when an item is removed from the list. If the
   519     contains no items, the info label (if visible) is hidden and the "no
   587     search has completed (or stopped), the search result count information is
   520     messages" label is displayed. Otherwise, only the result count in the info
   588     updated according to the number of messages in the list.
   521     label is updated.
       
   522 */
   589 */
   523 void NmMessageSearchListView::itemsRemoved()
   590 void NmMessageSearchListView::itemsRemoved()
   524 {
   591 {
   525     const int itemCount = mMsgListModel.rowCount();
   592     NM_FUNCTION;
   526 
   593     
   527     if (itemCount == 0) {
   594     if (!mSearchInProgress) {
   528         if (mInfoLabel && mInfoLabel->isVisible()) {
   595         updateSearchResultCountInfo();
   529             // Hide the info label.
       
   530             mInfoLabel->hide();
       
   531         }
       
   532 
       
   533         // Display the "no messages" label.
       
   534         noMessagesLabelVisibility(true);
       
   535     }
       
   536     else if (mInfoLabel && mInfoLabel->isVisible()) {
       
   537         // Update the search result count in the info label.
       
   538         QString resultsString(hbTrId("txt_mail_list_search_results"));
       
   539         resultsString.arg(itemCount);
       
   540         mInfoLabel->setPlainText(resultsString);
       
   541     }
   596     }
   542 }
   597 }
   543 
   598 
   544 
   599 
   545 /*!
   600 /*!
   546     Refreshes the search list.
   601     Refreshes the search list.
   547 */
   602 */
   548 void NmMessageSearchListView::refreshList()
   603 void NmMessageSearchListView::refreshList()
   549 {
   604 {
       
   605     NM_FUNCTION;
       
   606     
   550     if (mMessageListWidget) {
   607     if (mMessageListWidget) {
   551         // Set the model.
   608         // Set the model.
   552         mMessageListWidget->setModel(
   609         mMessageListWidget->setModel(
   553             static_cast<QStandardItemModel*>(&mMsgListModel));
   610             static_cast<QStandardItemModel*>(&mMsgListModel));
   554 
   611 
   575 
   632 
   576     Stops search: Sets the number of search results into the info label.
   633     Stops search: Sets the number of search results into the info label.
   577 */
   634 */
   578 void NmMessageSearchListView::toggleSearch()
   635 void NmMessageSearchListView::toggleSearch()
   579 {
   636 {
       
   637     NM_FUNCTION;
       
   638     
   580     if (mSearchInProgress) {
   639     if (mSearchInProgress) {
   581         // Search is in progress - do cancel.
   640         // Search is in progress - do cancel.
   582         mUiEngine.cancelSearch(mStartParam->mailboxId());
   641         mUiEngine.cancelSearch(mStartParam->mailboxId());
   583         handleSearchComplete();
   642         handleSearchComplete();
   584     }
   643     }
   605         noMessagesLabelVisibility(false);
   664         noMessagesLabelVisibility(false);
   606         setSearchInputMode(NmDimmedMode);
   665         setSearchInputMode(NmDimmedMode);
   607 
   666 
   608         // Display the info label.
   667         // Display the info label.
   609         if (mInfoLabel) {
   668         if (mInfoLabel) {
   610             mInfoLabel->setPlainText(hbTrId("txt_mail_list_searching"));
   669             mInfoLabel->setHeading(hbTrId("txt_mail_list_searching"));
   611             mInfoLabel->show();
   670             mInfoLabel->show();
   612         }
   671         }
   613 
   672 
   614         // Change the push button text.
   673         // Change the push button text.
   615         if (mPushButton) {
   674         if (mPushButton) {
   624     info label. If no messages were found, the method displays the "no messages"
   683     info label. If no messages were found, the method displays the "no messages"
   625     label. In either case, the search panel is updated.
   684     label. In either case, the search panel is updated.
   626 */
   685 */
   627 void NmMessageSearchListView::handleSearchComplete()
   686 void NmMessageSearchListView::handleSearchComplete()
   628 {
   687 {
   629     NMLOG("NmMessageSearchListView::handleSearchComplete()");
   688     NM_FUNCTION;
       
   689     
   630     mSearchInProgress = false;
   690     mSearchInProgress = false;
   631     
   691     
   632     // Change the push button text.
   692     // Change the push button text.
   633     if (mPushButton) {
   693     if (mPushButton) {
   634         mPushButton->setIcon(HbIcon("qtg_mono_search"));
   694         mPushButton->setIcon(HbIcon("qtg_mono_search"));
   635     }
   695     }
   636 
   696 
       
   697     // Display the search result count.
       
   698     updateSearchResultCountInfo();
       
   699 
   637     const int resultCount = mMsgListModel.rowCount();
   700     const int resultCount = mMsgListModel.rowCount();
   638 
   701 
   639     if (resultCount) {
   702     if (resultCount) {
   640         if (mInfoLabel) {
       
   641             // Display the result count on the info label.
       
   642             QString resultsString(hbTrId("txt_mail_list_search_results"));
       
   643             resultsString.arg(resultCount);
       
   644             mInfoLabel->setPlainText(resultsString);
       
   645 
       
   646             if (!mInfoLabel->isVisible()) {
       
   647                 mInfoLabel->show();
       
   648             }
       
   649         }
       
   650 
       
   651         // Undim the search input.
   703         // Undim the search input.
   652         setSearchInputMode(NmNormalMode);
   704         setSearchInputMode(NmNormalMode);
   653     }
   705     }
   654     else {
   706     else {
   655         // No search results!
   707         // Highlight the search field.
   656         if (mInfoLabel && mInfoLabel->isVisible()) {
       
   657             mInfoLabel->hide();
       
   658         }
       
   659 
       
   660         // Display the "no messags" label and highlight the search term.
       
   661         noMessagesLabelVisibility(true);
   708         noMessagesLabelVisibility(true);
   662         setSearchInputMode(NmHighlightedMode);
   709         setSearchInputMode(NmHighlightedMode);
   663     }
   710     }
   664 }
   711 }
   665 
   712