homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallappsstate.cpp
changeset 92 6727c5d0afc7
parent 85 35368b604b28
child 96 458d8c8d9580
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallappsstate.cpp	Thu Sep 02 20:17:27 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallappsstate.cpp	Fri Sep 17 08:27:54 2010 +0300
@@ -66,7 +66,9 @@
                                QState *parent) :
     HsBaseViewState(mainWindow, menuMode, parent),
     mAddModeProxyModel(0),
-    mSortAttribute(Hs::AscendingNameHsSortAttribute)
+    mSortAttribute(Hs::AscendingNameHsSortAttribute),
+    mAscendingMenuAction(0),
+    mDescendingMenuAction(0)
 {
     initialize(menuViewBuilder, HsAllAppsContext);
     construct();
@@ -117,37 +119,21 @@
     mViewOptions->addAction(hbTrId("txt_applib_opt_check_software_updates"),
                            static_cast<HsBaseViewState*>(this), SLOT(checkSoftwareUpdates()));
 
-    HbMenu *const sortMenu = mViewOptions->addMenu(hbTrId(
-                                 "txt_applib_opt_sort_by"));
-    //Grouped options are exclusive by default.
-    QActionGroup *sortGroup = new QActionGroup(this);
+    mAscendingMenuAction =
+        mViewOptions->addAction(hbTrId("txt_applib_menu_sort_by_ascending"),
+                            this, SLOT(ascendingMenuAction()));
 
-    sortGroup->addAction(
-        sortMenu->addAction(hbTrId("txt_applib_opt_sub_ascending"),
-                            this, SLOT(ascendingMenuAction())));
-    sortGroup->addAction(
-        sortMenu->addAction(hbTrId("txt_applib_opt_sub_descending"),
-                            this, SLOT(descendingMenuAction())));
+    mDescendingMenuAction =
+        mViewOptions->addAction(hbTrId("txt_applib_menu_sort_by_descending"),
+                            this, SLOT(descendingMenuAction()));
 
     mViewOptions->addAction(hbTrId("txt_applib_opt_view_installed_applications"),
                            this, SLOT(openInstalledView()));
 
-    foreach(QAction *action, sortMenu->actions()) {
-        action->setCheckable(true);
-    }
-    int currentSortingPosition(-1);
-    switch (mSortAttribute) {
-    case Hs::AscendingNameHsSortAttribute:
-        currentSortingPosition = 0;
-        break;
-    case Hs::DescendingNameHsSortAttribute:
-        currentSortingPosition = 1;
-        break;
-    default:
-        break;
-    }
-    if (currentSortingPosition >= 0) {
-        sortGroup->actions().at(currentSortingPosition)->setChecked(true);
+    if (mSortAttribute == Hs::AscendingNameHsSortAttribute) {
+        mAscendingMenuAction->setVisible(false);
+    } else {
+        mDescendingMenuAction->setVisible(false);
     }
 
     HSMENUTEST_FUNC_EXIT("HsAllAppsState::setMenuOptions");
@@ -299,6 +285,8 @@
     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::ascendingMenuAction");
     mSortAttribute = Hs::AscendingNameHsSortAttribute;
     mModel->setSort(mSortAttribute);
+    mAscendingMenuAction->setVisible(false);
+    mDescendingMenuAction->setVisible(true);
     HSMENUTEST_FUNC_EXIT("HsAllAppsState::ascendingMenuAction");
 }
 
@@ -310,6 +298,8 @@
     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::descendingMenuAction");
     mSortAttribute = Hs::DescendingNameHsSortAttribute;
     mModel->setSort(mSortAttribute);
+    mAscendingMenuAction->setVisible(true);
+    mDescendingMenuAction->setVisible(false);
     HSMENUTEST_FUNC_EXIT("HsAllAppsState::descendingMenuAction");
 
 }