Only updated feeds are now reloaded in the FeedsModel.

This commit is contained in:
Martin Rotter 2014-01-03 07:45:42 +01:00
parent e1c3defddc
commit 558b241eb4
4 changed files with 21 additions and 7 deletions

View File

@ -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);
}
}
}

View File

@ -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() {

View File

@ -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<QAction*>() <<

View File

@ -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();