diff --git a/src/services/standard/gui/formstandardcategorydetails.cpp b/src/services/standard/gui/formstandardcategorydetails.cpp index 86c6521a3..5dafa2c3f 100755 --- a/src/services/standard/gui/formstandardcategorydetails.cpp +++ b/src/services/standard/gui/formstandardcategorydetails.cpp @@ -76,7 +76,7 @@ void FormStandardCategoryDetails::setEditableCategory(StandardCategory *editable int FormStandardCategoryDetails::exec(StandardCategory *input_category, RootItem *parent_to_select) { // Load categories. - loadCategories(m_serviceRoot->allCategories().values(), m_serviceRoot, input_category); + loadCategories(m_serviceRoot->allCategories(), m_serviceRoot, input_category); if (input_category == NULL) { // User is adding new category. diff --git a/src/services/standard/gui/formstandardfeeddetails.cpp b/src/services/standard/gui/formstandardfeeddetails.cpp index fa7dd493a..bc720cad6 100755 --- a/src/services/standard/gui/formstandardfeeddetails.cpp +++ b/src/services/standard/gui/formstandardfeeddetails.cpp @@ -61,7 +61,7 @@ FormStandardFeedDetails::~FormStandardFeedDetails() { int FormStandardFeedDetails::exec(StandardFeed *input_feed, RootItem *parent_to_select) { // Load categories. - loadCategories(m_serviceRoot->allCategories().values(), m_serviceRoot); + loadCategories(m_serviceRoot->allCategories(), m_serviceRoot); if (input_feed == NULL) { // User is adding new category. @@ -491,8 +491,7 @@ void FormStandardFeedDetails::loadCategories(const QList cate QVariant::fromValue((void*) root_item)); foreach (StandardCategory *category, categories) { - m_ui->m_cmbParentCategory->addItem(category->data(FDS_MODEL_TITLE_INDEX, - Qt::DecorationRole).value(), + m_ui->m_cmbParentCategory->addItem(category->icon(), category->title(), QVariant::fromValue((void*) category)); } diff --git a/src/services/standard/standardserviceroot.cpp b/src/services/standard/standardserviceroot.cpp index 75c403fbf..6f6778072 100755 --- a/src/services/standard/standardserviceroot.cpp +++ b/src/services/standard/standardserviceroot.cpp @@ -292,35 +292,15 @@ void StandardServiceRoot::loadFromDatabase(){ m_recycleBin->updateCounts(true); } -QHash StandardServiceRoot::categoriesForItem(RootItem *root) { - QHash categories; - QList parents; +QList StandardServiceRoot::allCategories() { + QList cats = getSubTreeCategories(); + QList std_cats; - parents.append(root->childItems()); - - while (!parents.isEmpty()) { - RootItem *item = parents.takeFirst(); - - if (item->kind() == RootItemKind::Category) { - // This item is category, add it to the output list and - // scan its children. - int category_id = item->id(); - StandardCategory *category = static_cast(item); - - if (!categories.contains(category_id)) { - categories.insert(category_id, category); - } - - parents.append(category->childItems()); - } + foreach (Category *category, cats) { + std_cats.append(qobject_cast(category)); } - return categories; -} - -QHash StandardServiceRoot::allCategories() { - // TODO: změnit na qlist, použít getsubtree možná - return categoriesForItem(this); + return std_cats; } QList StandardServiceRoot::getContextMenuForFeed(StandardFeed *feed) { diff --git a/src/services/standard/standardserviceroot.h b/src/services/standard/standardserviceroot.h index 31cc877e1..1a7b62ab0 100755 --- a/src/services/standard/standardserviceroot.h +++ b/src/services/standard/standardserviceroot.h @@ -75,13 +75,9 @@ class StandardServiceRoot : public ServiceRoot { bool onBeforeMessagesRestoredFromBin(RootItem *selected_item, const QList &messages); bool onAfterMessagesRestoredFromBin(RootItem *selected_item, const QList &messages); - // Returns all standard categories which are lying under given root node. - // This does NOT include the root node even if the node is category. - QHash categoriesForItem(RootItem *root); - // Returns all categories from this root, each pair // consists of ID of parent item and pointer to category. - QHash allCategories(); + QList allCategories(); // Returns context specific menu actions for given feed. QList getContextMenuForFeed(StandardFeed *feed);