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

akonadi

  • sources
  • kde-4.14
  • kdepimlibs
  • 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 
26 using namespace Akonadi;
27 
31 class Akonadi::SpecialCollectionsDiscoveryJobPrivate
32 {
33 public:
34  SpecialCollectionsDiscoveryJobPrivate(SpecialCollections *collections, const QStringList &mimeTypes)
35  : mSpecialCollections(collections)
36  , mMimeTypes(mimeTypes)
37  {
38  }
39 
40  SpecialCollections *mSpecialCollections;
41  QStringList mMimeTypes;
42 };
43 
44 Akonadi::SpecialCollectionsDiscoveryJob::SpecialCollectionsDiscoveryJob(SpecialCollections *collections, const QStringList &mimeTypes, QObject *parent)
45  : KCompositeJob(parent)
46  , d(new SpecialCollectionsDiscoveryJobPrivate(collections, mimeTypes))
47 {
48 }
49 
50 Akonadi::SpecialCollectionsDiscoveryJob::~SpecialCollectionsDiscoveryJob()
51 {
52  delete d;
53 }
54 
55 void 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 
62 void 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::SpecialCollections
An interface to special collections.
Definition: specialcollections.h:65
Akonadi::CollectionFetchJob::collections
Collection::List collections() const
Returns the list of fetched collection.
Definition: collectionfetchjob.cpp:169
Akonadi::CollectionFetchJob::fetchScope
CollectionFetchScope & fetchScope()
Returns the collection fetch scope.
Definition: collectionfetchjob.cpp:439
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
Akonadi::CollectionFetchJob
Job that fetches collections from the Akonadi storage.
Definition: collectionfetchjob.h:53
Akonadi::SpecialCollectionAttribute
An Attribute that stores the special collection type of a collection.
Definition: specialcollectionattribute_p.h:39
Akonadi::Entity::attribute
Attribute * attribute(const QByteArray &name) const
Returns the attribute of the given type name if available, 0 otherwise.
Definition: entity.cpp:167
QObject
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::root
static Collection root()
Returns the root collection.
Definition: collection.cpp:192
Akonadi::SpecialCollectionsDiscoveryJob::~SpecialCollectionsDiscoveryJob
~SpecialCollectionsDiscoveryJob()
Destroys the special collections request job.
Definition: specialcollectionsdiscoveryjob.cpp:50
QStringList
Akonadi::SpecialCollectionsDiscoveryJob::SpecialCollectionsDiscoveryJob
SpecialCollectionsDiscoveryJob(SpecialCollections *collections, const QStringList &mimeTypes, QObject *parent=0)
Creates a new special collections request job.
Definition: specialcollectionsdiscoveryjob.cpp:44
Akonadi::Entity::hasAttribute
bool hasAttribute(const QByteArray &name) const
Returns true if the entity has an attribute of the given type name, false otherwise.
Definition: entity.cpp:148
Akonadi::SpecialCollectionAttribute::collectionType
QByteArray collectionType() const
Returns the special collections type of the collection.
Definition: specialcollectionattribute.cpp:74
Akonadi::CollectionFetchJob::Recursive
List all sub-collections.
Definition: collectionfetchjob.h:64
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:03 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs 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

Search



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