diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 7f136c76e..826eb2d6e 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -312,10 +312,6 @@ QList FeedsModel::messagesForFeeds(const QList &feeds) { return messages; } -QList FeedsModel::allCategories() { - return categoriesForItem(m_rootItem); -} - int FeedsModel::columnCount(const QModelIndex &parent) const { Q_UNUSED(parent) @@ -543,7 +539,7 @@ QList FeedsModel::allFeeds() { } QList FeedsModel::feedsForItem(RootItem *root) { - QList children = root->getRecursiveChildren(); + QList children = root->getSubTree(); QList feeds; foreach (RootItem *child, children) { @@ -555,22 +551,18 @@ QList FeedsModel::feedsForItem(RootItem *root) { return feeds; } +QList FeedsModel::allCategories() { + return categoriesForItem(m_rootItem); +} + QList FeedsModel::categoriesForItem(RootItem *root) { + QList children = root->getSubTree(); QList categories; - QList parents; - parents.append(root); - - 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. - categories.append( item->toCategory()); + foreach (RootItem *child, children) { + if (child->kind() == RootItemKind::Category) { + categories.append(child->toCategory()); } - - parents.append(item->childItems()); } return categories; diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index 3c4c6b23e..57f413307 100755 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -20,7 +20,7 @@ #include -#include "core/messagesmodel.h" +#include "core/message.h" #include "core/rootitem.h" diff --git a/src/core/feedsselection.cpp b/src/core/feedsselection.cpp index ba563eb95..8b3b1c31d 100755 --- a/src/core/feedsselection.cpp +++ b/src/core/feedsselection.cpp @@ -58,7 +58,7 @@ RootItem *FeedsSelection::selectedItem() const { QString FeedsSelection::generateListOfIds() { if (m_selectedItem != NULL && (m_selectedItem->kind() == RootItemKind::Feed || m_selectedItem->kind() == RootItemKind::Category)) { - QList children = m_selectedItem->getRecursiveChildren(); + QList children = m_selectedItem->getSubTree(); QStringList stringy_ids; foreach (RootItem *child, children) { diff --git a/src/core/rootitem.cpp b/src/core/rootitem.cpp index b06e00271..1192110bd 100755 --- a/src/core/rootitem.cpp +++ b/src/core/rootitem.cpp @@ -74,36 +74,20 @@ int RootItem::countOfAllMessages() const { return total_count; } -QList RootItem::getRecursiveChildren() { +QList RootItem::getSubTree() { QList children; - if (childCount() == 0) { - // Root itself has no children, it is either feed or - // empty category? - children.append(this); - } - else { - // Root itself is a CATEGORY or ROOT item. - QList traversable_items; + // Root itself is a CATEGORY or ROOT item. + QList traversable_items; - traversable_items.append(this); + traversable_items.append(this); - // Iterate all nested categories. - while (!traversable_items.isEmpty()) { - RootItem *active_item = traversable_items.takeFirst(); - children.append(active_item); + // Iterate all nested categories. + while (!traversable_items.isEmpty()) { + RootItem *active_item = traversable_items.takeFirst(); - foreach (RootItem *child, active_item->childItems()) { - if (child->childCount() == 0) { - // This child is feed or empty category. - children.append(child); - } - else { - // This child is category, add its child feeds too. - traversable_items.append(child); - } - } - } + children.append(active_item); + traversable_items.append(active_item->childItems()); } return children; diff --git a/src/core/rootitem.h b/src/core/rootitem.h index b36cf12c5..8f6988be0 100755 --- a/src/core/rootitem.h +++ b/src/core/rootitem.h @@ -138,7 +138,9 @@ class RootItem { m_childItems.clear(); } - QList getRecursiveChildren(); + // Returns flat list of all items from subtree where this item is a root. + // Returned list includes this item too. + QList getSubTree(); // Removes particular child at given index. // NOTE: Child is NOT freed from the memory. diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index 21dc93101..ac1359377 100755 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -330,12 +330,14 @@ void FeedsView::markAllFeedsRead() { void FeedsView::fetchMetadataForSelectedFeed() { // TODO: fix + /* StandardFeed *selected_feed = (StandardFeed*) selectedFeed(); if (selected_feed != NULL) { selected_feed->fetchMetadataForItself(); m_sourceModel->reloadChangedLayout(QModelIndexList() << m_proxyModel->mapToSource(selectionModel()->selectedRows(0).at(0))); } + */ } void FeedsView::clearAllReadMessages() {