homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallcollectionsstate.cpp
changeset 85 35368b604b28
parent 77 4b195f3bea29
child 96 458d8c8d9580
equal deleted inserted replaced
77:4b195f3bea29 85:35368b604b28
   107 {
   107 {
   108     Q_UNUSED(item)
   108     Q_UNUSED(item)
   109 
   109 
   110     HbAction *openAction = mContextMenu->addAction(hbTrId(
   110     HbAction *openAction = mContextMenu->addAction(hbTrId(
   111         "txt_common_menu_open"));
   111         "txt_common_menu_open"));
   112     openAction->setData(OpenContextAction);
   112     openAction->setData(Hs::OpenCollectionContextAction);
   113 
   113 
   114     // create context menu
   114     // create context menu
   115     HbAction *addShortcutAction = mContextMenu->addAction(hbTrId(
   115     HbAction *addShortcutAction = mContextMenu->addAction(hbTrId(
   116                                       "txt_applib_menu_add_to_home_screen"));
   116                                       "txt_applib_menu_add_to_home_screen"));
   117     addShortcutAction->setData(AddToHomeScreenContextAction);
   117     addShortcutAction->setData(Hs::AddToHomeScreenContextAction);
   118     HbAction *renameAction = NULL;
   118     HbAction *renameAction = NULL;
   119     HbAction *deleteAction = NULL;
   119     HbAction *deleteAction = NULL;
   120 
   120 
   121     if ((flags & RemovableEntryFlag)) {
   121     if ((flags & RemovableEntryFlag)) {
   122         renameAction = mContextMenu->addAction(
   122         renameAction = mContextMenu->addAction(
   123                            hbTrId("txt_common_menu_rename_item"));
   123                            hbTrId("txt_common_menu_rename_item"));
   124         renameAction->setData(RenameContextAction);
   124         renameAction->setData(Hs::RenameCollectionContextAction);
   125         deleteAction = mContextMenu->addAction(hbTrId("txt_common_menu_delete"));
   125         deleteAction = mContextMenu->addAction(hbTrId("txt_common_menu_delete"));
   126         deleteAction->setData(DeleteContextAction);
   126         deleteAction->setData(Hs::DeleteCollectionContextAction);
   127     }
   127     }
   128 }
   128 }
   129 
   129 
   130 /*!
   130 /*!
   131  Destructor.
   131  Destructor.
   167     HSMENUTEST_FUNC_EXIT("HsAllCollectionsState::stateExited");
   167     HSMENUTEST_FUNC_EXIT("HsAllCollectionsState::stateExited");
   168     qDebug("AllCollectionsState::stateExited()");
   168     qDebug("AllCollectionsState::stateExited()");
   169 }
   169 }
   170 
   170 
   171 /*!
   171 /*!
   172  Slot connected to List widget in add mode.
       
   173  \param index Model index of the activated item.
       
   174  */
       
   175 void HsAllCollectionsState::addActivated(const QModelIndex &index)
       
   176 {
       
   177     mMenuView->disconnect(this);
       
   178     const int itemId = index.data(CaItemModel::IdRole).toInt();
       
   179     machine()->postEvent(
       
   180         HsMenuEventFactory::createAddToHomeScreenEvent(
       
   181             itemId, mMenuMode->getHsMenuMode(), mMenuMode->getHsToken()));
       
   182 }
       
   183 
       
   184 /*!
       
   185  Slot connected to List widget in add mode.
       
   186  Called when item long pressed.
       
   187  \param item View item.
       
   188  \param coords Press point coordinates.
       
   189  */
       
   190 void HsAllCollectionsState::addLongPressed(HbAbstractViewItem *item,
       
   191         const QPointF &coords)
       
   192 {
       
   193     Q_UNUSED(coords);
       
   194     mMenuView->disconnect(this);
       
   195     const int itemId = item->modelIndex().data(CaItemModel::IdRole).toInt();
       
   196     machine()->postEvent(
       
   197         HsMenuEventFactory::createAddToHomeScreenEvent(itemId,
       
   198                 mMenuMode->getHsMenuMode(), mMenuMode->getHsToken()));
       
   199 }
       
   200 
       
   201 /*!
       
   202  Handles context menu actions.
       
   203  \param action to be handled.
       
   204  */
       
   205 void HsAllCollectionsState::contextMenuAction(HbAction *action)
       
   206 {
       
   207     HsContextAction command =
       
   208         static_cast<HsContextAction>(action->data().toInt());
       
   209 
       
   210     const int itemId = mContextModelIndex.data(CaItemModel::IdRole).toInt();
       
   211 
       
   212     switch (command) {
       
   213         case AddToHomeScreenContextAction:
       
   214             machine()->postEvent(
       
   215                 HsMenuEventFactory::createAddToHomeScreenEvent(
       
   216                     itemId,
       
   217                     mMenuMode->getHsMenuMode(),
       
   218                     mMenuMode->getHsToken()));
       
   219             break;
       
   220         case RenameContextAction:
       
   221             machine()->postEvent(
       
   222                 HsMenuEventFactory::createRenameCollectionEvent(itemId));
       
   223             break;
       
   224         case DeleteContextAction:
       
   225              machine()->postEvent(
       
   226                 HsMenuEventFactory::createDeleteCollectionEvent(itemId));
       
   227             break;
       
   228         case OpenContextAction:
       
   229             openCollection(mContextModelIndex);
       
   230             break;
       
   231         default:
       
   232             break;
       
   233     }
       
   234 
       
   235     mMenuView->hideSearchPanel();
       
   236 }
       
   237 
       
   238 /*!
       
   239  Slot connected to constructMenu.
   172  Slot connected to constructMenu.
   240  */
   173  */
   241 void HsAllCollectionsState::createNewCollection()
   174 void HsAllCollectionsState::createNewCollection()
   242 {
   175 {
   243     // Adding a new collection via the Collections view
   176     // Adding a new collection via the Collections view