Kgapi

fileabstractdatajob.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 "fileabstractdatajob.h"
10#include "debug.h"
11#include "utils.h"
12
13#include <QUrlQuery>
14
15using namespace KGAPI2;
16using namespace KGAPI2::Drive;
17
18class Q_DECL_HIDDEN FileAbstractDataJob::Private
19{
20public:
21 Private();
22
23 bool convert = false;
24 bool enforceSingleParent = false;
25 QString includePermissionsForView;
26 bool ocr = false;
27 QString ocrLanguage;
28 bool pinned = false;
29 bool supportsAllDrives = true;
30 QString timedTextLanguage;
31 QString timedTextTrackName;
32 bool useContentAsIndexableText = false;
33};
34
35FileAbstractDataJob::Private::Private()
36{
37}
38
39FileAbstractDataJob::FileAbstractDataJob(const AccountPtr &account, QObject *parent)
41 , d(new Private)
42{
43}
44
45FileAbstractDataJob::~FileAbstractDataJob()
46{
47 delete d;
48}
49
50bool FileAbstractDataJob::convert() const
51{
52 return d->convert;
53}
54
55void FileAbstractDataJob::setConvert(bool convert)
56{
57 if (isRunning()) {
58 qCWarning(KGAPIDebug) << "Can't modify setConvert property when job is running";
59 return;
60 }
61
62 d->convert = convert;
63}
64
65bool FileAbstractDataJob::enforceSingleParent() const
66{
67 return d->enforceSingleParent;
68}
69
70void FileAbstractDataJob::setEnforceSingleParent(bool enforceSingleParent)
71{
72 if (isRunning()) {
73 qCWarning(KGAPIDebug) << "Can't modify enforceSingleParent property when job is running";
74 return;
75 }
76
77 d->enforceSingleParent = enforceSingleParent;
78}
79
80QString FileAbstractDataJob::includePermissionsForView() const
81{
82 return d->includePermissionsForView;
83}
84
85void FileAbstractDataJob::setIncludePermissionsForView(const QString &includePermissionsForView)
86{
87 if (isRunning()) {
88 qCWarning(KGAPIDebug) << "Can't modify includePermissionsForView property when job is running";
89 return;
90 }
91
92 d->includePermissionsForView = includePermissionsForView;
93}
94
95bool FileAbstractDataJob::ocr() const
96{
97 return d->ocr;
98}
99
100void FileAbstractDataJob::setOcr(bool ocr)
101{
102 if (isRunning()) {
103 qCWarning(KGAPIDebug) << "Can't modify ocr property when job is running";
104 return;
105 }
106
107 d->ocr = ocr;
108}
109
110QString FileAbstractDataJob::ocrLanguage() const
111{
112 return d->ocrLanguage;
113}
114
115void FileAbstractDataJob::setOcrLanguage(const QString &ocrLanguage)
116{
117 if (isRunning()) {
118 qCWarning(KGAPIDebug) << "Can't modify ocrLanguage property when job is running";
119 return;
120 }
121
122 d->ocrLanguage = ocrLanguage;
123}
124
125bool FileAbstractDataJob::pinned() const
126{
127 return d->pinned;
128}
129
130void FileAbstractDataJob::setPinned(bool pinned)
131{
132 if (isRunning()) {
133 qCWarning(KGAPIDebug) << "Can't modify pinned property when job is running";
134 return;
135 }
136
137 d->pinned = pinned;
138}
139
140bool FileAbstractDataJob::supportsAllDrives() const
141{
142 return d->supportsAllDrives;
143}
144
145void FileAbstractDataJob::setSupportsAllDrives(bool supportsAllDrives)
146{
147 d->supportsAllDrives = supportsAllDrives;
148}
149
150QString FileAbstractDataJob::timedTextLanguage() const
151{
152 return d->timedTextLanguage;
153}
154
155void FileAbstractDataJob::setTimedTextLanguage(const QString &timedTextLanguage)
156{
157 if (isRunning()) {
158 qCWarning(KGAPIDebug) << "Can't modify timedTextLanguage property when job is running";
159 return;
160 }
161
162 d->timedTextLanguage = timedTextLanguage;
163}
164
165QString FileAbstractDataJob::timedTextTrackName() const
166{
167 return d->timedTextLanguage;
168}
169
170void FileAbstractDataJob::setTimedTextTrackName(const QString &timedTextTrackName)
171{
172 if (isRunning()) {
173 qCWarning(KGAPIDebug) << "Can't modify timedTextTrackName property when job is running";
174 return;
175 }
176
177 d->timedTextTrackName = timedTextTrackName;
178}
179
180void FileAbstractDataJob::setUseContentAsIndexableText(bool useContentAsIndexableText)
181{
182 if (isRunning()) {
183 qCWarning(KGAPIDebug) << "Can't modify useContentAsIndexableText property when job is running";
184 return;
185 }
186
187 d->useContentAsIndexableText = useContentAsIndexableText;
188}
189
190bool FileAbstractDataJob::useContentAsIndexableText() const
191{
192 return d->useContentAsIndexableText;
193}
194
195QUrl FileAbstractDataJob::updateUrl(QUrl &url)
196{
197 QUrlQuery query(url);
198 query.removeQueryItem(QStringLiteral("convert"));
199 query.addQueryItem(QStringLiteral("convert"), Utils::bool2Str(d->convert));
200
201 query.removeQueryItem(QStringLiteral("enforceSingleParent"));
202 query.removeQueryItem(QStringLiteral("includePermissionsForView"));
203 query.addQueryItem(QStringLiteral("enforceSingleParent"), Utils::bool2Str(d->enforceSingleParent));
204 if (!d->includePermissionsForView.isEmpty()) {
205 query.addQueryItem(QStringLiteral("includePermissionsForView"), d->includePermissionsForView);
206 }
207
208 query.removeQueryItem(QStringLiteral("ocr"));
209 query.removeQueryItem(QStringLiteral("ocrLanguage"));
210 query.addQueryItem(QStringLiteral("ocr"), Utils::bool2Str(d->ocr));
211 if (d->ocr && !d->ocrLanguage.isEmpty()) {
212 query.addQueryItem(QStringLiteral("ocrLanguage"), d->ocrLanguage);
213 }
214
215 query.removeQueryItem(QStringLiteral("pinned"));
216 query.addQueryItem(QStringLiteral("pinned"), Utils::bool2Str(d->pinned));
217
218 query.removeQueryItem(QStringLiteral("timedTextLanguage"));
219 if (!d->timedTextLanguage.isEmpty()) {
220 query.addQueryItem(QStringLiteral("timedTextLanguage"), d->timedTextLanguage);
221 }
222
223 query.removeQueryItem(QStringLiteral("timedTextTrackName"));
224 if (!d->timedTextTrackName.isEmpty()) {
225 query.addQueryItem(QStringLiteral("timedTextTrackName"), d->timedTextTrackName);
226 }
227
228 query.removeQueryItem(QStringLiteral("useContentAsIndexableText"));
229 query.addQueryItem(QStringLiteral("useContentAsIndexableText"), Utils::bool2Str(d->useContentAsIndexableText));
230
231 query.removeQueryItem(QStringLiteral("supportsAllDrives"));
232 query.addQueryItem(QStringLiteral("supportsAllDrives"), Utils::bool2Str(d->supportsAllDrives));
233
234 url.setQuery(query);
235 return url;
236}
237
238#include "moc_fileabstractdatajob.cpp"
Abstract base class for all jobs in LibKGAPI.
Definition job.h:41
AccountPtr account() const
Returns account used to authenticate requests.
Definition job.cpp:436
bool isRunning
Whether the job is running.
Definition job.h:67
KSERVICE_EXPORT KService::List query(FilterFunc filterFunc)
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
T convert(const QVariant &value)
QObject * parent() const const
bool isEmpty() const const
void setQuery(const QString &query, ParsingMode mode)
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.