homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsapplibrarystate.cpp
changeset 62 341166945d65
parent 51 4785f57bf3d4
child 63 52b0f64eeb51
child 77 4b195f3bea29
equal deleted inserted replaced
57:2e2dc3d30ca8 62:341166945d65
    24 #include <hbsearchpanel.h>
    24 #include <hbsearchpanel.h>
    25 #include <HbToolBarExtension>
    25 #include <HbToolBarExtension>
    26 #include <HbStyleLoader>
    26 #include <HbStyleLoader>
    27 #include <hsmenueventtransition.h>
    27 #include <hsmenueventtransition.h>
    28 
    28 
       
    29 
    29 #include "hstest_global.h"
    30 #include "hstest_global.h"
    30 #include "hsapplibrarystate.h"
    31 #include "hsapplibrarystate.h"
    31 #include "hsallappsstate.h"
    32 #include "hsallappsstate.h"
    32 #include "hsallcollectionsstate.h"
    33 #include "hsallcollectionsstate.h"
    33 #include "hscollectionstate.h"
    34 #include "hscollectionstate.h"
    34 #include "hsinstalledappsstate.h"
    35 #include "hsinstalledappsstate.h"
    35 #include "hsoperatorhandler.h"
    36 #include "hsoperatorhandler.h"
    36 #include "hsmenuview.h"
    37 #include "hsmenuview.h"
    37 #include "hsmenumodetransition.h"
    38 #include "hsmenumodetransition.h"
    38 
    39 
       
    40 
    39 /*!
    41 /*!
    40  \class HsAppLibraryState
    42  \class HsAppLibraryState
    41  \ingroup group_hsmenustateplugin
    43  \ingroup group_hsmenustateplugin
    42  \brief Application Library State.
    44  \brief Application Library State.
    43  Parent state for Application Library functionality
    45  Parent state for Application Library functionality
   118 {
   120 {
   119     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::construct");
   121     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::construct");
   120     setObjectName("homescreen.nokia.com/state/applibrarystate");
   122     setObjectName("homescreen.nokia.com/state/applibrarystate");
   121 
   123 
   122     mAllAppsState = new HsAllAppsState(mMenuViewBuilder, mMenuMode, mMainWindow, this);
   124     mAllAppsState = new HsAllAppsState(mMenuViewBuilder, mMenuMode, mMainWindow, this);
   123     connect(this, SIGNAL(entered()),mAllAppsState, SLOT(scrollToBeginning()));
       
   124 
   125 
   125     mAllCollectionsState = new HsAllCollectionsState(mMenuViewBuilder, mMenuMode,
   126     mAllCollectionsState = new HsAllCollectionsState(mMenuViewBuilder, mMenuMode,
   126             mMainWindow, this);
   127             mMainWindow, this);
   127     connect(this, SIGNAL(entered()),
   128             
   128             mAllCollectionsState, SLOT(scrollToBeginning()));
       
   129 
       
   130     QState *initialState = new QState(this);
   129     QState *initialState = new QState(this);
   131     setInitialState(initialState);
   130     setInitialState(initialState);
   132 
   131 
   133     mHistoryTransaction =  new HsMenuModeTransition(
   132     mHistoryTransaction =  new HsMenuModeTransition(
   134         mMenuMode, NormalHsMenuMode, mAllAppsState);
   133         mMenuMode, NormalHsMenuMode, mAllAppsState);
   141             mMenuMode,
   140             mMenuMode,
   142             mMainWindow,
   141             mMainWindow,
   143             this);
   142             this);
   144 
   143 
   145     connect(mCollectionState, SIGNAL(entered()),SLOT(clearToolbarLatch()));
   144     connect(mCollectionState, SIGNAL(entered()),SLOT(clearToolbarLatch()));
   146 
   145     
   147     HsMenuEventTransition *eventTransition =
   146     HsMenuEventTransition *openCollectionFromAppLibTransition =
   148         new HsMenuEventTransition(HsMenuEvent::OpenCollection,
   147         new HsMenuEventTransition(HsMenuEvent::OpenCollectionFromAppLibrary,
   149                                   this, mCollectionState);
   148                                   this, mCollectionState);
   150     this->addTransition(eventTransition);
   149     this->addTransition(openCollectionFromAppLibTransition);
       
   150     
       
   151     //It is called from: HsDefaultRuntime::activityRequested(const QString &name)
       
   152     HsMenuEventTransition *openCollectionAfterActivityRequest =
       
   153             new HsMenuEventTransition(HsMenuEvent::OpenCollection,
       
   154                                       this, mCollectionState);
       
   155     this->addTransition(openCollectionAfterActivityRequest);
   151 
   156 
   152     HsMenuEventTransition *collectionDeletedTransition =
   157     HsMenuEventTransition *collectionDeletedTransition =
   153         new HsMenuEventTransition(HsMenuEvent::CollectionDeleted,
   158         new HsMenuEventTransition(HsMenuEvent::CollectionDeleted,
   154                                   mCollectionState, mAllCollectionsState);
   159                                   mCollectionState, mAllCollectionsState);
   155     mCollectionState->addTransition(collectionDeletedTransition);
   160     mCollectionState->addTransition(collectionDeletedTransition);
   188     connect(mAllCollectionsState, SIGNAL(toAppLibraryState()),
   193     connect(mAllCollectionsState, SIGNAL(toAppLibraryState()),
   189             this, SIGNAL(toHomescreenState()));
   194             this, SIGNAL(toHomescreenState()));
   190 
   195 
   191     connect(mAllCollectionsState, SIGNAL(entered()),
   196     connect(mAllCollectionsState, SIGNAL(entered()),
   192             this, SLOT(allCollectionsStateEntered()));
   197             this, SLOT(allCollectionsStateEntered()));
   193 
   198   
   194     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::construct");
   199     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::construct");
   195 }
   200 }
   196 
   201 
   197 /*!
   202 /*!
   198  Sets entry event.
   203  Sets entry event.
   202 {
   207 {
   203     qDebug("HsCollectionState::onEntry()");
   208     qDebug("HsCollectionState::onEntry()");
   204     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::onEntry");
   209     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::onEntry");
   205     QState::onEntry(event);
   210     QState::onEntry(event);
   206 
   211 
       
   212     if (static_cast<HsMenuEvent *>(event)->operation() != 
       
   213             HsMenuEvent::OpenCollectionFromAppLibrary)
       
   214         {
       
   215     // we are back from HS, scroll those views to top
       
   216         mAllAppsState->scrollToBeginning();
       
   217         mAllCollectionsState->scrollToBeginning();        
       
   218         }
       
   219     
   207     if (event->type() == HsMenuEvent::eventType()) {
   220     if (event->type() == HsMenuEvent::eventType()) {
   208         HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
   221         HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
   209         QVariantMap data = menuEvent->data();
   222         QVariantMap data = menuEvent->data();
   210         mMenuMode.setHsMenuMode(
   223         mMenuMode.setHsMenuMode(
   211             static_cast<HsMenuMode>(data.value(menuModeType()).toInt()));
   224             static_cast<HsMenuMode>(data.value(menuModeType()).toInt()), 
       
   225             data.value(HOMESCREENDATA));
   212     } else {
   226     } else {
   213         mMenuMode.setHsMenuMode(NormalHsMenuMode);
   227         mMenuMode.setHsMenuMode(NormalHsMenuMode);
   214     }
   228     }
   215 
   229 
   216     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::onEntry");
   230     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::onEntry");
   301 }
   315 }
   302 
   316 
   303 /*!
   317 /*!
   304  Ovi Store Action slot
   318  Ovi Store Action slot
   305 */
   319 */
   306 bool HsAppLibraryState::oviStoreAction()
   320 int HsAppLibraryState::oviStoreAction()
   307 {
   321 {
   308     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::oviStoreAction");
   322     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::oviStoreAction");
       
   323     
   309     CaEntry oviEntry;
   324     CaEntry oviEntry;
   310     oviEntry.setEntryTypeName(urlTypeName());
   325     oviEntry.setEntryTypeName(applicationTypeName());
   311     oviEntry.setAttribute(urlEntryKey(),
   326     oviEntry.setAttribute( applicationUidEntryKey(), 
       
   327                     QString::number(oviLauncherApplicationUid));
       
   328     
       
   329     int result = CaService::instance()->executeCommand(oviEntry);
       
   330     if (result) {
       
   331         oviEntry.setEntryTypeName(urlTypeName());
       
   332         oviEntry.setAttribute(urlEntryKey(),
   312                           QString("https://store.ovi.com/applications/"));
   333                           QString("https://store.ovi.com/applications/"));
   313 
   334         result = CaService::instance()->executeCommand(oviEntry);
   314     bool result = CaService::instance()->executeCommand(oviEntry);
   335     }
       
   336     
   315     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::oviStoreAction");
   337     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::oviStoreAction");
   316     return result;
   338     return result;
   317 }
   339 }
   318 
   340 
   319 /*!
   341 /*!
   334     if (mMenuMode.getHsMenuMode() == NormalHsMenuMode) {
   356     if (mMenuMode.getHsMenuMode() == NormalHsMenuMode) {
   335         mHistoryTransaction->setTargetState(mAllCollectionsState);
   357         mHistoryTransaction->setTargetState(mAllCollectionsState);
   336     }
   358     }
   337 }
   359 }
   338 
   360 
       
   361