Akonadi

specialcollectionsdiscoveryjob.cpp
1/*
2 SPDX-FileCopyrightText: 2013 David Faure <faure@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "specialcollectionsdiscoveryjob.h"
8#include "collectionfetchjob.h"
9#include "collectionfetchscope.h"
10#include "specialcollectionattribute.h"
11#include <QStringList>
12
13#include "akonadicore_debug.h"
14
15using namespace Akonadi;
16
17/**
18 @internal
19*/
20class Akonadi::SpecialCollectionsDiscoveryJobPrivate
21{
22public:
23 SpecialCollectionsDiscoveryJobPrivate(SpecialCollections *collections, const QStringList &mimeTypes)
24 : mSpecialCollections(collections)
25 , mMimeTypes(mimeTypes)
26 {
27 }
28
29 SpecialCollections *const mSpecialCollections;
30 const QStringList mMimeTypes;
31};
32
35 , d(new SpecialCollectionsDiscoveryJobPrivate(collections, mimeTypes))
36{
37}
38
40
41void Akonadi::SpecialCollectionsDiscoveryJob::start()
42{
44 job->fetchScope().setContentMimeTypes(d->mMimeTypes);
45 addSubjob(job);
46}
47
48void Akonadi::SpecialCollectionsDiscoveryJob::slotResult(KJob *job)
49{
50 if (job->error()) {
51 qCWarning(AKONADICORE_LOG) << job->errorString();
52 return;
53 }
54 auto fetchJob = qobject_cast<Akonadi::CollectionFetchJob *>(job);
55 const Akonadi::Collection::List lstCollections = fetchJob->collections();
56 for (const Akonadi::Collection &collection : lstCollections) {
57 if (collection.hasAttribute<SpecialCollectionAttribute>()) {
58 d->mSpecialCollections->registerCollection(collection.attribute<SpecialCollectionAttribute>()->collectionType(), collection);
59 }
60 }
61 emitResult();
62}
63
64#include "moc_specialcollectionsdiscoveryjob.cpp"
Job that fetches collections from the Akonadi storage.
@ Recursive
List all sub-collections.
static Collection root()
Returns the root collection.
QList< Collection > List
Describes a list of collections.
Definition collection.h:84
An Attribute that stores the special collection type of a collection.
QByteArray collectionType() const
Returns the special collections type of the collection.
~SpecialCollectionsDiscoveryJob() override
Destroys the special collections request job.
SpecialCollectionsDiscoveryJob(SpecialCollections *collections, const QStringList &mimeTypes, QObject *parent=nullptr)
Creates a new special collections request job.
An interface to special collections.
KCompositeJob(QObject *parent=nullptr)
virtual QString errorString() const
int error() const
Helper integration between Akonadi and Qt.
QObject(QObject *parent)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:49:57 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.