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

akonadi

  • sources
  • kde-4.12
  • 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), mMimeTypes(mimeTypes) {}
36 
37  SpecialCollections *mSpecialCollections;
38  QStringList mMimeTypes;
39 };
40 
41 Akonadi::SpecialCollectionsDiscoveryJob::SpecialCollectionsDiscoveryJob(SpecialCollections *collections, const QStringList &mimeTypes, QObject *parent)
42  : KCompositeJob(parent),
43  d(new SpecialCollectionsDiscoveryJobPrivate(collections, mimeTypes))
44 {
45 }
46 
47 Akonadi::SpecialCollectionsDiscoveryJob::~SpecialCollectionsDiscoveryJob()
48 {
49  delete d;
50 }
51 
52 void Akonadi::SpecialCollectionsDiscoveryJob::start()
53 {
54  CollectionFetchJob* job = new CollectionFetchJob(Collection::root(), CollectionFetchJob::Recursive, this);
55  job->fetchScope().setContentMimeTypes(d->mMimeTypes);
56  addSubjob(job);
57 }
58 
59 void Akonadi::SpecialCollectionsDiscoveryJob::slotResult( KJob *job )
60 {
61  if ( job->error() ) {
62  qWarning() << job->errorString();
63  return;
64  }
65  Akonadi::CollectionFetchJob *fetchJob = qobject_cast<Akonadi::CollectionFetchJob*>( job );
66  foreach (const Akonadi::Collection &collection, fetchJob->collections()) {
67  if (collection.hasAttribute<SpecialCollectionAttribute>()) {
68  d->mSpecialCollections->registerCollection(collection.attribute<SpecialCollectionAttribute>()->collectionType(), collection);
69  }
70  }
71  emitResult();
72 }
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:175
Akonadi::CollectionFetchJob::fetchScope
CollectionFetchScope & fetchScope()
Returns the collection fetch scope.
Definition: collectionfetchjob.cpp:437
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:165
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:124
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:47
Akonadi::SpecialCollectionsDiscoveryJob::SpecialCollectionsDiscoveryJob
SpecialCollectionsDiscoveryJob(SpecialCollections *collections, const QStringList &mimeTypes, QObject *parent=0)
Creates a new special collections request job.
Definition: specialcollectionsdiscoveryjob.cpp:41
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:146
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-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:28 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
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

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