homescreenapp/stateplugins/hsapplibrarystateplugin/src/hscollectionstate.cpp
changeset 36 cdae8c6c3876
parent 35 f9ce957a272c
child 39 4e8ebe173323
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hscollectionstate.cpp	Fri Mar 19 09:27:44 2010 +0200
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hscollectionstate.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -122,6 +122,9 @@
 
     if (!mOptions) {
         mOptions = new HbMenu();
+        mOptions->addAction(hbTrId("txt_applib_opt_task_switcher"),
+                            this,
+                            SLOT(openTaskSwitcher()));
 
         EntryFlags flags =
             mCollectionModel->root().data(CaItemModel::FlagsRole).value<
@@ -170,13 +173,9 @@
         mOptions->setParent(this);
         mMenuView.view()->setMenu(mOptions);
     }
-
-    HbMainWindow *hbMainWindow =
-        HbInstance::instance()->allMainWindows().value(0);
-    // add BackStepping action
-
-    hbMainWindow->addSoftKeyAction(Hb::SecondarySoftKey,
-                                   mSecondarySoftkeyAction);
+    mOldNavigationAction = mMenuView.view()->navigationAction();
+    mMenuView.view()->setNavigationAction(mSecondarySoftkeyAction);
+    
     makeConnect();
     HSMENUTEST_FUNC_EXIT("HsCollectionState::stateEntered");
 }
@@ -194,12 +193,9 @@
     mMenuView.view()->setMenu(NULL);
     mMenuView.setLabelVisible(false);
 
-    HbMainWindow *hbW = HbInstance::instance()->allMainWindows().value(0);
-    if (hbW) {
-        //remove BackStepping action
-        hbW->removeSoftKeyAction(Hb::SecondarySoftKey,
-                                 mSecondarySoftkeyAction);
-    }
+    // revert navigation action
+    mMenuView.view()->setNavigationAction(mOldNavigationAction);
+
     HSMENUTEST_FUNC_EXIT("HsCollectionState::stateExited");
     qDebug("CollectionState::stateExited()");
 }
@@ -236,6 +232,15 @@
                this, SLOT(listItemLongPressed(HbAbstractViewItem *, QPointF)));
 }
 
+/*!
+ Open task switcher.
+ \retval true if operation is successful.
+ */
+bool HsCollectionState::openTaskSwitcher()
+{
+    return HsMenuService::launchTaskSwitcher();
+}
+
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
@@ -386,14 +391,16 @@
 void HsCollectionState::addElementToHomeScreen(const QModelIndex &index)
 {
     const CaEntry *entry = mCollectionModel->entry(index);
+    
+    QMap<QString, QString> attributes = entry->attributes();
 
-    machine()->
-    postEvent(
+    machine()->postEvent(
         HsMenuEventFactory::createAddToHomeScreenEvent(
             entry->id(),
             entry->entryTypeName(),
             entry->attribute(widgetUriAttributeName()),
-            entry->attribute(widgetLibraryAttributeName())));
+            entry->attribute(widgetLibraryAttributeName()),
+            &attributes));
 }
 
 /*!