homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmenuview.cpp
changeset 71 1db7cc813a4e
parent 69 87476091b3f5
child 81 7dd137878ff8
equal deleted inserted replaced
69:87476091b3f5 71:1db7cc813a4e
    74             SIGNAL(activated(QModelIndex)),
    74             SIGNAL(activated(QModelIndex)),
    75             this, SIGNAL(activated(QModelIndex)));
    75             this, SIGNAL(activated(QModelIndex)));
    76     connect(mListView,
    76     connect(mListView,
    77             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
    77             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
    78             this, SIGNAL(longPressed(HbAbstractViewItem *, QPointF)));
    78             this, SIGNAL(longPressed(HbAbstractViewItem *, QPointF)));
    79     
    79 
    80     connect(mHsSearchView.data(), SIGNAL(activated(QModelIndex)),
    80     connect(mHsSearchView.data(), SIGNAL(activated(QModelIndex)),
    81             this, SIGNAL(activated(QModelIndex)));
    81             this, SIGNAL(activated(QModelIndex)));
    82     connect(mHsSearchView.data(),
    82     connect(mHsSearchView.data(),
    83             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
    83             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
    84                         this, SIGNAL(longPressed(HbAbstractViewItem *, QPointF)));
    84                         this, SIGNAL(longPressed(HbAbstractViewItem *, QPointF)));
    96  Sets model for list item view if available in current context otherwise
    96  Sets model for list item view if available in current context otherwise
    97  ingores the request.
    97  ingores the request.
    98 
    98 
    99  \param model Model the view is to represent in HsItemViewMode.
    99  \param model Model the view is to represent in HsItemViewMode.
   100  */
   100  */
   101 void HsMenuView::setModel(HsMenuItemModel *model)
   101 void HsMenuView::setModel(QAbstractItemModel *model)
   102 {
   102 {
   103     HSMENUTEST_FUNC_ENTRY("HsMenuView::setModel");
   103     HSMENUTEST_FUNC_ENTRY("HsMenuView::setModel");
   104 
   104 
   105     if (mListView != NULL) {
   105     if (mListView != NULL) {
   106         if (mListView->model()) {
   106         if (mListView->model()) {
   111             disconnect(mListView->model(), SIGNAL(countChange()),
   111             disconnect(mListView->model(), SIGNAL(countChange()),
   112                        this,
   112                        this,
   113                         SIGNAL(listViewChange()));
   113                         SIGNAL(listViewChange()));
   114         }
   114         }
   115 
   115 
       
   116         mListView->setItemPixmapCacheEnabled(true); // TODO: remove when enabled from default
   116         mListView->setModel(model, new HsListViewItem());
   117         mListView->setModel(model, new HsListViewItem());
   117 
   118 
   118         if (mListView->model()) {
   119         if (mListView->model()) {
   119             connect(mListView->model(),
   120             connect(mListView->model(),
   120                     SIGNAL(scrollTo(int, QAbstractItemView::ScrollHint)),
   121                     SIGNAL(scrollTo(int, QAbstractItemView::ScrollHint)),
   127     }
   128     }
   128 
   129 
   129     HSMENUTEST_FUNC_EXIT("HsMenuView::setModel");
   130     HSMENUTEST_FUNC_EXIT("HsMenuView::setModel");
   130 }
   131 }
   131 
   132 
       
   133 /*!
       
   134  Returns model for list item view.
       
   135  */
       
   136 QAbstractItemModel *HsMenuView::model() const
       
   137 {
       
   138     return mListView->model();
       
   139 }
   132 
   140 
   133 /*!
   141 /*!
   134 \return View widget of the menu view.
   142 \return View widget of the menu view.
   135  */
   143  */
   136 HbView *HsMenuView::view() const
   144 HbView *HsMenuView::view() const
   137 {
   145 {
   138     return mView;
   146     return mView;
   139 }
   147 }
   140 
   148 
   141 /*!
   149 /*!
   142 \return List view widget of the menu view 
   150 \return List view widget of the menu view
   143  if available in the context or NULL otherwise.
   151  if available in the context or NULL otherwise.
   144  */
   152  */
   145 HbListView *HsMenuView::listView() const
   153 HbListView *HsMenuView::listView() const
   146 {
   154 {
   147     return mListView;
   155     return mListView;
   148 }
   156 }
   149 
   157 
   150 /*!
   158 /*!
   151     Returns label appropriate for the view.
   159     Returns label appropriate for the view.
   152     \return Pointer to the label 
   160     \return Pointer to the label
   153     if available in the context or NULL otherwise.
   161     if available in the context or NULL otherwise.
   154  */
   162  */
   155 HbGroupBox *HsMenuView::viewLabel() const
   163 HbGroupBox *HsMenuView::viewLabel() const
   156 {
   164 {
   157     return mViewLabel;
   165     return mViewLabel;
   158 }
   166 }
   159 
   167 
   160 /*!
   168 /*!
   161 \return Collection button 
   169 \return Collection button
   162  if available in the context or NULL otherwise.
   170  if available in the context or NULL otherwise.
   163  */
   171  */
   164 HbPushButton *HsMenuView::contentButton() const
   172 HbPushButton *HsMenuView::contentButton() const
   165 {
   173 {
   166     return mAddContentButton;
   174     return mAddContentButton;
   279     }
   287     }
   280     // ... and back-key action
   288     // ... and back-key action
   281     HbAction *const backKeyAction(mView->navigationAction());
   289     HbAction *const backKeyAction(mView->navigationAction());
   282 
   290 
   283     // now we can switch the context
   291     // now we can switch the context
   284 
   292     mOperationalContext = operationalContext;
   285     if (operationalContext != HsSearchContext) {
   293     synchronizeCache();
   286 
   294 
   287         mOperationalContext = operationalContext;
   295     if (mBuilder.currentViewLabel() != 0) {
   288         synchronizeCache();
   296         mBuilder.currentViewLabel()->setHeading(viewLabelHeading);
   289 
   297     }
   290         if (mBuilder.currentViewLabel() != 0) {
   298     mView->setNavigationAction(backKeyAction);
   291             mBuilder.currentViewLabel()->setHeading(viewLabelHeading);
       
   292         }
       
   293 
       
   294         mView->setNavigationAction(backKeyAction);
       
   295 
       
   296     } else {
       
   297         showSearchPanel();
       
   298     }
       
   299 }
   299 }
   300 
   300 
   301 /*!
   301 /*!
   302  Builder can be shared between many instances of HsMenuView
   302  Builder can be shared between many instances of HsMenuView
   303  being in different contexts. Before using builder make sure
   303  being in different contexts. Before using builder make sure
   304  it is in context matching the current HsMenuView.
   304  it is in context matching the current HsMenuView.
   305  */
   305  */
   306 
   306 
   307 void HsMenuView::switchBuilderContext() {
   307 void HsMenuView::switchBuilderContext()
       
   308 {
   308     mBuilder.setStateContext(mStateContext);
   309     mBuilder.setStateContext(mStateContext);
   309     mBuilder.setOperationalContext(mOperationalContext);
   310     mBuilder.setOperationalContext(mOperationalContext);
   310 }
   311 }
   311 
   312 
   312 /*!
   313 /*!