homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsapplibrarystate.cpp
changeset 61 2b1b11a301d2
parent 51 4785f57bf3d4
child 63 52b0f64eeb51
child 77 4b195f3bea29
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsapplibrarystate.cpp	Wed Jun 23 18:03:36 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsapplibrarystate.cpp	Tue Jul 06 14:06:53 2010 +0300
@@ -26,6 +26,7 @@
 #include <HbStyleLoader>
 #include <hsmenueventtransition.h>
 
+
 #include "hstest_global.h"
 #include "hsapplibrarystate.h"
 #include "hsallappsstate.h"
@@ -36,6 +37,7 @@
 #include "hsmenuview.h"
 #include "hsmenumodetransition.h"
 
+
 /*!
  \class HsAppLibraryState
  \ingroup group_hsmenustateplugin
@@ -120,13 +122,10 @@
     setObjectName("homescreen.nokia.com/state/applibrarystate");
 
     mAllAppsState = new HsAllAppsState(mMenuViewBuilder, mMenuMode, mMainWindow, this);
-    connect(this, SIGNAL(entered()),mAllAppsState, SLOT(scrollToBeginning()));
 
     mAllCollectionsState = new HsAllCollectionsState(mMenuViewBuilder, mMenuMode,
             mMainWindow, this);
-    connect(this, SIGNAL(entered()),
-            mAllCollectionsState, SLOT(scrollToBeginning()));
-
+            
     QState *initialState = new QState(this);
     setInitialState(initialState);
 
@@ -143,11 +142,17 @@
             this);
 
     connect(mCollectionState, SIGNAL(entered()),SLOT(clearToolbarLatch()));
-
-    HsMenuEventTransition *eventTransition =
-        new HsMenuEventTransition(HsMenuEvent::OpenCollection,
+    
+    HsMenuEventTransition *openCollectionFromAppLibTransition =
+        new HsMenuEventTransition(HsMenuEvent::OpenCollectionFromAppLibrary,
                                   this, mCollectionState);
-    this->addTransition(eventTransition);
+    this->addTransition(openCollectionFromAppLibTransition);
+    
+    //It is called from: HsDefaultRuntime::activityRequested(const QString &name)
+    HsMenuEventTransition *openCollectionAfterActivityRequest =
+            new HsMenuEventTransition(HsMenuEvent::OpenCollection,
+                                      this, mCollectionState);
+    this->addTransition(openCollectionAfterActivityRequest);
 
     HsMenuEventTransition *collectionDeletedTransition =
         new HsMenuEventTransition(HsMenuEvent::CollectionDeleted,
@@ -190,7 +195,7 @@
 
     connect(mAllCollectionsState, SIGNAL(entered()),
             this, SLOT(allCollectionsStateEntered()));
-
+  
     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::construct");
 }
 
@@ -204,11 +209,20 @@
     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::onEntry");
     QState::onEntry(event);
 
+    if (static_cast<HsMenuEvent *>(event)->operation() != 
+            HsMenuEvent::OpenCollectionFromAppLibrary)
+        {
+    // we are back from HS, scroll those views to top
+        mAllAppsState->scrollToBeginning();
+        mAllCollectionsState->scrollToBeginning();        
+        }
+    
     if (event->type() == HsMenuEvent::eventType()) {
         HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
         QVariantMap data = menuEvent->data();
         mMenuMode.setHsMenuMode(
-            static_cast<HsMenuMode>(data.value(menuModeType()).toInt()));
+            static_cast<HsMenuMode>(data.value(menuModeType()).toInt()), 
+            data.value(HOMESCREENDATA));
     } else {
         mMenuMode.setHsMenuMode(NormalHsMenuMode);
     }
@@ -303,15 +317,23 @@
 /*!
  Ovi Store Action slot
 */
-bool HsAppLibraryState::oviStoreAction()
+int HsAppLibraryState::oviStoreAction()
 {
     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::oviStoreAction");
+    
     CaEntry oviEntry;
-    oviEntry.setEntryTypeName(urlTypeName());
-    oviEntry.setAttribute(urlEntryKey(),
+    oviEntry.setEntryTypeName(applicationTypeName());
+    oviEntry.setAttribute( applicationUidEntryKey(), 
+                    QString::number(oviLauncherApplicationUid));
+    
+    int result = CaService::instance()->executeCommand(oviEntry);
+    if (result) {
+        oviEntry.setEntryTypeName(urlTypeName());
+        oviEntry.setAttribute(urlEntryKey(),
                           QString("https://store.ovi.com/applications/"));
-
-    bool result = CaService::instance()->executeCommand(oviEntry);
+        result = CaService::instance()->executeCommand(oviEntry);
+    }
+    
     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::oviStoreAction");
     return result;
 }
@@ -336,3 +358,4 @@
     }
 }
 
+