FeedsView optimizations.

This commit is contained in:
Martin Rotter 2014-09-22 18:03:22 +02:00
parent f9019ead0d
commit 134f2d408d
3 changed files with 12 additions and 13 deletions

View File

@ -212,14 +212,14 @@ void FeedsView::executeNextAutoUpdate() {
void FeedsView::setSelectedFeedsClearStatus(int clear) {
m_sourceModel->markFeedsDeleted(selectedFeeds(), clear, 0);
updateCountsOfSelectedFeeds();
updateCountsOfSelectedFeeds(true);
emit feedsNeedToBeReloaded(1);
}
void FeedsView::setAllFeedsClearStatus(int clear) {
m_sourceModel->markFeedsDeleted(allFeeds(), clear, 0);
updateCountsOfAllFeeds();
updateCountsOfAllFeeds(true);
emit feedsNeedToBeReloaded(1);
}
@ -348,9 +348,9 @@ void FeedsView::deleteSelectedItem() {
if (m_sourceModel->removeItem(m_proxyModel->mapToSource(current_index))) {
// Item WAS removed, update counts.
// TODO: I do not need to update counts of all items here.
// Updating counts of parent item (feed) should be enough.
updateCountsOfAllFeeds(true);
// TODO: Apparently, I do not need to update counts of all items here, therefore updateCountsOfAllFeeds(true)
// is not needed probably. We just need to inform other parts of application that number of messages has changed.
notifyWithCounts();
}
else {
// Item WAS NOT removed, either database-related error occurred
@ -412,7 +412,7 @@ void FeedsView::emptyRecycleBin() {
}
m_sourceModel->recycleBin()->empty();
updateCountsOfSelectedFeeds();
updateCountsOfSelectedFeeds(true);
emit feedsNeedToBeReloaded(1);
}
@ -459,8 +459,7 @@ void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
notifyWithCounts();
}
void FeedsView::updateCountsOfParticularFeed(FeedsModelFeed *feed,
bool update_total_too) {
void FeedsView::updateCountsOfParticularFeed(FeedsModelFeed *feed, bool update_total_too) {
QModelIndex index = m_sourceModel->indexForItem(feed);
if (index.isValid()) {

View File

@ -112,19 +112,18 @@ class FeedsView : public QTreeView {
void editFeed(FeedsModelFeed *feed);
// Reloads counts for selected feeds.
void updateCountsOfSelectedFeeds(bool update_total_too = true);
void updateCountsOfSelectedFeeds(bool update_total_too);
// Reloads counts for all feeds.
void updateCountsOfAllFeeds(bool update_total_too = true);
void updateCountsOfAllFeeds(bool update_total_too);
// Reloads counts for particular feed.
void updateCountsOfParticularFeed(FeedsModelFeed *feed, bool update_total_too = true);
void updateCountsOfParticularFeed(FeedsModelFeed *feed, bool update_total_too);
// Notifies other components about messages
// counts.
inline void notifyWithCounts() {
emit feedCountsChanged(m_sourceModel->countOfUnreadMessages(),
m_sourceModel->countOfAllMessages());
emit feedCountsChanged(m_sourceModel->countOfUnreadMessages(), m_sourceModel->countOfAllMessages());
}
// Selects next/previous item (feed/category) in the list.

View File

@ -129,6 +129,7 @@ QList<QAction*> FormMain::allActions() {
// Add recycle bin actions.
actions << m_ui->m_actionRestoreRecycleBin;
actions << m_ui->m_actionEmptyRecycleBin;
actions << m_ui->m_actionRestoreSelectedMessagesFromRecycleBin;
return actions;
}