Kgapi

drives.cpp
1/*
2 SPDX-FileCopyrightText: 2019 David Barchiesi <david@barchie.si>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "drives.h"
8#include "driveservice.h"
9#include "utils_p.h"
10
11#include <QJsonDocument>
12#include <QUrlQuery>
13#include <QVariant>
14
15namespace
16{
17static const QString ApiKind = QStringLiteral("drive#drive");
18static const QString ApiKindList = QStringLiteral("drive#driveList");
19}
20
21using namespace KGAPI2;
22using namespace KGAPI2::Drive;
23
24///// Drives::Restrictions
25
26class Q_DECL_HIDDEN Drives::Restrictions::Private
27{
28public:
29 Private() = default;
30 Private(const Private &other) = default;
31
32 bool adminManagedRestrictions = false;
33 bool copyRequiresWriterPermission = false;
34 bool domainUsersOnly = false;
35 bool driveMembersOnly = false;
36};
37
38Drives::Restrictions::Restrictions()
39 : d(new Private)
40{
41}
42
43Drives::Restrictions::Restrictions(const Drives::Restrictions &other)
44 : d(new Private(*(other.d)))
45{
46}
47
48Drives::Restrictions::~Restrictions() = default;
49
50bool Drives::Restrictions::operator==(const Drives::Restrictions &other) const
51{
52 GAPI_COMPARE(adminManagedRestrictions);
53 GAPI_COMPARE(copyRequiresWriterPermission);
54 GAPI_COMPARE(domainUsersOnly);
55 GAPI_COMPARE(driveMembersOnly);
56 return true;
57}
58
60{
61 return d->adminManagedRestrictions;
62}
63
64void Drives::Restrictions::setAdminManagedRestrictions(bool adminManagedRestrictions) const
65{
66 d->adminManagedRestrictions = adminManagedRestrictions;
67}
68
70{
71 return d->copyRequiresWriterPermission;
72}
73
74void Drives::Restrictions::setCopyRequiresWriterPermission(bool copyRequiresWriterPermission) const
75{
76 d->copyRequiresWriterPermission = copyRequiresWriterPermission;
77}
78
80{
81 return d->domainUsersOnly;
82}
83
84void Drives::Restrictions::setDomainUsersOnly(bool domainUsersOnly) const
85{
86 d->domainUsersOnly = domainUsersOnly;
87}
88
90{
91 return d->driveMembersOnly;
92}
93
94void Drives::Restrictions::setDriveMembersOnly(bool driveMembersOnly) const
95{
96 d->driveMembersOnly = driveMembersOnly;
97}
98
99///// Drives::Capabilities
100
101class Q_DECL_HIDDEN Drives::Capabilities::Private
102{
103public:
104 Private() = default;
105 Private(const Private &other) = default;
106
107 bool canAddChildren = false;
108 bool canChangeCopyRequiresWriterPermissionRestriction = false;
109 bool canChangeDomainUsersOnlyRestriction = false;
110 bool canChangeDriveBackground = false;
111 bool canChangeDriveMembersOnlyRestriction = false;
112 bool canComment = false;
113 bool canCopy = false;
114 bool canDeleteChildren = false;
115 bool canDeleteDrive = false;
116 bool canDownload = false;
117 bool canEdit = false;
118 bool canListChildren = false;
119 bool canManageMembers = false;
120 bool canReadRevisions = false;
121 bool canRename = false;
122 bool canRenameDrive = false;
123 bool canShare = false;
124 bool canTrashChildren = false;
125};
126
127Drives::Capabilities::Capabilities()
128 : d(new Private)
129{
130}
131
132Drives::Capabilities::Capabilities(const Drives::Capabilities &other)
133 : d(new Private(*(other.d)))
134{
135}
136
137Drives::Capabilities::~Capabilities() = default;
138
139bool Drives::Capabilities::operator==(const Drives::Capabilities &other) const
140{
141 GAPI_COMPARE(canAddChildren);
142 GAPI_COMPARE(canChangeCopyRequiresWriterPermissionRestriction);
143 GAPI_COMPARE(canChangeDomainUsersOnlyRestriction);
144 GAPI_COMPARE(canChangeDriveBackground);
145 GAPI_COMPARE(canChangeDriveMembersOnlyRestriction);
146 GAPI_COMPARE(canComment);
147 GAPI_COMPARE(canCopy);
148 GAPI_COMPARE(canDeleteChildren);
149 GAPI_COMPARE(canDeleteDrive);
150 GAPI_COMPARE(canDownload);
151 GAPI_COMPARE(canEdit);
152 GAPI_COMPARE(canListChildren);
153 GAPI_COMPARE(canManageMembers);
154 GAPI_COMPARE(canReadRevisions);
155 GAPI_COMPARE(canRename);
156 GAPI_COMPARE(canRenameDrive);
157 GAPI_COMPARE(canShare);
158 GAPI_COMPARE(canTrashChildren);
159 return true;
160}
161
163{
164 return d->canAddChildren;
165}
166
168{
169 return d->canChangeCopyRequiresWriterPermissionRestriction;
170}
171
173{
174 return d->canChangeDomainUsersOnlyRestriction;
175}
176
178{
179 return d->canChangeDriveBackground;
180}
181
183{
184 return d->canChangeDriveMembersOnlyRestriction;
185}
186
188{
189 return d->canComment;
190}
191
193{
194 return d->canCopy;
195}
196
198{
199 return d->canDeleteChildren;
200}
201
203{
204 return d->canDeleteDrive;
205}
206
208{
209 return d->canDownload;
210}
211
213{
214 return d->canEdit;
215}
216
218{
219 return d->canListChildren;
220}
221
223{
224 return d->canManageMembers;
225}
226
228{
229 return d->canReadRevisions;
230}
231
233{
234 return d->canRename;
235}
236
238{
239 return d->canRenameDrive;
240}
241
243{
244 return d->canShare;
245}
246
248{
249 return d->canTrashChildren;
250}
251
252///// Drives::BackgroundImageFile
253
254class Q_DECL_HIDDEN Drives::BackgroundImageFile::Private
255{
256public:
257 Private() = default;
258 Private(const Private &other) = default;
259
260 QString id;
261 float xCoordinate = 0.0f;
262 float yCoordinate = 0.0f;
263 float width = 0.0f;
264};
265
266Drives::BackgroundImageFile::BackgroundImageFile()
267 : d(new Private)
268{
269}
270
271Drives::BackgroundImageFile::BackgroundImageFile(const Drives::BackgroundImageFile &other)
272 : d(new Private(*(other.d)))
273{
274}
275
276Drives::BackgroundImageFile::~BackgroundImageFile() = default;
277
278bool Drives::BackgroundImageFile::operator==(const Drives::BackgroundImageFile &other) const
279{
280 GAPI_COMPARE(id);
281 GAPI_COMPARE(xCoordinate);
282 GAPI_COMPARE(yCoordinate);
283 GAPI_COMPARE(width);
284 return true;
285}
286
288{
289 return d->id;
290}
291
293{
294 d->id = id;
295}
296
298{
299 return d->xCoordinate;
300}
301
302void Drives::BackgroundImageFile::setXCoordinate(const float xCoordinate) const
303{
304 d->xCoordinate = xCoordinate;
305}
306
308{
309 return d->yCoordinate;
310}
311
312void Drives::BackgroundImageFile::setYCoordinate(const float yCoordinate) const
313{
314 d->yCoordinate = yCoordinate;
315}
316
318{
319 return d->width;
320}
321
322void Drives::BackgroundImageFile::setWidth(const float width) const
323{
324 d->width = width;
325}
326
327///// Drives
328
329class Q_DECL_HIDDEN Drives::Private
330{
331public:
332 Private() = default;
333 Private(const Private &other) = default;
334
335 QString id;
336 QString name;
337 QString themeId;
338 QString colorRgb;
339 BackgroundImageFilePtr backgroundImageFile;
340 QString backgroundImageLink;
341 CapabilitiesPtr capabilities;
342 QDateTime createdDate;
343 bool hidden = false;
344 RestrictionsPtr restrictions;
345
346 static DrivesPtr fromJSON(const QVariantMap &map);
347};
348
349DrivesPtr Drives::Private::fromJSON(const QVariantMap &map)
350{
351 if (!map.contains(Drives::Fields::Kind) || map[Drives::Fields::Kind].toString() != ApiKind) {
352 return DrivesPtr();
353 }
354
355 auto drives = DrivesPtr::create();
356 if (map.contains(Drives::Fields::Id)) {
357 drives->d->id = map[Drives::Fields::Id].toString();
358 }
359 if (map.contains(Drives::Fields::Name)) {
360 drives->d->name = map[Drives::Fields::Name].toString();
361 }
362 if (map.contains(Drives::Fields::ThemeId)) {
363 drives->d->themeId = map[Drives::Fields::ThemeId].toString();
364 }
365 if (map.contains(Drives::Fields::ColorRgb)) {
366 drives->d->colorRgb = map[Drives::Fields::ColorRgb].toString();
367 }
368 if (map.contains(Drives::Fields::BackgroundImageLink)) {
369 drives->d->backgroundImageLink = map[Drives::Fields::BackgroundImageLink].toString();
370 }
371 if (map.contains(Drives::Fields::CreatedDate)) {
372 drives->d->createdDate = QDateTime::fromString(map[Drives::Fields::CreatedDate].toString(), Qt::ISODate);
373 }
374 if (map.contains(Drives::Fields::Hidden)) {
375 drives->d->hidden = map[Drives::Fields::Hidden].toBool();
376 }
377
378 if (map.contains(Drives::Fields::BackgroundImageFile)) {
379 const QVariantMap backgroundImageFileMap = map[Drives::Fields::BackgroundImageFile].toMap();
381 backgroundImageFile->d->id = backgroundImageFileMap[Drives::BackgroundImageFile::Fields::Id].toString();
382 backgroundImageFile->d->xCoordinate = backgroundImageFileMap[Drives::BackgroundImageFile::Fields::XCoordinate].toReal();
383 backgroundImageFile->d->yCoordinate = backgroundImageFileMap[Drives::BackgroundImageFile::Fields::YCoordinate].toReal();
384 backgroundImageFile->d->width = backgroundImageFileMap[Drives::BackgroundImageFile::Fields::Width].toReal();
385 drives->d->backgroundImageFile = backgroundImageFile;
386 }
387
388 if (map.contains(Drives::Fields::Capabilities)) {
389 const QVariantMap capabilitiesMap = map[Drives::Fields::Capabilities].toMap();
391 capabilities->d->canAddChildren = capabilitiesMap[Drives::Capabilities::Fields::CanAddChildren].toBool();
392 capabilities->d->canChangeCopyRequiresWriterPermissionRestriction =
393 capabilitiesMap[Drives::Capabilities::Fields::CanChangeCopyRequiresWriterPermissionRestriction].toBool();
394 capabilities->d->canChangeDomainUsersOnlyRestriction = capabilitiesMap[Drives::Capabilities::Fields::CanChangeDomainUsersOnlyRestriction].toBool();
395 capabilities->d->canChangeDriveBackground = capabilitiesMap[Drives::Capabilities::Fields::CanChangeDriveBackground].toBool();
396 capabilities->d->canChangeDriveMembersOnlyRestriction = capabilitiesMap[Drives::Capabilities::Fields::CanChangeDriveMembersOnlyRestriction].toBool();
397 capabilities->d->canComment = capabilitiesMap[Drives::Capabilities::Fields::CanComment].toBool();
398 capabilities->d->canCopy = capabilitiesMap[Drives::Capabilities::Fields::CanCopy].toBool();
399 capabilities->d->canDeleteChildren = capabilitiesMap[Drives::Capabilities::Fields::CanDeleteChildren].toBool();
400 capabilities->d->canDeleteDrive = capabilitiesMap[Drives::Capabilities::Fields::CanDeleteDrive].toBool();
401 capabilities->d->canDownload = capabilitiesMap[Drives::Capabilities::Fields::CanDownload].toBool();
402 capabilities->d->canEdit = capabilitiesMap[Drives::Capabilities::Fields::CanEdit].toBool();
403 capabilities->d->canListChildren = capabilitiesMap[Drives::Capabilities::Fields::CanListChildren].toBool();
404 capabilities->d->canManageMembers = capabilitiesMap[Drives::Capabilities::Fields::CanManageMembers].toBool();
405 capabilities->d->canReadRevisions = capabilitiesMap[Drives::Capabilities::Fields::CanReadRevisions].toBool();
406 capabilities->d->canRename = capabilitiesMap[Drives::Capabilities::Fields::CanRename].toBool();
407 capabilities->d->canRenameDrive = capabilitiesMap[Drives::Capabilities::Fields::CanRenameDrive].toBool();
408 capabilities->d->canShare = capabilitiesMap[Drives::Capabilities::Fields::CanShare].toBool();
409 capabilities->d->canTrashChildren = capabilitiesMap[Drives::Capabilities::Fields::CanTrashChildren].toBool();
410 drives->d->capabilities = capabilities;
411 }
412
413 if (map.contains(Drives::Fields::Restrictions)) {
414 const QVariantMap restrictionsMap = map[Drives::Fields::Restrictions].toMap();
416 restrictions->d->adminManagedRestrictions = restrictionsMap[Drives::Restrictions::Fields::AdminManagedRestrictions].toBool();
417 restrictions->d->copyRequiresWriterPermission = restrictionsMap[Drives::Restrictions::Fields::CopyRequiresWriterPermission].toBool();
418 restrictions->d->domainUsersOnly = restrictionsMap[Drives::Restrictions::Fields::DomainUsersOnly].toBool();
419 restrictions->d->driveMembersOnly = restrictionsMap[Drives::Restrictions::Fields::DriveMembersOnly].toBool();
420 drives->d->restrictions = restrictions;
421 }
422
423 return drives;
424}
425
426const QString Drives::Restrictions::Fields::AdminManagedRestrictions = QStringLiteral("adminManagedRestrictions");
427const QString Drives::Restrictions::Fields::CopyRequiresWriterPermission = QStringLiteral("copyRequiresWriterPermission");
428const QString Drives::Restrictions::Fields::DomainUsersOnly = QStringLiteral("domainUsersOnly");
429const QString Drives::Restrictions::Fields::DriveMembersOnly = QStringLiteral("driveMembersOnly");
430
431const QString Drives::Capabilities::Fields::CanAddChildren = QStringLiteral("canAddChildren");
432const QString Drives::Capabilities::Fields::CanChangeCopyRequiresWriterPermissionRestriction =
433 QStringLiteral("canChangeCopyRequiresWriterPermissionRestriction");
434const QString Drives::Capabilities::Fields::CanChangeDomainUsersOnlyRestriction = QStringLiteral("canChangeDomainUsersOnlyRestriction");
435const QString Drives::Capabilities::Fields::CanChangeDriveBackground = QStringLiteral("canChangeDriveBackground");
436const QString Drives::Capabilities::Fields::CanChangeDriveMembersOnlyRestriction = QStringLiteral("canChangeDriveMembersOnlyRestriction");
437const QString Drives::Capabilities::Fields::CanComment = QStringLiteral("canComment");
438const QString Drives::Capabilities::Fields::CanCopy = QStringLiteral("canCopy");
439const QString Drives::Capabilities::Fields::CanDeleteChildren = QStringLiteral("canDeleteChildren");
440const QString Drives::Capabilities::Fields::CanDeleteDrive = QStringLiteral("canDeleteDrive");
441const QString Drives::Capabilities::Fields::CanDownload = QStringLiteral("canDownload");
442const QString Drives::Capabilities::Fields::CanEdit = QStringLiteral("canEdit");
443const QString Drives::Capabilities::Fields::CanListChildren = QStringLiteral("canListChildren");
444const QString Drives::Capabilities::Fields::CanManageMembers = QStringLiteral("canManageMembers");
445const QString Drives::Capabilities::Fields::CanReadRevisions = QStringLiteral("canReadRevisions");
446const QString Drives::Capabilities::Fields::CanRename = QStringLiteral("canRename");
447const QString Drives::Capabilities::Fields::CanRenameDrive = QStringLiteral("canRenameDrive");
448const QString Drives::Capabilities::Fields::CanShare = QStringLiteral("canShare");
449const QString Drives::Capabilities::Fields::CanTrashChildren = QStringLiteral("canTrashChildren");
450
451const QString Drives::BackgroundImageFile::Fields::Id = QStringLiteral("id");
452const QString Drives::BackgroundImageFile::Fields::XCoordinate = QStringLiteral("xCoordinate");
453const QString Drives::BackgroundImageFile::Fields::YCoordinate = QStringLiteral("yCoordinate");
454const QString Drives::BackgroundImageFile::Fields::Width = QStringLiteral("width");
455
456const QString Drives::Fields::Items = QStringLiteral("items");
457const QString Drives::Fields::KindDrive = QStringLiteral("kind");
458const QString Drives::Fields::PageToken = QStringLiteral("pageToken");
459const QString Drives::Fields::NextPageToken = QStringLiteral("nextPageToken");
460const QString Drives::Fields::Id = QStringLiteral("id");
461const QString Drives::Fields::Kind = QStringLiteral("kind");
462const QString Drives::Fields::Name = QStringLiteral("name");
463const QString Drives::Fields::ThemeId = QStringLiteral("themeId");
464const QString Drives::Fields::ColorRgb = QStringLiteral("colorRgb");
465const QString Drives::Fields::BackgroundImageFile = QStringLiteral("backgroundImageFile");
466const QString Drives::Fields::BackgroundImageLink = QStringLiteral("backgroundImageLink");
467const QString Drives::Fields::Capabilities = QStringLiteral("capabilities");
468const QString Drives::Fields::CreatedDate = QStringLiteral("createdDate");
469const QString Drives::Fields::Hidden = QStringLiteral("hidden");
470const QString Drives::Fields::Restrictions = QStringLiteral("restrictions");
471
472Drives::Drives()
473 : KGAPI2::Object()
474 , d(new Private)
475{
476}
477
478Drives::Drives(const Drives &other)
479 : KGAPI2::Object(other)
480 , d(new Private(*(other.d)))
481{
482}
483
484Drives::~Drives() = default;
485
486bool Drives::operator==(const Drives &other) const
487{
488 if (!Object::operator==(other)) {
489 return false;
490 }
491 GAPI_COMPARE(id);
492 GAPI_COMPARE(name);
493 GAPI_COMPARE(themeId);
494 GAPI_COMPARE(colorRgb);
495 GAPI_COMPARE_SHAREDPTRS(backgroundImageFile);
496 GAPI_COMPARE(backgroundImageLink);
497 GAPI_COMPARE_SHAREDPTRS(capabilities);
498 GAPI_COMPARE(createdDate);
499 GAPI_COMPARE(hidden);
500 GAPI_COMPARE_SHAREDPTRS(restrictions);
501 return true;
502}
503
505{
506 return d->id;
507}
508
509void Drives::setId(const QString &id) const
510{
511 d->id = id;
512}
513
515{
516 return d->name;
517}
518
519void Drives::setName(const QString &name) const
520{
521 d->name = name;
522}
523
525{
526 return d->themeId;
527}
528
530{
531 d->themeId = themeId;
532}
533
535{
536 return d->colorRgb;
537}
538
540{
541 d->colorRgb = colorRgb;
542}
543
545{
546 return d->backgroundImageFile;
547}
548
553
555{
556 return d->backgroundImageLink;
557}
558
560{
561 return d->capabilities;
562}
563
565{
566 return d->createdDate;
567}
568
569bool Drives::hidden() const
570{
571 return d->hidden;
572}
573
575{
576 d->restrictions = restrictions;
577}
578
580{
581 return d->restrictions;
582}
583
584DrivesPtr Drives::fromJSON(const QByteArray &jsonData)
585{
586 QJsonDocument document = QJsonDocument::fromJson(jsonData);
587 if (document.isNull()) {
588 return DrivesPtr();
589 }
590
591 const QVariant data = document.toVariant();
592 return Private::fromJSON(data.toMap());
593}
594
595DrivesList Drives::fromJSONFeed(const QByteArray &jsonData, FeedData &feedData)
596{
597 QJsonDocument document = QJsonDocument::fromJson(jsonData);
598 if (document.isNull()) {
599 return DrivesList();
600 }
601
602 const QVariant data = document.toVariant();
603 const QVariantMap map = data.toMap();
604 if (!map.contains(Drives::Fields::Kind) || map[Drives::Fields::Kind].toString() != ApiKindList) {
605 return DrivesList();
606 }
607
608 if (map.contains(Drives::Fields::NextPageToken)) {
609 feedData.nextPageUrl = DriveService::fetchDrivesUrl();
610 QUrlQuery query(feedData.nextPageUrl);
611 query.addQueryItem(Drives::Fields::PageToken, map.value(Drives::Fields::NextPageToken).toString());
612 feedData.nextPageUrl.setQuery(query);
613 }
614
616 const QVariantList items = map[Drives::Fields::Items].toList();
617 for (const QVariant &item : items) {
618 const DrivesPtr drives = Private::fromJSON(item.toMap());
619
620 if (!drives.isNull()) {
621 list << drives;
622 }
623 }
624
625 return list;
626}
627
628QByteArray Drives::toJSON(const DrivesPtr &drives)
629{
630 QVariantMap drivesMap;
631 drivesMap[Drives::Fields::Kind] = ApiKind;
632 if (!drives->id().isEmpty()) {
633 drivesMap[Drives::Fields::Id] = drives->id();
634 }
635 if (!drives->name().isEmpty()) {
636 drivesMap[Drives::Fields::Name] = drives->name();
637 }
638 if (!drives->themeId().isEmpty()) {
639 drivesMap[Drives::Fields::ThemeId] = drives->themeId();
640 }
641 if (!drives->colorRgb().isEmpty()) {
642 drivesMap[Drives::Fields::ColorRgb] = drives->colorRgb();
643 }
644 if (!drives->backgroundImageLink().isEmpty()) {
645 drivesMap[Drives::Fields::BackgroundImageLink] = drives->backgroundImageLink();
646 }
647 if (drives->createdDate().isValid()) {
648 drivesMap[Drives::Fields::CreatedDate] = drives->createdDate();
649 }
650 drivesMap[Drives::Fields::Hidden] = drives->hidden();
651
652 if (drives->restrictions()) {
653 QVariantMap restrictionsMap;
654 restrictionsMap[Drives::Restrictions::Fields::AdminManagedRestrictions] = drives->restrictions()->adminManagedRestrictions();
655 restrictionsMap[Drives::Restrictions::Fields::CopyRequiresWriterPermission] = drives->restrictions()->copyRequiresWriterPermission();
656 restrictionsMap[Drives::Restrictions::Fields::DomainUsersOnly] = drives->restrictions()->domainUsersOnly();
657 restrictionsMap[Drives::Restrictions::Fields::DriveMembersOnly] = drives->restrictions()->driveMembersOnly();
658 drivesMap[Drives::Fields::Restrictions] = restrictionsMap;
659 }
660
661 if (drives->backgroundImageFile()) {
662 QVariantMap backgroundImageFileMap;
663 backgroundImageFileMap[Drives::BackgroundImageFile::Fields::Id] = drives->backgroundImageFile()->id();
664 backgroundImageFileMap[Drives::BackgroundImageFile::Fields::XCoordinate] = drives->backgroundImageFile()->xCoordinate();
665 backgroundImageFileMap[Drives::BackgroundImageFile::Fields::YCoordinate] = drives->backgroundImageFile()->yCoordinate();
666 backgroundImageFileMap[Drives::BackgroundImageFile::Fields::Width] = drives->backgroundImageFile()->width();
667 drivesMap[Drives::Fields::BackgroundImageFile] = backgroundImageFileMap;
668 }
669
670 if (drives->capabilities()) {
671 QVariantMap capabilitiesMap;
672 capabilitiesMap[Drives::Capabilities::Fields::CanAddChildren] = drives->capabilities()->canAddChildren();
673 capabilitiesMap[Drives::Capabilities::Fields::CanChangeCopyRequiresWriterPermissionRestriction] =
674 drives->capabilities()->canChangeCopyRequiresWriterPermissionRestriction();
675 capabilitiesMap[Drives::Capabilities::Fields::CanChangeDomainUsersOnlyRestriction] = drives->capabilities()->canChangeDomainUsersOnlyRestriction();
676 capabilitiesMap[Drives::Capabilities::Fields::CanChangeDriveBackground] = drives->capabilities()->canChangeDriveBackground();
677 capabilitiesMap[Drives::Capabilities::Fields::CanChangeDriveMembersOnlyRestriction] = drives->capabilities()->canChangeDriveMembersOnlyRestriction();
678 capabilitiesMap[Drives::Capabilities::Fields::CanComment] = drives->capabilities()->canComment();
679 capabilitiesMap[Drives::Capabilities::Fields::CanCopy] = drives->capabilities()->canCopy();
680 capabilitiesMap[Drives::Capabilities::Fields::CanDeleteChildren] = drives->capabilities()->canDeleteChildren();
681 capabilitiesMap[Drives::Capabilities::Fields::CanDeleteDrive] = drives->capabilities()->canDeleteDrive();
682 capabilitiesMap[Drives::Capabilities::Fields::CanDownload] = drives->capabilities()->canDownload();
683 capabilitiesMap[Drives::Capabilities::Fields::CanEdit] = drives->capabilities()->canEdit();
684 capabilitiesMap[Drives::Capabilities::Fields::CanListChildren] = drives->capabilities()->canListChildren();
685 capabilitiesMap[Drives::Capabilities::Fields::CanManageMembers] = drives->capabilities()->canManageMembers();
686 capabilitiesMap[Drives::Capabilities::Fields::CanReadRevisions] = drives->capabilities()->canReadRevisions();
687 capabilitiesMap[Drives::Capabilities::Fields::CanRename] = drives->capabilities()->canRename();
688 capabilitiesMap[Drives::Capabilities::Fields::CanRenameDrive] = drives->capabilities()->canRenameDrive();
689 capabilitiesMap[Drives::Capabilities::Fields::CanShare] = drives->capabilities()->canShare();
690 capabilitiesMap[Drives::Capabilities::Fields::CanTrashChildren] = drives->capabilities()->canTrashChildren();
691 drivesMap[Drives::Fields::Capabilities] = capabilitiesMap;
692 }
693
694 QJsonDocument document = QJsonDocument::fromVariant(drivesMap);
695 return document.toJson(QJsonDocument::Compact);
696}
Drives::BackgroundImageFile holds the structure used for backgroundImageFile property.
Definition drives.h:291
void setId(const QString &id) const
Sets the ID of an image file in Google Drive to use for the background image.
Definition drives.cpp:292
void setYCoordinate(float yCoordinate) const
Sets the Y coordinate of the upper left corner of the cropping area in the background image.
Definition drives.cpp:312
void setWidth(float width) const
Sets the width of the cropped image in the closed range of 0 to 1.
Definition drives.cpp:322
void setXCoordinate(float xCoordinate) const
Returns the X coordinate of the upper left corner of the cropping area in the background image.
Definition drives.cpp:302
QString id() const
Returns the ID of an image file in Google Drive to use for the background image.
Definition drives.cpp:287
float width() const
Returns the width of the cropped image in the closed range of 0 to 1.
Definition drives.cpp:317
float xCoordinate() const
Returns the X coordinate of the upper left corner of the cropping area in the background image.
Definition drives.cpp:297
float yCoordinate() const
Returns the Y coordinate of the upper left corner of the cropping area in the background image.
Definition drives.cpp:307
Drives::Capabilities holds the structure used for capabilities the current user has on this shared dr...
Definition drives.h:137
bool canRenameDrive() const
Returns Whether the current user can rename this shared drive.
Definition drives.cpp:237
bool canEdit() const
Returns Whether the current user can edit files in this shared drive.
Definition drives.cpp:212
bool canShare() const
Returns Whether the current user can share files or folders in this shared drive.
Definition drives.cpp:242
bool canManageMembers() const
Returns Whether the current user can add members to this shared drive or remove them or change their ...
Definition drives.cpp:222
bool canCopy() const
Returns Whether the current user can copy files in this shared drive.
Definition drives.cpp:192
bool canDownload() const
Returns Whether the current user can download files in this shared drive.
Definition drives.cpp:207
bool canListChildren() const
Returns Whether the current user can list the children of folders in this shared drive.
Definition drives.cpp:217
bool canAddChildren() const
Returns whether the current user can add children to folders in this shared drive.
Definition drives.cpp:162
bool canReadRevisions() const
Returns Whether the current user can read the revisions resource of files in this shared drive.
Definition drives.cpp:227
bool canDeleteDrive() const
Returns Whether the current user can delete this shared drive.
Definition drives.cpp:202
bool canChangeCopyRequiresWriterPermissionRestriction() const
Returns whether the current user can change the copyRequiresWriterPermission restriction of this shar...
Definition drives.cpp:167
bool canRename() const
Returns Whether the current user can rename files or folders in this shared drive.
Definition drives.cpp:232
bool canTrashChildren() const
Returns Whether the current user can trash children from folders in this shared drive.
Definition drives.cpp:247
bool canComment() const
Returns Whether the current user can comment on files in this shared drive.
Definition drives.cpp:187
bool canChangeDriveMembersOnlyRestriction() const
Returns whether the current user can change the driveMembersOnly restriction of this shared drive.
Definition drives.cpp:182
bool canDeleteChildren() const
Returns Whether the current user can delete children from folders in this shared drive.
Definition drives.cpp:197
bool canChangeDomainUsersOnlyRestriction() const
Returns whether the current user can change the domainUsersOnly restriction of this shared drive.
Definition drives.cpp:172
bool canChangeDriveBackground() const
Returns whether the current user can change the background of this shared drive.
Definition drives.cpp:177
Drives::Restrictions holds the structure used for a set of restrictions that apply to this shared dri...
Definition drives.h:41
void setDomainUsersOnly(bool domainUsersOnly) const
Sets whether access to this shared drive and items inside this shared drive is restricted to users of...
Definition drives.cpp:84
void setAdminManagedRestrictions(bool adminManagedRestrictions) const
Sets whether administrative privileges on this shared drive are required to modify restrictions.
Definition drives.cpp:64
void setCopyRequiresWriterPermission(bool copyRequiresWriterPermission) const
Sets whether the options to copy, print, or download files inside this shared drive,...
Definition drives.cpp:74
void setDriveMembersOnly(bool driveMembersOnly) const
Sets whether access to items inside this shared drive is restricted to its members.
Definition drives.cpp:94
bool copyRequiresWriterPermission() const
Returns whether the options to copy, print, or download files inside this shared drive,...
Definition drives.cpp:69
bool driveMembersOnly() const
Returns whether access to items inside this shared drive is restricted to its members.
Definition drives.cpp:89
bool adminManagedRestrictions() const
Returns whether administrative privileges on this shared drive are required to modify restrictions.
Definition drives.cpp:59
bool domainUsersOnly() const
Returns whether access to this shared drive and items inside this shared drive is restricted to users...
Definition drives.cpp:79
Drives contains a representation of a Drive.
Definition drives.h:33
void setName(const QString &name) const
Sets the name of the drive.
Definition drives.cpp:519
void setThemeId(const QString &themeId) const
Sets the themeId of the shared drive.
Definition drives.cpp:529
bool hidden() const
Returns whether the shared drive is hidden from default view.
Definition drives.cpp:569
QString colorRgb() const
Returns the colorRgb of the shared drive.
Definition drives.cpp:534
QString id() const
Returns the ID of this shared drive which is also the ID of the top level folder of this shared drive...
Definition drives.cpp:504
CapabilitiesPtr capabilities() const
Returns the capabilities the current user has on this shared drive.
Definition drives.cpp:559
void setBackgroundImageFile(const BackgroundImageFilePtr &backgroundImageFile) const
Sets the backgroundImageFile of the shared drive.
Definition drives.cpp:549
RestrictionsPtr restrictions() const
Returns the set of restrictions that apply to this shared drive or items inside this shared drive.
Definition drives.cpp:579
QString name() const
Returns the name of the drive.
Definition drives.cpp:514
void setId(const QString &id) const
Sets the ID of this shared drive which is also the ID of the top level folder of this shared drive.
Definition drives.cpp:509
void setColorRgb(const QString &colorRgb) const
Sets the colorRgb of the shared drive.
Definition drives.cpp:539
QDateTime createdDate() const
Returns the time at which the shared drive was created.
Definition drives.cpp:564
QString backgroundImageLink() const
Returns the backgroundImageLink of the shared drive.
Definition drives.cpp:554
QString themeId() const
Returns the themeId of the drive.
Definition drives.cpp:524
void setRestrictions(const RestrictionsPtr &restrictions) const
Sets the restrictions of the shared drive.
Definition drives.cpp:574
BackgroundImageFilePtr backgroundImageFile() const
Returns the image file and cropping parameters from which a background image for this shared drive is...
Definition drives.cpp:544
Structure to store additional information about a feed.
Definition types.h:24
QUrl nextPageUrl
Link to next page of feed.
Definition types.h:38
Base class for all objects.
Definition object.h:31
char * toString(const EngineQuery &query)
KSERVICE_EXPORT KService::List query(FilterFunc filterFunc)
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
KIOCORE_EXPORT QStringList list(const QString &fileClass)
QDateTime fromString(QStringView string, QStringView format, QCalendar cal)
QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error)
QJsonDocument fromVariant(const QVariant &variant)
bool isNull() const const
QByteArray toJson(JsonFormat format) const const
QVariant toVariant() const const
QSharedPointer< T > create(Args &&... args)
bool isNull() const const
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
void setQuery(const QString &query, ParsingMode mode)
QMap< QString, QVariant > toMap() const const
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.