Commit 0dcf4269 authored by David Barchiesi's avatar David Barchiesi
Browse files

Move useContentAsIndexableText param handling from FileAbstractUploadJob to FileAbstractDataJob.

parent 9404f971
Pipeline #31646 passed with stage
in 13 minutes and 18 seconds
POST https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/copy?convert=false&ocr=false&pinned=false&supportsAllDrives=true&prettyPrint=false
POST https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/copy?convert=false&ocr=false&pinned=false&useContentAsIndexableText=false&supportsAllDrives=true&prettyPrint=false
Content-Type: application/json
{
......
POST https://www.googleapis.com/drive/v2/files?convert=false&ocr=false&pinned=false&supportsAllDrives=true&useContentAsIndexableText=false&prettyPrint=false
POST https://www.googleapis.com/drive/v2/files?convert=false&ocr=false&pinned=false&useContentAsIndexableText=false&supportsAllDrives=true&prettyPrint=false
Content-Type: application/json
{
......
POST https://www.googleapis.com/drive/v2/files/abc123def456ghi789/copy?convert=false&ocr=false&pinned=false&supportsAllDrives=true&prettyPrint=false
POST https://www.googleapis.com/drive/v2/files/abc123def456ghi789/copy?convert=false&ocr=false&pinned=false&useContentAsIndexableText=false&supportsAllDrives=true&prettyPrint=false
Content-Type: application/json
{
......
......@@ -26,6 +26,7 @@ class Q_DECL_HIDDEN FileAbstractDataJob::Private
bool pinned;
QString timedTextLanguage;
QString timedTextTrackName;
bool useContentAsIndexableText;
bool supportsAllDrives;
};
......@@ -33,6 +34,7 @@ FileAbstractDataJob::Private::Private():
convert(false),
ocr(false),
pinned(false),
useContentAsIndexableText(false),
supportsAllDrives(true)
{
}
......@@ -140,6 +142,21 @@ void FileAbstractDataJob::setTimedTextTrackName(const QString &timedTextTrackNam
d->timedTextTrackName = timedTextTrackName;
}
void FileAbstractDataJob::setUseContentAsIndexableText(bool useContentAsIndexableText)
{
if (isRunning()) {
qCWarning(KGAPIDebug) << "Can't modify useContentAsIndexableText property when job is running";
return;
}
d->useContentAsIndexableText = useContentAsIndexableText;
}
bool FileAbstractDataJob::useContentAsIndexableText() const
{
return d->useContentAsIndexableText;
}
bool FileAbstractDataJob::supportsAllDrives() const
{
return d->supportsAllDrives;
......@@ -175,6 +192,9 @@ QUrl FileAbstractDataJob::updateUrl(QUrl &url)
if (!d->timedTextTrackName.isEmpty()) {
query.addQueryItem(QStringLiteral("timedTextTrackName"), d->timedTextTrackName);
}
query.removeQueryItem(QStringLiteral("useContentAsIndexableText"));
query.addQueryItem(QStringLiteral("useContentAsIndexableText"), Utils::bool2Str(d->useContentAsIndexableText));
query.removeQueryItem(QStringLiteral("supportsAllDrives"));
query.addQueryItem(QStringLiteral("supportsAllDrives"), Utils::bool2Str(d->supportsAllDrives));
......
......@@ -84,6 +84,17 @@ class KGAPIDRIVE_EXPORT FileAbstractDataJob : public KGAPI2::Job
READ timedTextTrackName
WRITE setTimedTextTrackName)
/**
* Whether to use the content as indexable text.
*
* Default value is false.
*
* This property can be modified only when the job is not running.
*/
Q_PROPERTY(bool useContentAsIndexableText
READ useContentAsIndexableText
WRITE setUseContentAsIndexableText)
/**
* Sets whether the request supports both My Drives and shared drives.
*
......@@ -118,6 +129,9 @@ class KGAPIDRIVE_EXPORT FileAbstractDataJob : public KGAPI2::Job
QString timedTextTrackName() const;
void setTimedTextTrackName(const QString &timedTextTrackName);
bool useContentAsIndexableText() const;
void setUseContentAsIndexableText(bool useContentAsIndexableText);
/**
* @brief Whether the request supports both My Drives and shared drives.
*
......
......@@ -44,7 +44,6 @@ class Q_DECL_HIDDEN FileAbstractUploadJob::Private
QMap<QString, FilePtr> uploadedFiles;
bool useContentAsIndexableText;
File::SerializationOptions serializationOptions = File::NoOptions;
private:
......@@ -53,7 +52,6 @@ class Q_DECL_HIDDEN FileAbstractUploadJob::Private
FileAbstractUploadJob::Private::Private(FileAbstractUploadJob *parent):
originalFilesCount(0),
useContentAsIndexableText(false),
q(parent)
{
}
......@@ -143,7 +141,6 @@ void FileAbstractUploadJob::Private::processNext()
q->updateUrl(url);
QUrlQuery query(url);
query.addQueryItem(QStringLiteral("useContentAsIndexableText"), Utils::bool2Str(useContentAsIndexableText));
QByteArray rawData;
QString contentType;
......@@ -269,21 +266,6 @@ FileAbstractUploadJob::~FileAbstractUploadJob()
delete d;
}
void FileAbstractUploadJob::setUseContentAsIndexableText(bool useContentAsIndexableText)
{
if (isRunning()) {
qCWarning(KGAPIDebug) << "Can't modify useContentAsIndexableText property when job is running";
return;
}
d->useContentAsIndexableText = useContentAsIndexableText;
}
bool FileAbstractUploadJob::useContentAsIndexableText() const
{
return d->useContentAsIndexableText;
}
void FileAbstractUploadJob::start()
{
d->processNext();
......
......@@ -26,17 +26,6 @@ class KGAPIDRIVE_EXPORT FileAbstractUploadJob : public KGAPI2::Drive::FileAbstra
{
Q_OBJECT
/**
* Whether to use the content as indexable text.
*
* Default value is false.
*
* This property can be modified only when the job is not running.
*/
Q_PROPERTY(bool useContentAsIndexableText
READ useContentAsIndexableText
WRITE setUseContentAsIndexableText)
public:
explicit FileAbstractUploadJob(const FilePtr &metadata,
const AccountPtr &account,
......@@ -59,9 +48,6 @@ class KGAPIDRIVE_EXPORT FileAbstractUploadJob : public KGAPI2::Drive::FileAbstra
const AccountPtr &account, QObject *parent = nullptr);
~FileAbstractUploadJob() override;
bool useContentAsIndexableText() const;
void setUseContentAsIndexableText(bool useContentAsIndexableText);
QMap < QString /* file path */, FilePtr /* metadata */ > files() const;
protected:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment