130 void HsInstalledAppsState::stateEntered() |
130 void HsInstalledAppsState::stateEntered() |
131 { |
131 { |
132 qDebug("AllAppsState::stateEntered()"); |
132 qDebug("AllAppsState::stateEntered()"); |
133 HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::stateEntered"); |
133 HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::stateEntered"); |
134 |
134 |
135 HsBaseViewState::stateEntered(); |
135 mMenuView->viewLabel()->setHeading( |
136 setMenuOptions(); |
136 hbTrId("txt_applib_subtitle_installed")); |
|
137 |
137 if (!mModel) { |
138 if (!mModel) { |
138 mModel |
139 mModel |
139 = HsMenuService::getInstalledModel(AscendingNameHsSortAttribute); |
140 = HsMenuService::getInstalledModel(AscendingNameHsSortAttribute); |
|
141 } |
|
142 |
|
143 if (mModel->rowCount() == 0) { |
|
144 mMenuView->reset(HsEmptyLabelContext); |
|
145 } |
|
146 else { |
|
147 mMenuView->reset(HsItemViewContext); |
140 mMenuView->setModel(mModel); |
148 mMenuView->setModel(mModel); |
141 } |
149 mMenuView->listView()->scrollTo( |
142 |
150 mModel->index(0)); |
143 if (mModel->rowCount() == 0){ |
151 } |
144 mMenuView->setContext(HsInstalledAppsContext,HsEmptyLabelContext); |
152 setMenuOptions(); |
145 } |
|
146 |
|
147 mMenuView->listView()->scrollTo( |
|
148 mModel->index(0)); |
|
149 |
|
150 connect(mMenuView.data(), |
153 connect(mMenuView.data(), |
151 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), |
154 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), |
152 SLOT(showContextMenu(HbAbstractViewItem *, QPointF))); |
155 SLOT(showContextMenu(HbAbstractViewItem *, QPointF))); |
153 |
156 |
154 connect(mModel, SIGNAL(empty(bool)),this, |
157 connect(mModel, SIGNAL(empty(bool)),this, |
155 SLOT(setEmptyLabelVisibility(bool))); |
158 SLOT(setEmptyLabelVisibility(bool))); |
156 |
159 |
|
160 HsBaseViewState::stateEntered(); |
|
161 |
157 HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateEntered"); |
162 HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateEntered"); |
158 } |
163 } |
159 |
164 |
160 /*! |
165 /*! |
161 Slot invoked when a state is exited. |
166 Slot invoked when a state is exited. |
170 disconnect(mMenuView.data(), |
175 disconnect(mMenuView.data(), |
171 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), this, |
176 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), this, |
172 SLOT(showContextMenu(HbAbstractViewItem *, QPointF))); |
177 SLOT(showContextMenu(HbAbstractViewItem *, QPointF))); |
173 |
178 |
174 HsBaseViewState::stateExited(); |
179 HsBaseViewState::stateExited(); |
175 |
180 |
176 HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateExited"); |
181 HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateExited"); |
177 qDebug("AllAppsState::stateExited()"); |
182 qDebug("AllAppsState::stateExited()"); |
178 } |
183 } |
179 |
184 |
180 /*! |
185 /*! |
182 \param visibility indicates whether show or not to show 'empty' label. |
187 \param visibility indicates whether show or not to show 'empty' label. |
183 */ |
188 */ |
184 void HsInstalledAppsState::setEmptyLabelVisibility(bool visibility) |
189 void HsInstalledAppsState::setEmptyLabelVisibility(bool visibility) |
185 { |
190 { |
186 if(visibility){ |
191 if(visibility){ |
187 mMenuView->setContext(HsInstalledAppsContext,HsEmptyLabelContext); |
192 mMenuView->reset(HsEmptyLabelContext); |
188 } else { |
193 } else { |
189 mMenuView->setContext(HsInstalledAppsContext,HsItemViewContext); |
194 mMenuView->reset(HsItemViewContext); |
190 } |
195 mMenuView->setModel(mModel); |
|
196 } |
|
197 mMenuView->activate(); |
191 } |
198 } |
192 |
199 |
193 /*! |
200 /*! |
194 Open installation log. |
201 Open installation log. |
195 */ |
202 */ |
202 /*! |
209 /*! |
203 Handles context menu actions. |
210 Handles context menu actions. |
204 \param action to handle. |
211 \param action to handle. |
205 */ |
212 */ |
206 void HsInstalledAppsState::contextMenuAction(HbAction *action) |
213 void HsInstalledAppsState::contextMenuAction(HbAction *action) |
207 { |
214 { |
208 HsContextAction command = |
215 HsContextAction command = |
209 static_cast<HsContextAction>(action->data().toInt()); |
216 static_cast<HsContextAction>(action->data().toInt()); |
210 |
217 |
211 const int itemId = mContextModelIndex.data(CaItemModel::IdRole).toInt(); |
218 const int itemId = mContextModelIndex.data(CaItemModel::IdRole).toInt(); |
212 |
219 |
213 switch (command) { |
220 switch (command) { |
214 case UninstallContextAction: |
221 case UninstallContextAction: |
215 machine()->postEvent( |
222 machine()->postEvent( |
216 HsMenuEventFactory::createUninstallApplicationEvent( |
223 HsMenuEventFactory::createUninstallApplicationEvent( |
217 itemId)); |
224 itemId)); |
218 break; |
225 break; |
219 case AppDetailsContextAction: |
226 case AppDetailsContextAction: |
220 machine()->postEvent( |
227 machine()->postEvent( |
221 HsMenuEventFactory::createAppDetailsViewEvent(itemId)); |
228 HsMenuEventFactory::createAppDetailsViewEvent(itemId)); |
222 break; |
229 break; |
223 default: |
230 default: |
224 break; |
231 break; |
225 } |
232 } |
226 mMenuView->setSearchPanelVisible(false); |
233 mMenuView->hideSearchPanel(); |
227 } |
234 } |