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  */
77  Core::MessageItem *currentMessageItem() const;
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  */
130  void populateStatusFilterCombo();
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  */
158  void setCurrentStatusFilterItem();
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  */
209  virtual void viewMessageStatusChangeRequest(MessageItem *msg, Akonadi::MessageStatus set, Akonadi::MessageStatus clear);
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
264 
The MessageItem class.
Definition: messageitem.h:34
Provides a widget which has the messagelist and the most important helper widgets, like the search line and the comboboxes for changing status filtering, aggregation etc.
Definition: widgetbase.h:40
The MessageList::View is the real display of the message list.
Definition: view.h:47
PreSelectionMode
Pre-selection is the action of automatically selecting a message just after the folder has finished l...
The QAbstractItemModel based interface that you need to provide for your storage to work with Message...
This class is responsible of matching messages that should be displayed in the View.
Definition: filter.h:32
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Nov 30 2021 23:05:48 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.