Akonadi::TrashJob Class

class Akonadi::TrashJob

Job that moves items/collection to trash. More...

Header: #include <Akonadi/TrashJob>
CMake: find_package(KPim6 REQUIRED COMPONENTS AkonadiCore)
target_link_libraries(mytarget PRIVATE KPim6::AkonadiCore)
Inherits: Akonadi::Job

Public Functions

TrashJob(const Akonadi::Collection &collection, QObject *parent = nullptr)
TrashJob(const Akonadi::Item &item, QObject *parent = nullptr)
TrashJob(const Akonadi::Item::List &items, QObject *parent = nullptr)
void deleteIfInTrash(bool enable)
Akonadi::Item::List items() const
void keepTrashInCollection(bool enable)
void setTrashCollection(const Akonadi::Collection &trashcollection)

Detailed Description

This job marks the given entities as trash and moves them to a given trash collection, if available.

Priorities of trash collections are the following: 1. keepTrashInCollection() 2. setTrashCollection() 3. configured collection in TrashSettings 4. keep in collection if nothing is configured

If the item is already marked as trash, it will be deleted instead only if deleteIfInTrash() is set. The entity is marked as trash with the EntityDeletedAttribute.

The restore collection in the EntityDeletedAttribute is set the following way: -If entities are not moved to trash -> no restore collection -If collection is deleted -> also subentities get collection.parentCollection as restore collection -If multiple items are deleted -> all items get their parentCollection as restore collection

Example:

 const Akonadi::Item::List items = ...

 TrashJob *job = new TrashJob( items );
 connect(job, &KJob::result, this, &MyClass::deletionResult);

Author: Christian Mollekopf <chrigi_1@fastmail.fm>

Member Function Documentation

[explicit] TrashJob::TrashJob(const Akonadi::Collection &collection, QObject *parent = nullptr)

Creates a new trash job that marks collection as trash, and moves it to the configured trash collection. The subentities of the collection are also marked as trash.

If keepTrashInCollection is set, the item will not be moved to the configured trash collection.

collection The collection to mark as trash. parent The parent object.

[explicit] TrashJob::TrashJob(const Akonadi::Item &item, QObject *parent = nullptr)

Creates a new trash job that marks item as trash, and moves it to the configured trash collection.

If keepTrashInCollection is set, the item will not be moved to the configured trash collection.

item The item to mark as trash. parent The parent object.

[explicit] TrashJob::TrashJob(const Akonadi::Item::List &items, QObject *parent = nullptr)

Creates a new trash job that marks all items in the list items as trash, and moves it to the configured trash collection. The items can be in different collections/resources and will still be moved to the correct trash collection.

If keepTrashInCollection is set, the item will not be moved to the configured trash collection.

items The items to mark as trash. parent The parent object.

void TrashJob::deleteIfInTrash(bool enable)

Delete Items which are already in trash, instead of ignoring them

Akonadi::Item::List TrashJob::items() const

void TrashJob::keepTrashInCollection(bool enable)

Ignore configured Trash collections and keep all items local

void TrashJob::setTrashCollection(const Akonadi::Collection &trashcollection)

Moves all entities to the give collection