FeedsView optimizations.
This commit is contained in:
parent
f9019ead0d
commit
134f2d408d
3 changed files with 12 additions and 13 deletions
|
@ -212,14 +212,14 @@ void FeedsView::executeNextAutoUpdate() {
|
||||||
|
|
||||||
void FeedsView::setSelectedFeedsClearStatus(int clear) {
|
void FeedsView::setSelectedFeedsClearStatus(int clear) {
|
||||||
m_sourceModel->markFeedsDeleted(selectedFeeds(), clear, 0);
|
m_sourceModel->markFeedsDeleted(selectedFeeds(), clear, 0);
|
||||||
updateCountsOfSelectedFeeds();
|
updateCountsOfSelectedFeeds(true);
|
||||||
|
|
||||||
emit feedsNeedToBeReloaded(1);
|
emit feedsNeedToBeReloaded(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::setAllFeedsClearStatus(int clear) {
|
void FeedsView::setAllFeedsClearStatus(int clear) {
|
||||||
m_sourceModel->markFeedsDeleted(allFeeds(), clear, 0);
|
m_sourceModel->markFeedsDeleted(allFeeds(), clear, 0);
|
||||||
updateCountsOfAllFeeds();
|
updateCountsOfAllFeeds(true);
|
||||||
|
|
||||||
emit feedsNeedToBeReloaded(1);
|
emit feedsNeedToBeReloaded(1);
|
||||||
}
|
}
|
||||||
|
@ -348,9 +348,9 @@ void FeedsView::deleteSelectedItem() {
|
||||||
|
|
||||||
if (m_sourceModel->removeItem(m_proxyModel->mapToSource(current_index))) {
|
if (m_sourceModel->removeItem(m_proxyModel->mapToSource(current_index))) {
|
||||||
// Item WAS removed, update counts.
|
// Item WAS removed, update counts.
|
||||||
// TODO: I do not need to update counts of all items here.
|
// TODO: Apparently, I do not need to update counts of all items here, therefore updateCountsOfAllFeeds(true)
|
||||||
// Updating counts of parent item (feed) should be enough.
|
// is not needed probably. We just need to inform other parts of application that number of messages has changed.
|
||||||
updateCountsOfAllFeeds(true);
|
notifyWithCounts();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Item WAS NOT removed, either database-related error occurred
|
// Item WAS NOT removed, either database-related error occurred
|
||||||
|
@ -412,7 +412,7 @@ void FeedsView::emptyRecycleBin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sourceModel->recycleBin()->empty();
|
m_sourceModel->recycleBin()->empty();
|
||||||
updateCountsOfSelectedFeeds();
|
updateCountsOfSelectedFeeds(true);
|
||||||
|
|
||||||
emit feedsNeedToBeReloaded(1);
|
emit feedsNeedToBeReloaded(1);
|
||||||
}
|
}
|
||||||
|
@ -459,8 +459,7 @@ void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
|
||||||
notifyWithCounts();
|
notifyWithCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::updateCountsOfParticularFeed(FeedsModelFeed *feed,
|
void FeedsView::updateCountsOfParticularFeed(FeedsModelFeed *feed, bool update_total_too) {
|
||||||
bool update_total_too) {
|
|
||||||
QModelIndex index = m_sourceModel->indexForItem(feed);
|
QModelIndex index = m_sourceModel->indexForItem(feed);
|
||||||
|
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
|
|
|
@ -112,19 +112,18 @@ class FeedsView : public QTreeView {
|
||||||
void editFeed(FeedsModelFeed *feed);
|
void editFeed(FeedsModelFeed *feed);
|
||||||
|
|
||||||
// Reloads counts for selected feeds.
|
// Reloads counts for selected feeds.
|
||||||
void updateCountsOfSelectedFeeds(bool update_total_too = true);
|
void updateCountsOfSelectedFeeds(bool update_total_too);
|
||||||
|
|
||||||
// Reloads counts for all feeds.
|
// Reloads counts for all feeds.
|
||||||
void updateCountsOfAllFeeds(bool update_total_too = true);
|
void updateCountsOfAllFeeds(bool update_total_too);
|
||||||
|
|
||||||
// Reloads counts for particular feed.
|
// 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
|
// Notifies other components about messages
|
||||||
// counts.
|
// counts.
|
||||||
inline void notifyWithCounts() {
|
inline void notifyWithCounts() {
|
||||||
emit feedCountsChanged(m_sourceModel->countOfUnreadMessages(),
|
emit feedCountsChanged(m_sourceModel->countOfUnreadMessages(), m_sourceModel->countOfAllMessages());
|
||||||
m_sourceModel->countOfAllMessages());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Selects next/previous item (feed/category) in the list.
|
// Selects next/previous item (feed/category) in the list.
|
||||||
|
|
|
@ -129,6 +129,7 @@ QList<QAction*> FormMain::allActions() {
|
||||||
// Add recycle bin actions.
|
// Add recycle bin actions.
|
||||||
actions << m_ui->m_actionRestoreRecycleBin;
|
actions << m_ui->m_actionRestoreRecycleBin;
|
||||||
actions << m_ui->m_actionEmptyRecycleBin;
|
actions << m_ui->m_actionEmptyRecycleBin;
|
||||||
|
actions << m_ui->m_actionRestoreSelectedMessagesFromRecycleBin;
|
||||||
|
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue