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