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 AccountActivitiesAbstract;
21}
22namespace Akonadi
23{
24class StatisticsProxyModel;
25}
26
27class QLineEdit;
28class KXMLGUIClient;
29
31
32namespace MailCommon
33{
34class EntityCollectionOrderProxyModel;
35class FolderTreeView;
36
37/**
38 * This is the widget that shows the main folder tree.
39 *
40 * It consists of the view (FolderTreeView) and a search line.
41 * Internally, several proxy models are used on top of a entity tree model.
42 */
43class MAILCOMMON_EXPORT FolderTreeWidget : public QWidget
44{
45 Q_OBJECT
46
47public:
48 enum TreeViewOption {
49 None = 0,
50 ShowUnreadCount = 1,
51 UseLineEditForFiltering = 2,
52 UseDistinctSelectionModel = 4,
53 ShowCollectionStatisticAnimation = 8,
54 DontKeyFilter = 16,
55 HideStatistics = 32,
56 HideHeaderViewMenu = 64
57 };
58 Q_DECLARE_FLAGS(TreeViewOptions, TreeViewOption)
59
60 explicit FolderTreeWidget(QWidget *parent = nullptr,
61 KXMLGUIClient *xmlGuiClient = nullptr,
62 TreeViewOptions options = (TreeViewOptions)(ShowUnreadCount | ShowCollectionStatisticAnimation),
63 FolderTreeWidgetProxyModel::FolderTreeWidgetProxyModelOptions optReadableProxy = FolderTreeWidgetProxyModel::None);
64 ~FolderTreeWidget() override;
65
66 /**
67 * The possible tooltip display policies.
68 */
70 DisplayAlways, ///< Always display a tooltip when hovering over an item
71 DisplayWhenTextElided, ///< Display the tooltip if the item text is actually elided
72 DisplayNever ///< Nevery display tooltips
73 };
74
75 /**
76 * The available sorting policies.
77 */
79 SortByCurrentColumn, ///< Columns are clickable, sorting is by the current column
80 SortByDragAndDropKey ///< Columns are NOT clickable, sorting is done by drag and drop
81 };
82
83 void selectCollectionFolder(const Akonadi::Collection &col, bool expand = true);
84
85 void setSelectionMode(QAbstractItemView::SelectionMode mode);
86
87 [[nodiscard]] QAbstractItemView::SelectionMode selectionMode() const;
88
89 [[nodiscard]] QItemSelectionModel *selectionModel() const;
90
91 [[nodiscard]] QModelIndex currentIndex() const;
92
93 [[nodiscard]] Akonadi::Collection selectedCollection() const;
94
95 [[nodiscard]] Akonadi::Collection::List selectedCollections() const;
96
97 [[nodiscard]] FolderTreeView *folderTreeView() const;
98
99 [[nodiscard]] Akonadi::StatisticsProxyModel *statisticsProxyModel() const;
100
101 [[nodiscard]] FolderTreeWidgetProxyModel *folderTreeWidgetProxyModel() const;
102
103 [[nodiscard]] EntityCollectionOrderProxyModel *entityOrderProxy() const;
104
105 [[nodiscard]] QLineEdit *filterFolderLineEdit() const;
106 void applyFilter(const QString &);
107 void clearFilter();
108
109 void disableContextMenuAndExtraColumn();
110
111 void readConfig();
112
113 void restoreHeaderState(const QByteArray &data);
114
115 void setAccountActivities(Akonadi::AccountActivitiesAbstract *accountActivities);
116
117protected:
118 void changeToolTipsPolicyConfig(ToolTipDisplayPolicy);
119
120 [[nodiscard]] bool event(QEvent *e) override;
121
122protected Q_SLOTS:
123 void slotChangeTooltipsPolicy(FolderTreeWidget::ToolTipDisplayPolicy);
124 void slotManualSortingChanged(bool);
125 void slotFilterFixedString(const QString &);
126 void slotGeneralFontChanged();
127 void slotGeneralPaletteChanged();
128
129private:
130 bool eventFilter(QObject *o, QEvent *e) override;
131 class FolderTreeWidgetPrivate;
132 std::unique_ptr<FolderTreeWidgetPrivate> const d;
133};
134}
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 Fri Oct 11 2024 12:18:39 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.