save woprk
This commit is contained in:
parent
8b50c209b7
commit
6f7d192a98
5 changed files with 43 additions and 1 deletions
|
@ -18,6 +18,10 @@ void ArticleListNotificationModel::setArticles(const QList<Message>& msgs) {
|
||||||
emit previousPagePossibleChanged(previousPageAvailable());
|
emit previousPagePossibleChanged(previousPageAvailable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Message ArticleListNotificationModel::message(const QModelIndex& idx) const {
|
||||||
|
return m_articles.at((m_currentPage * NOTIFICATIONS_PAGE_SIZE) + idx.row());
|
||||||
|
}
|
||||||
|
|
||||||
void ArticleListNotificationModel::nextPage() {
|
void ArticleListNotificationModel::nextPage() {
|
||||||
m_currentPage++;
|
m_currentPage++;
|
||||||
reloadWholeLayout();
|
reloadWholeLayout();
|
||||||
|
|
|
@ -16,6 +16,8 @@ class ArticleListNotificationModel : public QAbstractListModel {
|
||||||
|
|
||||||
void setArticles(const QList<Message>& msgs);
|
void setArticles(const QList<Message>& msgs);
|
||||||
|
|
||||||
|
Message message(const QModelIndex& idx) const;
|
||||||
|
|
||||||
void nextPage();
|
void nextPage();
|
||||||
void previousPage();
|
void previousPage();
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include "core/articlelistnotificationmodel.h"
|
#include "core/articlelistnotificationmodel.h"
|
||||||
#include "miscellaneous/iconfactory.h"
|
#include "miscellaneous/iconfactory.h"
|
||||||
|
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
ArticleListNotification::ArticleListNotification(QWidget* parent)
|
ArticleListNotification::ArticleListNotification(QWidget* parent)
|
||||||
: BaseToastNotification(parent), m_model(new ArticleListNotificationModel(this)) {
|
: BaseToastNotification(parent), m_model(new ArticleListNotificationModel(this)) {
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
@ -25,6 +27,12 @@ ArticleListNotification::ArticleListNotification(QWidget* parent)
|
||||||
&ArticleListNotificationModel::previousPagePossibleChanged,
|
&ArticleListNotificationModel::previousPagePossibleChanged,
|
||||||
m_ui.m_btnPreviousPage,
|
m_ui.m_btnPreviousPage,
|
||||||
&PlainToolButton::setEnabled);
|
&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);
|
m_ui.m_treeArticles->setAttribute(Qt::WA_NoSystemBackground, true);
|
||||||
|
|
||||||
|
@ -56,6 +64,20 @@ void ArticleListNotification::loadResults(const QHash<Feed*, QList<Message>>& 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) {
|
void ArticleListNotification::showFeed(int index) {
|
||||||
m_model->setArticles(m_newMessages.value(m_ui.m_cmbFeeds->itemData(index).value<Feed*>()));
|
m_model->setArticles(m_newMessages.value(m_ui.m_cmbFeeds->itemData(index).value<Feed*>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -21,8 +21,12 @@ class ArticleListNotification : public BaseToastNotification {
|
||||||
void loadResults(const QHash<Feed*, QList<Message>>& new_messages);
|
void loadResults(const QHash<Feed*, QList<Message>>& new_messages);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void onMessageSelected(const QModelIndex& current, const QModelIndex& previous);
|
||||||
void showFeed(int index);
|
void showFeed(int index);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Message selectedMessage() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ArticleListNotification m_ui;
|
Ui::ArticleListNotification m_ui;
|
||||||
ArticleListNotificationModel* m_model;
|
ArticleListNotificationModel* m_model;
|
||||||
|
|
|
@ -75,13 +75,23 @@
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="2" column="0" colspan="2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="m_cmbFeeds"/>
|
<widget class="QComboBox" name="m_cmbFeeds">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Minimum</enum>
|
||||||
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>40</width>
|
||||||
|
|
Loading…
Add table
Reference in a new issue