Warning, file /pim/mailcommon/src/folder/foldertreewidget.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 0003 SPDX-FileCopyrightText: 2009-2024 Laurent Montel <montel@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include "foldertreewidgetproxymodel.h" 0011 #include "mailcommon_export.h" 0012 0013 #include <Akonadi/Collection> 0014 0015 #include <QAbstractItemView> 0016 #include <QWidget> 0017 #include <memory> 0018 namespace Akonadi 0019 { 0020 class StatisticsProxyModel; 0021 } 0022 0023 class QLineEdit; 0024 class KXMLGUIClient; 0025 0026 class QItemSelectionModel; 0027 0028 namespace MailCommon 0029 { 0030 class EntityCollectionOrderProxyModel; 0031 class FolderTreeView; 0032 0033 /** 0034 * This is the widget that shows the main folder tree. 0035 * 0036 * It consists of the view (FolderTreeView) and a search line. 0037 * Internally, several proxy models are used on top of a entity tree model. 0038 */ 0039 class MAILCOMMON_EXPORT FolderTreeWidget : public QWidget 0040 { 0041 Q_OBJECT 0042 0043 public: 0044 enum TreeViewOption { 0045 None = 0, 0046 ShowUnreadCount = 1, 0047 UseLineEditForFiltering = 2, 0048 UseDistinctSelectionModel = 4, 0049 ShowCollectionStatisticAnimation = 8, 0050 DontKeyFilter = 16, 0051 HideStatistics = 32, 0052 HideHeaderViewMenu = 64 0053 }; 0054 Q_DECLARE_FLAGS(TreeViewOptions, TreeViewOption) 0055 0056 explicit FolderTreeWidget(QWidget *parent = nullptr, 0057 KXMLGUIClient *xmlGuiClient = nullptr, 0058 TreeViewOptions options = (TreeViewOptions)(ShowUnreadCount | ShowCollectionStatisticAnimation), 0059 FolderTreeWidgetProxyModel::FolderTreeWidgetProxyModelOptions optReadableProxy = FolderTreeWidgetProxyModel::None); 0060 ~FolderTreeWidget() override; 0061 0062 /** 0063 * The possible tooltip display policies. 0064 */ 0065 enum ToolTipDisplayPolicy { 0066 DisplayAlways, ///< Always display a tooltip when hovering over an item 0067 DisplayWhenTextElided, ///< Display the tooltip if the item text is actually elided 0068 DisplayNever ///< Nevery display tooltips 0069 }; 0070 0071 /** 0072 * The available sorting policies. 0073 */ 0074 enum SortingPolicy { 0075 SortByCurrentColumn, ///< Columns are clickable, sorting is by the current column 0076 SortByDragAndDropKey ///< Columns are NOT clickable, sorting is done by drag and drop 0077 }; 0078 0079 void selectCollectionFolder(const Akonadi::Collection &col, bool expand = true); 0080 0081 void setSelectionMode(QAbstractItemView::SelectionMode mode); 0082 0083 [[nodiscard]] QAbstractItemView::SelectionMode selectionMode() const; 0084 0085 [[nodiscard]] QItemSelectionModel *selectionModel() const; 0086 0087 [[nodiscard]] QModelIndex currentIndex() const; 0088 0089 [[nodiscard]] Akonadi::Collection selectedCollection() const; 0090 0091 [[nodiscard]] Akonadi::Collection::List selectedCollections() const; 0092 0093 [[nodiscard]] FolderTreeView *folderTreeView() const; 0094 0095 [[nodiscard]] Akonadi::StatisticsProxyModel *statisticsProxyModel() const; 0096 0097 [[nodiscard]] FolderTreeWidgetProxyModel *folderTreeWidgetProxyModel() const; 0098 0099 [[nodiscard]] EntityCollectionOrderProxyModel *entityOrderProxy() const; 0100 0101 [[nodiscard]] QLineEdit *filterFolderLineEdit() const; 0102 void applyFilter(const QString &); 0103 void clearFilter(); 0104 0105 void disableContextMenuAndExtraColumn(); 0106 0107 void readConfig(); 0108 0109 void restoreHeaderState(const QByteArray &data); 0110 0111 protected: 0112 void changeToolTipsPolicyConfig(ToolTipDisplayPolicy); 0113 0114 [[nodiscard]] bool event(QEvent *e) override; 0115 0116 protected Q_SLOTS: 0117 void slotChangeTooltipsPolicy(FolderTreeWidget::ToolTipDisplayPolicy); 0118 void slotManualSortingChanged(bool); 0119 void slotFilterFixedString(const QString &); 0120 void slotGeneralFontChanged(); 0121 void slotGeneralPaletteChanged(); 0122 0123 private: 0124 bool eventFilter(QObject *o, QEvent *e) override; 0125 class FolderTreeWidgetPrivate; 0126 std::unique_ptr<FolderTreeWidgetPrivate> const d; 0127 }; 0128 }