50 */ |
50 */ |
51 HsInstalledAppsState::HsInstalledAppsState(HsMenuViewBuilder &menuViewBuilder, |
51 HsInstalledAppsState::HsInstalledAppsState(HsMenuViewBuilder &menuViewBuilder, |
52 HsMainWindow &mainWindow, |
52 HsMainWindow &mainWindow, |
53 QState *parent): |
53 QState *parent): |
54 HsBaseViewState(mainWindow, parent), |
54 HsBaseViewState(mainWindow, parent), |
55 mSortAttribute(Hs::OldestOnTopHsSortAttribute) |
55 mSortAttribute(Hs::OldestOnTopHsSortAttribute), |
|
56 mLatestOnTopMenuAction(0), |
|
57 mOldestOnTopMenuAction(0) |
56 { |
58 { |
57 initialize(menuViewBuilder, HsInstalledAppsContext); |
59 initialize(menuViewBuilder, HsInstalledAppsContext); |
58 construct(); |
60 construct(); |
59 } |
61 } |
60 |
62 |
86 mViewOptions->addAction(hbTrId("txt_applib_opt_task_switcher"), |
88 mViewOptions->addAction(hbTrId("txt_applib_opt_task_switcher"), |
87 this, SLOT(openTaskSwitcher())); |
89 this, SLOT(openTaskSwitcher())); |
88 mViewOptions->addAction(hbTrId("txt_applib_opt_installation_log"), |
90 mViewOptions->addAction(hbTrId("txt_applib_opt_installation_log"), |
89 this, SLOT(openInstallationLog())); |
91 this, SLOT(openInstallationLog())); |
90 if (mModel->rowCount() > 0) { |
92 if (mModel->rowCount() > 0) { |
91 HbMenu *sortMenu = mViewOptions->addMenu( |
93 |
92 hbTrId("txt_applib_opt_sort_by")); |
94 mLatestOnTopMenuAction = mViewOptions->addAction( |
93 //Grouped options are exclusive by default. |
95 hbTrId("txt_applib_menu_sort_by_latest_on_top"), |
94 QActionGroup *sortGroup = new QActionGroup(this); |
96 this, SLOT(latestOnTopMenuAction())); |
95 sortGroup->addAction( |
97 mOldestOnTopMenuAction = mViewOptions->addAction( |
96 sortMenu->addAction( |
98 hbTrId("txt_applib_menu_sort_by_oldest_on_top"), |
97 hbTrId("txt_applib_opt_sort_by_sub_latest_on_top"), |
99 this, SLOT(oldestOnTopMenuAction())); |
98 this, |
100 |
99 SLOT(latestOnTopMenuAction()))); |
101 // as we geting already reversed list from query |
100 sortGroup->addAction( |
102 // we set it to OldestOnTopHsSortAttribute |
101 sortMenu->addAction( |
|
102 hbTrId("txt_applib_opt_sort_by_sub_oldest_on_top"), |
|
103 this, |
|
104 SLOT(oldestOnTopMenuAction()))); |
|
105 foreach(QAction *action, sortMenu->actions()) { |
|
106 action->setCheckable(true); |
|
107 } |
|
108 static const int defaultSortingPosition = 0; |
|
109 if(mSortAttribute == Hs::LatestOnTopHsSortAttribute) |
103 if(mSortAttribute == Hs::LatestOnTopHsSortAttribute) |
110 { |
104 { |
111 sortGroup->actions().at(defaultSortingPosition + 1)->setChecked(true); |
105 mOldestOnTopMenuAction->setVisible(false); |
112 } |
106 } else { |
113 else { |
107 mLatestOnTopMenuAction->setVisible(false); |
114 sortGroup->actions().at(defaultSortingPosition)->setChecked(true); |
|
115 } |
108 } |
116 } |
109 } |
117 mMenuView->view()->setMenu(mViewOptions); |
110 mMenuView->view()->setMenu(mViewOptions); |
118 HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::setMenuOptions"); |
111 HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::setMenuOptions"); |
119 } |
112 } |
180 setMenuOptions(); |
173 setMenuOptions(); |
181 |
174 |
182 connect(mMenuView.data(), |
175 connect(mMenuView.data(), |
183 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), |
176 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), |
184 SLOT(showContextMenu(HbAbstractViewItem *, QPointF))); |
177 SLOT(showContextMenu(HbAbstractViewItem *, QPointF))); |
|
178 |
|
179 connect(mMenuView.data(), |
|
180 SIGNAL(activated(QModelIndex)), |
|
181 SLOT(launchDetails(QModelIndex))); |
185 |
182 |
186 connect(mModel, SIGNAL(empty(bool)),this, |
183 connect(mModel, SIGNAL(empty(bool)),this, |
187 SLOT(setEmptyLabelVisibility(bool))); |
184 SLOT(setEmptyLabelVisibility(bool))); |
188 |
185 |
189 HsBaseViewState::stateEntered(); |
186 HsBaseViewState::stateEntered(); |
198 { |
195 { |
199 HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::stateExited"); |
196 HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::stateExited"); |
200 |
197 |
201 disconnect(mModel, SIGNAL(empty(bool)),this, |
198 disconnect(mModel, SIGNAL(empty(bool)),this, |
202 SLOT(setEmptyLabelVisibility(bool))); |
199 SLOT(setEmptyLabelVisibility(bool))); |
|
200 |
|
201 disconnect(mMenuView.data(), |
|
202 SIGNAL(activated(QModelIndex)), this, |
|
203 SLOT(launchDetails(QModelIndex))); |
203 |
204 |
204 disconnect(mMenuView.data(), |
205 disconnect(mMenuView.data(), |
205 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), this, |
206 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), this, |
206 SLOT(showContextMenu(HbAbstractViewItem *, QPointF))); |
207 SLOT(showContextMenu(HbAbstractViewItem *, QPointF))); |
207 |
208 |
234 { |
235 { |
235 machine()->postEvent( |
236 machine()->postEvent( |
236 HsMenuEventFactory::createInstallationLogEvent()); |
237 HsMenuEventFactory::createInstallationLogEvent()); |
237 } |
238 } |
238 |
239 |
|
240 #ifdef COVERAGE_MEASUREMENT |
|
241 #pragma CTC SKIP |
|
242 #endif //COVERAGE_MEASUREMENT |
|
243 |
|
244 // calls tested factory method |
|
245 |
|
246 /*! |
|
247 Launches detail for app under index |
|
248 */ |
|
249 void HsInstalledAppsState::launchDetails(const QModelIndex &index) |
|
250 { |
|
251 machine()->postEvent(HsMenuEventFactory::createAppDetailsViewEvent( |
|
252 index.data(CaItemModel::IdRole).toInt())); |
|
253 } |
|
254 |
|
255 #ifdef COVERAGE_MEASUREMENT |
|
256 #pragma CTC ENDSKIP |
|
257 #endif //COVERAGE_MEASUREMENT |
239 /*! |
258 /*! |
240 A Slot called when an action for sorting (latest |
259 A Slot called when an action for sorting (latest |
241 on top) is invoked for Installed. |
260 on top) is invoked for Installed. |
242 */ |
261 */ |
243 void HsInstalledAppsState::latestOnTopMenuAction() |
262 void HsInstalledAppsState::latestOnTopMenuAction() |
244 { |
263 { |
245 // as we geting already reversed list from query |
264 // as we geting already reversed list from query |
246 // we set it to OldestOnTopHsSortAttribute |
265 // we set it to OldestOnTopHsSortAttribute |
247 mSortAttribute = Hs::OldestOnTopHsSortAttribute; |
266 mSortAttribute = Hs::OldestOnTopHsSortAttribute; |
248 mModel->setSort(mSortAttribute); |
267 mModel->setSort(mSortAttribute); |
|
268 mLatestOnTopMenuAction->setVisible(false); |
|
269 mOldestOnTopMenuAction->setVisible(true); |
249 } |
270 } |
250 |
271 |
251 /*! |
272 /*! |
252 A Slot called when an action for sorting (oldest |
273 A Slot called when an action for sorting (oldest |
253 on top) is invoked for Installed. |
274 on top) is invoked for Installed. |
256 { |
277 { |
257 // as we geting already reversed list from query |
278 // as we geting already reversed list from query |
258 // we set it to LatestOnTopHsSortAttribute |
279 // we set it to LatestOnTopHsSortAttribute |
259 mSortAttribute = Hs::LatestOnTopHsSortAttribute; |
280 mSortAttribute = Hs::LatestOnTopHsSortAttribute; |
260 mModel->setSort(mSortAttribute); |
281 mModel->setSort(mSortAttribute); |
261 } |
282 mLatestOnTopMenuAction->setVisible(true); |
|
283 mOldestOnTopMenuAction->setVisible(false); |
|
284 } |