File indexing completed on 2024-12-15 03:45:05
0001 /* 0002 SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #include "surveyinfo.h" 0008 0009 #include <QJsonObject> 0010 #include <QSharedData> 0011 0012 using namespace KUserFeedback; 0013 0014 class KUserFeedback::SurveyInfoData : public QSharedData 0015 { 0016 public: 0017 QUuid uuid; 0018 QUrl url; 0019 QString target; 0020 }; 0021 0022 0023 SurveyInfo::SurveyInfo() : d (new SurveyInfoData) 0024 { 0025 } 0026 0027 SurveyInfo::SurveyInfo(const SurveyInfo &other) : 0028 d(other.d) 0029 { 0030 } 0031 0032 SurveyInfo::~SurveyInfo() 0033 { 0034 } 0035 0036 SurveyInfo& SurveyInfo::operator=(const SurveyInfo &other) 0037 { 0038 d = other.d; 0039 return *this; 0040 } 0041 0042 bool SurveyInfo::isValid() const 0043 { 0044 return !d->uuid.isNull() && d->url.isValid(); 0045 } 0046 0047 QUuid SurveyInfo::uuid() const 0048 { 0049 return d->uuid; 0050 } 0051 0052 void SurveyInfo::setUuid(const QUuid &id) 0053 { 0054 d->uuid = id; 0055 } 0056 0057 QUrl SurveyInfo::url() const 0058 { 0059 return d->url; 0060 } 0061 0062 void SurveyInfo::setUrl(const QUrl& url) 0063 { 0064 d->url = url; 0065 } 0066 0067 QString SurveyInfo::target() const 0068 { 0069 return d->target; 0070 } 0071 0072 void SurveyInfo::setTarget(const QString &target) 0073 { 0074 d->target = target; 0075 } 0076 0077 SurveyInfo SurveyInfo::fromJson(const QJsonObject& obj) 0078 { 0079 SurveyInfo s; 0080 s.setUuid(QUuid(obj.value(QLatin1String("uuid")).toString())); 0081 s.setUrl(QUrl(obj.value(QLatin1String("url")).toString())); 0082 s.setTarget(obj.value(QLatin1String("target")).toString()); 0083 return s; 0084 } 0085 0086 #include "moc_surveyinfo.cpp"