searchui/stateproviders/searchstateprovider/src/searchprogressivestate.cpp
changeset 11 773be20e0a25
parent 7 51d10d255e92
child 12 993ab30e92fc
equal deleted inserted replaced
7:51d10d255e92 11:773be20e0a25
    43 #include <AknInternalIconUtils.h>
    43 #include <AknInternalIconUtils.h>
    44 #include <AknIconUtils.h> 
    44 #include <AknIconUtils.h> 
    45 #include <apaidpartner.h>
    45 #include <apaidpartner.h>
    46 #include <qpluginloader.h>
    46 #include <qpluginloader.h>
    47 #include <eventviewerplugininterface.h>
    47 #include <eventviewerplugininterface.h>
    48 #include <noteseditor.h>
    48 #include <noteseditorinterface.h>
    49 #include <w32std.h>
    49 #include <w32std.h>
    50 #include <apgtask.h>
    50 #include <apgtask.h>
    51 #include <apgcli.h>
    51 #include <apgcli.h>
    52 #include <AknTaskList.h>
    52 #include <AknTaskList.h>
    53 #include <apacmdln.h>
    53 #include <apacmdln.h>
    54 #include <xqconversions.h>
    54 #include <xqconversions.h>
    55 #include <apparc.h>
    55 #include <apparc.h>
       
    56 #define hbApp qobject_cast<HbApplication*>(qApp)
    56 const char *SEARCHSTATEPROVIDER_DOCML = ":/xml/searchstateprovider.docml";
    57 const char *SEARCHSTATEPROVIDER_DOCML = ":/xml/searchstateprovider.docml";
    57 const char *TOC_VIEW = "tocView";
    58 const char *TOC_VIEW = "tocView";
    58 const char *TUT_SEARCHPANEL_WIDGET = "searchPanel";
    59 const char *TUT_SEARCHPANEL_WIDGET = "searchPanel";
    59 const char *TUT_LIST_VIEW = "listView";
    60 const char *TUT_LIST_VIEW = "listView";
    60 const int totalcategories = 10;
    61 const int totalcategories = 10;
    62 // SearchProgressiveState::SearchProgressiveState
    63 // SearchProgressiveState::SearchProgressiveState
    63 // ---------------------------------------------------------------------------
    64 // ---------------------------------------------------------------------------
    64 SearchProgressiveState::SearchProgressiveState(QState *parent) :
    65 SearchProgressiveState::SearchProgressiveState(QState *parent) :
    65     QState(parent), mMainWindow(NULL), mView(NULL), mListView(NULL),
    66     QState(parent), mMainWindow(NULL), mView(NULL), mListView(NULL),
    66             mDocumentLoader(NULL), mModel(NULL), mSearchHandler(NULL),
    67             mDocumentLoader(NULL), mModel(NULL), mSearchHandler(NULL),
    67             notesEditor(0), mAiwMgr(0), mRequest(0)
    68             mNotesEditor(0), mAiwMgr(0), mRequest(0)
    68     {
    69     {
    69 
    70 
    70     mMainWindow = hbInstance->allMainWindows().at(0);
    71     mMainWindow = hbInstance->allMainWindows().at(0);
    71     mModel = new QStandardItemModel(this);
    72     mModel = new QStandardItemModel(this);
    72 
    73 
   121             mDocumentLoader->findWidget(TUT_SEARCHPANEL_WIDGET));
   122             mDocumentLoader->findWidget(TUT_SEARCHPANEL_WIDGET));
   122     if (mSearchPanel)
   123     if (mSearchPanel)
   123         {
   124         {
   124         mSearchPanel->setSearchOptionsEnabled(true);
   125         mSearchPanel->setSearchOptionsEnabled(true);
   125         
   126         
   126         mSearchPanel->setPlaceholderText("Search device");
   127         mSearchPanel->setPlaceholderText(hbTrId("txt_search_dialog_search_device"));
   127 
   128 
   128         mSearchPanel->setCancelEnabled(false);
   129         mSearchPanel->setCancelEnabled(false);
   129         }
   130         }
   130 
   131 
   131     constructHandlers();
   132     constructHandlers();
   165     m_categorySearchUiTime.start();
   166     m_categorySearchUiTime.start();
   166     m_totalSearchUiTime.start();
   167     m_totalSearchUiTime.start();
   167     m_categoryGetDocumentApiTime.start();
   168     m_categoryGetDocumentApiTime.start();
   168     m_getDocumentCatergoryTimeAccumulator = 0;
   169     m_getDocumentCatergoryTimeAccumulator = 0;
   169 #endif
   170 #endif
       
   171 
       
   172     //Notes Editor Interface loading 
       
   173     QDir dir(NOTES_EDITOR_PLUGIN_PATH);
       
   174     QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
       
   175 
       
   176     // Create plugin loader.
       
   177     mNotespluginLoader = new QPluginLoader(pluginName);
       
   178 
       
   179     if (mNotespluginLoader)
       
   180         {
       
   181         // Load the plugin.
       
   182         mNotespluginLoader->load();
       
   183 
       
   184         QObject *plugin = qobject_cast<QObject*> (
       
   185                 mNotespluginLoader->instance());
       
   186         mNotesEditor = qobject_cast<NotesEditorInterface*> (plugin);
       
   187         }
   170     }
   188     }
   171 // ---------------------------------------------------------------------------
   189 // ---------------------------------------------------------------------------
   172 // SearchProgressiveState::~SearchProgressiveState
   190 // SearchProgressiveState::~SearchProgressiveState
   173 // ---------------------------------------------------------------------------
   191 // ---------------------------------------------------------------------------
   174 SearchProgressiveState::~SearchProgressiveState()
   192 SearchProgressiveState::~SearchProgressiveState()
   187         }
   205         }
   188     for (int i = 0; i < mSearchHandlerList.count(); i++)
   206     for (int i = 0; i < mSearchHandlerList.count(); i++)
   189         {
   207         {
   190         delete mSearchHandlerList.at(i);
   208         delete mSearchHandlerList.at(i);
   191         }
   209         }
   192     if(notesEditor)
   210     if (mNotespluginLoader)
   193         {
   211         {
   194         delete notesEditor;
   212         mNotespluginLoader->unload();
       
   213         delete mNotespluginLoader;
   195         }
   214         }
   196     }
   215     }
   197 // ---------------------------------------------------------------------------
   216 // ---------------------------------------------------------------------------
   198 // SearchProgressiveState::constructHandlers
   217 // SearchProgressiveState::constructHandlers
   199 // ---------------------------------------------------------------------------
   218 // ---------------------------------------------------------------------------
   317                 SLOT(startNewSearch(QString)));
   336                 SLOT(startNewSearch(QString)));
   318         connect(mSearchPanel, SIGNAL(searchOptionsClicked()), this,
   337         connect(mSearchPanel, SIGNAL(searchOptionsClicked()), this,
   319                 SLOT(setSettings()));
   338                 SLOT(setSettings()));
   320         }
   339         }
   321 
   340 
       
   341     connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(viewReady()));
       
   342 
   322     }
   343     }
   323 // ---------------------------------------------------------------------------
   344 // ---------------------------------------------------------------------------
   324 // SearchProgressiveState::deActivateSignals
   345 // SearchProgressiveState::deActivateSignals
   325 // ---------------------------------------------------------------------------
   346 // ---------------------------------------------------------------------------
   326 void SearchProgressiveState::deActivateSignals()
   347 void SearchProgressiveState::deActivateSignals()
   344         disconnect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this,
   365         disconnect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this,
   345                 SLOT(startNewSearch(QString)));
   366                 SLOT(startNewSearch(QString)));
   346         disconnect(mSearchPanel, SIGNAL(searchOptionsClicked()), this,
   367         disconnect(mSearchPanel, SIGNAL(searchOptionsClicked()), this,
   347                 SLOT(setSettings()));
   368                 SLOT(setSettings()));
   348         }
   369         }
       
   370     disconnect(mMainWindow, SIGNAL(viewReady()), this, SLOT(viewReady()));
   349     }
   371     }
   350 // ---------------------------------------------------------------------------
   372 // ---------------------------------------------------------------------------
   351 // SearchProgressiveState::onAsyncSearchComplete
   373 // SearchProgressiveState::onAsyncSearchComplete
   352 // ---------------------------------------------------------------------------
   374 // ---------------------------------------------------------------------------
   353 void SearchProgressiveState::onAsyncSearchComplete(int aError,
   375 void SearchProgressiveState::onAsyncSearchComplete(int aError,
   560 // ---------------------------------------------------------------------------
   582 // ---------------------------------------------------------------------------
   561 void SearchProgressiveState::openResultitem(QModelIndex index)
   583 void SearchProgressiveState::openResultitem(QModelIndex index)
   562     {
   584     {
   563     QStandardItem* item = mModel->itemFromIndex(index);
   585     QStandardItem* item = mModel->itemFromIndex(index);
   564     if (item == NULL)
   586     if (item == NULL)
   565         return;
   587         return;PERF_RESULT_ITEM_LAUNCH_TIME_RESTART
   566     QList<QVariant> args;
   588     QList<QVariant> args;
   567     bool t;
   589     bool t;
   568     mRequest = NULL;
   590     mRequest = NULL;
   569     if (item->data(Qt::UserRole + 1).toString().contains("contact"))
   591     if (item->data(Qt::UserRole + 1).toString().contains("contact"))
   570         {
   592         {
       
   593         PERF_RESULT_ITEM_FOR_LAUNCHING("contact")
   571         mRequest = mAiwMgr->create("com.nokia.services.phonebookservices",
   594         mRequest = mAiwMgr->create("com.nokia.services.phonebookservices",
   572                 "Fetch", "open(int)", false);
   595                 "Fetch", "open(int)", false);
   573 
   596 
   574         int uid = (item->data(Qt::UserRole)).toInt(&t);
   597         int uid = (item->data(Qt::UserRole)).toInt(&t);
   575         args << uid;
   598         args << uid;
   576         }
   599         }
   577     else if (item->data(Qt::UserRole + 1).toString().contains("bookmark"))
   600     else if (item->data(Qt::UserRole + 1).toString().contains("bookmark"))
   578         {
   601         {
       
   602         PERF_RESULT_ITEM_FOR_LAUNCHING("bookmark")
       
   603         PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG("")
   579 
   604 
   580         }
   605         }
   581     else if (item->data(Qt::UserRole + 1).toString().contains("calendar"))
   606     else if (item->data(Qt::UserRole + 1).toString().contains("calendar"))
   582         {
   607         {
   583         QDir pluginDir = QDir(QString("z:/resource/qt/plugins/calendar"));
   608         QDir pluginDir = QDir(QString("z:/resource/qt/plugins/calendar"));
   596                 item->data(Qt::UserRole).toInt(),
   621                 item->data(Qt::UserRole).toInt(),
   597                 EventViewerPluginInterface::ActionEditDelete, NULL);
   622                 EventViewerPluginInterface::ActionEditDelete, NULL);
   598         }
   623         }
   599     else if (item->data(Qt::UserRole + 1).toString().contains("applications"))
   624     else if (item->data(Qt::UserRole + 1).toString().contains("applications"))
   600         {
   625         {
       
   626         PERF_RESULT_ITEM_FOR_LAUNCHING("applications")
   601         TRAP_IGNORE(LaunchApplicationL(TUid::Uid((item->data(Qt::UserRole)).toString().toInt(&t, 16))));
   627         TRAP_IGNORE(LaunchApplicationL(TUid::Uid((item->data(Qt::UserRole)).toString().toInt(&t, 16))));
       
   628         PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG("")
   602         }
   629         }
   603     else if (item->data(Qt::UserRole + 1).toString().contains("file"))
   630     else if (item->data(Qt::UserRole + 1).toString().contains("file"))
   604         {
   631         {
       
   632         PERF_RESULT_ITEM_FOR_LAUNCHING("file")
   605         QString uid = item->data(Qt::UserRole).toString();
   633         QString uid = item->data(Qt::UserRole).toString();
   606         QFile file(uid);
   634         QFile file(uid);
   607         mRequest = mAiwMgr->create(file, false);
   635         mRequest = mAiwMgr->create(file, false);
   608         args << file.fileName();
   636         args << file.fileName();
   609         }
   637         }
   610     else if ((item->data(Qt::UserRole + 1).toString().contains("video"))
   638     else if ((item->data(Qt::UserRole + 1).toString().contains("video"))
   611             || (item->data(Qt::UserRole + 1).toString().contains("audio"))
   639             || (item->data(Qt::UserRole + 1).toString().contains("audio"))
   612             || (item->data(Qt::UserRole + 1).toString().contains("image")))
   640             || (item->data(Qt::UserRole + 1).toString().contains("image")))
   613         {
   641         {
       
   642         PERF_RESULT_ITEM_FOR_LAUNCHING("media")
   614         QString uid = getDrivefromMediaId(
   643         QString uid = getDrivefromMediaId(
   615                 item->data(Qt::UserRole + 2).toString());
   644                 item->data(Qt::UserRole + 2).toString());
   616         uid.append(':');
   645         uid.append(':');
   617         uid.append(item->data(Qt::UserRole).toString());
   646         uid.append(item->data(Qt::UserRole).toString());
   618         QFile file(uid);
   647         QFile file(uid);
   620         args << file.fileName();
   649         args << file.fileName();
   621         }
   650         }
   622 
   651 
   623     else if (item->data(Qt::UserRole + 1).toString().contains("notes"))
   652     else if (item->data(Qt::UserRole + 1).toString().contains("notes"))
   624         {
   653         {
   625         if (!notesEditor)
   654         PERF_RESULT_ITEM_FOR_LAUNCHING("notes")
   626             {
   655         if(mNotesEditor)
   627             notesEditor = new NotesEditor(this);
   656             {
   628             }
   657             mNotesEditor->edit(item->data(Qt::UserRole).toInt());
   629         notesEditor->edit(item->data(Qt::UserRole).toInt());
   658             }
       
   659         PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG("")
   630         }
   660         }
   631     else if (item->data(Qt::UserRole + 1).toString().contains("msg"))
   661     else if (item->data(Qt::UserRole + 1).toString().contains("msg"))
   632         {
   662         {
       
   663         PERF_RESULT_ITEM_FOR_LAUNCHING("msg")
   633         mRequest = mAiwMgr->create("com.nokia.services.hbserviceprovider",
   664         mRequest = mAiwMgr->create("com.nokia.services.hbserviceprovider",
   634                 "conversationview", "view(int)", false);
   665                 "conversationview", "view(int)", false);
   635 
   666 
   636         int uid = (item->data(Qt::UserRole)).toInt(&t);
   667         int uid = (item->data(Qt::UserRole)).toInt(&t);
   637         args << uid;
   668         args << uid;
   663 // SearchProgressiveState::handleOk
   694 // SearchProgressiveState::handleOk
   664 // ---------------------------------------------------------------------------
   695 // ---------------------------------------------------------------------------
   665 void SearchProgressiveState::handleOk(const QVariant& var)
   696 void SearchProgressiveState::handleOk(const QVariant& var)
   666     {
   697     {
   667     Q_UNUSED(var);
   698     Q_UNUSED(var);
       
   699 PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG    ("")
   668     }
   700     }
   669 // ---------------------------------------------------------------------------
   701 // ---------------------------------------------------------------------------
   670 // SearchProgressiveState::handleError
   702 // SearchProgressiveState::handleError
   671 // ---------------------------------------------------------------------------
   703 // ---------------------------------------------------------------------------
   672 void SearchProgressiveState::handleError(int ret, const QString& var)
   704 void SearchProgressiveState::handleError(int ret, const QString& var)
  1267         User::LeaveIfError(appArcSession.StartApp(*cmdLine));
  1299         User::LeaveIfError(appArcSession.StartApp(*cmdLine));
  1268         CleanupStack::PopAndDestroy(cmdLine);
  1300         CleanupStack::PopAndDestroy(cmdLine);
  1269         CleanupStack::PopAndDestroy(&appArcSession);
  1301         CleanupStack::PopAndDestroy(&appArcSession);
  1270         }
  1302         }
  1271     CleanupStack::PopAndDestroy(&wsSession);
  1303     CleanupStack::PopAndDestroy(&wsSession);
       
  1304 PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG    ("")
  1272     }
  1305     }
  1273 // ---------------------------------------------------------------------------
  1306 // ---------------------------------------------------------------------------
  1274 // SearchProgressiveState::_viewingCompleted
  1307 // SearchProgressiveState::_viewingCompleted
  1275 // ---------------------------------------------------------------------------
  1308 // ---------------------------------------------------------------------------
  1276 void SearchProgressiveState::_viewingCompleted()
  1309 void SearchProgressiveState::_viewingCompleted()
  1277     {
  1310     {
  1278     if (calAgandaViewerPluginInstance)
  1311     if (calAgandaViewerPluginInstance)
  1279         calAgandaViewerPluginInstance->deleteLater();
  1312         calAgandaViewerPluginInstance->deleteLater();
  1280     }
  1313 PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG    ("")
       
  1314     }
       
  1315 // ---------------------------------------------------------------------------
       
  1316 // SearchProgressiveState::viewReady
       
  1317 // ---------------------------------------------------------------------------
       
  1318 void SearchProgressiveState::viewReady()
       
  1319     {
       
  1320     if (hbApp)
       
  1321         {
       
  1322         if (hbApp->activateReason() == Hb::ActivationReasonActivity)
       
  1323             {
       
  1324             QVariantHash params = hbApp->activateParams();
       
  1325             QString searchKey = params.value("query").toString();
       
  1326             if (searchKey.length() > 0)
       
  1327                 mSearchPanel->setCriteria(searchKey);
       
  1328             }
       
  1329         }PERF_APP_LAUNCH_END("SearchAppplication View is ready");
       
  1330     }