7#include "childreference.h"
10#include <QJsonDocument>
14using namespace KGAPI2::Drive;
20 Private(
const Private &other);
26 static ChildReferencePtr fromJSON(
const QVariantMap &map);
29ChildReference::Private::Private()
33ChildReference::Private::Private(
const Private &other)
40ChildReferencePtr ChildReference::Private::fromJSON(
const QVariantMap &map)
42 if (!
map.contains(QLatin1StringView(
"kind")) || map[QStringLiteral(
"kind")].
toString() != QLatin1StringView(
"drive#childReference")) {
43 return ChildReferencePtr();
46 ChildReferencePtr reference(
new ChildReference(map[QStringLiteral(
"id")].
toString()));
47 reference->d->selfLink =
map[QStringLiteral(
"selfLink")].toUrl();
48 reference->d->childLink =
map[QStringLiteral(
"childLink")].toUrl();
53ChildReference::ChildReference(
const QString &
id)
62 , d(new Private(*(other.d)))
66ChildReference::~ChildReference()
73 if (!Object::operator==(other)) {
97ChildReferencePtr ChildReference::fromJSON(
const QByteArray &jsonData)
101 return ChildReferencePtr();
105 return Private::fromJSON(data.
toMap());
108ChildReferencesList ChildReference::fromJSONFeed(
const QByteArray &jsonData,
FeedData &feedData)
112 return ChildReferencesList();
115 const QVariant data = document.
toVariant();
116 const QVariantMap
map = data.
toMap();
117 if (!
map.contains(QLatin1StringView(
"kind")) || map[QStringLiteral(
"kind")].
toString() != QLatin1StringView(
"drive#childList")) {
118 return ChildReferencesList();
121 ChildReferencesList
list;
122 const QVariantList items =
map[QStringLiteral(
"items")].toList();
123 for (
const QVariant &item : items) {
124 ChildReferencePtr reference = Private::fromJSON(item.toMap());
126 if (!reference.
isNull()) {
131 if (
map.contains(QLatin1StringView(
"nextLink"))) {
138QByteArray ChildReference::toJSON(
const ChildReferencePtr &reference)
142 map[QStringLiteral(
"id")] = reference->id();
ChildReference contains a reference to a folder's child.
QUrl selfLink() const
Returns a link back to this reference.
QString id() const
Returns the id of the child.
QUrl childLink() const
Returns a link to the child.
Structure to store additional information about a feed.
QUrl nextPageUrl
Link to next page of feed.
Base class for all objects.
char * toString(const EngineQuery &query)
A job to fetch a single map tile described by a StaticMapUrl.
KIOCORE_EXPORT QStringList list(const QString &fileClass)
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
bool isNull() const const
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
QMap< QString, QVariant > toMap() const const