119 */ |
119 */ |
120 HsCollectionState::HsCollectionState(HsMenuViewBuilder &menuViewBuilder, |
120 HsCollectionState::HsCollectionState(HsMenuViewBuilder &menuViewBuilder, |
121 HsMenuModeWrapper &menuMode, |
121 HsMenuModeWrapper &menuMode, |
122 HsMainWindow &mainWindow, |
122 HsMainWindow &mainWindow, |
123 QState *parent) : |
123 QState *parent) : |
124 QState(parent), |
124 HsBaseViewState(parent), |
125 mSortAttribute(LatestOnTopHsSortAttribute), |
125 mSortAttribute(LatestOnTopHsSortAttribute), |
126 mCollectionsSortAttribute(CustomHsSortAttribute), |
126 mCollectionsSortAttribute(CustomHsSortAttribute), |
127 mCollectionId(-1), |
127 mCollectionId(-1), |
128 mMenuView(menuViewBuilder, HsCollectionContext), |
128 mMenuView(menuViewBuilder, HsCollectionContext), |
129 mMenuMode(menuMode), |
129 mMenuMode(menuMode), |
307 |
307 |
308 disconnect(mCollectionModel, SIGNAL(modelReset()), |
308 disconnect(mCollectionModel, SIGNAL(modelReset()), |
309 this, SLOT(updateLabel())); |
309 this, SLOT(updateLabel())); |
310 delete mCollectionModel; |
310 delete mCollectionModel; |
311 mCollectionModel = NULL; |
311 mCollectionModel = NULL; |
|
312 mOptions->close(); |
312 delete mOptions; |
313 delete mOptions; |
313 mOptions = NULL; |
314 mOptions = NULL; |
314 if (mContextMenu) |
315 if (mContextMenu) |
315 mContextMenu->close(); |
316 mContextMenu->close(); |
|
317 this->mSortAttribute = NoHsSortAttribute; |
|
318 |
|
319 HsBaseViewState::stateExited(); |
|
320 |
316 HSMENUTEST_FUNC_EXIT("HsCollectionState::stateExited"); |
321 HSMENUTEST_FUNC_EXIT("HsCollectionState::stateExited"); |
317 this->mSortAttribute = NoHsSortAttribute; |
|
318 qDebug("CollectionState::stateExited()"); |
322 qDebug("CollectionState::stateExited()"); |
319 } |
323 } |
320 |
324 |
321 /*! |
325 /*! |
322 Perform all signal connections. |
326 Perform all signal connections. |
330 SLOT(listItemActivated(QModelIndex))); |
334 SLOT(listItemActivated(QModelIndex))); |
331 connect(&mMenuView, |
335 connect(&mMenuView, |
332 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), |
336 SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), |
333 SLOT(listItemLongPressed(HbAbstractViewItem *, QPointF))); |
337 SLOT(listItemLongPressed(HbAbstractViewItem *, QPointF))); |
334 connect(mMenuView.collectionButton(), |
338 connect(mMenuView.collectionButton(), |
335 SIGNAL(released()), this, SLOT(addAppsAction())); |
339 SIGNAL(toggled(bool)), this, SLOT(addAppsAction(bool))); |
336 |
|
337 } |
340 } |
338 |
341 |
339 /*! |
342 /*! |
340 Perform all signal disconnections. |
343 Perform all signal disconnections. |
341 */ |
344 */ |
342 void HsCollectionState::makeDisconnect() |
345 void HsCollectionState::makeDisconnect() |
343 { |
346 { |
344 disconnect(mMenuView.collectionButton(), |
347 disconnect(mMenuView.collectionButton(), |
345 SIGNAL(pressed()), this, SLOT(addAppsAction())); |
348 SIGNAL(toggled(bool)), this, SLOT(addAppsAction(bool))); |
346 |
349 |
347 disconnect(mSecondarySoftkeyAction, SIGNAL(triggered()), |
350 disconnect(mSecondarySoftkeyAction, SIGNAL(triggered()), |
348 this, SLOT(backSteppingAction())); |
351 this, SLOT(backSteppingAction())); |
349 |
352 |
350 disconnect(&mMenuView, |
353 disconnect(&mMenuView, |
374 HSMENUTEST_FUNC_ENTRY("HsCollectionState::listItemActivated"); |
377 HSMENUTEST_FUNC_ENTRY("HsCollectionState::listItemActivated"); |
375 |
378 |
376 QSharedPointer<const CaEntry> entry = mCollectionModel->entry(index); |
379 QSharedPointer<const CaEntry> entry = mCollectionModel->entry(index); |
377 |
380 |
378 if (entry->entryTypeName() == widgetTypeName()) { |
381 if (entry->entryTypeName() == widgetTypeName()) { |
379 machine()->postEvent( |
382 EntryFlags flags = index.data(CaItemModel::FlagsRole).value< |
380 HsMenuEventFactory::createPreviewHSWidgetEvent( |
383 EntryFlags> (); |
381 entry->id(), entry->entryTypeName(), entry->attribute( |
384 if (!(flags & UninstallEntryFlag)) { |
382 widgetUriAttributeName()), entry->attribute( |
385 machine()->postEvent( |
383 widgetLibraryAttributeName()))); |
386 HsMenuEventFactory::createPreviewHSWidgetEvent( |
384 |
387 entry->id(), entry->entryTypeName(), entry->attribute( |
385 const int itemId = index.data(CaItemModel::IdRole).toInt(); |
388 widgetUriAttributeName()), entry->attribute( |
386 HsMenuService::touch(itemId); |
389 widgetLibraryAttributeName()))); |
|
390 |
|
391 const int itemId = index.data(CaItemModel::IdRole).toInt(); |
|
392 HsMenuService::touch(itemId); |
|
393 } |
387 } else { |
394 } else { |
388 QVariant data = mCollectionModel->data(index, CaItemModel::IdRole); |
395 QVariant data = mCollectionModel->data(index, CaItemModel::IdRole); |
389 HsMenuService::executeAction(data.toInt()); |
396 int errCode = HsMenuService::executeAction(data.toInt()); |
|
397 if (errCode != 0) { |
|
398 createApplicationLaunchFailMessage(errCode,index.data(CaItemModel::IdRole).toInt()); |
|
399 } |
390 } |
400 } |
391 |
401 |
392 mMenuView.setSearchPanelVisible(false); |
402 mMenuView.setSearchPanelVisible(false); |
393 HSMENUTEST_FUNC_EXIT("HsCollectionState::listItemActivated"); |
403 HSMENUTEST_FUNC_EXIT("HsCollectionState::listItemActivated"); |
394 } |
404 } |
400 \retval void |
410 \retval void |
401 */ |
411 */ |
402 void HsCollectionState::listItemLongPressed(HbAbstractViewItem *item, |
412 void HsCollectionState::listItemLongPressed(HbAbstractViewItem *item, |
403 const QPointF &coords) |
413 const QPointF &coords) |
404 { |
414 { |
405 Q_UNUSED(item); |
|
406 HSMENUTEST_FUNC_ENTRY("HsCollectionState::listItemLongPressed"); |
415 HSMENUTEST_FUNC_ENTRY("HsCollectionState::listItemLongPressed"); |
407 // create context menu |
|
408 mContextMenu = new HbMenu(); |
|
409 |
|
410 HbAction *addShortcutAction = mContextMenu->addAction(hbTrId( |
|
411 "txt_applib_menu_add_to_home_screen")); |
|
412 addShortcutAction->setData(AddToHomeScreenContextAction); |
|
413 HbAction *addToCollection = mContextMenu->addAction(hbTrId( |
|
414 "txt_applib_menu_add_to_collection")); |
|
415 addToCollection->setData(AddToCollectionContextAction); |
|
416 HbAction *removeAction(NULL); |
|
417 HbAction *uninstallAction(NULL); |
|
418 HbAction *appSettingsAction(NULL); |
|
419 HbAction *appDetailsAction(NULL); |
|
420 // we do not add remove option in locked collection |
|
421 // check conditions and hide irrelevant menu items |
|
422 EntryFlags rootFlags = |
|
423 mCollectionModel->root().data(CaItemModel::FlagsRole).value< |
|
424 EntryFlags> (); |
|
425 |
|
426 if (rootFlags & RemovableEntryFlag) { |
|
427 removeAction = mContextMenu->addAction( |
|
428 hbTrId("txt_applib_menu_remove_from_collection")); |
|
429 removeAction->setData(RemoveFromCollectionContextAction); |
|
430 } |
|
431 |
416 |
432 EntryFlags flags = item->modelIndex().data(CaItemModel::FlagsRole).value< |
417 EntryFlags flags = item->modelIndex().data(CaItemModel::FlagsRole).value< |
433 EntryFlags> (); |
418 EntryFlags> (); |
434 |
419 |
435 if ((flags & RemovableEntryFlag)) { |
420 if (!(flags & UninstallEntryFlag)) { |
436 uninstallAction = mContextMenu->addAction(hbTrId("txt_common_menu_delete")); |
421 // create context menu |
437 uninstallAction->setData(UninstallContextAction); |
422 mContextMenu = new HbMenu(); |
438 } |
423 |
439 QSharedPointer<const CaEntry> entry = mCollectionModel->entry(item->modelIndex()); |
424 HbAction *addShortcutAction = mContextMenu->addAction(hbTrId( |
440 |
425 "txt_applib_menu_add_to_home_screen")); |
441 if (!(entry->attribute(appSettingsPlugin()).isEmpty())) { |
426 addShortcutAction->setData(AddToHomeScreenContextAction); |
442 appSettingsAction = mContextMenu->addAction(hbTrId( |
427 HbAction *addToCollection = mContextMenu->addAction(hbTrId( |
443 "txt_common_menu_settings")); |
428 "txt_applib_menu_add_to_collection")); |
444 appSettingsAction->setData(AppSettingContextAction); |
429 addToCollection->setData(AddToCollectionContextAction); |
445 } |
430 HbAction *removeAction(NULL); |
|
431 HbAction *uninstallAction(NULL); |
|
432 HbAction *appSettingsAction(NULL); |
|
433 HbAction *appDetailsAction(NULL); |
|
434 // we do not add remove option in locked collection |
|
435 // check conditions and hide irrelevant menu items |
|
436 EntryFlags rootFlags = |
|
437 mCollectionModel->root().data(CaItemModel::FlagsRole).value< |
|
438 EntryFlags> (); |
|
439 |
|
440 if (rootFlags & RemovableEntryFlag) { |
|
441 removeAction = mContextMenu->addAction( |
|
442 hbTrId("txt_applib_menu_remove_from_collection")); |
|
443 removeAction->setData(RemoveFromCollectionContextAction); |
|
444 } |
|
445 |
|
446 if ((flags & RemovableEntryFlag)) { |
|
447 uninstallAction = mContextMenu->addAction(hbTrId("txt_common_menu_delete")); |
|
448 uninstallAction->setData(UninstallContextAction); |
|
449 } |
|
450 QSharedPointer<const CaEntry> entry = mCollectionModel->entry(item->modelIndex()); |
|
451 |
|
452 if (!(entry->attribute(appSettingsPlugin()).isEmpty())) { |
|
453 appSettingsAction = mContextMenu->addAction(hbTrId( |
|
454 "txt_common_menu_settings")); |
|
455 appSettingsAction->setData(AppSettingContextAction); |
|
456 } |
446 |
457 |
447 if (!(entry->attribute(componentIdAttributeName()).isEmpty()) && |
458 if (!(entry->attribute(componentIdAttributeName()).isEmpty()) && |
448 (flags & RemovableEntryFlag) ) { |
459 (flags & RemovableEntryFlag) ) { |
449 appDetailsAction = mContextMenu->addAction(hbTrId( |
460 appDetailsAction = mContextMenu->addAction(hbTrId( |
450 "txt_common_menu_details")); |
461 "txt_common_menu_details")); |
451 appDetailsAction->setData(AppDetailsContextAction); |
462 appDetailsAction->setData(AppDetailsContextAction); |
452 } |
463 } |
453 mContextModelIndex = item->modelIndex(); |
464 mContextModelIndex = item->modelIndex(); |
454 mContextMenu->setPreferredPos(coords); |
465 mContextMenu->setPreferredPos(coords); |
455 mContextMenu->setAttribute(Qt::WA_DeleteOnClose); |
466 mContextMenu->setAttribute(Qt::WA_DeleteOnClose); |
456 mContextMenu->open(this, SLOT(contextMenuAction(HbAction*))); |
467 mContextMenu->open(this, SLOT(contextMenuAction(HbAction*))); |
457 |
468 } |
458 |
469 |
459 HSMENUTEST_FUNC_EXIT("HsCollectionState::listItemLongPressed"); |
470 HSMENUTEST_FUNC_EXIT("HsCollectionState::listItemLongPressed"); |
460 } |
471 } |
461 |
472 |
462 /*! |
473 /*! |
524 } |
536 } |
525 |
537 |
526 |
538 |
527 /*! |
539 /*! |
528 Handles lock serch button |
540 Handles lock serch button |
|
541 \param lock if true lock search button |
529 */ |
542 */ |
530 void HsCollectionState::lockSearchButton(bool lock) |
543 void HsCollectionState::lockSearchButton(bool lock) |
531 { |
544 { |
532 mMenuView.disableSearch(lock); |
545 mMenuView.disableSearch(lock); |
533 } |
546 } |
534 |
547 |
535 |
548 |
536 /*! |
549 /*! |
537 Menu add applications action slot |
550 Menu add applications action slot |
538 */ |
551 \param addApps if true create event for add enties to collection. Parametr use by toggled from HbPushButton |
539 void HsCollectionState::addAppsAction() |
552 */ |
|
553 void HsCollectionState::addAppsAction(bool addApps) |
540 { |
554 { |
541 // Add applications |
555 // Add applications |
542 machine()->postEvent( |
556 if (addApps) { |
543 HsMenuEventFactory::createAddAppsFromCallectionViewEvent( |
557 mMenuView.collectionButton()->setChecked(false); |
544 mCollectionId)); |
558 machine()->postEvent( |
|
559 HsMenuEventFactory::createAddAppsFromCallectionViewEvent( |
|
560 mCollectionId)); |
|
561 } |
545 } |
562 } |
546 |
563 |
547 /*! |
564 /*! |
548 Menu add shortcut action slot |
565 Menu add shortcut action slot |
549 */ |
566 */ |
550 void HsCollectionState::addCollectionShortcutToHomeScreenAction() |
567 void HsCollectionState::addCollectionShortcutToHomeScreenAction() |
551 { |
568 { |
552 machine()->postEvent(HsMenuEventFactory::createAddToHomeScreenEvent( |
569 machine()->postEvent(HsMenuEventFactory::createAddToHomeScreenEvent( |
553 mCollectionId, mMenuMode.getHsMenuMode())); |
570 mCollectionId, mMenuMode.getHsMenuMode(), |
|
571 mMenuMode.getHsToken())); |
554 } |
572 } |
555 |
573 |
556 /*! |
574 /*! |
557 Menu rename action slot |
575 Menu rename action slot |
558 */ |
576 */ |