From c48407e03861185f10f2bdcfad1ebaab8f9dfd65 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Tue, 10 Mar 2015 19:21:29 +0100 Subject: [PATCH] Add count of unread items to RSS tab label Closes #2681. --- src/gui/mainwindow.cpp | 8 +++++++- src/gui/mainwindow.h | 1 + src/gui/rss/rss_imp.cpp | 4 +++- src/gui/rss/rss_imp.h | 3 +++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 32a172f5e..e2774a170 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -503,7 +503,8 @@ void MainWindow::displayRSSTab(bool enable) // RSS tab if (!rssWidget) { rssWidget = new RSSImp(tabs); - int index_tab = tabs->addTab(rssWidget, tr("RSS")); + connect(rssWidget, SIGNAL(updateRSSCount(int)), this, SLOT(updateRSSTabLabel(int))); + int index_tab = tabs->addTab(rssWidget, tr("RSS (%1)").arg(0)); tabs->setTabIcon(index_tab, GuiIconProvider::instance()->getIcon("application-rss+xml")); } } @@ -513,6 +514,11 @@ void MainWindow::displayRSSTab(bool enable) } +void MainWindow::updateRSSTabLabel(int count) +{ + tabs->setTabText(tabs->indexOf(rssWidget), tr("RSS (%1)").arg(count)); +} + void MainWindow::displaySearchTab(bool enable) { Preferences::instance()->setSearchEnabled(enable); diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 77de76935..97c4b102f 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -138,6 +138,7 @@ protected slots: #if defined(Q_OS_WIN) || defined(Q_OS_MAC) void handleUpdateCheckFinished(bool update_available, QString new_version, bool invokedByUser); #endif + void updateRSSTabLabel(int count); protected: void dropEvent(QDropEvent *event); diff --git a/src/gui/rss/rss_imp.cpp b/src/gui/rss/rss_imp.cpp index 9e04f4bc0..f31edc1fb 100644 --- a/src/gui/rss/rss_imp.cpp +++ b/src/gui/rss/rss_imp.cpp @@ -637,8 +637,10 @@ void RSSImp::updateItemInfos(QTreeWidgetItem *item) return; QString name; - if (rss_item == m_rssManager) + if (rss_item == m_rssManager) { name = tr("Unread"); + emit updateRSSCount(rss_item->unreadCount()); + } else name = rss_item->displayName(); item->setText(0, name + QString::fromUtf8(" (") + QString::number(rss_item->unreadCount()) + QString(")")); diff --git a/src/gui/rss/rss_imp.h b/src/gui/rss/rss_imp.h index b38d07a15..5754effd6 100644 --- a/src/gui/rss/rss_imp.h +++ b/src/gui/rss/rss_imp.h @@ -57,6 +57,9 @@ public slots: void deleteSelectedItems(); void updateRefreshInterval(uint val); +signals: + void updateRSSCount(int); + private slots: void on_newFeedButton_clicked(); void refreshAllFeeds();