homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmenuviewbuilder.cpp
changeset 46 23b5d6a29cce
parent 39 4e8ebe173323
child 51 4785f57bf3d4
equal deleted inserted replaced
39:4e8ebe173323 46:23b5d6a29cce
    14  * Description: Menu View Builder
    14  * Description: Menu View Builder
    15  *
    15  *
    16  */
    16  */
    17 
    17 
    18 #include <QDebug>
    18 #include <QDebug>
       
    19 #include <QActionGroup>
    19 #include <QGraphicsWidget>
    20 #include <QGraphicsWidget>
    20 #include <HbAction>
    21 #include <HbAction>
    21 #include <HbGroupBox>
    22 #include <HbGroupBox>
    22 #include <HbListView>
    23 #include <HbListView>
    23 #include <HbLineEdit>
    24 #include <HbLineEdit>
    26 #include <HbView>
    27 #include <HbView>
    27 #include <HbWidget>
    28 #include <HbWidget>
    28 #include <HbStaticVkbHost>
    29 #include <HbStaticVkbHost>
    29 #include <HbMainWindow>
    30 #include <HbMainWindow>
    30 #include <HbInputMethod>
    31 #include <HbInputMethod>
       
    32 #include <HbToolBarExtension>
    31 
    33 
    32 #include "hsmenuviewbuilder.h"
    34 #include "hsmenuviewbuilder.h"
    33 #include "hsmenustates_global.h"
    35 #include "hsmenustates_global.h"
    34 
    36 
    35 // TODO this class is temprary solution, proper one should come from Orbit
    37 // TODO this class is temprary solution, proper one should come from Orbit
    36 class HsVkbHost : public HbStaticVkbHost {
    38 class HsVkbHost : public HbStaticVkbHost
       
    39 {
    37 public:
    40 public:
    38 	explicit HsVkbHost(HbWidget *target):
    41     explicit HsVkbHost(HbWidget *target):
    39 		HbStaticVkbHost(target), mWidget(target) {}
    42         HbStaticVkbHost(target), mWidget(target) {}
    40 
    43 
    41 #ifdef COVERAGE_MEASUREMENT
    44 #ifdef COVERAGE_MEASUREMENT
    42 #pragma CTC SKIP
    45 #pragma CTC SKIP
    43 #endif //COVERAGE_MEASUREMENT skipped: its very temporary TODO
    46 #endif //COVERAGE_MEASUREMENT skipped: its very temporary TODO
    44 	void openFinished() {		
    47     void openFinished() {
    45 		updateViewHeight(applicationArea().height());
    48         updateViewHeight(applicationArea().height());
    46 	}
    49     }
    47 
    50 
    48 	void closeFinished(){				
    51     void closeFinished() {
    49 		updateViewHeight(-1);
    52         updateViewHeight(-1);
    50 	}
    53     }
    51 
    54 
    52 	void updateViewHeight(qreal height) {		
    55     void updateViewHeight(qreal height) {
    53 		HbView* view = mWidget->mainWindow()->currentView();
    56         HbView *view = mWidget->mainWindow()->currentView();
    54 		view->setMaximumHeight(height);
    57         view->setMaximumHeight(height);
    55 	}
    58     }
    56 #ifdef COVERAGE_MEASUREMENT
    59 #ifdef COVERAGE_MEASUREMENT
    57 #pragma CTC ENDSKIP
    60 #pragma CTC ENDSKIP
    58 #endif //COVERAGE_MEASUREMENT
    61 #endif //COVERAGE_MEASUREMENT
    59 	
    62 
    60 	HbWidget * mWidget;
    63     HbWidget *mWidget;
    61 };
    64 };
    62 
    65 
    63 /*!
    66 /*!
    64     \class HsMenuViewBuilder
    67     \class HsMenuViewBuilder
    65     \ingroup group_hsmenustateplugin
    68     \ingroup group_hsmenustateplugin
    69     Reads UI object from Application Library docml
    72     Reads UI object from Application Library docml
    70 
    73 
    71     \sa HsMenuView
    74     \sa HsMenuView
    72 */
    75 */
    73 
    76 
    74 /*!
    77 
    75   Sets view label visible or hidden.
    78 /*!
    76   \param visible When true label is set visible, invisible otherwise.
    79   Cleanup search text on showing search panel. Ensures vkb host instance
    77   \return \a true on success, \a false otherwise.
    80   is appears on show and disappears on hide search panel.
    78  */
    81   
    79 bool HsMenuViewBuilder::setLabelVisible(bool visible)
    82   \param visible When true search panel is to show up,
    80 {
    83   hide otherwise.
    81     bool result(true);
    84  */
    82 
    85 void HsMenuViewBuilder::searchPanelVisibilityChange(bool visible)
    83     if (visible != mViewOptions.testFlag(Label)) {
    86 {
    84         mViewOptions ^= ViewOptions(Label);
    87     if (visible) {
    85         result = parseSection(mSections[mViewOptions]);
    88         // TODO this is temprary solution, proper solution should come from Orbit
    86     }
    89         if (!HbVkbHost::getVkbHost(currentSearchPanel())) {
    87     return result;
    90             new HsVkbHost(currentSearchPanel());
    88 }
       
    89 
       
    90 
       
    91 /*!
       
    92   Sets search panel visible or hidden.
       
    93   \param visible When true search panel is set visible,
       
    94   invisible otherwise.
       
    95   \return \a true on success, \a false otherwise.
       
    96  */
       
    97 bool HsMenuViewBuilder::setSearchPanelVisible(bool visible)
       
    98 {
       
    99     bool result(true);
       
   100 
       
   101     if (visible != mViewOptions.testFlag(Search)) {
       
   102         mViewOptions ^= ViewOptions(Search);
       
   103         result = parseSection(mSections[mViewOptions]);
       
   104 
       
   105         if (visible) {
       
   106 			// TODO this is temprary solution, proper solution should come from Orbit
       
   107                         if (!HbVkbHost::getVkbHost(searchPanel()))
       
   108                                 {
       
   109                                 new HsVkbHost(searchPanel());
       
   110                                 }
       
   111             HbLineEdit *const lineEdit(searchPanelLineEdit());
       
   112 
       
   113             lineEdit->setText("");
       
   114         }
    91         }
   115         else {
    92         HbLineEdit *const lineEdit(searchPanelLineEdit());
   116            if (static_cast<HsVkbHost *>(HbVkbHost::getVkbHost(searchPanel()))) {
    93 
   117              static_cast<HsVkbHost *>(HbVkbHost::getVkbHost(searchPanel()))->
    94         lineEdit->setText("");
   118                      updateViewHeight(-1);
    95     } else {
   119             }
    96         if (static_cast<HsVkbHost *>(HbVkbHost::getVkbHost(currentSearchPanel()))) {
   120        }
    97             static_cast<HsVkbHost *>(HbVkbHost::getVkbHost(currentSearchPanel()))->
   121     }
    98             updateViewHeight(-1);
   122     return result;
    99         }
   123 }
   100     }
   124 
   101 
   125 /*!
   102 }
   126  \return \a true when label is visible, \a false otherwise.
   103 
   127  */
   104 /*!
   128 bool HsMenuViewBuilder::isLabelVisible() const
   105  \return pointer to the view resulting from last \a build call or NULL if 
   129 {
   106  the \a build has not yet been called.
   130     return mViewOptions.testFlag(Label);
   107  Memory ownership is not changed.
   131 }
   108  */
   132 
   109 HbView *HsMenuViewBuilder::currentView() const
   133 /*!
   110 {
   134  \return \a true when search panel is visible, \a false otherwise.
   111     const QString VIEW_NAME =
   135  */
   112         mViewContextToStringMap[mViewContext]
   136 bool HsMenuViewBuilder::isSearchPanelVisible() const
   113         + "View";
   137 {
   114 
   138     return mViewOptions.testFlag(Search);
   115     HbView *const view =
   139 }
   116         qobject_cast<HbView *>(mDocumentLoader.findWidget(VIEW_NAME));
   140 
   117 
   141 /*!
   118     if (view != NULL && mViewContext != HsInstalledAppsContext) {
   142  \return pointer to the main view.
   119         view->setToolBar(mToolBar);
   143  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   120     }
   144  Memory ownership is not changed.
   121 
   145  */
   122     return view;
   146 HbView *HsMenuViewBuilder::view() const
   123 }
   147 {
   124 
   148     return qobject_cast<HbView *>(mDocumentLoader.findWidget(VIEW_NAME));
   125 /*!
   149 }
   126  \return pointer to list view resulting from last \a build call or NULL if 
   150 
   127  the \a build has not yet been called.
   151 /*!
   128  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   152  \return pointer to the list item view.
   129  Memory ownership is not changed.
   153  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   130  */
   154  Memory ownership is not changed.
   131 HbListView *HsMenuViewBuilder::currentListView() const
   155  */
   132 {
   156 HbListView *HsMenuViewBuilder::listView() const
   133     const QString LIST_VIEW_NAME = mViewContextToStringMap[mViewContext]
   157 {
   134                                    + mOperationalContextToStringMap[mOperationalContext]
       
   135                                    + "ListView";
       
   136 
   158     return qobject_cast<HbListView *>(
   137     return qobject_cast<HbListView *>(
   159                mDocumentLoader.findWidget(LIST_VIEW_NAME));
   138                mDocumentLoader.findWidget(LIST_VIEW_NAME));
   160 }
   139 }
   161 
   140 
   162 /*!
   141 /*!
   163  \return pointer to the label.
   142  \return pointer to the view label resulting from last \a build call. It is 
   164  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   143  guaranteed to be not NULL if the \a build was called for the context
   165  Memory ownership is not changed.
   144  related to view including label.
   166  */
   145  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   167 HbGroupBox *HsMenuViewBuilder::label() const
   146  Memory ownership is not changed.
   168 {
   147  */
       
   148 HbGroupBox *HsMenuViewBuilder::currentViewLabel() const
       
   149 {
       
   150     const QString LABEL_NAME = mViewContextToStringMap[mViewContext]
       
   151                                + "Label";
       
   152 
   169     return qobject_cast<HbGroupBox *>(
   153     return qobject_cast<HbGroupBox *>(
   170                mDocumentLoader.findWidget(LABEL_NAME));
   154                mDocumentLoader.findWidget(LABEL_NAME));
   171 }
   155 }
   172 
   156 
   173 /*!
   157 /*!
   174  \return pointer to the searchPanel.
   158  \return pointer to search panel.
   175  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   159  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   176  Memory ownership is not changed.
   160  Memory ownership is not changed.
   177  */
   161  */
   178 HbSearchPanel *HsMenuViewBuilder::searchPanel() const
   162 HbSearchPanel *HsMenuViewBuilder::currentSearchPanel() const
   179 {
   163 {
   180     return qobject_cast<HbSearchPanel *>(mDocumentLoader.findWidget(
   164     return qobject_cast<HbSearchPanel *>(mDocumentLoader.findWidget(
   181             SEARCH_PANEL_NAME));
   165             SEARCH_PANEL_NAME));
   182 }
   166 }
   183 
   167 
   184 /*!
   168 /*!
   185  \return pointer to All Applications Action.
   169  \return pointer to All Applications Action. Guaranteed to be not NULL.
   186  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   170  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   187  Memory ownership is not changed.
   171  Memory ownership is not changed.
   188  */
   172  */
   189 HbAction *HsMenuViewBuilder::allAppsAction() const
   173 HbAction *HsMenuViewBuilder::allAppsAction() const
   190 {
   174 {
   191     return qobject_cast<HbAction *>(mDocumentLoader.findObject(
   175     return qobject_cast<HbAction *>(mDocumentLoader.findObject(
   192                                         ALL_APPS_ACTION_NAME));
   176                                         ALL_APPS_ACTION_NAME));
   193 }
   177 }
   194 
   178 
   195 /*!
   179 /*!
   196  \return pointer to All Collections Action.
   180  \return pointer to All Collections Action. Guaranteed to be not NULL.
   197  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   181  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   198  Memory ownership is not changed.
   182  Memory ownership is not changed.
   199  */
   183  */
   200 HbAction *HsMenuViewBuilder::allCollectionsAction() const
   184 HbAction *HsMenuViewBuilder::allCollectionsAction() const
   201 {
   185 {
   202     return qobject_cast<HbAction *>(mDocumentLoader.findObject(
   186     return qobject_cast<HbAction *>(mDocumentLoader.findObject(
   203                                         ALL_COLLECTIONS_ACTION_NAME));
   187                                         ALL_COLLECTIONS_ACTION_NAME));
   204 }
   188 }
   205 
   189 
   206 /*!
   190 /*!
   207  \return pointer to Search Action.
   191  \return pointer to Search Action. Guaranteed to be not NULL.
   208  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   192  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   209  Memory ownership is not changed.
   193  Memory ownership is not changed.
   210  */
   194  */
   211 HbAction *HsMenuViewBuilder::searchAction() const
   195 HbAction *HsMenuViewBuilder::searchAction() const
   212 {
   196 {
   213     return qobject_cast<HbAction *>(mDocumentLoader.findObject(
   197     return qobject_cast<HbAction *>(mDocumentLoader.findObject(
   214                                         SEARCH_ACTION_NAME));
   198                                         SEARCH_ACTION_NAME));
   215 }
   199 }
   216 
   200 
   217 /*!
   201 /*!
   218  \return pointer to Ovi Store Action.
   202  \return pointer to Ovi Store Action. Guaranteed to be not NULL.
   219  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   203  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   220  Memory ownership is not changed.
   204  Memory ownership is not changed.
   221  */
   205  */
   222 HbAction *HsMenuViewBuilder::oviStoreAction() const
   206 HbAction *HsMenuViewBuilder::oviStoreAction() const
   223 {
   207 {
   224     return qobject_cast<HbAction *>(mDocumentLoader.findObject(
   208     return qobject_cast<HbAction *>(mDocumentLoader.findObject(
   225                                         OVI_STORE_ACTION_NAME));
   209                                         OVI_STORE_ACTION_NAME));
   226 }
   210 }
   227 
   211 
   228 /*!
   212 /*!
       
   213  \return pointer to Operator Action. Guaranteed to be not NULL.
       
   214  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
       
   215  Memory ownership is not changed.
       
   216  */
       
   217 HbAction *HsMenuViewBuilder::operatorAction() const
       
   218 {
       
   219     return qobject_cast<HbAction *>(mDocumentLoader.findObject(
       
   220                                         OPERATOR_ACTION_NAME));
       
   221 }
       
   222 
       
   223 /*!
   229  \return pointer to the main view toolbar.
   224  \return pointer to the main view toolbar.
   230  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   225  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
   231  Memory ownership is not changed.
   226  Memory ownership is not changed.
   232  */
   227  */
   233 HbToolBar *HsMenuViewBuilder::toolBar() const
   228 HbToolBar *HsMenuViewBuilder::toolBar() const
   234 {
   229 {
   235     return qobject_cast<HbToolBar *>(
   230     return mToolBar;
   236                mDocumentLoader.findWidget(TOOL_BAR_NAME));
   231 }
   237 }
   232 
       
   233 /*!
       
   234  \return pointer to the toolbar extension.
       
   235  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
       
   236  Memory ownership is not changed.
       
   237  */
       
   238 HbToolBarExtension *HsMenuViewBuilder::toolBarExtension() const
       
   239 {
       
   240     return mToolBarExtension;
       
   241 }
       
   242 
       
   243 /*!
       
   244  \return action group for \a allAppsState and \a allCollectionsState action.
       
   245  */
       
   246 QActionGroup *HsMenuViewBuilder::toolBarActionGroup() const
       
   247 {
       
   248     return mToolBarActionGroup;
       
   249 }
       
   250 
       
   251 /*!
       
   252  Reads docml configuration corresponding to current context.
       
   253  */
       
   254 bool HsMenuViewBuilder::build()
       
   255 {
       
   256     return readContextConfiguration(mViewContext, mOperationalContext);
       
   257 }
       
   258 
       
   259 
   238 
   260 
   239 /*!
   261 /*!
   240  Constructor.
   262  Constructor.
   241  Makes object be initialized with with hidden but existing
   263  Makes object be initialized with with hidden but existing
   242  search panel and view label.
   264  search panel and view label.
   243  */
   265  */
   244 HsMenuViewBuilder::HsMenuViewBuilder():
   266 HsMenuViewBuilder::HsMenuViewBuilder():
   245     mViewOptions(0),
       
   246     DOCUMENT_FILE_NAME(":/xml/applibrary.docml"),
   267     DOCUMENT_FILE_NAME(":/xml/applibrary.docml"),
       
   268     COMMON_SECTION_NAME("commonDefinitions"),
   247     ALL_APPS_ACTION_NAME("allAppsAction"),
   269     ALL_APPS_ACTION_NAME("allAppsAction"),
   248     ALL_COLLECTIONS_ACTION_NAME("allCollectionsAction"),
   270     ALL_COLLECTIONS_ACTION_NAME("allCollectionsAction"),
   249     SEARCH_ACTION_NAME("searchAction"),
   271     SEARCH_ACTION_NAME("searchAction"),
   250     OVI_STORE_ACTION_NAME("oviStoreAction"),
   272     OVI_STORE_ACTION_NAME("oviStoreAction"),
   251     VIEW_NAME("view"),
   273     OPERATOR_ACTION_NAME("operatorAction"),
   252     CONTAINER_NAME("container"),
   274     SEARCH_PANEL_NAME("searchPanel"),
   253     LIST_VIEW_NAME("listView"),
       
   254     TOOL_BAR_NAME("toolBar"),
   275     TOOL_BAR_NAME("toolBar"),
   255     SEARCH_PANEL_NAME("searchPanel"),
   276     mToolBar(new HbToolBar),
   256     LABEL_NAME("label"),
   277     mToolBarExtension(new HbToolBarExtension),
   257     LIST_VIEW_SECTION_NAME("list_view"),
   278     mViewContext(HsAllAppsContext),
   258     LIST_LABELED_VIEW_SECTION_NAME("list_labeled_view"),
   279     mOperationalContext(HsItemViewContext)
   259     LIST_SEARCH_VIEW_SECTION_NAME("list_search_view"),
   280 {
   260     LIST_SEARCH_LABELED_VIEW_SECTION_NAME("list_search_labeled_view")
   281     init();
   261 {
       
   262     buildSectionKeyMap();
       
   263 
   282 
   264     // parse common section and the one specified by view options
   283     // parse common section and the one specified by view options
   265     bool result = parseSection("") && parseSection(mSections[mViewOptions]);
   284     const bool result = parseSection(COMMON_SECTION_NAME);
   266 
   285 
   267     Q_ASSERT_X(result,
   286     Q_ASSERT_X(result,
   268                "HsMenuViewBuilder::HsMenuViewBuilder()",
   287                "HsMenuViewBuilder::HsMenuViewBuilder()",
   269                "construction failed");
   288                "construction failed");
       
   289 
       
   290     mToolBar->addAction(allAppsAction());
       
   291     mToolBar->addAction(allCollectionsAction());
       
   292     mToolBar->addAction(searchAction());
       
   293 
       
   294     mToolBarActionGroup = new QActionGroup(allAppsAction());
       
   295 
       
   296     allAppsAction()->setActionGroup(mToolBarActionGroup);
       
   297     allCollectionsAction()->setActionGroup(mToolBarActionGroup);
   270 }
   298 }
   271 
   299 
   272 /*!
   300 /*!
   273  Destructor.
   301  Destructor.
   274  Deletes list view, search panel, view label, All Applications
   302  Deletes widgets owned by the Menu View Builder.
   275  Action, All Collections Action, Search Action, Ovi Store Action, container
       
   276  widget, main view toolbar and the main view.
       
   277 
       
   278  The destructor needs to be checked agains any change in related docml file.
       
   279  */
   303  */
   280 HsMenuViewBuilder::~HsMenuViewBuilder()
   304 HsMenuViewBuilder::~HsMenuViewBuilder()
   281 {
   305 {
   282     QObjectList objectList;
   306     delete mToolBarExtension;
   283 
   307     delete mToolBar;
   284     objectList << listView();
   308     qDeleteAll(mLoadedObjects);
   285 
       
   286     objectList << searchPanel();
       
   287 
       
   288     objectList << label();
       
   289 
       
   290     objectList << allAppsAction();
       
   291     objectList << allCollectionsAction();
       
   292     objectList << searchAction();
       
   293     objectList << mDocumentLoader.findWidget(CONTAINER_NAME);
       
   294     objectList << toolBar();
       
   295     objectList << view();
       
   296 
       
   297     foreach(QObject *obj, objectList) {
       
   298         obj->deleteLater();
       
   299     }
       
   300 }
   309 }
   301 
   310 
   302 /*!
   311 /*!
   303  Parses requested docml file section and reflects its contents in the
   312  Parses requested docml file section and reflects its contents in the
   304  object state.
   313  object state.
   309 {
   318 {
   310     HSMENUTEST_FUNC_ENTRY("HsMenuViewBuilder::parseSection");
   319     HSMENUTEST_FUNC_ENTRY("HsMenuViewBuilder::parseSection");
   311 
   320 
   312     bool loadStatusOk = false;
   321     bool loadStatusOk = false;
   313 
   322 
   314     QObjectList loadedObjects = mDocumentLoader.load(DOCUMENT_FILE_NAME,
   323     const QObjectList loadedObjects =
   315                                 sectionName,
   324         mDocumentLoader.load(DOCUMENT_FILE_NAME,
   316                                 &loadStatusOk);
   325                              sectionName,
       
   326                              &loadStatusOk);
       
   327 
       
   328     mLoadedObjects |= loadedObjects.toSet();
   317 
   329 
   318     Q_ASSERT_X(loadStatusOk,
   330     Q_ASSERT_X(loadStatusOk,
   319                DOCUMENT_FILE_NAME.toLatin1().data(),
   331                DOCUMENT_FILE_NAME.toLatin1().data(),
   320                "Error while loading docml file.");
   332                "Error while loading docml file.");
       
   333 
   321     HSMENUTEST_FUNC_EXIT("HsMenuViewBuilder::parseSection");
   334     HSMENUTEST_FUNC_EXIT("HsMenuViewBuilder::parseSection");
   322 
   335 
   323     return loadStatusOk;
   336     return loadStatusOk;
   324 }
   337 }
   325 
   338 
   326 /*!
   339 
   327  \retval Line edit of the searchPanel on success, 0 otherwise.
   340 /*!
       
   341  \return Line edit of the searchPanel on success, NULL otherwise.
   328  */
   342  */
   329 HbLineEdit *HsMenuViewBuilder::searchPanelLineEdit() const
   343 HbLineEdit *HsMenuViewBuilder::searchPanelLineEdit() const
   330 {
   344 {
   331     HSMENUTEST_FUNC_ENTRY("HsMenuViewBuilder::searchPanelLineEdit");
   345     HSMENUTEST_FUNC_ENTRY("HsMenuViewBuilder::searchPanelLineEdit");
   332 
   346 
   333     HbLineEdit *result(0);
   347     HbLineEdit *result(0);
   334 
   348 
   335     foreach(QGraphicsItem *obj, searchPanel()->childItems()) {
   349     foreach(QGraphicsItem *obj, currentSearchPanel()->childItems()) {
   336 
   350 
   337         QGraphicsWidget *const widget =
   351         QGraphicsWidget *const widget =
   338             static_cast<QGraphicsWidget *>(obj);
   352             static_cast<QGraphicsWidget *>(obj);
   339 
   353 
   340         if (widget != NULL) {
   354         if (widget != NULL) {
   351 
   365 
   352     return result;
   366     return result;
   353 }
   367 }
   354 
   368 
   355 /*!
   369 /*!
   356     Sets up mapping between ViewOptions and section names.
   370     Builds mapping between context and docml name buidling blocks.
   357  */
   371  */
   358 void HsMenuViewBuilder::buildSectionKeyMap()
   372 void HsMenuViewBuilder::init()
   359 {
   373 {
   360     mSections[ViewOptions()]  =
   374     mViewContextToStringMap[HsAllAppsContext] = "allApps";
   361         LIST_VIEW_SECTION_NAME;
   375     mViewContextToStringMap[HsAllCollectionsContext] = "allCollections";
   362 
   376     mViewContextToStringMap[HsInstalledAppsContext] = "installedApps";
   363     mSections[ViewOptions(Search)]   =
   377     mViewContextToStringMap[HsCollectionContext] = "collection";
   364         LIST_SEARCH_VIEW_SECTION_NAME;
   378     mOperationalContextToStringMap[HsItemViewContext] = "";
   365 
   379     mOperationalContextToStringMap[HsSearchContext] = "Search";
   366     mSections[ViewOptions(Label)]  =
   380 }
   367         LIST_LABELED_VIEW_SECTION_NAME;
   381 
   368 
   382 /*!
   369     mSections[ViewOptions(Label | Search)]   =
   383  Sets view context. Not reflected in widgets returned by the builder
   370         LIST_SEARCH_LABELED_VIEW_SECTION_NAME;
   384  until \a build is not run.
   371 }
   385  */
       
   386 void HsMenuViewBuilder::setViewContext(HsViewContext viewContext)
       
   387 {
       
   388     mViewContext = viewContext;
       
   389 }
       
   390 
       
   391 /*!
       
   392  Sets operational context. Not reflected in widgets returned by the builder
       
   393  until \a build is not run.
       
   394  */
       
   395 void HsMenuViewBuilder::setOperationalContext(
       
   396     HsOperationalContext operationalContext)
       
   397 {
       
   398 
       
   399     mOperationalContext = operationalContext;
       
   400 }
       
   401 
       
   402 /*!
       
   403  Reads configuration for requested context and ensures search panel and corresponding
       
   404  vkb host are managed properly.
       
   405  */
       
   406 bool HsMenuViewBuilder::readContextConfiguration(HsViewContext viewContext,
       
   407         HsOperationalContext operationalContext)
       
   408 {
       
   409     const QString sectionName = mViewContextToStringMap[viewContext]
       
   410         + mOperationalContextToStringMap[operationalContext] 
       
   411         + "ViewDefinition";
       
   412 
       
   413     const bool result = parseSection(sectionName);
       
   414 
       
   415     if (currentSearchPanel()) {
       
   416         searchPanelVisibilityChange(mOperationalContext == HsSearchContext);
       
   417     }
       
   418 
       
   419     return result;
       
   420 }
       
   421