Only updated feeds are now reloaded in the FeedsModel.
This commit is contained in:
parent
e1c3defddc
commit
558b241eb4
4 changed files with 21 additions and 7 deletions
|
@ -203,15 +203,16 @@ QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const {
|
||||||
|
|
||||||
void FeedsModel::reloadChangedLayout(QModelIndexList list) {
|
void FeedsModel::reloadChangedLayout(QModelIndexList list) {
|
||||||
while (!list.isEmpty()) {
|
while (!list.isEmpty()) {
|
||||||
QModelIndex ix = list.takeLast();
|
QModelIndex indx = list.takeLast();
|
||||||
|
QModelIndex indx_parent = indx.parent();
|
||||||
|
|
||||||
// Underlying data are changed.
|
// Underlying data are changed.
|
||||||
emit dataChanged(index(ix.row(), 0, ix.parent()),
|
emit dataChanged(index(indx.row(), 0, indx_parent),
|
||||||
index(ix.row(), FDS_MODEL_COUNTS_INDEX, ix.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.
|
// Make sure that data of parent are changed too.
|
||||||
list.append(ix.parent());
|
list.append(indx_parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,8 @@ void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed,
|
||||||
// TODO: Don't update counts of all feeds here,
|
// TODO: Don't update counts of all feeds here,
|
||||||
// it is enough to update counts of update feed.
|
// it is enough to update counts of update feed.
|
||||||
// So use indexForItem method from the model.
|
// So use indexForItem method from the model.
|
||||||
m_feedsView->updateCountsOfAllFeeds(true);
|
//m_feedsView->updateCountsOfAllFeeds(true);
|
||||||
|
m_feedsView->updateCountsOfParticularFeed(feed, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedMessageViewer::onFeedUpdatesFinished() {
|
void FeedMessageViewer::onFeedUpdatesFinished() {
|
||||||
|
|
|
@ -151,6 +151,16 @@ void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
|
||||||
m_sourceModel->reloadWholeLayout();
|
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() {
|
void FeedsView::initializeContextMenuCategoriesFeeds() {
|
||||||
m_contextMenuCategoriesFeeds = new QMenu(tr("Context menu for feeds"), this);
|
m_contextMenuCategoriesFeeds = new QMenu(tr("Context menu for feeds"), this);
|
||||||
m_contextMenuCategoriesFeeds->addActions(QList<QAction*>() <<
|
m_contextMenuCategoriesFeeds->addActions(QList<QAction*>() <<
|
||||||
|
|
|
@ -56,6 +56,8 @@ class FeedsView : public QTreeView {
|
||||||
// Reloads counts for all feeds.
|
// Reloads counts for all feeds.
|
||||||
void updateCountsOfAllFeeds(bool update_total_too = true);
|
void updateCountsOfAllFeeds(bool update_total_too = true);
|
||||||
|
|
||||||
|
void updateCountsOfParticularFeed(FeedsModelFeed *feed, bool update_total_too = true);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Initializes context menus.
|
// Initializes context menus.
|
||||||
void initializeContextMenuCategoriesFeeds();
|
void initializeContextMenuCategoriesFeeds();
|
||||||
|
|
Loading…
Add table
Reference in a new issue