Mailcommon

foldertreewidget.h
1 /*
2 
3  SPDX-FileCopyrightText: 2009-2023 Laurent Montel <[email protected]>
4 
5  SPDX-License-Identifier: GPL-2.0-or-later
6 */
7 
8 #pragma once
9 
10 #include "foldertreewidgetproxymodel.h"
11 #include "mailcommon_export.h"
12 
13 #include <Akonadi/Collection>
14 
15 #include <QAbstractItemView>
16 #include <QWidget>
17 #include <memory>
18 namespace Akonadi
19 {
20 class StatisticsProxyModel;
21 }
22 
23 class QLineEdit;
24 class KXMLGUIClient;
25 
27 
28 namespace MailCommon
29 {
30 class EntityCollectionOrderProxyModel;
31 class FolderTreeView;
32 
33 /**
34  * This is the widget that shows the main folder tree.
35  *
36  * It consists of the view (FolderTreeView) and a search line.
37  * Internally, several proxy models are used on top of a entity tree model.
38  */
39 class MAILCOMMON_EXPORT FolderTreeWidget : public QWidget
40 {
41  Q_OBJECT
42 
43 public:
44  enum TreeViewOption {
45  None = 0,
46  ShowUnreadCount = 1,
47  UseLineEditForFiltering = 2,
48  UseDistinctSelectionModel = 4,
49  ShowCollectionStatisticAnimation = 8,
50  DontKeyFilter = 16,
51  HideStatistics = 32,
52  HideHeaderViewMenu = 64
53  };
54  Q_DECLARE_FLAGS(TreeViewOptions, TreeViewOption)
55 
56  explicit FolderTreeWidget(QWidget *parent = nullptr,
57  KXMLGUIClient *xmlGuiClient = nullptr,
58  TreeViewOptions options = (TreeViewOptions)(ShowUnreadCount | ShowCollectionStatisticAnimation),
59  FolderTreeWidgetProxyModel::FolderTreeWidgetProxyModelOptions optReadableProxy = FolderTreeWidgetProxyModel::None);
60  ~FolderTreeWidget() override;
61 
62  /**
63  * The possible tooltip display policies.
64  */
66  DisplayAlways, ///< Always display a tooltip when hovering over an item
67  DisplayWhenTextElided, ///< Display the tooltip if the item text is actually elided
68  DisplayNever ///< Nevery display tooltips
69  };
70 
71  /**
72  * The available sorting policies.
73  */
75  SortByCurrentColumn, ///< Columns are clickable, sorting is by the current column
76  SortByDragAndDropKey ///< Columns are NOT clickable, sorting is done by drag and drop
77  };
78 
79  void selectCollectionFolder(const Akonadi::Collection &col, bool expand = true);
80 
81  void setSelectionMode(QAbstractItemView::SelectionMode mode);
82 
83  Q_REQUIRED_RESULT QAbstractItemView::SelectionMode selectionMode() const;
84 
85  Q_REQUIRED_RESULT QItemSelectionModel *selectionModel() const;
86 
87  Q_REQUIRED_RESULT QModelIndex currentIndex() const;
88 
89  Q_REQUIRED_RESULT Akonadi::Collection selectedCollection() const;
90 
91  Q_REQUIRED_RESULT Akonadi::Collection::List selectedCollections() const;
92 
93  Q_REQUIRED_RESULT FolderTreeView *folderTreeView() const;
94 
95  Q_REQUIRED_RESULT Akonadi::StatisticsProxyModel *statisticsProxyModel() const;
96 
97  Q_REQUIRED_RESULT FolderTreeWidgetProxyModel *folderTreeWidgetProxyModel() const;
98 
99  Q_REQUIRED_RESULT EntityCollectionOrderProxyModel *entityOrderProxy() const;
100 
101  Q_REQUIRED_RESULT QLineEdit *filterFolderLineEdit() const;
102  void applyFilter(const QString &);
103  void clearFilter();
104 
105  void disableContextMenuAndExtraColumn();
106 
107  void readConfig();
108 
109  void restoreHeaderState(const QByteArray &data);
110 
111 protected:
112  void changeToolTipsPolicyConfig(ToolTipDisplayPolicy);
113 
114  Q_REQUIRED_RESULT bool event(QEvent *e) override;
115 
116 protected Q_SLOTS:
117  void slotChangeTooltipsPolicy(FolderTreeWidget::ToolTipDisplayPolicy);
118  void slotManualSortingChanged(bool);
119  void slotFilterFixedString(const QString &);
120  void slotGeneralFontChanged();
121  void slotGeneralPaletteChanged();
122 
123 private:
124  bool eventFilter(QObject *o, QEvent *e) override;
125  class FolderTreeWidgetPrivate;
126  std::unique_ptr<FolderTreeWidgetPrivate> const d;
127 };
128 }
@ DisplayWhenTextElided
Display the tooltip if the item text is actually elided.
SortingPolicy
The available sorting policies.
@ DisplayAlways
Always display a tooltip when hovering over an item.
The EntityCollectionOrderProxyModel class implements ordering of mail collections.
This is the widget that shows the main folder tree.
The FolderTreeWidgetProxyModel class.
ToolTipDisplayPolicy
The possible tooltip display policies.
This is an enhanced EntityTreeView specially suited for the folders in KMail's main folder widget.
@ SortByCurrentColumn
Columns are clickable, sorting is by the current column.
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Sep 22 2023 03:58:42 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.