diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index ae20b66b6..ce0a7242c 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -488,12 +488,31 @@ FeedsModelRecycleBin *FeedsModel::recycleBinForIndex(const QModelIndex &index) c } } -QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const { +QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const { if (item == NULL || item->kind() == FeedsModelRootItem::RootItem) { // Root item lies on invalid index. return QModelIndex(); } + QStack chain; + + while (item->kind() != FeedsModelRootItem::RootItem) { + chain.push(item); + item = item->parent(); + } + + // Now, we have complete chain list: parent --- ..... --- parent --- leaf (item). + QModelIndex target_index = indexForItem(m_rootItem); + + // We go through the stack and create our target index. + while (!chain.isEmpty()) { + FeedsModelRootItem *parent_item = chain.pop(); + target_index = index(parent_item->parent()->childItems().indexOf(parent_item), 0, target_index); + } + + return target_index; + + /* QList parents; // Start with root item (which obviously has invalid index). @@ -527,6 +546,7 @@ QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const { } return QModelIndex(); + */ } bool FeedsModel::mergeModel(FeedsImportExportModel *model, QString &output_message) { diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 637e6e0af..596fb1a9f 100755 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -169,9 +169,7 @@ void FeedMessageViewer::onFeedUpdatesStarted() { qApp->mainForm()->statusBar()->showProgress(0, tr("Feed update started")); } -void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed, - int current, - int total) { +void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed, int current, int total) { // Some feed got updated. m_feedsView->updateCountsOfParticularFeed(feed, true); qApp->mainForm()->statusBar()->showProgress((current * 100.0) / total,