searchui/stateproviders/searchstateprovider/src/searchprogressivestate.cpp
changeset 17 7d8c8d8f5eab
parent 12 993ab30e92fc
child 20 68cdadcf169e
equal deleted inserted replaced
12:993ab30e92fc 17:7d8c8d8f5eab
    14  * Description:  Implementation of the progressive search state.
    14  * Description:  Implementation of the progressive search state.
    15  *
    15  *
    16  */
    16  */
    17 #include "searchprogressivestate.h"
    17 #include "searchprogressivestate.h"
    18 #include "indevicehandler.h"
    18 #include "indevicehandler.h"
    19 #include <qcpixdocument.h>
    19 #include "searchuiloader.h"
    20 #include <qcpixdocumentfield.h>
    20 #include <cpixdocument.h>
       
    21 #include <cpixdocumentfield.h>
    21 #include <hbmainwindow.h>
    22 #include <hbmainwindow.h>
    22 #include <hbview.h>
    23 #include <hbview.h>
    23 #include <hblabel.h>
    24 #include <hblabel.h>
    24 #include <hbicon.h>
    25 #include <hbicon.h>
    25 #include <hbmenu.h>
    26 #include <hbmenu.h>
    26 #include <hbinstance.h>
    27 #include <hbinstance.h>
    27 #include <hbdocumentloader.h>
       
    28 #include <hbsearchpanel.h>
    28 #include <hbsearchpanel.h>
    29 #include <hbaction.h>
    29 #include <hbaction.h>
    30 #include <hbframebackground.h>
       
    31 #include <hbapplication.h>
    30 #include <hbapplication.h>
    32 #include <qsortfilterproxymodel.h>
    31 #include <qsortfilterproxymodel.h>
    33 #include <AknsUtils.h>
    32 #include <AknsUtils.h>
    34 #include <bitdev.h> 
    33 #include <bitdev.h> 
    35 #include <bitstd.h>
    34 #include <bitstd.h>
    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 
   141     mLinkindex = 0;
    99     mLinkindex = 0;
   142     mResultcount = 0;
   100     mResultcount = 0;
   143     mResultparser = 0;
   101     mResultparser = 0;
   144     loadSettings = true;
   102     loadSettings = true;
   145 
   103 
   146     //Icon creation in array
   104     if (hbApp)
   147     RArray<TUid> appUid;
   105         {
   148     appUid.Append(TUid::Uid(0x20022EF9));//contact
   106         connect(hbApp->activityManager(), SIGNAL(activityRequested(QString)),
   149     appUid.Append(TUid::Uid(0x10207C62));//audio
   107                 this, SLOT(activityRequested(QString)));
   150     appUid.Append(TUid::Uid(0x200211FE));//video 
   108         }
   151     appUid.Append(TUid::Uid(0x20000A14));//image 
   109 
   152     appUid.Append(TUid::Uid(0x2001FE79));//msg
       
   153     appUid.Append(TUid::Uid(0x200255BA));//email 
       
   154     appUid.Append(TUid::Uid(0x10005901));//calender
       
   155     appUid.Append(TUid::Uid(0x20029F80));//notes
       
   156     //appUid.Append(TUid::Uid(0x20022F35));//application
       
   157     appUid.Append(TUid::Uid(0x10008D39));//bookmark
       
   158     appUid.Append(TUid::Uid(0x2002BCC0));//files
       
   159 
       
   160     for (int i = 0; i < appUid.Count(); i++)
       
   161         {
       
   162         TRAP_IGNORE(mIconArray.append(getAppIconFromAppIdL(appUid[i])));
       
   163         }
       
   164 #ifdef OST_TRACE_COMPILER_IN_USE 
   110 #ifdef OST_TRACE_COMPILER_IN_USE 
   165     //start() the timers to avoid worrying abt having to start()/restart() later
   111     //start() the timers to avoid worrying abt having to start()/restart() later
   166     m_categorySearchApiTime.start();
   112     m_categorySearchApiTime.start();
   167     m_categorySearchUiTime.start();
   113     m_categorySearchUiTime.start();
   168     m_totalSearchUiTime.start();
   114     m_totalSearchUiTime.start();
   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             {
   295             }
   207             }
   296         mMainWindow->show();
   208         mMainWindow->show();
   297         }
   209         }
   298     if (loadSettings)
   210     if (loadSettings)
   299         {
   211         {
       
   212         // to get the intial settings form delimeter  
   300         emit switchProToSettingsState();
   213         emit switchProToSettingsState();
   301         loadSettings = false;
   214         loadSettings = false;
   302         }
   215         }
   303     setSelectedCategories();
   216     setSelectedCategories();
   304     if (mOnlineQueryAvailable)
   217     if (mOnlineQueryAvailable)
   311 // SearchProgressiveState::onExit
   224 // SearchProgressiveState::onExit
   312 // ---------------------------------------------------------------------------
   225 // ---------------------------------------------------------------------------
   313 void SearchProgressiveState::onExit(QEvent *event)
   226 void SearchProgressiveState::onExit(QEvent *event)
   314     {
   227     {
   315     QState::onExit(event);
   228     QState::onExit(event);
       
   229     mStateStatus = false;
   316     deActivateSignals();
   230     deActivateSignals();
   317     }
   231     }
   318 // ---------------------------------------------------------------------------
   232 // ---------------------------------------------------------------------------
   319 // SearchProgressiveState::activateSignals
   233 // SearchProgressiveState::activateSignals
   320 // ---------------------------------------------------------------------------
   234 // ---------------------------------------------------------------------------
   324         {
   238         {
   325         connect(mSearchHandlerList.at(i),
   239         connect(mSearchHandlerList.at(i),
   326                 SIGNAL(handleAsyncSearchResult(int,int)), this,
   240                 SIGNAL(handleAsyncSearchResult(int,int)), this,
   327                 SLOT(onAsyncSearchComplete(int,int)));
   241                 SLOT(onAsyncSearchComplete(int,int)));
   328         connect(mSearchHandlerList.at(i),
   242         connect(mSearchHandlerList.at(i),
   329                 SIGNAL(handleDocument(int,QCPixDocument*)), this,
   243                 SIGNAL(handleDocument(int,CpixDocument*)), this,
   330                 SLOT(onGetDocumentComplete(int,QCPixDocument*)));
   244                 SLOT(onGetDocumentComplete(int,CpixDocument*)));
       
   245         connect(mSearchHandlerList.at(i),
       
   246                 SIGNAL(handleBatchDocument(int,int,CpixDocument**)), this,
       
   247                 SLOT(onGetBatchDocumentComplete(int,int,CpixDocument**)));
       
   248 
   331         }
   249         }
   332     if (mListView)
   250     if (mListView)
   333         {
   251         {
   334         connect(mListView, SIGNAL(activated(HbListWidgetItem *)), this,
   252         connect(mListView, SIGNAL(activated(HbListWidgetItem *)), this,
   335                 SLOT(openResultitem(HbListWidgetItem *)));
   253                 SLOT(openResultitem(HbListWidgetItem *)));
   339         connect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this,
   257         connect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this,
   340                 SLOT(startNewSearch(QString)));
   258                 SLOT(startNewSearch(QString)));
   341         connect(mSearchPanel, SIGNAL(searchOptionsClicked()), this,
   259         connect(mSearchPanel, SIGNAL(searchOptionsClicked()), this,
   342                 SLOT(setSettings()));
   260                 SLOT(setSettings()));
   343         }
   261         }
   344 
       
   345     connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(viewReady()));
   262     connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(viewReady()));
   346 
       
   347     }
   263     }
   348 // ---------------------------------------------------------------------------
   264 // ---------------------------------------------------------------------------
   349 // SearchProgressiveState::deActivateSignals
   265 // SearchProgressiveState::deActivateSignals
   350 // ---------------------------------------------------------------------------
   266 // ---------------------------------------------------------------------------
   351 void SearchProgressiveState::deActivateSignals()
   267 void SearchProgressiveState::deActivateSignals()
   354         {
   270         {
   355         disconnect(mSearchHandlerList.at(i),
   271         disconnect(mSearchHandlerList.at(i),
   356                 SIGNAL(handleAsyncSearchResult(int,int)), this,
   272                 SIGNAL(handleAsyncSearchResult(int,int)), this,
   357                 SLOT(onAsyncSearchComplete(int,int)));
   273                 SLOT(onAsyncSearchComplete(int,int)));
   358         disconnect(mSearchHandlerList.at(i),
   274         disconnect(mSearchHandlerList.at(i),
   359                 SIGNAL(handleDocument(int,QCPixDocument*)), this,
   275                 SIGNAL(handleDocument(int,CpixDocument*)), this,
   360                 SLOT(onGetDocumentComplete(int,QCPixDocument*)));
   276                 SLOT(onGetDocumentComplete(int,CpixDocument*)));
       
   277         disconnect(mSearchHandlerList.at(i),
       
   278                 SIGNAL(handleBatchDocument(int,int,CpixDocument**)), this,
       
   279                 SLOT(onGetBatchDocumentComplete(int,int,CpixDocument**)));
   361         }
   280         }
   362     if (mListView)
   281     if (mListView)
   363         {
   282         {
   364         disconnect(mListView, SIGNAL(activated(HbListWidgetItem *)), this,
   283         disconnect(mListView, SIGNAL(activated(HbListWidgetItem *)), this,
   365                 SLOT(openResultitem(HbListWidgetItem *)));
   284                 SLOT(openResultitem(HbListWidgetItem *)));
   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 
   636                 EventViewerPluginInterface::ActionEditDelete, NULL);
   427                 EventViewerPluginInterface::ActionEditDelete, NULL);
   637         }
   428         }
   638     else if (item->data(Qt::UserRole + 1).toString().contains("applications"))
   429     else if (item->data(Qt::UserRole + 1).toString().contains("applications"))
   639         {
   430         {
   640         PERF_RESULT_ITEM_FOR_LAUNCHING("applications")
   431         PERF_RESULT_ITEM_FOR_LAUNCHING("applications")
   641         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))));
   642         PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG("")
   433         PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG("")
   643         }
   434         }
   644     else if (item->data(Qt::UserRole + 1).toString().contains("file"))
   435     else if (item->data(Qt::UserRole + 1).toString().contains("file"))
   645         {
   436         {
   646         PERF_RESULT_ITEM_FOR_LAUNCHING("file")
   437         PERF_RESULT_ITEM_FOR_LAUNCHING("file")
   647         QString uid = item->data(Qt::UserRole).toString();
   438         QString uid = item->data(Qt::UserRole).toString();
   648         QFile file(uid);
   439         QFile file(uid);
   649         mRequest = mAiwMgr->create(file, false);
   440         mRequest = mAiwMgr->create(file, true);
   650         args << file.fileName();
   441         args << file.fileName();
   651         }
   442         }
   652     else if ((item->data(Qt::UserRole + 1).toString().contains("video"))
   443     else if ((item->data(Qt::UserRole + 1).toString().contains("video"))
   653             || (item->data(Qt::UserRole + 1).toString().contains("audio"))
   444             || (item->data(Qt::UserRole + 1).toString().contains("audio"))
   654             || (item->data(Qt::UserRole + 1).toString().contains("image")))
   445             || (item->data(Qt::UserRole + 1).toString().contains("image")))
   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&)));
   723 // SearchProgressiveState::handleOk
   515 // SearchProgressiveState::handleOk
   724 // ---------------------------------------------------------------------------
   516 // ---------------------------------------------------------------------------
   725 void SearchProgressiveState::handleOk(const QVariant& var)
   517 void SearchProgressiveState::handleOk(const QVariant& var)
   726     {
   518     {
   727     Q_UNUSED(var);
   519     Q_UNUSED(var);
   728 PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG    ("")
   520     PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG ("")
   729     }
   521     }
   730 // ---------------------------------------------------------------------------
   522 // ---------------------------------------------------------------------------
   731 // SearchProgressiveState::handleError
   523 // SearchProgressiveState::handleError
   732 // ---------------------------------------------------------------------------
   524 // ---------------------------------------------------------------------------
   733 void SearchProgressiveState::handleError(int ret, const QString& var)
   525 void SearchProgressiveState::handleError(int ret, const QString& var)
   780 // SearchProgressiveState::searchOnCategory
   572 // SearchProgressiveState::searchOnCategory
   781 // ---------------------------------------------------------------------------
   573 // ---------------------------------------------------------------------------
   782 void SearchProgressiveState::searchOnCategory(const QString aKeyword)
   574 void SearchProgressiveState::searchOnCategory(const QString aKeyword)
   783     {
   575     {
   784 #ifdef OST_TRACE_COMPILER_IN_USE
   576 #ifdef OST_TRACE_COMPILER_IN_USE
   785     if( mDatabasecount != 0 )
   577     if (mDatabasecount != 0)
   786         {//Search just started.
   578         {//Search just started.
   787         PERF_CAT_UI_ENDLOG
   579         PERF_CAT_UI_ENDLOG
   788         }
   580         }
   789     PERF_CAT_UI_TIME_RESTART
   581     PERF_CAT_UI_TIME_RESTART
   790 #endif
   582 #endif
   798             }
   590             }
   799         else if (mTemplist.at(mDatabasecount).contains("contact"))
   591         else if (mTemplist.at(mDatabasecount).contains("contact"))
   800             {
   592             {
   801             mSearchHandler = mSearchHandlerList.at(1);
   593             mSearchHandler = mSearchHandlerList.at(1);
   802             }
   594             }
       
   595         else if (mTemplist.at(mDatabasecount).contains("image"))
       
   596             {
       
   597             mSearchHandler = mSearchHandlerList.at(10);
       
   598             }
       
   599         else if (mTemplist.at(mDatabasecount).contains("audio"))
       
   600             {
       
   601             mSearchHandler = mSearchHandlerList.at(11);
       
   602             }
       
   603         else if (mTemplist.at(mDatabasecount).contains("video"))
       
   604             {
       
   605             mSearchHandler = mSearchHandlerList.at(12);
       
   606             }
   803         else if (mTemplist.at(mDatabasecount).contains("media"))
   607         else if (mTemplist.at(mDatabasecount).contains("media"))
   804             {
   608             {
   805             mSearchHandler = mSearchHandlerList.at(2);
   609             mSearchHandler = mSearchHandlerList.at(2);
   806             }
   610             }
   807         else if (mTemplist.at(mDatabasecount).contains("msg"))
   611         else if (mTemplist.at(mDatabasecount).contains("msg"))
   832             {
   636             {
   833             mSearchHandler = mSearchHandlerList.at(9);
   637             mSearchHandler = mSearchHandlerList.at(9);
   834             }
   638             }
   835         // mSearchHandler->setCategory(mTemplist.at(mDatabasecount));
   639         // mSearchHandler->setCategory(mTemplist.at(mDatabasecount));
   836         mDatabasecount++;
   640         mDatabasecount++;
   837         if (mSearchHandler->isPrepared())
   641         if (mSearchHandler != NULL && mSearchHandler->isPrepared())
   838             {
   642             {
   839             PERF_CAT_API_TIME_RESTART
   643             PERF_CAT_API_TIME_RESTART
   840             mSearchHandler->searchAsync(aKeyword, "_aggregate");
   644             mSearchHandler->searchAsync(aKeyword, "_aggregate");
   841 
   645 
   842             }
   646             }
   861 // ---------------------------------------------------------------------------
   665 // ---------------------------------------------------------------------------
   862 void SearchProgressiveState::startNewSearch(const QString &aKeyword)
   666 void SearchProgressiveState::startNewSearch(const QString &aKeyword)
   863     {
   667     {
   864     PERF_CAT_TOTAL_TIME_RESTART
   668     PERF_CAT_TOTAL_TIME_RESTART
   865     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 
   866     for (int i = 0; i < mSearchHandlerList.count(); i++)
   690     for (int i = 0; i < mSearchHandlerList.count(); i++)
   867         {
   691         {
   868         mSearchHandlerList.at(i)->cancelLastSearch();
   692         mSearchHandlerList.at(i)->cancelLastSearch();
   869         }
   693         }
   870     if (mListView->count() != 0)
   694     if (mListView->count() != 0)
   873         }
   697         }
   874     if (mOriginalString.length())
   698     if (mOriginalString.length())
   875         {
   699         {
   876         mDatabasecount = 0;
   700         mDatabasecount = 0;
   877         mLinkindex = 0;
   701         mLinkindex = 0;
   878         //Prefix query
       
   879         mSearchString = "$prefix(\"";
   702         mSearchString = "$prefix(\"";
   880         mSearchString += mOriginalString;
   703         mSearchString += mOriginalString;
   881         mSearchString += "\")";
   704         mSearchString += "\")";
   882         /*mSearchString = mOriginalString;
       
   883          mSearchString.append('*');*/
       
   884         searchOnCategory(mSearchString);
   705         searchOnCategory(mSearchString);
   885         }
   706         }
   886     }
   707     }
   887 // ---------------------------------------------------------------------------
   708 // ---------------------------------------------------------------------------
   888 // SearchProgressiveState::setSettings
   709 // SearchProgressiveState::setSettings
   897 // ---------------------------------------------------------------------------
   718 // ---------------------------------------------------------------------------
   898 // SearchProgressiveState::settingsaction
   719 // SearchProgressiveState::settingsaction
   899 // ---------------------------------------------------------------------------
   720 // ---------------------------------------------------------------------------
   900 void SearchProgressiveState::settingsaction(bool avalue)
   721 void SearchProgressiveState::settingsaction(bool avalue)
   901     {
   722     {
   902     if (avalue)
   723     if (avalue && mStateStatus)
   903         {
   724         {
   904         QMapIterator<int, bool> i(mTempSelectedCategory);
   725         QMapIterator<int, bool> i(mTempSelectedCategory);
   905         QMapIterator<int, bool> j(mSelectedCategory);
   726         QMapIterator<int, bool> j(mSelectedCategory);
   906         while (i.hasNext())
   727         while (i.hasNext())
   907             {
   728             {
  1044             CleanupStack::Pop(fileNameFromApparc);
   865             CleanupStack::Pop(fileNameFromApparc);
  1045             }
   866             }
  1046         CleanupStack::PopAndDestroy(apaMaskedBitmap);
   867         CleanupStack::PopAndDestroy(apaMaskedBitmap);
  1047         }
   868         }
  1048     CleanupStack::PopAndDestroy(&apaLsSession);
   869     CleanupStack::PopAndDestroy(&apaLsSession);
  1049 
       
  1050     if (icon.isNull() || !(icon.size().isValid()))
   870     if (icon.isNull() || !(icon.size().isValid()))
  1051         icon = HbIcon("qtg_large_application");
   871         icon = HbIcon("qtg_large_application");
  1052     return icon;
   872     return icon;
  1053     }
   873     }
  1054 // ---------------------------------------------------------------------------
   874 // ---------------------------------------------------------------------------
  1057 void SearchProgressiveState::GetPixmapByFilenameL(TDesC& fileName,
   877 void SearchProgressiveState::GetPixmapByFilenameL(TDesC& fileName,
  1058         const QSize &size, QPixmap& pixmap)
   878         const QSize &size, QPixmap& pixmap)
  1059     {
   879     {
  1060     CFbsBitmap *bitamp(0);
   880     CFbsBitmap *bitamp(0);
  1061     CFbsBitmap *mask(0);
   881     CFbsBitmap *mask(0);
  1062 
       
  1063     if (AknIconUtils::IsMifFile(fileName))
   882     if (AknIconUtils::IsMifFile(fileName))
  1064         {
   883         {
  1065         // SVG icon
   884         // SVG icon
  1066         // SVG always has only one icon
   885         // SVG always has only one icon
  1067         TInt bitmapIndex = 0;
   886         TInt bitmapIndex = 0;
  1070                 maskIndex);
   889                 maskIndex);
  1071 
   890 
  1072         AknIconUtils::CreateIconLC(bitamp, mask, fileName, bitmapIndex,
   891         AknIconUtils::CreateIconLC(bitamp, mask, fileName, bitmapIndex,
  1073                 maskIndex);
   892                 maskIndex);
  1074         }
   893         }
  1075 
       
  1076     AknIconUtils::DisableCompression(bitamp);
   894     AknIconUtils::DisableCompression(bitamp);
  1077     AknIconUtils::SetSize(bitamp, TSize(size.width(), size.height()),
   895     AknIconUtils::SetSize(bitamp, TSize(size.width(), size.height()),
  1078             EAspectRatioPreservedAndUnusedSpaceRemoved);
   896             EAspectRatioPreservedAndUnusedSpaceRemoved);
  1079 
       
  1080     AknIconUtils::DisableCompression(mask);
   897     AknIconUtils::DisableCompression(mask);
  1081     AknIconUtils::SetSize(mask, TSize(size.width(), size.height()),
   898     AknIconUtils::SetSize(mask, TSize(size.width(), size.height()),
  1082             EAspectRatioPreservedAndUnusedSpaceRemoved);
   899             EAspectRatioPreservedAndUnusedSpaceRemoved);
  1083 
       
  1084     fromBitmapAndMaskToPixmapL(bitamp, mask, pixmap);
   900     fromBitmapAndMaskToPixmapL(bitamp, mask, pixmap);
  1085 
       
  1086     // bitmap and icon, AknsUtils::CreateIconLC doesn't specify the order
   901     // bitmap and icon, AknsUtils::CreateIconLC doesn't specify the order
  1087     CleanupStack::Pop(2);
   902     CleanupStack::Pop(2);
  1088     }
   903     }
  1089 // ---------------------------------------------------------------------------
   904 // ---------------------------------------------------------------------------
  1090 // SearchProgressiveState::TDisplayMode2Format
   905 // SearchProgressiveState::TDisplayMode2Format
  1184         }
   999         }
  1185     }
  1000     }
  1186 // ---------------------------------------------------------------------------
  1001 // ---------------------------------------------------------------------------
  1187 // SearchProgressiveState::filterDoc
  1002 // SearchProgressiveState::filterDoc
  1188 // ---------------------------------------------------------------------------
  1003 // ---------------------------------------------------------------------------
  1189 QString SearchProgressiveState::filterDoc(const QCPixDocument* aDoc,
  1004 QString SearchProgressiveState::filterDoc(const CpixDocument* aDoc,
  1190         const QString& filter)
  1005         const QString& filter)
  1191     {
  1006     {
  1192     for (int i = 0; i < aDoc->fieldCount(); i++)
  1007     for (int i = 0; i < aDoc->fieldCount(); i++)
  1193         {
  1008         {
  1194         if (aDoc->field(i).name().contains(filter))
  1009         if (aDoc->field(i).name().contains(filter))
  1199     return NULL;
  1014     return NULL;
  1200     }
  1015     }
  1201 // ---------------------------------------------------------------------------
  1016 // ---------------------------------------------------------------------------
  1202 // SearchProgressiveState::filterDoc
  1017 // SearchProgressiveState::filterDoc
  1203 // ---------------------------------------------------------------------------
  1018 // ---------------------------------------------------------------------------
  1204 QStringList SearchProgressiveState::filterDoc(const QCPixDocument* aDoc,
  1019 QStringList SearchProgressiveState::filterDoc(const CpixDocument* aDoc,
  1205         const QString& filter1, const QString& filter2,
  1020         const QString& filter1, const QString& filter2,
  1206         const QString& filter3)
  1021         const QString& filter3)
  1207     {
  1022     {
  1208     QStringList docList;
  1023     QStringList docList;
  1209     docList.append(QString());
  1024     docList.append(QString());
  1316         User::LeaveIfError(appArcSession.StartApp(*cmdLine));
  1131         User::LeaveIfError(appArcSession.StartApp(*cmdLine));
  1317         CleanupStack::PopAndDestroy(cmdLine);
  1132         CleanupStack::PopAndDestroy(cmdLine);
  1318         CleanupStack::PopAndDestroy(&appArcSession);
  1133         CleanupStack::PopAndDestroy(&appArcSession);
  1319         }
  1134         }
  1320     CleanupStack::PopAndDestroy(&wsSession);
  1135     CleanupStack::PopAndDestroy(&wsSession);
  1321 PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG    ("")
  1136     PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG ("")
  1322     }
  1137     }
  1323 // ---------------------------------------------------------------------------
  1138 // ---------------------------------------------------------------------------
  1324 // SearchProgressiveState::_viewingCompleted
  1139 // SearchProgressiveState::_viewingCompleted
  1325 // ---------------------------------------------------------------------------
  1140 // ---------------------------------------------------------------------------
  1326 void SearchProgressiveState::_viewingCompleted()
  1141 void SearchProgressiveState::_viewingCompleted()
  1327     {
  1142     {
  1328     if (calAgandaViewerPluginInstance)
  1143     if (calAgandaViewerPluginInstance)
  1329         calAgandaViewerPluginInstance->deleteLater();
  1144         calAgandaViewerPluginInstance->deleteLater();
  1330 PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG    ("")
  1145     PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG ("")
  1331     }
  1146     }
  1332 // ---------------------------------------------------------------------------
  1147 // ---------------------------------------------------------------------------
  1333 // SearchProgressiveState::viewReady
  1148 // SearchProgressiveState::viewReady
  1334 // ---------------------------------------------------------------------------
  1149 // ---------------------------------------------------------------------------
  1335 void SearchProgressiveState::viewReady()
  1150 void SearchProgressiveState::viewReady()
  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     }