1/*
2 Copyright (c) 2006 Volker Krause <vkrause@kde.org>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#ifndef AKONADI_COLLECTIONSTATISTICSMODEL_H
21#define AKONADI_COLLECTIONSTATISTICSMODEL_H
22
23#include "akonadi_export.h"
24#include <akonadi/collectionmodel.h>
25
26namespace Akonadi {
27
28class CollectionStatisticsModelPrivate;
29
30/**
31 * @short A model that provides statistics for collections.
32 *
33 * This model extends the CollectionModel by providing additional
34 * information about the collections, e.g. the number of items
35 * in a collection, the number of read/unread items, or the total size
36 * of the collection.
37 *
38 * Example:
39 *
40 * @code
41 *
42 * QTreeView *view = new QTreeView( this );
43 *
44 * Akonadi::CollectionStatisticsModel *model = new Akonadi::CollectionStatisticsModel( view );
45 * view->setModel( model );
46 *
47 * @endcode
48 *
49 * @author Volker Krause <vkrause@kde.org>
50 * @deprecated Use Akonadi::EntityTreeModel with an Akonadi::StatisticsProxyModel on top
51 */
52class AKONADI_DEPRECATED_EXPORT CollectionStatisticsModel : public CollectionModel
53{
54 Q_OBJECT
55
56public:
57
58 /**
59 * Describes the roles for the statistics collection model.
60 */
61 enum Roles {
62 UnreadRole = CollectionModel::UserRole + 1, ///< The number of unread items in this collection.
63 TotalRole, ///< The number of items in this collection.
64 StatisticsRole, ///< A statistics object of this collection.
65 RecursiveUnreadRole, ///< The number of unread items in this collection and its children.
66 RecursiveTotalRole, ///< The number of items in this collection and its children.
67 RecursiveStatisticsRole, ///< A statistics object of this collection and its children.
68 SizeRole, ///< The total size of the items in this collection.
69 RecursiveSizeRole, ///< The total size of the items in this collection and its children.
70 UserRole = CollectionModel::UserRole + 42 ///< Role for user extensions.
71 };
72
73 /**
74 * Creates a new collection statistics model.
75 * @param parent The parent object.
76 */
77 explicit CollectionStatisticsModel(QObject *parent = 0);
78
79 /**
80 * @param parent parent model index
81 * @return column count
82 */
83 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
84
85 /**
86 * @param index model index
87 * @param role data role
88 */
89 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
90
91 /**
92 * @param section section of header
93 * @param orientation of the data
94 * @param role data role
95 */
96 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
97
98private:
99 Q_DECLARE_PRIVATE(CollectionStatisticsModel)
100};
101
102}
103
104#endif
105