Kgapi

teamdrive.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 "teamdrive.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#teamDrive");
18static const QString ApiKindList = QStringLiteral("drive#teamDriveList");
19}
20
21using namespace KGAPI2;
22using namespace KGAPI2::Drive;
23
24///// DriveTeamdrive::Restrictions
25
26class Q_DECL_HIDDEN Teamdrive::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 teamMembersOnly = false;
36};
37
38Teamdrive::Restrictions::Restrictions()
39 : d(new Private)
40{
41}
42
43Teamdrive::Restrictions::Restrictions(const Teamdrive::Restrictions &other)
44 : d(new Private(*(other.d)))
45{
46}
47
48Teamdrive::Restrictions::~Restrictions() = default;
49
50bool Teamdrive::Restrictions::operator==(const Teamdrive::Restrictions &other) const
51{
52 GAPI_COMPARE(adminManagedRestrictions);
53 GAPI_COMPARE(copyRequiresWriterPermission);
54 GAPI_COMPARE(domainUsersOnly);
55 GAPI_COMPARE(teamMembersOnly);
56 return true;
57}
58
60{
61 return d->adminManagedRestrictions;
62}
63
64void Teamdrive::Restrictions::setAdminManagedRestrictions(bool adminManagedRestrictions) const
65{
66 d->adminManagedRestrictions = adminManagedRestrictions;
67}
68
70{
71 return d->copyRequiresWriterPermission;
72}
73
74void Teamdrive::Restrictions::setCopyRequiresWriterPermission(bool copyRequiresWriterPermission) const
75{
76 d->copyRequiresWriterPermission = copyRequiresWriterPermission;
77}
78
80{
81 return d->domainUsersOnly;
82}
83
84void Teamdrive::Restrictions::setDomainUsersOnly(bool domainUsersOnly) const
85{
86 d->domainUsersOnly = domainUsersOnly;
87}
88
90{
91 return d->teamMembersOnly;
92}
93
94void Teamdrive::Restrictions::setTeamMembersOnly(bool teamMembersOnly) const
95{
96 d->teamMembersOnly = teamMembersOnly;
97}
98
99///// DriveTeamdrive::Capabilities
100
101class Q_DECL_HIDDEN Teamdrive::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 canChangeTeamDriveBackground = false;
111 bool canChangeTeamMembersOnlyRestriction = false;
112 bool canComment = false;
113 bool canCopy = false;
114 bool canDeleteChildren = false;
115 bool canDeleteTeamDrive = 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 canRenameTeamDrive = false;
123 bool canShare = false;
124 bool canTrashChildren = false;
125};
126
127Teamdrive::Capabilities::Capabilities()
128 : d(new Private)
129{
130}
131
132Teamdrive::Capabilities::Capabilities(const Teamdrive::Capabilities &other)
133 : d(new Private(*(other.d)))
134{
135}
136
137Teamdrive::Capabilities::~Capabilities() = default;
138
139bool Teamdrive::Capabilities::operator==(const Teamdrive::Capabilities &other) const
140{
141 GAPI_COMPARE(canAddChildren);
142 GAPI_COMPARE(canChangeCopyRequiresWriterPermissionRestriction);
143 GAPI_COMPARE(canChangeDomainUsersOnlyRestriction);
144 GAPI_COMPARE(canChangeTeamDriveBackground);
145 GAPI_COMPARE(canChangeTeamMembersOnlyRestriction);
146 GAPI_COMPARE(canComment);
147 GAPI_COMPARE(canCopy);
148 GAPI_COMPARE(canDeleteChildren);
149 GAPI_COMPARE(canDeleteTeamDrive);
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(canRenameTeamDrive);
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->canChangeTeamDriveBackground;
180}
181
183{
184 return d->canChangeTeamMembersOnlyRestriction;
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->canDeleteTeamDrive;
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->canRenameTeamDrive;
240}
241
243{
244 return d->canShare;
245}
246
248{
249 return d->canTrashChildren;
250}
251
252///// DriveTeamdrive::BackgroundImageFile
253
254class Q_DECL_HIDDEN Teamdrive::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
266Teamdrive::BackgroundImageFile::BackgroundImageFile()
267 : d(new Private)
268{
269}
270
271Teamdrive::BackgroundImageFile::BackgroundImageFile(const Teamdrive::BackgroundImageFile &other)
272 : d(new Private(*(other.d)))
273{
274}
275
276Teamdrive::BackgroundImageFile::~BackgroundImageFile() = default;
277
278bool Teamdrive::BackgroundImageFile::operator==(const Teamdrive::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 Teamdrive::BackgroundImageFile::setXCoordinate(const float xCoordinate) const
303{
304 d->xCoordinate = xCoordinate;
305}
306
308{
309 return d->yCoordinate;
310}
311
312void Teamdrive::BackgroundImageFile::setYCoordinate(const float yCoordinate) const
313{
314 d->yCoordinate = yCoordinate;
315}
316
318{
319 return d->width;
320}
321
322void Teamdrive::BackgroundImageFile::setWidth(const float width) const
323{
324 d->width = width;
325}
326
327///// DriveTeamdrive
328
329class Q_DECL_HIDDEN Teamdrive::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 RestrictionsPtr restrictions;
344
345 static TeamdrivePtr fromJSON(const QVariantMap &map);
346};
347
348TeamdrivePtr Teamdrive::Private::fromJSON(const QVariantMap &map)
349{
350 if (!map.contains(Teamdrive::Fields::Kind) || map[Teamdrive::Fields::Kind].toString() != ApiKind) {
351 return TeamdrivePtr();
352 }
353
354 auto teamdrive = TeamdrivePtr::create();
355 if (map.contains(Teamdrive::Fields::Id)) {
356 teamdrive->d->id = map[Teamdrive::Fields::Id].toString();
357 }
358 if (map.contains(Teamdrive::Fields::Name)) {
359 teamdrive->d->name = map[Teamdrive::Fields::Name].toString();
360 }
361 if (map.contains(Teamdrive::Fields::ThemeId)) {
362 teamdrive->d->themeId = map[Teamdrive::Fields::ThemeId].toString();
363 }
364 if (map.contains(Teamdrive::Fields::ColorRgb)) {
365 teamdrive->d->colorRgb = map[Teamdrive::Fields::ColorRgb].toString();
366 }
367 if (map.contains(Teamdrive::Fields::BackgroundImageLink)) {
368 teamdrive->d->backgroundImageLink = map[Teamdrive::Fields::BackgroundImageLink].toString();
369 }
370 if (map.contains(Teamdrive::Fields::CreatedDate)) {
371 teamdrive->d->createdDate = QDateTime::fromString(map[Teamdrive::Fields::CreatedDate].toString(), Qt::ISODate);
372 }
373
374 if (map.contains(Teamdrive::Fields::BackgroundImageFile)) {
375 const QVariantMap backgroundImageFileMap = map[Teamdrive::Fields::BackgroundImageFile].toMap();
377 backgroundImageFile->d->id = backgroundImageFileMap[Teamdrive::BackgroundImageFile::Fields::Id].toString();
378 backgroundImageFile->d->xCoordinate = backgroundImageFileMap[Teamdrive::BackgroundImageFile::Fields::XCoordinate].toReal();
379 backgroundImageFile->d->yCoordinate = backgroundImageFileMap[Teamdrive::BackgroundImageFile::Fields::YCoordinate].toReal();
380 backgroundImageFile->d->width = backgroundImageFileMap[Teamdrive::BackgroundImageFile::Fields::Width].toReal();
381 teamdrive->d->backgroundImageFile = backgroundImageFile;
382 }
383
384 if (map.contains(Teamdrive::Fields::Capabilities)) {
385 const QVariantMap capabilitiesMap = map[Teamdrive::Fields::Capabilities].toMap();
387 capabilities->d->canAddChildren = capabilitiesMap[Teamdrive::Capabilities::Fields::CanAddChildren].toBool();
388 capabilities->d->canChangeCopyRequiresWriterPermissionRestriction =
389 capabilitiesMap[Teamdrive::Capabilities::Fields::CanChangeCopyRequiresWriterPermissionRestriction].toBool();
390 capabilities->d->canChangeDomainUsersOnlyRestriction = capabilitiesMap[Teamdrive::Capabilities::Fields::CanChangeDomainUsersOnlyRestriction].toBool();
391 capabilities->d->canChangeTeamDriveBackground = capabilitiesMap[Teamdrive::Capabilities::Fields::CanChangeTeamDriveBackground].toBool();
392 capabilities->d->canChangeTeamMembersOnlyRestriction = capabilitiesMap[Teamdrive::Capabilities::Fields::CanChangeTeamMembersOnlyRestriction].toBool();
393 capabilities->d->canComment = capabilitiesMap[Teamdrive::Capabilities::Fields::CanComment].toBool();
394 capabilities->d->canCopy = capabilitiesMap[Teamdrive::Capabilities::Fields::CanCopy].toBool();
395 capabilities->d->canDeleteChildren = capabilitiesMap[Teamdrive::Capabilities::Fields::CanDeleteChildren].toBool();
396 capabilities->d->canDeleteTeamDrive = capabilitiesMap[Teamdrive::Capabilities::Fields::CanDeleteTeamDrive].toBool();
397 capabilities->d->canDownload = capabilitiesMap[Teamdrive::Capabilities::Fields::CanDownload].toBool();
398 capabilities->d->canEdit = capabilitiesMap[Teamdrive::Capabilities::Fields::CanEdit].toBool();
399 capabilities->d->canListChildren = capabilitiesMap[Teamdrive::Capabilities::Fields::CanListChildren].toBool();
400 capabilities->d->canManageMembers = capabilitiesMap[Teamdrive::Capabilities::Fields::CanManageMembers].toBool();
401 capabilities->d->canReadRevisions = capabilitiesMap[Teamdrive::Capabilities::Fields::CanReadRevisions].toBool();
402 capabilities->d->canRename = capabilitiesMap[Teamdrive::Capabilities::Fields::CanRename].toBool();
403 capabilities->d->canRenameTeamDrive = capabilitiesMap[Teamdrive::Capabilities::Fields::CanRenameTeamDrive].toBool();
404 capabilities->d->canShare = capabilitiesMap[Teamdrive::Capabilities::Fields::CanShare].toBool();
405 capabilities->d->canTrashChildren = capabilitiesMap[Teamdrive::Capabilities::Fields::CanTrashChildren].toBool();
406 teamdrive->d->capabilities = capabilities;
407 }
408
409 if (map.contains(Teamdrive::Fields::Restrictions)) {
410 const QVariantMap restrictionsMap = map[Teamdrive::Fields::Restrictions].toMap();
412 restrictions->d->adminManagedRestrictions = restrictionsMap[Teamdrive::Restrictions::Fields::AdminManagedRestrictions].toBool();
413 restrictions->d->copyRequiresWriterPermission = restrictionsMap[Teamdrive::Restrictions::Fields::CopyRequiresWriterPermission].toBool();
414 restrictions->d->domainUsersOnly = restrictionsMap[Teamdrive::Restrictions::Fields::DomainUsersOnly].toBool();
415 restrictions->d->teamMembersOnly = restrictionsMap[Teamdrive::Restrictions::Fields::TeamMembersOnly].toBool();
416 teamdrive->d->restrictions = restrictions;
417 }
418
419 return teamdrive;
420}
421
422const QString Teamdrive::Restrictions::Fields::AdminManagedRestrictions = QStringLiteral("adminManagedRestrictions");
423const QString Teamdrive::Restrictions::Fields::CopyRequiresWriterPermission = QStringLiteral("copyRequiresWriterPermission");
424const QString Teamdrive::Restrictions::Fields::DomainUsersOnly = QStringLiteral("domainUsersOnly");
425const QString Teamdrive::Restrictions::Fields::TeamMembersOnly = QStringLiteral("teamMembersOnly");
426
427const QString Teamdrive::Capabilities::Fields::CanAddChildren = QStringLiteral("canAddChildren");
428const QString Teamdrive::Capabilities::Fields::CanChangeCopyRequiresWriterPermissionRestriction =
429 QStringLiteral("canChangeCopyRequiresWriterPermissionRestriction");
430const QString Teamdrive::Capabilities::Fields::CanChangeDomainUsersOnlyRestriction = QStringLiteral("canChangeDomainUsersOnlyRestriction");
431const QString Teamdrive::Capabilities::Fields::CanChangeTeamDriveBackground = QStringLiteral("canChangeTeamDriveBackground");
432const QString Teamdrive::Capabilities::Fields::CanChangeTeamMembersOnlyRestriction = QStringLiteral("canChangeTeamMembersOnlyRestriction");
433const QString Teamdrive::Capabilities::Fields::CanComment = QStringLiteral("canComment");
434const QString Teamdrive::Capabilities::Fields::CanCopy = QStringLiteral("canCopy");
435const QString Teamdrive::Capabilities::Fields::CanDeleteChildren = QStringLiteral("canDeleteChildren");
436const QString Teamdrive::Capabilities::Fields::CanDeleteTeamDrive = QStringLiteral("canDeleteTeamDrive");
437const QString Teamdrive::Capabilities::Fields::CanDownload = QStringLiteral("canDownload");
438const QString Teamdrive::Capabilities::Fields::CanEdit = QStringLiteral("canEdit");
439const QString Teamdrive::Capabilities::Fields::CanListChildren = QStringLiteral("canListChildren");
440const QString Teamdrive::Capabilities::Fields::CanManageMembers = QStringLiteral("canManageMembers");
441const QString Teamdrive::Capabilities::Fields::CanReadRevisions = QStringLiteral("canReadRevisions");
442const QString Teamdrive::Capabilities::Fields::CanRename = QStringLiteral("canRename");
443const QString Teamdrive::Capabilities::Fields::CanRenameTeamDrive = QStringLiteral("canRenameTeamDrive");
444const QString Teamdrive::Capabilities::Fields::CanShare = QStringLiteral("canShare");
445const QString Teamdrive::Capabilities::Fields::CanTrashChildren = QStringLiteral("canTrashChildren");
446
447const QString Teamdrive::BackgroundImageFile::Fields::Id = QStringLiteral("id");
448const QString Teamdrive::BackgroundImageFile::Fields::XCoordinate = QStringLiteral("xCoordinate");
449const QString Teamdrive::BackgroundImageFile::Fields::YCoordinate = QStringLiteral("yCoordinate");
450const QString Teamdrive::BackgroundImageFile::Fields::Width = QStringLiteral("width");
451
452const QString Teamdrive::Fields::Items = QStringLiteral("items");
453const QString Teamdrive::Fields::KindDrive = QStringLiteral("kind");
454const QString Teamdrive::Fields::PageToken = QStringLiteral("pageToken");
455const QString Teamdrive::Fields::NextPageToken = QStringLiteral("nextPageToken");
456const QString Teamdrive::Fields::Id = QStringLiteral("id");
457const QString Teamdrive::Fields::Kind = QStringLiteral("kind");
458const QString Teamdrive::Fields::Name = QStringLiteral("name");
459const QString Teamdrive::Fields::ThemeId = QStringLiteral("themeId");
460const QString Teamdrive::Fields::ColorRgb = QStringLiteral("colorRgb");
461const QString Teamdrive::Fields::BackgroundImageFile = QStringLiteral("backgroundImageFile");
462const QString Teamdrive::Fields::BackgroundImageLink = QStringLiteral("backgroundImageLink");
463const QString Teamdrive::Fields::Capabilities = QStringLiteral("capabilities");
464const QString Teamdrive::Fields::CreatedDate = QStringLiteral("createdDate");
465const QString Teamdrive::Fields::Restrictions = QStringLiteral("restrictions");
466
467Teamdrive::Teamdrive()
468 : KGAPI2::Object()
469 , d(new Private)
470{
471}
472
473Teamdrive::Teamdrive(const Teamdrive &other)
474 : KGAPI2::Object(other)
475 , d(new Private(*(other.d)))
476{
477}
478
479Teamdrive::~Teamdrive() = default;
480
481bool Teamdrive::operator==(const Teamdrive &other) const
482{
483 if (!Object::operator==(other)) {
484 return false;
485 }
486 GAPI_COMPARE(id);
487 GAPI_COMPARE(name);
488 GAPI_COMPARE(themeId);
489 GAPI_COMPARE(colorRgb);
490 GAPI_COMPARE_SHAREDPTRS(backgroundImageFile);
491 GAPI_COMPARE(backgroundImageLink);
492 GAPI_COMPARE_SHAREDPTRS(capabilities);
493 GAPI_COMPARE(createdDate);
494 GAPI_COMPARE_SHAREDPTRS(restrictions);
495 return true;
496}
497
499{
500 return d->id;
501}
502
503void Teamdrive::setId(const QString &id) const
504{
505 d->id = id;
506}
507
509{
510 return d->name;
511}
512
514{
515 d->name = name;
516}
517
519{
520 return d->themeId;
521}
522
524{
525 d->themeId = themeId;
526}
527
529{
530 return d->colorRgb;
531}
532
534{
535 d->colorRgb = colorRgb;
536}
537
539{
540 return d->backgroundImageFile;
541}
542
547
549{
550 return d->backgroundImageLink;
551}
552
554{
555 return d->capabilities;
556}
557
559{
560 return d->createdDate;
561}
562
564{
565 d->restrictions = restrictions;
566}
567
569{
570 return d->restrictions;
571}
572
573TeamdrivePtr Teamdrive::fromJSON(const QByteArray &jsonData)
574{
575 QJsonDocument document = QJsonDocument::fromJson(jsonData);
576 if (document.isNull()) {
577 return TeamdrivePtr();
578 }
579
580 const QVariant data = document.toVariant();
581 return Private::fromJSON(data.toMap());
582}
583
584TeamdrivesList Teamdrive::fromJSONFeed(const QByteArray &jsonData, FeedData &feedData)
585{
586 QJsonDocument document = QJsonDocument::fromJson(jsonData);
587 if (document.isNull()) {
588 return TeamdrivesList();
589 }
590
591 const QVariant data = document.toVariant();
592 const QVariantMap map = data.toMap();
593 if (!map.contains(Teamdrive::Fields::Kind) || map[Teamdrive::Fields::Kind].toString() != ApiKindList) {
594 return TeamdrivesList();
595 }
596
597 if (map.contains(Teamdrive::Fields::NextPageToken)) {
598 feedData.nextPageUrl = DriveService::fetchTeamdrivesUrl();
599 QUrlQuery query(feedData.nextPageUrl);
600 query.addQueryItem(Teamdrive::Fields::PageToken, map.value(Teamdrive::Fields::NextPageToken).toString());
601 feedData.nextPageUrl.setQuery(query);
602 }
603
605 const QVariantList items = map[Teamdrive::Fields::Items].toList();
606 for (const QVariant &item : items) {
607 const TeamdrivePtr teamdrive = Private::fromJSON(item.toMap());
608
609 if (!teamdrive.isNull()) {
610 list << teamdrive;
611 }
612 }
613
614 return list;
615}
616
617QByteArray Teamdrive::toJSON(const TeamdrivePtr &teamdrive)
618{
619 QVariantMap teamDriveMap;
620 teamDriveMap[Teamdrive::Fields::Kind] = ApiKind;
621 if (!teamdrive->id().isEmpty()) {
622 teamDriveMap[Teamdrive::Fields::Id] = teamdrive->id();
623 }
624 if (!teamdrive->name().isEmpty()) {
625 teamDriveMap[Teamdrive::Fields::Name] = teamdrive->name();
626 }
627 if (!teamdrive->themeId().isEmpty()) {
628 teamDriveMap[Teamdrive::Fields::ThemeId] = teamdrive->themeId();
629 }
630 if (!teamdrive->colorRgb().isEmpty()) {
631 teamDriveMap[Teamdrive::Fields::ColorRgb] = teamdrive->colorRgb();
632 }
633 if (!teamdrive->backgroundImageLink().isEmpty()) {
634 teamDriveMap[Teamdrive::Fields::BackgroundImageLink] = teamdrive->backgroundImageLink();
635 }
636 if (teamdrive->createdDate().isValid()) {
637 teamDriveMap[Teamdrive::Fields::CreatedDate] = teamdrive->createdDate();
638 }
639
640 if (teamdrive->restrictions()) {
641 QVariantMap restrictionsMap;
642 restrictionsMap[Teamdrive::Restrictions::Fields::AdminManagedRestrictions] = teamdrive->restrictions()->adminManagedRestrictions();
643 restrictionsMap[Teamdrive::Restrictions::Fields::CopyRequiresWriterPermission] = teamdrive->restrictions()->copyRequiresWriterPermission();
644 restrictionsMap[Teamdrive::Restrictions::Fields::DomainUsersOnly] = teamdrive->restrictions()->domainUsersOnly();
645 restrictionsMap[Teamdrive::Restrictions::Fields::TeamMembersOnly] = teamdrive->restrictions()->teamMembersOnly();
646 teamDriveMap[Teamdrive::Fields::Restrictions] = restrictionsMap;
647 }
648
649 if (teamdrive->backgroundImageFile()) {
650 QVariantMap backgroundImageFileMap;
651 backgroundImageFileMap[Teamdrive::BackgroundImageFile::Fields::Id] = teamdrive->backgroundImageFile()->id();
652 backgroundImageFileMap[Teamdrive::BackgroundImageFile::Fields::XCoordinate] = teamdrive->backgroundImageFile()->xCoordinate();
653 backgroundImageFileMap[Teamdrive::BackgroundImageFile::Fields::YCoordinate] = teamdrive->backgroundImageFile()->yCoordinate();
654 backgroundImageFileMap[Teamdrive::BackgroundImageFile::Fields::Width] = teamdrive->backgroundImageFile()->width();
655 teamDriveMap[Teamdrive::Fields::BackgroundImageFile] = backgroundImageFileMap;
656 }
657
658 if (teamdrive->capabilities()) {
659 QVariantMap capabilitiesMap;
660 capabilitiesMap[Teamdrive::Capabilities::Fields::CanAddChildren] = teamdrive->capabilities()->canAddChildren();
661 capabilitiesMap[Teamdrive::Capabilities::Fields::CanChangeCopyRequiresWriterPermissionRestriction] =
662 teamdrive->capabilities()->canChangeCopyRequiresWriterPermissionRestriction();
663 capabilitiesMap[Teamdrive::Capabilities::Fields::CanChangeDomainUsersOnlyRestriction] =
664 teamdrive->capabilities()->canChangeDomainUsersOnlyRestriction();
665 capabilitiesMap[Teamdrive::Capabilities::Fields::CanChangeTeamDriveBackground] = teamdrive->capabilities()->canChangeTeamDriveBackground();
666 capabilitiesMap[Teamdrive::Capabilities::Fields::CanChangeTeamMembersOnlyRestriction] =
667 teamdrive->capabilities()->canChangeTeamMembersOnlyRestriction();
668 capabilitiesMap[Teamdrive::Capabilities::Fields::CanComment] = teamdrive->capabilities()->canComment();
669 capabilitiesMap[Teamdrive::Capabilities::Fields::CanCopy] = teamdrive->capabilities()->canCopy();
670 capabilitiesMap[Teamdrive::Capabilities::Fields::CanDeleteChildren] = teamdrive->capabilities()->canDeleteChildren();
671 capabilitiesMap[Teamdrive::Capabilities::Fields::CanDeleteTeamDrive] = teamdrive->capabilities()->canDeleteTeamDrive();
672 capabilitiesMap[Teamdrive::Capabilities::Fields::CanDownload] = teamdrive->capabilities()->canDownload();
673 capabilitiesMap[Teamdrive::Capabilities::Fields::CanEdit] = teamdrive->capabilities()->canEdit();
674 capabilitiesMap[Teamdrive::Capabilities::Fields::CanListChildren] = teamdrive->capabilities()->canListChildren();
675 capabilitiesMap[Teamdrive::Capabilities::Fields::CanManageMembers] = teamdrive->capabilities()->canManageMembers();
676 capabilitiesMap[Teamdrive::Capabilities::Fields::CanReadRevisions] = teamdrive->capabilities()->canReadRevisions();
677 capabilitiesMap[Teamdrive::Capabilities::Fields::CanRename] = teamdrive->capabilities()->canRename();
678 capabilitiesMap[Teamdrive::Capabilities::Fields::CanRenameTeamDrive] = teamdrive->capabilities()->canRenameTeamDrive();
679 capabilitiesMap[Teamdrive::Capabilities::Fields::CanShare] = teamdrive->capabilities()->canShare();
680 capabilitiesMap[Teamdrive::Capabilities::Fields::CanTrashChildren] = teamdrive->capabilities()->canTrashChildren();
681 teamDriveMap[Teamdrive::Fields::Capabilities] = capabilitiesMap;
682 }
683
684 QJsonDocument document = QJsonDocument::fromVariant(teamDriveMap);
685 return document.toJson(QJsonDocument::Compact);
686}
DriveTeamdrive::BackgroundImageFile holds the structure used for backgroundImageFile property.
Definition teamdrive.h:289
float width() const
Returns the width for this background image file.
float yCoordinate() const
Returns the y coordinate for this background image file.
void setId(const QString &id) const
Sets the id of the background image file.
void setWidth(float width) const
Sets the width for this background image file.
QString id() const
Returns the id of the background image file.
void setYCoordinate(float yCoordinate) const
Sets the y coordinate for this background image file.
float xCoordinate() const
Returns the x coordinate for this background image file.
void setXCoordinate(float xCoordinate) const
Sets the x coordinate for this background image file.
DriveTeamdrive::Capabilities holds the structure used for capabilities property.
Definition teamdrive.h:135
bool canReadRevisions() const
Returns Whether the current user can read the revisions resource of files in this Team Drive.
bool canManageMembers() const
Returns Whether the current user can add members to this Team Drive or remove them or change their ro...
bool canListChildren() const
Returns Whether the current user can list the children of folders in this Team Drive.
bool canCopy() const
Returns Whether the current user can copy files in this Team Drive.
bool canChangeTeamMembersOnlyRestriction() const
Returns whether the current user can change the teamMembersOnly restriction of this Team Drive.
bool canChangeDomainUsersOnlyRestriction() const
Returns whether the current user can change the domainUsersOnly restriction of this Team Drive.
bool canShare() const
Returns Whether the current user can share files or folders in this Team Drive.
bool canComment() const
Returns Whether the current user can comment on files in this Team Drive.
bool canRenameTeamDrive() const
Returns Whether the current user can rename this Team Drive.
bool canAddChildren() const
Returns whether the current user can add children to folders in this Team Drive.
bool canRename() const
Returns Whether the current user can rename files or folders in this Team Drive.
bool canDeleteTeamDrive() const
Returns Whether the current user can delete this Team Drive.
bool canDownload() const
Returns Whether the current user can download files in this Team Drive.
bool canChangeCopyRequiresWriterPermissionRestriction() const
Returns whether the current user can change the copyRequiresWriterPermission restriction of this Team...
bool canEdit() const
Returns Whether the current user can edit files in this Team Drive.
bool canTrashChildren() const
Returns Whether the current user can trash children from folders in this Team Drive.
bool canDeleteChildren() const
Returns Whether the current user can delete children from folders in this Team Drive.
bool canChangeTeamDriveBackground() const
Returns whether the current user can change the background of this Team Drive.
DriveTeamdrive::Restrictions holds the structure used for restrictions property.
Definition teamdrive.h:40
void setDomainUsersOnly(bool domainUsersOnly) const
Sets whether access to this Team Drive and items inside this Team Drive is restricted to users of the...
Definition teamdrive.cpp:84
void setAdminManagedRestrictions(bool adminManagedRestrictions) const
Sets whether administrative privileges on this Team Drive are required to modify restrictions.
Definition teamdrive.cpp:64
bool teamMembersOnly() const
Returns whether access to items inside this Team Drive is restricted to members of this Team Drive.
Definition teamdrive.cpp:89
void setTeamMembersOnly(bool teamMembersOnly) const
Sets whether access to items inside this Team Drive is restricted to members of this Team Drive.
Definition teamdrive.cpp:94
bool domainUsersOnly() const
Returns whether access to this Team Drive and items inside this Team Drive is restricted to users of ...
Definition teamdrive.cpp:79
bool adminManagedRestrictions() const
Returns whether administrative privileges on this Team Drive are required to modify restrictions.
Definition teamdrive.cpp:59
bool copyRequiresWriterPermission() const
Returns whether the options to copy, print, or download files inside this Team Drive,...
Definition teamdrive.cpp:69
void setCopyRequiresWriterPermission(bool copyRequiresWriterPermission) const
Sets whether the options to copy, print, or download files inside this Team Drive,...
Definition teamdrive.cpp:74
Teamdrive contains a representation of a Team Drive.
Definition teamdrive.h:33
void setThemeId(const QString &themeId) const
Sets the themeId of the teamdrive.
CapabilitiesPtr capabilities() const
Returns the capabilities the current user has on this Team Drive.
void setBackgroundImageFile(const BackgroundImageFilePtr &backgroundImageFile) const
Sets the backgroundImageFile of the teamdrive.
QString backgroundImageLink() const
Returns the backgroundImageLink of the teamdrive.
QString name() const
Returns the name of the teamdrive.
void setName(const QString &name) const
Sets the name of the teamdrive.
QString id() const
Returns the id of the teamdrive.
QString colorRgb() const
Returns the colorRgb of the teamdrive.
void setRestrictions(const RestrictionsPtr &restrictions) const
Sets the restrictions of the teamdrive.
void setId(const QString &id) const
Sets the id of the teamdrive.
void setColorRgb(const QString &colorRgb) const
Sets the colorRgb of the teamdrive.
QString themeId() const
Returns the themeId of the teamdrive.
QDateTime createdDate() const
Returns the time at which the Team Drive was created.
BackgroundImageFilePtr backgroundImageFile() const
Returns the image file and cropping parameters from which a background image for this Team Drive is s...
RestrictionsPtr restrictions() const
Returns the set of restrictions that apply to this Team Drive or items inside this Team Drive.
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 Dec 27 2024 11:55:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.