1 /*
2     SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
3 
4     SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QHash>
10 #include <QString>
11 
12 #include "akonaditests_export.h"
13 
14 #include "collection.h"
15 #include "collectionstatistics.h"
16 #include "item.h"
17 
18 class KCoreConfigSkeleton;
19 class KJob;
20 
21 namespace Akonadi
22 {
23 class AgentInstance;
24 class SpecialCollections;
25 class Monitor;
26 
27 /**
28   @internal
29 */
30 class AKONADI_TESTS_EXPORT SpecialCollectionsPrivate
31 {
32 public:
33     SpecialCollectionsPrivate(KCoreConfigSkeleton *settings, SpecialCollections *qq);
34     ~SpecialCollectionsPrivate();
35 
36     QString defaultResourceId() const;
37     void emitChanged(const QString &resourceId);
38     void collectionRemoved(const Collection &collection); // slot
39     void collectionFetchJobFinished(KJob *job); // slot
40     void collectionStatisticsChanged(Akonadi::Collection::Id collectionId,
41                                      const Akonadi::CollectionStatistics &statistics); // slot
42 
43     /**
44       Forgets all folders owned by the given resource.
45       This method is used by SpecialCollectionsRequestJob.
46       @param resourceId the identifier of the resource for which to forget folders
47     */
48     void forgetFoldersForResource(const QString &resourceId);
49 
50     /**
51       Avoids emitting the foldersChanged() signal until endBatchRegister()
52       is called. This is used to avoid emitting repeated signals when multiple
53       folders are registered in a row.
54       This method is used by SpecialCollectionsRequestJob.
55     */
56     void beginBatchRegister();
57 
58     /**
59       @see beginBatchRegister()
60       This method is used by SpecialCollectionsRequestJob.
61     */
62     void endBatchRegister();
63 
64     AgentInstance defaultResource() const;
65 
66     SpecialCollections *const q;
67     KCoreConfigSkeleton *mSettings = nullptr;
68     QHash<QString, QHash<QByteArray, Collection>> mFoldersForResource;
69     bool mBatchMode;
70     QSet<QString> mToEmitChangedFor;
71     Monitor *mMonitor = nullptr;
72 
73     mutable QString mDefaultResourceId;
74 };
75 
76 } // namespace Akonadi
77 
78