Messagelib

widgetbase.h
1 /******************************************************************************
2  *
3  * SPDX-FileCopyrightText: 2008 Szymon Tomasz Stefanek <[email protected]>
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 
17 class QLineEdit;
18 class QActionGroup;
19 class QMenu;
20 
21 namespace Akonadi
22 {
23 class Collection;
24 class MessageStatus;
25 }
26 
27 namespace MessageList
28 {
29 namespace Core
30 {
31 class GroupHeaderItem;
32 class MessageItem;
33 class StorageModel;
34 class View;
35 class 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  */
40 class Widget : public QWidget
41 {
42  friend class View;
43 
44  Q_OBJECT
45 public:
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  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  QLineEdit *quickSearch() const;
67 
68  /**
69  * Returns the View attached to this Widget. Never nullptr.
70  */
71  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  */
82  Q_REQUIRED_RESULT QVector<Akonadi::MessageStatus> currentFilterStatus() const;
83 
84  /**
85  * Returns the search term in the current quicksearch field.
86  */
87  Q_REQUIRED_RESULT QString currentFilterSearchString() const;
88 
89  /**
90  * Returns the id of the MessageItem::Tag currently set in the quicksearch field.
91  */
92  Q_REQUIRED_RESULT 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  Q_REQUIRED_RESULT bool isThreaded() const;
104  /**
105  * Fast function that determines if the selection is empty
106  */
107  Q_REQUIRED_RESULT bool selectionEmpty() const;
108 
109  /**
110  * Sets the current folder.
111  */
112  void setCurrentFolder(const Akonadi::Collection &collection);
113  Q_REQUIRED_RESULT Akonadi::Collection currentFolder() const;
114 
115  void saveCurrentSelection();
116 
117  Q_REQUIRED_RESULT bool searchEditHasFocus() const;
118 
119  void sortOrderMenuAboutToShow(QMenu *menu);
120  void themeMenuAboutToShow(QMenu *menu);
121  void aggregationMenuAboutToShow(QMenu *menu);
122 
123  Q_REQUIRED_RESULT MessageList::Core::QuickSearchLine::SearchOptions currentOptions() const;
124  void setFilter(Filter *filter);
125 public 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  */
135  void changeQuicksearchVisibility(bool);
136 
137  void setLockTab(bool lock);
138  Q_REQUIRED_RESULT bool isLocked() const;
139 
140 protected:
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 QVector<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 
213 Q_SIGNALS:
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 
222 protected 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 
257 private:
258  void slotActivateFilter(Filter *f);
259  class WidgetPrivate;
260  std::unique_ptr<WidgetPrivate> const d;
261 };
262 } // namespace Core
263 } // namespace MessageList
Q_OBJECTQ_OBJECT
virtual void viewSelectionChanged()
This is called by View when selection changes.
void aggregationsChanged()
This is called by Manager when the option sets stored within have changed.
Definition: widgetbase.cpp:887
The MessageItem class.
Definition: messageitem.h:34
virtual void viewMessageActivated(MessageItem *msg)
This is called by View when a message is double-clicked or activated by other input means.
Q_SLOTSQ_SLOTS
The MessageList::View is the real display of the message list.
Definition: view.h:47
QString currentFilterSearchString() const
Returns the search term in the current quicksearch field.
Definition: widgetbase.cpp:259
QVector< Akonadi::MessageStatus > currentFilterStatus() const
Returns the Akonadi::MessageStatus in the current quicksearch field.
Definition: widgetbase.cpp:251
Core::MessageItem * currentMessageItem() const
Returns the current MessageItem in the current folder.
Definition: widgetbase.cpp:241
void changeQuicksearchVisibility(bool)
Shows or hides the quicksearch field, the filter combobox and the toolbutton for advanced search.
Definition: widgetbase.cpp:190
virtual void viewStartDragRequest()
This is called by View when a drag can possibly be started.
void setCurrentStatusFilterItem()
Must be called by fillMessageTagCombo()
Definition: widgetbase.cpp:232
Provides a widget which has the messagelist and the most important helper widgets,...
Definition: widgetbase.h:40
void slotViewHeaderSectionClicked(int logicalIndex)
Handles header section clicks switching the Aggregation MessageSorting on-the-fly.
Definition: widgetbase.cpp:837
View * view() const
Returns the View attached to this Widget.
Definition: widgetbase.cpp:386
virtual void viewMessageListContextPopupRequest(const QVector< MessageItem * > &selectedItems, const QPoint &globalPos)
This is called by View when a message is right clicked.
virtual void viewDragEnterEvent(QDragEnterEvent *e)
This is called by View when a drag enter event is received.
PreSelectionMode
Pre-selection is the action of automatically selecting a message just after the folder has finished l...
StorageModel * storageModel() const
Returns the StorageModel currently set.
Definition: widgetbase.cpp:376
QString currentFilterTagId() const
Returns the id of the MessageItem::Tag currently set in the quicksearch field.
Definition: widgetbase.cpp:267
virtual void viewDragMoveEvent(QDragMoveEvent *e)
This is called by View when a drag move event is received.
void themesChanged()
This is called by Manager when the option sets stored within have changed.
Definition: widgetbase.cpp:880
Q_SIGNALSQ_SIGNALS
void populateStatusFilterCombo()
This is called to setup the status filter's QComboBox.
Definition: widgetbase.cpp:212
void setStorageModel(StorageModel *storageModel, PreSelectionMode preSelectionMode=PreSelectLastSelected)
Sets the storage model for this Widget.
Definition: widgetbase.cpp:341
virtual void fillMessageTagCombo()
Called when the "Message Status/Tag" filter menu is opened by the user.
Definition: widgetbase.cpp:895
void statusMessage(const QString &message)
Notify the outside when updating the status bar with a message could be useful.
QLineEdit * quickSearch() const
Returns the search line of this widget.
Definition: widgetbase.cpp:381
virtual void viewGroupHeaderContextPopupRequest(GroupHeaderItem *group, const QPoint &globalPos)
This is called by View when a group header is right clicked.
void focusQuickSearch(const QString &selectedText)
Sets the focus on the quick search line of the currently active tab.
The QAbstractItemModel based interface that you need to provide for your storage to work with Message...
bool selectionEmpty() const
Fast function that determines if the selection is empty.
void setCurrentFolder(const Akonadi::Collection &collection)
Sets the current folder.
This class is responsible of matching messages that should be displayed in the View.
Definition: filter.h:44
virtual void viewMessageSelected(MessageItem *msg)
This is called by View when a message is single-clicked (thus selected and made current)
virtual void viewDropEvent(QDropEvent *e)
This is called by View when a drop event is received.
bool isThreaded() const
Returns true if the current Aggregation is threaded, false otherwise (or if there is no current Aggre...
QObject * parent() const const
QString message
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...
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Wed May 25 2022 03:55:41 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.