|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 static const char *NMUI_MESSAGE_SEARCH_LIST_VIEW_XML = ":/docml/nmmessagesearchlistview.docml"; |
|
19 static const char *NMUI_MESSAGE_SEARCH_LIST_VIEW = "NmMessageListView"; |
|
20 static const char *NMUI_MESSAGE_SEARCH_LIST_TREE_LIST = "MessageTreeList"; |
|
21 static const char *NMUI_MESSAGE_SEARCH_LIST_NO_MESSAGES = "MessageListNoMessages"; |
|
22 static const char *NMUI_MESSAGE_SEARCH_LIST_INFO_LABEL = "InfoLabel"; |
|
23 static const char *NMUI_MESSAGE_SEARCH_LIST_LINE_EDIT = "LineEdit"; |
|
24 static const char *NMUI_MESSAGE_SEARCH_LIST_PUSH_BUTTON = "PushButton"; |
|
25 |
|
26 |
|
27 #include "nmuiheaders.h" |
|
28 |
|
29 |
|
30 /*! |
|
31 \class NmMessageSearchListView |
|
32 \brief The view for searching messages. |
|
33 */ |
|
34 |
|
35 |
|
36 /*! |
|
37 Class constructor. |
|
38 */ |
|
39 NmMessageSearchListView::NmMessageSearchListView( |
|
40 NmApplication &application, |
|
41 NmUiStartParam* startParam, |
|
42 NmUiEngine &uiEngine, |
|
43 NmMessageSearchListModel &searchListModel, |
|
44 HbDocumentLoader *documentLoader, |
|
45 QGraphicsItem *parent) |
|
46 : NmBaseView(startParam, parent), |
|
47 mApplication(application), |
|
48 mUiEngine(uiEngine), |
|
49 mSearchListModel(searchListModel), |
|
50 mDocumentLoader(documentLoader), |
|
51 mItemContextMenu(NULL), |
|
52 mMessageListWidget(NULL), |
|
53 mNoMessagesLabel(NULL), |
|
54 mInfoLabel(NULL), |
|
55 mLineEdit(NULL), |
|
56 mPushButton(NULL), |
|
57 mLongPressedItem(NULL), |
|
58 mViewReady(false), |
|
59 mSearchInProgress(false) |
|
60 { |
|
61 loadViewLayout(); |
|
62 initTreeView(); |
|
63 } |
|
64 |
|
65 |
|
66 /*! |
|
67 Class destructor. |
|
68 */ |
|
69 NmMessageSearchListView::~NmMessageSearchListView() |
|
70 { |
|
71 delete mDocumentLoader; |
|
72 |
|
73 mWidgetList.clear(); |
|
74 |
|
75 if (mItemContextMenu){ |
|
76 mItemContextMenu->clearActions(); |
|
77 } |
|
78 |
|
79 delete mItemContextMenu; |
|
80 } |
|
81 |
|
82 |
|
83 /*! |
|
84 From NmBaseView. |
|
85 |
|
86 Returns the view ID. |
|
87 |
|
88 \return The view ID. |
|
89 */ |
|
90 NmUiViewId NmMessageSearchListView::nmailViewId() const |
|
91 { |
|
92 return NmUiViewMessageSearchList; |
|
93 } |
|
94 |
|
95 |
|
96 /*! |
|
97 From NmBaseView. |
|
98 |
|
99 Does the lazy loading after the view layout has been loaded. |
|
100 */ |
|
101 void NmMessageSearchListView::viewReady() |
|
102 { |
|
103 if (!mViewReady){ |
|
104 // Set the mailbox name to the title pane. |
|
105 setViewTitle(); |
|
106 |
|
107 // Refresh the list. |
|
108 QMetaObject::invokeMethod(this, "refreshList", Qt::QueuedConnection); |
|
109 |
|
110 // Highlight the search input. |
|
111 setSearchInputMode(NmHighlightedMode); |
|
112 |
|
113 mViewReady = true; |
|
114 } |
|
115 } |
|
116 |
|
117 |
|
118 /*! |
|
119 From NmMenuObserver. |
|
120 |
|
121 Handles action commands which are usually given by the user by selecting |
|
122 menu items. |
|
123 |
|
124 \param actionResponse The command details. |
|
125 */ |
|
126 void NmMessageSearchListView::handleActionCommand(NmActionResponse &actionResponse) |
|
127 { |
|
128 // Handle options menu commands here. |
|
129 if (actionResponse.menuType() == NmActionOptionsMenu) { |
|
130 switch (actionResponse.responseCommand()) { |
|
131 case NmActionResponseCommandUpdateMailboxName: { |
|
132 setViewTitle(); |
|
133 break; |
|
134 } |
|
135 case NmActionResponseCommandMailboxDeleted: { |
|
136 mApplication.popView(); |
|
137 break; |
|
138 } |
|
139 default: { |
|
140 break; |
|
141 } |
|
142 } |
|
143 } |
|
144 } |
|
145 |
|
146 |
|
147 /*! |
|
148 From NmBaseView. |
|
149 |
|
150 Loads the view layout from the XML file. |
|
151 */ |
|
152 void NmMessageSearchListView::loadViewLayout() |
|
153 { |
|
154 // Use the document loader to load the view layout. |
|
155 bool ok(false); |
|
156 setObjectName(QString(NMUI_MESSAGE_SEARCH_LIST_VIEW)); |
|
157 QObjectList objectList; |
|
158 objectList.append(this); |
|
159 |
|
160 // Pass the view to the document loader. Instead of creating a new view, the |
|
161 // document loader uses this view when the docml file is parsed. |
|
162 if (mDocumentLoader) { |
|
163 mDocumentLoader->setObjectTree(objectList); |
|
164 mWidgetList = mDocumentLoader->load(NMUI_MESSAGE_SEARCH_LIST_VIEW_XML, &ok); |
|
165 } |
|
166 |
|
167 if (ok && mWidgetList.count()) { |
|
168 // Get the message list widget. |
|
169 mMessageListWidget = qobject_cast<HbTreeView *>( |
|
170 mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_TREE_LIST)); |
|
171 |
|
172 if (mMessageListWidget) { |
|
173 NMLOG("NmMessageSearchListView: Message list widget loaded."); |
|
174 |
|
175 // Set the item prototype. |
|
176 mMessageListWidget->setItemPrototype(new NmMessageListViewItem()); |
|
177 mMessageListWidget->setItemRecycling(true); |
|
178 mMessageListWidget->contentWidget()->setProperty("indentation", 0); |
|
179 mMessageListWidget->setScrollDirections(Qt::Vertical); |
|
180 mMessageListWidget->setClampingStyle(HbScrollArea::BounceBackClamping); |
|
181 mMessageListWidget->setFrictionEnabled(true); |
|
182 } |
|
183 |
|
184 // Load the "no messages" label. |
|
185 mNoMessagesLabel = qobject_cast<HbLabel *>( |
|
186 mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_NO_MESSAGES)); |
|
187 |
|
188 if (mNoMessagesLabel) { |
|
189 NMLOG("NmMessageSearchListView: \"No messages\" label loaded."); |
|
190 mNoMessagesLabel->hide(); |
|
191 } |
|
192 |
|
193 // Load the info label. |
|
194 mInfoLabel = qobject_cast<HbLabel *>( |
|
195 mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_INFO_LABEL)); |
|
196 |
|
197 if (mInfoLabel) { |
|
198 NMLOG("NmMessageSearchListView: Info label loaded."); |
|
199 mInfoLabel->setPlainText(hbTrId("txt_mail_subhead_inbox")); |
|
200 mInfoLabel->hide(); |
|
201 } |
|
202 |
|
203 // Load the search panel. |
|
204 mLineEdit = qobject_cast<HbLineEdit *>( |
|
205 mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_LINE_EDIT)); |
|
206 if (mLineEdit) { |
|
207 connect(mLineEdit, SIGNAL(textChanged(QString)), |
|
208 this, SLOT(criteriaChanged(QString))); |
|
209 } |
|
210 |
|
211 mPushButton = qobject_cast<HbPushButton *>( |
|
212 mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_PUSH_BUTTON)); |
|
213 if (mPushButton) { |
|
214 // button is disabled when line edit is empty |
|
215 mPushButton->setEnabled(false); |
|
216 // The push button both starts and stops the search. |
|
217 connect(mPushButton, SIGNAL(clicked()), this, SLOT(toggleSearch())); |
|
218 mPushButton->setIcon(HbIcon("qtg_mono_search")); |
|
219 } |
|
220 } |
|
221 else { |
|
222 NMLOG("NmMessageSearchListView: Failed to load widgets from XML!"); |
|
223 } |
|
224 } |
|
225 |
|
226 |
|
227 /*! |
|
228 Initializes the tree view. |
|
229 */ |
|
230 void NmMessageSearchListView::initTreeView() |
|
231 { |
|
232 // Get the mailbox widget pointer and set the parameters. |
|
233 if (mMessageListWidget) { |
|
234 connect(mMessageListWidget, SIGNAL(activated(const QModelIndex &)), |
|
235 this, SLOT(itemActivated(const QModelIndex &))); |
|
236 |
|
237 connect(mMessageListWidget, SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), |
|
238 this, SLOT(showItemContextMenu(HbAbstractViewItem*, QPointF))); |
|
239 |
|
240 mMessageListWidget->setFocus(); |
|
241 mItemContextMenu = new HbMenu(); |
|
242 } |
|
243 |
|
244 // Clear the previous content if any. |
|
245 mSearchListModel.clearSearchResults(); |
|
246 } |
|
247 |
|
248 |
|
249 /*! |
|
250 Sets the title according to the name of the current mailbox. |
|
251 */ |
|
252 void NmMessageSearchListView::setViewTitle() |
|
253 { |
|
254 if (mStartParam){ |
|
255 NmMailboxMetaData *meta = mUiEngine.mailboxById(mStartParam->mailboxId()); |
|
256 |
|
257 if (meta){ |
|
258 setTitle(meta->name()); |
|
259 } |
|
260 } |
|
261 } |
|
262 |
|
263 |
|
264 /*! |
|
265 Toggles the visiblity between the message list widget and the "no messages" |
|
266 label. |
|
267 |
|
268 \param visible If true, will display the "no messages" label. If false, |
|
269 will display the message list widget. |
|
270 */ |
|
271 void NmMessageSearchListView::noMessagesLabelVisibility(bool visible) |
|
272 { |
|
273 if (visible) { |
|
274 // Hide the message list widget and display the "no messages" label. |
|
275 if (mMessageListWidget) { |
|
276 mMessageListWidget->hide(); |
|
277 } |
|
278 |
|
279 if (mNoMessagesLabel && !mNoMessagesLabel->isVisible()) { |
|
280 mNoMessagesLabel->show(); |
|
281 } |
|
282 } |
|
283 else { |
|
284 // Hide the "no messages" label and display the message list widget. |
|
285 if (mNoMessagesLabel && mNoMessagesLabel->isVisible()) { |
|
286 mNoMessagesLabel->hide(); |
|
287 } |
|
288 |
|
289 if (mMessageListWidget) { |
|
290 mMessageListWidget->show(); |
|
291 } |
|
292 } |
|
293 } |
|
294 |
|
295 |
|
296 /*! |
|
297 Sets the mode for the search input. |
|
298 |
|
299 \param mode The mode to set. |
|
300 */ |
|
301 void NmMessageSearchListView::setSearchInputMode(NmSearchInputMode mode) |
|
302 { |
|
303 if (!mLineEdit) { |
|
304 // No line edit widget! |
|
305 return; |
|
306 } |
|
307 |
|
308 switch (mode) { |
|
309 case NmNormalMode: { |
|
310 mLineEdit->setEnabled(true); |
|
311 break; |
|
312 } |
|
313 case NmHighlightedMode: { |
|
314 mLineEdit->setEnabled(true); |
|
315 mLineEdit->setFocus(); |
|
316 break; |
|
317 } |
|
318 case NmDimmedMode: { |
|
319 mLineEdit->setEnabled(false); |
|
320 break; |
|
321 } |
|
322 } |
|
323 } |
|
324 |
|
325 |
|
326 /*! |
|
327 From NmBaseView. |
|
328 |
|
329 Reloads the view contents with new start parameters. This method is |
|
330 typically used when the view is already open and an external view activation |
|
331 occurs for this same view. |
|
332 */ |
|
333 void NmMessageSearchListView::reloadViewContents(NmUiStartParam *startParam) |
|
334 { |
|
335 // Check the start parameter's validity; message view cannot be updated if |
|
336 // the given parameter is zero. |
|
337 if (startParam&&startParam->viewId() == NmUiViewMessageSearchList && |
|
338 startParam->folderId() != 0) { |
|
339 // Delete the existing start parameter data. |
|
340 delete mStartParam; |
|
341 mStartParam = NULL; |
|
342 |
|
343 // Store the new start parameter data. |
|
344 mStartParam = startParam; |
|
345 |
|
346 // Update the model with new parameters. |
|
347 NmMessageListModel &messageListModel = |
|
348 mUiEngine.messageListModel(startParam->mailboxId(), |
|
349 startParam->folderId()); |
|
350 mSearchListModel.setSourceModel(&messageListModel); |
|
351 refreshList(); |
|
352 |
|
353 // Refresh the mailbox name. |
|
354 setViewTitle(); |
|
355 } |
|
356 else { |
|
357 // Invalid start parameter data! Unused start parameter needs to be |
|
358 // deleted. |
|
359 NMLOG("NmMessageSearchListView: Invalid message list start parameter!"); |
|
360 delete startParam; |
|
361 } |
|
362 } |
|
363 |
|
364 |
|
365 /*! |
|
366 Displays the item context menu. This method gets called if an item on the |
|
367 list is long pressed. |
|
368 */ |
|
369 void NmMessageSearchListView::showItemContextMenu( |
|
370 HbAbstractViewItem *listViewItem, const QPointF &coords) |
|
371 { |
|
372 // Store long press item for later use with response. |
|
373 mLongPressedItem = |
|
374 mSearchListModel.data(listViewItem->modelIndex(), |
|
375 Qt::DisplayRole).value<NmMessageListModelItem*>(); |
|
376 |
|
377 if (mItemContextMenu && mLongPressedItem && mLongPressedItem->itemType() == |
|
378 NmMessageListModelItem::NmMessageItemMessage) { |
|
379 // Clear the previous menu actions. |
|
380 mItemContextMenu->clearActions(); |
|
381 NmUiExtensionManager &extMngr = mApplication.extManager(); |
|
382 QList<NmAction*> list; |
|
383 |
|
384 // Fetch the menu actions based on the selected item. |
|
385 NmMessageEnvelope *envelope = mLongPressedItem->envelopePtr(); |
|
386 |
|
387 if (envelope){ |
|
388 NmActionRequest request(this, NmActionContextMenu, NmActionContextViewMessageList, |
|
389 NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(), |
|
390 envelope->messageId(),QVariant::fromValue(envelope)); |
|
391 |
|
392 extMngr.getActions(request, list); |
|
393 } |
|
394 else{ |
|
395 NmActionRequest request(this, NmActionContextMenu, NmActionContextViewMessageList, |
|
396 NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(), |
|
397 envelope->messageId()); |
|
398 |
|
399 extMngr.getActions(request, list); |
|
400 } |
|
401 |
|
402 for (int i(0); i < list.count(); ++i) { |
|
403 mItemContextMenu->addAction(list[i]); |
|
404 } |
|
405 mItemContextMenu->setPreferredPos(coords); |
|
406 mItemContextMenu->open(this, SLOT(contextButton(NmActionResponse&))); |
|
407 } |
|
408 } |
|
409 |
|
410 /*! |
|
411 Slot. Signaled when menu option is selected |
|
412 */ |
|
413 void NmMessageSearchListView::contextButton(NmActionResponse &result) |
|
414 { |
|
415 // Handle context menu commands here. |
|
416 if (result.menuType() == NmActionContextMenu){ |
|
417 switch (result.responseCommand()) { |
|
418 case NmActionResponseCommandOpen: { |
|
419 if (mLongPressedItem){ |
|
420 NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageViewer, |
|
421 mStartParam->mailboxId(), mStartParam->folderId(), |
|
422 mLongPressedItem->envelope().messageId()); |
|
423 |
|
424 mApplication.enterNmUiView(startParam); |
|
425 mLongPressedItem = NULL; |
|
426 } |
|
427 |
|
428 break; |
|
429 } |
|
430 default: { |
|
431 break; |
|
432 } |
|
433 } |
|
434 } |
|
435 } |
|
436 |
|
437 /*! |
|
438 Stores the given index and forwards the call to handleSelection(). This |
|
439 method gets called when an item on the list is selected. |
|
440 |
|
441 \param index The index of the activated item. |
|
442 */ |
|
443 void NmMessageSearchListView::itemActivated(const QModelIndex &index) |
|
444 { |
|
445 mActivatedIndex = index; |
|
446 QMetaObject::invokeMethod(this, "handleSelection", Qt::QueuedConnection); |
|
447 } |
|
448 |
|
449 /*! |
|
450 Called when text is changed in the edit field |
|
451 |
|
452 \param text new text entered in the field |
|
453 */ |
|
454 void NmMessageSearchListView::criteriaChanged(QString text) |
|
455 { |
|
456 NMLOG(QString("NmMessageSearchListView::criteriaChanged %1").arg(text)); |
|
457 |
|
458 // Check when button should be disabled/enabled |
|
459 bool enabled = mPushButton->isEnabled(); |
|
460 if (!enabled && !text.isEmpty()) { |
|
461 mPushButton->setEnabled(true); |
|
462 } |
|
463 else if (enabled && text.isEmpty()) { |
|
464 mPushButton->setEnabled(false); |
|
465 } |
|
466 } |
|
467 |
|
468 /*! |
|
469 If the selected item is a message, will open the message. |
|
470 */ |
|
471 void NmMessageSearchListView::handleSelection() |
|
472 { |
|
473 // Do expand/collapse for title divider items |
|
474 NmMessageListModelItem* modelItem = mSearchListModel.data( |
|
475 mActivatedIndex, Qt::DisplayRole).value<NmMessageListModelItem*>(); |
|
476 |
|
477 if (modelItem && |
|
478 modelItem->itemType() == NmMessageListModelItem::NmMessageItemMessage) |
|
479 { |
|
480 if (mSearchInProgress) { |
|
481 // Stop the search. |
|
482 toggleSearch(); |
|
483 } |
|
484 |
|
485 // Open the message. |
|
486 NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageViewer, |
|
487 mStartParam->mailboxId(), mStartParam->folderId(), |
|
488 modelItem->envelope().messageId()); |
|
489 |
|
490 mApplication.enterNmUiView(startParam); |
|
491 } |
|
492 } |
|
493 |
|
494 |
|
495 /*! |
|
496 Displays the message list widtet if not visible and scrolls to the |
|
497 appropriate point on the list. |
|
498 */ |
|
499 void NmMessageSearchListView::itemsAdded(const QModelIndex &parent, int start, int end) |
|
500 { |
|
501 NMLOG("nmailui: NmMessageSearchListView::itemsAdded()"); |
|
502 |
|
503 Q_UNUSED(parent); |
|
504 Q_UNUSED(end); |
|
505 |
|
506 // Display the message list widget if not visible. |
|
507 noMessagesLabelVisibility(false); |
|
508 |
|
509 if (!start && mMessageListWidget) { |
|
510 QList<HbAbstractViewItem*> items = mMessageListWidget->visibleItems(); |
|
511 |
|
512 if (items.count()) { |
|
513 QModelIndex index = items.at(0)->modelIndex(); |
|
514 |
|
515 if (1 == index.row()) { |
|
516 QModelIndex previous = mMessageListWidget->modelIterator()->previousIndex(index); |
|
517 |
|
518 if (previous.isValid()) { |
|
519 mMessageListWidget->scrollTo(previous); |
|
520 } |
|
521 } |
|
522 } |
|
523 } |
|
524 } |
|
525 |
|
526 |
|
527 /*! |
|
528 This method gets called when an item is removed from the list. If the list |
|
529 contains no items, "no messages" label is displayed. |
|
530 */ |
|
531 void NmMessageSearchListView::itemsRemoved() |
|
532 { |
|
533 if (mSearchListModel.searchResultCount() == 0) { |
|
534 noMessagesLabelVisibility(true); |
|
535 } |
|
536 } |
|
537 |
|
538 |
|
539 /*! |
|
540 Refreshes the search list. |
|
541 */ |
|
542 void NmMessageSearchListView::refreshList() |
|
543 { |
|
544 if (mMessageListWidget) { |
|
545 // Set the model. |
|
546 NmMessageListModel &messageListModel = |
|
547 mUiEngine.messageListModel(mStartParam->mailboxId(), |
|
548 mStartParam->folderId()); |
|
549 mSearchListModel.setSourceModel(&messageListModel); |
|
550 mMessageListWidget->setModel( |
|
551 static_cast<QSortFilterProxyModel*>(&mSearchListModel)); |
|
552 |
|
553 // Connect the signals. |
|
554 connect(&mSearchListModel, SIGNAL(rowsInserted(const QModelIndex&, int, int)), |
|
555 this, SLOT(itemsAdded(const QModelIndex&, int, int)), Qt::UniqueConnection); |
|
556 |
|
557 connect(&mSearchListModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), |
|
558 this, SLOT(itemsRemoved()), Qt::UniqueConnection); |
|
559 |
|
560 connect(&messageListModel, SIGNAL(setNewParam(NmUiStartParam*)), |
|
561 this, SLOT(reloadViewContents(NmUiStartParam*)), Qt::UniqueConnection); |
|
562 |
|
563 } |
|
564 } |
|
565 |
|
566 |
|
567 /*! |
|
568 Starts and stops the search according to the current status. |
|
569 |
|
570 Starts search: Uses the input given by the user as a search string and |
|
571 starts an asynchronous search. Any previous search results are removed from |
|
572 the search list. |
|
573 |
|
574 Stops search: Sets the number of search results into the info label. |
|
575 */ |
|
576 void NmMessageSearchListView::toggleSearch() |
|
577 { |
|
578 if (mSearchInProgress) { |
|
579 // Search is in progress - do cancel. |
|
580 mUiEngine.cancelSearch(mStartParam->mailboxId()); |
|
581 handleSearchComplete(); |
|
582 } |
|
583 else { |
|
584 // Do start the search. |
|
585 mSearchInProgress = true; |
|
586 |
|
587 // Clear previous results if any. |
|
588 mSearchListModel.clearSearchResults(); |
|
589 |
|
590 connect(&mUiEngine, SIGNAL(searchComplete()), |
|
591 this, SLOT(handleSearchComplete()), Qt::UniqueConnection); |
|
592 |
|
593 // Get the search input and start the search. |
|
594 QStringList searchStrings; |
|
595 |
|
596 if (mLineEdit) { |
|
597 searchStrings.append(mLineEdit->text()); |
|
598 } |
|
599 |
|
600 mUiEngine.search(mStartParam->mailboxId(), searchStrings); |
|
601 |
|
602 // Hide the "no messages" label if visible and dim the search input. |
|
603 noMessagesLabelVisibility(false); |
|
604 setSearchInputMode(NmDimmedMode); |
|
605 |
|
606 // Display the info label. |
|
607 if (mInfoLabel) { |
|
608 mInfoLabel->setPlainText(hbTrId("txt_mail_list_searching")); |
|
609 mInfoLabel->show(); |
|
610 } |
|
611 |
|
612 // Change the push button text. |
|
613 if (mPushButton) { |
|
614 mPushButton->setIcon(HbIcon("qtg_mono_search_stop")); |
|
615 } |
|
616 } |
|
617 } |
|
618 |
|
619 |
|
620 /*! |
|
621 If the search matched any messages, displays the search result count in the |
|
622 info label. If no messages were found, the method displays the "no messages" |
|
623 label. In either case, the search panel is updated. |
|
624 */ |
|
625 void NmMessageSearchListView::handleSearchComplete() |
|
626 { |
|
627 NMLOG("NmMessageSearchListView::handleSearchComplete()"); |
|
628 mSearchInProgress = false; |
|
629 |
|
630 // Change the push button text. |
|
631 if (mPushButton) { |
|
632 mPushButton->setIcon(HbIcon("qtg_mono_search")); |
|
633 } |
|
634 |
|
635 const int resultCount = mSearchListModel.searchResultCount(); |
|
636 |
|
637 if (resultCount == 1) { |
|
638 // For some reason when the result count is only 1, the search list |
|
639 // will not display the found message. Until the underlying reason for |
|
640 // this bug is found, let us use the following solution to fix this |
|
641 // issue. |
|
642 refreshList(); |
|
643 } |
|
644 |
|
645 if (resultCount) { |
|
646 if (mInfoLabel) { |
|
647 // Display the result count on the info label. |
|
648 QString resultsString(hbTrId("txt_mail_list_search_results")); |
|
649 resultsString.arg(resultCount); |
|
650 mInfoLabel->setPlainText(resultsString); |
|
651 |
|
652 if (!mInfoLabel->isVisible()) { |
|
653 mInfoLabel->show(); |
|
654 } |
|
655 } |
|
656 |
|
657 // Undim the search input. |
|
658 setSearchInputMode(NmNormalMode); |
|
659 } |
|
660 else { |
|
661 // No search results! |
|
662 if (mInfoLabel && mInfoLabel->isVisible()) { |
|
663 mInfoLabel->hide(); |
|
664 } |
|
665 |
|
666 // Display the "no messags" label and highlight the search term. |
|
667 noMessagesLabelVisibility(true); |
|
668 setSearchInputMode(NmHighlightedMode); |
|
669 } |
|
670 } |
|
671 |
|
672 |
|
673 // End of file. |