Mailcommon

foldertreeview.h
1 /*
2 
3  SPDX-FileCopyrightText: 2009-2022 Laurent Montel <[email protected]>
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 
17 class QMouseEvent;
18 
19 namespace Akonadi
20 {
21 class CollectionStatisticsDelegate;
22 }
23 
24 namespace MailCommon
25 {
26 /**
27  * This is an enhanced EntityTreeView specially suited for the folders in KMail's
28  * main folder widget.
29  */
30 class MAILCOMMON_EXPORT FolderTreeView : public Akonadi::EntityTreeView
31 {
32  Q_OBJECT
33 
34 public:
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  Q_REQUIRED_RESULT 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 
63 protected:
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 
80 public Q_SLOTS:
81  void slotFocusNextFolder();
82  void slotFocusPrevFolder();
83  void slotSelectFocusFolder();
84  void slotFocusFirstFolder();
85  void slotFocusLastFolder();
86 
87 protected Q_SLOTS:
88  void slotHeaderContextMenuRequested(const QPoint &);
89  void slotHeaderContextMenuChangeIconSize(bool);
90  void slotHeaderContextMenuChangeHeader(bool);
91  void slotHeaderContextMenuChangeToolTipDisplayPolicy(bool);
92  void slotHeaderContextMenuChangeSortingPolicy(bool);
93 
94 Q_SIGNALS:
95  void changeTooltipsPolicy(FolderTreeWidget::ToolTipDisplayPolicy);
96  void manualSortingChanged(bool actif);
97  void newTabRequested(bool);
98 
99 private:
100  enum SearchDirection { ForwardSearch, BackwardSearch };
101 
102  QModelIndex indexAbove(const QModelIndex &current) const;
103  QModelIndex indexBelow(const QModelIndex &current) const;
104  QModelIndex lastChild(const QModelIndex &current) const;
105  QModelIndex nextUnreadCollection(const QModelIndex &current, SearchDirection direction) const;
106 
107  bool ignoreUnreadFolder(const Akonadi::Collection &, bool) const;
108  bool allowedToEnterFolder(const Akonadi::Collection &, bool) const;
109  bool trySelectNextUnreadFolder(const QModelIndex &, SearchDirection, bool);
110 
111  FolderTreeWidget::ToolTipDisplayPolicy mToolTipDisplayPolicy;
112  FolderTreeWidget::SortingPolicy mSortingPolicy;
113  Akonadi::CollectionStatisticsDelegate *mCollectionStatisticsDelegate = nullptr;
114  bool mbDisableContextMenuAndExtraColumn = false;
115  bool mbDisableSaveConfig = false;
116 };
117 }
QCA_EXPORT void init()
SortingPolicy
The available sorting policies.
ToolTipDisplayPolicy
The possible tooltip display policies.
This is an enhanced EntityTreeView specially suited for the folders in KMail's main folder widget.
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Oct 1 2022 04:00:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.