Akonadi

core/collectionstatistics.h
1/*
2 SPDX-FileCopyrightText: 2006 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "akonadicore_export.h"
10
11#include <QMetaType>
12#include <QSharedDataPointer>
13
14namespace Akonadi
15{
16class CollectionStatisticsPrivate;
17
18/**
19 * @short Provides statistics information of a Collection.
20 *
21 * This class contains information such as total number of items,
22 * number of new and unread items, etc.
23 *
24 * This information might be expensive to obtain and is thus
25 * not included when fetching collections with a CollectionFetchJob.
26 * It can be retrieved separately using CollectionStatisticsJob.
27 *
28 * Example:
29 *
30 * @code
31 *
32 * Akonadi::Collection collection = ...
33 *
34 * Akonadi::CollectionStatisticsJob *job = new Akonadi::CollectionStatisticsJob( collection );
35 * connect( job, SIGNAL(result(KJob*)), SLOT(jobFinished(KJob*)) );
36 *
37 * ...
38 *
39 * MyClass::jobFinished( KJob *job )
40 * {
41 * if ( job->error() ) {
42 * qDebug() << "Error occurred";
43 * return;
44 * }
45 *
46 * CollectionStatisticsJob *statisticsJob = qobject_cast<CollectionStatisticsJob*>( job );
47 *
48 * const Akonadi::CollectionStatistics statistics = statisticsJob->statistics();
49 * qDebug() << "Unread items:" << statistics.unreadCount();
50 * }
51 *
52 * @endcode
53 *
54 * This class is implicitly shared.
55 *
56 * @author Volker Krause <vkrause@kde.org>
57 */
58class AKONADICORE_EXPORT CollectionStatistics
59{
60public:
61 /**
62 * Creates a new collection statistics object.
63 */
65
66 /**
67 * Creates a collection statistics object from an @p other one.
68 */
70
71 /**
72 * Destroys the collection statistics object.
73 */
75
76 /**
77 * Returns the number of items in this collection or @c -1 if
78 * this information is not available.
79 *
80 * @see setCount()
81 * @see unreadCount()
82 */
83 [[nodiscard]] qint64 count() const;
84
85 /**
86 * Sets the number of items in this collection.
87 *
88 * @param count The number of items.
89 * @see count()
90 */
91 void setCount(qint64 count);
92
93 /**
94 * Returns the number of unread items in this collection or @c -1 if
95 * this information is not available.
96 *
97 * @see setUnreadCount()
98 * @see count()
99 */
100 [[nodiscard]] qint64 unreadCount() const;
101
102 /**
103 * Sets the number of unread items in this collection.
104 *
105 * @param count The number of unread messages.
106 * @see unreadCount()
107 */
108 void setUnreadCount(qint64 count);
109
110 /**
111 * Returns the total size of the items in this collection or @c -1 if
112 * this information is not available.
113 *
114 * @see setSize()
115 * @since 4.3
116 */
117 [[nodiscard]] qint64 size() const;
118
119 /**
120 * Sets the total size of the items in this collection.
121 *
122 * @param size The total size of the items
123 * @see size()
124 * @since 4.3
125 */
126 void setSize(qint64 size);
127
128 /**
129 * Assigns @p other to this statistics object and returns a reference to this one.
130 */
131 CollectionStatistics &operator=(const CollectionStatistics &other);
132
133private:
134 /// @cond PRIVATE
136 /// @endcond
137};
138
139}
140
141/**
142 * Allows to output the collection statistics for debugging purposes.
143 */
144AKONADICORE_EXPORT QDebug operator<<(QDebug d, const Akonadi::CollectionStatistics &);
145
146Q_DECLARE_METATYPE(Akonadi::CollectionStatistics)
Provides statistics information of a Collection.
~CollectionStatistics()
Destroys the collection statistics object.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 12 2024 11:50:59 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.