| 1 | // For license of this file, see <project-root-folder>/LICENSE.md. |
| 2 | |
| 3 | #ifndef ARTICLELISTNOTIFICATIONMODEL_H |
| 4 | #define ARTICLELISTNOTIFICATIONMODEL_H |
| 5 | |
| 6 | #include "core/message.h" |
| 7 | |
| 8 | #include <QAbstractListModel> |
| 9 | |
| 10 | class ArticleListNotificationModel : public QAbstractListModel { |
| 11 | Q_OBJECT |
| 12 | |
| 13 | public: |
| 14 | explicit ArticleListNotificationModel(QObject* parent = nullptr); |
| 15 | virtual ~ArticleListNotificationModel(); |
| 16 | |
| 17 | void setArticles(const QList<Message>& msgs); |
| 18 | |
| 19 | Message message(const QModelIndex& idx) const; |
| 20 | |
| 21 | void nextPage(); |
| 22 | void previousPage(); |
| 23 | |
| 24 | virtual int rowCount(const QModelIndex& parent) const; |
| 25 | virtual int columnCount(const QModelIndex& parent) const; |
| 26 | virtual QVariant data(const QModelIndex& index, int role) const; |
| 27 | |
| 28 | void reloadWholeLayout(); |
| 29 | |
| 30 | signals: |
| 31 | void nextPagePossibleChanged(bool possible); |
| 32 | void previousPagePossibleChanged(bool possible); |
| 33 | |
| 34 | private: |
| 35 | bool nextPageAvailable() const; |
| 36 | bool previousPageAvailable() const; |
| 37 | |
| 38 | private: |
| 39 | QList<Message> m_articles; |
| 40 | int m_currentPage; |
| 41 | }; |
| 42 | |
| 43 | #endif // ARTICLELISTNOTIFICATIONMODEL_H |