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 #ifndef KUSERFEEDBACK_SURVEYINFO_H
0008 #define KUSERFEEDBACK_SURVEYINFO_H
0009 
0010 #include "kuserfeedbackcore_export.h"
0011 
0012 #include <QMetaType>
0013 #include <QSharedDataPointer>
0014 #include <qobjectdefs.h>
0015 #include <QUrl>
0016 #include <QUuid>
0017 
0018 
0019 QT_BEGIN_NAMESPACE
0020 class QJsonObject;
0021 QT_END_NAMESPACE
0022 
0023 namespace KUserFeedback {
0024 
0025 class SurveyInfoData;
0026 
0027 /*! Information about a survey request.
0028  *  This class is implicitly shared.
0029  */
0030 class KUSERFEEDBACKCORE_EXPORT SurveyInfo
0031 {
0032     Q_GADGET
0033     Q_PROPERTY(bool isValid READ isValid)
0034     Q_PROPERTY(QUrl url READ url)
0035     Q_PROPERTY(QString target READ target)
0036     Q_PROPERTY(QUuid uuid READ uuid)
0037 public:
0038     /*! Create an empty, invalid survey request. */
0039     SurveyInfo();
0040     /*! Copy constructor. */
0041     SurveyInfo(const SurveyInfo&);
0042     ~SurveyInfo();
0043     /*! Assignment operator. */
0044     SurveyInfo& operator=(const SurveyInfo&);
0045 
0046     /*! Returns @c true if this survey has all necessary information to actually execute it. */
0047     bool isValid() const;
0048 
0049     /*! Internal global unique id of the survey.
0050      *  Used to locally check if a user has completed the survey already.
0051      */
0052     QUuid uuid() const;
0053 
0054     /*! The URL to the survey website. */
0055     QUrl url() const;
0056 
0057     /*! The survey targeting expression. */
0058     QString target() const;
0059 
0060     ///@cond internal
0061     void setUuid(const QUuid &id);
0062     void setUrl(const QUrl &url);
0063     void setTarget(const QString &target);
0064     static SurveyInfo fromJson(const QJsonObject &obj);
0065     ///@endcond
0066 private:
0067     QSharedDataPointer<SurveyInfoData> d;
0068 };
0069 
0070 }
0071 
0072 Q_DECLARE_METATYPE(KUserFeedback::SurveyInfo)
0073 
0074 #endif // KUSERFEEDBACK_SURVEYINFO_H