Kgapi

tagline.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 "tagline.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 Tagline::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 && metadata == other.metadata;
36 }
37
38 bool operator!=(const Private &other) const
39 {
40 return !(*this == other);
41 }
42
43 QString value{};
44 FieldMetadata metadata{};
45};
46
48 : d(new Private)
49{
50}
51
52Tagline::Tagline(const Tagline &) = default;
53Tagline::Tagline(Tagline &&) noexcept = default;
54Tagline &Tagline::operator=(const Tagline &) = default;
55Tagline &Tagline::operator=(Tagline &&) noexcept = default;
56Tagline::~Tagline() = default;
57
58bool Tagline::operator==(const Tagline &other) const
59{
60 return *d == *other.d;
61}
62
63bool Tagline::operator!=(const Tagline &other) const
64{
65 return !(*this == other);
66}
67
69{
70 return d->value;
71}
72
73void Tagline::setValue(const QString &value)
74{
75 d->value = value;
76}
78{
79 return d->metadata;
80}
81
83{
84 d->metadata = value;
85}
86
87Tagline Tagline::fromJSON(const QJsonObject &obj)
88{
89 Q_UNUSED(obj);
90 return Tagline();
91}
92
93QJsonValue Tagline::toJSON() const
94{
95 QJsonObject obj;
96
97 PeopleUtils::addValueToJsonObjectIfValid(obj, "value", d->value);
98 // Skip, field metadata is only useful for receiving -> PeopleUtils::addValueToJsonObjectIfValid(obj, "metadata", d->metadata.toJSON());
99 return obj;
100}
101
102} // namespace KGAPI2::People
Metadata about a field.
DEPRECATED: No data will be returned A brief one-line description of the person.
Definition tagline.h:33
QString value() const
The tagline.
Definition tagline.cpp:68
void setValue(const QString &value)
Sets value of the value property.
Definition tagline.cpp:73
Tagline()
Constructs a new Tagline.
Definition tagline.cpp:47
void setMetadata(const FieldMetadata &value)
Sets value of the metadata property.
Definition tagline.cpp:82
FieldMetadata metadata() const
Metadata about the tagline.
Definition tagline.cpp:77
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:54:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.