1 | /* |
2 | Copyright (c) 2006 - 2007 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_COLLECTIONSTATISTICSJOB_H |
21 | #define AKONADI_COLLECTIONSTATISTICSJOB_H |
22 | |
23 | #include "akonadi_export.h" |
24 | |
25 | #include <akonadi/job.h> |
26 | |
27 | namespace Akonadi { |
28 | |
29 | class Collection; |
30 | class CollectionStatistics; |
31 | class CollectionStatisticsJobPrivate; |
32 | |
33 | /** |
34 | * @short Job that fetches collection statistics from the Akonadi storage. |
35 | * |
36 | * This class fetches the CollectionStatistics object for a given collection. |
37 | * |
38 | * Example: |
39 | * |
40 | * @code |
41 | * |
42 | * Akonadi::Collection collection = ... |
43 | * |
44 | * Akonadi::CollectionStatisticsJob *job = new Akonadi::CollectionStatisticsJob( collection ); |
45 | * connect( job, SIGNAL(result(KJob*)), SLOT(jobFinished(KJob*)) ); |
46 | * |
47 | * ... |
48 | * |
49 | * MyClass::jobFinished( KJob *job ) |
50 | * { |
51 | * if ( job->error() ) { |
52 | * qDebug() << "Error occurred"; |
53 | * return; |
54 | * } |
55 | * |
56 | * CollectionStatisticsJob *statisticsJob = qobject_cast<CollectionStatisticsJob*>( job ); |
57 | * |
58 | * const Akonadi::CollectionStatistics statistics = statisticsJob->statistics(); |
59 | * qDebug() << "Unread items:" << statistics.unreadCount(); |
60 | * } |
61 | * |
62 | * @endcode |
63 | * |
64 | * @author Volker Krause <vkrause@kde.org> |
65 | */ |
66 | class AKONADI_EXPORT CollectionStatisticsJob : public Job |
67 | { |
68 | Q_OBJECT |
69 | |
70 | public: |
71 | /** |
72 | * Creates a new collection statistics job. |
73 | * |
74 | * @param collection The collection to fetch the statistics from. |
75 | * @param parent The parent object. |
76 | */ |
77 | explicit CollectionStatisticsJob(const Collection &collection, QObject *parent = 0); |
78 | |
79 | /** |
80 | * Destroys the collection statistics job. |
81 | */ |
82 | virtual ~CollectionStatisticsJob(); |
83 | |
84 | /** |
85 | * Returns the fetched collection statistics. |
86 | */ |
87 | CollectionStatistics statistics() const; |
88 | |
89 | /** |
90 | * Returns the corresponding collection, if the job was executed successfully, |
91 | * the collection is already updated. |
92 | */ |
93 | Collection collection() const; |
94 | |
95 | protected: |
96 | virtual void doStart(); |
97 | virtual void doHandleResponse(const QByteArray &tag, const QByteArray &data); |
98 | |
99 | private: |
100 | Q_DECLARE_PRIVATE(CollectionStatisticsJob) |
101 | }; |
102 | |
103 | } |
104 | |
105 | #endif |
106 | |