Debian Codegraph @

src/librssguard/gui/messagesview.h

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.
2
3 #ifndef MESSAGESVIEW_H
4 #define MESSAGESVIEW_H
5
6 #include "core/messagesmodel.h"
7 #include "core/messagesproxymodel.h"
8 #include "gui/reusable/basetreeview.h"
9 #include "gui/reusable/searchlineedit.h"
10 #include "services/abstract/rootitem.h"
11
12 #include <QHeaderView>
13 #include <QTimer>
14
15 class MessagesProxyModel;
16
17 class MessagesView : public BaseTreeView {
18 Q_OBJECT
19
20 public:
21 enum class ArticleMarkingPolicy {
22 // Article is marked as read right when selected.
23 MarkImmediately = 0,
24
25 // Article is marked as read with some configured delay.
26 MarkWithDelay = 1,
27
28 // Article is never marked as read on selection.
29 MarkOnlyManually = 2
30 };
31
32 explicit MessagesView(QWidget* parent = nullptr);
33 virtual ~MessagesView();
34
35 MessagesProxyModel* model() const;
36 MessagesModel* sourceModel() const;
37
38 void reloadFontSettings();
39 void setupArticleMarkingPolicy();
40
41 QByteArray saveHeaderState() const;
42 void restoreHeaderState(const QByteArray& dta);
43
44 public slots:
45 void copyUrlOfSelectedArticles() const;
46
47 void keyboardSearch(const QString& search);
48
49 // Called after data got changed externally
50 // and it needs to be reloaded to the view.
51 void reloadSelections();
52
53 // Loads un-deleted messages from selected feeds.
54 void loadItem(RootItem* item);
55
56 // Message manipulators.
57 #if defined(ENABLE_MEDIAPLAYER)
58 void playSelectedArticleInMediaPlayer();
59 #endif
60
61 void openSelectedSourceMessagesExternally();
62 void openSelectedMessagesInternally();
63 void openSelectedMessageUrl();
64 void sendSelectedMessageViaEmail();
65
66 // Works with SELECTED messages only.
67 void setSelectedMessagesReadStatus(RootItem::ReadStatus read);
68 void markSelectedMessagesRead();
69 void markSelectedMessagesUnread();
70 void switchSelectedMessagesImportance();
71 void deleteSelectedMessages();
72 void restoreSelectedMessages();
73
74 void selectNextItem();
75 void selectPreviousItem();
76 void selectItemWithCursorAction(QAbstractItemView::CursorAction act);
77
78 void selectNextUnreadItem();
79
80 // Searchs the visible message according to given pattern.
81 void searchMessages(SearchLineEdit::SearchMode mode,
82 Qt::CaseSensitivity sensitivity,
83 int custom_criteria,
84 const QString& phrase);
85
86 void highlightMessages(MessagesModel::MessageHighlighter highlighter);
87 void changeFilter(MessagesProxyModel::MessageListFilter filter);
88
89 private slots:
90 void openSelectedMessagesWithExternalTool();
91
92 // Marks given indexes as selected.
93 void reselectIndexes(const QModelIndexList& indexes);
94
95 // Changes resize mode for all columns.
96 void adjustColumns();
97
98 void markSelectedMessagesReadDelayed();
99
100 // Saves current sort state.
101 void onSortIndicatorChanged(int column, Qt::SortOrder order);
102
103 signals:
104 #if defined(ENABLE_MEDIAPLAYER)
105 void playLinkInMediaPlayer(const QString& link);
106 #endif
107
108 void openLinkNewTab(const QString& link);
109 void openLinkMiniBrowser(const QString& link);
110 void openSingleMessageInNewTab(RootItem* root, const Message& message);
111
112 // Notify others about message selections.
113 void currentMessageChanged(const Message& message, RootItem* root);
114 void currentMessageRemoved(RootItem* root);
115 void willReselectSameMessage();
116
117 private:
118 void sort(int column,
119 Qt::SortOrder order,
120 bool repopulate_data,
121 bool change_header,
122 bool emit_changed_from_header,
123 bool ignore_multicolumn_sorting,
124 int additional_article_id = 0);
125
126 // Creates needed connections.
127 void createConnections();
128
129 // Initializes context menu.
130 void initializeContextMenu();
131
132 // Sets up appearance.
133 void setupAppearance();
134
135 // Event reimplementations.
136 void focusInEvent(QFocusEvent* event);
137 void contextMenuEvent(QContextMenuEvent* event);
138 void mousePressEvent(QMouseEvent* event);
139 void mouseMoveEvent(QMouseEvent* event);
140 void keyPressEvent(QKeyEvent* event);
141 void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
142
143 QMenu* m_contextMenu;
144 MessagesProxyModel* m_proxyModel;
145 MessagesModel* m_sourceModel;
146 bool m_columnsAdjusted;
147 bool m_processingAnyMouseButton;
148 bool m_processingRightMouseButton;
149 ArticleMarkingPolicy m_articleMarkingPolicy;
150 int m_articleMarkingDelay;
151 QTimer m_delayedArticleMarker;
152 QModelIndex m_delayedArticleIndex;
153 };
154
155 inline MessagesProxyModel* MessagesView::model() const {
156 return m_proxyModel;
157 }
158
159 inline MessagesModel* MessagesView::sourceModel() const {
160 return m_sourceModel;
161 }
162
163 #endif // MESSAGESVIEW_H