51 #include <qdesktopservices.h> |
50 #include <qdesktopservices.h> |
52 #include <hblistwidget.h> |
51 #include <hblistwidget.h> |
53 #include <hblistwidgetitem.h> |
52 #include <hblistwidgetitem.h> |
54 #include <hbabstractviewitem.h> |
53 #include <hbabstractviewitem.h> |
55 #include <hblistviewitem.h> |
54 #include <hblistviewitem.h> |
|
55 #include <hbactivitymanager.h> |
56 #define hbApp qobject_cast<HbApplication*>(qApp) |
56 #define hbApp qobject_cast<HbApplication*>(qApp) |
57 const char *SEARCHSTATEPROVIDER_DOCML = ":/xml/searchstateprovider.docml"; |
57 const int totalcategories_normalreason = 10; |
58 const char *TOC_VIEW = "tocView"; |
58 const int totalcategories_activityreasonreason = 13; |
59 const char *TUT_SEARCHPANEL_WIDGET = "searchPanel"; |
59 const int intial_iteration = 3; |
60 const char *TUT_LIST_VIEW = "listView"; |
60 const int batch_iteration = 20; |
61 const int totalcategories = 10; |
|
62 // --------------------------------------------------------------------------- |
61 // --------------------------------------------------------------------------- |
63 // SearchProgressiveState::SearchProgressiveState |
62 // SearchProgressiveState::SearchProgressiveState |
64 // --------------------------------------------------------------------------- |
63 // --------------------------------------------------------------------------- |
65 SearchProgressiveState::SearchProgressiveState(QState *parent) : |
64 SearchProgressiveState::SearchProgressiveState(QState *parent) : |
66 QState(parent), mMainWindow(NULL), mView(NULL), mListView(NULL), |
65 QState(parent), mMainWindow(NULL), mView(NULL), mListView(NULL), |
67 mDocumentLoader(NULL), mSearchHandler(NULL), mNotesEditor(0), |
66 mSearchHandler(NULL), mNotesEditor(0), mAiwMgr(0), mRequest(0) |
68 mAiwMgr(0), mRequest(0) |
67 { |
69 { |
68 mUiLoader = SearchUiLoader::instance(); |
70 |
69 |
71 mMainWindow = hbInstance->allMainWindows().at(0); |
70 mMainWindow = hbInstance->allMainWindows().at(0); |
72 |
71 |
73 mAiwMgr = new XQApplicationManager; |
72 mAiwMgr = new XQApplicationManager; |
74 |
73 |
75 mDocumentLoader = new HbDocumentLoader(); |
74 mView = mUiLoader->View(); |
76 bool ok = false; |
75 mListView = mUiLoader->ListWidget(); |
77 mDocumentLoader->load(SEARCHSTATEPROVIDER_DOCML, &ok); |
76 mSearchPanel = mUiLoader->SearchPanel(); |
78 |
77 |
79 QGraphicsWidget *widget = mDocumentLoader->findWidget(TOC_VIEW); |
78 HbStyle style; |
80 Q_ASSERT_X(ok && (widget != 0), "TOC_VIEW", "invalid view"); |
79 qreal x; |
81 |
80 style.parameter("hb-param-graphic-size-primary-large", x); |
82 mView = qobject_cast<HbView*> (widget); |
81 QSizeF size(x, x); |
83 if (mView) |
82 mListViewIconSize = size.toSize(); |
84 { |
83 |
85 mView->setTitle(hbTrId("txt_search_title_search")); |
|
86 } |
|
87 |
|
88 mListView = qobject_cast<HbListWidget *> (mDocumentLoader->findWidget( |
|
89 TUT_LIST_VIEW)); |
|
90 Q_ASSERT_X(ok && (mListView != 0), "TUT_LIST_VIEW", "invalid viewocML file"); |
|
91 |
|
92 if (mListView) |
|
93 { |
|
94 HbAbstractViewItem *prototype = mListView->itemPrototypes().first(); |
|
95 HbFrameBackground frame; |
|
96 frame.setFrameGraphicsName("qtg_fr_list_normal"); |
|
97 frame.setFrameType(HbFrameDrawer::NinePieces); |
|
98 prototype->setDefaultFrame(frame); |
|
99 |
|
100 HbListViewItem *prototypeListView = qobject_cast<HbListViewItem *> ( |
|
101 prototype); |
|
102 prototypeListView->setGraphicsSize(HbListViewItem::LargeIcon); |
|
103 if (prototypeListView) |
|
104 { |
|
105 HbStyle style; |
|
106 qreal x; |
|
107 style.parameter("hb-param-graphic-size-primary-large", x); |
|
108 QSizeF size(x, x); |
|
109 mListViewIconSize = size.toSize(); |
|
110 prototypeListView->setTextFormat(Qt::RichText); |
|
111 } |
|
112 |
|
113 HbAbstractItemView::ItemAnimations noCreationAndRemovalAnimations = |
|
114 HbAbstractItemView::All; |
|
115 noCreationAndRemovalAnimations ^= HbAbstractItemView::Appear; |
|
116 noCreationAndRemovalAnimations ^= HbAbstractItemView::Disappear; |
|
117 mListView->setEnabledAnimations(noCreationAndRemovalAnimations); |
|
118 } |
|
119 |
|
120 mSearchPanel = qobject_cast<HbSearchPanel *> ( |
|
121 mDocumentLoader->findWidget(TUT_SEARCHPANEL_WIDGET)); |
|
122 if (mSearchPanel) |
84 if (mSearchPanel) |
123 { |
85 { |
124 mSearchPanel->setSearchOptionsEnabled(true); |
|
125 |
|
126 mSearchPanel->setPlaceholderText(hbTrId( |
86 mSearchPanel->setPlaceholderText(hbTrId( |
127 "txt_search_dialog_search_device")); |
87 "txt_search_dialog_search_device")); |
128 |
|
129 mSearchPanel->setCancelEnabled(false); |
|
130 mSearchPanel->setFocus(); |
88 mSearchPanel->setFocus(); |
131 } |
89 } |
132 |
90 |
133 constructHandlers(); |
91 constructHandlers(); |
134 |
92 |
186 mNotespluginLoader->instance()); |
132 mNotespluginLoader->instance()); |
187 mNotesEditor = qobject_cast<NotesEditorInterface*> (plugin); |
133 mNotesEditor = qobject_cast<NotesEditorInterface*> (plugin); |
188 } |
134 } |
189 |
135 |
190 mOnlineQueryAvailable = false; |
136 mOnlineQueryAvailable = false; |
|
137 //Prepare the icons,listen of theme change |
|
138 connect(hbInstance->theme(), SIGNAL(changeFinished()), this, |
|
139 SLOT(slotPrepareResultIcons())); |
|
140 slotPrepareResultIcons(); |
|
141 |
|
142 // creating the handler if it is not prepared, useful when user try to create before |
|
143 mValidateHandlerCreation = false; |
191 } |
144 } |
192 // --------------------------------------------------------------------------- |
145 // --------------------------------------------------------------------------- |
193 // SearchProgressiveState::~SearchProgressiveState |
146 // SearchProgressiveState::~SearchProgressiveState |
194 // --------------------------------------------------------------------------- |
147 // --------------------------------------------------------------------------- |
195 SearchProgressiveState::~SearchProgressiveState() |
148 SearchProgressiveState::~SearchProgressiveState() |
196 { |
149 { |
197 if (mAiwMgr) |
150 if (mAiwMgr) |
198 { |
151 { |
199 delete mAiwMgr; |
152 delete mAiwMgr; |
200 } |
|
201 if (mDocumentLoader) |
|
202 { |
|
203 delete mDocumentLoader; |
|
204 } |
153 } |
205 for (int i = 0; i < mSearchHandlerList.count(); i++) |
154 for (int i = 0; i < mSearchHandlerList.count(); i++) |
206 { |
155 { |
207 delete mSearchHandlerList.at(i); |
156 delete mSearchHandlerList.at(i); |
208 } |
157 } |
209 if (mNotespluginLoader) |
158 if (mNotespluginLoader) |
210 { |
159 { |
211 mNotespluginLoader->unload(); |
160 mNotespluginLoader->unload(); |
212 delete mNotespluginLoader; |
161 delete mNotespluginLoader; |
213 } |
162 } |
|
163 SearchUiLoader::deleteinstance(); |
214 } |
164 } |
215 // --------------------------------------------------------------------------- |
165 // --------------------------------------------------------------------------- |
216 // SearchProgressiveState::constructHandlers |
166 // SearchProgressiveState::constructHandlers |
217 // --------------------------------------------------------------------------- |
167 // --------------------------------------------------------------------------- |
218 void SearchProgressiveState::constructHandlers() |
168 void SearchProgressiveState::constructHandlers() |
219 { |
169 { |
220 InDeviceHandler* handler = NULL; |
170 int categories = totalcategories_normalreason; |
221 for (int i = 0; i < totalcategories; i++) |
171 |
222 { |
172 if (hbApp && hbApp->activateReason() == Hb::ActivationReasonActivity) |
223 handler = new InDeviceHandler(); |
173 { |
224 switch (i) |
174 categories = totalcategories_activityreasonreason; |
225 { |
175 } |
226 case 0: |
176 for (int i = 0; i < categories; i++) |
227 { |
177 { |
228 handler->setCategory(""); |
178 mSearchHandlerList.append(constructHandlers(i)); |
229 break; |
|
230 } |
|
231 case 1: |
|
232 { |
|
233 handler->setCategory("contact"); |
|
234 break; |
|
235 } |
|
236 case 2: |
|
237 { |
|
238 handler->setCategory("media"); |
|
239 break; |
|
240 } |
|
241 case 3: |
|
242 { |
|
243 handler->setCategory("msg"); |
|
244 break; |
|
245 } |
|
246 case 4: |
|
247 { |
|
248 handler->setCategory("msg email"); |
|
249 break; |
|
250 } |
|
251 case 5: |
|
252 { |
|
253 handler->setCategory("calendar"); |
|
254 break; |
|
255 } |
|
256 case 6: |
|
257 { |
|
258 handler->setCategory("notes"); |
|
259 break; |
|
260 } |
|
261 case 7: |
|
262 { |
|
263 handler->setCategory("applications"); |
|
264 break; |
|
265 } |
|
266 case 8: |
|
267 { |
|
268 handler->setCategory("file"); |
|
269 break; |
|
270 } |
|
271 case 9: |
|
272 { |
|
273 handler->setCategory("bookmark"); |
|
274 break; |
|
275 } |
|
276 } |
|
277 mSearchHandlerList.append(handler); |
|
278 } |
179 } |
279 } |
180 } |
280 // --------------------------------------------------------------------------- |
181 // --------------------------------------------------------------------------- |
281 // SearchProgressiveState::onEntry |
182 // SearchProgressiveState::onEntry |
282 // --------------------------------------------------------------------------- |
183 // --------------------------------------------------------------------------- |
283 void SearchProgressiveState::onEntry(QEvent *event) |
184 void SearchProgressiveState::onEntry(QEvent *event) |
284 { |
185 { |
285 // WMS_LOG << "::onEntry"; |
186 // WMS_LOG << "::onEntry"; |
286 QState::onEntry(event); |
187 QState::onEntry(event); |
|
188 |
|
189 mStateStatus = true;// used for conditional execution for the slots that are connected as transitions |
|
190 if (mSearchPanel) |
|
191 { |
|
192 mSearchPanel->setPlaceholderText(hbTrId( |
|
193 "txt_search_dialog_search_device")); |
|
194 mSearchPanel->setProgressive(true); |
|
195 } |
|
196 if (mListView) |
|
197 { |
|
198 mListView->setVisible(true); |
|
199 } |
287 activateSignals(); |
200 activateSignals(); |
288 |
|
289 // If this is not the current view, we're getting back from plugin view |
201 // If this is not the current view, we're getting back from plugin view |
290 if (mMainWindow) |
202 if (mMainWindow) |
291 { |
203 { |
292 if (mMainWindow->currentView() != mView) |
204 if (mMainWindow->currentView() != mView) |
293 { |
205 { |
402 } |
321 } |
403 // --------------------------------------------------------------------------- |
322 // --------------------------------------------------------------------------- |
404 // SearchProgressiveState::onGetDocumentComplete |
323 // SearchProgressiveState::onGetDocumentComplete |
405 // --------------------------------------------------------------------------- |
324 // --------------------------------------------------------------------------- |
406 void SearchProgressiveState::onGetDocumentComplete(int aError, |
325 void SearchProgressiveState::onGetDocumentComplete(int aError, |
407 QCPixDocument* aDoc) |
326 CpixDocument* aDoc) |
408 { |
327 { |
409 PERF_CAT_GETDOC_TIME_ACCUMULATE |
328 if (aError) |
410 if (aDoc == NULL || aError != 0) |
|
411 return; |
329 return; |
412 QStringList liststr; |
330 parseDocument(aDoc); |
413 QString secondrow = aDoc->excerpt(); |
|
414 QString firstrow; |
|
415 HbListWidgetItem* listitem = new HbListWidgetItem(); |
|
416 |
|
417 if (aDoc->baseAppClass().contains("contact")) |
|
418 { |
|
419 QStringList docsList = filterDoc(aDoc, "GivenName", "FamilyName"); |
|
420 if (docsList.value(0, "").length()) |
|
421 { |
|
422 firstrow.append(docsList.at(0)); |
|
423 } |
|
424 if (docsList.value(1, "").length()) |
|
425 { |
|
426 if (firstrow.length()) |
|
427 firstrow.append(" "); |
|
428 firstrow.append(docsList.at(1)); |
|
429 } |
|
430 if (firstrow.length() == 0) |
|
431 { |
|
432 firstrow = hbTrId("txt_phob_dblist_unnamed"); |
|
433 } |
|
434 liststr << firstrow << secondrow; |
|
435 listitem->setData(mIconArray.at(0), Qt::DecorationRole); |
|
436 } |
|
437 else if (aDoc->baseAppClass().contains("audio")) |
|
438 { |
|
439 QStringList audioList = filterDoc(aDoc, "Title", "MediaId"); |
|
440 if (audioList.value(0, "").length()) |
|
441 { |
|
442 firstrow.append(audioList.at(0)); |
|
443 } |
|
444 if (firstrow.length() == 0) |
|
445 { |
|
446 firstrow = hbTrId("txt_mus_dblist_val_unknown4"); |
|
447 } |
|
448 liststr << firstrow << secondrow; |
|
449 listitem->setData(mIconArray.at(1), Qt::DecorationRole); |
|
450 if (audioList.value(1, "").length()) |
|
451 { |
|
452 listitem->setData(audioList.at(1), Qt::UserRole + 2); |
|
453 } |
|
454 } |
|
455 else if (aDoc->baseAppClass().contains("video")) |
|
456 { |
|
457 QStringList videoList = filterDoc(aDoc, "Title", "MediaId", "Name"); |
|
458 if (videoList.value(0, "").length()) |
|
459 { |
|
460 firstrow.append(videoList.at(0)); |
|
461 } |
|
462 if (firstrow.length() == 0 && videoList.value(2, "").length()) |
|
463 { |
|
464 firstrow.append(videoList.at(2)); |
|
465 } |
|
466 liststr << firstrow << secondrow; |
|
467 listitem->setData(mIconArray.at(2), Qt::DecorationRole); |
|
468 if (videoList.value(1, "").length()) |
|
469 { |
|
470 listitem->setData(videoList.at(1), Qt::UserRole + 2); |
|
471 } |
|
472 } |
|
473 else if (aDoc->baseAppClass().contains("image")) |
|
474 { |
|
475 QStringList imageList = filterDoc(aDoc, "Name", "MediaId"); |
|
476 if (imageList.value(0, "").length()) |
|
477 { |
|
478 firstrow.append(imageList.at(0)); |
|
479 } |
|
480 liststr << firstrow << secondrow; |
|
481 listitem->setData(mIconArray.at(3), Qt::DecorationRole); |
|
482 if (imageList.value(1, "").length()) |
|
483 { |
|
484 listitem->setData(imageList.at(1), Qt::UserRole + 2); |
|
485 } |
|
486 } |
|
487 else if (aDoc->baseAppClass().contains("msg email")) |
|
488 { |
|
489 qDebug() << "searchui:on Get doc email"; |
|
490 QStringList emailList = filterDoc(aDoc, "Sender", "MailBoxId", |
|
491 "FolderId"); |
|
492 |
|
493 qDebug() << "searchui:recipients" << emailList.at(0) << emailList.at( |
|
494 1) << emailList.at(2); |
|
495 firstrow.append(emailList.at(0)); |
|
496 listitem->setData(emailList.at(1), Qt::UserRole + 2); |
|
497 listitem->setData(emailList.at(2), Qt::UserRole + 3); |
|
498 liststr << firstrow << secondrow; |
|
499 listitem->setData(mIconArray.at(5), Qt::DecorationRole); |
|
500 } |
|
501 else if (aDoc->baseAppClass().contains("msg")) |
|
502 { |
|
503 QStringList msgList = filterDoc(aDoc, "Subject", "Body"); |
|
504 if (msgList.value(0, "").length()) |
|
505 { |
|
506 firstrow.append(msgList.at(0)); |
|
507 } |
|
508 else |
|
509 { |
|
510 if (msgList.value(1, "").length()) |
|
511 firstrow.append(msgList.at(1)); |
|
512 } |
|
513 if (firstrow.length() == 0) |
|
514 { |
|
515 firstrow = " ";// space if subject and body are missing |
|
516 } |
|
517 liststr << firstrow << secondrow; |
|
518 listitem->setData(mIconArray.at(4), Qt::DecorationRole); |
|
519 } |
|
520 else if (aDoc->baseAppClass().contains("calendar")) |
|
521 { |
|
522 firstrow.append(filterDoc(aDoc, "Summary")); |
|
523 if (firstrow.length() == 0) |
|
524 { |
|
525 firstrow = hbTrId("txt_calendar_preview_unnamed"); |
|
526 } |
|
527 |
|
528 liststr << firstrow << secondrow; |
|
529 listitem->setData(mIconArray.at(6), Qt::DecorationRole); |
|
530 } |
|
531 else if (aDoc->baseAppClass().contains("notes")) |
|
532 { |
|
533 firstrow.append(filterDoc(aDoc, "Memo")); |
|
534 if (firstrow.length() == 0) |
|
535 { |
|
536 firstrow = hbTrId("txt_notes_dblist_unnamed"); |
|
537 } |
|
538 liststr << firstrow << secondrow; |
|
539 listitem->setData(mIconArray.at(7), Qt::DecorationRole); |
|
540 } |
|
541 else if (aDoc->baseAppClass().contains("applications")) |
|
542 { |
|
543 firstrow.append(filterDoc(aDoc, "Name")); |
|
544 liststr << firstrow; |
|
545 bool ok; |
|
546 TRAP_IGNORE(listitem->setData(getAppIconFromAppIdL(TUid::Uid(aDoc->docId().toInt( |
|
547 &ok, 16))), Qt::DecorationRole)); |
|
548 } |
|
549 else if (aDoc->baseAppClass().contains("bookmark")) |
|
550 { |
|
551 firstrow.append(filterDoc(aDoc, "Name")); |
|
552 if (firstrow.length() == 0) |
|
553 { |
|
554 firstrow = "UnKnown"; |
|
555 } |
|
556 liststr << firstrow << secondrow; |
|
557 listitem->setData(secondrow, Qt::UserRole + 2); |
|
558 listitem->setData(mIconArray.at(8), Qt::DecorationRole); |
|
559 } |
|
560 else if (aDoc->baseAppClass().contains("file")) |
|
561 { |
|
562 firstrow.append(filterDoc(aDoc, "Name")); |
|
563 if (firstrow.length() == 0) |
|
564 firstrow = aDoc->baseAppClass(); |
|
565 liststr << firstrow << secondrow; |
|
566 listitem->setData(mIconArray.at(9), Qt::DecorationRole); |
|
567 } |
|
568 listitem->setText(firstrow); |
|
569 listitem->setSecondaryText(secondrow); |
|
570 listitem->setData(aDoc->docId(), Qt::UserRole); |
|
571 listitem->setData(aDoc->baseAppClass(), Qt::UserRole + 1); |
|
572 mListView->addItem(listitem); |
|
573 |
|
574 mResultparser++; |
331 mResultparser++; |
575 if (mResultparser < mResultcount) |
332 if (mResultparser < mResultcount) |
576 { |
333 { |
577 PERF_CAT_GETDOC_TIME_RESTART |
334 PERF_CAT_GETDOC_TIME_RESTART |
578 mSearchHandler->getDocumentAsyncAtIndex(mResultparser); |
335 if (mResultparser < intial_iteration) |
|
336 { |
|
337 mSearchHandler->getDocumentAsyncAtIndex(mResultparser); |
|
338 } |
|
339 else |
|
340 { |
|
341 mSearchHandler->getBatchDocumentAsyncAtIndex(mResultparser, |
|
342 batch_iteration); |
|
343 } |
579 } |
344 } |
580 else |
345 else |
581 { |
346 { |
582 PERF_CAT_GETDOC_ACCUMULATOR_ENDLOG |
347 PERF_CAT_GETDOC_ACCUMULATOR_ENDLOG |
583 searchOnCategory(mSearchString); |
348 searchOnCategory(mSearchString); |
584 } |
349 } |
|
350 } |
|
351 // --------------------------------------------------------------------------- |
|
352 // SearchProgressiveState::onGetDocumentComplete |
|
353 // --------------------------------------------------------------------------- |
|
354 void SearchProgressiveState::onGetBatchDocumentComplete(int aError, |
|
355 int aCount, CpixDocument** aDoc) |
|
356 { |
|
357 if (aError) |
|
358 return; |
|
359 for (int i = 0; i < aCount; i++) |
|
360 { |
|
361 parseDocument(aDoc[i]); |
|
362 } |
585 delete aDoc; |
363 delete aDoc; |
|
364 mResultparser += aCount; |
|
365 if (mResultparser < mResultcount) |
|
366 { |
|
367 PERF_CAT_GETDOC_TIME_RESTART |
|
368 mSearchHandler->getBatchDocumentAsyncAtIndex(mResultparser, |
|
369 batch_iteration); |
|
370 } |
|
371 else |
|
372 { |
|
373 PERF_CAT_GETDOC_ACCUMULATOR_ENDLOG |
|
374 searchOnCategory(mSearchString); |
|
375 } |
586 } |
376 } |
587 // --------------------------------------------------------------------------- |
377 // --------------------------------------------------------------------------- |
588 // SearchProgressiveState::getSettingCategory |
378 // SearchProgressiveState::getSettingCategory |
589 // --------------------------------------------------------------------------- |
379 // --------------------------------------------------------------------------- |
590 void SearchProgressiveState::getSettingCategory(int item, bool avalue) |
380 void SearchProgressiveState::getSettingCategory(int item, bool avalue) |
595 // SearchProgressiveState::openResultitem |
385 // SearchProgressiveState::openResultitem |
596 // --------------------------------------------------------------------------- |
386 // --------------------------------------------------------------------------- |
597 void SearchProgressiveState::openResultitem(HbListWidgetItem * item) |
387 void SearchProgressiveState::openResultitem(HbListWidgetItem * item) |
598 { |
388 { |
599 if (item == NULL) |
389 if (item == NULL) |
600 return;PERF_RESULT_ITEM_LAUNCH_TIME_RESTART |
390 return; |
|
391 PERF_RESULT_ITEM_LAUNCH_TIME_RESTART |
601 QList<QVariant> args; |
392 QList<QVariant> args; |
602 bool t; |
393 bool t; |
603 mRequest = NULL; |
394 mRequest = NULL; |
604 if (item->data(Qt::UserRole + 1).toString().contains("contact")) |
395 if (item->data(Qt::UserRole + 1).toString().contains("contact")) |
605 { |
396 { |
606 PERF_RESULT_ITEM_FOR_LAUNCHING("contact") |
397 PERF_RESULT_ITEM_FOR_LAUNCHING("contact") |
607 mRequest = mAiwMgr->create("com.nokia.services.phonebookservices", |
398 mRequest = mAiwMgr->create("com.nokia.services.phonebookservices", |
608 "Fetch", "open(int)", false); |
399 "Fetch", "open(int)", true); |
609 |
400 |
610 int uid = (item->data(Qt::UserRole)).toInt(&t); |
401 int uid = (item->data(Qt::UserRole)).toInt(&t); |
611 args << uid; |
402 args << uid; |
612 } |
403 } |
613 else if (item->data(Qt::UserRole + 1).toString().contains("bookmark")) |
404 else if (item->data(Qt::UserRole + 1).toString().contains("bookmark")) |
614 { |
405 { |
615 PERF_RESULT_ITEM_FOR_LAUNCHING("bookmark") |
406 PERF_RESULT_ITEM_FOR_LAUNCHING("bookmark") |
616 QDesktopServices::openUrl(item->data(Qt::UserRole + 2).toString()); |
407 QDesktopServices::openUrl(item->data(Qt::UserRole + 2).toString()); |
617 PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG ("") |
408 PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG ("") |
618 |
409 |
619 } |
410 } |
620 else if (item->data(Qt::UserRole + 1).toString().contains("calendar")) |
411 else if (item->data(Qt::UserRole + 1).toString().contains("calendar")) |
621 { |
412 { |
622 QDir pluginDir = QDir(QString("z:/resource/qt/plugins/calendar")); |
413 QDir pluginDir = QDir(QString("z:/resource/qt/plugins/calendar")); |
623 QPluginLoader *calAgandaViewerPluginLoader = new QPluginLoader( |
414 QPluginLoader *calAgandaViewerPluginLoader = new QPluginLoader( |
624 pluginDir.absoluteFilePath(QString( |
415 pluginDir.absoluteFilePath(QString( |
625 "agendaeventviewerplugin.qtplugin"))); |
416 "agendaeventviewerplugin.qtplugin"))); |
626 |
417 |
627 calAgandaViewerPluginInstance = qobject_cast< |
418 calAgandaViewerPluginInstance = qobject_cast< |
628 EventViewerPluginInterface *> ( |
419 EventViewerPluginInterface *> ( |
629 calAgandaViewerPluginLoader->instance()); |
420 calAgandaViewerPluginLoader->instance()); |
630 |
421 |
631 connect(calAgandaViewerPluginInstance, SIGNAL(viewingCompleted()), |
422 connect(calAgandaViewerPluginInstance, SIGNAL(viewingCompleted()), |
632 this, SLOT(_viewingCompleted())); |
423 this, SLOT(_viewingCompleted())); |
633 |
424 |
657 QString uid = getDrivefromMediaId( |
448 QString uid = getDrivefromMediaId( |
658 item->data(Qt::UserRole + 2).toString()); |
449 item->data(Qt::UserRole + 2).toString()); |
659 uid.append(':'); |
450 uid.append(':'); |
660 uid.append(item->data(Qt::UserRole).toString()); |
451 uid.append(item->data(Qt::UserRole).toString()); |
661 QFile file(uid); |
452 QFile file(uid); |
662 mRequest = mAiwMgr->create(file, false); |
453 mRequest = mAiwMgr->create(file, true); |
663 args << file.fileName(); |
454 args << file.fileName(); |
664 } |
455 } |
665 |
456 |
666 else if (item->data(Qt::UserRole + 1).toString().contains("notes")) |
457 else if (item->data(Qt::UserRole + 1).toString().contains("notes")) |
667 { |
458 { |
668 PERF_RESULT_ITEM_FOR_LAUNCHING("notes") |
459 PERF_RESULT_ITEM_FOR_LAUNCHING("notes") |
669 if(mNotesEditor) |
460 if (mNotesEditor) |
670 { |
461 { |
671 mNotesEditor->edit(item->data(Qt::UserRole).toInt()); |
462 mNotesEditor->edit(item->data(Qt::UserRole).toInt()); |
672 } |
463 } |
673 PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG("") |
464 PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG("") |
674 } |
465 } |
675 else if (item->data(Qt::UserRole + 1).toString().contains("msg email")) |
466 else if (item->data(Qt::UserRole + 1).toString().contains("msg email")) |
676 { |
467 { |
677 |
468 |
678 mRequest = mAiwMgr->create("nmail", |
469 mRequest = mAiwMgr->create("nmail", |
679 "com.nokia.symbian.IEmailMessageView", |
470 "com.nokia.symbian.IEmailMessageView", |
680 "viewMessage(QVariant,QVariant,QVariant)", false); |
471 "viewMessage(QVariant,QVariant,QVariant)", true); |
681 |
472 |
682 args << item->data(Qt::UserRole + 2).toULongLong(&t) << item->data( |
473 args << item->data(Qt::UserRole + 2).toULongLong(&t) << item->data( |
683 Qt::UserRole + 3).toULongLong(&t) << item->data(Qt::UserRole).toULongLong(&t); |
474 Qt::UserRole + 3).toULongLong(&t) |
|
475 << item->data(Qt::UserRole).toULongLong(&t); |
684 } |
476 } |
685 else if (item->data(Qt::UserRole + 1).toString().contains("msg")) |
477 else if (item->data(Qt::UserRole + 1).toString().contains("msg")) |
686 { |
478 { |
687 PERF_RESULT_ITEM_FOR_LAUNCHING("msg") |
479 PERF_RESULT_ITEM_FOR_LAUNCHING("msg") |
688 mRequest = mAiwMgr->create("com.nokia.services.hbserviceprovider", |
480 mRequest = mAiwMgr->create("messaging", |
689 "conversationview", "view(int)", false); |
481 "com.nokia.symbian.IMessageView", "view(int)", true); |
690 |
482 |
691 int uid = (item->data(Qt::UserRole)).toInt(&t); |
483 int uid = (item->data(Qt::UserRole)).toInt(&t); |
692 args << uid; |
484 args << uid; |
693 } |
485 } |
694 else if(item->data(Qt::UserRole + 1).toString().contains("links")) |
486 else if (item->data(Qt::UserRole + 1).toString().contains("links")) |
695 { |
487 { |
696 emit launchLink((item->data(Qt::UserRole)).toInt(&t),mOriginalString); |
488 emit launchLink((item->data(Qt::UserRole)).toInt(&t), mOriginalString); |
697 } |
489 } |
698 if (mRequest) |
490 if (mRequest) |
699 { |
491 { |
700 connect(mRequest, SIGNAL(requestOk(const QVariant&)), this, |
492 connect(mRequest, SIGNAL(requestOk(const QVariant&)), this, |
701 SLOT(handleOk(const QVariant&))); |
493 SLOT(handleOk(const QVariant&))); |
1338 { |
1153 { |
1339 if (hbApp->activateReason() == Hb::ActivationReasonActivity) |
1154 if (hbApp->activateReason() == Hb::ActivationReasonActivity) |
1340 { |
1155 { |
1341 QVariantHash params = hbApp->activateParams(); |
1156 QVariantHash params = hbApp->activateParams(); |
1342 QString searchKey = params.value("query").toString(); |
1157 QString searchKey = params.value("query").toString(); |
|
1158 params.remove("query"); |
|
1159 params.remove("activityname"); |
|
1160 QList<QVariant> list = params.values(); |
|
1161 mTemplist.clear(); |
|
1162 for (int i = 0; i < list.count(); i++) |
|
1163 { |
|
1164 QString str = list.at(i).toString(); |
|
1165 if (!str.isNull()) |
|
1166 mTemplist.append(str); |
|
1167 } |
1343 if (searchKey.length() > 0) |
1168 if (searchKey.length() > 0) |
1344 mSearchPanel->setCriteria(searchKey); |
1169 mSearchPanel->setCriteria(searchKey); |
1345 } |
1170 } |
1346 }PERF_APP_LAUNCH_END("SearchAppplication View is ready"); |
1171 } |
1347 } |
1172 PERF_APP_LAUNCH_END("SearchAppplication View is ready"); |
|
1173 emit applicationReady(); |
|
1174 } |
|
1175 // --------------------------------------------------------------------------- |
|
1176 // SearchProgressiveState::slotOnlineQuery |
|
1177 // --------------------------------------------------------------------------- |
1348 void SearchProgressiveState::slotOnlineQuery(QString str) |
1178 void SearchProgressiveState::slotOnlineQuery(QString str) |
1349 { |
1179 { |
1350 mOriginalString = str; |
1180 if (mOriginalString != str) |
1351 mOnlineQueryAvailable = true; |
1181 { |
1352 } |
1182 mOriginalString = str; |
|
1183 mOnlineQueryAvailable = true; |
|
1184 } |
|
1185 } |
|
1186 // --------------------------------------------------------------------------- |
|
1187 // SearchProgressiveState::slotISProvidersIcon |
|
1188 // --------------------------------------------------------------------------- |
1353 void SearchProgressiveState::slotISProvidersIcon(int id, HbIcon icon) |
1189 void SearchProgressiveState::slotISProvidersIcon(int id, HbIcon icon) |
1354 { |
1190 { |
1355 mISprovidersIcon.insert(id, icon); |
1191 mISprovidersIcon.insert(id, icon); |
1356 } |
1192 } |
|
1193 // --------------------------------------------------------------------------- |
|
1194 // SearchProgressiveState::slotPrepareResultIcons |
|
1195 // --------------------------------------------------------------------------- |
|
1196 void SearchProgressiveState::slotPrepareResultIcons() |
|
1197 { |
|
1198 //Icon creation in array |
|
1199 QStringList icons; |
|
1200 icons << "qtg_large_phonebook" << "qtg_large_tone" << "qtg_large_video" |
|
1201 << "qtg_large_photos" << "qtg_large_message" << "qtg_large_email" |
|
1202 << "qtg_large_calendar" << "qtg_large_notes" |
|
1203 << "qtg_large_web_link" << "qtg_large_text" << "qtg_large_sisx" |
|
1204 << "qtg_large_java" << "qtg_large_flash" << "qtg_large_folder" |
|
1205 << "qtg_large_query"; |
|
1206 mIconArray.clear(); |
|
1207 for (int i = 0; i < icons.count(); i++) |
|
1208 { |
|
1209 HbIcon icon(icons.at(i)); |
|
1210 if (icon.isNull() || !(icon.size().isValid())) |
|
1211 icon = HbIcon("qtg_large_application"); |
|
1212 mIconArray.append(icon); |
|
1213 } |
|
1214 /*QList<TUid> appUid; |
|
1215 appUid.append(TUid::Uid(0x20022EF9));//contact |
|
1216 appUid.append(TUid::Uid(0x10207C62));//audio |
|
1217 appUid.append(TUid::Uid(0x200211FE));//video |
|
1218 appUid.append(TUid::Uid(0x20000A14));//image |
|
1219 appUid.append(TUid::Uid(0x2001FE79));//msg |
|
1220 appUid.append(TUid::Uid(0x200255BA));//email |
|
1221 appUid.append(TUid::Uid(0x10005901));//calender |
|
1222 appUid.append(TUid::Uid(0x20029F80));//notes |
|
1223 //appUid.Append(TUid::Uid(0x20022F35));//application |
|
1224 appUid.append(TUid::Uid(0x10008D39));//bookmark |
|
1225 appUid.append(TUid::Uid(0x2002BCC0));//files |
|
1226 |
|
1227 for (int i = 0; i < appUid.count(); i++) |
|
1228 { |
|
1229 TRAP_IGNORE(mIconArray.append(getAppIconFromAppIdL(appUid.at(i)))); |
|
1230 }*/ |
|
1231 } |
|
1232 // --------------------------------------------------------------------------- |
|
1233 // SearchProgressiveState::activityRequested |
|
1234 // --------------------------------------------------------------------------- |
|
1235 void SearchProgressiveState::activityRequested(const QString &name) |
|
1236 { |
|
1237 /* when search application is launched in normal and then supporting for activity uri |
|
1238 * for normal search launching "media" is used instead of "media image","media audio","media video" |
|
1239 */ |
|
1240 if (mSearchHandlerList.count() != totalcategories_activityreasonreason) |
|
1241 { |
|
1242 InDeviceHandler* handler = NULL; |
|
1243 handler->setCategory("media image"); |
|
1244 mSearchHandlerList.append(handler); |
|
1245 handler->setCategory("media audio"); |
|
1246 mSearchHandlerList.append(handler); |
|
1247 handler->setCategory("media video"); |
|
1248 mSearchHandlerList.append(handler); |
|
1249 } |
|
1250 if (name == "SearchDeviceQueryView") |
|
1251 { |
|
1252 QVariantHash params = hbApp->activateParams(); |
|
1253 QString searchKey = params.value("query").toString(); |
|
1254 int i = params.count(); |
|
1255 params.remove("query"); |
|
1256 params.remove("activityname"); |
|
1257 QList<QVariant> list = params.values(); |
|
1258 int j = list.count(); |
|
1259 mTemplist.clear(); |
|
1260 for (int i = 0; i < list.count(); i++) |
|
1261 { |
|
1262 QString str = list.at(i).toString(); |
|
1263 if (!str.isNull()) |
|
1264 mTemplist.append(str); |
|
1265 } |
|
1266 if (searchKey.length() > 0) |
|
1267 mSearchPanel->setCriteria(searchKey); |
|
1268 } |
|
1269 } |
|
1270 // --------------------------------------------------------------------------- |
|
1271 // SearchProgressiveState::parseDocument |
|
1272 // --------------------------------------------------------------------------- |
|
1273 void SearchProgressiveState::parseDocument(CpixDocument* aDoc) |
|
1274 { |
|
1275 PERF_CAT_GETDOC_TIME_ACCUMULATE |
|
1276 if (aDoc == NULL) |
|
1277 return; |
|
1278 QString secondrow = aDoc->excerpt(); |
|
1279 QString firstrow; |
|
1280 HbListWidgetItem* listitem = new HbListWidgetItem(); |
|
1281 |
|
1282 if (aDoc->baseAppClass().contains("contact")) |
|
1283 { |
|
1284 QStringList docsList = filterDoc(aDoc, "GivenName", "FamilyName"); |
|
1285 if (docsList.value(0, "").length()) |
|
1286 { |
|
1287 firstrow.append(docsList.at(0)); |
|
1288 } |
|
1289 if (docsList.value(1, "").length()) |
|
1290 { |
|
1291 if (firstrow.length()) |
|
1292 firstrow.append(" "); |
|
1293 firstrow.append(docsList.at(1)); |
|
1294 } |
|
1295 if (firstrow.length() == 0) |
|
1296 { |
|
1297 firstrow = hbTrId("txt_phob_dblist_unnamed"); |
|
1298 } |
|
1299 listitem->setData(mIconArray.at(0), Qt::DecorationRole); |
|
1300 } |
|
1301 else if (aDoc->baseAppClass().contains("audio")) |
|
1302 { |
|
1303 QStringList audioList = filterDoc(aDoc, "Title", "MediaId"); |
|
1304 if (audioList.value(0, "").length()) |
|
1305 { |
|
1306 firstrow.append(audioList.at(0)); |
|
1307 } |
|
1308 if (firstrow.length() == 0) |
|
1309 { |
|
1310 firstrow = hbTrId("txt_mus_dblist_val_unknown4"); |
|
1311 } |
|
1312 listitem->setData(mIconArray.at(1), Qt::DecorationRole); |
|
1313 if (audioList.value(1, "").length()) |
|
1314 { |
|
1315 listitem->setData(audioList.at(1), Qt::UserRole + 2); |
|
1316 } |
|
1317 } |
|
1318 else if (aDoc->baseAppClass().contains("video")) |
|
1319 { |
|
1320 QStringList videoList = filterDoc(aDoc, "Title", "MediaId", "Name"); |
|
1321 if (videoList.value(0, "").length()) |
|
1322 { |
|
1323 firstrow.append(videoList.at(0)); |
|
1324 } |
|
1325 if (firstrow.length() == 0 && videoList.value(2, "").length()) |
|
1326 { |
|
1327 firstrow.append(videoList.at(2)); |
|
1328 } |
|
1329 listitem->setData(mIconArray.at(2), Qt::DecorationRole); |
|
1330 if (videoList.value(1, "").length()) |
|
1331 { |
|
1332 listitem->setData(videoList.at(1), Qt::UserRole + 2); |
|
1333 } |
|
1334 } |
|
1335 else if (aDoc->baseAppClass().contains("image")) |
|
1336 { |
|
1337 QStringList imageList = filterDoc(aDoc, "Name", "MediaId"); |
|
1338 if (imageList.value(0, "").length()) |
|
1339 { |
|
1340 firstrow.append(imageList.at(0)); |
|
1341 } |
|
1342 listitem->setData(mIconArray.at(3), Qt::DecorationRole); |
|
1343 if (imageList.value(1, "").length()) |
|
1344 { |
|
1345 listitem->setData(imageList.at(1), Qt::UserRole + 2); |
|
1346 } |
|
1347 } |
|
1348 else if (aDoc->baseAppClass().contains("msg email")) |
|
1349 { |
|
1350 QStringList emailList = filterDoc(aDoc, "Sender", "MailBoxId", |
|
1351 "FolderId"); |
|
1352 firstrow.append(emailList.at(0)); |
|
1353 listitem->setData(emailList.at(1), Qt::UserRole + 2); |
|
1354 listitem->setData(emailList.at(2), Qt::UserRole + 3); |
|
1355 listitem->setData(mIconArray.at(5), Qt::DecorationRole); |
|
1356 } |
|
1357 else if (aDoc->baseAppClass().contains("msg")) |
|
1358 { |
|
1359 QStringList msgList = filterDoc(aDoc, "Folder", "To", "From"); |
|
1360 if (msgList.value(0).contains("Inbox")) |
|
1361 { |
|
1362 firstrow.append(msgList.at(2)); |
|
1363 } |
|
1364 else |
|
1365 { |
|
1366 if (msgList.value(1, "").length()) |
|
1367 firstrow.append(msgList.at(1)); |
|
1368 } |
|
1369 listitem->setData(mIconArray.at(4), Qt::DecorationRole); |
|
1370 } |
|
1371 else if (aDoc->baseAppClass().contains("calendar")) |
|
1372 { |
|
1373 firstrow.append(filterDoc(aDoc, "Summary")); |
|
1374 if (firstrow.length() == 0) |
|
1375 { |
|
1376 firstrow = hbTrId("txt_calendar_preview_unnamed"); |
|
1377 } |
|
1378 listitem->setData(mIconArray.at(6), Qt::DecorationRole); |
|
1379 } |
|
1380 else if (aDoc->baseAppClass().contains("notes")) |
|
1381 { |
|
1382 firstrow.append(filterDoc(aDoc, "Memo")); |
|
1383 if (firstrow.length() == 0) |
|
1384 { |
|
1385 firstrow = hbTrId("txt_notes_dblist_unnamed"); |
|
1386 } |
|
1387 listitem->setData(mIconArray.at(7), Qt::DecorationRole); |
|
1388 } |
|
1389 else if (aDoc->baseAppClass().contains("applications")) |
|
1390 { |
|
1391 firstrow.append(filterDoc(aDoc, "Name")); |
|
1392 bool ok; |
|
1393 TRAP_IGNORE(listitem->setData(getAppIconFromAppIdL(TUid::Uid(aDoc->docId().toUInt( |
|
1394 &ok, 16))), Qt::DecorationRole)); |
|
1395 } |
|
1396 else if (aDoc->baseAppClass().contains("bookmark")) |
|
1397 { |
|
1398 firstrow.append(filterDoc(aDoc, "Name")); |
|
1399 if (firstrow.length() == 0) |
|
1400 { |
|
1401 firstrow = "UnKnown"; |
|
1402 } |
|
1403 listitem->setData(secondrow, Qt::UserRole + 2); |
|
1404 listitem->setData(mIconArray.at(8), Qt::DecorationRole); |
|
1405 } |
|
1406 else if (aDoc->baseAppClass().contains("file folder")) |
|
1407 { |
|
1408 bool ok; |
|
1409 QStringList fileList = filterDoc(aDoc, "Name", "IsFolder", |
|
1410 "Extension"); |
|
1411 firstrow = fileList.at(0); |
|
1412 if (fileList.at(1).toInt(&ok) == 1) // folder result icon map |
|
1413 |
|
1414 { |
|
1415 listitem->setData(mIconArray.at(13), Qt::DecorationRole); |
|
1416 } |
|
1417 else |
|
1418 { |
|
1419 if (fileList.at(2).contains("sis", Qt::CaseInsensitive) |
|
1420 || fileList.at(1).contains("sisx", Qt::CaseInsensitive)) |
|
1421 { |
|
1422 listitem->setData(mIconArray.at(10), Qt::DecorationRole); |
|
1423 } |
|
1424 else if (fileList.at(2).contains("java", Qt::CaseInsensitive) |
|
1425 || fileList.at(2).contains("jar", Qt::CaseInsensitive) |
|
1426 || fileList.at(2).contains("jad", Qt::CaseInsensitive)) |
|
1427 { |
|
1428 listitem->setData(mIconArray.at(11), Qt::DecorationRole); |
|
1429 } |
|
1430 else if (fileList.at(2).contains("swf", Qt::CaseInsensitive)) |
|
1431 { |
|
1432 listitem->setData(mIconArray.at(12), Qt::DecorationRole); |
|
1433 } |
|
1434 else |
|
1435 { |
|
1436 listitem->setData(mIconArray.at(14), Qt::DecorationRole); |
|
1437 } |
|
1438 } |
|
1439 } |
|
1440 else if (aDoc->baseAppClass().contains("file")) |
|
1441 { |
|
1442 QStringList fileList = filterDoc(aDoc, "Name", "Extension"); |
|
1443 firstrow = fileList.at(0); |
|
1444 if (firstrow.length() == 0) |
|
1445 firstrow = aDoc->baseAppClass(); |
|
1446 if (fileList.at(1).contains("txt", Qt::CaseInsensitive)) |
|
1447 { |
|
1448 listitem->setData(mIconArray.at(9), Qt::DecorationRole); |
|
1449 } |
|
1450 else |
|
1451 { |
|
1452 listitem->setData(mIconArray.at(14), Qt::DecorationRole); |
|
1453 } |
|
1454 } |
|
1455 listitem->setText(firstrow); |
|
1456 listitem->setSecondaryText(secondrow); |
|
1457 listitem->setData(aDoc->docId(), Qt::UserRole); |
|
1458 listitem->setData(aDoc->baseAppClass(), Qt::UserRole + 1); |
|
1459 mListView->addItem(listitem); |
|
1460 |
|
1461 delete aDoc; |
|
1462 } |
|
1463 |
|
1464 InDeviceHandler* SearchProgressiveState::constructHandlers(int mDatabase) |
|
1465 { |
|
1466 InDeviceHandler* handler = NULL; |
|
1467 handler = new InDeviceHandler(); |
|
1468 switch (mDatabase) |
|
1469 { |
|
1470 case 0: |
|
1471 { |
|
1472 handler->setCategory(""); |
|
1473 break; |
|
1474 } |
|
1475 case 1: |
|
1476 { |
|
1477 handler->setCategory("contact"); |
|
1478 break; |
|
1479 } |
|
1480 case 2: |
|
1481 { |
|
1482 handler->setCategory("media"); |
|
1483 break; |
|
1484 } |
|
1485 case 3: |
|
1486 { |
|
1487 handler->setCategory("msg"); |
|
1488 break; |
|
1489 } |
|
1490 case 4: |
|
1491 { |
|
1492 handler->setCategory("msg email"); |
|
1493 break; |
|
1494 } |
|
1495 case 5: |
|
1496 { |
|
1497 handler->setCategory("calendar"); |
|
1498 break; |
|
1499 } |
|
1500 case 6: |
|
1501 { |
|
1502 handler->setCategory("notes"); |
|
1503 break; |
|
1504 } |
|
1505 case 7: |
|
1506 { |
|
1507 handler->setCategory("applications"); |
|
1508 break; |
|
1509 } |
|
1510 case 8: |
|
1511 { |
|
1512 handler->setCategory("file"); |
|
1513 break; |
|
1514 } |
|
1515 case 9: |
|
1516 { |
|
1517 // handler->setCategory("bookmark"); |
|
1518 break; |
|
1519 } |
|
1520 case 10: |
|
1521 { |
|
1522 handler->setCategory("media image"); |
|
1523 break; |
|
1524 } |
|
1525 case 11: |
|
1526 { |
|
1527 handler->setCategory("media audio"); |
|
1528 break; |
|
1529 } |
|
1530 case 12: |
|
1531 { |
|
1532 handler->setCategory("media video"); |
|
1533 break; |
|
1534 } |
|
1535 } |
|
1536 return handler; |
|
1537 } |