Kgapi

filedeletejob.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 "filedeletejob.h"
10#include "driveservice.h"
11#include "file.h"
12
13#include <QNetworkRequest>
14
15using namespace KGAPI2;
16using namespace KGAPI2::Drive;
17
18class Q_DECL_HIDDEN FileDeleteJob::Private
19{
20public:
21 QStringList filesIDs;
22};
23
24FileDeleteJob::FileDeleteJob(const QString &fileId, const AccountPtr &account, QObject *parent)
25 : DeleteJob(account, parent)
26 , d(new Private)
27{
28 d->filesIDs << fileId;
29}
30
31FileDeleteJob::FileDeleteJob(const QStringList &filesIds, const AccountPtr &account, QObject *parent)
32 : DeleteJob(account, parent)
33 , d(new Private)
34{
35 d->filesIDs << filesIds;
36}
37
38FileDeleteJob::FileDeleteJob(const FilePtr &file, const AccountPtr &account, QObject *parent)
39 : DeleteJob(account, parent)
40 , d(new Private)
41{
42 d->filesIDs << file->id();
43}
44
45FileDeleteJob::FileDeleteJob(const FilesList &files, const AccountPtr &account, QObject *parent)
46 : DeleteJob(account, parent)
47 , d(new Private)
48{
49 for (const FilePtr &file : std::as_const(files)) {
50 d->filesIDs << file->id();
51 }
52}
53
54FileDeleteJob::~FileDeleteJob()
55{
56 delete d;
57}
58
59void FileDeleteJob::start()
60{
61 if (d->filesIDs.isEmpty()) {
63 return;
64 }
65
66 const QString fileId = d->filesIDs.takeFirst();
67 const QUrl url = DriveService::deleteFileUrl(fileId);
68
69 QNetworkRequest request(url);
70 enqueueRequest(request);
71}
72
73#include "moc_filedeletejob.cpp"
Abstract superclass for all jobs that delete resources from Google.
Definition deletejob.h:25
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 fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
bool isEmpty() const const
value_type takeFirst()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:11:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.