summaryrefslogtreecommitdiffstats
path: root/src/location/places/qplacecontent.h
blob: 1af46920aa918feb4ef515ab53d7828ae742b26d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright (C) 2015 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPLACECONTENT_H
#define QPLACECONTENT_H

#include <QtLocation/qlocationglobal.h>

#include <QtCore/QExplicitlySharedDataPointer>
#include <QtCore/QMap>
#include <QtCore/QMetaType>
#include <QtCore/QVariant>

#include <QtLocation/QPlaceUser>
#include <QtLocation/QPlaceSupplier>

QT_BEGIN_NAMESPACE

class QPlaceContentPrivate;
QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QPlaceContentPrivate, Q_LOCATION_EXPORT)

class Q_LOCATION_EXPORT QPlaceContent
{
public:
    typedef QMap<int, QPlaceContent> Collection;

    enum Type {
        NoType = 0,
        ImageType,
        ReviewType,
        EditorialType,
        CustomType = 0x0100
    };

    enum DataTag {
        ContentSupplier,
        ContentUser,
        ContentAttribution,
        ImageId,
        ImageUrl,
        ImageMimeType,
        EditorialTitle,
        EditorialText,
        EditorialLanguage,
        ReviewId,
        ReviewDateTime,
        ReviewTitle,
        ReviewText,
        ReviewLanguage,
        ReviewRating,
        CustomDataTag = 1000
    };

    QPlaceContent(Type type = NoType);
    ~QPlaceContent();

    QPlaceContent(const QPlaceContent &other) noexcept;
    QPlaceContent &operator=(const QPlaceContent &other) noexcept;

    QPlaceContent(QPlaceContent &&other) noexcept = default;
    QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QPlaceContent)
    void swap(QPlaceContent &other) noexcept
    { d_ptr.swap(other.d_ptr); }
    void detach();

    bool operator==(const QPlaceContent &other) const;
    bool operator!=(const QPlaceContent &other) const;

    QPlaceContent::Type type() const;

    QList<DataTag> dataTags() const;
    QVariant value(DataTag tag) const;
    void setValue(DataTag tag, const QVariant &);

#if QT_DEPRECATED_SINCE(6, 0)
    QT_DEPRECATED_VERSION_X_6_0("Use value()") QPlaceSupplier supplier() const
    { return value(QPlaceContent::ContentSupplier).value<QPlaceSupplier>(); }
    QT_DEPRECATED_VERSION_X_6_0("Use setValue()") void setSupplier(const QPlaceSupplier &supplier)
    { setValue(QPlaceContent::ContentSupplier, QVariant::fromValue(supplier)); }

    QT_DEPRECATED_VERSION_X_6_0("Use value()") QPlaceUser user() const
    { return value(QPlaceContent::ContentUser).value<QPlaceUser>(); }
    QT_DEPRECATED_VERSION_X_6_0("Use setValue()") void setUser(const QPlaceUser &user)
    { setValue(QPlaceContent::ContentUser, QVariant::fromValue(user)); }

    QT_DEPRECATED_VERSION_X_6_0("Use value()") QString attribution() const
    { return value(QPlaceContent::ContentAttribution).value<QString>(); }
    QT_DEPRECATED_VERSION_X_6_0("Use setValue()") void setAttribution(const QString &attribution)
    { setValue(QPlaceContent::ContentAttribution, QVariant::fromValue(attribution)); }
#endif

protected:
    inline QPlaceContentPrivate *d_func();
    inline const QPlaceContentPrivate *d_func() const;

private:
    QExplicitlySharedDataPointer<QPlaceContentPrivate> d_ptr;
    friend class QPlaceContentPrivate;
};

QT_END_NAMESPACE

Q_DECLARE_METATYPE(QPlaceContent)
Q_DECLARE_METATYPE(QPlaceContent::Type)

#endif