homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallappsstate.cpp
changeset 63 52b0f64eeb51
parent 62 341166945d65
child 69 87476091b3f5
equal deleted inserted replaced
62:341166945d65 63:52b0f64eeb51
    13  *
    13  *
    14  * Description: Menu All Applications state.
    14  * Description: Menu All Applications state.
    15  *
    15  *
    16  */
    16  */
    17 
    17 
    18 #include <qstatemachine.h>
    18 #include <QStateMachine>
    19 #include <hbview.h>
    19 #include <HbMenu>
    20 #include <hblistview.h>
    20 #include <HbAction>
    21 #include <hbaction.h>
    21 #include <HbAbstractViewItem>
    22 #include <hbmenu.h>
    22 #include <HbIndexFeedback>
    23 #include <hbabstractviewitem.h>
    23 #include <HbListView>
    24 #include <hsmenueventfactory.h>
    24 #include <HbScrollBar>
    25 #include <hbinstance.h>
    25 #include <HbView>
       
    26 
       
    27 #include <cadefs.h>
    26 #include <caentry.h>
    28 #include <caentry.h>
    27 #include <hbsearchpanel.h>
    29 #include <caitemmodel.h>
    28 #include <HbScrollBar>
    30 #include <caservice.h>
    29 #include <HbIndexFeedback>
    31 
    30 
    32 #include "hsapp_defs.h"
       
    33 #include "hsmenueventfactory.h"
    31 #include "hsmenuitemmodel.h"
    34 #include "hsmenuitemmodel.h"
    32 #include "cadefs.h"
       
    33 #include "hsallappsstate.h"
    35 #include "hsallappsstate.h"
    34 #include "hsaddappstocollectionstate.h"
       
    35 #include "hsapp_defs.h"
       
    36 #include "hsmenumodewrapper.h"
    36 #include "hsmenumodewrapper.h"
    37 #include "hsmenuviewbuilder.h"
    37 #include "hsmenuviewbuilder.h"
    38 #include "hsmenumodetransition.h"
       
    39 #include "caentry.h"
       
    40 #include "caservice.h"
       
    41 #include "hsmainwindow.h"
    38 #include "hsmainwindow.h"
    42 
    39 
    43 /*!
    40 /*!
    44  \class HsAllAppsState
    41  \class HsAllAppsState
    45  \ingroup group_hsmenustateplugin
    42  \ingroup group_hsmenustateplugin
    53  \var HsAllAppsState::mSortAttribute
    50  \var HsAllAppsState::mSortAttribute
    54  Sort order
    51  Sort order
    55  */
    52  */
    56 
    53 
    57 /*!
    54 /*!
    58  \var HsAllAppsState::mCollectionsSortAttribute
       
    59  Collections sort order
       
    60  */
       
    61 
       
    62 /*!
       
    63  \var HsAllAppsState::mMenuView
       
    64  Wrapper for All Applications View.
       
    65  */
       
    66 
       
    67 /*!
       
    68  \var HsAllAppsState::mMenuMode
       
    69  Menu view mode wrapper.
       
    70  Not Own.
       
    71  */
       
    72 
       
    73 /*!
       
    74  Constructor.
    55  Constructor.
    75  \param menuViewBuilder Menu view builder.
    56  \param menuViewBuilder Menu view builder.
    76  \param menuMode reference to object representing menu mode (add mode on/add mode off).
    57  \param menuMode Menu mode object(add mode on/add mode off).
       
    58  \param mainWindow Main window wrapper.
    77  \param parent Owner.
    59  \param parent Owner.
    78  */
    60  */
    79 HsAllAppsState::HsAllAppsState(HsMenuViewBuilder &menuViewBuilder,
    61 HsAllAppsState::HsAllAppsState(HsMenuViewBuilder &menuViewBuilder,
    80                                HsMenuModeWrapper &menuMode,
    62                                HsMenuModeWrapper &menuMode,
    81                                HsMainWindow &mainWindow,
    63                                HsMainWindow &mainWindow,
    82                                QState *parent) :
    64                                QState *parent) :
    83     HsBaseViewState(parent), mSortAttribute(AscendingNameHsSortAttribute),
    65     HsBaseViewState(mainWindow, menuMode, parent),
    84     mCollectionsSortAttribute(LatestOnTopHsSortAttribute),
    66     mSortAttribute(AscendingNameHsSortAttribute)
    85     mMenuView(menuViewBuilder, HsAllAppsContext),
    67 {
    86     mMenuMode(menuMode),
    68     initialize(menuViewBuilder, HsAllAppsContext);
    87     mAllAppsModel(0),
       
    88     mMainWindow(mainWindow),
       
    89     mContextModelIndex(), mContextMenu(0)
       
    90 {
       
    91     construct();
    69     construct();
    92 }
    70 }
    93 
    71 
    94 /*!
    72 /*!
    95  Constructs contained objects.
    73  Constructs contained objects.
    96  */
    74  */
    97 void HsAllAppsState::construct()
    75 void HsAllAppsState::construct()
    98 {
    76 {
    99     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::construct");
    77     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::construct");
   100 
    78 
   101     QState *initialState = new QState(this);
    79     defineTransitions();
   102     setInitialState(initialState);
       
   103 
       
   104     QState *addModeState = new QState(this);
       
   105     connect(addModeState, SIGNAL(entered()),SLOT(addModeEntered()));
       
   106 
       
   107     QState *normalModeState = new QState(this);
       
   108     connect(normalModeState, SIGNAL(entered()),SLOT(normalModeEntered()));
       
   109 
       
   110     initialState->addTransition(new HsMenuModeTransition(
       
   111                                     mMenuMode, NormalHsMenuMode, normalModeState));
       
   112     initialState->addTransition(new HsMenuModeTransition(
       
   113                                     mMenuMode, AddHsMenuMode, addModeState));
       
   114 
    80 
   115     const QString parentName =
    81     const QString parentName =
   116         parent() != 0 ? parent()->objectName() : QString("");
    82         parent() != 0 ? parent()->objectName() : QString("");
   117     setObjectName(parentName + "/allappsstate");
    83     setObjectName(parentName + "/allappsstate");
   118 
    84 
   119     connect(this, SIGNAL(entered()),SLOT(stateEntered()));
    85     connect(mBackKeyAction, SIGNAL(triggered()), SIGNAL(toAppLibraryState()));
   120     connect(this, SIGNAL(exited()),SLOT(stateExited()));
    86 
   121 
    87     mModel = HsMenuService::getAllApplicationsModel(mSortAttribute);
   122     mSecondarySoftkeyAction = new HbAction(Hb::BackNaviAction, this);
    88     mMenuView->setModel(mModel);
   123 
    89 
   124     mMenuView.view()->setNavigationAction(
    90     mMenuView->listView()->verticalScrollBar()->setInteractive(true);
   125         mSecondarySoftkeyAction);
    91     HbIndexFeedback *indexFeedback = new HbIndexFeedback(mMenuView->view());
   126 
       
   127     connect(mSecondarySoftkeyAction, SIGNAL(triggered()),
       
   128             SIGNAL(toAppLibraryState()));
       
   129 
       
   130     mAllAppsModel = HsMenuService::getAllApplicationsModel(mSortAttribute);
       
   131     mMenuView.setModel(mAllAppsModel);
       
   132 
       
   133     mMenuView.listView()->verticalScrollBar()->setInteractive(true);
       
   134     HbIndexFeedback *indexFeedback = new HbIndexFeedback(mMenuView.view());
       
   135     indexFeedback->setIndexFeedbackPolicy(HbIndexFeedback::IndexFeedbackSingleCharacter);
    92     indexFeedback->setIndexFeedbackPolicy(HbIndexFeedback::IndexFeedbackSingleCharacter);
   136     indexFeedback->setItemView(mMenuView.listView());
    93     indexFeedback->setItemView(mMenuView->listView());
   137 
    94 
   138     HSMENUTEST_FUNC_EXIT("HsAllAppsState::construct");
    95     HSMENUTEST_FUNC_EXIT("HsAllAppsState::construct");
   139 }
    96 }
       
    97 
   140 
    98 
   141 /*!
    99 /*!
   142  Creates and installs menu options for the view
   100  Creates and installs menu options for the view
   143  */
   101  */
   144 void HsAllAppsState::setMenuOptions()
   102 void HsAllAppsState::setMenuOptions()
   145 {
   103 {
   146     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::setMenuOptions");
   104     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::setMenuOptions");
   147     QScopedPointer<HbMenu> viewOptions(new HbMenu);
   105     QScopedPointer<HbMenu> viewOptions(new HbMenu);
   148     viewOptions->addAction(hbTrId("txt_applib_opt_task_switcher"),
   106     viewOptions->addAction(hbTrId("txt_applib_opt_task_switcher"),
   149                            this, SLOT(openTaskSwitcher()));
   107                            static_cast<HsBaseViewState*>(this), SLOT(openTaskSwitcher()));
   150     viewOptions->addAction(hbTrId("txt_applib_opt_add_to_collection"),
   108     viewOptions->addAction(hbTrId("txt_applib_opt_add_to_collection"),
   151                            this, SLOT(addToCollection()));
   109                            this, SLOT(addToCollection()));
   152     viewOptions->addAction(hbTrId("txt_applib_opt_check_software_updates"),
   110     viewOptions->addAction(hbTrId("txt_applib_opt_check_software_updates"),
   153                            this, SLOT(checkSoftwareUpdates()));
   111                            static_cast<HsBaseViewState*>(this), SLOT(checkSoftwareUpdates()));
   154 
   112 
   155     HbMenu *const sortMenu = viewOptions->addMenu(hbTrId(
   113     HbMenu *const sortMenu = viewOptions->addMenu(hbTrId(
   156                                  "txt_applib_opt_sort_by"));
   114                                  "txt_applib_opt_sort_by"));
   157     //Grouped options are exclusive by default.
   115     //Grouped options are exclusive by default.
   158     QActionGroup *sortGroup = new QActionGroup(viewOptions.data());
   116     QActionGroup *sortGroup = new QActionGroup(viewOptions.data());
   182         break;
   140         break;
   183     }
   141     }
   184     if (currentSortingPosition >= 0) {
   142     if (currentSortingPosition >= 0) {
   185         sortGroup->actions().at(currentSortingPosition)->setChecked(true);
   143         sortGroup->actions().at(currentSortingPosition)->setChecked(true);
   186     }
   144     }
   187     mMenuView.view()->setMenu(viewOptions.take());
   145     mMenuView->view()->setMenu(viewOptions.take());
   188 
   146 
   189     HSMENUTEST_FUNC_EXIT("HsAllAppsState::setMenuOptions");
   147     HSMENUTEST_FUNC_EXIT("HsAllAppsState::setMenuOptions");
   190 }
   148 }
   191 
   149 
   192 /*!
   150 /*!
   193  Destructor.
   151  Destructor.
   194  */
   152  */
   195 
   153 
   196 HsAllAppsState::~HsAllAppsState()
   154 HsAllAppsState::~HsAllAppsState()
   197 {
   155 {
   198     mMenuView.setModel(NULL);
   156 }
   199     delete mAllAppsModel;
   157 
   200 }
       
   201 
       
   202 /*!
       
   203  Scrolls view to first item at top
       
   204  */
       
   205 void HsAllAppsState::scrollToBeginning()
       
   206 {
       
   207     mMenuView.listView()->scrollTo(
       
   208         mAllAppsModel->index(0), HbAbstractItemView::PositionAtTop);
       
   209 }
       
   210 
       
   211 /*!
       
   212  Slot invoked when a state is entered.
       
   213  */
       
   214 
       
   215 
       
   216 void HsAllAppsState::stateEntered()
       
   217 {
       
   218     qDebug("AllAppsState::stateEntered()");
       
   219     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::stateEntered");
       
   220     
       
   221     mMainWindow.setCurrentView(mMenuView);
       
   222     mMenuView.activate();
       
   223 
       
   224     HSMENUTEST_FUNC_EXIT("HsAllAppsState::stateEntered");
       
   225 }
       
   226 
   158 
   227 /*!
   159 /*!
   228  Slot invoked when add mode entered.
   160  Slot invoked when add mode entered.
   229  */
   161  */
   230 void HsAllAppsState::normalModeEntered()
   162 void HsAllAppsState::normalModeEntered()
   231 {    
   163 {
   232     setMenuOptions();
   164     HsBaseViewState::normalModeEntered();
   233     connect(&mMainWindow, SIGNAL(viewIsReady()),
   165     connect(mMenuView.data(),
   234         &mMainWindow, SLOT(saveActivity()),
       
   235         Qt::UniqueConnection);
       
   236     connect(&mMenuView,
       
   237             SIGNAL(activated(QModelIndex)),
   166             SIGNAL(activated(QModelIndex)),
   238             SLOT(listItemActivated(QModelIndex)));
   167             static_cast<HsBaseViewState*>(this), SLOT(launchItem(QModelIndex)));
   239     connect(&mMenuView,
       
   240             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
       
   241             SLOT(listItemLongPressed(HbAbstractViewItem *, QPointF)));
       
   242 }
       
   243 
       
   244 /*!
       
   245  Add mode entered.
       
   246  */
       
   247 void HsAllAppsState::addModeEntered()
       
   248 {
       
   249     connect(&mMenuView,
       
   250             SIGNAL(activated(QModelIndex)),
       
   251             SLOT(addActivated(QModelIndex)));
       
   252     connect(&mMenuView,
       
   253             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
       
   254             SLOT(addLongPressed(HbAbstractViewItem *, QPointF)));
       
   255 }
   168 }
   256 
   169 
   257 /*!
   170 /*!
   258  Slot invoked when a state is exited.
   171  Slot invoked when a state is exited.
   259  */
   172  */
   260 void HsAllAppsState::stateExited()
   173 void HsAllAppsState::stateExited()
   261 {
   174 {
   262     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::stateExited");
   175     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::stateExited");
   263 
       
   264     disconnect(&mMainWindow, SIGNAL(viewIsReady()),
       
   265                &mMainWindow, SLOT(saveActivity()));
       
   266        
       
   267     mMenuView.setSearchPanelVisible(false);
       
   268 
       
   269     mMenuView.disconnect(this);
       
   270 
       
   271     mMenuView.view()->setMenu(NULL);
       
   272 
       
   273     mMenuView.inactivate();
       
   274 
       
   275     if (mContextMenu)
       
   276         mContextMenu->close();
       
   277 
   176 
   278     HsBaseViewState::stateExited();
   177     HsBaseViewState::stateExited();
   279     
   178     
   280     HSMENUTEST_FUNC_EXIT("HsAllAppsState::stateExited");
   179     HSMENUTEST_FUNC_EXIT("HsAllAppsState::stateExited");
   281     qDebug("AllAppsState::stateExited()");
   180     qDebug("AllAppsState::stateExited()");
   282 }
   181 }
   283 
   182 
   284 /*!
   183 /*!
   285  Open task switcher.
       
   286  \retval true if operation is successful.
       
   287  */
       
   288 bool HsAllAppsState::openTaskSwitcher()
       
   289 {
       
   290     return HsMenuService::launchTaskSwitcher();
       
   291 }
       
   292 
       
   293 /*!
       
   294  Check software updates.
       
   295  \retval 0 if operation is successful.
       
   296  */
       
   297 int HsAllAppsState::checkSoftwareUpdates()
       
   298 {
       
   299     int errCode = HsMenuService::launchSoftwareUpdate();
       
   300     if (errCode != 0){
       
   301         createApplicationLaunchFailMessage(errCode,0);
       
   302     }
       
   303     return errCode;
       
   304 }
       
   305 
       
   306 /*!
       
   307  Slot connected to List widget in normal mode.
       
   308  \param index Model index of the activated item.
       
   309  */
       
   310 void HsAllAppsState::listItemActivated(const QModelIndex &index)
       
   311 {
       
   312     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::listItemActivated");
       
   313 
       
   314     QSharedPointer<const CaEntry> entry = mAllAppsModel->entry(index);
       
   315     
       
   316     if (entry->entryTypeName() == widgetTypeName()) {
       
   317         EntryFlags flags = index.data(CaItemModel::FlagsRole).value<
       
   318                                EntryFlags> ();
       
   319         if (!(flags & UninstallEntryFlag)) {
       
   320             machine()->postEvent(
       
   321                 HsMenuEventFactory::createPreviewHSWidgetEvent(
       
   322                     entry->id(), entry->entryTypeName(), entry->attribute(
       
   323                         widgetUriAttributeName()), entry->attribute(
       
   324                         widgetLibraryAttributeName())));
       
   325 
       
   326             const int itemId = index.data(CaItemModel::IdRole).toInt();
       
   327             HsMenuService::touch(itemId);
       
   328         }
       
   329     } else {
       
   330         QVariant data = mAllAppsModel->data(index, CaItemModel::IdRole);
       
   331         int errCode = HsMenuService::executeAction(data.toInt());
       
   332         if (errCode != 0) {
       
   333             createApplicationLaunchFailMessage(errCode,index.data(CaItemModel::IdRole).toInt());
       
   334         }
       
   335     }
       
   336     
       
   337     mMenuView.setSearchPanelVisible(false);
       
   338 
       
   339     HSMENUTEST_FUNC_EXIT("HsAllAppsState::listItemActivated");
       
   340 }
       
   341 
       
   342 /*!
       
   343  Slot connected to List widget in add mode.
   184  Slot connected to List widget in add mode.
   344  \param index Model index of the activated item.
   185  \param index Model index of the activated item.
   345  */
   186  */
   346 void HsAllAppsState::addActivated(const QModelIndex &index)
   187 void HsAllAppsState::addActivated(const QModelIndex &index)
   347 {
   188 {
       
   189     mMenuView->disconnect(this);
   348     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::addActivated");
   190     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::addActivated");
   349     addToHomeScreen(index);
   191     addToHomeScreen(index);
   350     HSMENUTEST_FUNC_EXIT("HsAllAppsState::addActivated");
   192     HSMENUTEST_FUNC_EXIT("HsAllAppsState::addActivated");
   351 }
   193 }
   352 
   194 
   353 /*!
       
   354  Handles long-item-pressed event in all apps view by showing context menu
       
   355  \param item View item
       
   356  \param coords Press point coordinates
       
   357  */
       
   358 void HsAllAppsState::listItemLongPressed(HbAbstractViewItem *item,
       
   359         const QPointF &coords)
       
   360 {
       
   361     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::listItemLongPressed");
       
   362 
       
   363     EntryFlags flags = item->modelIndex().data(
       
   364                            CaItemModel::FlagsRole).value<EntryFlags> ();
       
   365 
       
   366     if (!(flags & UninstallEntryFlag)) {
       
   367         // create context menu
       
   368         mContextMenu = new HbMenu;
       
   369 
       
   370         HbAction *addToHomeScreenAction = mContextMenu->addAction(
       
   371             hbTrId("txt_applib_menu_add_to_home_screen"));
       
   372         addToHomeScreenAction->setData(AddToHomeScreenContextAction);
       
   373 
       
   374         HbAction *addToCollectionAction = mContextMenu->addAction(
       
   375             hbTrId("txt_applib_menu_add_to_collection"));
       
   376         addToCollectionAction->setData(AddToCollectionContextAction);
       
   377 
       
   378         HbAction *uninstallAction = mContextMenu->addAction(
       
   379             hbTrId("txt_common_menu_delete"));
       
   380         uninstallAction->setData(UninstallContextAction);
       
   381         HbAction *appSettingsAction(NULL);
       
   382         HbAction *appDetailsAction(NULL);
       
   383 
       
   384         // check conditions and hide irrelevant menu items
       
   385         QSharedPointer<const CaEntry> entry = mAllAppsModel->entry(item->modelIndex());
       
   386 
       
   387         if (!(entry->attribute(appSettingsPlugin()).isEmpty())) {
       
   388             appSettingsAction = mContextMenu->addAction(
       
   389                 hbTrId("txt_common_menu_settings"));
       
   390             appSettingsAction->setData(AppSettingContextAction);
       
   391         }
       
   392         if (!(entry->attribute(componentIdAttributeName()).isEmpty()) &&
       
   393                 (flags & RemovableEntryFlag) ) {
       
   394             appDetailsAction = mContextMenu->addAction(
       
   395                 hbTrId("txt_common_menu_details"));
       
   396             appDetailsAction->setData(AppDetailsContextAction);
       
   397         }
       
   398 
       
   399         if (!(flags & RemovableEntryFlag)) {
       
   400             uninstallAction->setVisible(false);
       
   401         }
       
   402 
       
   403         mContextModelIndex = item->modelIndex();
       
   404         mContextMenu->setPreferredPos(coords);
       
   405         mContextMenu->setAttribute(Qt::WA_DeleteOnClose);
       
   406         mContextMenu->open(this, SLOT(contextMenuAction(HbAction*)));
       
   407     }
       
   408 
       
   409 
       
   410     HSMENUTEST_FUNC_EXIT("HsAllAppsState::listItemLongPressed");
       
   411 }
       
   412 
   195 
   413 /*!
   196 /*!
   414  Handles context menu actions
   197  Handles context menu actions
   415  */
   198  */
   416 void HsAllAppsState::contextMenuAction(HbAction *action)
   199 void HsAllAppsState::contextMenuAction(HbAction *action)
   427         case AddToCollectionContextAction:
   210         case AddToCollectionContextAction:
   428             // Addding a specific application to
   211             // Addding a specific application to
   429             // an existing collection via item specific menu.
   212             // an existing collection via item specific menu.
   430             machine()->postEvent(
   213             machine()->postEvent(
   431                 HsMenuEventFactory::createAddAppsFromApplicationsViewEvent(
   214                 HsMenuEventFactory::createAddAppsFromApplicationsViewEvent(
   432                     mSortAttribute, mCollectionsSortAttribute, itemId));
   215                     mSortAttribute, itemId));
   433             break;
   216             break;
   434         case UninstallContextAction:
   217         case UninstallContextAction:
   435             machine()->postEvent(
   218             machine()->postEvent(
   436                 HsMenuEventFactory::createUninstallApplicationEvent(itemId));
   219                 HsMenuEventFactory::createUninstallApplicationEvent(itemId));
   437             break;
   220             break;
   444                 HsMenuEventFactory::createAppDetailsViewEvent(itemId));
   227                 HsMenuEventFactory::createAppDetailsViewEvent(itemId));
   445             break;            
   228             break;            
   446         default:
   229         default:
   447             break;
   230             break;
   448     }
   231     }
   449                                     
   232     mMenuView->setSearchPanelVisible(false);
   450     mMenuView.setSearchPanelVisible(false);
       
   451 }
   233 }
   452 
   234 
   453 /*!
   235 /*!
   454  Slot connected to List widget in add mode.
   236  Slot connected to List widget in add mode.
   455  Called when item long pressed.
   237  Called when item long pressed.
   458  */
   240  */
   459 void HsAllAppsState::addLongPressed(HbAbstractViewItem *item,
   241 void HsAllAppsState::addLongPressed(HbAbstractViewItem *item,
   460                                     const QPointF &coords)
   242                                     const QPointF &coords)
   461 {
   243 {
   462     Q_UNUSED(coords);
   244     Q_UNUSED(coords);
       
   245     mMenuView->disconnect(this);
   463     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::addLongPressed");
   246     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::addLongPressed");
   464     addToHomeScreen(item->modelIndex());
   247     addToHomeScreen(item->modelIndex());
   465     HSMENUTEST_FUNC_EXIT("HsAllAppsState::addLongPressed");
   248     HSMENUTEST_FUNC_EXIT("HsAllAppsState::addLongPressed");
   466 
   249 
   467 }
   250 }
   473 {
   256 {
   474     // Add one/many applications to
   257     // Add one/many applications to
   475     // a new/an existing collection via the All view
   258     // a new/an existing collection via the All view
   476     machine()->postEvent(
   259     machine()->postEvent(
   477         HsMenuEventFactory::createAddAppsFromApplicationsViewEvent(
   260         HsMenuEventFactory::createAddAppsFromApplicationsViewEvent(
   478             mSortAttribute, mCollectionsSortAttribute));
   261             mSortAttribute));
   479 }
   262 }
   480 
   263 
   481 /*!
   264 /*!
   482  Triggers event so that a installed applications state is entered.
   265  Triggers event so that a installed applications state is entered.
   483  \retval void
   266  \retval void
   493 #pragma CTC ENDSKIP
   276 #pragma CTC ENDSKIP
   494 #endif //COVERAGE_MEASUREMENT
   277 #endif //COVERAGE_MEASUREMENT
   495 
   278 
   496 /*!
   279 /*!
   497  Triggers event so that a state adding to Home Screen is reached
   280  Triggers event so that a state adding to Home Screen is reached
   498  \param index of an item to be added to homescreen
   281  \param index of an item to be added to homescreen.
   499  \retval void
   282  \retval void
   500  */
   283  */
   501 void HsAllAppsState::addToHomeScreen(const QModelIndex &index)
   284 void HsAllAppsState::addToHomeScreen(const QModelIndex &index)
   502 {
   285 {
   503     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::addToHomeScreen");
   286     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::addToHomeScreen");
   504     QSharedPointer<const CaEntry> entry = mAllAppsModel->entry(index);
   287     QSharedPointer<const CaEntry> entry = mModel->entry(index);
   505 
   288 
   506     machine()-> postEvent(HsMenuEventFactory::createAddToHomeScreenEvent(
   289     machine()-> postEvent(HsMenuEventFactory::createAddToHomeScreenEvent(
   507                               entry->id(), mMenuMode.getHsMenuMode(), 
   290                               entry->id(), mMenuMode->getHsMenuMode(),
   508                               mMenuMode.getHsToken()));
   291                               mMenuMode->getHsToken()));
   509 
   292 
   510     HSMENUTEST_FUNC_EXIT("HsAllAppsState::addToHomeScreen");
   293     HSMENUTEST_FUNC_EXIT("HsAllAppsState::addToHomeScreen");
       
   294 }
       
   295 
       
   296 /*!
       
   297  Method seting context menu options.
       
   298  */
       
   299 void HsAllAppsState::setContextMenuOptions(HbAbstractViewItem *item, EntryFlags flags)
       
   300 {
       
   301     HbAction *addToHomeScreenAction = mContextMenu->addAction(
       
   302         hbTrId("txt_applib_menu_add_to_home_screen"));
       
   303     addToHomeScreenAction->setData(AddToHomeScreenContextAction);
       
   304 
       
   305     HbAction *addToCollectionAction = mContextMenu->addAction(
       
   306         hbTrId("txt_applib_menu_add_to_collection"));
       
   307     addToCollectionAction->setData(AddToCollectionContextAction);
       
   308 
       
   309     HbAction *uninstallAction = mContextMenu->addAction(
       
   310         hbTrId("txt_common_menu_delete"));
       
   311     uninstallAction->setData(UninstallContextAction);
       
   312     HbAction *appSettingsAction(NULL);
       
   313     HbAction *appDetailsAction(NULL);
       
   314 
       
   315     // check conditions and hide irrelevant menu items
       
   316     QSharedPointer<const CaEntry> entry = mModel->entry(item->modelIndex());
       
   317 
       
   318     if (!(entry->attribute(appSettingsPlugin()).isEmpty())) {
       
   319         appSettingsAction = mContextMenu->addAction(
       
   320             hbTrId("txt_common_menu_settings"));
       
   321         appSettingsAction->setData(AppSettingContextAction);
       
   322     }
       
   323     if (!(entry->attribute(componentIdAttributeName()).isEmpty()) &&
       
   324             (flags & RemovableEntryFlag) ) {
       
   325         appDetailsAction = mContextMenu->addAction(
       
   326             hbTrId("txt_common_menu_details"));
       
   327         appDetailsAction->setData(AppDetailsContextAction);
       
   328     }
       
   329 
       
   330     if (!(flags & RemovableEntryFlag)) {
       
   331         uninstallAction->setVisible(false);
       
   332     }
   511 }
   333 }
   512 
   334 
   513 /*!
   335 /*!
   514   Menu ascending sort action slot.
   336   Menu ascending sort action slot.
   515  */
   337  */
   516 void HsAllAppsState::ascendingMenuAction()
   338 void HsAllAppsState::ascendingMenuAction()
   517 {
   339 {
   518     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::ascendingMenuAction");
   340     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::ascendingMenuAction");
   519     mSortAttribute = AscendingNameHsSortAttribute;
   341     mSortAttribute = AscendingNameHsSortAttribute;
   520     mAllAppsModel->setSort(mSortAttribute);
   342     mModel->setSort(mSortAttribute);
   521     HSMENUTEST_FUNC_EXIT("HsAllAppsState::ascendingMenuAction");
   343     HSMENUTEST_FUNC_EXIT("HsAllAppsState::ascendingMenuAction");
   522 }
       
   523 
       
   524 /*!
       
   525  Sets collections sort order
       
   526  /param sortOrder sort order.
       
   527  */
       
   528 void HsAllAppsState::collectionsSortOrder(
       
   529     HsSortAttribute sortOrder)
       
   530 {
       
   531     mCollectionsSortAttribute = sortOrder;
       
   532 }
   344 }
   533 
   345 
   534 /*!
   346 /*!
   535  Menu descending sort action slot.
   347  Menu descending sort action slot.
   536  */
   348  */
   537 void HsAllAppsState::descendingMenuAction()
   349 void HsAllAppsState::descendingMenuAction()
   538 {
   350 {
   539     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::descendingMenuAction");
   351     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::descendingMenuAction");
   540     mSortAttribute = DescendingNameHsSortAttribute;
   352     mSortAttribute = DescendingNameHsSortAttribute;
   541     mAllAppsModel->setSort(mSortAttribute);
   353     mModel->setSort(mSortAttribute);
   542     HSMENUTEST_FUNC_EXIT("HsAllAppsState::descendingMenuAction");
   354     HSMENUTEST_FUNC_EXIT("HsAllAppsState::descendingMenuAction");
   543 
   355 
   544 }
   356 }