File indexing completed on 2024-05-12 05:22:17
0001 /* 0002 * This file is part of LibKGAPI library 0003 * 0004 * SPDX-FileCopyrightText: 2019 David Barchiesi <david@barchie.si> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #include "drivesdeletejob.h" 0010 #include "drives.h" 0011 #include "driveservice.h" 0012 0013 #include <QNetworkRequest> 0014 0015 using namespace KGAPI2; 0016 using namespace KGAPI2::Drive; 0017 0018 class Q_DECL_HIDDEN DrivesDeleteJob::Private 0019 { 0020 public: 0021 QStringList drivesIds; 0022 }; 0023 0024 DrivesDeleteJob::DrivesDeleteJob(const QString &drivesId, const AccountPtr &account, QObject *parent) 0025 : DeleteJob(account, parent) 0026 , d(new Private) 0027 { 0028 d->drivesIds << drivesId; 0029 } 0030 0031 DrivesDeleteJob::DrivesDeleteJob(const QStringList &drivesIds, const AccountPtr &account, QObject *parent) 0032 : DeleteJob(account, parent) 0033 , d(new Private) 0034 { 0035 d->drivesIds << drivesIds; 0036 } 0037 0038 DrivesDeleteJob::DrivesDeleteJob(const DrivesPtr &drives, const AccountPtr &account, QObject *parent) 0039 : DeleteJob(account, parent) 0040 , d(new Private) 0041 { 0042 d->drivesIds << drives->id(); 0043 } 0044 0045 DrivesDeleteJob::DrivesDeleteJob(const DrivesList &drives, const AccountPtr &account, QObject *parent) 0046 : DeleteJob(account, parent) 0047 , d(new Private) 0048 { 0049 for (const DrivesPtr &drive : std::as_const(drives)) { 0050 d->drivesIds << drive->id(); 0051 } 0052 } 0053 0054 DrivesDeleteJob::~DrivesDeleteJob() = default; 0055 0056 void DrivesDeleteJob::start() 0057 { 0058 if (d->drivesIds.isEmpty()) { 0059 emitFinished(); 0060 return; 0061 } 0062 0063 const QString drivesId = d->drivesIds.takeFirst(); 0064 const QUrl url = DriveService::fetchDrivesUrl(drivesId); 0065 0066 QNetworkRequest request(url); 0067 enqueueRequest(request); 0068 } 0069 0070 #include "moc_drivesdeletejob.cpp"