Kgapi

relationshipstatus.cpp
1/*
2 * SPDX-FileCopyrightText: 2021 Daniel Vrátil <dvratil@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 * SPDX-License-Identifier: LGPL-3.0-only
6 * SPDX-License-Identifier: LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "relationshipstatus.h"
10
11#include "fieldmetadata.h"
12#include "peopleservice.h"
13
14#include <QJsonArray>
15#include <QJsonObject>
16#include <QJsonValue>
17#include <QSharedData>
18
19#include <algorithm>
20
21namespace KGAPI2::People
22{
23class RelationshipStatus::Private : public QSharedData
24{
25public:
26 explicit Private() = default;
27 Private(const Private &) = default;
28 Private(Private &&) noexcept = delete;
29 Private &operator=(const Private &) = delete;
30 Private &operator=(Private &&) noexcept = delete;
31 ~Private() = default;
32
33 bool operator==(const Private &other) const
34 {
35 return value == other.value && formattedValue == other.formattedValue && metadata == other.metadata;
36 }
37
38 bool operator!=(const Private &other) const
39 {
40 return !(*this == other);
41 }
42
43 QString value{};
44 QString formattedValue{};
45 FieldMetadata metadata{};
46};
47
49 : d(new Private)
50{
51}
52
55RelationshipStatus &RelationshipStatus::operator=(const RelationshipStatus &) = default;
56RelationshipStatus &RelationshipStatus::operator=(RelationshipStatus &&) noexcept = default;
58
59bool RelationshipStatus::operator==(const RelationshipStatus &other) const
60{
61 return *d == *other.d;
62}
63
64bool RelationshipStatus::operator!=(const RelationshipStatus &other) const
65{
66 return !(*this == other);
67}
68
70{
71 return d->value;
72}
73
75{
76 d->value = value;
77}
79{
80 return d->formattedValue;
81}
83{
84 return d->metadata;
85}
86
88{
89 d->metadata = value;
90}
91
92RelationshipStatus RelationshipStatus::fromJSON(const QJsonObject &obj)
93{
94 Q_UNUSED(obj);
95 return RelationshipStatus();
96}
97
98QJsonValue RelationshipStatus::toJSON() const
99{
100 QJsonObject obj;
101
102 PeopleUtils::addValueToJsonObjectIfValid(obj, "value", d->value);
103 PeopleUtils::addValueToJsonObjectIfValid(obj, "formattedValue", d->formattedValue);
104 // Skip, field metadata is only useful for receiving -> PeopleUtils::addValueToJsonObjectIfValid(obj, "metadata", d->metadata.toJSON());
105 return obj;
106}
107
108} // namespace KGAPI2::People
Metadata about a field.
DEPRECATED: No data will be returned A person's relationship status.
RelationshipStatus()
Constructs a new RelationshipStatus.
FieldMetadata metadata() const
Metadata about the relationship status.
void setMetadata(const FieldMetadata &value)
Sets value of the metadata property.
void setValue(const QString &value)
Sets value of the value property.
QString formattedValue() const
Output only.
QString value() const
The relationship status.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:36:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.