File indexing completed on 2024-05-12 05:22:33

0001 /*
0002  * This file is part of LibKGAPI library
0003  *
0004  * SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007  */
0008 
0009 #pragma once
0010 
0011 #include "kgapitasks_export.h"
0012 #include "modifyjob.h"
0013 
0014 #include <QScopedPointer>
0015 
0016 namespace KGAPI2
0017 {
0018 
0019 /**
0020  * @brief A job that can reparent tasks to become subtasks of another task
0021  *
0022  * @author Daniel Vrátil <dvratil@redhat.com>
0023  * @since 2.0
0024  */
0025 class KGAPITASKS_EXPORT TaskMoveJob : public KGAPI2::ModifyJob
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     /**
0031      * @brief Constructs a job that will move given \p task in a tasklist
0032      *        with given @p taskListId to be a subtask of another task with
0033      *        @p newParentId.
0034      *
0035      * Passing an empty string in @p newParentId will move the task to top-level.
0036      *
0037      * @param task Task to move
0038      * @param taskListId ID of tasklist where the task is stored
0039      * @param newParentId ID of another task this task should become subtask of
0040      *                    or empty string to move the task to top level
0041      * @param account Account to authenticate the request
0042      * @param parent
0043      */
0044     explicit TaskMoveJob(const TaskPtr &task, const QString &taskListId, const QString &newParentId, const AccountPtr &account, QObject *parent = nullptr);
0045 
0046     /**
0047      * @brief Constructs a job that will move given \p tasks in a tasklist
0048      *        with given @p taskListId to be subtasks of given task with
0049      *        @p newParentId.
0050      *
0051      * Passing an empty string in @p newParentId will move the tasks to top-level.
0052      *
0053      * @param tasks Tasks to move
0054      * @param taskListId ID of tasklist where the task is stored
0055      * @param newParentId ID of another task this tasks should become subtasks of.
0056      *                    or empty string to move the tasks to top level
0057      * @param account Account to authenticate the request
0058      * @param parent
0059      */
0060     explicit TaskMoveJob(const TasksList &tasks, const QString &taskListId, const QString &newParentId, const AccountPtr &account, QObject *parent = nullptr);
0061 
0062     /**
0063      * @brief Constructs a job that will move task with given \p taskId in a
0064      *        tasklist with given @p taskListId to be a subtask of another task
0065      *        with @p newParentId.
0066      *
0067      * Passing an empty string in @p newParentId will move the task to top-level.
0068      *
0069      * @param taskId ID of task to move
0070      * @param taskListId ID of tasklist where the task is stored
0071      * @param newParentId ID of another task this task should become subtask of.
0072      *                    or empty string to move the task to top level
0073      * @param account Account to authenticate the request
0074      * @param parent
0075      */
0076     explicit TaskMoveJob(const QString &taskId, const QString &taskListId, const QString &newParentId, const AccountPtr &account, QObject *parent = nullptr);
0077 
0078     /**
0079      * @brief Constructs a job that will move tasks with given \p tasksIds in a
0080      *        tasklist with given @p taskListId to be subtasks of another task
0081      *        with @p newParentId.
0082      *
0083      * Passing an empty string in @p newParentId will move the tasks to top-level.
0084      *
0085      * @param tasksIds IDs of tasks to move
0086      * @param taskListId ID of tasklist where the tasks is stored
0087      * @param newParentId ID of another task this tasks should become subtasks of,
0088      *                    or empty string to move the tasks to top level
0089      * @param account Account to authenticate the request
0090      * @param parent
0091      */
0092     explicit TaskMoveJob(const QStringList &tasksIds,
0093                          const QString &taskListId,
0094                          const QString &newParentId,
0095                          const AccountPtr &account,
0096                          QObject *parent = nullptr);
0097 
0098     /**
0099      * @brief Destructor
0100      */
0101     ~TaskMoveJob() override;
0102 
0103 protected:
0104     /**
0105      * @brief KGAPI2::Job::start implementation
0106      */
0107     void start() override;
0108 
0109     /**
0110      * @brief KGAPI2::Job::dispatchRequest implementation
0111      *
0112      * @param accessManager
0113      * @param request
0114      * @param data
0115      * @param contentType
0116      */
0117     void dispatchRequest(QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data, const QString &contentType) override;
0118 
0119     /**
0120      * @brief KGAPI2::Job::handleReply implementation
0121      *
0122      * @param reply
0123      * @param rawData
0124      */
0125     void handleReply(const QNetworkReply *reply, const QByteArray &rawData) override;
0126 
0127 private:
0128     class Private;
0129     QScopedPointer<Private> const d;
0130     friend class Private;
0131 };
0132 
0133 } // namespace KGAPI2