homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuitemmodel.cpp
changeset 77 4b195f3bea29
parent 61 2b1b11a301d2
child 85 35368b604b28
--- a/homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuitemmodel.cpp	Tue Jul 06 14:06:53 2010 +0300
+++ b/homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuitemmodel.cpp	Wed Aug 18 09:40:07 2010 +0300
@@ -16,9 +16,12 @@
  */
 
 #include <hbnamespace.h>
+#include <cauninstallnotifier.h>
+#include <casoftwareregistry.h>
 
 #include "hsmenuitemmodel.h"
 #include "hsmenuserviceutils.h"
+#include "hsiconsidleloader.h"
 
 // Constants
 const QSize smallIconSize(55, 55);
@@ -29,9 +32,15 @@
  \param pointer to parent object
  */
 HsMenuItemModel::HsMenuItemModel(const CaQuery &query, QObject *parent) :
-    CaItemModel(query, parent)
+    CaItemModel(query, parent),
+    mIconsIdleLoader(NULL)
 {
     setIconSize(smallIconSize);
+    mComponentId = 0;
+    mUninstallNotifier = 
+        CaSoftwareRegistry::create()->createUninstallNotifier();
+    connect(mUninstallNotifier, SIGNAL(progressChange(int, int)),
+            this, SLOT(uninstallChange(int, int)));
 }
 
 /*!
@@ -39,7 +48,9 @@
  */
 HsMenuItemModel::~HsMenuItemModel()
 {
-
+    if (!mIds.isEmpty()) {
+        mIds.clear();
+    }
 }
 
 /*!
@@ -77,9 +88,9 @@
     } else if (role == Hb::IndexFeedbackRole){
         QVariant display = CaItemModel::data(index, Qt::DisplayRole);
         if (display.type() == QVariant::String){
-            variant = display;
+            variant = QVariant(display.toString().at(0).toUpper());;
         } else {
-            variant = QVariant(display.toList().at(0));
+            variant = QVariant(display.toList().at(0).toString().at(0).toUpper());
         }
     } else {
         variant = CaItemModel::data(index, role);
@@ -106,3 +117,35 @@
     HSMENUTEST_FUNC_EXIT("HsMenuItemModel::newIconNeeded");
     return result;
 }
+
+/*!
+ Updating uninstall progress with value for each item
+  \param componentId Component Id of installed item
+  \param valueOfProgress % value of current progress
+ */
+void HsMenuItemModel::uninstallChange(int componentId, int valueOfProgress)
+{
+    if (componentId!=mComponentId) {
+        if (!mIds.isEmpty()) {
+            mIds.clear();
+        }
+        // get items list with same componentID
+        mIds = CaItemModel::getUninstallingEntriesIds(componentId);
+        mComponentId = componentId;
+    }
+    // update each item with progress value
+    foreach (int id, mIds) {
+        CaItemModel::updateProgress(id, valueOfProgress);
+    }
+}
+
+
+/*!
+ Start preloading icons if idle
+ \param entry entry representing an item
+ \retval void
+ */
+void HsMenuItemModel::preloadIcons()
+{
+    mIconsIdleLoader = new HsIconsIdleLoader(this, this);
+}