File indexing completed on 2024-11-10 04:40:33
0001 /* 0002 SPDX-FileCopyrightText: 2008 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 UnlinkJobPrivate; 0017 0018 /** 0019 * @short Job that unlinks items inside the Akonadi storage. 0020 * 0021 * This job allows you to remove references to a set of items in a virtual 0022 * collection. 0023 * 0024 * Example: 0025 * 0026 * @code 0027 * 0028 * // Unlink the given items from the given collection 0029 * const Akonadi::Collection virtualCollection = ... 0030 * const Akonadi::Item::List items = ... 0031 * 0032 * Akonadi::UnlinkJob *job = new Akonadi::UnlinkJob( virtualCollection, items ); 0033 * connect( job, SIGNAL(result(KJob*)), SLOT(jobFinished(KJob*)) ); 0034 * 0035 * ... 0036 * 0037 * MyClass::jobFinished( KJob *job ) 0038 * { 0039 * if ( job->error() ) 0040 * qDebug() << "Error occurred"; 0041 * else 0042 * qDebug() << "Unlinked items successfully"; 0043 * } 0044 * 0045 * @endcode 0046 * 0047 * @author Volker Krause <vkrause@kde.org> 0048 * @since 4.2 0049 * @see LinkJob 0050 */ 0051 class AKONADICORE_EXPORT UnlinkJob : public Job 0052 { 0053 Q_OBJECT 0054 public: 0055 /** 0056 * Creates a new unlink job. 0057 * 0058 * The job will remove references to the given items from the given collection. 0059 * 0060 * @param collection The collection from which the references should be removed. 0061 * @param items The items of which the references should be removed. 0062 * @param parent The parent object. 0063 */ 0064 UnlinkJob(const Collection &collection, const Item::List &items, QObject *parent = nullptr); 0065 0066 /** 0067 * Destroys the unlink job. 0068 */ 0069 ~UnlinkJob() override; 0070 0071 protected: 0072 void doStart() override; 0073 bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override; 0074 0075 private: 0076 Q_DECLARE_PRIVATE(UnlinkJob) 0077 template<typename T> 0078 friend class LinkJobImpl; 0079 }; 0080 0081 }