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;
15class CollectionStatistics;
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{
53 Q_OBJECT
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}
Job that fetches collection statistics from the Akonadi storage.
Provides statistics information of a Collection.
Represents a collection of PIM items.
Definition collection.h:62
Base class for all actions in the Akonadi storage.
Definition job.h:81
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:51:45 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.