SVN_SILENT made messages (.desktop file) - always resolve ours
[kdepim.git] / kalarm / collectionsearch.h
blobe7e536eb7d7b71d2452233d198c1e8e9e3a631bf
1 /*
2 * collectionsearch.h - Search Akonadi Collections
3 * Program: kalarm
4 * Copyright © 2014 by David Jarvie <djarvie@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef COLLECTIONSEARCH_H
22 #define COLLECTIONSEARCH_H
25 #include <AkonadiCore/collection.h>
26 #include <AkonadiCore/item.h>
28 #include <QObject>
29 #include <QMap>
30 #include <QList>
32 class KJob;
33 namespace Akonadi
35 class CollectionFetchJob;
36 class ItemFetchJob;
37 class ItemDeleteJob;
40 /*=============================================================================
41 = Class: CollectionSearch
42 = Fetches a list of all Akonadi collections which handle a specified mime type,
43 = and then optionally fetches or deletes all Items from them with a given GID.
45 = Note that this class auto-deletes once it has emitted its completion signal.
46 = Instances must therefore be created on the heap by operator new(), not on the
47 = stack.
48 =============================================================================*/
49 class CollectionSearch : public QObject
51 Q_OBJECT
52 public:
53 explicit CollectionSearch(const QString& mimeType, const QString& gid = QString(), bool remove = false);
55 Q_SIGNALS:
56 // Signal emitted if action is to fetch all collections for the mime type
57 void collections(const Akonadi::Collection::List&);
58 // Signal emitted if action is to fetch all items with the remote ID
59 void items(const Akonadi::Item::List&);
60 // Signal emitted if action is to delete all items with the remote ID
61 void deleted(int count);
63 private Q_SLOTS:
64 void collectionFetchResult(KJob*);
65 void itemFetchResult(KJob*);
66 void itemDeleteResult(KJob*);
67 void finish();
69 private:
70 QString mMimeType;
71 QString mGid;
72 QList<Akonadi::CollectionFetchJob*> mCollectionJobs;
73 QMap<Akonadi::ItemFetchJob*, Akonadi::Collection::Id> mItemFetchJobs;
74 QMap<Akonadi::ItemDeleteJob*, Akonadi::Collection::Id> mItemDeleteJobs;
75 Akonadi::Collection::List mCollections;
76 Akonadi::Item::List mItems;
77 int mDeleteCount;
78 bool mDelete;
81 #endif // COLLECTIONSEARCH_H
83 // vim: et sw=4: