Kgapi

taskdeletejob.cpp
1/*
2 * This file is part of LibKGAPI library
3 *
4 * SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "taskdeletejob.h"
10#include "account.h"
11#include "debug.h"
12#include "private/queuehelper_p.h"
13#include "task.h"
14#include "tasksservice.h"
15#include "utils.h"
16
17#include <QNetworkRequest>
18
19using namespace KGAPI2;
20
21class Q_DECL_HIDDEN TaskDeleteJob::Private
22{
23public:
24 QueueHelper<QString> tasksIds;
25 QString taskListId;
26};
27
28TaskDeleteJob::TaskDeleteJob(const TaskPtr &task, const QString &taskListId, const AccountPtr &account, QObject *parent)
29 : DeleteJob(account, parent)
30 , d(new Private())
31{
32 d->tasksIds << task->uid();
33 d->taskListId = taskListId;
34}
35
36TaskDeleteJob::TaskDeleteJob(const TasksList &tasks, const QString &tasklistId, const AccountPtr &account, QObject *parent)
37 : DeleteJob(account, parent)
38 , d(new Private())
39{
40 d->tasksIds.reserve(tasks.size());
41 for (const TaskPtr &task : std::as_const(tasks)) {
42 d->tasksIds << task->uid();
43 }
44 d->taskListId = tasklistId;
45}
46
47TaskDeleteJob::TaskDeleteJob(const QString &taskId, const QString &taskListId, const AccountPtr &account, QObject *parent)
48 : DeleteJob(account, parent)
49 , d(new Private())
50{
51 d->tasksIds << taskId;
52 d->taskListId = taskListId;
53}
54
55TaskDeleteJob::TaskDeleteJob(const QStringList &tasksIds, const QString &taskListId, const AccountPtr &account, QObject *parent)
56 : DeleteJob(account, parent)
57 , d(new Private())
58{
59 d->tasksIds = tasksIds;
60 d->taskListId = taskListId;
61}
62
64
66{
67 if (d->tasksIds.atEnd()) {
69 return;
70 }
71
72 const QString taskId = d->tasksIds.current();
73 const QUrl url = TasksService::removeTaskUrl(d->taskListId, taskId);
74 QNetworkRequest request(url);
75
76 enqueueRequest(request);
77}
78
79void TaskDeleteJob::handleReply(const QNetworkReply *reply, const QByteArray &rawData)
80{
81 d->tasksIds.currentProcessed();
82
83 KGAPI2::DeleteJob::handleReply(reply, rawData);
84}
85
86#include "moc_taskdeletejob.cpp"
Abstract superclass for all jobs that delete resources from Google.
Definition deletejob.h:25
void handleReply(const QNetworkReply *reply, const QByteArray &rawData) override
KGAPI2::Job::handleReply implementation.
Definition deletejob.cpp:58
virtual void emitFinished()
Emits Job::finished() signal.
Definition job.cpp:493
virtual void enqueueRequest(const QNetworkRequest &request, const QByteArray &data=QByteArray(), const QString &contentType=QString())
Enqueues request in dispatcher queue.
Definition job.cpp:513
A job to delete one or more tasks from tasklist in user's Google Tasks account.
TaskDeleteJob(const TaskPtr &task, const QString &taskListId, const AccountPtr &account, QObject *parent=nullptr)
Constructs a new job that will delete given task from a tasklist with given taskListId.
void handleReply(const QNetworkReply *reply, const QByteArray &rawData) override
KGAPI2::Job::handleReply implementation.
~TaskDeleteJob() override
Destructor.
void start() override
KGAPI2::Job::start implementation.
QUrl removeTaskUrl(const QString &tasklistID, const QString &taskID)
Returns URL for removing a task.
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
qsizetype size() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 19 2024 11:58:18 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.