diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 051de41c9..96a94ab63 100644 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -203,15 +203,16 @@ QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const { void FeedsModel::reloadChangedLayout(QModelIndexList list) { while (!list.isEmpty()) { - QModelIndex ix = list.takeLast(); + QModelIndex indx = list.takeLast(); + QModelIndex indx_parent = indx.parent(); // Underlying data are changed. - emit dataChanged(index(ix.row(), 0, ix.parent()), - index(ix.row(), FDS_MODEL_COUNTS_INDEX, ix.parent())); + emit dataChanged(index(indx.row(), 0, indx_parent), + index(indx.row(), FDS_MODEL_COUNTS_INDEX, indx_parent)); - if (ix.parent().isValid()) { + if (indx_parent.isValid()) { // Make sure that data of parent are changed too. - list.append(ix.parent()); + list.append(indx_parent); } } } diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index a8e673310..8bc0c2a60 100644 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -120,8 +120,9 @@ void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed, // Some feed got updated. // TODO: Don't update counts of all feeds here, // it is enough to update counts of update feed. - // So use indexForItem method from the model. - m_feedsView->updateCountsOfAllFeeds(true); + // So use indexForItem method from the model. + //m_feedsView->updateCountsOfAllFeeds(true); + m_feedsView->updateCountsOfParticularFeed(feed, true); } void FeedMessageViewer::onFeedUpdatesFinished() { diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index b804ff240..a7bdfbf40 100644 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -151,6 +151,16 @@ void FeedsView::updateCountsOfAllFeeds(bool update_total_too) { m_sourceModel->reloadWholeLayout(); } +void FeedsView::updateCountsOfParticularFeed(FeedsModelFeed *feed, + bool update_total_too) { + QModelIndex index = m_sourceModel->indexForItem(feed); + + if (index.isValid()) { + feed->updateCounts(update_total_too); + m_sourceModel->reloadChangedLayout(QModelIndexList() << index); + } +} + void FeedsView::initializeContextMenuCategoriesFeeds() { m_contextMenuCategoriesFeeds = new QMenu(tr("Context menu for feeds"), this); m_contextMenuCategoriesFeeds->addActions(QList() << diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index 4f65f9160..8fa9d53dd 100644 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -56,6 +56,8 @@ class FeedsView : public QTreeView { // Reloads counts for all feeds. void updateCountsOfAllFeeds(bool update_total_too = true); + void updateCountsOfParticularFeed(FeedsModelFeed *feed, bool update_total_too = true); + protected: // Initializes context menus. void initializeContextMenuCategoriesFeeds();