• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • akonadi
specialcollectionsdiscoveryjob.cpp
1/*
2 Copyright (c) 2013 David Faure <faure@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#include "specialcollectionsdiscoveryjob.h"
21#include "specialcollectionattribute_p.h"
22#include <akonadi/collectionfetchscope.h>
23#include <akonadi/collectionfetchjob.h>
24#include <QStringList>
25
26using namespace Akonadi;
27
31class Akonadi::SpecialCollectionsDiscoveryJobPrivate
32{
33public:
34 SpecialCollectionsDiscoveryJobPrivate(SpecialCollections *collections, const QStringList &mimeTypes)
35 : mSpecialCollections(collections)
36 , mMimeTypes(mimeTypes)
37 {
38 }
39
40 SpecialCollections *mSpecialCollections;
41 QStringList mMimeTypes;
42};
43
44Akonadi::SpecialCollectionsDiscoveryJob::SpecialCollectionsDiscoveryJob(SpecialCollections *collections, const QStringList &mimeTypes, QObject *parent)
45 : KCompositeJob(parent)
46 , d(new SpecialCollectionsDiscoveryJobPrivate(collections, mimeTypes))
47{
48}
49
50Akonadi::SpecialCollectionsDiscoveryJob::~SpecialCollectionsDiscoveryJob()
51{
52 delete d;
53}
54
55void Akonadi::SpecialCollectionsDiscoveryJob::start()
56{
57 CollectionFetchJob *job = new CollectionFetchJob(Collection::root(), CollectionFetchJob::Recursive, this);
58 job->fetchScope().setContentMimeTypes(d->mMimeTypes);
59 addSubjob(job);
60}
61
62void Akonadi::SpecialCollectionsDiscoveryJob::slotResult(KJob *job)
63{
64 if (job->error()) {
65 qWarning() << job->errorString();
66 return;
67 }
68 Akonadi::CollectionFetchJob *fetchJob = qobject_cast<Akonadi::CollectionFetchJob *>(job);
69 foreach (const Akonadi::Collection &collection, fetchJob->collections()) {
70 if (collection.hasAttribute<SpecialCollectionAttribute>()) {
71 d->mSpecialCollections->registerCollection(collection.attribute<SpecialCollectionAttribute>()->collectionType(), collection);
72 }
73 }
74 emitResult();
75}
Akonadi::CollectionFetchJob
Job that fetches collections from the Akonadi storage.
Definition: collectionfetchjob.h:54
Akonadi::CollectionFetchJob::fetchScope
CollectionFetchScope & fetchScope()
Returns the collection fetch scope.
Definition: collectionfetchjob.cpp:439
Akonadi::CollectionFetchJob::Recursive
@ Recursive
List all sub-collections.
Definition: collectionfetchjob.h:64
Akonadi::CollectionFetchJob::collections
Collection::List collections() const
Returns the list of fetched collection.
Definition: collectionfetchjob.cpp:169
Akonadi::CollectionFetchScope::setContentMimeTypes
void setContentMimeTypes(const QStringList &mimeTypes)
Sets a content mimetypes filter, that is only collections that contain at least one of the given mime...
Definition: collectionfetchscope.cpp:128
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:76
Akonadi::Collection::root
static Collection root()
Returns the root collection.
Definition: collection.cpp:192
Akonadi::SpecialCollectionAttribute
An Attribute that stores the special collection type of a collection.
Definition: specialcollectionattribute_p.h:40
Akonadi::SpecialCollectionAttribute::collectionType
QByteArray collectionType() const
Returns the special collections type of the collection.
Definition: specialcollectionattribute.cpp:74
Akonadi::SpecialCollectionsDiscoveryJob::~SpecialCollectionsDiscoveryJob
~SpecialCollectionsDiscoveryJob()
Destroys the special collections request job.
Definition: specialcollectionsdiscoveryjob.cpp:50
Akonadi::SpecialCollectionsDiscoveryJob::SpecialCollectionsDiscoveryJob
SpecialCollectionsDiscoveryJob(SpecialCollections *collections, const QStringList &mimeTypes, QObject *parent=0)
Creates a new special collections request job.
Definition: specialcollectionsdiscoveryjob.cpp:44
Akonadi::SpecialCollections
An interface to special collections.
Definition: specialcollections.h:66
Akonadi
FreeBusyManager::Singleton.
Definition: actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal