File indexing completed on 2024-11-10 04:40:31
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 LinkJobPrivate; 0017 0018 /** 0019 * @short Job that links items inside the Akonadi storage. 0020 * 0021 * This job allows you to create references to a set of items in a virtual 0022 * collection. 0023 * 0024 * Example: 0025 * 0026 * @code 0027 * 0028 * // Links the given items to the given virtual collection 0029 * const Akonadi::Collection virtualCollection = ... 0030 * const Akonadi::Item::List items = ... 0031 * 0032 * Akonadi::LinkJob *job = new Akonadi::LinkJob( 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() << "Linked items successfully"; 0043 * } 0044 * 0045 * @endcode 0046 * 0047 * @author Volker Krause <vkrause@kde.org> 0048 * @since 4.2 0049 * @see UnlinkJob 0050 */ 0051 class AKONADICORE_EXPORT LinkJob : public Job 0052 { 0053 Q_OBJECT 0054 public: 0055 /** 0056 * Creates the link job. 0057 * 0058 * The job will create references to the given items in the given collection. 0059 * 0060 * @param collection The collection in which the references should be created. 0061 * @param items The items of which the references should be created. 0062 * @param parent The parent object. 0063 */ 0064 LinkJob(const Collection &collection, const Item::List &items, QObject *parent = nullptr); 0065 0066 /** 0067 * Destroys the link job. 0068 */ 0069 ~LinkJob() 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(LinkJob) 0077 template<typename T> 0078 friend class LinkJobImpl; 0079 }; 0080 0081 }