From bdc7aa7a3148c0835117b6a64f52c4092866e57b Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Sat, 11 Jan 2014 13:18:53 +0100 Subject: [PATCH] Some work... --- src/core/feedsmodel.cpp | 8 ++++++++ src/core/feedsmodel.h | 4 ++++ src/gui/feedsview.cpp | 11 ++++++++--- src/gui/formmain.cpp | 5 ----- src/gui/systemtrayicon.cpp | 1 + 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 00a249195..298b9f3f6 100644 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -140,6 +140,14 @@ int FeedsModel::rowCount(const QModelIndex &parent) const { return parent_item->childCount(); } +int FeedsModel::countOfAllMessages() const { + return m_rootItem->countOfAllMessages(); +} + +int FeedsModel::countOfUnreadMessages() const { + return m_rootItem->countOfUnreadMessages(); +} + // TODO: přepsat tudle metodu, // vim ze to zhruba funguje ale je potreba pridat taky // vymazani feedu/kategorie z SQL (pridat metodu do FeedsModelRootItem diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index 5061ac769..e32640415 100644 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -33,6 +33,10 @@ class FeedsModel : public QAbstractItemModel { int columnCount(const QModelIndex &parent) const; int rowCount(const QModelIndex &parent) const; + // Returns couns of ALL/UNREAD (non-deleted) messages for the model. + int countOfAllMessages() const; + int countOfUnreadMessages() const; + // Feed/category manipulators. bool removeItems(const QModelIndexList &indexes); diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index 37552df70..925963a31 100644 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -169,6 +169,9 @@ void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) { // Make sure that selected view reloads changed indexes. m_sourceModel->reloadChangedLayout(m_proxyModel->mapListToSource(selectionModel()->selectedRows())); + + emit feedCountsChanged(m_sourceModel->countOfUnreadMessages(), + m_sourceModel->countOfAllMessages()); } } @@ -179,6 +182,9 @@ void FeedsView::updateCountsOfAllFeeds(bool update_total_too) { // Make sure that all views reloads its data. m_sourceModel->reloadWholeLayout(); + + emit feedCountsChanged(m_sourceModel->countOfUnreadMessages(), + m_sourceModel->countOfAllMessages()); } void FeedsView::updateCountsOfParticularFeed(FeedsModelFeed *feed, @@ -190,9 +196,8 @@ void FeedsView::updateCountsOfParticularFeed(FeedsModelFeed *feed, m_sourceModel->reloadChangedLayout(QModelIndexList() << index); } - // TODO: Optimize this and call the signal in all updateCounts* methods. - emit feedCountsChanged(m_sourceModel->rootItem()->countOfUnreadMessages(), - m_sourceModel->rootItem()->countOfAllMessages()); + emit feedCountsChanged(m_sourceModel->countOfUnreadMessages(), + m_sourceModel->countOfAllMessages()); } void FeedsView::initializeContextMenuCategoriesFeeds() { diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp index dac7269a4..e0d19a676 100755 --- a/src/gui/formmain.cpp +++ b/src/gui/formmain.cpp @@ -47,11 +47,6 @@ FormMain::FormMain(QWidget *parent) : QMainWindow(parent), m_ui(new Ui::FormMain FormMain::~FormMain() { delete m_ui; - - if (SystemTrayIcon::isSystemTrayAvailable()) { - delete m_trayMenu; - qDebug("Deleting tray icon menu."); - } } FormMain *FormMain::instance() { diff --git a/src/gui/systemtrayicon.cpp b/src/gui/systemtrayicon.cpp index fb9bbe8fa..fac63fa72 100644 --- a/src/gui/systemtrayicon.cpp +++ b/src/gui/systemtrayicon.cpp @@ -64,6 +64,7 @@ void SystemTrayIcon::onActivated(const QSystemTrayIcon::ActivationReason &reason case SystemTrayIcon::DoubleClick: case SystemTrayIcon::MiddleClick: static_cast(parent())->switchVisibility(); + default: break; }