Some work...

This commit is contained in:
Martin Rotter 2014-01-11 13:18:53 +01:00
parent 82d3de2699
commit bdc7aa7a31
5 changed files with 21 additions and 8 deletions

View File

@ -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

View File

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

View File

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

View File

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

View File

@ -64,6 +64,7 @@ void SystemTrayIcon::onActivated(const QSystemTrayIcon::ActivationReason &reason
case SystemTrayIcon::DoubleClick:
case SystemTrayIcon::MiddleClick:
static_cast<FormMain*>(parent())->switchVisibility();
default:
break;
}