Akonadi

trashjob.h
1 /*
2  SPDX-FileCopyrightText: 2011 Christian Mollekopf <[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 "collection.h"
11 #include "item.h"
12 #include "job.h"
13 
14 namespace Akonadi
15 {
16 class TrashJobPrivate;
17 
18 /**
19  * @short Job that moves items/collection to trash.
20  *
21  * This job marks the given entities as trash and moves them to a given trash collection, if available.
22  *
23  * Priorities of trash collections are the following:
24  * 1. keepTrashInCollection()
25  * 2. setTrashCollection()
26  * 3. configured collection in TrashSettings
27  * 4. keep in collection if nothing is configured
28  *
29  * If the item is already marked as trash, it will be deleted instead
30  * only if deleteIfInTrash() is set.
31  * The entity is marked as trash with the EntityDeletedAttribute.
32  *
33  * The restore collection in the EntityDeletedAttribute is set the following way:
34  * -If entities are not moved to trash -> no restore collection
35  * -If collection is deleted -> also subentities get collection.parentCollection as restore collection
36  * -If multiple items are deleted -> all items get their parentCollection as restore collection
37  *
38  * Example:
39  *
40  * @code
41  *
42  * const Akonadi::Item::List items = ...
43  *
44  * TrashJob *job = new TrashJob( items );
45  * connect( job, SIGNAL(result(KJob*)), this, SLOT(deletionResult(KJob*)) );
46  *
47  * @endcode
48  *
49  * @author Christian Mollekopf <[email protected]>
50  * @since 4.8
51  */
52 class AKONADICORE_EXPORT TrashJob : public Job
53 {
54  Q_OBJECT
55 
56 public:
57  /**
58  * Creates a new trash job that marks @p item as trash, and moves it to the configured trash collection.
59  *
60  * If @p keepTrashInCollection is set, the item will not be moved to the configured trash collection.
61  *
62  * @param item The item to mark as trash.
63  * @param parent The parent object.
64  */
65  explicit TrashJob(const Item &item, QObject *parent = nullptr);
66 
67  /**
68  * Creates a new trash job that marks all items in the list
69  * @p items as trash, and moves it to the configured trash collection.
70  * The items can be in different collections/resources and will still be moved to the correct trash collection.
71  *
72  * If @p keepTrashInCollection is set, the item will not be moved to the configured trash collection.
73  *
74  * @param items The items to mark as trash.
75  * @param parent The parent object.
76  */
77  explicit TrashJob(const Item::List &items, QObject *parent = nullptr);
78 
79  /**
80  * Creates a new trash job that marks @p collection as trash, and moves it to the configured trash collection.
81  * The subentities of the collection are also marked as trash.
82  *
83  * If @p keepTrashInCollection is set, the item will not be moved to the configured trash collection.
84  *
85  * @param collection The collection to mark as trash.
86  * @param parent The parent object.
87  */
88  explicit TrashJob(const Collection &collection, QObject *parent = nullptr);
89 
90  ~TrashJob() override;
91 
92  /**
93  * Ignore configured Trash collections and keep all items local
94  */
95  void keepTrashInCollection(bool enable);
96 
97  /**
98  * Moves all entities to the give collection
99  */
100  void setTrashCollection(const Collection &trashcollection);
101 
102  /**
103  * Delete Items which are already in trash, instead of ignoring them
104  */
105  void deleteIfInTrash(bool enable);
106 
107  Q_REQUIRED_RESULT Item::List items() const;
108 
109 protected:
110  void doStart() override;
111 
112 private:
113  /// @cond PRIVATE
114  Q_DECLARE_PRIVATE(TrashJob)
115  /// @endcond
116 };
117 
118 }
119 
Represents a collection of PIM items.
Definition: collection.h:61
Job that moves items/collection to trash.
Definition: trashjob.h:52
Base class for all actions in the Akonadi storage.
Definition: job.h:80
Represents a PIM item stored in Akonadi storage.
Definition: item.h:104
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Sep 26 2022 04:03:29 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.