138 Constructs contained objects. |
139 Constructs contained objects. |
139 */ |
140 */ |
140 void HsCollectionState::construct() |
141 void HsCollectionState::construct() |
141 { |
142 { |
142 HSMENUTEST_FUNC_ENTRY("HsCollectionState::construct"); |
143 HSMENUTEST_FUNC_ENTRY("HsCollectionState::construct"); |
|
144 |
143 const QString parentName = |
145 const QString parentName = |
144 parent() != 0 ? parent()->objectName() : QString(""); |
146 parent() != 0 ? parent()->objectName() : QString(""); |
145 setObjectName(parentName + "/collectionstate"); |
147 setObjectName(parentName + "/collectionstate"); |
146 |
148 |
147 |
|
148 connect(this, SIGNAL(entered()),SLOT(stateEntered())); |
149 connect(this, SIGNAL(entered()),SLOT(stateEntered())); |
149 connect(this, SIGNAL(exited()),SLOT(stateExited())); |
150 connect(this, SIGNAL(exited()),SLOT(stateExited())); |
150 |
151 |
151 makeConnect(); |
152 makeConnect(); |
152 mMenuView.view()-> |
153 mMenuView.view()->setNavigationAction(mSecondarySoftkeyAction); |
153 setNavigationAction(mSecondarySoftkeyAction); |
|
154 |
154 |
155 HSMENUTEST_FUNC_EXIT("HsCollectionState::construct"); |
155 HSMENUTEST_FUNC_EXIT("HsCollectionState::construct"); |
156 } |
156 } |
157 |
157 |
158 /*! |
158 /*! |
205 mCollectionModel = |
205 mCollectionModel = |
206 HsMenuService::getCollectionModel( |
206 HsMenuService::getCollectionModel( |
207 mCollectionId, mSortAttribute, mCollectionType); |
207 mCollectionId, mSortAttribute, mCollectionType); |
208 } |
208 } |
209 |
209 |
|
210 EntryFlags flags = |
|
211 mCollectionModel->root().data(CaItemModel::FlagsRole).value< |
|
212 EntryFlags> (); |
|
213 |
|
214 if (mCollectionModel->rowCount() == 0){ |
|
215 if (flags & RemovableEntryFlag){ |
|
216 mMenuView.setContext(HsCollectionContext,HsButtonContext); |
|
217 } else { |
|
218 mMenuView.setContext(HsCollectionContext,HsEmptyLabelContext); |
|
219 } |
|
220 mMenuView.disableSearch(true); |
|
221 } else { |
|
222 mMenuView.setContext(HsCollectionContext,HsItemViewContext); |
|
223 mMenuView.disableSearch(false); |
|
224 } |
|
225 |
210 connect(mCollectionModel, SIGNAL(modelReset()), SLOT(updateLabel())); |
226 connect(mCollectionModel, SIGNAL(modelReset()), SLOT(updateLabel())); |
|
227 connect(mCollectionModel, SIGNAL(empty(bool)),this, |
|
228 SLOT(handleEmptyChange(bool))); |
|
229 connect(mCollectionModel, SIGNAL(empty(bool)),this, |
|
230 SLOT(lockSearchButton(bool))); |
211 |
231 |
212 mMenuView.setModel(mCollectionModel); |
232 mMenuView.setModel(mCollectionModel); |
213 |
233 |
214 mMenuView.listView()->scrollTo( |
234 mMenuView.listView()->scrollTo( |
215 mCollectionModel->index(0), HbAbstractItemView::PositionAtTop); |
235 mCollectionModel->index(0), HbAbstractItemView::PositionAtTop); |
220 if (!mOptions) { |
240 if (!mOptions) { |
221 mOptions = new HbMenu(); |
241 mOptions = new HbMenu(); |
222 mOptions->addAction(hbTrId("txt_applib_opt_task_switcher"), |
242 mOptions->addAction(hbTrId("txt_applib_opt_task_switcher"), |
223 this, |
243 this, |
224 SLOT(openTaskSwitcher())); |
244 SLOT(openTaskSwitcher())); |
225 |
|
226 EntryFlags flags = |
|
227 mCollectionModel->root().data(CaItemModel::FlagsRole).value< |
|
228 EntryFlags> (); |
|
229 |
245 |
230 if (flags & RemovableEntryFlag) { |
246 if (flags & RemovableEntryFlag) { |
231 mOptions->addAction(hbTrId("txt_applib_opt_add_content"), this, |
247 mOptions->addAction(hbTrId("txt_applib_opt_add_content"), this, |
232 SLOT(addAppsAction())); |
248 SLOT(addAppsAction())); |
233 } |
249 } |
278 */ |
294 */ |
279 void HsCollectionState::stateExited() |
295 void HsCollectionState::stateExited() |
280 { |
296 { |
281 HSMENUTEST_FUNC_ENTRY("HsCollectionState::stateExited"); |
297 HSMENUTEST_FUNC_ENTRY("HsCollectionState::stateExited"); |
282 |
298 |
|
299 mMenuView.inactivate(); |
283 mMenuView.setSearchPanelVisible(false); |
300 mMenuView.setSearchPanelVisible(false); |
284 mMenuView.inactivate(); |
301 mMenuView.disableSearch(false); |
|
302 disconnect(mCollectionModel, SIGNAL(empty(bool)),this, |
|
303 SLOT(handleEmptyChange(bool))); |
|
304 |
|
305 disconnect(mCollectionModel, SIGNAL(empty(bool)),this, |
|
306 SLOT(lockSearchButton(bool))); |
|
307 |
285 disconnect(mCollectionModel, SIGNAL(modelReset()), |
308 disconnect(mCollectionModel, SIGNAL(modelReset()), |
286 this, SLOT(updateLabel())); |
309 this, SLOT(updateLabel())); |
287 delete mCollectionModel; |
310 delete mCollectionModel; |
288 mCollectionModel = NULL; |
311 mCollectionModel = NULL; |
289 delete mOptions; |
312 delete mOptions; |
306 SIGNAL(activated(QModelIndex)), |
329 SIGNAL(activated(QModelIndex)), |
307 SLOT(listItemActivated(QModelIndex))); |
330 SLOT(listItemActivated(QModelIndex))); |
308 connect(&mMenuView, |
331 connect(&mMenuView, |
309 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), |
332 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), |
310 SLOT(listItemLongPressed(HbAbstractViewItem *, QPointF))); |
333 SLOT(listItemLongPressed(HbAbstractViewItem *, QPointF))); |
|
334 connect(mMenuView.collectionButton(), |
|
335 SIGNAL(released()), this, SLOT(addAppsAction())); |
|
336 |
311 } |
337 } |
312 |
338 |
313 /*! |
339 /*! |
314 Perform all signal disconnections. |
340 Perform all signal disconnections. |
315 */ |
341 */ |
316 void HsCollectionState::makeDisconnect() |
342 void HsCollectionState::makeDisconnect() |
317 { |
343 { |
|
344 disconnect(mMenuView.collectionButton(), |
|
345 SIGNAL(pressed()), this, SLOT(addAppsAction())); |
|
346 |
318 disconnect(mSecondarySoftkeyAction, SIGNAL(triggered()), |
347 disconnect(mSecondarySoftkeyAction, SIGNAL(triggered()), |
319 this, SLOT(backSteppingAction())); |
348 this, SLOT(backSteppingAction())); |
320 |
349 |
321 disconnect(&mMenuView, |
350 disconnect(&mMenuView, |
322 SIGNAL(activated(QModelIndex)), |
351 SIGNAL(activated(QModelIndex)), |
414 "txt_common_menu_settings")); |
443 "txt_common_menu_settings")); |
415 appSettingsAction->setData(AppSettingContextAction); |
444 appSettingsAction->setData(AppSettingContextAction); |
416 } |
445 } |
417 |
446 |
418 if (!(entry->attribute(componentIdAttributeName()).isEmpty()) && |
447 if (!(entry->attribute(componentIdAttributeName()).isEmpty()) && |
419 entry->entryTypeName() == applicationTypeName() ) { |
448 (flags & RemovableEntryFlag) ) { |
420 appDetailsAction = mContextMenu->addAction(hbTrId( |
449 appDetailsAction = mContextMenu->addAction(hbTrId( |
421 "txt_common_menu_details")); |
450 "txt_common_menu_details")); |
422 appDetailsAction->setData(AppDetailsContextAction); |
451 appDetailsAction->setData(AppDetailsContextAction); |
423 } |
452 } |
424 mContextModelIndex = item->modelIndex(); |
453 mContextModelIndex = item->modelIndex(); |
448 machine()->postEvent( |
477 machine()->postEvent( |
449 HsMenuEventFactory::createAddAppsFromCallectionViewEvent( |
478 HsMenuEventFactory::createAddAppsFromCallectionViewEvent( |
450 mCollectionId, itemId, mCollectionsSortAttribute)); |
479 mCollectionId, itemId, mCollectionsSortAttribute)); |
451 break; |
480 break; |
452 case UninstallContextAction: |
481 case UninstallContextAction: |
453 HsMenuService::executeAction(itemId, removeActionIdentifier()); |
482 machine()->postEvent( |
|
483 HsMenuEventFactory::createUninstallApplicationEvent( |
|
484 itemId)); |
454 break; |
485 break; |
455 case RemoveFromCollectionContextAction: |
486 case RemoveFromCollectionContextAction: |
456 machine()->postEvent( |
487 machine()->postEvent( |
457 HsMenuEventFactory::createRemoveAppFromCollectionEvent( |
488 HsMenuEventFactory::createRemoveAppFromCollectionEvent( |
458 itemId, mCollectionId)); |
489 itemId, mCollectionId)); |
471 |
502 |
472 mMenuView.setSearchPanelVisible(false); |
503 mMenuView.setSearchPanelVisible(false); |
473 } |
504 } |
474 |
505 |
475 /*! |
506 /*! |
|
507 Handles button visibility |
|
508 */ |
|
509 void HsCollectionState::handleEmptyChange(bool empty) |
|
510 { |
|
511 EntryFlags flags = |
|
512 mCollectionModel->root().data(CaItemModel::FlagsRole).value< |
|
513 EntryFlags> (); |
|
514 |
|
515 if (empty){ |
|
516 if (flags & RemovableEntryFlag){ |
|
517 mMenuView.setContext(HsCollectionContext,HsButtonContext); |
|
518 } else { |
|
519 mMenuView.setContext(HsCollectionContext,HsEmptyLabelContext); |
|
520 } |
|
521 } else { |
|
522 mMenuView.setContext(HsCollectionContext,HsItemViewContext); |
|
523 } |
|
524 } |
|
525 |
|
526 |
|
527 /*! |
|
528 Handles lock serch button |
|
529 */ |
|
530 void HsCollectionState::lockSearchButton(bool lock) |
|
531 { |
|
532 mMenuView.disableSearch(lock); |
|
533 } |
|
534 |
|
535 |
|
536 /*! |
476 Menu add applications action slot |
537 Menu add applications action slot |
477 */ |
538 */ |
478 void HsCollectionState::addAppsAction() |
539 void HsCollectionState::addAppsAction() |
479 { |
540 { |
480 // Add applications |
541 // Add applications |