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 /**
93 * Sets the focus on the quick search line of the currently active tab.
94 */
95 void focusQuickSearch(const QString &selectedText);
96
97 /**
98 * Returns true if the current Aggregation is threaded, false otherwise
99 * (or if there is no current Aggregation).
100 */
101 [[nodiscard]] bool isThreaded() const;
102 /**
103 * Fast function that determines if the selection is empty
104 */
105 [[nodiscard]] bool selectionEmpty() const;
106
107 /**
108 * Sets the current folder.
109 */
110 void setCurrentFolder(const Akonadi::Collection &collection);
111 [[nodiscard]] Akonadi::Collection currentFolder() const;
112
113 void saveCurrentSelection();
114
115 [[nodiscard]] bool searchEditHasFocus() const;
116
117 void sortOrderMenuAboutToShow(QMenu *menu);
118 void themeMenuAboutToShow(QMenu *menu);
119 void aggregationMenuAboutToShow(QMenu *menu);
120
121 [[nodiscard]] MessageList::Core::SearchMessageByButtons::SearchOptions currentOptions() const;
122 void setFilter(Filter *filter);
123public Q_SLOTS:
124
125 /**
126 * This is called to setup the status filter's QComboBox.
127 */
129
130 /**
131 * Shows or hides the quicksearch field, the filter combobox and the toolbutton for advanced search.
132 */
134
135 void setLockTab(bool lock);
136 [[nodiscard]] bool isLocked() const;
137
138protected:
139 /**
140 * Called when the "Message Status/Tag" filter menu is opened by the user.
141 * You may override this function in order to add some "custom tag" entries
142 * to the menu. The entries should be placed in a QActionGroup which should be returned
143 * to the caller. The QAction objects associated to the entries should have
144 * the string id of the tag set as data() and the tag icon set as icon().
145 * The default implementation does nothing.
146 *
147 * Once the tag retrieval is complete call setCurrentStatusFilterItem()
148 */
149 virtual void fillMessageTagCombo();
150
151 void addMessageTagItem(const QPixmap &, const QString &, const QVariant &);
152
153 /**
154 * Must be called by fillMessageTagCombo()
155 */
157
158 /**
159 * This is called by View when a message is single-clicked (thus selected and made current)
160 */
161 virtual void viewMessageSelected(MessageItem *msg);
162
163 /**
164 * This is called by View when a message is double-clicked or activated by other input means
165 */
166 virtual void viewMessageActivated(MessageItem *msg);
167
168 /**
169 * This is called by View when selection changes.
170 */
171 virtual void viewSelectionChanged();
172
173 /**
174 * This is called by View when a message is right clicked.
175 */
176 virtual void viewMessageListContextPopupRequest(const QList<MessageItem *> &selectedItems, const QPoint &globalPos);
177
178 /**
179 * This is called by View when a group header is right clicked.
180 */
181 virtual void viewGroupHeaderContextPopupRequest(GroupHeaderItem *group, const QPoint &globalPos);
182
183 /**
184 * This is called by View when a drag enter event is received
185 */
186 virtual void viewDragEnterEvent(QDragEnterEvent *e);
187
188 /**
189 * This is called by View when a drag move event is received
190 */
191 virtual void viewDragMoveEvent(QDragMoveEvent *e);
192
193 /**
194 * This is called by View when a drop event is received
195 */
196 virtual void viewDropEvent(QDropEvent *e);
197
198 /**
199 * This is called by View when a drag can possibly be started
200 */
201 virtual void viewStartDragRequest();
202
203 /**
204 * This is called by View when a message item is manipulated by the user
205 * in a way that it's status should change. (e.g, by clicking on a status icon, for example).
206 */
208
209 void tagIdSelected(const QVariant &data);
210
212 /**
213 * Notify the outside when updating the status bar with a message
214 * could be useful
215 */
216 void statusMessage(const QString &message);
217 void forceLostFocus();
218 void unlockTabRequested();
219
220protected Q_SLOTS:
221 /**
222 * This is called by Manager when the option sets stored within have changed.
223 */
224 void aggregationsChanged();
225
226 /**
227 * This is called by Manager when the option sets stored within have changed.
228 */
229 void themesChanged();
230
231 void themeMenuAboutToShow();
232 void aggregationMenuAboutToShow();
233 void themeSelected(bool);
234 void configureThemes();
235 void setPrivateSortOrderForStorage();
236 void aggregationSelected(bool);
237 void statusSelected(int index);
238 void searchEditTextEdited();
239 void searchTimerFired();
240 void searchEditClearButtonClicked();
241 void sortOrderMenuAboutToShow();
242 void messageSortingSelected(QAction *action);
243 void messageSortDirectionSelected(QAction *action);
244 void groupSortingSelected(QAction *action);
245 void groupSortDirectionSelected(QAction *action);
246 void resetFilter();
247
248 /**
249 * Handles header section clicks switching the Aggregation MessageSorting on-the-fly.
250 */
251 void slotViewHeaderSectionClicked(int logicalIndex);
252 void slotStatusButtonsClicked();
253 void slotSaveFilter();
254
255private:
256 void slotActivateFilter(Filter *f);
257 class WidgetPrivate;
258 std::unique_ptr<WidgetPrivate> const d;
259};
260} // namespace Core
261} // 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
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.
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)
The implementation independent part of the MessageList library.
Definition aggregation.h:22
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
QWidget(QWidget *parent, Qt::WindowFlags f)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Mar 28 2025 11:49:15 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.