Akonadi

statisticsproxymodel.h
1/*
2 SPDX-FileCopyrightText: 2009 Kevin Ottens <ervin@kde.org>
3 2016 David Faure <faure@kde.org>s
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#pragma once
9
10#include "akonadicore_export.h"
11
12#include <KExtraColumnsProxyModel>
13
14#include <memory>
15
16namespace Akonadi
17{
18class StatisticsProxyModelPrivate;
19
20/**
21 * @short A proxy model that exposes collection statistics through extra columns.
22 *
23 * This class can be used on top of an EntityTreeModel to display extra columns
24 * summarizing statistics of collections.
25 *
26 * @code
27 *
28 * Akonadi::EntityTreeModel *model = new Akonadi::EntityTreeModel( ... );
29 *
30 * Akonadi::StatisticsProxyModel *proxy = new Akonadi::StatisticsProxyModel();
31 * proxy->setSourceModel( model );
32 *
33 * Akonadi::EntityTreeView *view = new Akonadi::EntityTreeView( this );
34 * view->setModel( proxy );
35 *
36 * @endcode
37 *
38 * @author Kevin Ottens <ervin@kde.org>, now maintained by David Faure <faure@kde.org>
39 * @since 4.4
40 */
41class AKONADICORE_EXPORT StatisticsProxyModel : public KExtraColumnsProxyModel
42{
43 Q_OBJECT
44
45public:
46 /**
47 * Creates a new statistics proxy model.
48 *
49 * @param parent The parent object.
50 */
51 explicit StatisticsProxyModel(QObject *parent = nullptr);
52
53 /**
54 * Destroys the statistics proxy model.
55 */
57
58 /**
59 * @param enable Display tooltips
60 * By default, tooltips are disabled.
61 */
62 void setToolTipEnabled(bool enable);
63
64 /**
65 * Return true if we display tooltips, otherwise false
66 */
67 [[nodiscard]] bool isToolTipEnabled() const;
68
69 /**
70 * @param enable Display extra statistics columns
71 * By default, the extra columns are enabled.
72 */
73 void setExtraColumnsEnabled(bool enable);
74
75 /**
76 * Return true if we display extra statistics columns, otherwise false
77 */
78 [[nodiscard]] bool isExtraColumnsEnabled() const;
79
80 [[nodiscard]] QVariant extraColumnData(const QModelIndex &parent, int row, int extraColumn, int role) const override;
81 [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
82 [[nodiscard]] Qt::ItemFlags flags(const QModelIndex &index) const override;
83
84 [[nodiscard]] QModelIndexList match(const QModelIndex &start,
85 int role,
86 const QVariant &value,
87 int hits = 1,
89
90 void setSourceModel(QAbstractItemModel *model) override;
91
92private:
93 /// @cond PRIVATE
94 std::unique_ptr<StatisticsProxyModelPrivate> const d;
95 /// @endcond
96};
97
98}
A proxy model that exposes collection statistics through extra columns.
~StatisticsProxyModel() override
Destroys the statistics proxy model.
Q_SCRIPTABLE Q_NOREPLY void start()
Helper integration between Akonadi and Qt.
DisplayRole
typedef ItemFlags
typedef MatchFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 12 2024 11:50:58 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.