homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuservice.cpp
changeset 51 4785f57bf3d4
parent 39 4e8ebe173323
child 60 30f14686fb04
child 62 341166945d65
equal deleted inserted replaced
46:23b5d6a29cce 51:4785f57bf3d4
   124     if (collectionType == collectionDownloadedTypeName()) {
   124     if (collectionType == collectionDownloadedTypeName()) {
   125         query.setFlagsOn(RemovableEntryFlag | VisibleEntryFlag);
   125         query.setFlagsOn(RemovableEntryFlag | VisibleEntryFlag);
   126     } else {
   126     } else {
   127         query.setFlagsOn(VisibleEntryFlag);
   127         query.setFlagsOn(VisibleEntryFlag);
   128     }
   128     }
       
   129     if(!collectionId) {
       
   130         collectionId = collectionIdByType(collectionType);
       
   131     }
   129     query.setParentId(collectionId);
   132     query.setParentId(collectionId);
   130     query.setSort(HsMenuServiceUtils::sortBy(sortAttribute),
   133     query.setSort(HsMenuServiceUtils::sortBy(sortAttribute),
   131                   HsMenuServiceUtils::sortOrder(sortAttribute));
   134                   HsMenuServiceUtils::sortOrder(sortAttribute));
   132     HsMenuItemModel *model = new HsMenuItemModel(query);
   135     HsMenuItemModel *model = new HsMenuItemModel(query);
   133     HSMENUTEST_FUNC_EXIT("HsMenuService::getCollectionModel");
   136     HSMENUTEST_FUNC_EXIT("HsMenuService::getCollectionModel");
   345     HSMENUTEST_FUNC_EXIT("HsMenuService::allCollectionsId");
   348     HSMENUTEST_FUNC_EXIT("HsMenuService::allCollectionsId");
   346     return mAllCollectionsId;
   349     return mAllCollectionsId;
   347 }
   350 }
   348 
   351 
   349 /*!
   352 /*!
       
   353  Retrives the first found collection entry id
       
   354  \param collectionType collection type.
       
   355  \retval collectionType id
       
   356  */
       
   357 int HsMenuService::collectionIdByType(const QString& collectionType)
       
   358 {
       
   359     HSMENUTEST_FUNC_ENTRY("HsMenuService::collectionsIdByType");
       
   360     int collectionId;
       
   361     CaQuery collectionsQuery;
       
   362     collectionsQuery.setEntryRoles(GroupEntryRole);
       
   363     //sorting is set to (default, ascending) to assure that
       
   364     //proper entry is fetched, somebody can add item with
       
   365     //"menucollections" typename to the storage, but even if he or she
       
   366     //do this we fetch entry that we wanted
       
   367     collectionsQuery.setSort(DefaultSortAttribute, Qt::AscendingOrder);
       
   368     collectionsQuery.addEntryTypeName(collectionType);
       
   369     QList<int> ids = CaService::instance()->getEntryIds(
       
   370                          collectionsQuery);
       
   371     Q_ASSERT(ids.count() > 0);
       
   372     collectionId = ids.at(0);
       
   373     qDebug() << "HsMenuService::HsMenuService collectionsIdByType"
       
   374              << collectionId;
       
   375     HSMENUTEST_FUNC_EXIT("HsMenuService::collectionsIdByType");
       
   376     return collectionId;
       
   377 }
       
   378 
       
   379 /*!
   350  Touch action on an entry.
   380  Touch action on an entry.
   351  \param entryId of this entry.
   381  \param entryId of this entry.
   352  \retval boolean error code.
   382  \retval boolean error code.
   353  */
   383  */
   354 bool HsMenuService::touch(int entryId)
   384 bool HsMenuService::touch(int entryId)