File indexing completed on 2024-11-10 04:40:33
0001 /* 0002 * SPDX-FileCopyrightText: 2011 Christian Mollekopf <chrigi_1@fastmail.fm> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "akonadicore_export.h" 0010 #include "collection.h" 0011 #include "item.h" 0012 #include "job.h" 0013 0014 namespace Akonadi 0015 { 0016 class TrashRestoreJobPrivate; 0017 /** 0018 * @short Job that restores entities from trash 0019 * 0020 * This job restores the given entities from trash. 0021 * The EntityDeletedAttribute is removed and the item is restored to the stored restore collection. 0022 * 0023 * If the stored restore collection is not available, the root collection of the original resource is used. 0024 * If also this is not available, setTargetCollection has to be used to restore the item to a specific collection. 0025 * 0026 * Example: 0027 * 0028 * @code 0029 * 0030 * const Akonadi::Item::List items = ... 0031 * 0032 * TrashRestoreJob *job = new TrashRestoreJob( items ); 0033 * connect( job, SIGNAL(result(KJob*)), this, SLOT(restoreResult(KJob*)) ); 0034 * 0035 * @endcode 0036 * 0037 * @author Christian Mollekopf <chrigi_1@fastmail.fm> 0038 * @since 4.8 0039 */ 0040 class AKONADICORE_EXPORT TrashRestoreJob : public Job 0041 { 0042 Q_OBJECT 0043 public: 0044 /** 0045 * All items need to be from the same resource 0046 */ 0047 explicit TrashRestoreJob(const Item &item, QObject *parent = nullptr); 0048 0049 explicit TrashRestoreJob(const Item::List &items, QObject *parent = nullptr); 0050 0051 explicit TrashRestoreJob(const Collection &collection, QObject *parent = nullptr); 0052 0053 ~TrashRestoreJob() override; 0054 0055 /** 0056 * Sets the target collection, where the item is moved to. 0057 * If not set the item will be restored in the collection saved in the EntityDeletedAttribute. 0058 * @param collection the collection to set as target 0059 */ 0060 void setTargetCollection(const Collection &collection); 0061 0062 [[nodiscard]] Item::List items() const; 0063 0064 protected: 0065 void doStart() override; 0066 0067 private: 0068 /// @cond PRIVATE 0069 Q_DECLARE_PRIVATE(TrashRestoreJob) 0070 /// @endcond 0071 }; 0072 0073 }