surveyinfo.h 2.34 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
    Copyright (C) 2016 Volker Krause <vkrause@kde.org>

    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU Library General Public License as published by
    the Free Software Foundation; either version 2 of the License, or (at your
    option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
    License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef USERFEEDBACK_SURVEYINFO_H
#define USERFEEDBACK_SURVEYINFO_H

#include "userfeedbackcore_export.h"

#include <QSharedDataPointer>
24
25
26
27
28
29
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <qobjectdefs.h>
#include <QUrl>
#include <QUuid>
#endif

30

Volker Krause's avatar
Volker Krause committed
31
QT_BEGIN_NAMESPACE
32
33
class QJsonObject;
class QUrl;
Volker Krause's avatar
Volker Krause committed
34
35
class QUuid;
QT_END_NAMESPACE
36
37
38
39
40

namespace UserFeedback {

class SurveyInfoData;

41
42
43
/*! Information about a survey request.
 *  This class is implicitly shared.
 */
44
45
class USERFEEDBACKCORE_EXPORT SurveyInfo
{
46
#ifndef QT4_MOC_WORKAROUND
47
48
49
50
51
52
    Q_GADGET
    Q_PROPERTY(bool isValid READ isValid)
    Q_PROPERTY(QUrl url READ url)
    Q_PROPERTY(QString target READ target)
    Q_PROPERTY(QUuid uuid READ uuid)
#endif
53
public:
54
    /*! Create an empty, invalid survey request. */
55
    SurveyInfo();
56
    /*! Copy constructor. */
57
58
    SurveyInfo(const SurveyInfo&);
    ~SurveyInfo();
59
    /*! Assignment operator. */
60
61
    SurveyInfo& operator=(const SurveyInfo&);

62
    /*! Returns @c true if this survey has all necessary information to actually execute it. */
63
64
    bool isValid() const;

Volker Krause's avatar
Volker Krause committed
65
    /*! Internal global unique id of the survey.
66
67
     *  Used to locally check if a user has completed the survey already.
     */
Volker Krause's avatar
Volker Krause committed
68
    QUuid uuid() const;
69

70
    /*! The URL to the survey website. */
71
72
    QUrl url() const;

73
74
75
    /*! The survey targeting expression. */
    QString target() const;

76
    ///@cond internal
Volker Krause's avatar
Volker Krause committed
77
    void setUuid(const QUuid &id);
78
    void setUrl(const QUrl &url);
79
    void setTarget(const QString &target);
80
    static SurveyInfo fromJson(const QJsonObject &obj);
81
    ///@endcond
82
83
84
85
86
87
88
private:
    QSharedDataPointer<SurveyInfoData> d;
};

}

#endif // USERFEEDBACK_SURVEYINFO_H