File indexing completed on 2024-05-12 05:22:30
0001 /* 0002 * SPDX-FileCopyrightText: 2021 Daniel Vrátil <dvratil@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-only 0005 * SPDX-License-Identifier: LGPL-3.0-only 0006 * SPDX-License-Identifier: LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #include "tagline.h" 0010 0011 #include "fieldmetadata.h" 0012 #include "peopleservice.h" 0013 0014 #include <QJsonArray> 0015 #include <QJsonObject> 0016 #include <QJsonValue> 0017 #include <QSharedData> 0018 0019 #include <algorithm> 0020 0021 namespace KGAPI2::People 0022 { 0023 class Tagline::Private : public QSharedData 0024 { 0025 public: 0026 explicit Private() = default; 0027 Private(const Private &) = default; 0028 Private(Private &&) noexcept = delete; 0029 Private &operator=(const Private &) = delete; 0030 Private &operator=(Private &&) noexcept = delete; 0031 ~Private() = default; 0032 0033 bool operator==(const Private &other) const 0034 { 0035 return value == other.value && metadata == other.metadata; 0036 } 0037 0038 bool operator!=(const Private &other) const 0039 { 0040 return !(*this == other); 0041 } 0042 0043 QString value{}; 0044 FieldMetadata metadata{}; 0045 }; 0046 0047 Tagline::Tagline() 0048 : d(new Private) 0049 { 0050 } 0051 0052 Tagline::Tagline(const Tagline &) = default; 0053 Tagline::Tagline(Tagline &&) noexcept = default; 0054 Tagline &Tagline::operator=(const Tagline &) = default; 0055 Tagline &Tagline::operator=(Tagline &&) noexcept = default; 0056 Tagline::~Tagline() = default; 0057 0058 bool Tagline::operator==(const Tagline &other) const 0059 { 0060 return *d == *other.d; 0061 } 0062 0063 bool Tagline::operator!=(const Tagline &other) const 0064 { 0065 return !(*this == other); 0066 } 0067 0068 QString Tagline::value() const 0069 { 0070 return d->value; 0071 } 0072 0073 void Tagline::setValue(const QString &value) 0074 { 0075 d->value = value; 0076 } 0077 FieldMetadata Tagline::metadata() const 0078 { 0079 return d->metadata; 0080 } 0081 0082 void Tagline::setMetadata(const FieldMetadata &value) 0083 { 0084 d->metadata = value; 0085 } 0086 0087 Tagline Tagline::fromJSON(const QJsonObject &obj) 0088 { 0089 Q_UNUSED(obj); 0090 return Tagline(); 0091 } 0092 0093 QJsonValue Tagline::toJSON() const 0094 { 0095 QJsonObject obj; 0096 0097 PeopleUtils::addValueToJsonObjectIfValid(obj, "value", d->value); 0098 // Skip, field metadata is only useful for receiving -> PeopleUtils::addValueToJsonObjectIfValid(obj, "metadata", d->metadata.toJSON()); 0099 return obj; 0100 } 0101 0102 } // namespace KGAPI2::People