File indexing completed on 2024-11-10 04:40:29

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 ItemCopyJobPrivate;
0017 
0018 /**
0019  * @short Job that copies a set of items to a target collection in the Akonadi storage.
0020  *
0021  * The job can be used to copy one or several Item objects to another collection.
0022  *
0023  * Example:
0024  *
0025  * @code
0026  *
0027  * Akonadi::Item::List items = ...
0028  * Akonadi::Collection collection = ...
0029  *
0030  * Akonadi::ItemCopyJob *job = new Akonadi::ItemCopyJob( items, collection );
0031  * connect( job, SIGNAL(result(KJob*)), SLOT(jobFinished(KJob*)) );
0032  *
0033  * ...
0034  *
0035  * MyClass::jobFinished( KJob *job )
0036  * {
0037  *   if ( job->error() )
0038  *     qDebug() << "Error occurred";
0039  *   else
0040  *     qDebug() << "Items copied successfully";
0041  * }
0042  *
0043  * @endcode
0044  *
0045  * @author Volker Krause <vkrause@kde.org>
0046  */
0047 class AKONADICORE_EXPORT ItemCopyJob : public Job
0048 {
0049     Q_OBJECT
0050 
0051 public:
0052     /**
0053      * Creates a new item copy job.
0054      *
0055      * @param item The item to copy.
0056      * @param target The target collection.
0057      * @param parent The parent object.
0058      */
0059     ItemCopyJob(const Item &item, const Collection &target, QObject *parent = nullptr);
0060 
0061     /**
0062      * Creates a new item copy job.
0063      *
0064      * @param items A list of items to copy.
0065      * @param target The target collection.
0066      * @param parent The parent object.
0067      */
0068     ItemCopyJob(const Item::List &items, const Collection &target, QObject *parent = nullptr);
0069 
0070     /**
0071      * Destroys the item copy job.
0072      */
0073     ~ItemCopyJob() override;
0074 
0075 protected:
0076     void doStart() override;
0077     bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override;
0078 
0079 private:
0080     Q_DECLARE_PRIVATE(ItemCopyJob)
0081 };
0082 
0083 }