Akonadi

trashjob.h
1/*
2 SPDX-FileCopyrightText: 2011 Christian Mollekopf <chrigi_1@fastmail.fm>
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
14namespace Akonadi
15{
16class 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 <chrigi_1@fastmail.fm>
50 * @since 4.8
51 */
52class AKONADICORE_EXPORT TrashJob : public Job
53{
54 Q_OBJECT
55
56public:
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 [[nodiscard]] Item::List items() const;
108
109protected:
110 void doStart() override;
111
112private:
113 /// @cond PRIVATE
114 Q_DECLARE_PRIVATE(TrashJob)
115 /// @endcond
116};
117
118}
Represents a collection of PIM items.
Definition collection.h:62
Represents a PIM item stored in Akonadi storage.
Definition item.h:100
Base class for all actions in the Akonadi storage.
Definition job.h:81
Job that moves items/collection to trash.
Definition trashjob.h:53
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.