homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallcollectionsstate.cpp
changeset 69 87476091b3f5
parent 63 52b0f64eeb51
child 71 1db7cc813a4e
equal deleted inserted replaced
67:474929a40a0f 69:87476091b3f5
    12  * Contributors:
    12  * Contributors:
    13  *
    13  *
    14  * Description: Menu All Collections state.
    14  * Description: Menu All Collections state.
    15  *
    15  *
    16  */
    16  */
       
    17 #include <QPointF>
    17 #include <QScopedPointer>
    18 #include <QScopedPointer>
    18 #include <QStateMachine>
    19 #include <QStateMachine>
    19 #include <HbView>
    20 #include <HbView>
    20 #include <HbListView>
    21 #include <HbListView>
    21 #include <HbMenu>
    22 #include <HbMenu>
    22 #include <HbAction>
    23 #include <HbAction>
    23 #include <HbAbstractViewItem>
    24 #include <HbAbstractViewItem>
    24 
    25 
    25 #include <cadefs.h>
    26 #include <cadefs.h>
    26 
    27 
       
    28 #include "hsmenumodewrapper.h"
    27 #include "hsmenueventfactory.h"
    29 #include "hsmenueventfactory.h"
    28 #include "hsmenumodewrapper.h"
    30 #include "hsmenumodewrapper.h"
    29 #include "hsmenuitemmodel.h"
    31 #include "hsmenuitemmodel.h"
    30 #include "hsallcollectionsstate.h"
    32 #include "hsallcollectionsstate.h"
    31 #include "hsaddappstocollectionstate.h"
    33 #include "hsaddappstocollectionstate.h"
    32 //#include "hsmenumodetransition.h"
       
    33 #include "hsmainwindow.h"
    34 #include "hsmainwindow.h"
    34 
    35 
    35 /*!
    36 /*!
    36  \class HsAllCollectionsState
    37  \class HsAllCollectionsState
    37  \ingroup group_hsmenustateplugin
    38  \ingroup group_hsmenustateplugin
   105  \param flags related to \a item.
   106  \param flags related to \a item.
   106  */
   107  */
   107 void HsAllCollectionsState::setContextMenuOptions(HbAbstractViewItem *item, EntryFlags flags)
   108 void HsAllCollectionsState::setContextMenuOptions(HbAbstractViewItem *item, EntryFlags flags)
   108 {
   109 {
   109     Q_UNUSED(item)
   110     Q_UNUSED(item)
       
   111 
       
   112     HbAction *openAction = mContextMenu->addAction(hbTrId(
       
   113         "txt_common_menu_open"));
       
   114     openAction->setData(OpenContextAction);
       
   115 
   110     // create context menu
   116     // create context menu
   111     HbAction *addShortcutAction = mContextMenu->addAction(hbTrId(
   117     HbAction *addShortcutAction = mContextMenu->addAction(hbTrId(
   112                                       "txt_applib_menu_add_to_home_screen"));
   118                                       "txt_applib_menu_add_to_home_screen"));
   113     addShortcutAction->setData(AddToHomeScreenContextAction);
   119     addShortcutAction->setData(AddToHomeScreenContextAction);
   114     HbAction *renameAction = NULL;
   120     HbAction *renameAction = NULL;
   198  Handles context menu actions.
   204  Handles context menu actions.
   199  \param action to be handled.
   205  \param action to be handled.
   200  */
   206  */
   201 void HsAllCollectionsState::contextMenuAction(HbAction *action)
   207 void HsAllCollectionsState::contextMenuAction(HbAction *action)
   202 {
   208 {
   203     HsContextAction command = 
   209     HsContextAction command =
   204         static_cast<HsContextAction>(action->data().toInt());
   210         static_cast<HsContextAction>(action->data().toInt());
   205 
   211 
   206     const int itemId = mContextModelIndex.data(CaItemModel::IdRole).toInt();
   212     const int itemId = mContextModelIndex.data(CaItemModel::IdRole).toInt();
   207 
   213 
   208     switch (command) {
   214     switch (command) {
   209         case AddToHomeScreenContextAction:
   215         case AddToHomeScreenContextAction:
   210             machine()->postEvent(
   216             machine()->postEvent(
   211                 HsMenuEventFactory::createAddToHomeScreenEvent(
   217                 HsMenuEventFactory::createAddToHomeScreenEvent(
   212                     itemId, mMenuMode->getHsMenuMode(), mMenuMode->getHsToken()));
   218                     itemId,
       
   219                     mMenuMode->getHsMenuMode(),
       
   220                     mMenuMode->getHsToken()));
   213             break;
   221             break;
   214         case RenameContextAction:
   222         case RenameContextAction:
   215             machine()->postEvent(
   223             machine()->postEvent(
   216                 HsMenuEventFactory::createRenameCollectionEvent(itemId));
   224                 HsMenuEventFactory::createRenameCollectionEvent(itemId));
   217             break;
   225             break;
   218         case DeleteContextAction:
   226         case DeleteContextAction:
   219              machine()->postEvent(
   227              machine()->postEvent(
   220                 HsMenuEventFactory::createDeleteCollectionEvent(itemId));
   228                 HsMenuEventFactory::createDeleteCollectionEvent(itemId));
   221             break;      
   229             break;
       
   230         case OpenContextAction:
       
   231             openCollection(mContextModelIndex);
       
   232             break;
   222         default:
   233         default:
   223             break;
   234             break;
   224     }
   235     }
   225                                     
   236 
   226     mMenuView->setSearchPanelVisible(false);
   237     mMenuView->hideSearchPanel();
   227 }
   238 }
   228 
   239 
   229 /*!
   240 /*!
   230  Slot connected to constructMenu.
   241  Slot connected to constructMenu.
   231  */
   242  */