From 41139cd905c1749afcf85b69719b2a6a0009d888 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Fri, 22 Sep 2023 13:37:10 +0200 Subject: [PATCH] fix build --- .../core/articlelistnotificationmodel.cpp | 27 +++++++++++--- .../core/articlelistnotificationmodel.h | 4 +++ .../notifications/articlelistnotification.ui | 35 ++++++------------- .../gui/settings/settingsnotifications.cpp | 4 +-- 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/librssguard/core/articlelistnotificationmodel.cpp b/src/librssguard/core/articlelistnotificationmodel.cpp index 4cb601706..ac02a466b 100644 --- a/src/librssguard/core/articlelistnotificationmodel.cpp +++ b/src/librssguard/core/articlelistnotificationmodel.cpp @@ -10,20 +10,28 @@ ArticleListNotificationModel::ArticleListNotificationModel(QObject* parent) ArticleListNotificationModel::~ArticleListNotificationModel() {} void ArticleListNotificationModel::setArticles(const QList& msgs) { - m_articles = msgs; m_currentPage = 0; + m_articles = msgs; reloadWholeLayout(); + emit nextPagePossibleChanged(nextPageAvailable()); + emit previousPagePossibleChanged(previousPageAvailable()); } void ArticleListNotificationModel::nextPage() { - emit nextPagePossibleChanged(true); - emit previousPagePossibleChanged(true); + m_currentPage++; + reloadWholeLayout(); + + emit nextPagePossibleChanged(nextPageAvailable()); + emit previousPagePossibleChanged(previousPageAvailable()); } void ArticleListNotificationModel::previousPage() { - emit nextPagePossibleChanged(true); - emit previousPagePossibleChanged(true); + m_currentPage--; + reloadWholeLayout(); + + emit nextPagePossibleChanged(nextPageAvailable()); + emit previousPagePossibleChanged(previousPageAvailable()); } int ArticleListNotificationModel::rowCount(const QModelIndex& parent) const { @@ -37,6 +45,7 @@ int ArticleListNotificationModel::columnCount(const QModelIndex& parent) const { QVariant ArticleListNotificationModel::data(const QModelIndex& index, int role) const { switch (role) { case Qt::ItemDataRole::DisplayRole: + case Qt::ItemDataRole::ToolTipRole: return m_articles.at((m_currentPage * NOTIFICATIONS_PAGE_SIZE) + index.row()).m_title; } @@ -47,3 +56,11 @@ void ArticleListNotificationModel::reloadWholeLayout() { emit layoutAboutToBeChanged(); emit layoutChanged(); } + +bool ArticleListNotificationModel::nextPageAvailable() const { + return m_articles.size() - (NOTIFICATIONS_PAGE_SIZE * (m_currentPage + 1)) > 0; +} + +bool ArticleListNotificationModel::previousPageAvailable() const { + return m_currentPage > 0; +} diff --git a/src/librssguard/core/articlelistnotificationmodel.h b/src/librssguard/core/articlelistnotificationmodel.h index c97574d6f..17263b0f9 100644 --- a/src/librssguard/core/articlelistnotificationmodel.h +++ b/src/librssguard/core/articlelistnotificationmodel.h @@ -29,6 +29,10 @@ class ArticleListNotificationModel : public QAbstractListModel { void nextPagePossibleChanged(bool possible); void previousPagePossibleChanged(bool possible); + private: + bool nextPageAvailable() const; + bool previousPageAvailable() const; + private: QList m_articles; int m_currentPage; diff --git a/src/librssguard/gui/notifications/articlelistnotification.ui b/src/librssguard/gui/notifications/articlelistnotification.ui index 4cba4fad9..3ec01ee55 100644 --- a/src/librssguard/gui/notifications/articlelistnotification.ui +++ b/src/librssguard/gui/notifications/articlelistnotification.ui @@ -75,18 +75,7 @@ - - - Go to previous page - - - - - - - Go to next page - - + @@ -102,20 +91,18 @@ - + + + Go to previous page + + - - - Qt::Horizontal + + + Go to next page - - - 40 - 20 - - - + @@ -145,9 +132,9 @@ m_btnClose m_treeArticles + m_cmbFeeds m_btnPreviousPage m_btnNextPage - m_cmbFeeds m_btnOpenArticleList m_btnOpenWebBrowser diff --git a/src/librssguard/gui/settings/settingsnotifications.cpp b/src/librssguard/gui/settings/settingsnotifications.cpp index 5ea235ffa..084b320a0 100644 --- a/src/librssguard/gui/settings/settingsnotifications.cpp +++ b/src/librssguard/gui/settings/settingsnotifications.cpp @@ -27,8 +27,8 @@ SettingsNotifications::SettingsNotifications(Settings* settings, QWidget* parent connect(m_ui.m_rbNativeNotifications, &QRadioButton::toggled, this, &SettingsNotifications::dirtifySettings); connect(m_ui.m_rbNativeNotifications, &QRadioButton::toggled, this, &SettingsNotifications::requireRestart); - connect(m_ui.m_sbScreen, &QSpinBox::valueChanged, this, &SettingsNotifications::dirtifySettings); - connect(m_ui.m_sbScreen, &QSpinBox::valueChanged, this, &SettingsNotifications::requireRestart); + connect(m_ui.m_sbScreen, QOverload::of(&QSpinBox::valueChanged), this, &SettingsNotifications::dirtifySettings); + connect(m_ui.m_sbScreen, QOverload::of(&QSpinBox::valueChanged), this, &SettingsNotifications::requireRestart); m_ui.m_sbScreen->setMinimum(-1); m_ui.m_sbScreen->setMaximum(QGuiApplication::screens().size() - 1);