homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuservice.cpp
changeset 51 4785f57bf3d4
parent 39 4e8ebe173323
child 60 30f14686fb04
child 62 341166945d65
--- a/homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuservice.cpp	Fri May 14 15:43:04 2010 +0300
+++ b/homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuservice.cpp	Thu May 27 12:46:08 2010 +0300
@@ -126,6 +126,9 @@
     } else {
         query.setFlagsOn(VisibleEntryFlag);
     }
+    if(!collectionId) {
+        collectionId = collectionIdByType(collectionType);
+    }
     query.setParentId(collectionId);
     query.setSort(HsMenuServiceUtils::sortBy(sortAttribute),
                   HsMenuServiceUtils::sortOrder(sortAttribute));
@@ -347,6 +350,33 @@
 }
 
 /*!
+ Retrives the first found collection entry id
+ \param collectionType collection type.
+ \retval collectionType id
+ */
+int HsMenuService::collectionIdByType(const QString& collectionType)
+{
+    HSMENUTEST_FUNC_ENTRY("HsMenuService::collectionsIdByType");
+    int collectionId;
+    CaQuery collectionsQuery;
+    collectionsQuery.setEntryRoles(GroupEntryRole);
+    //sorting is set to (default, ascending) to assure that
+    //proper entry is fetched, somebody can add item with
+    //"menucollections" typename to the storage, but even if he or she
+    //do this we fetch entry that we wanted
+    collectionsQuery.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+    collectionsQuery.addEntryTypeName(collectionType);
+    QList<int> ids = CaService::instance()->getEntryIds(
+                         collectionsQuery);
+    Q_ASSERT(ids.count() > 0);
+    collectionId = ids.at(0);
+    qDebug() << "HsMenuService::HsMenuService collectionsIdByType"
+             << collectionId;
+    HSMENUTEST_FUNC_EXIT("HsMenuService::collectionsIdByType");
+    return collectionId;
+}
+
+/*!
  Touch action on an entry.
  \param entryId of this entry.
  \retval boolean error code.