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