File indexing completed on 2024-11-10 04:40:45

0001 /*
0002     SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QHash>
0010 #include <QString>
0011 
0012 #include "akonaditests_export.h"
0013 
0014 #include "collection.h"
0015 #include "collectionstatistics.h"
0016 #include "item.h"
0017 
0018 class KCoreConfigSkeleton;
0019 class KJob;
0020 
0021 namespace Akonadi
0022 {
0023 class AgentInstance;
0024 class SpecialCollections;
0025 class Monitor;
0026 
0027 /**
0028   @internal
0029 */
0030 class AKONADI_TESTS_EXPORT SpecialCollectionsPrivate
0031 {
0032 public:
0033     SpecialCollectionsPrivate(KCoreConfigSkeleton *settings, SpecialCollections *qq);
0034     ~SpecialCollectionsPrivate();
0035 
0036     [[nodiscard]] QString defaultResourceId() const;
0037     void emitChanged(const QString &resourceId);
0038     void collectionRemoved(const Collection &collection); // slot
0039     void collectionFetchJobFinished(KJob *job); // slot
0040     void collectionStatisticsChanged(Akonadi::Collection::Id collectionId,
0041                                      const Akonadi::CollectionStatistics &statistics); // slot
0042 
0043     /**
0044       Forgets all folders owned by the given resource.
0045       This method is used by SpecialCollectionsRequestJob.
0046       @param resourceId the identifier of the resource for which to forget folders
0047     */
0048     void forgetFoldersForResource(const QString &resourceId);
0049 
0050     /**
0051       Avoids emitting the foldersChanged() signal until endBatchRegister()
0052       is called. This is used to avoid emitting repeated signals when multiple
0053       folders are registered in a row.
0054       This method is used by SpecialCollectionsRequestJob.
0055     */
0056     void beginBatchRegister();
0057 
0058     /**
0059       @see beginBatchRegister()
0060       This method is used by SpecialCollectionsRequestJob.
0061     */
0062     void endBatchRegister();
0063 
0064     [[nodiscard]] AgentInstance defaultResource() const;
0065 
0066     SpecialCollections *const q;
0067     KCoreConfigSkeleton *mSettings = nullptr;
0068     QHash<QString, QHash<QByteArray, Collection>> mFoldersForResource;
0069     bool mBatchMode;
0070     QSet<QString> mToEmitChangedFor;
0071     Monitor *mMonitor = nullptr;
0072 
0073     mutable QString mDefaultResourceId;
0074 };
0075 
0076 } // namespace Akonadi