Akonadi Mime

specialmailcollectionstesting.cpp
1/*
2 SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "specialmailcollections.h"
8#include "specialmailcollectionssettings.h"
9#include "specialmailcollectionstesting_p.h"
10
11#include <Akonadi/SpecialCollection>
12
13using namespace Akonadi;
14
15typedef SpecialMailCollectionsSettings Settings;
16
17SpecialMailCollectionsTesting *SpecialMailCollectionsTesting::_t_self()
18{
19 static SpecialMailCollectionsTesting instance;
20 return &instance;
21}
22
23void SpecialMailCollectionsTesting::_t_setDefaultResourceId(const QString &resourceId)
24{
25 Settings::self()->defaultResourceIdItem()->setValue(resourceId);
26 Settings::self()->save();
27}
28
29void SpecialMailCollectionsTesting::_t_forgetFoldersForResource(const QString &resourceId)
30{
31 static_cast<SpecialCollections *>(SpecialMailCollections::self())->d->forgetFoldersForResource(resourceId);
32}
33
34void SpecialMailCollectionsTesting::_t_beginBatchRegister()
35{
36 static_cast<SpecialCollections *>(SpecialMailCollections::self())->d->beginBatchRegister();
37}
38
39void SpecialMailCollectionsTesting::_t_endBatchRegister()
40{
41 static_cast<SpecialCollections *>(SpecialMailCollections::self())->d->endBatchRegister();
42}
43
44int SpecialMailCollectionsTesting::_t_knownResourceCount() const
45{
46 return static_cast<SpecialCollections *>(SpecialMailCollections::self())->d->mFoldersForResource.count();
47}
48
49int SpecialMailCollectionsTesting::_t_knownFolderCount() const
50{
51 const SpecialCollectionsPrivate *d = static_cast<SpecialCollections *>(SpecialMailCollections::self())->d;
52 int ret = 0;
53
54 QHashIterator<QString, QHash<QByteArray, Collection>> resourceIt(d->mFoldersForResource);
55 while (resourceIt.hasNext()) {
56 resourceIt.next();
57
58 QHashIterator<QByteArray, Collection> it(resourceIt.value());
59 while (it.hasNext()) {
60 it.next();
61 if (it.value().isValid()) {
62 ret++;
63 }
64 }
65 }
66 return ret;
67}
static SpecialMailCollections * self()
Returns the global SpecialMailCollections instance.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:32:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.