Messagelib

widgetbase.h
1/******************************************************************************
2 *
3 * SPDX-FileCopyrightText: 2008 Szymon Tomasz Stefanek <pragma@kvirc.net>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 *
7 *******************************************************************************/
8
9#pragma once
10
11#include <QString>
12#include <QWidget>
13
14#include <MessageList/Enums>
15#include <MessageList/QuickSearchLine>
16
17class QLineEdit;
18class QActionGroup;
19class QMenu;
20
21namespace Akonadi
22{
23class Collection;
24class MessageStatus;
25}
26
27namespace MessageList
28{
29namespace Core
30{
31class GroupHeaderItem;
32class MessageItem;
33class StorageModel;
34class View;
35class Filter;
36/**
37 * Provides a widget which has the messagelist and the most important helper widgets,
38 * like the search line and the comboboxes for changing status filtering, aggregation etc.
39 */
40class Widget : public QWidget
41{
42 friend class View;
43
45public:
46 explicit Widget(QWidget *parent);
47 ~Widget() override;
48
49 /**
50 * Sets the storage model for this Widget.
51 *
52 * Pre-selection is the action of automatically selecting a message just after the folder
53 * has finished loading. See Model::setStorageModel() for more information.
54 */
55 void setStorageModel(StorageModel *storageModel, PreSelectionMode preSelectionMode = PreSelectLastSelected);
56
57 /**
58 * Returns the StorageModel currently set. May be nullptr.
59 */
60 [[nodiscard]] StorageModel *storageModel() const;
61
62 /**
63 * Returns the search line of this widget. Can be nullptr if the quick search
64 * is disabled in the global configuration.
65 */
66 [[nodiscard]] QLineEdit *quickSearch() const;
67
68 /**
69 * Returns the View attached to this Widget. Never nullptr.
70 */
71 [[nodiscard]] View *view() const;
72
73 /**
74 * Returns the current MessageItem in the current folder.
75 * May return nullptr if there is no current message or no current folder.
76 */
78
79 /**
80 * Returns the Akonadi::MessageStatus in the current quicksearch field.
81 */
83
84 /**
85 * Returns the search term in the current quicksearch field.
86 */
87 [[nodiscard]] QString currentFilterSearchString() const;
88
89 /**
90 * Returns the id of the MessageItem::Tag currently set in the quicksearch field.
91 */
92 [[nodiscard]] QString currentFilterTagId() const;
93
94 /**
95 * Sets the focus on the quick search line of the currently active tab.
96 */
97 void focusQuickSearch(const QString &selectedText);
98
99 /**
100 * Returns true if the current Aggregation is threaded, false otherwise
101 * (or if there is no current Aggregation).
102 */
103 [[nodiscard]] bool isThreaded() const;
104 /**
105 * Fast function that determines if the selection is empty
106 */
107 [[nodiscard]] bool selectionEmpty() const;
108
109 /**
110 * Sets the current folder.
111 */
112 void setCurrentFolder(const Akonadi::Collection &collection);
113 [[nodiscard]] Akonadi::Collection currentFolder() const;
114
115 void saveCurrentSelection();
116
117 [[nodiscard]] bool searchEditHasFocus() const;
118
119 void sortOrderMenuAboutToShow(QMenu *menu);
120 void themeMenuAboutToShow(QMenu *menu);
121 void aggregationMenuAboutToShow(QMenu *menu);
122
123 [[nodiscard]] MessageList::Core::SearchMessageByButtons::SearchOptions currentOptions() const;
124 void setFilter(Filter *filter);
125public Q_SLOTS:
126
127 /**
128 * This is called to setup the status filter's QComboBox.
129 */
131
132 /**
133 * Shows or hides the quicksearch field, the filter combobox and the toolbutton for advanced search.
134 */
136
137 void setLockTab(bool lock);
138 [[nodiscard]] bool isLocked() const;
139
140protected:
141 /**
142 * Called when the "Message Status/Tag" filter menu is opened by the user.
143 * You may override this function in order to add some "custom tag" entries
144 * to the menu. The entries should be placed in a QActionGroup which should be returned
145 * to the caller. The QAction objects associated to the entries should have
146 * the string id of the tag set as data() and the tag icon set as icon().
147 * The default implementation does nothing.
148 *
149 * Once the tag retrieval is complete call setCurrentStatusFilterItem()
150 */
151 virtual void fillMessageTagCombo();
152
153 void addMessageTagItem(const QPixmap &, const QString &, const QVariant &);
154
155 /**
156 * Must be called by fillMessageTagCombo()
157 */
159
160 /**
161 * This is called by View when a message is single-clicked (thus selected and made current)
162 */
163 virtual void viewMessageSelected(MessageItem *msg);
164
165 /**
166 * This is called by View when a message is double-clicked or activated by other input means
167 */
168 virtual void viewMessageActivated(MessageItem *msg);
169
170 /**
171 * This is called by View when selection changes.
172 */
173 virtual void viewSelectionChanged();
174
175 /**
176 * This is called by View when a message is right clicked.
177 */
178 virtual void viewMessageListContextPopupRequest(const QList<MessageItem *> &selectedItems, const QPoint &globalPos);
179
180 /**
181 * This is called by View when a group header is right clicked.
182 */
183 virtual void viewGroupHeaderContextPopupRequest(GroupHeaderItem *group, const QPoint &globalPos);
184
185 /**
186 * This is called by View when a drag enter event is received
187 */
188 virtual void viewDragEnterEvent(QDragEnterEvent *e);
189
190 /**
191 * This is called by View when a drag move event is received
192 */
193 virtual void viewDragMoveEvent(QDragMoveEvent *e);
194
195 /**
196 * This is called by View when a drop event is received
197 */
198 virtual void viewDropEvent(QDropEvent *e);
199
200 /**
201 * This is called by View when a drag can possibly be started
202 */
203 virtual void viewStartDragRequest();
204
205 /**
206 * This is called by View when a message item is manipulated by the user
207 * in a way that it's status should change. (e.g, by clicking on a status icon, for example).
208 */
210
211 void tagIdSelected(const QVariant &data);
212
214 /**
215 * Notify the outside when updating the status bar with a message
216 * could be useful
217 */
218 void statusMessage(const QString &message);
219 void forceLostFocus();
220 void unlockTabRequested();
221
222protected Q_SLOTS:
223 /**
224 * This is called by Manager when the option sets stored within have changed.
225 */
226 void aggregationsChanged();
227
228 /**
229 * This is called by Manager when the option sets stored within have changed.
230 */
231 void themesChanged();
232
233 void themeMenuAboutToShow();
234 void aggregationMenuAboutToShow();
235 void themeSelected(bool);
236 void configureThemes();
237 void setPrivateSortOrderForStorage();
238 void aggregationSelected(bool);
239 void statusSelected(int index);
240 void searchEditTextEdited();
241 void searchTimerFired();
242 void searchEditClearButtonClicked();
243 void sortOrderMenuAboutToShow();
244 void messageSortingSelected(QAction *action);
245 void messageSortDirectionSelected(QAction *action);
246 void groupSortingSelected(QAction *action);
247 void groupSortDirectionSelected(QAction *action);
248 void resetFilter();
249
250 /**
251 * Handles header section clicks switching the Aggregation MessageSorting on-the-fly.
252 */
253 void slotViewHeaderSectionClicked(int logicalIndex);
254 void slotStatusButtonsClicked();
255 void slotSaveFilter();
256
257private:
258 void slotActivateFilter(Filter *f);
259 class WidgetPrivate;
260 std::unique_ptr<WidgetPrivate> const d;
261};
262} // namespace Core
263} // namespace MessageList
This class is responsible of matching messages that should be displayed in the View.
Definition filter.h:34
The MessageItem class.
Definition messageitem.h:35
The QAbstractItemModel based interface that you need to provide for your storage to work with Message...
The MessageList::View is the real display of the message list.
Definition view.h:47
Provides a widget which has the messagelist and the most important helper widgets,...
Definition widgetbase.h:41
virtual void viewDragMoveEvent(QDragMoveEvent *e)
This is called by View when a drag move event is received.
bool isThreaded() const
Returns true if the current Aggregation is threaded, false otherwise (or if there is no current Aggre...
virtual void fillMessageTagCombo()
Called when the "Message Status/Tag" filter menu is opened by the user.
virtual void viewMessageStatusChangeRequest(MessageItem *msg, Akonadi::MessageStatus set, Akonadi::MessageStatus clear)
This is called by View when a message item is manipulated by the user in a way that it's status shoul...
View * view() const
Returns the View attached to this Widget.
bool selectionEmpty() const
Fast function that determines if the selection is empty.
void changeQuicksearchVisibility(bool)
Shows or hides the quicksearch field, the filter combobox and the toolbutton for advanced search.
StorageModel * storageModel() const
Returns the StorageModel currently set.
virtual void viewDropEvent(QDropEvent *e)
This is called by View when a drop event is received.
void slotViewHeaderSectionClicked(int logicalIndex)
Handles header section clicks switching the Aggregation MessageSorting on-the-fly.
virtual void viewMessageListContextPopupRequest(const QList< MessageItem * > &selectedItems, const QPoint &globalPos)
This is called by View when a message is right clicked.
void setCurrentFolder(const Akonadi::Collection &collection)
Sets the current folder.
virtual void viewSelectionChanged()
This is called by View when selection changes.
virtual void viewMessageActivated(MessageItem *msg)
This is called by View when a message is double-clicked or activated by other input means.
virtual void viewStartDragRequest()
This is called by View when a drag can possibly be started.
virtual void viewGroupHeaderContextPopupRequest(GroupHeaderItem *group, const QPoint &globalPos)
This is called by View when a group header is right clicked.
void setCurrentStatusFilterItem()
Must be called by fillMessageTagCombo()
void populateStatusFilterCombo()
This is called to setup the status filter's QComboBox.
QLineEdit * quickSearch() const
Returns the search line of this widget.
void aggregationsChanged()
This is called by Manager when the option sets stored within have changed.
void themesChanged()
This is called by Manager when the option sets stored within have changed.
QString currentFilterTagId() const
Returns the id of the MessageItem::Tag currently set in the quicksearch field.
Core::MessageItem * currentMessageItem() const
Returns the current MessageItem in the current folder.
void setStorageModel(StorageModel *storageModel, PreSelectionMode preSelectionMode=PreSelectLastSelected)
Sets the storage model for this Widget.
QList< Akonadi::MessageStatus > currentFilterStatus() const
Returns the Akonadi::MessageStatus in the current quicksearch field.
virtual void viewMessageSelected(MessageItem *msg)
This is called by View when a message is single-clicked (thus selected and made current)
virtual void viewDragEnterEvent(QDragEnterEvent *e)
This is called by View when a drag enter event is received.
void focusQuickSearch(const QString &selectedText)
Sets the focus on the quick search line of the currently active tab.
QString currentFilterSearchString() const
Returns the search term in the current quicksearch field.
void statusMessage(const QString &message)
Notify the outside when updating the status bar with a message could be useful.
Q_SCRIPTABLE bool setFilter(const QString &filter)
PreSelectionMode
Pre-selection is the action of automatically selecting a message just after the folder has finished l...
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.