homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmenuviewbuilder.cpp
changeset 55 03646e8da489
parent 51 4785f57bf3d4
child 60 30f14686fb04
equal deleted inserted replaced
51:4785f57bf3d4 55:03646e8da489
    21 #include <HbAction>
    21 #include <HbAction>
    22 #include <HbGroupBox>
    22 #include <HbGroupBox>
    23 #include <HbListView>
    23 #include <HbListView>
    24 #include <HbLineEdit>
    24 #include <HbLineEdit>
    25 #include <HbSearchPanel>
    25 #include <HbSearchPanel>
       
    26 #include <HbPushButton>
    26 #include <HbToolBar>
    27 #include <HbToolBar>
    27 #include <HbView>
    28 #include <HbView>
    28 #include <HbWidget>
    29 #include <HbWidget>
    29 #include <HbStaticVkbHost>
    30 #include <HbStaticVkbHost>
    30 #include <HbMainWindow>
    31 #include <HbMainWindow>
    81         qobject_cast<HbView *>(mDocumentLoader.findWidget(VIEW_NAME));
    82         qobject_cast<HbView *>(mDocumentLoader.findWidget(VIEW_NAME));
    82 
    83 
    83     if (view != NULL && mViewContext != HsInstalledAppsContext) {
    84     if (view != NULL && mViewContext != HsInstalledAppsContext) {
    84         view->setToolBar(mToolBar);
    85         view->setToolBar(mToolBar);
    85     }
    86     }
    86 
       
    87     return view;
    87     return view;
    88 }
    88 }
    89 
    89 
    90 /*!
    90 /*!
    91  \return pointer to list view resulting from last \a build call or NULL if 
    91  \return pointer to list view resulting from last \a build call or NULL if 
    93  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
    93  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
    94  Memory ownership is not changed.
    94  Memory ownership is not changed.
    95  */
    95  */
    96 HbListView *HsMenuViewBuilder::currentListView() const
    96 HbListView *HsMenuViewBuilder::currentListView() const
    97 {
    97 {
    98     const QString LIST_VIEW_NAME = mViewContextToStringMap[mViewContext]
    98     QString LIST_VIEW_NAME = mViewContextToStringMap[mViewContext];
    99                                    + mOperationalContextToStringMap[mOperationalContext]
    99     if (mOperationalContext == HsSearchContext) {
   100                                    + "ListView";
   100         LIST_VIEW_NAME.append(mOperationalContextToStringMap[mOperationalContext]);
       
   101     }
       
   102     LIST_VIEW_NAME.append("ListView");
   101 
   103 
   102     return qobject_cast<HbListView *>(
   104     return qobject_cast<HbListView *>(
   103                mDocumentLoader.findWidget(LIST_VIEW_NAME));
   105                mDocumentLoader.findWidget(LIST_VIEW_NAME));
   104 }
   106 }
   105 
   107 
   129     return qobject_cast<HbSearchPanel *>(mDocumentLoader.findWidget(
   131     return qobject_cast<HbSearchPanel *>(mDocumentLoader.findWidget(
   130             SEARCH_PANEL_NAME));
   132             SEARCH_PANEL_NAME));
   131 }
   133 }
   132 
   134 
   133 /*!
   135 /*!
       
   136  \return pointer to a button
       
   137  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
       
   138  Memory ownership is not changed.
       
   139  */
       
   140 HbPushButton *HsMenuViewBuilder::collectionButton() const
       
   141 {
       
   142     return qobject_cast<HbPushButton *>(mDocumentLoader.findWidget(
       
   143             BUTTON_NAME));
       
   144 }
       
   145 
       
   146 /*!
   134  \return pointer to All Applications Action. Guaranteed to be not NULL.
   147  \return pointer to All Applications Action. Guaranteed to be not NULL.
   135  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   148  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   136  Memory ownership is not changed.
   149  Memory ownership is not changed.
   137  */
   150  */
   138 HbAction *HsMenuViewBuilder::allAppsAction() const
   151 HbAction *HsMenuViewBuilder::allAppsAction() const
   228  Makes object be initialized with with hidden but existing
   241  Makes object be initialized with with hidden but existing
   229  search panel and view label.
   242  search panel and view label.
   230  */
   243  */
   231 HsMenuViewBuilder::HsMenuViewBuilder():
   244 HsMenuViewBuilder::HsMenuViewBuilder():
   232     DOCUMENT_FILE_NAME(":/xml/applibrary.docml"),
   245     DOCUMENT_FILE_NAME(":/xml/applibrary.docml"),
   233     COMMON_SECTION_NAME("commonDefinitions"),
       
   234     ALL_APPS_ACTION_NAME("allAppsAction"),
   246     ALL_APPS_ACTION_NAME("allAppsAction"),
   235     ALL_COLLECTIONS_ACTION_NAME("allCollectionsAction"),
   247     ALL_COLLECTIONS_ACTION_NAME("allCollectionsAction"),
   236     SEARCH_ACTION_NAME("searchAction"),
   248     SEARCH_ACTION_NAME("searchAction"),
   237     OVI_STORE_ACTION_NAME("oviStoreAction"),
   249     OVI_STORE_ACTION_NAME("oviStoreAction"),
   238     OPERATOR_ACTION_NAME("operatorAction"),
   250     OPERATOR_ACTION_NAME("operatorAction"),
   239     SEARCH_PANEL_NAME("searchPanel"),
   251     SEARCH_PANEL_NAME("searchPanel"),
       
   252     BUTTON_NAME("collectionButton"),
   240     TOOL_BAR_NAME("toolBar"),
   253     TOOL_BAR_NAME("toolBar"),
   241     mToolBar(new HbToolBar),
   254     mToolBar(new HbToolBar),
   242     mToolBarExtension(new HbToolBarExtension),
   255     mToolBarExtension(new HbToolBarExtension),
   243     mViewContext(HsAllAppsContext),
   256     mViewContext(HsAllAppsContext),
   244     mOperationalContext(HsItemViewContext)
   257     mOperationalContext(HsItemViewContext)
   245 {
   258 {
   246     init();
   259     init();
   247 
   260 
   248     // parse common section and the one specified by view options
   261     // parse common section and the one specified by view options
   249     const bool result = parseSection(COMMON_SECTION_NAME);
   262     const bool result = parseSection();
   250 
   263 
   251     Q_ASSERT_X(result,
   264     Q_ASSERT_X(result,
   252                "HsMenuViewBuilder::HsMenuViewBuilder()",
   265                "HsMenuViewBuilder::HsMenuViewBuilder()",
   253                "construction failed");
   266                "construction failed");
   254 
   267 
   282 bool HsMenuViewBuilder::parseSection(const QString &sectionName)
   295 bool HsMenuViewBuilder::parseSection(const QString &sectionName)
   283 {
   296 {
   284     HSMENUTEST_FUNC_ENTRY("HsMenuViewBuilder::parseSection");
   297     HSMENUTEST_FUNC_ENTRY("HsMenuViewBuilder::parseSection");
   285 
   298 
   286     bool loadStatusOk = false;
   299     bool loadStatusOk = false;
   287 
       
   288     const QObjectList loadedObjects =
   300     const QObjectList loadedObjects =
   289         mDocumentLoader.load(DOCUMENT_FILE_NAME,
   301         mDocumentLoader.load(DOCUMENT_FILE_NAME,
   290                              sectionName,
   302                              sectionName,
   291                              &loadStatusOk);
   303                              &loadStatusOk); 
   292 
       
   293     mLoadedObjects |= loadedObjects.toSet();
   304     mLoadedObjects |= loadedObjects.toSet();
   294 
   305 
   295     Q_ASSERT_X(loadStatusOk,
   306     Q_ASSERT_X(loadStatusOk,
   296                DOCUMENT_FILE_NAME.toLatin1().data(),
   307                DOCUMENT_FILE_NAME.toLatin1().data(),
   297                "Error while loading docml file.");
   308                "Error while loading docml file.");
   340     mViewContextToStringMap[HsAllCollectionsContext] = "allCollections";
   351     mViewContextToStringMap[HsAllCollectionsContext] = "allCollections";
   341     mViewContextToStringMap[HsInstalledAppsContext] = "installedApps";
   352     mViewContextToStringMap[HsInstalledAppsContext] = "installedApps";
   342     mViewContextToStringMap[HsCollectionContext] = "collection";
   353     mViewContextToStringMap[HsCollectionContext] = "collection";
   343     mOperationalContextToStringMap[HsItemViewContext] = "";
   354     mOperationalContextToStringMap[HsItemViewContext] = "";
   344     mOperationalContextToStringMap[HsSearchContext] = "Search";
   355     mOperationalContextToStringMap[HsSearchContext] = "Search";
       
   356     mOperationalContextToStringMap[HsButtonContext] = "Button";
       
   357     mOperationalContextToStringMap[HsEmptyLabelContext] = "EmptyLabel";
       
   358 
   345 }
   359 }
   346 
   360 
   347 /*!
   361 /*!
   348  Sets view context. Not reflected in widgets returned by the builder
   362  Sets view context. Not reflected in widgets returned by the builder
   349  until \a build is not run.
   363  until \a build is not run.
   358  until \a build is not run.
   372  until \a build is not run.
   359  */
   373  */
   360 void HsMenuViewBuilder::setOperationalContext(
   374 void HsMenuViewBuilder::setOperationalContext(
   361     HsOperationalContext operationalContext)
   375     HsOperationalContext operationalContext)
   362 {
   376 {
   363 
       
   364     mOperationalContext = operationalContext;
   377     mOperationalContext = operationalContext;
   365 }
   378 }
   366 
   379 
   367 /*!
   380 /*!
   368  Reads configuration for requested context and ensures search panel and corresponding
   381  Reads configuration for requested context and ensures search panel and corresponding