Mailcommon

foldertreewidget.h
1/*
2
3 SPDX-FileCopyrightText: 2009-2024 Laurent Montel <montel@kde.org>
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>
18namespace Akonadi
19{
20class StatisticsProxyModel;
21}
22
23class QLineEdit;
24class KXMLGUIClient;
25
27
28namespace MailCommon
29{
30class EntityCollectionOrderProxyModel;
31class 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 */
39class MAILCOMMON_EXPORT FolderTreeWidget : public QWidget
40{
41 Q_OBJECT
42
43public:
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 [[nodiscard]] QAbstractItemView::SelectionMode selectionMode() const;
84
85 [[nodiscard]] QItemSelectionModel *selectionModel() const;
86
87 [[nodiscard]] QModelIndex currentIndex() const;
88
89 [[nodiscard]] Akonadi::Collection selectedCollection() const;
90
91 [[nodiscard]] Akonadi::Collection::List selectedCollections() const;
92
93 [[nodiscard]] FolderTreeView *folderTreeView() const;
94
95 [[nodiscard]] Akonadi::StatisticsProxyModel *statisticsProxyModel() const;
96
97 [[nodiscard]] FolderTreeWidgetProxyModel *folderTreeWidgetProxyModel() const;
98
99 [[nodiscard]] EntityCollectionOrderProxyModel *entityOrderProxy() const;
100
101 [[nodiscard]] 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
111protected:
112 void changeToolTipsPolicyConfig(ToolTipDisplayPolicy);
113
114 [[nodiscard]] bool event(QEvent *e) override;
115
116protected Q_SLOTS:
117 void slotChangeTooltipsPolicy(FolderTreeWidget::ToolTipDisplayPolicy);
118 void slotManualSortingChanged(bool);
119 void slotFilterFixedString(const QString &);
120 void slotGeneralFontChanged();
121 void slotGeneralPaletteChanged();
122
123private:
124 bool eventFilter(QObject *o, QEvent *e) override;
125 class FolderTreeWidgetPrivate;
126 std::unique_ptr<FolderTreeWidgetPrivate> const d;
127};
128}
The EntityCollectionOrderProxyModel class implements ordering of mail collections.
This is an enhanced EntityTreeView specially suited for the folders in KMail's main folder widget.
The FolderTreeWidgetProxyModel class.
This is the widget that shows the main folder tree.
SortingPolicy
The available sorting policies.
@ SortByCurrentColumn
Columns are clickable, sorting is by the current column.
ToolTipDisplayPolicy
The possible tooltip display policies.
@ DisplayWhenTextElided
Display the tooltip if the item text is actually elided.
@ DisplayAlways
Always display a tooltip when hovering over an item.
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:39:23 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.