Akonadi

collectiondeletejob.h
1/*
2 SPDX-FileCopyrightText: 2006 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "akonadicore_export.h"
10#include "job.h"
11
12namespace Akonadi
13{
14class Collection;
15class CollectionDeleteJobPrivate;
16
17/**
18 * @short Job that deletes a collection in the Akonadi storage.
19 *
20 * This job deletes a collection and all its sub-collections as well as all associated content.
21 *
22 * @code
23 * Akonadi::Collection collection = ...
24 *
25 * auto job = new Akonadi::CollectionDeleteJob(collection);
26 * connect(job, &KJob::result, this, &MyClass::deletionResult);
27 *
28 * @endcode
29 *
30 * @note This job deletes the data from the backend storage. To delete the collection
31 * from the Akonadi storage only, leaving the backend storage unchanged, delete
32 * the Agent instead, as follows. Note that if it's a sub-collection, deleting
33 * the agent will also delete its parent collection; in this case the only
34 * option is to delete the sub-collection data in both Akonadi and backend
35 * storage.
36 *
37 * @code
38 * const auto instance = Akonadi::AgentManager::self()->instance(collection.resource());
39 * if (instance.isValid()) {
40 * Akonadi::AgentManager::self()->removeInstance(instance);
41 * }
42 * @endcode
43 *
44 * @author Volker Krause <vkrause@kde.org>
45 */
46class AKONADICORE_EXPORT CollectionDeleteJob : public Job
47{
49
50public:
51 /**
52 * Creates a new collection delete job. The collection needs to either have a unique
53 * identifier or a remote identifier set. Note that using a remote identifier only works
54 * in a resource context (that is from within ResourceBase), as remote identifiers
55 * are not guaranteed to be globally unique.
56 *
57 * @param collection The collection to delete.
58 * @param parent The parent object.
59 */
60 explicit CollectionDeleteJob(const Collection &collection, QObject *parent = nullptr);
61
62 /**
63 * Destroys the collection delete job.
64 */
65 ~CollectionDeleteJob() override;
66
67protected:
68 void doStart() override;
69 bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override;
70
71private:
72 Q_DECLARE_PRIVATE(CollectionDeleteJob)
73};
74
75}
bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override
This method should be reimplemented in the concrete jobs in case you want to handle incoming data.
void doStart() override
This method must be reimplemented in the concrete jobs.
CollectionDeleteJob(const Collection &collection, QObject *parent=nullptr)
Creates a new collection delete job.
Represents a collection of PIM items.
Definition collection.h:62
Job(QObject *parent=nullptr)
Creates a new job.
Definition job.cpp:290
Helper integration between Akonadi and Qt.
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:49:57 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.