1/*
2 Copyright (c) 2006 Volker Krause <vkrause@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#ifndef AKONADI_ITEMDELETEJOB_H
21#define AKONADI_ITEMDELETEJOB_H
22
23#include "akonadi_export.h"
24
25#include <akonadi/item.h>
26#include <akonadi/job.h>
27
28namespace Akonadi {
29
30class Collection;
31class ItemDeleteJobPrivate;
32
33/**
34 * @short Job that deletes items from the Akonadi storage.
35 *
36 * This job removes the given items from the Akonadi storage.
37 *
38 * Example:
39 *
40 * @code
41 *
42 * const Akonadi::Item item = ...
43 *
44 * ItemDeleteJob *job = new ItemDeleteJob(item);
45 * connect(job, SIGNAL(result(KJob*)), this, SLOT(deletionResult(KJob*)));
46 *
47 * @endcode
48 *
49 * Example:
50 *
51 * @code
52 *
53 * const Akonadi::Item::List items = ...
54 *
55 * ItemDeleteJob *job = new ItemDeleteJob(items);
56 * connect(job, SIGNAL(result(KJob*)), this, SLOT(deletionResult(KJob*)));
57 *
58 * @endcode
59 *
60 * @author Volker Krause <vkrause@kde.org>
61 */
62class AKONADI_EXPORT ItemDeleteJob : public Job
63{
64 Q_OBJECT
65
66public:
67 /**
68 * Creates a new item delete job that deletes @p item. The item
69 * needs to have a unique identifier set.
70 *
71 * @internal
72 * For internal use only, the item may have a remote identifier set instead
73 * of a unique identifier. In this case, a collection or resource context
74 * needs to be selected using CollectionSelectJob or ResourceSelectJob.
75 * @endinternal
76 *
77 * @param item The item to delete.
78 * @param parent The parent object.
79 */
80 explicit ItemDeleteJob(const Item &item, QObject *parent = 0);
81
82 /**
83 * Creates a new item delete job that deletes all items in the list
84 * @p items. Each item needs to have a unique identifier set. These items
85 * can be located in any collection.
86 *
87 * @internal
88 * For internal use only, the items may have remote identifiers set instead
89 * of unique identifiers. In this case, a collection or resource context
90 * needs to be selected using CollectionSelectJob or ResourceSelectJob.
91 * @endinternal
92 *
93 * @param items The items to delete.
94 * @param parent The parent object.
95 *
96 * @since 4.3
97 */
98 explicit ItemDeleteJob(const Item::List &items, QObject *parent = 0);
99
100 /**
101 * Creates a new item delete job that deletes all items in the collection
102 * @p collection. The collection needs to have a unique identifier set.
103 *
104 * @internal
105 * For internal use only, the collection may have a remote identifier set
106 * instead of a unique identifier. In this case, a resource context needs
107 * to be selected using ResourceSelectJob.
108 * @endinternal
109 *
110 * @param collection The collection which content should be deleted.
111 * @param parent The parent object.
112 *
113 * @since 4.3
114 */
115 explicit ItemDeleteJob(const Collection &collection, QObject *parent = 0);
116
117 /**
118 * Creates a new item delete job that deletes all items that have assigned
119 * the tag @p tag.
120 *
121 * @param tag The tag which content should be deleted.
122 * @param parent The parent object.
123 *
124 * @since 4.14
125 */
126 explicit ItemDeleteJob(const Tag &tag, QObject *parent = 0);
127
128 /**
129 * Destroys the item delete job.
130 */
131 ~ItemDeleteJob();
132
133 /**
134 * Returns the items passed on in the constructor.
135 * @since 4.4
136 */
137 Item::List deletedItems() const;
138
139protected:
140 virtual void doStart();
141
142private:
143 //@cond PRIVATE
144 Q_DECLARE_PRIVATE(ItemDeleteJob)
145 //@endcond
146};
147
148}
149
150#endif
151