homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsinstalledappsstate.cpp
changeset 97 66b5fe3c07fd
parent 90 3ac3aaebaee5
child 98 e6f74eb7f69f
equal deleted inserted replaced
95:32e56106abf2 97:66b5fe3c07fd
   134 /*!
   134 /*!
   135  Method seting context menu options.
   135  Method seting context menu options.
   136  \param item the context menu is built for.
   136  \param item the context menu is built for.
   137  \param flags of the \item.
   137  \param flags of the \item.
   138  */
   138  */
   139 void HsInstalledAppsState::setContextMenuOptions(HbAbstractViewItem *item, EntryFlags flags)
   139 void HsInstalledAppsState::setContextMenuOptions(
   140 {
   140         HbAbstractViewItem *item, EntryFlags flags)
       
   141 {
       
   142     Q_UNUSED(item)
       
   143     Q_UNUSED(flags)
   141     HbAction *uninstallAction = mContextMenu->addAction(
   144     HbAction *uninstallAction = mContextMenu->addAction(
   142                                 hbTrId("txt_common_menu_delete"));
   145             hbTrId("txt_common_menu_delete"));
   143     HbAction *appDetailsAction(NULL);
       
   144     uninstallAction->setData(Hs::UninstallContextAction);
   146     uninstallAction->setData(Hs::UninstallContextAction);
   145 
   147 
   146     QSharedPointer<const CaEntry> entry = mModel->entry(item->modelIndex());
   148     HbAction *appDetailsAction = mContextMenu->addAction(
   147 
   149             hbTrId("txt_common_menu_details"));
   148     if (!(entry->attribute(Hs::componentIdAttributeName).isEmpty()) &&
   150     appDetailsAction->setData(Hs::AppDetailsContextAction);
   149             (flags & RemovableEntryFlag) ) {
       
   150         appDetailsAction = mContextMenu->addAction(hbTrId(
       
   151                                                 "txt_common_menu_details"));
       
   152         appDetailsAction->setData(Hs::AppDetailsContextAction);
       
   153     }
       
   154 }
   151 }
   155 
   152 
   156 
   153 
   157 /*!
   154 /*!
   158  Destructor.
   155  Destructor.
   169  */
   166  */
   170 void HsInstalledAppsState::stateEntered()
   167 void HsInstalledAppsState::stateEntered()
   171 {
   168 {
   172     qDebug("AllAppsState::stateEntered()");
   169     qDebug("AllAppsState::stateEntered()");
   173     HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::stateEntered");
   170     HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::stateEntered");
   174 
       
   175     mMenuView->viewLabel()->setHeading(
       
   176             hbTrId("txt_applib_subtitle_installed"));
       
   177 
   171 
   178     if (!mModel) {
   172     if (!mModel) {
   179         mModel
   173         mModel
   180             = HsMenuService::getInstalledModel(mSortAttribute);
   174             = HsMenuService::getInstalledModel(mSortAttribute);
   181     }
   175     }
   182 
   176     
       
   177     updateLabel();
       
   178     
   183     if (mModel->rowCount() == 0) {
   179     if (mModel->rowCount() == 0) {
   184         mMenuView->reset(HsEmptyLabelContext);
   180         mMenuView->reset(HsEmptyLabelContext);
   185     }
   181     }
   186     else {
   182     else {
   187 		mMenuView->reset(HsItemViewContext);
   183 		mMenuView->reset(HsItemViewContext);
   188         mMenuView->setModel(mModel);
   184         mMenuView->setModel(mModel);
   189         mMenuView->listView()->scrollTo(
   185         mMenuView->listView()->scrollTo(
   190             mModel->index(0));
   186             mModel->index(0));
   191     }
   187     }
   192     
   188 
   193     setMenuOptions();
   189     setMenuOptions();
   194 
   190 
   195     connect(mMenuView.data(),
   191     connect(mMenuView.data(),
   196             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
   192             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
   197             SLOT(showContextMenu(HbAbstractViewItem *, QPointF)));
   193             SLOT(showContextMenu(HbAbstractViewItem *, QPointF)));
   198     
   194 
   199     connect(mMenuView.data(),
   195     connect(mMenuView.data(),
   200                 SIGNAL(activated(QModelIndex)),
   196                 SIGNAL(activated(QModelIndex)),
   201                 SLOT(launchDetails(QModelIndex)));
   197                 SLOT(launchDetails(QModelIndex)));
   202 
   198 
   203     connect(mModel, SIGNAL(empty(bool)),this,
   199     connect(mModel, SIGNAL(empty(bool)),this,
   204             SLOT(setEmptyLabelVisibility(bool)));
   200             SLOT(setEmptyLabelVisibility(bool)));
   205 
   201     
       
   202     connect(mModel, SIGNAL(countChange()),this,
       
   203             SLOT(updateLabel()));
       
   204     
       
   205     
   206     HsBaseViewState::stateEntered();
   206     HsBaseViewState::stateEntered();
   207 
   207 
   208     HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateEntered");
   208     HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateEntered");
   209 }
   209 }
   210 
   210 
   213  */
   213  */
   214 void HsInstalledAppsState::stateExited()
   214 void HsInstalledAppsState::stateExited()
   215 {
   215 {
   216     HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::stateExited");
   216     HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::stateExited");
   217 
   217 
       
   218     disconnect(mModel, SIGNAL(countChange()),this,
       
   219             SLOT(updateLabel()));
       
   220     
   218     disconnect(mModel, SIGNAL(empty(bool)),this,
   221     disconnect(mModel, SIGNAL(empty(bool)),this,
   219                SLOT(setEmptyLabelVisibility(bool)));
   222                SLOT(setEmptyLabelVisibility(bool)));
   220     
   223 
   221     disconnect(mMenuView.data(),
   224     disconnect(mMenuView.data(),
   222                 SIGNAL(activated(QModelIndex)), this,
   225                 SIGNAL(activated(QModelIndex)), this,
   223                 SLOT(launchDetails(QModelIndex)));
   226                 SLOT(launchDetails(QModelIndex)));
   224 
   227 
   225     disconnect(mMenuView.data(),
   228     disconnect(mMenuView.data(),
   247     setMenuOptions();
   250     setMenuOptions();
   248     mMenuView->activate();
   251     mMenuView->activate();
   249 }
   252 }
   250 
   253 
   251 /*!
   254 /*!
       
   255  Slot update label.
       
   256  */
       
   257 void HsInstalledAppsState::updateLabel()
       
   258 {
       
   259     mMenuView->viewLabel()->setHeading(
       
   260             hbTrId("txt_applib_subtitle_installed").arg(
       
   261                     mModel->rowCount()));    
       
   262 }
       
   263 
       
   264 /*!
   252  Menu softkey back action slot
   265  Menu softkey back action slot
   253  */
   266  */
   254 #ifdef COVERAGE_MEASUREMENT
   267 #ifdef COVERAGE_MEASUREMENT
   255 #pragma CTC SKIP
   268 #pragma CTC SKIP
   256 #endif //COVERAGE_MEASUREMENT
   269 #endif //COVERAGE_MEASUREMENT
   282 /*!
   295 /*!
   283  Launches detail for app under index
   296  Launches detail for app under index
   284  */
   297  */
   285 void HsInstalledAppsState::launchDetails(const QModelIndex &index)
   298 void HsInstalledAppsState::launchDetails(const QModelIndex &index)
   286 {
   299 {
   287 	machine()->postEvent(HsMenuEventFactory::createAppDetailsViewEvent(
   300     QSharedPointer<const CaEntry> entry = mModel->entry(index);
   288 			index.data(CaItemModel::IdRole).toInt()));	
   301     if (!entry.isNull() && !(entry->flags() & UninstallEntryFlag)) {
       
   302 
       
   303         machine()->postEvent(HsMenuEventFactory::createAppDetailsViewEvent(
       
   304                 index.data(CaItemModel::IdRole).toInt()));
       
   305     }
   289 }
   306 }
   290 
   307 
   291 #ifdef COVERAGE_MEASUREMENT
   308 #ifdef COVERAGE_MEASUREMENT
   292 #pragma CTC ENDSKIP
   309 #pragma CTC ENDSKIP
   293 #endif //COVERAGE_MEASUREMENT
   310 #endif //COVERAGE_MEASUREMENT