Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdeclarativeplacecontentmodel_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QDECLARATIVEPLACECONTENTMODEL_H
6#define QDECLARATIVEPLACECONTENTMODEL_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtLocation/private/qlocationglobal_p.h>
20#include <QtCore/QAbstractListModel>
21#include <QtQml/QQmlParserStatus>
22#include <QtLocation/QPlaceContent>
23#include <QtLocation/QPlaceContentReply>
24#include <QtLocation/QPlaceContentRequest>
25#include <QtLocation/QPlaceSupplier>
26
27Q_MOC_INCLUDE(<QtLocation/private/qdeclarativeplace_p.h>)
28
29QT_BEGIN_NAMESPACE
30
31class QDeclarativePlace;
32class QDeclarativeGeoServiceProvider;
33class QGeoServiceProvider;
34
35class Q_LOCATION_EXPORT QDeclarativePlaceContentModel : public QAbstractListModel, public QQmlParserStatus
36{
37 Q_OBJECT
38
39 Q_PROPERTY(QDeclarativePlace *place READ place WRITE setPlace NOTIFY placeChanged)
40 Q_PROPERTY(int batchSize READ batchSize WRITE setBatchSize NOTIFY batchSizeChanged)
41 Q_PROPERTY(int totalCount READ totalCount NOTIFY totalCountChanged)
42
43 Q_INTERFACES(QQmlParserStatus)
44
45public:
46 explicit QDeclarativePlaceContentModel(QPlaceContent::Type type, QObject *parent = nullptr);
47 ~QDeclarativePlaceContentModel();
48
49 QDeclarativePlace *place() const;
50 void setPlace(QDeclarativePlace *place);
51
52 int batchSize() const;
53 void setBatchSize(int batchSize);
54
55 int totalCount() const;
56
57 void clearData();
58
59 void initializeCollection(int totalCount, const QPlaceContent::Collection &collection);
60
61 // from QAbstractListModel
62 int rowCount(const QModelIndex &parent) const override;
63 QVariant data(const QModelIndex &index, int role) const override;
64 QHash<int, QByteArray> roleNames() const override;
65
66 enum Roles {
67 ContentSupplierRole = Qt::UserRole,
68 ContentUserRole,
69 ContentAttributionRole,
70 EditorialTitleRole,
71 EditorialTextRole,
72 EditorialLanguageRole,
73 ImageIdRole,
74 ImageUrlRole,
75 ImageMimeTypeRole,
76 ReviewIdRole,
77 ReviewDateTimeRole,
78 ReviewTitleRole,
79 ReviewTextRole,
80 ReviewLanguageRole,
81 ReviewRatingRole
82 };
83
84 bool canFetchMore(const QModelIndex &parent) const override;
85 void fetchMore(const QModelIndex &parent) override;
86
87 // from QQmlParserStatus
88 void classBegin() override;
89 void componentComplete() override;
90
91Q_SIGNALS:
92 void placeChanged();
93 void batchSizeChanged();
94 void totalCountChanged();
95
96private Q_SLOTS:
97 void fetchFinished();
98
99protected:
100 QPlaceContent::Collection m_content;
101 QMap<QString, QPlaceSupplier> m_suppliers;
102 QMap<QString, QPlaceUser>m_users;
103
104private:
105 QDeclarativePlace *m_place = nullptr;
106 QPlaceContent::Type m_type;
107 int m_batchSize = 1;
108 int m_contentCount = -1;
109
110 QPlaceContentReply *m_reply = nullptr;
111 QPlaceContentRequest m_nextRequest;
112
113 bool m_complete = false;
114};
115
117{
118 Q_GADGET
119 QML_NAMED_ELEMENT(ReviewModel)
121
122public:
126};
127
129{
130 Q_GADGET
131 QML_NAMED_ELEMENT(EditorialModel)
133public:
137};
138
140{
141 Q_GADGET
142 QML_NAMED_ELEMENT(ImageModel)
144public:
148};
149
150QT_END_NAMESPACE
151
152#endif // QDECLARATIVEPLACECONTENTMODEL_H
Combined button and popup list for selecting options.