searchui/stateproviders/searchstateprovider/src/searchprogressivestate.cpp
changeset 16 e918432ddd92
parent 15 df6898e696c6
child 18 1edf350003c5
equal deleted inserted replaced
15:df6898e696c6 16:e918432ddd92
    54 #include <hblistviewitem.h>
    54 #include <hblistviewitem.h>
    55 #include <hbactivitymanager.h>
    55 #include <hbactivitymanager.h>
    56 #define hbApp qobject_cast<HbApplication*>(qApp)
    56 #define hbApp qobject_cast<HbApplication*>(qApp)
    57 const int totalcategories_normalreason = 10;
    57 const int totalcategories_normalreason = 10;
    58 const int totalcategories_activityreasonreason = 13;
    58 const int totalcategories_activityreasonreason = 13;
       
    59 const int intial_iteration = 3;
       
    60 const int batch_iteration = 20;
    59 // ---------------------------------------------------------------------------
    61 // ---------------------------------------------------------------------------
    60 // SearchProgressiveState::SearchProgressiveState
    62 // SearchProgressiveState::SearchProgressiveState
    61 // ---------------------------------------------------------------------------
    63 // ---------------------------------------------------------------------------
    62 SearchProgressiveState::SearchProgressiveState(QState *parent) :
    64 SearchProgressiveState::SearchProgressiveState(QState *parent) :
    63     QState(parent), mMainWindow(NULL), mView(NULL), mListView(NULL),
    65     QState(parent), mMainWindow(NULL), mView(NULL), mListView(NULL),
    64             mSearchHandler(NULL), mNotesEditor(0), mAiwMgr(0), mRequest(0)
    66             mSearchHandler(NULL), mNotesEditor(0), mAiwMgr(0), mRequest(0)
    65     {
    67     {
       
    68     mUiLoader = SearchUiLoader::instance();
    66 
    69 
    67     mMainWindow = hbInstance->allMainWindows().at(0);
    70     mMainWindow = hbInstance->allMainWindows().at(0);
    68 
    71 
    69     mAiwMgr = new XQApplicationManager;
    72     mAiwMgr = new XQApplicationManager;
    70 
       
    71     mUiLoader = SearchUiLoader::instance();
       
    72 
    73 
    73     mView = mUiLoader->View();
    74     mView = mUiLoader->View();
    74     mListView = mUiLoader->ListWidget();
    75     mListView = mUiLoader->ListWidget();
    75     mSearchPanel = mUiLoader->SearchPanel();
    76     mSearchPanel = mUiLoader->SearchPanel();
    76 
    77 
   134 
   135 
   135     mOnlineQueryAvailable = false;
   136     mOnlineQueryAvailable = false;
   136     //Prepare the icons,listen of theme change    
   137     //Prepare the icons,listen of theme change    
   137     connect(hbInstance->theme(), SIGNAL(changeFinished()), this,
   138     connect(hbInstance->theme(), SIGNAL(changeFinished()), this,
   138             SLOT(slotPrepareResultIcons()));
   139             SLOT(slotPrepareResultIcons()));
   139     slotPrepareResultIcons();    
   140     slotPrepareResultIcons();
       
   141 
       
   142     // creating the handler if it is not prepared, useful when user try to create before 
       
   143     mValidateHandlerCreation = false;
   140     }
   144     }
   141 // ---------------------------------------------------------------------------
   145 // ---------------------------------------------------------------------------
   142 // SearchProgressiveState::~SearchProgressiveState
   146 // SearchProgressiveState::~SearchProgressiveState
   143 // ---------------------------------------------------------------------------
   147 // ---------------------------------------------------------------------------
   144 SearchProgressiveState::~SearchProgressiveState()
   148 SearchProgressiveState::~SearchProgressiveState()
   167 
   171 
   168     if (hbApp && hbApp->activateReason() == Hb::ActivationReasonActivity)
   172     if (hbApp && hbApp->activateReason() == Hb::ActivationReasonActivity)
   169         {
   173         {
   170         categories = totalcategories_activityreasonreason;
   174         categories = totalcategories_activityreasonreason;
   171         }
   175         }
   172     InDeviceHandler* handler = NULL;
       
   173     for (int i = 0; i < categories; i++)
   176     for (int i = 0; i < categories; i++)
   174         {
   177         {
   175         handler = new InDeviceHandler();
   178         mSearchHandlerList.append(constructHandlers(i));
   176         switch (i)
       
   177             {
       
   178             case 0:
       
   179                 {
       
   180                 handler->setCategory("");
       
   181                 break;
       
   182                 }
       
   183             case 1:
       
   184                 {
       
   185                 handler->setCategory("contact");
       
   186                 break;
       
   187                 }
       
   188             case 2:
       
   189                 {
       
   190                 handler->setCategory("media");
       
   191                 break;
       
   192                 }
       
   193             case 3:
       
   194                 {
       
   195                 handler->setCategory("msg");
       
   196                 break;
       
   197                 }
       
   198             case 4:
       
   199                 {
       
   200                 handler->setCategory("msg email");
       
   201                 break;
       
   202                 }
       
   203             case 5:
       
   204                 {
       
   205                 handler->setCategory("calendar");
       
   206                 break;
       
   207                 }
       
   208             case 6:
       
   209                 {
       
   210                 handler->setCategory("notes");
       
   211                 break;
       
   212                 }
       
   213             case 7:
       
   214                 {
       
   215                 handler->setCategory("applications");
       
   216                 break;
       
   217                 }
       
   218             case 8:
       
   219                 {
       
   220                 handler->setCategory("file");
       
   221                 break;
       
   222                 }
       
   223             case 9:
       
   224                 {
       
   225                 handler->setCategory("bookmark");
       
   226                 break;
       
   227                 }
       
   228             case 10:
       
   229                 {
       
   230                 handler->setCategory("media image");
       
   231                 break;
       
   232                 }
       
   233             case 11:
       
   234                 {
       
   235                 handler->setCategory("media audio");
       
   236                 break;
       
   237                 }
       
   238             case 12:
       
   239                 {
       
   240                 handler->setCategory("media video");
       
   241                 break;
       
   242                 }
       
   243             }
       
   244         mSearchHandlerList.append(handler);
       
   245         }
   179         }
   246     }
   180     }
   247 // ---------------------------------------------------------------------------
   181 // ---------------------------------------------------------------------------
   248 // SearchProgressiveState::onEntry
   182 // SearchProgressiveState::onEntry
   249 // ---------------------------------------------------------------------------
   183 // ---------------------------------------------------------------------------
   273             }
   207             }
   274         mMainWindow->show();
   208         mMainWindow->show();
   275         }
   209         }
   276     if (loadSettings)
   210     if (loadSettings)
   277         {
   211         {
       
   212         // to get the intial settings form delimeter  
   278         emit switchProToSettingsState();
   213         emit switchProToSettingsState();
   279         loadSettings = false;
   214         loadSettings = false;
   280         }
   215         }
   281     setSelectedCategories();
   216     setSelectedCategories();
   282     if (mOnlineQueryAvailable)
   217     if (mOnlineQueryAvailable)
   290 // ---------------------------------------------------------------------------
   225 // ---------------------------------------------------------------------------
   291 void SearchProgressiveState::onExit(QEvent *event)
   226 void SearchProgressiveState::onExit(QEvent *event)
   292     {
   227     {
   293     QState::onExit(event);
   228     QState::onExit(event);
   294     mStateStatus = false;
   229     mStateStatus = false;
   295     deActivateSignals();    
   230     deActivateSignals();
   296     }
   231     }
   297 // ---------------------------------------------------------------------------
   232 // ---------------------------------------------------------------------------
   298 // SearchProgressiveState::activateSignals
   233 // SearchProgressiveState::activateSignals
   299 // ---------------------------------------------------------------------------
   234 // ---------------------------------------------------------------------------
   300 void SearchProgressiveState::activateSignals()
   235 void SearchProgressiveState::activateSignals()
   305                 SIGNAL(handleAsyncSearchResult(int,int)), this,
   240                 SIGNAL(handleAsyncSearchResult(int,int)), this,
   306                 SLOT(onAsyncSearchComplete(int,int)));
   241                 SLOT(onAsyncSearchComplete(int,int)));
   307         connect(mSearchHandlerList.at(i),
   242         connect(mSearchHandlerList.at(i),
   308                 SIGNAL(handleDocument(int,CpixDocument*)), this,
   243                 SIGNAL(handleDocument(int,CpixDocument*)), this,
   309                 SLOT(onGetDocumentComplete(int,CpixDocument*)));
   244                 SLOT(onGetDocumentComplete(int,CpixDocument*)));
       
   245         connect(mSearchHandlerList.at(i),
       
   246                 SIGNAL(handleBatchDocument(int,int,CpixDocument**)), this,
       
   247                 SLOT(onGetBatchDocumentComplete(int,int,CpixDocument**)));
       
   248 
   310         }
   249         }
   311     if (mListView)
   250     if (mListView)
   312         {
   251         {
   313         connect(mListView, SIGNAL(activated(HbListWidgetItem *)), this,
   252         connect(mListView, SIGNAL(activated(HbListWidgetItem *)), this,
   314                 SLOT(openResultitem(HbListWidgetItem *)));
   253                 SLOT(openResultitem(HbListWidgetItem *)));
   333                 SIGNAL(handleAsyncSearchResult(int,int)), this,
   272                 SIGNAL(handleAsyncSearchResult(int,int)), this,
   334                 SLOT(onAsyncSearchComplete(int,int)));
   273                 SLOT(onAsyncSearchComplete(int,int)));
   335         disconnect(mSearchHandlerList.at(i),
   274         disconnect(mSearchHandlerList.at(i),
   336                 SIGNAL(handleDocument(int,CpixDocument*)), this,
   275                 SIGNAL(handleDocument(int,CpixDocument*)), this,
   337                 SLOT(onGetDocumentComplete(int,CpixDocument*)));
   276                 SLOT(onGetDocumentComplete(int,CpixDocument*)));
       
   277         disconnect(mSearchHandlerList.at(i),
       
   278                 SIGNAL(handleBatchDocument(int,int,CpixDocument**)), this,
       
   279                 SLOT(onGetBatchDocumentComplete(int,int,CpixDocument**)));
   338         }
   280         }
   339     if (mListView)
   281     if (mListView)
   340         {
   282         {
   341         disconnect(mListView, SIGNAL(activated(HbListWidgetItem *)), this,
   283         disconnect(mListView, SIGNAL(activated(HbListWidgetItem *)), this,
   342                 SLOT(openResultitem(HbListWidgetItem *)));
   284                 SLOT(openResultitem(HbListWidgetItem *)));
   381 // SearchProgressiveState::onGetDocumentComplete
   323 // SearchProgressiveState::onGetDocumentComplete
   382 // ---------------------------------------------------------------------------
   324 // ---------------------------------------------------------------------------
   383 void SearchProgressiveState::onGetDocumentComplete(int aError,
   325 void SearchProgressiveState::onGetDocumentComplete(int aError,
   384         CpixDocument* aDoc)
   326         CpixDocument* aDoc)
   385     {
   327     {
   386     PERF_CAT_GETDOC_TIME_ACCUMULATE
   328     if (aError)
   387     if (aDoc == NULL || aError != 0)
       
   388         return;
   329         return;
   389     QString secondrow = aDoc->excerpt();
   330     parseDocument(aDoc);
   390     QString firstrow;
       
   391     HbListWidgetItem* listitem = new HbListWidgetItem();
       
   392 
       
   393     if (aDoc->baseAppClass().contains("contact"))
       
   394         {
       
   395         QStringList docsList = filterDoc(aDoc, "GivenName", "FamilyName");
       
   396         if (docsList.value(0, "").length())
       
   397             {
       
   398             firstrow.append(docsList.at(0));
       
   399             }
       
   400         if (docsList.value(1, "").length())
       
   401             {
       
   402             if (firstrow.length())
       
   403                 firstrow.append(" ");
       
   404             firstrow.append(docsList.at(1));
       
   405             }
       
   406         if (firstrow.length() == 0)
       
   407             {
       
   408             firstrow = hbTrId("txt_phob_dblist_unnamed");
       
   409             }
       
   410         listitem->setData(mIconArray.at(0), Qt::DecorationRole);
       
   411         }
       
   412     else if (aDoc->baseAppClass().contains("audio"))
       
   413         {
       
   414         QStringList audioList = filterDoc(aDoc, "Title", "MediaId");
       
   415         if (audioList.value(0, "").length())
       
   416             {
       
   417             firstrow.append(audioList.at(0));
       
   418             }
       
   419         if (firstrow.length() == 0)
       
   420             {
       
   421             firstrow = hbTrId("txt_mus_dblist_val_unknown4");
       
   422             }
       
   423         listitem->setData(mIconArray.at(1), Qt::DecorationRole);
       
   424         if (audioList.value(1, "").length())
       
   425             {
       
   426             listitem->setData(audioList.at(1), Qt::UserRole + 2);
       
   427             }
       
   428         }
       
   429     else if (aDoc->baseAppClass().contains("video"))
       
   430         {
       
   431         QStringList videoList = filterDoc(aDoc, "Title", "MediaId", "Name");
       
   432         if (videoList.value(0, "").length())
       
   433             {
       
   434             firstrow.append(videoList.at(0));
       
   435             }
       
   436         if (firstrow.length() == 0 && videoList.value(2, "").length())
       
   437             {
       
   438             firstrow.append(videoList.at(2));
       
   439             }
       
   440         listitem->setData(mIconArray.at(2), Qt::DecorationRole);
       
   441         if (videoList.value(1, "").length())
       
   442             {
       
   443             listitem->setData(videoList.at(1), Qt::UserRole + 2);
       
   444             }
       
   445         }
       
   446     else if (aDoc->baseAppClass().contains("image"))
       
   447         {
       
   448         QStringList imageList = filterDoc(aDoc, "Name", "MediaId");
       
   449         if (imageList.value(0, "").length())
       
   450             {
       
   451             firstrow.append(imageList.at(0));
       
   452             }
       
   453         listitem->setData(mIconArray.at(3), Qt::DecorationRole);
       
   454         if (imageList.value(1, "").length())
       
   455             {
       
   456             listitem->setData(imageList.at(1), Qt::UserRole + 2);
       
   457             }
       
   458         }
       
   459     else if (aDoc->baseAppClass().contains("msg email"))
       
   460         {
       
   461         QStringList emailList = filterDoc(aDoc, "Sender", "MailBoxId",
       
   462                 "FolderId");
       
   463         firstrow.append(emailList.at(0));
       
   464         listitem->setData(emailList.at(1), Qt::UserRole + 2);
       
   465         listitem->setData(emailList.at(2), Qt::UserRole + 3);
       
   466         listitem->setData(mIconArray.at(5), Qt::DecorationRole);
       
   467         }
       
   468     else if (aDoc->baseAppClass().contains("msg"))
       
   469         {
       
   470         QStringList msgList = filterDoc(aDoc, "Folder", "To", "From");
       
   471         if (msgList.value(0).contains("Inbox"))
       
   472             {
       
   473             firstrow.append(msgList.at(2));
       
   474             }
       
   475         else
       
   476             {
       
   477             if (msgList.value(1, "").length())
       
   478                 firstrow.append(msgList.at(1));
       
   479             }
       
   480         listitem->setData(mIconArray.at(4), Qt::DecorationRole);
       
   481         }
       
   482     else if (aDoc->baseAppClass().contains("calendar"))
       
   483         {
       
   484         firstrow.append(filterDoc(aDoc, "Summary"));
       
   485         if (firstrow.length() == 0)
       
   486             {
       
   487             firstrow = hbTrId("txt_calendar_preview_unnamed");
       
   488             }
       
   489         listitem->setData(mIconArray.at(6), Qt::DecorationRole);
       
   490         }
       
   491     else if (aDoc->baseAppClass().contains("notes"))
       
   492         {
       
   493         firstrow.append(filterDoc(aDoc, "Memo"));
       
   494         if (firstrow.length() == 0)
       
   495             {
       
   496             firstrow = hbTrId("txt_notes_dblist_unnamed");
       
   497             }
       
   498         listitem->setData(mIconArray.at(7), Qt::DecorationRole);
       
   499         }
       
   500     else if (aDoc->baseAppClass().contains("applications"))
       
   501         {
       
   502         firstrow.append(filterDoc(aDoc, "Name"));
       
   503         bool ok;
       
   504         TRAP_IGNORE(listitem->setData(getAppIconFromAppIdL(TUid::Uid(aDoc->docId().toInt(
       
   505                                                 &ok, 16))), Qt::DecorationRole));
       
   506         }
       
   507     else if (aDoc->baseAppClass().contains("bookmark"))
       
   508         {
       
   509         firstrow.append(filterDoc(aDoc, "Name"));
       
   510         if (firstrow.length() == 0)
       
   511             {
       
   512             firstrow = "UnKnown";
       
   513             }
       
   514         listitem->setData(secondrow, Qt::UserRole + 2);
       
   515         listitem->setData(mIconArray.at(8), Qt::DecorationRole);
       
   516         }
       
   517     else if (aDoc->baseAppClass().contains("file folder"))
       
   518         {
       
   519         bool ok;
       
   520         QStringList fileList = filterDoc(aDoc, "Name", "IsFolder",
       
   521                 "Extension");
       
   522         firstrow = fileList.at(0);
       
   523         if (fileList.at(1).toInt(&ok) == 1) // folder result icon map 
       
   524             {
       
   525             listitem->setData(mIconArray.at(13), Qt::DecorationRole);
       
   526             }
       
   527         else
       
   528             {
       
   529             if (fileList.at(2).contains("sis", Qt::CaseInsensitive)
       
   530                     || fileList.at(1).contains("sisx", Qt::CaseInsensitive))
       
   531                 {
       
   532                 listitem->setData(mIconArray.at(10), Qt::DecorationRole);
       
   533                 }
       
   534             else if (fileList.at(2).contains("java", Qt::CaseInsensitive)
       
   535                     || fileList.at(2).contains("jar", Qt::CaseInsensitive)
       
   536                     || fileList.at(2).contains("jad", Qt::CaseInsensitive))
       
   537                 {
       
   538                 listitem->setData(mIconArray.at(11), Qt::DecorationRole);
       
   539                 }
       
   540             else if (fileList.at(2).contains("swf", Qt::CaseInsensitive))
       
   541                 {
       
   542                 listitem->setData(mIconArray.at(12), Qt::DecorationRole);
       
   543                 }
       
   544             else
       
   545                 {
       
   546                 listitem->setData(mIconArray.at(14), Qt::DecorationRole);
       
   547                 }
       
   548             }
       
   549         }
       
   550     else if (aDoc->baseAppClass().contains("file"))
       
   551         {
       
   552         QStringList fileList = filterDoc(aDoc, "Name", "Extension");
       
   553         firstrow = fileList.at(0);
       
   554         if (firstrow.length() == 0)
       
   555             firstrow = aDoc->baseAppClass();
       
   556         if (fileList.at(1).contains("txt", Qt::CaseInsensitive))
       
   557             {
       
   558             listitem->setData(mIconArray.at(9), Qt::DecorationRole);
       
   559             }
       
   560         else
       
   561             {
       
   562             listitem->setData(mIconArray.at(14), Qt::DecorationRole);
       
   563             }
       
   564         }
       
   565     listitem->setText(firstrow);
       
   566     listitem->setSecondaryText(secondrow);
       
   567     listitem->setData(aDoc->docId(), Qt::UserRole);
       
   568     listitem->setData(aDoc->baseAppClass(), Qt::UserRole + 1);
       
   569     mListView->addItem(listitem);
       
   570 
       
   571     mResultparser++;
   331     mResultparser++;
   572     if (mResultparser < mResultcount)
   332     if (mResultparser < mResultcount)
   573         {
   333         {
   574         PERF_CAT_GETDOC_TIME_RESTART
   334         PERF_CAT_GETDOC_TIME_RESTART
   575         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             }
   576         }
   344         }
   577     else
   345     else
   578         {
   346         {
   579         PERF_CAT_GETDOC_ACCUMULATOR_ENDLOG
   347         PERF_CAT_GETDOC_ACCUMULATOR_ENDLOG
   580         searchOnCategory(mSearchString);
   348         searchOnCategory(mSearchString);
   581         }
   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         }
   582     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         }
   583     }
   376     }
   584 // ---------------------------------------------------------------------------
   377 // ---------------------------------------------------------------------------
   585 // SearchProgressiveState::getSettingCategory
   378 // SearchProgressiveState::getSettingCategory
   586 // ---------------------------------------------------------------------------
   379 // ---------------------------------------------------------------------------
   587 void SearchProgressiveState::getSettingCategory(int item, bool avalue)
   380 void SearchProgressiveState::getSettingCategory(int item, bool avalue)
   592 // SearchProgressiveState::openResultitem
   385 // SearchProgressiveState::openResultitem
   593 // ---------------------------------------------------------------------------
   386 // ---------------------------------------------------------------------------
   594 void SearchProgressiveState::openResultitem(HbListWidgetItem * item)
   387 void SearchProgressiveState::openResultitem(HbListWidgetItem * item)
   595     {
   388     {
   596     if (item == NULL)
   389     if (item == NULL)
   597         return;PERF_RESULT_ITEM_LAUNCH_TIME_RESTART
   390         return;
       
   391     PERF_RESULT_ITEM_LAUNCH_TIME_RESTART
   598     QList<QVariant> args;
   392     QList<QVariant> args;
   599     bool t;
   393     bool t;
   600     mRequest = NULL;
   394     mRequest = NULL;
   601     if (item->data(Qt::UserRole + 1).toString().contains("contact"))
   395     if (item->data(Qt::UserRole + 1).toString().contains("contact"))
   602         {
   396         {
   609         }
   403         }
   610     else if (item->data(Qt::UserRole + 1).toString().contains("bookmark"))
   404     else if (item->data(Qt::UserRole + 1).toString().contains("bookmark"))
   611         {
   405         {
   612         PERF_RESULT_ITEM_FOR_LAUNCHING("bookmark")
   406         PERF_RESULT_ITEM_FOR_LAUNCHING("bookmark")
   613         QDesktopServices::openUrl(item->data(Qt::UserRole + 2).toString());
   407         QDesktopServices::openUrl(item->data(Qt::UserRole + 2).toString());
   614 PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG        ("")
   408         PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG ("")
   615 
   409 
   616         }
   410         }
   617     else if (item->data(Qt::UserRole + 1).toString().contains("calendar"))
   411     else if (item->data(Qt::UserRole + 1).toString().contains("calendar"))
   618         {
   412         {
   619         QDir pluginDir = QDir(QString("z:/resource/qt/plugins/calendar"));
   413         QDir pluginDir = QDir(QString("z:/resource/qt/plugins/calendar"));
   620         QPluginLoader *calAgandaViewerPluginLoader = new QPluginLoader(
   414         QPluginLoader *calAgandaViewerPluginLoader = new QPluginLoader(
   621                 pluginDir.absoluteFilePath(QString(
   415                 pluginDir.absoluteFilePath(QString(
   622                                 "agendaeventviewerplugin.qtplugin")));
   416                         "agendaeventviewerplugin.qtplugin")));
   623 
   417 
   624         calAgandaViewerPluginInstance = qobject_cast<
   418         calAgandaViewerPluginInstance = qobject_cast<
   625         EventViewerPluginInterface *> (
   419                 EventViewerPluginInterface *> (
   626                 calAgandaViewerPluginLoader->instance());
   420                 calAgandaViewerPluginLoader->instance());
   627 
   421 
   628         connect(calAgandaViewerPluginInstance, SIGNAL(viewingCompleted()),
   422         connect(calAgandaViewerPluginInstance, SIGNAL(viewingCompleted()),
   629                 this, SLOT(_viewingCompleted()));
   423                 this, SLOT(_viewingCompleted()));
   630 
   424 
   633                 EventViewerPluginInterface::ActionEditDelete, NULL);
   427                 EventViewerPluginInterface::ActionEditDelete, NULL);
   634         }
   428         }
   635     else if (item->data(Qt::UserRole + 1).toString().contains("applications"))
   429     else if (item->data(Qt::UserRole + 1).toString().contains("applications"))
   636         {
   430         {
   637         PERF_RESULT_ITEM_FOR_LAUNCHING("applications")
   431         PERF_RESULT_ITEM_FOR_LAUNCHING("applications")
   638         TRAP_IGNORE(LaunchApplicationL(TUid::Uid((item->data(Qt::UserRole)).toString().toInt(&t, 16))));
   432         TRAP_IGNORE(LaunchApplicationL(TUid::Uid((item->data(Qt::UserRole)).toString().toUInt(&t, 16))));
   639         PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG("")
   433         PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG("")
   640         }
   434         }
   641     else if (item->data(Qt::UserRole + 1).toString().contains("file"))
   435     else if (item->data(Qt::UserRole + 1).toString().contains("file"))
   642         {
   436         {
   643         PERF_RESULT_ITEM_FOR_LAUNCHING("file")
   437         PERF_RESULT_ITEM_FOR_LAUNCHING("file")
   661         }
   455         }
   662 
   456 
   663     else if (item->data(Qt::UserRole + 1).toString().contains("notes"))
   457     else if (item->data(Qt::UserRole + 1).toString().contains("notes"))
   664         {
   458         {
   665         PERF_RESULT_ITEM_FOR_LAUNCHING("notes")
   459         PERF_RESULT_ITEM_FOR_LAUNCHING("notes")
   666         if(mNotesEditor)
   460         if (mNotesEditor)
   667             {
   461             {
   668             mNotesEditor->edit(item->data(Qt::UserRole).toInt());
   462             mNotesEditor->edit(item->data(Qt::UserRole).toInt());
   669             }
   463             }
   670         PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG("")
   464         PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG("")
   671         }
   465         }
   675         mRequest = mAiwMgr->create("nmail",
   469         mRequest = mAiwMgr->create("nmail",
   676                 "com.nokia.symbian.IEmailMessageView",
   470                 "com.nokia.symbian.IEmailMessageView",
   677                 "viewMessage(QVariant,QVariant,QVariant)", true);
   471                 "viewMessage(QVariant,QVariant,QVariant)", true);
   678 
   472 
   679         args << item->data(Qt::UserRole + 2).toULongLong(&t) << item->data(
   473         args << item->data(Qt::UserRole + 2).toULongLong(&t) << item->data(
   680                 Qt::UserRole + 3).toULongLong(&t) << item->data(Qt::UserRole).toULongLong(&t);
   474                 Qt::UserRole + 3).toULongLong(&t)
       
   475                 << item->data(Qt::UserRole).toULongLong(&t);
   681         }
   476         }
   682     else if (item->data(Qt::UserRole + 1).toString().contains("msg"))
   477     else if (item->data(Qt::UserRole + 1).toString().contains("msg"))
   683         {
   478         {
   684         PERF_RESULT_ITEM_FOR_LAUNCHING("msg")
   479         PERF_RESULT_ITEM_FOR_LAUNCHING("msg")
   685         mRequest = mAiwMgr->create("messaging",
   480         mRequest = mAiwMgr->create("messaging",
   686                 "com.nokia.symbian.IMessageView", "view(int)", true);
   481                 "com.nokia.symbian.IMessageView", "view(int)", true);
   687 
   482 
   688         int uid = (item->data(Qt::UserRole)).toInt(&t);
   483         int uid = (item->data(Qt::UserRole)).toInt(&t);
   689         args << uid;
   484         args << uid;
   690         }
   485         }
   691     else if(item->data(Qt::UserRole + 1).toString().contains("links"))
   486     else if (item->data(Qt::UserRole + 1).toString().contains("links"))
   692         {
   487         {
   693         emit launchLink((item->data(Qt::UserRole)).toInt(&t),mOriginalString);
   488         emit launchLink((item->data(Qt::UserRole)).toInt(&t), mOriginalString);
   694         }
   489         }
   695     if (mRequest)
   490     if (mRequest)
   696         {
   491         {
   697         connect(mRequest, SIGNAL(requestOk(const QVariant&)), this,
   492         connect(mRequest, SIGNAL(requestOk(const QVariant&)), this,
   698                 SLOT(handleOk(const QVariant&)));
   493                 SLOT(handleOk(const QVariant&)));
   720 // SearchProgressiveState::handleOk
   515 // SearchProgressiveState::handleOk
   721 // ---------------------------------------------------------------------------
   516 // ---------------------------------------------------------------------------
   722 void SearchProgressiveState::handleOk(const QVariant& var)
   517 void SearchProgressiveState::handleOk(const QVariant& var)
   723     {
   518     {
   724     Q_UNUSED(var);
   519     Q_UNUSED(var);
   725 PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG    ("")
   520     PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG ("")
   726     }
   521     }
   727 // ---------------------------------------------------------------------------
   522 // ---------------------------------------------------------------------------
   728 // SearchProgressiveState::handleError
   523 // SearchProgressiveState::handleError
   729 // ---------------------------------------------------------------------------
   524 // ---------------------------------------------------------------------------
   730 void SearchProgressiveState::handleError(int ret, const QString& var)
   525 void SearchProgressiveState::handleError(int ret, const QString& var)
   777 // SearchProgressiveState::searchOnCategory
   572 // SearchProgressiveState::searchOnCategory
   778 // ---------------------------------------------------------------------------
   573 // ---------------------------------------------------------------------------
   779 void SearchProgressiveState::searchOnCategory(const QString aKeyword)
   574 void SearchProgressiveState::searchOnCategory(const QString aKeyword)
   780     {
   575     {
   781 #ifdef OST_TRACE_COMPILER_IN_USE
   576 #ifdef OST_TRACE_COMPILER_IN_USE
   782     if( mDatabasecount != 0 )
   577     if (mDatabasecount != 0)
   783         {//Search just started.
   578         {//Search just started.
   784         PERF_CAT_UI_ENDLOG
   579         PERF_CAT_UI_ENDLOG
   785         }
   580         }
   786     PERF_CAT_UI_TIME_RESTART
   581     PERF_CAT_UI_TIME_RESTART
   787 #endif
   582 #endif
   870 // ---------------------------------------------------------------------------
   665 // ---------------------------------------------------------------------------
   871 void SearchProgressiveState::startNewSearch(const QString &aKeyword)
   666 void SearchProgressiveState::startNewSearch(const QString &aKeyword)
   872     {
   667     {
   873     PERF_CAT_TOTAL_TIME_RESTART
   668     PERF_CAT_TOTAL_TIME_RESTART
   874     mOriginalString = aKeyword.trimmed();
   669     mOriginalString = aKeyword.trimmed();
       
   670 
       
   671     if (!mValidateHandlerCreation)
       
   672         {
       
   673         for (int i = 0; i < mSearchHandlerList.count(); i++)
       
   674             {
       
   675             /* ignoring bookmark to getrid of unnecesary check as bookmark support is withdrawn
       
   676              * keeping perfomance into consideration, otherwise not  
       
   677              */
       
   678             if (!mSearchHandlerList.at(i)->isPrepared() && (i != 9))
       
   679                 {
       
   680                 constructHandlers(i);
       
   681                 mValidateHandlerCreation = false;
       
   682                 }
       
   683             else
       
   684                 {
       
   685                 mValidateHandlerCreation = true;
       
   686                 }
       
   687             }
       
   688         }
       
   689 
   875     for (int i = 0; i < mSearchHandlerList.count(); i++)
   690     for (int i = 0; i < mSearchHandlerList.count(); i++)
   876         {
   691         {
   877         mSearchHandlerList.at(i)->cancelLastSearch();
   692         mSearchHandlerList.at(i)->cancelLastSearch();
   878         }
   693         }
   879     if (mListView->count() != 0)
   694     if (mListView->count() != 0)
   882         }
   697         }
   883     if (mOriginalString.length())
   698     if (mOriginalString.length())
   884         {
   699         {
   885         mDatabasecount = 0;
   700         mDatabasecount = 0;
   886         mLinkindex = 0;
   701         mLinkindex = 0;
   887         //Prefix query
       
   888         mSearchString = "$prefix(\"";
   702         mSearchString = "$prefix(\"";
   889         mSearchString += mOriginalString;
   703         mSearchString += mOriginalString;
   890         mSearchString += "\")";
   704         mSearchString += "\")";
   891         /*mSearchString = mOriginalString;
       
   892          mSearchString.append('*');*/
       
   893         searchOnCategory(mSearchString);
   705         searchOnCategory(mSearchString);
   894         }
   706         }
   895     }
   707     }
   896 // ---------------------------------------------------------------------------
   708 // ---------------------------------------------------------------------------
   897 // SearchProgressiveState::setSettings
   709 // SearchProgressiveState::setSettings
  1319         User::LeaveIfError(appArcSession.StartApp(*cmdLine));
  1131         User::LeaveIfError(appArcSession.StartApp(*cmdLine));
  1320         CleanupStack::PopAndDestroy(cmdLine);
  1132         CleanupStack::PopAndDestroy(cmdLine);
  1321         CleanupStack::PopAndDestroy(&appArcSession);
  1133         CleanupStack::PopAndDestroy(&appArcSession);
  1322         }
  1134         }
  1323     CleanupStack::PopAndDestroy(&wsSession);
  1135     CleanupStack::PopAndDestroy(&wsSession);
  1324 PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG    ("")
  1136     PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG ("")
  1325     }
  1137     }
  1326 // ---------------------------------------------------------------------------
  1138 // ---------------------------------------------------------------------------
  1327 // SearchProgressiveState::_viewingCompleted
  1139 // SearchProgressiveState::_viewingCompleted
  1328 // ---------------------------------------------------------------------------
  1140 // ---------------------------------------------------------------------------
  1329 void SearchProgressiveState::_viewingCompleted()
  1141 void SearchProgressiveState::_viewingCompleted()
  1330     {
  1142     {
  1331     if (calAgandaViewerPluginInstance)
  1143     if (calAgandaViewerPluginInstance)
  1332         calAgandaViewerPluginInstance->deleteLater();
  1144         calAgandaViewerPluginInstance->deleteLater();
  1333 PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG    ("")
  1145     PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG ("")
  1334     }
  1146     }
  1335 // ---------------------------------------------------------------------------
  1147 // ---------------------------------------------------------------------------
  1336 // SearchProgressiveState::viewReady
  1148 // SearchProgressiveState::viewReady
  1337 // ---------------------------------------------------------------------------
  1149 // ---------------------------------------------------------------------------
  1338 void SearchProgressiveState::viewReady()
  1150 void SearchProgressiveState::viewReady()
  1339     {
  1151     {
  1340 
       
  1341     if (hbApp)
  1152     if (hbApp)
  1342         {
  1153         {
  1343         if (hbApp->activateReason() == Hb::ActivationReasonActivity)
  1154         if (hbApp->activateReason() == Hb::ActivationReasonActivity)
  1344             {
  1155             {
  1345             QVariantHash params = hbApp->activateParams();
  1156             QVariantHash params = hbApp->activateParams();
  1355                     mTemplist.append(str);
  1166                     mTemplist.append(str);
  1356                 }
  1167                 }
  1357             if (searchKey.length() > 0)
  1168             if (searchKey.length() > 0)
  1358                 mSearchPanel->setCriteria(searchKey);
  1169                 mSearchPanel->setCriteria(searchKey);
  1359             }
  1170             }
  1360         }PERF_APP_LAUNCH_END("SearchAppplication View is ready");
  1171         }
       
  1172     PERF_APP_LAUNCH_END("SearchAppplication View is ready");
  1361     emit applicationReady();
  1173     emit applicationReady();
  1362     }
  1174     }
  1363 // ---------------------------------------------------------------------------
  1175 // ---------------------------------------------------------------------------
  1364 // SearchProgressiveState::slotOnlineQuery
  1176 // SearchProgressiveState::slotOnlineQuery
  1365 // ---------------------------------------------------------------------------
  1177 // ---------------------------------------------------------------------------
  1453             }
  1265             }
  1454         if (searchKey.length() > 0)
  1266         if (searchKey.length() > 0)
  1455             mSearchPanel->setCriteria(searchKey);
  1267             mSearchPanel->setCriteria(searchKey);
  1456         }
  1268         }
  1457     }
  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     }