homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsapplibrarystate.cpp
changeset 77 4b195f3bea29
parent 61 2b1b11a301d2
child 85 35368b604b28
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsapplibrarystate.cpp	Tue Jul 06 14:06:53 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsapplibrarystate.cpp	Wed Aug 18 09:40:07 2010 +0300
@@ -14,18 +14,11 @@
  * Description: Menu Application Library state.
  *
  */
-#include <hbmainwindow.h>
-#include <hbview.h>
-#include <hbaction.h>
+
+#include <HbAction>
 #include <HbToolBar>
-#include <HbIcon>
-#include <hbinstance.h>
-#include <hblistview.h>
-#include <hbsearchpanel.h>
 #include <HbToolBarExtension>
 #include <HbStyleLoader>
-#include <hsmenueventtransition.h>
-
 
 #include "hstest_global.h"
 #include "hsapplibrarystate.h"
@@ -34,7 +27,7 @@
 #include "hscollectionstate.h"
 #include "hsinstalledappsstate.h"
 #include "hsoperatorhandler.h"
-#include "hsmenuview.h"
+#include "hsmenueventtransition.h"
 #include "hsmenumodetransition.h"
 
 
@@ -125,7 +118,7 @@
 
     mAllCollectionsState = new HsAllCollectionsState(mMenuViewBuilder, mMenuMode,
             mMainWindow, this);
-            
+
     QState *initialState = new QState(this);
     setInitialState(initialState);
 
@@ -142,12 +135,12 @@
             this);
 
     connect(mCollectionState, SIGNAL(entered()),SLOT(clearToolbarLatch()));
-    
+
     HsMenuEventTransition *openCollectionFromAppLibTransition =
         new HsMenuEventTransition(HsMenuEvent::OpenCollectionFromAppLibrary,
                                   this, mCollectionState);
     this->addTransition(openCollectionFromAppLibTransition);
-    
+
     //It is called from: HsDefaultRuntime::activityRequested(const QString &name)
     HsMenuEventTransition *openCollectionAfterActivityRequest =
             new HsMenuEventTransition(HsMenuEvent::OpenCollection,
@@ -180,11 +173,6 @@
 
     constructToolbar();
 
-    connect(mAllCollectionsState, SIGNAL(sortOrderChanged(HsSortAttribute)),
-            mAllAppsState, SLOT(collectionsSortOrder(HsSortAttribute)));
-    connect(mAllCollectionsState, SIGNAL(sortOrderChanged(HsSortAttribute)),
-            mCollectionState, SLOT(collectionsSortOrder(HsSortAttribute)));
-
     connect(mAllAppsState, SIGNAL(entered()),
             this, SLOT(allAppsStateEntered()));
 
@@ -195,7 +183,7 @@
 
     connect(mAllCollectionsState, SIGNAL(entered()),
             this, SLOT(allCollectionsStateEntered()));
-  
+
     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::construct");
 }
 
@@ -209,19 +197,19 @@
     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::onEntry");
     QState::onEntry(event);
 
-    if (static_cast<HsMenuEvent *>(event)->operation() != 
+    if (static_cast<HsMenuEvent *>(event)->operation() !=
             HsMenuEvent::OpenCollectionFromAppLibrary)
         {
     // we are back from HS, scroll those views to top
         mAllAppsState->scrollToBeginning();
-        mAllCollectionsState->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);
@@ -242,16 +230,14 @@
 
     HsOperatorHandler *const operatorHandler = new HsOperatorHandler(this);
 
-    const bool operatorActionAvailable = !operatorHandler->icon().isNull();
-
-    if (operatorActionAvailable) {
+    if (operatorHandler->oviStorePresent()
+            && operatorHandler->operatorStorePresent()) {
 
         //TODO HbToolBarExtension is not supported in docml currently
         //should be changed in future
         bool loaded = HbStyleLoader::registerFilePath(
                      ":/css/hsapplibrarystateplugin.css");
         Q_ASSERT(loaded);
-        HbAction *const operatorAction(mMenuViewBuilder.operatorAction());
 
         HbToolBarExtension *const extension(
             mMenuViewBuilder.toolBarExtension());
@@ -260,25 +246,31 @@
 
         extensionAction->setIcon(HbIcon("qtg_mono_store"));
 
-        operatorAction->setIcon(operatorHandler->icon());
+        HbAction *const operatorAction(
+                operatorHandler->prepareOperatorStoreAction(
+                        mMenuViewBuilder.operatorAction()));
         operatorAction->setText(hbTrId(operatorHandler->text().toLatin1()));
 
         //TODO: no locstring for ovi store currently
         mMenuViewBuilder.oviStoreAction()->setText("Ovi Store");
-
-        connect(mMenuViewBuilder.operatorAction(), SIGNAL(triggered()),
-                operatorHandler, SLOT(action()));
-
-        extension->addAction(mMenuViewBuilder.oviStoreAction());
-        extension->addAction(operatorAction);
-
-    } else {
+        if (operatorHandler->operatorStoreFirst()) {
+            extension->addAction(operatorAction);
+            extension->addAction(mMenuViewBuilder.oviStoreAction());
+        } else {
+            extension->addAction(mMenuViewBuilder.oviStoreAction());
+            extension->addAction(operatorAction);
+        }
+    } else if (operatorHandler->oviStorePresent()) {
         mMenuViewBuilder.toolBar()->addAction(
             mMenuViewBuilder.oviStoreAction());
+    } else if (operatorHandler->operatorStorePresent()) {
+        mMenuViewBuilder.toolBar()->addAction(
+            operatorHandler->prepareOperatorStoreAction(
+                    mMenuViewBuilder.operatorAction()));
     }
 
-
-    HbAction *const allCollectionsAction(mMenuViewBuilder.allCollectionsAction());
+    HbAction *const allCollectionsAction(
+            mMenuViewBuilder.allCollectionsAction());
 
     mAllAppsState->addTransition(
         allCollectionsAction, SIGNAL(triggered()), mAllCollectionsState);
@@ -320,12 +312,12 @@
 int HsAppLibraryState::oviStoreAction()
 {
     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::oviStoreAction");
-    
+
     CaEntry oviEntry;
     oviEntry.setEntryTypeName(applicationTypeName());
-    oviEntry.setAttribute( applicationUidEntryKey(), 
+    oviEntry.setAttribute( applicationUidEntryKey(),
                     QString::number(oviLauncherApplicationUid));
-    
+
     int result = CaService::instance()->executeCommand(oviEntry);
     if (result) {
         oviEntry.setEntryTypeName(urlTypeName());
@@ -333,7 +325,7 @@
                           QString("https://store.ovi.com/applications/"));
         result = CaService::instance()->executeCommand(oviEntry);
     }
-    
+
     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::oviStoreAction");
     return result;
 }