Kgapi

parentreferencedeletejob.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 "parentreferencedeletejob.h"
10#include "driveservice.h"
11#include "parentreference.h"
12
13#include <QNetworkRequest>
14
15using namespace KGAPI2;
16using namespace KGAPI2::Drive;
17
18class Q_DECL_HIDDEN ParentReferenceDeleteJob::Private
19{
20public:
21 QString fileId;
22 QStringList referencesIds;
23};
24
25ParentReferenceDeleteJob::ParentReferenceDeleteJob(const QString &fileId, const QString &referenceId, const AccountPtr &account, QObject *parent)
26 : DeleteJob(account, parent)
27 , d(new Private)
28{
29 d->fileId = fileId;
30 d->referencesIds << referenceId;
31}
32
33ParentReferenceDeleteJob::ParentReferenceDeleteJob(const QString &fileId, const QStringList &referencesIds, const AccountPtr &account, QObject *parent)
34 : DeleteJob(account, parent)
35 , d(new Private)
36{
37 d->fileId = fileId;
38 d->referencesIds << referencesIds;
39}
40
41ParentReferenceDeleteJob::ParentReferenceDeleteJob(const QString &fileId, const ParentReferencePtr &reference, const AccountPtr &account, QObject *parent)
42 : DeleteJob(account, parent)
43 , d(new Private)
44{
45 d->fileId = fileId;
46 d->referencesIds << reference->id();
47}
48
49ParentReferenceDeleteJob::ParentReferenceDeleteJob(const QString &fileId, const ParentReferencesList &references, const AccountPtr &account, QObject *parent)
50 : DeleteJob(account, parent)
51 , d(new Private)
52{
53 d->fileId = fileId;
54 for (const ParentReferencePtr &reference : references) {
55 d->referencesIds << reference->id();
56 }
57}
58
59ParentReferenceDeleteJob::~ParentReferenceDeleteJob()
60{
61 delete d;
62}
63
64void ParentReferenceDeleteJob::start()
65{
66 if (d->referencesIds.isEmpty()) {
68 return;
69 }
70
71 const QString referenceId = d->referencesIds.takeFirst();
72 const QUrl url = DriveService::deleteParentReferenceUrl(d->fileId, referenceId);
73
74 QNetworkRequest request(url);
75
76 enqueueRequest(request);
77}
78
79#include "moc_parentreferencedeletejob.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 Nov 22 2024 12:08:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.