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

KDE's Doxygen guidelines are available online.