File indexing completed on 2024-11-10 04:40:29
0001 /* 0002 SPDX-FileCopyrightText: 2006 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "akonadicore_export.h" 0010 #include "item.h" 0011 #include "job.h" 0012 0013 namespace Akonadi 0014 { 0015 class Collection; 0016 class ItemDeleteJobPrivate; 0017 0018 /** 0019 * @short Job that deletes items from the Akonadi storage. 0020 * 0021 * This job removes the given items from the Akonadi storage. 0022 * 0023 * Example: 0024 * 0025 * @code 0026 * 0027 * const Akonadi::Item item = ... 0028 * 0029 * ItemDeleteJob *job = new ItemDeleteJob(item); 0030 * connect(job, SIGNAL(result(KJob*)), this, SLOT(deletionResult(KJob*))); 0031 * 0032 * @endcode 0033 * 0034 * Example: 0035 * 0036 * @code 0037 * 0038 * const Akonadi::Item::List items = ... 0039 * 0040 * ItemDeleteJob *job = new ItemDeleteJob(items); 0041 * connect(job, SIGNAL(result(KJob*)), this, SLOT(deletionResult(KJob*))); 0042 * 0043 * @endcode 0044 * 0045 * @author Volker Krause <vkrause@kde.org> 0046 */ 0047 class AKONADICORE_EXPORT ItemDeleteJob : public Job 0048 { 0049 Q_OBJECT 0050 0051 public: 0052 /** 0053 * Creates a new item delete job that deletes @p item. The item 0054 * needs to have a unique identifier set. 0055 * 0056 * @internal 0057 * For internal use only, the item may have a remote identifier set instead 0058 * of a unique identifier. In this case, a collection or resource context 0059 * needs to be selected using ResourceSelectJob. 0060 * @endinternal 0061 * 0062 * @param item The item to delete. 0063 * @param parent The parent object. 0064 */ 0065 explicit ItemDeleteJob(const Item &item, QObject *parent = nullptr); 0066 0067 /** 0068 * Creates a new item delete job that deletes all items in the list 0069 * @p items. Each item needs to have a unique identifier set. These items 0070 * can be located in any collection. 0071 * 0072 * @internal 0073 * For internal use only, the items may have remote identifiers set instead 0074 * of unique identifiers. In this case, a collection or resource context 0075 * needs to be selected using ResourceSelectJob. 0076 * @endinternal 0077 * 0078 * @param items The items to delete. 0079 * @param parent The parent object. 0080 * 0081 * @since 4.3 0082 */ 0083 explicit ItemDeleteJob(const Item::List &items, QObject *parent = nullptr); 0084 0085 /** 0086 * Creates a new item delete job that deletes all items in the collection 0087 * @p collection. The collection needs to have a unique identifier set. 0088 * 0089 * @internal 0090 * For internal use only, the collection may have a remote identifier set 0091 * instead of a unique identifier. In this case, a resource context needs 0092 * to be selected using ResourceSelectJob. 0093 * @endinternal 0094 * 0095 * @param collection The collection which content should be deleted. 0096 * @param parent The parent object. 0097 * 0098 * @since 4.3 0099 */ 0100 explicit ItemDeleteJob(const Collection &collection, QObject *parent = nullptr); 0101 0102 /** 0103 * Creates a new item delete job that deletes all items that have assigned 0104 * the tag @p tag. 0105 * 0106 * @param tag The tag which content should be deleted. 0107 * @param parent The parent object. 0108 * 0109 * @since 4.14 0110 */ 0111 explicit ItemDeleteJob(const Tag &tag, QObject *parent = nullptr); 0112 0113 /** 0114 * Destroys the item delete job. 0115 */ 0116 ~ItemDeleteJob() override; 0117 0118 /** 0119 * Returns the items passed on in the constructor. 0120 * @since 4.4 0121 */ 0122 [[nodiscard]] Item::List deletedItems() const; 0123 0124 protected: 0125 void doStart() override; 0126 bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override; 0127 0128 private: 0129 /// @cond PRIVATE 0130 Q_DECLARE_PRIVATE(ItemDeleteJob) 0131 /// @endcond 0132 }; 0133 0134 }