12#include "fieldmetadata.h"
13#include "peopleservice.h"
22namespace KGAPI2::People
24class Biography::Private :
public QSharedData
27 explicit Private() =
default;
28 Private(
const Private &) =
default;
29 Private(Private &&) noexcept = delete;
30 Private &operator=(const Private &) = delete;
31 Private &operator=(Private &&) noexcept = delete;
34 bool operator==(const Private &other)
const
36 return metadata == other.metadata && contentType == other.contentType && value == other.value;
39 bool operator!=(
const Private &other)
const
41 return !(*
this == other);
44 FieldMetadata metadata{};
62 return *d == *other.d;
65bool Biography::operator!=(
const Biography &other)
const
67 return !(*
this == other);
81 return d->contentType;
86 d->contentType =
value;
103 const auto jsonMetadata = obj.
value(QStringLiteral(
"metadata")).
toObject();
105 biography.
setMetadata(FieldMetadata::fromJSON(jsonMetadata));
106 biography.
setValue(obj.
value(QStringLiteral(
"value")).toString());
108 const auto jsonContentType = obj.
value(QStringLiteral(
"contentType"));
121QList<Biography> Biography::fromJSONArray(
const QJsonArray &data)
123 QList<Biography> biographies;
125 for(
const auto &biography : data) {
126 if(biography.isObject()) {
127 const auto objectifiedBiography = biography.toObject();
128 biographies.
append(fromJSON(objectifiedBiography));
135QJsonValue Biography::toJSON()
const
140 switch (d->contentType) {
142 PeopleUtils::addValueToJsonObjectIfValid(obj,
"contentType", QStringLiteral(
"CONTENT_TYPE_UNSPECIFIED"));
145 PeopleUtils::addValueToJsonObjectIfValid(obj,
"contentType", QStringLiteral(
"TEXT_PLAIN"));
148 PeopleUtils::addValueToJsonObjectIfValid(obj,
"contentType", QStringLiteral(
"TEXT_HTML"));
151 PeopleUtils::addValueToJsonObjectIfValid(obj,
"value", d->value);
A person's short biography.
Biography::ContentType contentType() const
The content type of the biography.
void setMetadata(const FieldMetadata &value)
Sets value of the metadata property.
Biography()
Constructs a new Biography.
void setValue(const QString &value)
Sets value of the value property.
FieldMetadata metadata() const
Metadata about the biography.
QString value() const
The short biography.
@ CONTENT_TYPE_UNSPECIFIED
Unspecified.
void setContentType(Biography::ContentType value)
Sets value of the contentType property.
bool isEmpty() const const
QJsonValue value(QLatin1StringView key) const const
QJsonObject toObject() const const
void append(QList< T > &&value)