Akonadi

collectionstatisticsdelegate.h
1/*
2 SPDX-FileCopyrightText: 2008 Thomas McGuire <thomas.mcguire@gmx.net>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6#pragma once
7
8#include "akonadiwidgets_export.h"
9
10#include <QStyledItemDelegate>
11
12#include <memory>
13
15class QTreeView;
16
17namespace Akonadi
18{
19class CollectionStatisticsDelegatePrivate;
20
21/**
22 * @short A delegate that draws unread and total count for StatisticsProxyModel.
23 *
24 * The delegate provides the following features:
25 *
26 * - Collections with unread items will have the foldername and the unread
27 * column marked in bold.
28 * - If a folder is collapsed, the unread and the total column will contain
29 * the total sum of all child folders
30 * - It has the possibility to draw the unread count directly after the
31 * foldername, see toggleUnreadAfterFolderName().
32 *
33 * Example:
34 * @code
35 *
36 * Akonadi::EntityTreeView *view = new Akonadi::EntityTreeView( this );
37 *
38 * Akonadi::StatisticsProxyModel *statisticsProxy = new Akonadi::StatisticsProxyModel( view );
39 * view->setModel( statisticsProxy );
40 *
41 * Akonadi::CollectionStatisticsDelegate *delegate = new Akonadi::CollectionStatisticsDelegate( view );
42 * view->setItemDelegate( delegate );
43 *
44 * @endcode
45 *
46 * @note This proxy model is intended to be used on top of the EntityTreeModel. One of the proxies
47 * between the EntityTreeModel (the root model) and the view must be a StatisticsProxyModel. That
48 * proxy model may appear anywhere in the chain.
49 *
50 * @author Thomas McGuire <thomas.mcguire@gmx.net>
51 */
52class AKONADIWIDGETS_EXPORT CollectionStatisticsDelegate : public QStyledItemDelegate
53{
54 Q_OBJECT
55
56public:
57 /**
58 * Creates a new collection statistics delegate.
59 *
60 * @param parent The parent item view, which will also take ownership.
61 *
62 * @since 4.6
63 */
65
66 /**
67 * Creates a new collection statistics delegate.
68 *
69 * @param parent The parent tree view, which will also take ownership.
70 */
72
73 /**
74 * Destroys the collection statistics delegate.
75 */
77
78 /**
79 * @since 4.9.1
80 */
81 void updatePalette();
82
83 /**
84 * Sets whether the unread count is drawn next to the folder name.
85 *
86 * You probably want to enable this when the unread count is hidden only.
87 * This is disabled by default.
88 *
89 * @param enable If @c true, the unread count is drawn next to the folder name,
90 * if @c false, the folder name will be drawn normally.
91 */
92 void setUnreadCountShown(bool enable);
93
94 /**
95 * Returns whether the unread count is drawn next to the folder name.
96 */
97 [[nodiscard]] bool unreadCountShown() const;
98
99 /**
100 * @param enable new mode of progress animation
101 */
102 void setProgressAnimationEnabled(bool enable);
103
104 [[nodiscard]] bool progressAnimationEnabled() const;
105
106protected:
107 /**
108 * @param painter pointer for QPainter to use in method
109 * @param option style options
110 * @param index model index (QModelIndex)
111 */
112 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
113
114 /**
115 * @param option style option view item
116 * @param index model index (QModelIndex)
117 */
118 void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override;
119
120private:
121 /// @cond PRIVATE
122 std::unique_ptr<CollectionStatisticsDelegatePrivate> const d_ptr;
123 /// @endcond
124
125 Q_DECLARE_PRIVATE(CollectionStatisticsDelegate)
126};
127
128}
A delegate that draws unread and total count for StatisticsProxyModel.
~CollectionStatisticsDelegate() override
Destroys the collection statistics delegate.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.