homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsbaseviewstate.cpp
changeset 71 1db7cc813a4e
parent 69 87476091b3f5
child 81 7dd137878ff8
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsbaseviewstate.cpp	Fri Jul 23 13:47:57 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsbaseviewstate.cpp	Fri Aug 06 13:36:36 2010 +0300
@@ -53,6 +53,7 @@
     mMainWindow(mainWindow)
 {
     mBackKeyAction = new HbAction(Hb::BackNaviAction, this);
+    mViewOptions = new HbMenu;
 }
 
 /*!
@@ -75,6 +76,7 @@
     mMainWindow(mainWindow)
 {
     mBackKeyAction = new HbAction(Hb::BackNaviAction, this);
+    mViewOptions = new HbMenu;
 }
 /*!
  Initialize contained objects.
@@ -87,6 +89,7 @@
 {
     mMenuView.reset(new HsMenuView(menuViewBuilder, stateContext, mMainWindow));
     mMenuView->view()->setNavigationAction(mBackKeyAction);
+    mMenuView->view()->setMenu(mViewOptions);
 
     connect(this, SIGNAL(entered()),SLOT(stateEntered()));
     connect(this, SIGNAL(exited()),SLOT(stateExited()));
@@ -139,7 +142,7 @@
 
     mMenuView->hideSearchPanel();
     mMenuView->disconnect(this);
-    mMenuView->view()->setMenu(NULL);
+
     mMenuView->inactivate();
     if (!mApplicationLaunchFailMessage.isNull()) {
         mApplicationLaunchFailMessage->close();
@@ -153,6 +156,7 @@
  */
 void HsBaseViewState::addModeEntered()
 {
+    mViewOptions = mMenuView->view()->takeMenu();
     connect(mMenuView.data(),
             SIGNAL(activated(QModelIndex)),
             SLOT(addActivated(QModelIndex)));
@@ -162,7 +166,15 @@
 }
 
 /*!
- Slot invoked when add mode entered.
+ Add mode exited.
+ */
+void HsBaseViewState::addModeExited()
+{
+    mMenuView->view()->setMenu(mViewOptions);
+}
+
+/*!
+ Slot invoked when normal mode entered.
  */
 void HsBaseViewState::normalModeEntered()
 {
@@ -182,6 +194,8 @@
 HsBaseViewState::~HsBaseViewState()
 {
     delete mModel;
+	mViewOptions = mMenuView->view()->takeMenu();
+	delete mViewOptions;
 }
 
 /*!
@@ -193,15 +207,12 @@
     HSMENUTEST_FUNC_ENTRY("HsBaseViewState::launchItem");
 
     QSharedPointer<const CaEntry> entry = mModel->entry(index);
-    if (!entry.isNull()) {
+    if (!entry.isNull() && !(entry->flags() & UninstallEntryFlag)) {
         if (entry->entryTypeName() == widgetTypeName()) {
-            EntryFlags flags = entry->flags();
-            if (!(flags & UninstallEntryFlag)) {
-                machine()->postEvent(HsMenuEventFactory::createPreviewHSWidgetEvent(entry->id(),
-                    entry->entryTypeName(), entry->attribute(widgetUriAttributeName()),
-                    entry->attribute(widgetLibraryAttributeName())));
-                HsMenuService::touch(entry->id());
-            }
+            machine()->postEvent(HsMenuEventFactory::createPreviewHSWidgetEvent(entry->id(),
+                entry->entryTypeName(), entry->attribute(widgetUriAttributeName()),
+                entry->attribute(widgetLibraryAttributeName())));
+            HsMenuService::touch(entry->id());
         }
         else {
             int errCode = HsMenuService::executeAction(entry->id());
@@ -320,6 +331,7 @@
 
     QState *addModeState = new QState(this);
     connect(addModeState, SIGNAL(entered()),SLOT(addModeEntered()));
+    connect(addModeState, SIGNAL(exited()),SLOT(addModeExited()));
 
     QState *normalModeState = new QState(this);
     connect(normalModeState, SIGNAL(entered()),SLOT(normalModeEntered()));