Akonadi

collectionstatisticsjob.h
1/*
2 SPDX-FileCopyrightText: 2006-2007 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#include "job.h"
11
12namespace Akonadi
13{
14class Collection;
16class CollectionStatisticsJobPrivate;
17
18/**
19 * @short Job that fetches collection statistics from the Akonadi storage.
20 *
21 * This class fetches the CollectionStatistics object for a given collection.
22 *
23 * Example:
24 *
25 * @code
26 *
27 * Akonadi::Collection collection = ...
28 *
29 * Akonadi::CollectionStatisticsJob *job = new Akonadi::CollectionStatisticsJob( collection );
30 * connect( job, SIGNAL(result(KJob*)), SLOT(jobFinished(KJob*)) );
31 *
32 * ...
33 *
34 * MyClass::jobFinished( KJob *job )
35 * {
36 * if ( job->error() ) {
37 * qDebug() << "Error occurred";
38 * return;
39 * }
40 *
41 * CollectionStatisticsJob *statisticsJob = qobject_cast<CollectionStatisticsJob*>( job );
42 *
43 * const Akonadi::CollectionStatistics statistics = statisticsJob->statistics();
44 * qDebug() << "Unread items:" << statistics.unreadCount();
45 * }
46 *
47 * @endcode
48 *
49 * @author Volker Krause <vkrause@kde.org>
50 */
51class AKONADICORE_EXPORT CollectionStatisticsJob : public Job
52{
54
55public:
56 /**
57 * Creates a new collection statistics job.
58 *
59 * @param collection The collection to fetch the statistics from.
60 * @param parent The parent object.
61 */
62 explicit CollectionStatisticsJob(const Collection &collection, QObject *parent = nullptr);
63
64 /**
65 * Destroys the collection statistics job.
66 */
67 ~CollectionStatisticsJob() override;
68
69 /**
70 * Returns the fetched collection statistics.
71 */
72 [[nodiscard]] CollectionStatistics statistics() const;
73
74 /**
75 * Returns the corresponding collection, if the job was executed successfully,
76 * the collection is already updated.
77 */
78 [[nodiscard]] Collection collection() const;
79
80protected:
81 void doStart() override;
82 bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override;
83
84private:
85 Q_DECLARE_PRIVATE(CollectionStatisticsJob)
86};
87
88}
CollectionStatisticsJob(const Collection &collection, QObject *parent=nullptr)
Creates a new collection statistics job.
CollectionStatistics statistics() const
Returns the fetched collection statistics.
Collection collection() const
Returns the corresponding collection, if the job was executed successfully, the collection is already...
bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override
This method should be reimplemented in the concrete jobs in case you want to handle incoming data.
void doStart() override
This method must be reimplemented in the concrete jobs.
Provides statistics information of a Collection.
Represents a collection of PIM items.
Definition collection.h:62
Job(QObject *parent=nullptr)
Creates a new job.
Definition job.cpp:290
Helper integration between Akonadi and Qt.
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:49:57 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.