| 1 | // For license of this file, see <project-root-folder>/LICENSE.md. |
| 2 | |
| 3 | #ifndef ARTICLELISTNOTIFICATION_H |
| 4 | #define ARTICLELISTNOTIFICATION_H |
| 5 | |
| 6 | #include "core/message.h" |
| 7 | #include "gui/notifications/basetoastnotification.h" |
| 8 | |
| 9 | #include "ui_articlelistnotification.h" |
| 10 | |
| 11 | class Feed; |
| 12 | class ArticleListNotificationModel; |
| 13 | |
| 14 | class ArticleListNotification : public BaseToastNotification { |
| 15 | Q_OBJECT |
| 16 | |
| 17 | public: |
| 18 | explicit ArticleListNotification(QWidget* parent = nullptr); |
| 19 | |
| 20 | void loadResults(const QHash<Feed*, QList<Message>>& new_messages); |
| 21 | |
| 22 | signals: |
| 23 | void openingArticleInArticleListRequested(Feed* feed, const Message& msg); |
| 24 | void reloadMessageListRequested(bool mark_selected_messages_read); |
| 25 | |
| 26 | public: |
| 27 | virtual bool eventFilter(QObject* watched, QEvent* event); |
| 28 | |
| 29 | private slots: |
| 30 | void openArticleInArticleList(); |
| 31 | void openArticleInWebBrowser(); |
| 32 | void onMessageSelected(const QModelIndex& current, const QModelIndex& previous); |
| 33 | void showFeed(int index); |
| 34 | void markAllRead(); |
| 35 | |
| 36 | private: |
| 37 | void markAsRead(Feed* feed, const QList<Message>& articles); |
| 38 | |
| 39 | Feed* selectedFeed(int index = -1) const; |
| 40 | Message selectedMessage() const; |
| 41 | |
| 42 | private: |
| 43 | Ui::ArticleListNotification m_ui; |
| 44 | ArticleListNotificationModel* m_model; |
| 45 | QHash<Feed*, QList<Message>> m_newMessages; |
| 46 | }; |
| 47 | |
| 48 | #endif // ARTICLELISTNOTIFICATION_H |