diff --git a/src/librssguard/core/articlelistnotificationmodel.cpp b/src/librssguard/core/articlelistnotificationmodel.cpp index ac02a466b..09a4a7194 100644 --- a/src/librssguard/core/articlelistnotificationmodel.cpp +++ b/src/librssguard/core/articlelistnotificationmodel.cpp @@ -18,6 +18,10 @@ void ArticleListNotificationModel::setArticles(const QList& msgs) { emit previousPagePossibleChanged(previousPageAvailable()); } +Message ArticleListNotificationModel::message(const QModelIndex& idx) const { + return m_articles.at((m_currentPage * NOTIFICATIONS_PAGE_SIZE) + idx.row()); +} + void ArticleListNotificationModel::nextPage() { m_currentPage++; reloadWholeLayout(); diff --git a/src/librssguard/core/articlelistnotificationmodel.h b/src/librssguard/core/articlelistnotificationmodel.h index 17263b0f9..e98c57a00 100644 --- a/src/librssguard/core/articlelistnotificationmodel.h +++ b/src/librssguard/core/articlelistnotificationmodel.h @@ -16,6 +16,8 @@ class ArticleListNotificationModel : public QAbstractListModel { void setArticles(const QList& msgs); + Message message(const QModelIndex& idx) const; + void nextPage(); void previousPage(); diff --git a/src/librssguard/gui/notifications/articlelistnotification.cpp b/src/librssguard/gui/notifications/articlelistnotification.cpp index 79c906921..931064150 100644 --- a/src/librssguard/gui/notifications/articlelistnotification.cpp +++ b/src/librssguard/gui/notifications/articlelistnotification.cpp @@ -5,6 +5,8 @@ #include "core/articlelistnotificationmodel.h" #include "miscellaneous/iconfactory.h" +#include + ArticleListNotification::ArticleListNotification(QWidget* parent) : BaseToastNotification(parent), m_model(new ArticleListNotificationModel(this)) { m_ui.setupUi(this); @@ -25,6 +27,12 @@ ArticleListNotification::ArticleListNotification(QWidget* parent) &ArticleListNotificationModel::previousPagePossibleChanged, m_ui.m_btnPreviousPage, &PlainToolButton::setEnabled); + connect(m_ui.m_btnNextPage, &PlainToolButton::clicked, m_model, &ArticleListNotificationModel::nextPage); + connect(m_ui.m_btnPreviousPage, &PlainToolButton::clicked, m_model, &ArticleListNotificationModel::previousPage); + connect(m_ui.m_treeArticles->selectionModel(), + &QItemSelectionModel::currentChanged, + this, + &ArticleListNotificationModel::onMessageSelected); m_ui.m_treeArticles->setAttribute(Qt::WA_NoSystemBackground, true); @@ -56,6 +64,20 @@ void ArticleListNotification::loadResults(const QHash>& ne } } +void ArticleListNotification::onMessageSelected(const QModelIndex& current, const QModelIndex& previous) { + m_ui.m_btnOpenArticleList->setEnabled(current.isValid()); + m_ui.m_btnOpenWebBrowser->setEnabled(current.isValid()); +} + void ArticleListNotification::showFeed(int index) { m_model->setArticles(m_newMessages.value(m_ui.m_cmbFeeds->itemData(index).value())); } + +Message ArticleListNotification::selectedMessage() const { + if (m_ui.m_treeArticles->currentIndex().isValid()) { + return m_model->message(m_ui.m_treeArticles->currentIndex()); + } + else { + throw ApplicationException("message cannot be loaded, wrong index"); + } +} diff --git a/src/librssguard/gui/notifications/articlelistnotification.h b/src/librssguard/gui/notifications/articlelistnotification.h index d7590abbf..a2774b7f3 100644 --- a/src/librssguard/gui/notifications/articlelistnotification.h +++ b/src/librssguard/gui/notifications/articlelistnotification.h @@ -21,8 +21,12 @@ class ArticleListNotification : public BaseToastNotification { void loadResults(const QHash>& new_messages); private slots: + void onMessageSelected(const QModelIndex& current, const QModelIndex& previous); void showFeed(int index); + private: + Message selectedMessage() const; + private: Ui::ArticleListNotification m_ui; ArticleListNotificationModel* m_model; diff --git a/src/librssguard/gui/notifications/articlelistnotification.ui b/src/librssguard/gui/notifications/articlelistnotification.ui index 3ec01ee55..cee497ca8 100644 --- a/src/librssguard/gui/notifications/articlelistnotification.ui +++ b/src/librssguard/gui/notifications/articlelistnotification.ui @@ -75,13 +75,23 @@ - + + + + 0 + 0 + + + Qt::Horizontal + + QSizePolicy::Minimum + 40