64 HsMenuModeWrapper &menuMode, |
64 HsMenuModeWrapper &menuMode, |
65 HsMainWindow &mainWindow, |
65 HsMainWindow &mainWindow, |
66 QState *parent) : |
66 QState *parent) : |
67 HsBaseViewState(mainWindow, menuMode, parent), |
67 HsBaseViewState(mainWindow, menuMode, parent), |
68 mAddModeProxyModel(0), |
68 mAddModeProxyModel(0), |
69 mSortAttribute(Hs::AscendingNameHsSortAttribute) |
69 mSortAttribute(Hs::AscendingNameHsSortAttribute), |
|
70 mAscendingMenuAction(0), |
|
71 mDescendingMenuAction(0) |
70 { |
72 { |
71 initialize(menuViewBuilder, HsAllAppsContext); |
73 initialize(menuViewBuilder, HsAllAppsContext); |
72 construct(); |
74 construct(); |
73 mAddModeProxyModel = new HsAddModeProxyModel(this); |
75 mAddModeProxyModel = new HsAddModeProxyModel(this); |
74 mAddModeProxyModel->setSourceModel(mModel); |
76 mAddModeProxyModel->setSourceModel(mModel); |
115 mViewOptions->addAction(hbTrId("txt_applib_opt_add_to_collection"), |
117 mViewOptions->addAction(hbTrId("txt_applib_opt_add_to_collection"), |
116 this, SLOT(addToCollection())); |
118 this, SLOT(addToCollection())); |
117 mViewOptions->addAction(hbTrId("txt_applib_opt_check_software_updates"), |
119 mViewOptions->addAction(hbTrId("txt_applib_opt_check_software_updates"), |
118 static_cast<HsBaseViewState*>(this), SLOT(checkSoftwareUpdates())); |
120 static_cast<HsBaseViewState*>(this), SLOT(checkSoftwareUpdates())); |
119 |
121 |
120 HbMenu *const sortMenu = mViewOptions->addMenu(hbTrId( |
122 mAscendingMenuAction = |
121 "txt_applib_opt_sort_by")); |
123 mViewOptions->addAction(hbTrId("txt_applib_menu_sort_by_ascending"), |
122 //Grouped options are exclusive by default. |
124 this, SLOT(ascendingMenuAction())); |
123 QActionGroup *sortGroup = new QActionGroup(this); |
125 |
124 |
126 mDescendingMenuAction = |
125 sortGroup->addAction( |
127 mViewOptions->addAction(hbTrId("txt_applib_menu_sort_by_descending"), |
126 sortMenu->addAction(hbTrId("txt_applib_opt_sub_ascending"), |
128 this, SLOT(descendingMenuAction())); |
127 this, SLOT(ascendingMenuAction()))); |
|
128 sortGroup->addAction( |
|
129 sortMenu->addAction(hbTrId("txt_applib_opt_sub_descending"), |
|
130 this, SLOT(descendingMenuAction()))); |
|
131 |
129 |
132 mViewOptions->addAction(hbTrId("txt_applib_opt_view_installed_applications"), |
130 mViewOptions->addAction(hbTrId("txt_applib_opt_view_installed_applications"), |
133 this, SLOT(openInstalledView())); |
131 this, SLOT(openInstalledView())); |
134 |
132 |
135 foreach(QAction *action, sortMenu->actions()) { |
133 if (mSortAttribute == Hs::AscendingNameHsSortAttribute) { |
136 action->setCheckable(true); |
134 mAscendingMenuAction->setVisible(false); |
137 } |
135 } else { |
138 int currentSortingPosition(-1); |
136 mDescendingMenuAction->setVisible(false); |
139 switch (mSortAttribute) { |
|
140 case Hs::AscendingNameHsSortAttribute: |
|
141 currentSortingPosition = 0; |
|
142 break; |
|
143 case Hs::DescendingNameHsSortAttribute: |
|
144 currentSortingPosition = 1; |
|
145 break; |
|
146 default: |
|
147 break; |
|
148 } |
|
149 if (currentSortingPosition >= 0) { |
|
150 sortGroup->actions().at(currentSortingPosition)->setChecked(true); |
|
151 } |
137 } |
152 |
138 |
153 HSMENUTEST_FUNC_EXIT("HsAllAppsState::setMenuOptions"); |
139 HSMENUTEST_FUNC_EXIT("HsAllAppsState::setMenuOptions"); |
154 } |
140 } |
155 |
141 |
297 void HsAllAppsState::ascendingMenuAction() |
283 void HsAllAppsState::ascendingMenuAction() |
298 { |
284 { |
299 HSMENUTEST_FUNC_ENTRY("HsAllAppsState::ascendingMenuAction"); |
285 HSMENUTEST_FUNC_ENTRY("HsAllAppsState::ascendingMenuAction"); |
300 mSortAttribute = Hs::AscendingNameHsSortAttribute; |
286 mSortAttribute = Hs::AscendingNameHsSortAttribute; |
301 mModel->setSort(mSortAttribute); |
287 mModel->setSort(mSortAttribute); |
|
288 mAscendingMenuAction->setVisible(false); |
|
289 mDescendingMenuAction->setVisible(true); |
302 HSMENUTEST_FUNC_EXIT("HsAllAppsState::ascendingMenuAction"); |
290 HSMENUTEST_FUNC_EXIT("HsAllAppsState::ascendingMenuAction"); |
303 } |
291 } |
304 |
292 |
305 /*! |
293 /*! |
306 Menu descending sort action slot. |
294 Menu descending sort action slot. |
308 void HsAllAppsState::descendingMenuAction() |
296 void HsAllAppsState::descendingMenuAction() |
309 { |
297 { |
310 HSMENUTEST_FUNC_ENTRY("HsAllAppsState::descendingMenuAction"); |
298 HSMENUTEST_FUNC_ENTRY("HsAllAppsState::descendingMenuAction"); |
311 mSortAttribute = Hs::DescendingNameHsSortAttribute; |
299 mSortAttribute = Hs::DescendingNameHsSortAttribute; |
312 mModel->setSort(mSortAttribute); |
300 mModel->setSort(mSortAttribute); |
|
301 mAscendingMenuAction->setVisible(true); |
|
302 mDescendingMenuAction->setVisible(false); |
313 HSMENUTEST_FUNC_EXIT("HsAllAppsState::descendingMenuAction"); |
303 HSMENUTEST_FUNC_EXIT("HsAllAppsState::descendingMenuAction"); |
314 |
304 |
315 } |
305 } |