Mailcommon

foldertreeview.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 "foldertreewidget.h"
11#include "mailcommon/mailutil.h"
12#include "mailcommon_export.h"
13
14#include <Akonadi/Collection>
15#include <Akonadi/EntityTreeView>
16
17class QMouseEvent;
18
19namespace Akonadi
20{
21class CollectionStatisticsDelegate;
22}
23
24namespace MailCommon
25{
26/**
27 * This is an enhanced EntityTreeView specially suited for the folders in KMail's
28 * main folder widget.
29 */
30class MAILCOMMON_EXPORT FolderTreeView : public Akonadi::EntityTreeView
31{
32 Q_OBJECT
33
34public:
35 explicit FolderTreeView(QWidget *parent = nullptr, bool showUnreadCount = true);
36
37 explicit FolderTreeView(KXMLGUIClient *xmlGuiClient, QWidget *parent = nullptr, bool showUnreadCount = true);
38
39 ~FolderTreeView() override;
40
41 void selectNextUnreadFolder(bool confirm = false);
42 void selectPrevUnreadFolder(bool confirm = false);
43
44 void showStatisticAnimation(bool anim);
45
46 void disableContextMenuAndExtraColumn();
47
48 void setTooltipsPolicy(FolderTreeWidget::ToolTipDisplayPolicy);
49
50 void restoreHeaderState(const QByteArray &data);
51
52 [[nodiscard]] Akonadi::Collection currentFolder() const;
53
54 void disableSaveConfig();
55 void readConfig();
56
57 void updatePalette();
58
59 void keyboardSearch(const QString &) override;
60
61 void setEnableDragDrop(bool enabled);
62
63protected:
64 enum Move {
65 Next = 0,
66 Previous = 1,
67 };
68
69 void init(bool showUnreadCount);
70 void selectModelIndex(const QModelIndex &);
71 void setCurrentModelIndex(const QModelIndex &);
72 QModelIndex selectNextFolder(const QModelIndex &current);
73 bool isUnreadFolder(const QModelIndex &current, QModelIndex &nextIndex, FolderTreeView::Move move, bool confirm);
74 void writeConfig();
75
76 void setSortingPolicy(FolderTreeWidget::SortingPolicy policy, bool writeInConfig = false);
77
78 void mousePressEvent(QMouseEvent *e) override;
79
80public Q_SLOTS:
81 void slotFocusNextFolder();
82 void slotFocusPrevFolder();
83 void slotSelectFocusFolder();
84 void slotFocusFirstFolder();
85 void slotFocusLastFolder();
86
87protected Q_SLOTS:
88 void slotHeaderContextMenuRequested(const QPoint &);
89 void slotHeaderContextMenuChangeIconSize(bool);
90 void slotHeaderContextMenuChangeHeader(bool);
91 void slotHeaderContextMenuChangeToolTipDisplayPolicy(bool);
92 void slotHeaderContextMenuChangeSortingPolicy(bool);
93
94Q_SIGNALS:
95 void changeTooltipsPolicy(FolderTreeWidget::ToolTipDisplayPolicy);
96 void manualSortingChanged(bool actif);
97 void newTabRequested(bool);
98
99private:
100 enum SearchDirection {
101 ForwardSearch,
102 BackwardSearch,
103 };
104
105 MAILCOMMON_NO_EXPORT QModelIndex indexAbove(const QModelIndex &current) const;
106 MAILCOMMON_NO_EXPORT QModelIndex indexBelow(const QModelIndex &current) const;
107 MAILCOMMON_NO_EXPORT QModelIndex lastChild(const QModelIndex &current) const;
108 MAILCOMMON_NO_EXPORT QModelIndex nextUnreadCollection(const QModelIndex &current, SearchDirection direction) const;
109
110 MAILCOMMON_NO_EXPORT bool ignoreUnreadFolder(const Akonadi::Collection &, bool) const;
111 MAILCOMMON_NO_EXPORT bool allowedToEnterFolder(const Akonadi::Collection &, bool) const;
112 MAILCOMMON_NO_EXPORT bool trySelectNextUnreadFolder(const QModelIndex &, SearchDirection, bool);
113
114 FolderTreeWidget::ToolTipDisplayPolicy mToolTipDisplayPolicy;
115 FolderTreeWidget::SortingPolicy mSortingPolicy;
116 Akonadi::CollectionStatisticsDelegate *mCollectionStatisticsDelegate = nullptr;
117 bool mbDisableContextMenuAndExtraColumn = false;
118 bool mbDisableSaveConfig = false;
119};
120}
This is an enhanced EntityTreeView specially suited for the folders in KMail's main folder widget.
SortingPolicy
The available sorting policies.
ToolTipDisplayPolicy
The possible tooltip display policies.
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 4 2024 12:04:33 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.