14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
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 = "NmMessageSearchListView"; |
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 = "LabelGroupBox"; |
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"; |
185 if (mDocumentLoader) { |
185 if (mDocumentLoader) { |
186 mDocumentLoader->setObjectTree(objectList); |
186 mDocumentLoader->setObjectTree(objectList); |
187 mWidgetList = mDocumentLoader->load(NMUI_MESSAGE_SEARCH_LIST_VIEW_XML, &ok); |
187 mWidgetList = mDocumentLoader->load(NMUI_MESSAGE_SEARCH_LIST_VIEW_XML, &ok); |
188 } |
188 } |
189 |
189 |
190 if (ok && mWidgetList.count()) { |
190 if (ok) { |
|
191 // Load the search panel (contains the line edit and the push button |
|
192 // widgets. |
|
193 mLineEdit = qobject_cast<HbLineEdit *>( |
|
194 mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_LINE_EDIT)); |
|
195 |
|
196 if (mLineEdit) { |
|
197 connect(mLineEdit, SIGNAL(textChanged(QString)), |
|
198 this, SLOT(criteriaChanged(QString))); |
|
199 } |
|
200 |
|
201 mPushButton = qobject_cast<HbPushButton *>( |
|
202 mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_PUSH_BUTTON)); |
|
203 |
|
204 if (mPushButton) { |
|
205 // button is disabled when line edit is empty |
|
206 mPushButton->setEnabled(false); |
|
207 |
|
208 // The push button both starts and stops the search. |
|
209 connect(mPushButton, SIGNAL(clicked()), this, SLOT(toggleSearch())); |
|
210 mPushButton->setIcon(HbIcon("qtg_mono_search")); |
|
211 } |
|
212 |
|
213 // Load the info label. |
|
214 mInfoLabel = qobject_cast<HbGroupBox *>( |
|
215 mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_INFO_LABEL)); |
|
216 |
|
217 if (mInfoLabel) { |
|
218 NM_COMMENT("NmMessageSearchListView: info label loaded"); |
|
219 |
|
220 // If the heading is empty, the widget will not be shown which in |
|
221 // turn would ruin the layout. |
|
222 mInfoLabel->setHeading(" "); |
|
223 } |
|
224 |
191 // Get the message list widget. |
225 // Get the message list widget. |
192 mMessageListWidget = qobject_cast<HbTreeView *>( |
226 mMessageListWidget = qobject_cast<HbTreeView *>( |
193 mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_TREE_LIST)); |
227 mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_TREE_LIST)); |
194 |
228 |
195 if (mMessageListWidget) { |
229 if (mMessageListWidget) { |
208 // We want the search results to appear one by one. |
242 // We want the search results to appear one by one. |
209 mMessageListWidget->setEnabledAnimations(HbAbstractItemView::Appear & |
243 mMessageListWidget->setEnabledAnimations(HbAbstractItemView::Appear & |
210 HbAbstractItemView::Expand); |
244 HbAbstractItemView::Expand); |
211 } |
245 } |
212 |
246 |
213 // Load the info label. |
|
214 mInfoLabel = qobject_cast<HbGroupBox *>( |
|
215 mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_INFO_LABEL)); |
|
216 |
|
217 if (mInfoLabel) { |
|
218 NM_COMMENT("NmMessageSearchListView: info label loaded"); |
|
219 mInfoLabel->hide(); |
|
220 } |
|
221 |
|
222 // Load the no messages label. |
247 // Load the no messages label. |
223 mNoMessagesLabel = qobject_cast<HbLabel *>( |
248 mNoMessagesLabel = qobject_cast<HbLabel *>( |
224 mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_NO_MESSAGES)); |
249 mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_NO_MESSAGES)); |
225 |
250 |
226 if (mNoMessagesLabel) { |
251 if (mNoMessagesLabel) { |
227 NMLOG("NmMessageSearchListView: No messages label loaded."); |
252 NMLOG("NmMessageSearchListView: No messages label loaded."); |
228 mNoMessagesLabel->hide(); |
253 mNoMessagesLabel->hide(); |
229 } |
|
230 |
|
231 // Load the search panel. |
|
232 mLineEdit = qobject_cast<HbLineEdit *>( |
|
233 mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_LINE_EDIT)); |
|
234 if (mLineEdit) { |
|
235 connect(mLineEdit, SIGNAL(textChanged(QString)), |
|
236 this, SLOT(criteriaChanged(QString))); |
|
237 } |
|
238 |
|
239 mPushButton = qobject_cast<HbPushButton *>( |
|
240 mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_PUSH_BUTTON)); |
|
241 if (mPushButton) { |
|
242 // button is disabled when line edit is empty |
|
243 mPushButton->setEnabled(false); |
|
244 // The push button both starts and stops the search. |
|
245 connect(mPushButton, SIGNAL(clicked()), this, SLOT(toggleSearch())); |
|
246 mPushButton->setIcon(HbIcon("qtg_mono_search")); |
|
247 } |
254 } |
248 } |
255 } |
249 else { |
256 else { |
250 NM_ERROR(1, "NmMessageSearchListView: failed to load widgets from XML"); |
257 NM_ERROR(1, "NmMessageSearchListView: failed to load widgets from XML"); |
251 } |
258 } |
616 connect(&mMsgListModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), |
623 connect(&mMsgListModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), |
617 this, SLOT(itemsRemoved()), Qt::UniqueConnection); |
624 this, SLOT(itemsRemoved()), Qt::UniqueConnection); |
618 |
625 |
619 connect(&mMsgListModel, SIGNAL(setNewParam(NmUiStartParam*)), |
626 connect(&mMsgListModel, SIGNAL(setNewParam(NmUiStartParam*)), |
620 this, SLOT(reloadViewContents(NmUiStartParam*)), Qt::UniqueConnection); |
627 this, SLOT(reloadViewContents(NmUiStartParam*)), Qt::UniqueConnection); |
621 |
628 } |
|
629 |
|
630 // The info label cannot be hidden when constructed because doing so would |
|
631 // ruin the layout (for example the line edit widget's width would be too |
|
632 // short in lanscape). |
|
633 if (mInfoLabel) { |
|
634 mInfoLabel->hide(); |
622 } |
635 } |
623 } |
636 } |
624 |
637 |
625 |
638 |
626 /*! |
639 /*! |