9#include "filemodifyjob.h"
11#include "driveservice.h"
15#include <QNetworkAccessManager>
16#include <QNetworkRequest>
20using namespace KGAPI2::Drive;
22class Q_DECL_HIDDEN FileModifyJob::Private
27 QMap<QString , QString > files;
29 bool createNewRevision =
true;
30 bool changeModifiedDate =
false;
31 bool updateViewedDate =
true;
34FileModifyJob::Private::Private()
42 d->files.insert(QStringLiteral(
"?=0"), metadata->id());
46FileModifyJob::FileModifyJob(
const QString &filePath,
const QString &fileId,
const AccountPtr &account,
QObject *parent)
47 : FileAbstractUploadJob(filePath, account, parent)
50 d->files.insert(filePath, fileId);
53FileModifyJob::FileModifyJob(
const QString &filePath,
const FilePtr &metaData,
const AccountPtr &account,
QObject *parent)
54 : FileAbstractUploadJob(filePath, metaData, account, parent)
57 d->files.insert(filePath, metaData->id());
62 : FileAbstractUploadJob(files.keys(), account, parent)
69 : FileAbstractUploadJob(files, account, parent)
74 for (; iter != iterEnd; ++iter) {
75 d->files.insert(iter.
key(), iter.
value()->id());
80FileModifyJob::~FileModifyJob()
85bool FileModifyJob::createNewRevision()
const
87 return d->createNewRevision;
90void FileModifyJob::setCreateNewRevision(
bool createNewRevision)
93 qCWarning(KGAPIDebug) <<
"Can't modify createNewRevision property when the job is running";
97 d->createNewRevision = createNewRevision;
100bool FileModifyJob::updateModifiedDate()
const
102 return d->updateViewedDate;
105void FileModifyJob::setUpdateModifiedDate(
bool updateModifiedDate)
108 qCWarning(KGAPIDebug) <<
"Can't modify updateModifiedDate property when the job is running";
112 d->updateViewedDate = updateModifiedDate;
115bool FileModifyJob::updateViewedDate()
const
117 return d->updateViewedDate;
120void FileModifyJob::setUpdateViewedDate(
bool updateViewedDate)
123 qCWarning(KGAPIDebug) <<
"Can't modify updateViewedDate property when job is running";
127 d->updateViewedDate = updateViewedDate;
130QUrl FileModifyJob::createUrl(
const QString &filePath,
const FilePtr &metaData)
135 url = DriveService::uploadMediaFileUrl(d->files.value(filePath));
136 }
else if (filePath.
isEmpty()) {
137 url = DriveService::uploadMetadataFileUrl(metaData->id());
139 url = DriveService::uploadMultipartFileUrl(d->files.value(filePath));
142 QUrlQuery
query(url);
143 query.addQueryItem(QStringLiteral(
"newRevision"), Utils::bool2Str(d->createNewRevision));
144 query.addQueryItem(QStringLiteral(
"setModifiedDate"), Utils::bool2Str(d->changeModifiedDate));
145 query.addQueryItem(QStringLiteral(
"updateViewedDate"), Utils::bool2Str(d->updateViewedDate));
151QNetworkReply *FileModifyJob::dispatch(QNetworkAccessManager *accessManager,
const QNetworkRequest &request,
const QByteArray &data)
153 return accessManager->
put(request, data);
156#include "moc_filemodifyjob.cpp"
@ ExcludeCreationDate
Exclude 'createdDate' entry. This is necessary when renaming URLs.
AccountPtr account() const
Returns account used to authenticate requests.
bool isRunning
Whether the job is running.
KSERVICE_EXPORT KService::List query(FilterFunc filterFunc)
A job to fetch a single map tile described by a StaticMapUrl.
const_iterator constBegin() const const
const_iterator constEnd() const const
Key key(const T &value, const Key &defaultKey) const const
T value(const Key &key, const T &defaultValue) const const
QNetworkReply * put(const QNetworkRequest &request, QHttpMultiPart *multiPart)
QObject * parent() const const
bool isNull() const const
bool isEmpty() const const
void setQuery(const QString &query, ParsingMode mode)