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
4#ifndef QDECLARATIVEPLACECONTENTMODEL_H
5#define QDECLARATIVEPLACECONTENTMODEL_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtLocation/private/qlocationglobal_p.h>
19#include <QtCore/QAbstractListModel>
20#include <QtQml/QQmlParserStatus>
21#include <QtLocation/QPlaceContent>
22#include <QtLocation/QPlaceContentReply>
23#include <QtLocation/QPlaceContentRequest>
24#include <QtLocation/QPlaceSupplier>
25
26Q_MOC_INCLUDE(<QtLocation/private/qdeclarativeplace_p.h>)
27
28QT_BEGIN_NAMESPACE
29
30class QDeclarativePlace;
31class QDeclarativeGeoServiceProvider;
32class QGeoServiceProvider;
33
34class Q_LOCATION_EXPORT QDeclarativePlaceContentModel : public QAbstractListModel, public QQmlParserStatus
35{
36 Q_OBJECT
37
38 Q_PROPERTY(QDeclarativePlace *place READ place WRITE setPlace NOTIFY placeChanged)
39 Q_PROPERTY(int batchSize READ batchSize WRITE setBatchSize NOTIFY batchSizeChanged)
40 Q_PROPERTY(int totalCount READ totalCount NOTIFY totalCountChanged)
41
42 Q_INTERFACES(QQmlParserStatus)
43
44public:
45 explicit QDeclarativePlaceContentModel(QPlaceContent::Type type, QObject *parent = nullptr);
46 ~QDeclarativePlaceContentModel();
47
48 QDeclarativePlace *place() const;
49 void setPlace(QDeclarativePlace *place);
50
51 int batchSize() const;
52 void setBatchSize(int batchSize);
53
54 int totalCount() const;
55
56 void clearData();
57
58 void initializeCollection(int totalCount, const QPlaceContent::Collection &collection);
59
60 // from QAbstractListModel
61 int rowCount(const QModelIndex &parent) const override;
62 QVariant data(const QModelIndex &index, int role) const override;
63 QHash<int, QByteArray> roleNames() const override;
64
65 enum Roles {
66 ContentSupplierRole = Qt::UserRole,
67 ContentUserRole,
68 ContentAttributionRole,
69 EditorialTitleRole,
70 EditorialTextRole,
71 EditorialLanguageRole,
72 ImageIdRole,
73 ImageUrlRole,
74 ImageMimeTypeRole,
75 ReviewIdRole,
76 ReviewDateTimeRole,
77 ReviewTitleRole,
78 ReviewTextRole,
79 ReviewLanguageRole,
80 ReviewRatingRole
81 };
82
83 bool canFetchMore(const QModelIndex &parent) const override;
84 void fetchMore(const QModelIndex &parent) override;
85
86 // from QQmlParserStatus
87 void classBegin() override;
88 void componentComplete() override;
89
90Q_SIGNALS:
91 void placeChanged();
92 void batchSizeChanged();
93 void totalCountChanged();
94
95private Q_SLOTS:
96 void fetchFinished();
97
98protected:
99 QPlaceContent::Collection m_content;
100 QMap<QString, QPlaceSupplier> m_suppliers;
101 QMap<QString, QPlaceUser>m_users;
102
103private:
104 QDeclarativePlace *m_place = nullptr;
105 QPlaceContent::Type m_type;
106 int m_batchSize = 1;
107 int m_contentCount = -1;
108
109 QPlaceContentReply *m_reply = nullptr;
110 QPlaceContentRequest m_nextRequest;
111
112 bool m_complete = false;
113};
114
116{
117 Q_GADGET
118 QML_NAMED_ELEMENT(ReviewModel)
120
121public:
125};
126
128{
129 Q_GADGET
130 QML_NAMED_ELEMENT(EditorialModel)
132public:
136};
137
139{
140 Q_GADGET
141 QML_NAMED_ELEMENT(ImageModel)
143public:
147};
148
149QT_END_NAMESPACE
150
151#endif // QDECLARATIVEPLACECONTENTMODEL_H