Akonadi

collectiondeletejob.h
1 /*
2  SPDX-FileCopyrightText: 2006 Volker Krause <[email protected]>
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 
12 namespace Akonadi
13 {
14 class Collection;
15 class 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  *
24  * Akonadi::Collection collection = ...
25  *
26  * Akonadi::CollectionDeleteJob *job = new Akonadi::CollectionDeleteJob( collection );
27  * connect( job, SIGNAL(result(KJob*)), this, SLOT(deletionResult(KJob*)) );
28  *
29  * @endcode
30  *
31  * @note This job deletes the data from the backend storage. To delete the collection
32  * from the Akonadi storage only, leaving the backend storage unchanged, delete
33  * the Agent instead, as follows. (Note that if it's a sub-collection, deleting
34  * the agent will also delete its parent collection; in this case the only
35  * option is to delete the sub-collection data in both Akonadi and backend
36  * storage.)
37  *
38  * @code
39  *
40  * const Akonadi::AgentInstance instance =
41  * Akonadi::AgentManager::self()->instance( collection.resource() );
42  * if ( instance.isValid() ) {
43  * Akonadi::AgentManager::self()->removeInstance( instance );
44  * }
45  *
46  * @endcode
47  *
48  * @author Volker Krause <[email protected]>
49  */
50 class AKONADICORE_EXPORT CollectionDeleteJob : public Job
51 {
52  Q_OBJECT
53 
54 public:
55  /**
56  * Creates a new collection delete job. The collection needs to either have a unique
57  * identifier or a remote identifier set. Note that using a remote identifier only works
58  * in a resource context (that is from within ResourceBase), as remote identifiers
59  * are not guaranteed to be globally unique.
60  *
61  * @param collection The collection to delete.
62  * @param parent The parent object.
63  */
64  explicit CollectionDeleteJob(const Collection &collection, QObject *parent = nullptr);
65 
66  /**
67  * Destroys the collection delete job.
68  */
69  ~CollectionDeleteJob() override;
70 
71 protected:
72  void doStart() override;
73  bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override;
74 
75 private:
76  Q_DECLARE_PRIVATE(CollectionDeleteJob)
77 };
78 
79 }
Represents a collection of PIM items.
Definition: collection.h:61
Base class for all actions in the Akonadi storage.
Definition: job.h:80
Job that deletes a collection in the Akonadi storage.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Sep 27 2023 04:01:18 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.