homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsinstalledappsstate.cpp
changeset 62 341166945d65
parent 55 03646e8da489
child 63 52b0f64eeb51
equal deleted inserted replaced
57:2e2dc3d30ca8 62:341166945d65
    76  \param parent Owner.
    76  \param parent Owner.
    77  */
    77  */
    78 HsInstalledAppsState::HsInstalledAppsState(HsMenuViewBuilder &menuViewBuilder,
    78 HsInstalledAppsState::HsInstalledAppsState(HsMenuViewBuilder &menuViewBuilder,
    79         HsMainWindow &mainWindow,
    79         HsMainWindow &mainWindow,
    80         QState *parent):
    80         QState *parent):
    81     QState(parent),
    81     HsBaseViewState(parent),
    82     mMenuView(menuViewBuilder, HsInstalledAppsContext),
    82     mMenuView(menuViewBuilder, HsInstalledAppsContext),
    83     mInstalledAppsModel(0),
    83     mInstalledAppsModel(0),
    84     mSecondarySoftkeyAction(new HbAction(Hb::BackNaviAction, this)),
    84     mSecondarySoftkeyAction(new HbAction(Hb::BackNaviAction, this)),
    85     mMainWindow(mainWindow),
    85     mMainWindow(mainWindow),
    86     mContextModelIndex(),mContextMenu(0)
    86     mContextModelIndex(),mContextMenu(0)
   173             SLOT(listItemLongPressed(HbAbstractViewItem *, QPointF)));
   173             SLOT(listItemLongPressed(HbAbstractViewItem *, QPointF)));
   174 
   174 
   175     connect(mInstalledAppsModel, SIGNAL(empty(bool)),this,
   175     connect(mInstalledAppsModel, SIGNAL(empty(bool)),this,
   176             SLOT(setEmptyLabelVisibility(bool)));
   176             SLOT(setEmptyLabelVisibility(bool)));
   177 
   177 
   178     mMenuView.viewLabel()->setHeading(
       
   179         hbTrId("txt_applib_subtitle_installed"));
       
   180 
       
   181     HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateEntered");
   178     HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateEntered");
   182 }
   179 }
   183 
   180 
   184 /*!
   181 /*!
   185  Slot invoked when a state is exited.
   182  Slot invoked when a state is exited.
   190 
   187 
   191     disconnect(mInstalledAppsModel, SIGNAL(empty(bool)),this,
   188     disconnect(mInstalledAppsModel, SIGNAL(empty(bool)),this,
   192                SLOT(setEmptyLabelVisibility(bool)));
   189                SLOT(setEmptyLabelVisibility(bool)));
   193 
   190 
   194     mMenuView.setSearchPanelVisible(false);
   191     mMenuView.setSearchPanelVisible(false);
       
   192 
       
   193     disconnect(&mMenuView,
       
   194             SIGNAL(activated(QModelIndex)), this,
       
   195             SLOT(listItemActivated(QModelIndex)));
       
   196     disconnect(&mMenuView,
       
   197             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), this,
       
   198             SLOT(listItemLongPressed(HbAbstractViewItem *, QPointF)));
       
   199 
   195     mMenuView.inactivate();
   200     mMenuView.inactivate();
   196 
   201 
   197     if (mContextMenu)
   202     if (mContextMenu)
   198         mContextMenu->close();
   203         mContextMenu->close();
       
   204     
       
   205     HsBaseViewState::stateExited();
   199     
   206     
   200     HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateExited");
   207     HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateExited");
   201     qDebug("AllAppsState::stateExited()");
   208     qDebug("AllAppsState::stateExited()");
   202 }
   209 }
   203 
   210 
   248 void HsInstalledAppsState::listItemLongPressed(HbAbstractViewItem *item,
   255 void HsInstalledAppsState::listItemLongPressed(HbAbstractViewItem *item,
   249         const QPointF &coords)
   256         const QPointF &coords)
   250 {
   257 {
   251     HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::listItemLongPressed");
   258     HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::listItemLongPressed");
   252 
   259 
   253     // create context menu
       
   254     mContextMenu = new HbMenu();
       
   255 
       
   256     HbAction *uninstallAction = mContextMenu->addAction(
       
   257                                     hbTrId("txt_common_menu_delete"));
       
   258     HbAction *appDetailsAction(NULL);
       
   259     uninstallAction->setData(UninstallContextAction);
       
   260     
       
   261     QSharedPointer<const CaEntry> entry = mInstalledAppsModel->entry(item->modelIndex());
       
   262     EntryFlags flags = item->modelIndex().data(
   260     EntryFlags flags = item->modelIndex().data(
   263                            CaItemModel::FlagsRole).value<EntryFlags> ();
   261                            CaItemModel::FlagsRole).value<EntryFlags> ();
   264     
   262     if (!(flags & UninstallEntryFlag)) {
   265     if (!(entry->attribute(componentIdAttributeName()).isEmpty()) && 
   263         // create context menu
   266             (flags & RemovableEntryFlag) ) {
   264         mContextMenu = new HbMenu();
   267         appDetailsAction = mContextMenu->addAction(hbTrId(
   265 
   268                                                 "txt_common_menu_details"));
   266         HbAction *uninstallAction = mContextMenu->addAction(
   269         appDetailsAction->setData(AppDetailsContextAction);
   267                                     hbTrId("txt_common_menu_delete"));
   270     }      
   268         HbAction *appDetailsAction(NULL);
   271 
   269         uninstallAction->setData(UninstallContextAction);
   272     mContextModelIndex = item->modelIndex();
   270     
   273     mContextMenu->setPreferredPos(coords);
   271         QSharedPointer<const CaEntry> entry = mInstalledAppsModel->entry(item->modelIndex());
   274     mContextMenu->setAttribute(Qt::WA_DeleteOnClose);
   272     
   275     mContextMenu->open(this, SLOT(contextMenuAction(HbAction*)));
   273         if (!(entry->attribute(componentIdAttributeName()).isEmpty()) &&
       
   274                 (flags & RemovableEntryFlag) ) {
       
   275             appDetailsAction = mContextMenu->addAction(hbTrId(
       
   276                                                     "txt_common_menu_details"));
       
   277             appDetailsAction->setData(AppDetailsContextAction);
       
   278         }
       
   279 
       
   280         mContextModelIndex = item->modelIndex();
       
   281         mContextMenu->setPreferredPos(coords);
       
   282         mContextMenu->setAttribute(Qt::WA_DeleteOnClose);
       
   283         mContextMenu->open(this, SLOT(contextMenuAction(HbAction*)));
       
   284     }
   276     
   285     
   277     
   286     
   278     HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::listItemLongPressed");
   287     HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::listItemLongPressed");
   279 }
   288 }
   280 #ifdef COVERAGE_MEASUREMENT
   289 #ifdef COVERAGE_MEASUREMENT