Akonadi

collectionstatisticsjob.h
1 /*
2  SPDX-FileCopyrightText: 2006-2007 Volker Krause <[email protected]>
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 
12 namespace Akonadi
13 {
14 class Collection;
15 class CollectionStatistics;
16 class 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 <[email protected]>
50  */
51 class AKONADICORE_EXPORT CollectionStatisticsJob : public Job
52 {
53  Q_OBJECT
54 
55 public:
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 
80 protected:
81  void doStart() override;
82  bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override;
83 
84 private:
85  Q_DECLARE_PRIVATE(CollectionStatisticsJob)
86 };
87 
88 }
Provides statistics information of a Collection.
Represents a collection of PIM items.
Definition: collection.h:61
Base class for all actions in the Akonadi storage.
Definition: job.h:80
Job that fetches collection statistics from the Akonadi storage.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Dec 7 2023 03:52:48 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.