fix build

This commit is contained in:
Martin Rotter 2023-09-22 13:37:10 +02:00
parent d7574afa0e
commit 41139cd905
4 changed files with 39 additions and 31 deletions

View File

@ -10,20 +10,28 @@ ArticleListNotificationModel::ArticleListNotificationModel(QObject* parent)
ArticleListNotificationModel::~ArticleListNotificationModel() {}
void ArticleListNotificationModel::setArticles(const QList<Message>& 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;
}

View File

@ -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<Message> m_articles;
int m_currentPage;

View File

@ -75,18 +75,7 @@
<item row="2" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="PlainToolButton" name="m_btnPreviousPage">
<property name="toolTip">
<string>Go to previous page</string>
</property>
</widget>
</item>
<item>
<widget class="PlainToolButton" name="m_btnNextPage">
<property name="toolTip">
<string>Go to next page</string>
</property>
</widget>
<widget class="QComboBox" name="m_cmbFeeds"/>
</item>
<item>
<spacer name="horizontalSpacer">
@ -102,20 +91,18 @@
</spacer>
</item>
<item>
<widget class="QComboBox" name="m_cmbFeeds"/>
<widget class="PlainToolButton" name="m_btnPreviousPage">
<property name="toolTip">
<string>Go to previous page</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<widget class="PlainToolButton" name="m_btnNextPage">
<property name="toolTip">
<string>Go to next page</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</widget>
</item>
<item>
<widget class="PlainToolButton" name="m_btnOpenArticleList">
@ -145,9 +132,9 @@
<tabstops>
<tabstop>m_btnClose</tabstop>
<tabstop>m_treeArticles</tabstop>
<tabstop>m_cmbFeeds</tabstop>
<tabstop>m_btnPreviousPage</tabstop>
<tabstop>m_btnNextPage</tabstop>
<tabstop>m_cmbFeeds</tabstop>
<tabstop>m_btnOpenArticleList</tabstop>
<tabstop>m_btnOpenWebBrowser</tabstop>
</tabstops>

View File

@ -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<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::dirtifySettings);
connect(m_ui.m_sbScreen, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::requireRestart);
m_ui.m_sbScreen->setMinimum(-1);
m_ui.m_sbScreen->setMaximum(QGuiApplication::screens().size() - 1);