homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallappsstate.cpp
changeset 60 30f14686fb04
parent 55 03646e8da489
child 61 2b1b11a301d2
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallappsstate.cpp	Fri Jun 11 13:30:16 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallappsstate.cpp	Wed Jun 23 18:03:36 2010 +0300
@@ -293,21 +293,25 @@
     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::listItemActivated");
 
     QSharedPointer<const CaEntry> entry = mAllAppsModel->entry(index);
-
+    
     if (entry->entryTypeName() == widgetTypeName()) {
-        machine()->postEvent(
-            HsMenuEventFactory::createPreviewHSWidgetEvent(
-                entry->id(), entry->entryTypeName(), entry->attribute(
-                    widgetUriAttributeName()), entry->attribute(
-                    widgetLibraryAttributeName())));
+        EntryFlags flags = index.data(CaItemModel::FlagsRole).value<
+                               EntryFlags> ();
+        if (!(flags & UninstallEntryFlag)) {
+            machine()->postEvent(
+                HsMenuEventFactory::createPreviewHSWidgetEvent(
+                    entry->id(), entry->entryTypeName(), entry->attribute(
+                        widgetUriAttributeName()), entry->attribute(
+                        widgetLibraryAttributeName())));
 
-        const int itemId = index.data(CaItemModel::IdRole).toInt();
-        HsMenuService::touch(itemId);
+            const int itemId = index.data(CaItemModel::IdRole).toInt();
+            HsMenuService::touch(itemId);
+        }
     } else {
         QVariant data = mAllAppsModel->data(index, CaItemModel::IdRole);
         HsMenuService::executeAction(data.toInt());
     }
-
+    
     mMenuView.setSearchPanelVisible(false);
 
     HSMENUTEST_FUNC_EXIT("HsAllAppsState::listItemActivated");
@@ -334,50 +338,51 @@
 {
     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::listItemLongPressed");
 
-
-    // create context menu
-    mContextMenu = new HbMenu;
-
-    HbAction *addToHomeScreenAction = mContextMenu->addAction(hbTrId(
-                                          "txt_applib_menu_add_to_home_screen"));
-    addToHomeScreenAction->setData(AddToHomeScreenContextAction);
-
-    HbAction *addToCollectionAction = mContextMenu->addAction(hbTrId(
-                                          "txt_applib_menu_add_to_collection"));
-    addToCollectionAction->setData(AddToCollectionContextAction);
-
-    HbAction *uninstallAction = mContextMenu->addAction(hbTrId(
-                                    "txt_common_menu_delete"));
-    uninstallAction->setData(UninstallContextAction);
-    HbAction *appSettingsAction(NULL);
-    HbAction *appDetailsAction(NULL);
-
-    // check conditions and hide irrelevant menu items
-
-    QSharedPointer<const CaEntry> entry = mAllAppsModel->entry(item->modelIndex());
     EntryFlags flags = item->modelIndex().data(
                            CaItemModel::FlagsRole).value<EntryFlags> ();
 
-    if (!(entry->attribute(appSettingsPlugin()).isEmpty())) {
-        appSettingsAction = mContextMenu->addAction(hbTrId(
-                                                "txt_common_menu_settings"));
-        appSettingsAction->setData(AppSettingContextAction);
+    if (!(flags & UninstallEntryFlag)) {
+        // create context menu
+        mContextMenu = new HbMenu;
+
+        HbAction *addToHomeScreenAction = mContextMenu->addAction(
+            hbTrId("txt_applib_menu_add_to_home_screen"));
+        addToHomeScreenAction->setData(AddToHomeScreenContextAction);
+
+        HbAction *addToCollectionAction = mContextMenu->addAction(
+            hbTrId("txt_applib_menu_add_to_collection"));
+        addToCollectionAction->setData(AddToCollectionContextAction);
+
+        HbAction *uninstallAction = mContextMenu->addAction(
+            hbTrId("txt_common_menu_delete"));
+        uninstallAction->setData(UninstallContextAction);
+        HbAction *appSettingsAction(NULL);
+        HbAction *appDetailsAction(NULL);
+
+        // check conditions and hide irrelevant menu items
+        QSharedPointer<const CaEntry> entry = mAllAppsModel->entry(item->modelIndex());
+
+        if (!(entry->attribute(appSettingsPlugin()).isEmpty())) {
+            appSettingsAction = mContextMenu->addAction(
+                hbTrId("txt_common_menu_settings"));
+            appSettingsAction->setData(AppSettingContextAction);
+        }
+        if (!(entry->attribute(componentIdAttributeName()).isEmpty()) &&
+                (flags & RemovableEntryFlag) ) {
+            appDetailsAction = mContextMenu->addAction(
+                hbTrId("txt_common_menu_details"));
+            appDetailsAction->setData(AppDetailsContextAction);
+        }
+
+        if (!(flags & RemovableEntryFlag)) {
+            uninstallAction->setVisible(false);
+        }
+
+        mContextModelIndex = item->modelIndex();
+        mContextMenu->setPreferredPos(coords);
+        mContextMenu->setAttribute(Qt::WA_DeleteOnClose);
+        mContextMenu->open(this, SLOT(contextMenuAction(HbAction*)));
     }
-    if (!(entry->attribute(componentIdAttributeName()).isEmpty()) && 
-            (flags & RemovableEntryFlag) ) {
-        appDetailsAction = mContextMenu->addAction(hbTrId(
-                                                "txt_common_menu_details"));
-        appDetailsAction->setData(AppDetailsContextAction);
-    }        
-
-    if (!(flags & RemovableEntryFlag)) {
-        uninstallAction->setVisible(false);
-    }
-
-    mContextModelIndex = item->modelIndex();
-    mContextMenu->setPreferredPos(coords);
-    mContextMenu->setAttribute(Qt::WA_DeleteOnClose);
-    mContextMenu->open(this, SLOT(contextMenuAction(HbAction*)));
 
 
     HSMENUTEST_FUNC_EXIT("HsAllAppsState::listItemLongPressed");
@@ -406,8 +411,7 @@
             break;
         case UninstallContextAction:
             machine()->postEvent(
-                HsMenuEventFactory::createUninstallApplicationEvent(
-                    itemId));
+                HsMenuEventFactory::createUninstallApplicationEvent(itemId));
             break;
         case AppSettingContextAction: 
             machine()->postEvent(