homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsbaseviewstate.cpp
changeset 92 6727c5d0afc7
parent 85 35368b604b28
child 96 458d8c8d9580
equal deleted inserted replaced
85:35368b604b28 92:6727c5d0afc7
    86      is to provide widgets for.
    86      is to provide widgets for.
    87  */
    87  */
    88 void HsBaseViewState::initialize(HsMenuViewBuilder &menuViewBuilder,
    88 void HsBaseViewState::initialize(HsMenuViewBuilder &menuViewBuilder,
    89     HsStateContext stateContext)
    89     HsStateContext stateContext)
    90 {
    90 {
    91     mMenuView.reset(new HsMenuView(menuViewBuilder, stateContext, mMainWindow));
    91     mMenuView.reset(new HsMenuView(
       
    92             menuViewBuilder, stateContext, mMainWindow));
    92     mMenuView->view()->setNavigationAction(mBackKeyAction);
    93     mMenuView->view()->setNavigationAction(mBackKeyAction);
    93     mMenuView->view()->setMenu(mViewOptions);
    94     mMenuView->view()->setMenu(mViewOptions);
    94 
    95 
    95     connect(this, SIGNAL(entered()),SLOT(stateEntered()));
    96     connect(this, SIGNAL(entered()),SLOT(stateEntered()));
    96     connect(this, SIGNAL(exited()),SLOT(stateExited()));
    97     connect(this, SIGNAL(exited()),SLOT(stateExited()));
   102  \param itemId id of the launched item.
   103  \param itemId id of the launched item.
   103  */
   104  */
   104 void HsBaseViewState::createApplicationLaunchFailMessage(int errorCode,
   105 void HsBaseViewState::createApplicationLaunchFailMessage(int errorCode,
   105     int itemId)
   106     int itemId)
   106 {
   107 {
   107     QString message;
   108     QString message(HbParameterLengthLimiter(
   108     message.append(
   109             "txt_applib_info_launching_the_application_failed").arg(
   109         HbParameterLengthLimiter("txt_applib_info_launching_the_application_failed").arg(
   110                     errorCode));
   110             errorCode));
       
   111 
   111 
   112     // create and show message box
   112     // create and show message box
   113     mApplicationLaunchFailMessage = HsMenuDialogFactory().create(
   113     mApplicationLaunchFailMessage = HsMenuDialogFactory().create(
   114             message, HsMenuDialogFactory::Close);
   114             message, HsMenuDialogFactory::Close);
   115 
   115 
   116     QScopedPointer<HsMenuEntryRemovedHandler> entryObserver(
   116     QScopedPointer<HsMenuEntryRemovedHandler> entryObserver(
   117         new HsMenuEntryRemovedHandler(itemId, mApplicationLaunchFailMessage.data(), SLOT(close())));
   117             new HsMenuEntryRemovedHandler(itemId, 
       
   118                     mApplicationLaunchFailMessage.data(), SLOT(close())));
   118 
   119 
   119     entryObserver.take()->setParent(mApplicationLaunchFailMessage.data());
   120     entryObserver.take()->setParent(mApplicationLaunchFailMessage.data());
   120 
   121 
   121     mApplicationLaunchFailMessage->open();
   122     mApplicationLaunchFailMessage->open();
   122 }
   123 }
   161     connect(mMenuView.data(),
   162     connect(mMenuView.data(),
   162             SIGNAL(activated(QModelIndex)),
   163             SIGNAL(activated(QModelIndex)),
   163             SLOT(addActivated(QModelIndex)));
   164             SLOT(addActivated(QModelIndex)));
   164     connect(mMenuView.data(),
   165     connect(mMenuView.data(),
   165             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
   166             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
   166             SLOT(addLongPressed(HbAbstractViewItem *, QPointF)));
   167             SLOT(addModeShowContextMenu(HbAbstractViewItem *, QPointF)));
   167 }
   168 }
   168 
   169 
   169 /*!
   170 /*!
   170  Add mode exited.
   171  Add mode exited.
   171  */
   172  */
   242 
   243 
   243 /*!
   244 /*!
   244  Slot connected to List widget in normal mode.
   245  Slot connected to List widget in normal mode.
   245  \param index Model index of the activated item.
   246  \param index Model index of the activated item.
   246  */
   247  */
   247 void HsBaseViewState::showContextMenu(HbAbstractViewItem *item, const QPointF &coords)
   248 void HsBaseViewState::showContextMenu(
       
   249         HbAbstractViewItem *item, const QPointF &coords)
   248 {
   250 {
   249     HSMENUTEST_FUNC_ENTRY("HsBaseViewState::showContextMenu");
   251     HSMENUTEST_FUNC_ENTRY("HsBaseViewState::showContextMenu");
   250 
   252 
   251     EntryFlags flags = item->modelIndex().data(
   253     EntryFlags flags = item->modelIndex().data(
   252             CaItemModel::FlagsRole).value<EntryFlags> ();
   254             CaItemModel::FlagsRole).value<EntryFlags> ();
   396  Slot connected to List widget in add mode.
   398  Slot connected to List widget in add mode.
   397  Called when item long pressed.
   399  Called when item long pressed.
   398  \param item View item.
   400  \param item View item.
   399  \param coords Press point coordinates.
   401  \param coords Press point coordinates.
   400  */
   402  */
   401 void HsBaseViewState::addLongPressed(HbAbstractViewItem *item,
   403 void HsBaseViewState::addModeShowContextMenu(HbAbstractViewItem *item,
   402                                     const QPointF &coords)
   404                                     const QPointF &coords)
   403 {
   405 {
   404     Q_UNUSED(coords);
   406     Q_UNUSED(coords);
   405     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::addLongPressed");
   407     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::addLongPressed");
   406     addActivated(item->modelIndex());
   408     EntryFlags flags = item->modelIndex().data(
       
   409             CaItemModel::FlagsRole).value<EntryFlags> ();
       
   410 
       
   411     if (!(flags & UninstallEntryFlag)) {
       
   412         mContextMenu = new HbMenu;
       
   413 
       
   414         HbAction *addToHomeScreenAction = mContextMenu->addAction(
       
   415             hbTrId("txt_applib_menu_add_to_home_screen"));
       
   416         addToHomeScreenAction->setData(Hs::AddToHomeScreenContextAction);
       
   417 
       
   418         mContextModelIndex = item->modelIndex();
       
   419         mContextMenu->setPreferredPos(coords);
       
   420         mContextMenu->setAttribute(Qt::WA_DeleteOnClose);
       
   421         mContextMenu->open(this, SLOT(contextMenuAction(HbAction*)));
       
   422     }
   407     HSMENUTEST_FUNC_EXIT("HsAllAppsState::addLongPressed");
   423     HSMENUTEST_FUNC_EXIT("HsAllAppsState::addLongPressed");
   408 }
   424 }
   409 
   425 
   410 /*!
   426 /*!
   411  Scrolls view to first item at top
   427  Scrolls view to first item at top