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
qdeclarativeplace_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 QDECLARATIVEPLACE_P_H
6#define QDECLARATIVEPLACE_P_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/QObject>
21#include <QtQml/QQmlListProperty>
22#include <QtQml/QQmlParserStatus>
23#include <QtQml/QQmlPropertyMap>
24#include <QtLocation/QPlace>
25#include <QtLocation/QPlaceRatings>
26#include <QtLocation/QPlaceIcon>
27
28#include <QtPositioningQuick/private/qdeclarativegeolocation_p.h>
29#include <QtLocation/private/qdeclarativecategory_p.h>
30#include <QtLocation/private/qdeclarativeplacecontentmodel_p.h>
31
32QT_BEGIN_NAMESPACE
33
34class QPlaceReply;
35class QPlaceManager;
36class QPlaceSupplier;
37class QDeclarativeContactDetails;
38
39class Q_LOCATION_EXPORT QDeclarativePlace : public QObject, public QQmlParserStatus
40{
41 Q_OBJECT
42 QML_NAMED_ELEMENT(Place)
43 QML_ADDED_IN_VERSION(5, 0)
44
45 Q_PROPERTY(QPlace place READ place WRITE setPlace)
46 Q_PROPERTY(QDeclarativeGeoServiceProvider *plugin READ plugin WRITE setPlugin NOTIFY pluginChanged)
47 Q_PROPERTY(QQmlListProperty<QDeclarativeCategory> categories READ categories NOTIFY categoriesChanged)
48 Q_PROPERTY(QDeclarativeGeoLocation *location READ location WRITE setLocation NOTIFY locationChanged)
49 Q_PROPERTY(QPlaceRatings ratings READ ratings WRITE setRatings NOTIFY ratingsChanged)
50 Q_PROPERTY(QPlaceSupplier supplier READ supplier WRITE setSupplier NOTIFY supplierChanged)
51 Q_PROPERTY(QPlaceIcon icon READ icon WRITE setIcon NOTIFY iconChanged)
52 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
53 Q_PROPERTY(QString placeId READ placeId WRITE setPlaceId NOTIFY placeIdChanged)
54 Q_PROPERTY(QString attribution READ attribution WRITE setAttribution NOTIFY attributionChanged)
55
56 Q_PROPERTY(QDeclarativePlaceReviewModel *reviewModel READ reviewModel NOTIFY reviewModelChanged)
57 Q_PROPERTY(QDeclarativePlaceImageModel *imageModel READ imageModel NOTIFY imageModelChanged)
58 Q_PROPERTY(QDeclarativePlaceEditorialModel *editorialModel READ editorialModel NOTIFY editorialModelChanged)
59
60 Q_PROPERTY(QObject *extendedAttributes READ extendedAttributes NOTIFY extendedAttributesChanged)
61 Q_PROPERTY(QDeclarativeContactDetails *contactDetails READ contactDetails NOTIFY contactDetailsChanged)
62 Q_PROPERTY(bool detailsFetched READ detailsFetched NOTIFY detailsFetchedChanged)
63 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
64
65 Q_PROPERTY(QString primaryPhone READ primaryPhone NOTIFY primaryPhoneChanged)
66 Q_PROPERTY(QString primaryFax READ primaryFax NOTIFY primaryFaxChanged)
67 Q_PROPERTY(QString primaryEmail READ primaryEmail NOTIFY primaryEmailChanged)
68 Q_PROPERTY(QUrl primaryWebsite READ primaryWebsite NOTIFY primaryWebsiteChanged)
69
70 Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged)
71 Q_PROPERTY(QDeclarativePlace *favorite READ favorite WRITE setFavorite NOTIFY favoriteChanged)
72
73 Q_INTERFACES(QQmlParserStatus)
74
75public:
76 explicit QDeclarativePlace(QObject *parent = nullptr);
77 QDeclarativePlace(const QPlace &src, QDeclarativeGeoServiceProvider *plugin, QObject *parent = nullptr);
78 ~QDeclarativePlace();
79
80 enum Status {Ready, Saving, Fetching, Removing, Error};
81 Q_ENUM(Status)
82
83 enum Visibility {
84 UnspecifiedVisibility = QLocation::UnspecifiedVisibility,
85 DeviceVisibility = QLocation::DeviceVisibility,
86 PrivateVisibility = QLocation::PrivateVisibility,
87 PublicVisibility = QLocation::PublicVisibility
88 };
89 Q_ENUM(Visibility)
90
91 //From QQmlParserStatus
92 void classBegin() override {}
93 void componentComplete() override;
94
95 void setPlugin(QDeclarativeGeoServiceProvider *plugin);
96 QDeclarativeGeoServiceProvider *plugin() const;
97
98 QDeclarativePlaceReviewModel *reviewModel();
99 QDeclarativePlaceImageModel *imageModel();
100 QDeclarativePlaceEditorialModel *editorialModel();
101
102 QPlace place() const;
103 void setPlace(const QPlace &src);
104
105 QQmlListProperty<QDeclarativeCategory> categories();
106 static void category_append(QQmlListProperty<QDeclarativeCategory> *prop,
107 QDeclarativeCategory *value);
108 static qsizetype category_count(QQmlListProperty<QDeclarativeCategory> *prop);
109 static QDeclarativeCategory *category_at(QQmlListProperty<QDeclarativeCategory> *prop, qsizetype index);
110 static void category_clear(QQmlListProperty<QDeclarativeCategory> *prop);
111
112 QDeclarativeGeoLocation *location() const;
113 void setLocation(QDeclarativeGeoLocation *location);
114 QPlaceRatings ratings() const;
115 void setRatings(const QPlaceRatings &ratings);
116 QPlaceSupplier supplier() const;
117 void setSupplier(const QPlaceSupplier &supplier);
118 QPlaceIcon icon() const;
119 void setIcon(const QPlaceIcon &icon);
120 QString name() const;
121 void setName(const QString &name);
122 QString placeId() const;
123 void setPlaceId(const QString &placeId);
124 QString attribution() const;
125 void setAttribution(const QString &attribution);
126 bool detailsFetched() const;
127
128 Status status() const;
129 void setStatus(Status status, const QString &errorString = QString());
130
131 Q_INVOKABLE void getDetails();
132 Q_INVOKABLE void save();
133 Q_INVOKABLE void remove();
134 Q_INVOKABLE QString errorString() const;
135
136 QString primaryPhone() const;
137 QString primaryFax() const;
138 QString primaryEmail() const;
139 QUrl primaryWebsite() const;
140
141 QQmlPropertyMap *extendedAttributes() const;
142
143 QDeclarativeContactDetails *contactDetails() const;
144
145 Visibility visibility() const;
146 void setVisibility(Visibility visibility);
147
148 QDeclarativePlace *favorite() const;
149 void setFavorite(QDeclarativePlace *favorite);
150
151 Q_INVOKABLE void copyFrom(QDeclarativePlace *original);
152 Q_INVOKABLE void initializeFavorite(QDeclarativeGeoServiceProvider *plugin);
153
154Q_SIGNALS:
155 void pluginChanged();
156 void categoriesChanged();
157 void locationChanged();
158 void ratingsChanged();
159 void supplierChanged();
160 void iconChanged();
161 void nameChanged();
162 void placeIdChanged();
163 void attributionChanged();
164 void detailsFetchedChanged();
165 void reviewModelChanged();
166 void imageModelChanged();
167 void editorialModelChanged();
168
169 void primaryPhoneChanged();
170 void primaryFaxChanged();
171 void primaryEmailChanged();
172 void primaryWebsiteChanged();
173
174 void extendedAttributesChanged();
175 void contactDetailsChanged();
176 void statusChanged();
177 void visibilityChanged();
178 void favoriteChanged();
179
180private Q_SLOTS:
181 void finished();
182 void contactsModified(const QString &, const QVariant &);
183 void pluginReady();
184 void cleanupDeletedCategories();
185private:
186 void synchronizeCategories();
187 void pullExtendedAttributes();
188 void synchronizeContacts();
189 void primarySignalsEmission(const QString &type = QString());
190 QString primaryValue(const QString &contactType) const;
191
192private:
193 QPlaceManager *manager();
194
195 QList<QDeclarativeCategory *> m_categories;
196 QDeclarativeGeoLocation *m_location = nullptr;
197 QDeclarativePlaceReviewModel *m_reviewModel = nullptr;
198 QDeclarativePlaceImageModel *m_imageModel = nullptr;
199 QDeclarativePlaceEditorialModel *m_editorialModel = nullptr;
200 QQmlPropertyMap *m_extendedAttributes = nullptr;
201 QDeclarativeContactDetails *m_contactDetails = nullptr;
202
203 QPlace m_src;
204
205 QPlaceReply *m_reply = nullptr;
206
207 QDeclarativeGeoServiceProvider *m_plugin = nullptr;
208 bool m_complete = false;
209
210 QString m_prevPrimaryPhone;
211 QString m_prevPrimaryEmail;
212 QString m_prevPrimaryFax;
213 QUrl m_prevPrimaryWebsite;
214
215 QDeclarativePlace *m_favorite = nullptr;
216
217 Status m_status = Ready;
218 QString m_errorString;
219
220 QList<QDeclarativeCategory *>m_categoriesToBeDeleted;
221};
222
223QT_END_NAMESPACE
224
225QML_DECLARE_TYPE(QDeclarativePlace)
226
227#endif // QDECLARATIVEPLACE_P_H
Combined button and popup list for selecting options.