homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallappsstate.cpp
changeset 71 1db7cc813a4e
parent 69 87476091b3f5
child 81 7dd137878ff8
equal deleted inserted replaced
69:87476091b3f5 71:1db7cc813a4e
    34 #include "hsmenuitemmodel.h"
    34 #include "hsmenuitemmodel.h"
    35 #include "hsallappsstate.h"
    35 #include "hsallappsstate.h"
    36 #include "hsmenumodewrapper.h"
    36 #include "hsmenumodewrapper.h"
    37 #include "hsmenuviewbuilder.h"
    37 #include "hsmenuviewbuilder.h"
    38 #include "hsmainwindow.h"
    38 #include "hsmainwindow.h"
       
    39 #include "hsaddmodeproxymodel.h"
       
    40 #include "hsapplibstateutils.h"
    39 
    41 
    40 /*!
    42 /*!
    41  \class HsAllAppsState
    43  \class HsAllAppsState
    42  \ingroup group_hsmenustateplugin
    44  \ingroup group_hsmenustateplugin
    43  \brief All Applications State.
    45  \brief All Applications State.
    61 HsAllAppsState::HsAllAppsState(HsMenuViewBuilder &menuViewBuilder,
    63 HsAllAppsState::HsAllAppsState(HsMenuViewBuilder &menuViewBuilder,
    62                                HsMenuModeWrapper &menuMode,
    64                                HsMenuModeWrapper &menuMode,
    63                                HsMainWindow &mainWindow,
    65                                HsMainWindow &mainWindow,
    64                                QState *parent) :
    66                                QState *parent) :
    65     HsBaseViewState(mainWindow, menuMode, parent),
    67     HsBaseViewState(mainWindow, menuMode, parent),
       
    68     mAddModeProxyModel(0),
    66     mSortAttribute(AscendingNameHsSortAttribute)
    69     mSortAttribute(AscendingNameHsSortAttribute)
    67 {
    70 {
    68     initialize(menuViewBuilder, HsAllAppsContext);
    71     initialize(menuViewBuilder, HsAllAppsContext);
    69     construct();
    72     construct();
       
    73 	mAddModeProxyModel = new HsAddModeProxyModel(this);
       
    74     mAddModeProxyModel->setSourceModel(mModel);
    70 }
    75 }
    71 
    76 
    72 /*!
    77 /*!
    73  Constructs contained objects.
    78  Constructs contained objects.
    74  */
    79  */
    84 
    89 
    85     connect(mBackKeyAction, SIGNAL(triggered()), SIGNAL(toAppLibraryState()));
    90     connect(mBackKeyAction, SIGNAL(triggered()), SIGNAL(toAppLibraryState()));
    86 
    91 
    87     mModel = HsMenuService::getAllApplicationsModel(mSortAttribute);
    92     mModel = HsMenuService::getAllApplicationsModel(mSortAttribute);
    88     mMenuView->setModel(mModel);
    93     mMenuView->setModel(mModel);
       
    94 
       
    95     mModel->preloadIcons();
    89 
    96 
    90     mMenuView->listView()->verticalScrollBar()->setInteractive(true);
    97     mMenuView->listView()->verticalScrollBar()->setInteractive(true);
    91     HbIndexFeedback *indexFeedback = new HbIndexFeedback(mMenuView->view());
    98     HbIndexFeedback *indexFeedback = new HbIndexFeedback(mMenuView->view());
    92     indexFeedback->setIndexFeedbackPolicy(HbIndexFeedback::IndexFeedbackSingleCharacter);
    99     indexFeedback->setIndexFeedbackPolicy(HbIndexFeedback::IndexFeedbackSingleCharacter);
    93     indexFeedback->setItemView(mMenuView->listView());
   100     indexFeedback->setItemView(mMenuView->listView());
   100  Creates and installs menu options for the view
   107  Creates and installs menu options for the view
   101  */
   108  */
   102 void HsAllAppsState::setMenuOptions()
   109 void HsAllAppsState::setMenuOptions()
   103 {
   110 {
   104     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::setMenuOptions");
   111     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::setMenuOptions");
   105     QScopedPointer<HbMenu> viewOptions(new HbMenu);
   112     mViewOptions->clearActions();
   106     viewOptions->addAction(hbTrId("txt_applib_opt_task_switcher"),
   113     mViewOptions->addAction(hbTrId("txt_applib_opt_task_switcher"),
   107                            static_cast<HsBaseViewState*>(this), SLOT(openTaskSwitcher()));
   114                            static_cast<HsBaseViewState*>(this), SLOT(openTaskSwitcher()));
   108     viewOptions->addAction(hbTrId("txt_applib_opt_add_to_collection"),
   115     mViewOptions->addAction(hbTrId("txt_applib_opt_add_to_collection"),
   109                            this, SLOT(addToCollection()));
   116                            this, SLOT(addToCollection()));
   110     viewOptions->addAction(hbTrId("txt_applib_opt_check_software_updates"),
   117     mViewOptions->addAction(hbTrId("txt_applib_opt_check_software_updates"),
   111                            static_cast<HsBaseViewState*>(this), SLOT(checkSoftwareUpdates()));
   118                            static_cast<HsBaseViewState*>(this), SLOT(checkSoftwareUpdates()));
   112 
   119 
   113     HbMenu *const sortMenu = viewOptions->addMenu(hbTrId(
   120     HbMenu *const sortMenu = mViewOptions->addMenu(hbTrId(
   114                                  "txt_applib_opt_sort_by"));
   121                                  "txt_applib_opt_sort_by"));
   115     //Grouped options are exclusive by default.
   122     //Grouped options are exclusive by default.
   116     QActionGroup *sortGroup = new QActionGroup(viewOptions.data());
   123     QActionGroup *sortGroup = new QActionGroup(this);
   117 
   124 
   118     sortGroup->addAction(
   125     sortGroup->addAction(
   119         sortMenu->addAction(hbTrId("txt_applib_opt_sub_ascending"),
   126         sortMenu->addAction(hbTrId("txt_applib_opt_sub_ascending"),
   120                             this, SLOT(ascendingMenuAction())));
   127                             this, SLOT(ascendingMenuAction())));
   121     sortGroup->addAction(
   128     sortGroup->addAction(
   122         sortMenu->addAction(hbTrId("txt_applib_opt_sub_descending"),
   129         sortMenu->addAction(hbTrId("txt_applib_opt_sub_descending"),
   123                             this, SLOT(descendingMenuAction())));
   130                             this, SLOT(descendingMenuAction())));
   124 
   131 
   125     viewOptions->addAction(hbTrId("txt_applib_subtitle_installed"),
   132     mViewOptions->addAction(hbTrId("txt_applib_opt_view_installed_applications"),
   126                            this, SLOT(openInstalledView()));
   133                            this, SLOT(openInstalledView()));
   127 
   134 
   128     foreach(QAction *action, sortMenu->actions()) {
   135     foreach(QAction *action, sortMenu->actions()) {
   129         action->setCheckable(true);
   136         action->setCheckable(true);
   130     }
   137     }
   140         break;
   147         break;
   141     }
   148     }
   142     if (currentSortingPosition >= 0) {
   149     if (currentSortingPosition >= 0) {
   143         sortGroup->actions().at(currentSortingPosition)->setChecked(true);
   150         sortGroup->actions().at(currentSortingPosition)->setChecked(true);
   144     }
   151     }
   145     mMenuView->view()->setMenu(viewOptions.take());
       
   146 
   152 
   147     HSMENUTEST_FUNC_EXIT("HsAllAppsState::setMenuOptions");
   153     HSMENUTEST_FUNC_EXIT("HsAllAppsState::setMenuOptions");
   148 }
   154 }
   149 
   155 
   150 /*!
   156 /*!
   155 {
   161 {
   156 }
   162 }
   157 
   163 
   158 
   164 
   159 /*!
   165 /*!
   160  Slot invoked when add mode entered.
   166  Slot invoked when normal mode entered.
   161  */
   167  */
   162 void HsAllAppsState::normalModeEntered()
   168 void HsAllAppsState::normalModeEntered()
   163 {
   169 {
   164     HsBaseViewState::normalModeEntered();
   170     HsBaseViewState::normalModeEntered();
       
   171     if (mMenuView->model() != mModel) {
       
   172         mMenuView->setModel(mModel);
       
   173     }
   165     connect(mMenuView.data(),
   174     connect(mMenuView.data(),
   166             SIGNAL(activated(QModelIndex)),
   175             SIGNAL(activated(QModelIndex)),
   167             static_cast<HsBaseViewState*>(this), SLOT(launchItem(QModelIndex)));
   176             static_cast<HsBaseViewState*>(this), SLOT(launchItem(QModelIndex)));
       
   177 }
       
   178 
       
   179 /*!
       
   180  Slot invoked when add mode entered.
       
   181  */
       
   182 void HsAllAppsState::addModeEntered()
       
   183 {
       
   184     HsBaseViewState::addModeEntered();
       
   185     if (mMenuView->model() != mAddModeProxyModel) {
       
   186         mMenuView->setModel(mAddModeProxyModel);
       
   187     }
   168 }
   188 }
   169 
   189 
   170 /*!
   190 /*!
   171  Slot invoked when a state is exited.
   191  Slot invoked when a state is exited.
   172  */
   192  */
   335     }
   355     }
   336 
   356 
   337     if (!(flags & RemovableEntryFlag)) {
   357     if (!(flags & RemovableEntryFlag)) {
   338         uninstallAction->setVisible(false);
   358         uninstallAction->setVisible(false);
   339     }
   359     }
       
   360 
       
   361     addToHomeScreenAction->setVisible(
       
   362         !HsAppLibStateUtils::isCWRTWidgetOnHomeScreen(entry.data()));
   340 }
   363 }
   341 
   364 
   342 /*!
   365 /*!
   343   Menu ascending sort action slot.
   366   Menu ascending sort action slot.
   344  */
   367  */