homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsapplibrarystate.cpp
changeset 39 4e8ebe173323
parent 36 cdae8c6c3876
child 46 23b5d6a29cce
equal deleted inserted replaced
36:cdae8c6c3876 39:4e8ebe173323
    29 #include "hstest_global.h"
    29 #include "hstest_global.h"
    30 #include "hsapplibrarystate.h"
    30 #include "hsapplibrarystate.h"
    31 #include "hsallappsstate.h"
    31 #include "hsallappsstate.h"
    32 #include "hsallcollectionsstate.h"
    32 #include "hsallcollectionsstate.h"
    33 #include "hscollectionstate.h"
    33 #include "hscollectionstate.h"
       
    34 #include "hsinstalledappsstate.h"
    34 #include "hsovistorehandler.h"
    35 #include "hsovistorehandler.h"
    35 #include "hsmenuview.h"
    36 #include "hsmenuview.h"
    36 #include "hsmenumodetransition.h"
    37 #include "hsmenumodetransition.h"
    37 
    38 
    38 // ---------------------------------------------------------------------------
    39 /*!
    39 // ---------------------------------------------------------------------------
    40  Constructor.
    40 //
    41  \param parent Owner.
       
    42  */
    41 HsAppLibraryState::HsAppLibraryState(QState *parent) :
    43 HsAppLibraryState::HsAppLibraryState(QState *parent) :
    42     QState(parent), mSecondarySoftkeyAction(0), mAllAppsState(0),
    44     QState(parent), mSecondarySoftkeyAction(0), mAllAppsState(0),
    43     mHistoryTransaction(0), mAllCollectionsState(0), mCollectionState(0),
    45     mHistoryTransaction(0), mAllCollectionsState(0), mCollectionState(0)
    44     mMenuView(HbInstance::instance()->allMainWindows().value(0))
       
    45 {
    46 {
    46     construct();
    47     construct();
    47 }
    48 }
    48 
    49 
    49 // ---------------------------------------------------------------------------
    50 /*!
    50 // ---------------------------------------------------------------------------
    51  Destructor.
    51 //
    52  */
    52 HsAppLibraryState::~HsAppLibraryState()
    53 HsAppLibraryState::~HsAppLibraryState()
    53 {
    54 {
    54     HbMainWindow *const hbW =
    55     HbMainWindow *const hbW =
    55         HbInstance::instance()->allMainWindows().value(0);
    56         HbInstance::instance()->allMainWindows().value(0);
    56 
    57 
    58         mMenuView.view()->setNavigationAction(NULL);
    59         mMenuView.view()->setNavigationAction(NULL);
    59         hbW->removeView(mMenuView.view());
    60         hbW->removeView(mMenuView.view());
    60     }
    61     }
    61 }
    62 }
    62 
    63 
    63 // ---------------------------------------------------------------------------
    64 /*!
    64 // ---------------------------------------------------------------------------
    65  Constructs contained objects.
    65 //
    66  */
    66 void HsAppLibraryState::construct()
    67 void HsAppLibraryState::construct()
    67 {
    68 {
    68     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::construct");
    69     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::construct");
    69     setObjectName("homescreen.nokia.com/state/applibrarystate");
    70     setObjectName("homescreen.nokia.com/state/applibrarystate");
    70 
    71 
   104     //transition for returning from collection
   105     //transition for returning from collection
   105     HsMenuEventTransition *collectionToAppLibTransition =
   106     HsMenuEventTransition *collectionToAppLibTransition =
   106         new HsMenuEventTransition(HsMenuEvent::OpenApplicationLibrary,
   107         new HsMenuEventTransition(HsMenuEvent::OpenApplicationLibrary,
   107                                   mCollectionState, mAllCollectionsState);
   108                                   mCollectionState, mAllCollectionsState);
   108     mCollectionState->addTransition(collectionToAppLibTransition);
   109     mCollectionState->addTransition(collectionToAppLibTransition);
       
   110 
       
   111     HsInstalledAppsState *installedAppsState = new HsInstalledAppsState(
       
   112         mMenuView, this);
       
   113 
       
   114     HsMenuEventTransition *installedToAppLibTransition =
       
   115         new HsMenuEventTransition(HsMenuEvent::OpenApplicationLibrary,
       
   116                                   installedAppsState, mAllAppsState);
       
   117     installedAppsState->addTransition(installedToAppLibTransition);
       
   118 
       
   119     HsMenuEventTransition *allViewToInstalledTransition =
       
   120         new HsMenuEventTransition(HsMenuEvent::OpenInstalledView,
       
   121                                   mAllAppsState, installedAppsState);
       
   122     mAllAppsState->addTransition(allViewToInstalledTransition);
   109 
   123 
   110     constructToolbar();
   124     constructToolbar();
   111 
   125 
   112     connect(this, SIGNAL(entered()),SLOT(stateEntered()));
   126     connect(this, SIGNAL(entered()),SLOT(stateEntered()));
   113     connect(this, SIGNAL(exited()),SLOT(stateExited()));
   127     connect(this, SIGNAL(exited()),SLOT(stateExited()));
   122             this, SLOT(allCollectionsStateEntered()));
   136             this, SLOT(allCollectionsStateEntered()));
   123 
   137 
   124     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::construct");
   138     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::construct");
   125 }
   139 }
   126 
   140 
   127 // ---------------------------------------------------------------------------
   141 /*!
   128 // ---------------------------------------------------------------------------
   142  Sets entry event.
   129 //
   143  \param event entry event.
       
   144  */
   130 void HsAppLibraryState::onEntry(QEvent *event)
   145 void HsAppLibraryState::onEntry(QEvent *event)
   131 {
   146 {
   132     qDebug("HsCollectionState::onEntry()");
   147     qDebug("HsCollectionState::onEntry()");
   133     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::onEntry");
   148     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::onEntry");
   134     QState::onEntry(event);
   149     QState::onEntry(event);
   143     }
   158     }
   144 
   159 
   145     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::onEntry");
   160     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::onEntry");
   146 }
   161 }
   147 
   162 
   148 // ---------------------------------------------------------------------------
   163 /*!
   149 // ---------------------------------------------------------------------------
   164  Slot invoked when a state is entered.
   150 //
   165  */
   151 void HsAppLibraryState::stateEntered()
   166 void HsAppLibraryState::stateEntered()
   152 {
   167 {
   153     HSTEST_FUNC_ENTRY("AppLibraryState::stateEntered");
   168     HSTEST_FUNC_ENTRY("AppLibraryState::stateEntered");
   154     HbMainWindow *hbW = HbInstance::instance()->allMainWindows().value(0);
   169     HbMainWindow *hbW = HbInstance::instance()->allMainWindows().value(0);
   155     if (!hbW->views().contains(mMenuView.view())) {
   170     if (!hbW->views().contains(mMenuView.view())) {
   156         hbW->addView(mMenuView.view());
   171         hbW->addView(mMenuView.view());
   157         mMenuView.view()->setNavigationAction(mSecondarySoftkeyAction);
   172         mMenuView.view()->setNavigationAction(mSecondarySoftkeyAction);
   158     }    
   173     }
   159     hbW->setCurrentView(mMenuView.view());
   174     hbW->setCurrentView(mMenuView.view());
   160     HSTEST_FUNC_EXIT("AppLibraryState::stateEntered");
   175     HSTEST_FUNC_EXIT("AppLibraryState::stateEntered");
   161 }
   176 }
   162 
   177 
   163 // ---------------------------------------------------------------------------
   178 /*!
   164 // ---------------------------------------------------------------------------
   179  Slot invoked when a state is exited.
   165 //
   180  */
   166 void HsAppLibraryState::stateExited()
   181 void HsAppLibraryState::stateExited()
   167 {
   182 {
   168     HSTEST_FUNC_ENTRY("AppLibraryState::stateExited");   
   183     HSTEST_FUNC_ENTRY("AppLibraryState::stateExited");
   169     HSTEST_FUNC_EXIT("AppLibraryState::stateExited");
   184     HSTEST_FUNC_EXIT("AppLibraryState::stateExited");
   170 }
   185 }
   171 
   186 
   172 // ---------------------------------------------------------------------------
   187 /*!
   173 // ---------------------------------------------------------------------------
   188  Sets up Toolbar.
   174 //
   189  */
   175 void HsAppLibraryState::constructToolbar()
   190 void HsAppLibraryState::constructToolbar()
   176 {
   191 {
   177     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::constructToolbar");
   192     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::constructToolbar");
   178 
   193 
   179     HsOviStoreHandler *const oviStoreHandler = new HsOviStoreHandler(this);
   194     HsOviStoreHandler *const oviStoreHandler = new HsOviStoreHandler(this);
   203     mAllCollectionsState->assignProperty(
   218     mAllCollectionsState->assignProperty(
   204         allCollectionsAction, "checked", true);
   219         allCollectionsAction, "checked", true);
   205     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::constructToolbar");
   220     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::constructToolbar");
   206 }
   221 }
   207 
   222 
   208 // ---------------------------------------------------------------------------
   223 /*!
   209 // ---------------------------------------------------------------------------
   224  Clear toolbar latch
   210 //
   225 */
   211 void HsAppLibraryState::clearToolbarLatch()
   226 void HsAppLibraryState::clearToolbarLatch()
   212 {
   227 {
   213     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::clearToolbarLatch");
   228     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::clearToolbarLatch");
   214     QAction *const checkedAction =
   229     QAction *const checkedAction =
   215         mMenuView.toolBarActionGroup()->checkedAction();
   230         mMenuView.toolBarActionGroup()->checkedAction();
   218         checkedAction->setChecked(false);
   233         checkedAction->setChecked(false);
   219     }
   234     }
   220     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::clearToolbarLatch");
   235     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::clearToolbarLatch");
   221 }
   236 }
   222 
   237 
   223 // ---------------------------------------------------------------------------
   238 /*!
   224 // ---------------------------------------------------------------------------
   239  All apps stete entered.
   225 //
   240  */
   226 void HsAppLibraryState::allAppsStateEntered()
   241 void HsAppLibraryState::allAppsStateEntered()
   227 {
   242 {
   228     if (mMenuView.getHsMenuMode() == NormalHsMenuMode) {
   243     if (mMenuView.getHsMenuMode() == NormalHsMenuMode) {
   229         mHistoryTransaction->setTargetState(mAllAppsState);
   244         mHistoryTransaction->setTargetState(mAllAppsState);
   230     }
   245     }
   231 }
   246 }
   232 
   247 
   233 // ---------------------------------------------------------------------------
   248 /*!
   234 // ---------------------------------------------------------------------------
   249  All collections state entered.
   235 //
   250  */
   236 void HsAppLibraryState::allCollectionsStateEntered()
   251 void HsAppLibraryState::allCollectionsStateEntered()
   237 {
   252 {
   238     if (mMenuView.getHsMenuMode() == NormalHsMenuMode) {
   253     if (mMenuView.getHsMenuMode() == NormalHsMenuMode) {
   239         mHistoryTransaction->setTargetState(mAllCollectionsState);
   254         mHistoryTransaction->setTargetState(mAllCollectionsState);
   240     }
   255     }