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
qdeclarativegeoserviceprovider_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 QDECLARATIVEQGEOSERVICEPROVIDER_H
6#define QDECLARATIVEQGEOSERVICEPROVIDER_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
21#include <QtCore/QMap>
22#include <QtCore/QString>
23#include <QtCore/QStringList>
24#include <QtCore/QVariant>
25#include <QtQml/qqml.h>
26#include <QtQml/QQmlParserStatus>
27#include <QtQml/QQmlListProperty>
28#include <QtLocation/QGeoServiceProvider>
29#include <QtPositioningQuick/private/qdeclarativepluginparameter_p.h>
30
31QT_BEGIN_NAMESPACE
32
33class QDeclarativeGeoServiceProviderRequirements;
34
35// From QtPositioning, needs to be registered in the Location module as well.
36// Can probably just be a QVariantMap?
38{
39 Q_GADGET
40 QML_FOREIGN(QDeclarativePluginParameter)
42};
43
44class Q_LOCATION_EXPORT QDeclarativeGeoServiceProvider : public QObject, public QQmlParserStatus
45{
46 Q_OBJECT
47 QML_NAMED_ELEMENT(Plugin)
48 QML_ADDED_IN_VERSION(5, 0)
49
50 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
51 Q_PROPERTY(QStringList availableServiceProviders READ availableServiceProviders CONSTANT)
52 Q_PROPERTY(QQmlListProperty<QDeclarativePluginParameter> parameters READ parameters)
53 Q_PROPERTY(QDeclarativeGeoServiceProviderRequirements *required READ requirements WRITE setRequirements)
54 Q_PROPERTY(QStringList locales READ locales WRITE setLocales NOTIFY localesChanged)
55 Q_PROPERTY(QStringList preferred READ preferred WRITE setPreferred NOTIFY preferredChanged)
56 Q_PROPERTY(bool allowExperimental READ allowExperimental WRITE setAllowExperimental NOTIFY allowExperimentalChanged)
57 Q_PROPERTY(bool isAttached READ isAttached NOTIFY attached)
58
59 Q_CLASSINFO("DefaultProperty", "parameters")
60 Q_INTERFACES(QQmlParserStatus)
61
62public:
63 explicit QDeclarativeGeoServiceProvider(QObject *parent = nullptr);
64 ~QDeclarativeGeoServiceProvider();
65
66 enum RoutingFeature {
67 NoRoutingFeatures = QGeoServiceProvider::NoRoutingFeatures,
68 OnlineRoutingFeature = QGeoServiceProvider::OnlineRoutingFeature,
69 OfflineRoutingFeature = QGeoServiceProvider::OfflineRoutingFeature,
70 LocalizedRoutingFeature = QGeoServiceProvider::LocalizedRoutingFeature,
71 RouteUpdatesFeature = QGeoServiceProvider::RouteUpdatesFeature,
72 AlternativeRoutesFeature = QGeoServiceProvider::AlternativeRoutesFeature,
73 ExcludeAreasRoutingFeature = QGeoServiceProvider::ExcludeAreasRoutingFeature,
74 AnyRoutingFeatures = QGeoServiceProvider::AnyRoutingFeatures
75 };
76
77 enum GeocodingFeature {
78 NoGeocodingFeatures = QGeoServiceProvider::NoGeocodingFeatures,
79 OnlineGeocodingFeature = QGeoServiceProvider::OnlineGeocodingFeature,
80 OfflineGeocodingFeature = QGeoServiceProvider::OfflineGeocodingFeature,
81 ReverseGeocodingFeature = QGeoServiceProvider::ReverseGeocodingFeature,
82 LocalizedGeocodingFeature = QGeoServiceProvider::LocalizedGeocodingFeature,
83 AnyGeocodingFeatures = QGeoServiceProvider::AnyGeocodingFeatures
84 };
85
86 enum MappingFeature {
87 NoMappingFeatures = QGeoServiceProvider::NoMappingFeatures,
88 OnlineMappingFeature = QGeoServiceProvider::OnlineMappingFeature,
89 OfflineMappingFeature = QGeoServiceProvider::OfflineMappingFeature,
90 LocalizedMappingFeature = QGeoServiceProvider::LocalizedMappingFeature,
91 AnyMappingFeatures = QGeoServiceProvider::AnyMappingFeatures
92 };
93
94 enum PlacesFeature {
95 NoPlacesFeatures = QGeoServiceProvider::NoPlacesFeatures,
96 OnlinePlacesFeature = QGeoServiceProvider::OnlinePlacesFeature,
97 OfflinePlacesFeature = QGeoServiceProvider::OfflinePlacesFeature,
98 SavePlaceFeature = QGeoServiceProvider::SavePlaceFeature,
99 RemovePlaceFeature = QGeoServiceProvider::RemovePlaceFeature,
100 SaveCategoryFeature = QGeoServiceProvider::SaveCategoryFeature,
101 RemoveCategoryFeature = QGeoServiceProvider::RemoveCategoryFeature,
102 PlaceRecommendationsFeature = QGeoServiceProvider::PlaceRecommendationsFeature,
103 SearchSuggestionsFeature = QGeoServiceProvider::SearchSuggestionsFeature,
104 LocalizedPlacesFeature = QGeoServiceProvider::LocalizedPlacesFeature,
105 NotificationsFeature = QGeoServiceProvider::NotificationsFeature,
106 PlaceMatchingFeature = QGeoServiceProvider::PlaceMatchingFeature,
107 AnyPlacesFeatures = QGeoServiceProvider::AnyPlacesFeatures
108 };
109
110 enum NavigationFeature {
111 NoNavigationFeatures = QGeoServiceProvider::NoNavigationFeatures,
112 OnlineNavigationFeature = QGeoServiceProvider::OnlineNavigationFeature,
113 OfflineNavigationFeature = QGeoServiceProvider::OfflineNavigationFeature,
114 AnyNavigationFeatures = QGeoServiceProvider::AnyNavigationFeatures
115 };
116
117 Q_ENUM(RoutingFeature)
118 Q_DECLARE_FLAGS(RoutingFeatures, RoutingFeature)
119 Q_FLAG(RoutingFeatures)
120
121 Q_ENUM(GeocodingFeature)
122 Q_DECLARE_FLAGS(GeocodingFeatures, GeocodingFeature)
123 Q_FLAG(GeocodingFeatures)
124
125 Q_ENUM(MappingFeature)
126 Q_DECLARE_FLAGS(MappingFeatures, MappingFeature)
127 Q_FLAG(MappingFeatures)
128
129 Q_ENUM(PlacesFeature)
130 Q_DECLARE_FLAGS(PlacesFeatures, PlacesFeature)
131 Q_FLAG(PlacesFeatures)
132
133 Q_DECLARE_FLAGS(NavigationFeatures, NavigationFeature)
134 Q_FLAG(NavigationFeatures)
135
136 // From QQmlParserStatus
137 void classBegin() override {}
138 void componentComplete() override;
139
140 void setName(const QString &name);
141 QString name() const;
142
143 QQmlListProperty<QDeclarativePluginParameter> parameters();
144 QVariantMap parameterMap() const;
145
146 QStringList availableServiceProviders();
147
148 QDeclarativeGeoServiceProviderRequirements *requirements() const;
149 void setRequirements(QDeclarativeGeoServiceProviderRequirements *req);
150
151 QStringList preferred() const;
152 void setPreferred(const QStringList &val);
153
154 QGeoServiceProvider *sharedGeoServiceProvider() const;
155
156 Q_INVOKABLE bool supportsRouting(const RoutingFeatures &feature = AnyRoutingFeatures) const;
157 Q_INVOKABLE bool supportsGeocoding(const GeocodingFeatures &feature = AnyGeocodingFeatures) const;
158 Q_INVOKABLE bool supportsMapping(const MappingFeatures &feature = AnyMappingFeatures) const;
159 Q_INVOKABLE bool supportsPlaces(const PlacesFeatures &feature = AnyPlacesFeatures) const;
160 Q_REVISION(5, 11) Q_INVOKABLE bool supportsNavigation(const NavigationFeature &feature = AnyNavigationFeatures) const;
161
162 QStringList locales() const;
163 void setLocales(const QStringList &locales);
164
165 bool isAttached() const;
166
167 void setAllowExperimental(bool allow);
168 bool allowExperimental() const;
169
170Q_SIGNALS:
171 void nameChanged(const QString &name);
172 void localesChanged();
173 void attached();
174 void preferredChanged(const QStringList &preferences);
175 void allowExperimentalChanged(bool allow);
176
177private:
178 bool parametersReady();
179 void tryAttach();
180 static void parameter_append(QQmlListProperty<QDeclarativePluginParameter> *prop, QDeclarativePluginParameter *mapObject);
181 static qsizetype parameter_count(QQmlListProperty<QDeclarativePluginParameter> *prop);
182 static QDeclarativePluginParameter *parameter_at(QQmlListProperty<QDeclarativePluginParameter> *prop, qsizetype index);
183 static void parameter_clear(QQmlListProperty<QDeclarativePluginParameter> *prop);
184
185 std::unique_ptr<QGeoServiceProvider> sharedProvider_;
186 QString name_;
187 QList<QDeclarativePluginParameter *> parameters_;
188 std::unique_ptr<QDeclarativeGeoServiceProviderRequirements> required_;
189 bool complete_ = false;
190 bool experimental_ = false;
191 QStringList locales_;
192 QStringList prefer_;
193 Q_DISABLE_COPY(QDeclarativeGeoServiceProvider)
194};
195
196class Q_LOCATION_EXPORT QDeclarativeGeoServiceProviderRequirements : public QObject
197{
198 Q_OBJECT
199 QML_NAMED_ELEMENT(PluginRequirements)
200 QML_UNCREATABLE("PluginRequirements is not intended instantiable by developer.")
201 QML_ADDED_IN_VERSION(5, 0)
202 Q_PROPERTY(QDeclarativeGeoServiceProvider::MappingFeatures mapping
203 READ mappingRequirements WRITE setMappingRequirements
204 NOTIFY mappingRequirementsChanged)
205 Q_PROPERTY(QDeclarativeGeoServiceProvider::RoutingFeatures routing
206 READ routingRequirements WRITE setRoutingRequirements
207 NOTIFY routingRequirementsChanged)
208 Q_PROPERTY(QDeclarativeGeoServiceProvider::GeocodingFeatures geocoding
209 READ geocodingRequirements WRITE setGeocodingRequirements
210 NOTIFY geocodingRequirementsChanged)
211 Q_PROPERTY(QDeclarativeGeoServiceProvider::PlacesFeatures places
212 READ placesRequirements WRITE setPlacesRequirements
213 NOTIFY placesRequirementsChanged)
214 Q_PROPERTY(QDeclarativeGeoServiceProvider::NavigationFeatures navigation
215 READ navigationRequirements WRITE setNavigationRequirements
216 NOTIFY navigationRequirementsChanged)
217
218public:
219 explicit QDeclarativeGeoServiceProviderRequirements(QObject *parent = nullptr);
220 ~QDeclarativeGeoServiceProviderRequirements();
221
222 QDeclarativeGeoServiceProvider::MappingFeatures mappingRequirements() const;
223 void setMappingRequirements(const QDeclarativeGeoServiceProvider::MappingFeatures &features);
224
225 QDeclarativeGeoServiceProvider::RoutingFeatures routingRequirements() const;
226 void setRoutingRequirements(const QDeclarativeGeoServiceProvider::RoutingFeatures &features);
227
228 QDeclarativeGeoServiceProvider::GeocodingFeatures geocodingRequirements() const;
229 void setGeocodingRequirements(const QDeclarativeGeoServiceProvider::GeocodingFeatures &features);
230
231 QDeclarativeGeoServiceProvider::PlacesFeatures placesRequirements() const;
232 void setPlacesRequirements(const QDeclarativeGeoServiceProvider::PlacesFeatures &features);
234 QDeclarativeGeoServiceProvider::NavigationFeatures navigationRequirements() const;
235 void setNavigationRequirements(const QDeclarativeGeoServiceProvider::NavigationFeatures &features);
237 Q_INVOKABLE bool matches(const QGeoServiceProvider *provider) const;
239 bool operator == (const QDeclarativeGeoServiceProviderRequirements &rhs) const;
240
241Q_SIGNALS:
242 void mappingRequirementsChanged(const QDeclarativeGeoServiceProvider::MappingFeatures &features);
243 void routingRequirementsChanged(const QDeclarativeGeoServiceProvider::RoutingFeatures &features);
244 void geocodingRequirementsChanged(const QDeclarativeGeoServiceProvider::GeocodingFeatures &features);
245 void placesRequirementsChanged(const QDeclarativeGeoServiceProvider::PlacesFeatures &features);
246 void navigationRequirementsChanged(const QDeclarativeGeoServiceProvider::NavigationFeatures &features);
247
248 void requirementsChanged();
249
250private:
251 QDeclarativeGeoServiceProvider::MappingFeatures mapping_ = QDeclarativeGeoServiceProvider::NoMappingFeatures;
252 QDeclarativeGeoServiceProvider::RoutingFeatures routing_ = QDeclarativeGeoServiceProvider::NoRoutingFeatures;
253 QDeclarativeGeoServiceProvider::GeocodingFeatures geocoding_ = QDeclarativeGeoServiceProvider::NoGeocodingFeatures;
254 QDeclarativeGeoServiceProvider::PlacesFeatures places_ = QDeclarativeGeoServiceProvider::NoPlacesFeatures;
255 QDeclarativeGeoServiceProvider::NavigationFeatures navigation_ = QDeclarativeGeoServiceProvider::NoNavigationFeatures;
256};
257
258QT_END_NAMESPACE
259
260QML_DECLARE_TYPE(QDeclarativeGeoServiceProviderRequirements)
261QML_DECLARE_TYPE(QDeclarativeGeoServiceProvider)
262
263#endif