2 Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
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.
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.
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
20 #ifndef AKONADI_RECURSIVEITEMFETCHJOB_H
21 #define AKONADI_RECURSIVEITEMFETCHJOB_H
23 #include <akonadi/item.h>
32 * @short Job that fetches all items of a collection recursive.
34 * This job takes a collection as argument and returns a list of
35 * all items that are part of the passed collection and its child
36 * collections. The parts of the items that shall be fetched can
37 * by specified via an ItemFetchScope.
43 * // Assume the following Akonadi storage tree structure:
55 * // Collection 'Contacts' has the ID 15, then the following code
56 * // returns all items from 'Contacts', 'Private' and 'Business'.
58 * const Akonadi::Collection contactsCollection( 15 );
60 * Akonadi::RecursiveItemFetchJob *job = new Akonadi::RecursiveItemFetchJob( contactsCollection );
61 * job->fetchScope().fetchFullPayload();
62 * connect( job, SIGNAL( result( KJob* ) ), this, SLOT( fetchResult( KJob* ) ) );
68 * MyClass::fetchResult( KJob *job )
70 * Akonadi::RecursiveItemFetchJob *fetchJob = qobject_cast<Akonadi::RecursiveItemFetchJob*>( job );
71 * const Akonadi::Item::List items = fetchJob->items();
72 * // do something with the items
77 * @author Tobias Koenig <tokoe@kde.org>
79 class RecursiveItemFetchJob
: public KJob
85 * Creates a new recursive item fetch job.
87 * @param collection The collection that shall be fetched recursive.
88 * @param parent The parent object.
90 explicit RecursiveItemFetchJob( const Akonadi::Collection
&collection
, QObject
*parent
= 0 );
93 * Destroys the recursive item fetch job.
95 ~RecursiveItemFetchJob();
98 * Sets the item fetch scope.
100 * The ItemFetchScope controls how much of an item's data is fetched
101 * from the server, e.g. whether to fetch the full item payload or
104 * @param fetchScope The new scope for item fetch operations.
108 void setFetchScope( const Akonadi::ItemFetchScope
&fetchScope
);
111 * Returns the item fetch scope.
113 * Since this returns a reference it can be used to conveniently modify the
114 * current scope in-place, i.e. by calling a method on the returned reference
115 * without storing it in a local variable. See the ItemFetchScope documentation
118 * @return a reference to the current item fetch scope
120 * @see setFetchScope() for replacing the current item fetch scope
122 Akonadi::ItemFetchScope
&fetchScope();
125 * Returns the list of fetched items.
127 Akonadi::Item::List
items() const;
130 * Starts the recursive item fetch job.
132 virtual void start();
139 Q_PRIVATE_SLOT( d
, void collectionFetchResult( KJob
* ) )
140 Q_PRIVATE_SLOT( d
, void itemFetchResult( KJob
* ) )