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.cpp
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
6#include <QtQml/QQmlInfo>
7#include <QtQml/QQmlEngine>
8#include <QLocale>
9
10QT_BEGIN_NAMESPACE
11
12/*!
13 \qmltype Plugin
14 //! \nativetype QDeclarativeGeoServiceProvider
15 \inqmlmodule QtLocation
16 \ingroup qml-QtLocation5-common
17 \since QtLocation 5.5
18
19 \brief The Plugin type describes a Location based services plugin.
20
21 The Plugin type is used to declaratively specify which available
22 GeoServices plugin should be used for various tasks in the Location API.
23 Plugins are used by \l Map, \l RouteModel, and \l GeocodeModel
24 types, as well as a variety of others.
25
26 Plugins recognized by the system have a \l name property, a simple string
27 normally indicating the name of the service that the Plugin retrieves
28 data from. They also have a variety of features, which can be test for using the
29 \l {supportsRouting()}, \l {supportsGeocoding()}, \l {supportsMapping()},
30 \l {supportsPlaces()} and \l {supportsNavigation()} methods.
31
32 When a Plugin object is created, it is "detached" and not associated with
33 any actual service plugin. Once it has received information via setting
34 its \l name, \l preferred, or \l required properties, it will choose an
35 appropriate service plugin to attach to. Plugin objects can only be
36 attached once; to use multiple plugins, create multiple Plugin objects.
37
38 \section2 Example Usage
39
40 The following snippet shows a Plugin object being created with the
41 \l required and \l preferred properties set. This Plugin will attach to the
42 first found plugin that supports both mapping and geocoding, and will
43 prefer plugins named "here" or "osm" to any others.
44
45 \code
46 Plugin {
47 id: plugin
48 preferred: ["here", "osm"]
49 required: Plugin.AnyMappingFeatures | Plugin.AnyGeocodingFeatures
50 }
51 \endcode
52*/
53
54QDeclarativeGeoServiceProvider::QDeclarativeGeoServiceProvider(QObject *parent)
55: QObject(parent), required_(new QDeclarativeGeoServiceProviderRequirements)
56{
57 locales_.append(QLocale().name());
58}
59
60QDeclarativeGeoServiceProvider::~QDeclarativeGeoServiceProvider()
61{
62}
63
64
65
66/*!
67 \qmlproperty string Plugin::name
68
69 This property holds the name of the plugin. Setting this property
70 will cause the Plugin to only attach to a plugin with exactly this
71 name. The value of \l required will be ignored.
72*/
73void QDeclarativeGeoServiceProvider::setName(const QString &name)
74{
75 if (name_ == name)
76 return;
77
78 name_ = name;
79
80 if (complete_)
81 tryAttach();
82
83 emit nameChanged(name_);
84}
85
86/*!
87 \internal
88*/
89bool QDeclarativeGeoServiceProvider::parametersReady() {
90 for (const QDeclarativePluginParameter *p: std::as_const(parameters_)) {
91 if (!p->isInitialized())
92 return false;
93 }
94 return true;
95}
96
97/*!
98 \internal
99*/
100void QDeclarativeGeoServiceProvider::tryAttach()
101{
102 if (!parametersReady())
103 return;
104
105 sharedProvider_.reset();
106
107 if (name_.isEmpty())
108 return;
109
110 sharedProvider_.reset(new QGeoServiceProvider(name_, parameterMap()));
111 sharedProvider_->setQmlEngine(qmlEngine(this));
112 sharedProvider_->setLocale(QLocale(locales_.at(0)));
113 sharedProvider_->setAllowExperimental(experimental_);
114
115 emit attached();
116}
117
118QString QDeclarativeGeoServiceProvider::name() const
119{
120 return name_;
121}
122
123
124/*!
125 \qmlproperty stringlist Plugin::availableServiceProviders
126
127 This property holds a list of all available service plugins' names. This
128 can be used to manually enumerate the available plugins if the
129 control provided by \l name and \l required is not sufficient for your
130 needs.
131*/
132QStringList QDeclarativeGeoServiceProvider::availableServiceProviders()
133{
134 return QGeoServiceProvider::availableServiceProviders();
135}
136
137/*!
138 \internal
139*/
140void QDeclarativeGeoServiceProvider::componentComplete()
141{
142 complete_ = true;
143
144 for (QDeclarativePluginParameter *p: std::as_const(parameters_)) {
145 if (!p->isInitialized()) {
146 connect(p, &QDeclarativePluginParameter::initialized,
147 this, &QDeclarativeGeoServiceProvider::tryAttach);
148 }
149 }
150
151 if (!name_.isEmpty()) {
152 tryAttach();
153 } else if (!prefer_.isEmpty()
154 || required_->mappingRequirements() != NoMappingFeatures
155 || required_->routingRequirements() != NoRoutingFeatures
156 || required_->geocodingRequirements() != NoGeocodingFeatures
157 || required_->placesRequirements() != NoPlacesFeatures
158 || required_->navigationRequirements() != NoNavigationFeatures) {
159
160 QStringList providers = QGeoServiceProvider::availableServiceProviders();
161
162 /* first check any preferred plugins */
163 for (const QString &name : std::as_const(prefer_)) {
164 if (providers.contains(name)) {
165 // so we don't try it again later
166 providers.removeAll(name);
167
168 QGeoServiceProvider sp(name, parameterMap(), experimental_);
169 if (required_->matches(&sp)) {
170 setName(name);
171 return;
172 }
173 }
174 }
175
176 /* then try the rest */
177 for (const QString &name : std::as_const(providers)) {
178 QGeoServiceProvider sp(name, parameterMap(), experimental_);
179 if (required_->matches(&sp)) {
180 setName(name);
181 return;
182 }
183 }
184
185 qmlWarning(this) << "Could not find a plugin with the required features to attach to";
186 }
187}
188
189/*!
190 \qmlmethod bool Plugin::supportsGeocoding(GeocodingFeatures features)
191
192 This method returns a boolean indicating whether the specified set of \a features are supported
193 by the geo service provider plugin. \c True is returned if all specified \a features are
194 supported; otherwise \c false is returned.
195
196 The \a features parameter can be any flag combination of:
197 \table
198 \header
199 \li Feature
200 \li Description
201 \row
202 \li Plugin.NoGeocodingFeatures
203 \li No geocoding features are supported.
204 \row
205 \li Plugin.OnlineGeocodingFeature
206 \li Online geocoding is supported.
207 \row
208 \li Plugin.OfflineGeocodingFeature
209 \li Offline geocoding is supported.
210 \row
211 \li Plugin.ReverseGeocodingFeature
212 \li Reverse geocoding is supported.
213 \row
214 \li Plugin.LocalizedGeocodingFeature
215 \li Supports returning geocoding results with localized addresses.
216 \row
217 \li Plugin.AnyGeocodingFeatures
218 \li Matches a geo service provider that provides any geocoding features.
219 \endtable
220*/
221bool QDeclarativeGeoServiceProvider::supportsGeocoding(const GeocodingFeatures &feature) const
222{
223 QGeoServiceProvider *sp = sharedGeoServiceProvider();
224 QGeoServiceProvider::GeocodingFeatures f =
225 static_cast<QGeoServiceProvider::GeocodingFeature>(int(feature));
226 if (f == QGeoServiceProvider::AnyGeocodingFeatures)
227 return (sp && (sp->geocodingFeatures() != QGeoServiceProvider::NoGeocodingFeatures));
228 else
229 return (sp && (sp->geocodingFeatures() & f) == f);
230}
231
232/*!
233 \qmlmethod bool Plugin::supportsMapping(MappingFeatures features)
234
235 This method returns a boolean indicating whether the specified set of \a features are supported
236 by the geo service provider plugin. True is returned if all specified \a features are
237 supported; otherwise false is returned.
238
239 The \a features parameter can be any flag combination of:
240 \table
241 \header
242 \li Feature
243 \li Description
244 \row
245 \li Plugin.NoMappingFeatures
246 \li No mapping features are supported.
247 \row
248 \li Plugin.OnlineMappingFeature
249 \li Online mapping is supported.
250 \row
251 \li Plugin.OfflineMappingFeature
252 \li Offline mapping is supported.
253 \row
254 \li Plugin.LocalizedMappingFeature
255 \li Supports returning localized map data.
256 \row
257 \li Plugin.AnyMappingFeatures
258 \li Matches a geo service provider that provides any mapping features.
259 \endtable
260*/
261bool QDeclarativeGeoServiceProvider::supportsMapping(const MappingFeatures &feature) const
262{
263 QGeoServiceProvider *sp = sharedGeoServiceProvider();
264 QGeoServiceProvider::MappingFeatures f =
265 static_cast<QGeoServiceProvider::MappingFeature>(int(feature));
266 if (f == QGeoServiceProvider::AnyMappingFeatures)
267 return (sp && (sp->mappingFeatures() != QGeoServiceProvider::NoMappingFeatures));
268 else
269 return (sp && (sp->mappingFeatures() & f) == f);
270}
271
272/*!
273 \qmlmethod bool Plugin::supportsRouting(RoutingFeatures features)
274
275 This method returns a boolean indicating whether the specified set of \a features are supported
276 by the geo service provider plugin. True is returned if all specified \a features are
277 supported; otherwise false is returned.
278
279 The \a features parameter can be any flag combination of:
280 \table
281 \header
282 \li Feature
283 \li Description
284 \row
285 \li Plugin.NoRoutingFeatures
286 \li No routing features are supported.
287 \row
288 \li Plugin.OnlineRoutingFeature
289 \li Online routing is supported.
290 \row
291 \li Plugin.OfflineRoutingFeature
292 \li Offline routing is supported.
293 \row
294 \li Plugin.LocalizedRoutingFeature
295 \li Supports returning routes with localized addresses and instructions.
296 \row
297 \li Plugin.RouteUpdatesFeature
298 \li Updating an existing route based on the current position is supported.
299 \row
300 \li Plugin.AlternativeRoutesFeature
301 \li Supports returning alternative routes.
302 \row
303 \li Plugin.ExcludeAreasRoutingFeature
304 \li Supports specifying a areas which the returned route must not cross.
305 \row
306 \li Plugin.AnyRoutingFeatures
307 \li Matches a geo service provider that provides any routing features.
308 \endtable
309*/
310bool QDeclarativeGeoServiceProvider::supportsRouting(const RoutingFeatures &feature) const
311{
312 QGeoServiceProvider *sp = sharedGeoServiceProvider();
313 QGeoServiceProvider::RoutingFeatures f =
314 static_cast<QGeoServiceProvider::RoutingFeature>(int(feature));
315 if (f == QGeoServiceProvider::AnyRoutingFeatures)
316 return (sp && (sp->routingFeatures() != QGeoServiceProvider::NoRoutingFeatures));
317 else
318 return (sp && (sp->routingFeatures() & f) == f);
319}
320
321/*!
322 \qmlmethod bool Plugin::supportsPlaces(PlacesFeatures features)
323
324 This method returns a boolean indicating whether the specified set of \a features are supported
325 by the geo service provider plugin. True is returned if all specified \a features are
326 supported; otherwise false is returned.
327
328 The \a features parameter can be any flag combination of:
329 \table
330 \header
331 \li Feature
332 \li Description
333 \row
334 \li Plugin.NoPlacesFeatures
335 \li No places features are supported.
336 \row
337 \li Plugin.OnlinePlacesFeature
338 \li Online places is supported.
339 \row
340 \li Plugin.OfflinePlacesFeature
341 \li Offline places is supported.
342 \row
343 \li Plugin.SavePlaceFeature
344 \li Saving categories is supported.
345 \row
346 \li Plugin.RemovePlaceFeature
347 \li Removing or deleting places is supported.
348 \row
349 \li Plugin.PlaceRecommendationsFeature
350 \li Searching for recommended places similar to another place is supported.
351 \row
352 \li Plugin.SearchSuggestionsFeature
353 \li Search suggestions is supported.
354 \row
355 \li Plugin.LocalizedPlacesFeature
356 \li Supports returning localized place data.
357 \row
358 \li Plugin.NotificationsFeature
359 \li Notifications of place and category changes is supported.
360 \row
361 \li Plugin.PlaceMatchingFeature
362 \li Supports matching places from two different geo service providers.
363 \row
364 \li Plugin.AnyPlacesFeatures
365 \li Matches a geo service provider that provides any places features.
366 \endtable
367*/
368bool QDeclarativeGeoServiceProvider::supportsPlaces(const PlacesFeatures &feature) const
369{
370 QGeoServiceProvider *sp = sharedGeoServiceProvider();
371 QGeoServiceProvider::PlacesFeatures f =
372 static_cast<QGeoServiceProvider::PlacesFeature>(int(feature));
373 if (f == QGeoServiceProvider::AnyPlacesFeatures)
374 return (sp && (sp->placesFeatures() != QGeoServiceProvider::NoPlacesFeatures));
375 else
376 return (sp && (sp->placesFeatures() & f) == f);
377}
378
379/*!
380 \qmlmethod bool Plugin::supportsNavigation(NavigationFeatures features)
381
382 This method returns a boolean indicating whether the specified set of \a features are supported
383 by the geo service provider plugin. True is returned if all specified \a features are
384 supported; otherwise false is returned.
385
386 The \a features parameter can be any flag combination of:
387 \table
388 \header
389 \li Feature
390 \li Description
391 \row
392 \li Plugin.NoNavigationFeatures
393 \li No navigation features are supported.
394 \row
395 \li Plugin.OnlineNavigationFeature
396 \li Online navigation is supported.
397 \row
398 \li Plugin.OfflineNavigationFeature
399 \li Offline navigation is supported.
400 \row
401 \li Plugin.AnyNavigationFeatures
402 \li Matches a geo service provider that provides any navigation features.
403 \endtable
404*/
405bool QDeclarativeGeoServiceProvider::supportsNavigation(const QDeclarativeGeoServiceProvider::NavigationFeature &feature) const
406{
407 QGeoServiceProvider *sp = sharedGeoServiceProvider();
408 QGeoServiceProvider::NavigationFeatures f =
409 static_cast<QGeoServiceProvider::NavigationFeature>(int(feature));
410 if (f == QGeoServiceProvider::AnyNavigationFeatures)
411 return (sp && (sp->navigationFeatures() != QGeoServiceProvider::NoNavigationFeatures));
412 else
413 return (sp && (sp->navigationFeatures() & f) == f);
414}
415
416/*!
417 \qmlproperty enumeration Plugin::required
418
419 This property contains the set of features that will be required by the
420 Plugin object when choosing which service plugin to attach to. If the
421 \l name property is set, this has no effect.
422
423 Any of the following values or a bitwise combination of multiple values
424 may be set:
425
426 \list
427 \li Plugin.NoFeatures
428 \li Plugin.GeocodingFeature
429 \li Plugin.ReverseGeocodingFeature
430 \li Plugin.RoutingFeature
431 \li Plugin.MappingFeature
432 \li Plugin.AnyPlacesFeature
433 \endlist
434*/
435QDeclarativeGeoServiceProviderRequirements *QDeclarativeGeoServiceProvider::requirements() const
436{
437 return required_.get();
438}
439
440void QDeclarativeGeoServiceProvider::setRequirements(QDeclarativeGeoServiceProviderRequirements *req)
441{
442 if (!name().isEmpty() || !req)
443 return;
444
445 if (required_ && *required_ == *req)
446 return;
447
448 required_.reset(req);
449 QQmlEngine::setObjectOwnership(req, QQmlEngine::CppOwnership); // To prevent the engine from making this object disappear
450}
451
452/*!
453 \qmlproperty stringlist Plugin::preferred
454
455 This property contains an ordered list of preferred plugin names, which
456 will be checked for the required features set in \l{Plugin::required}{required}
457 before any other available plugins are checked.
458*/
459QStringList QDeclarativeGeoServiceProvider::preferred() const
460{
461 return prefer_;
462}
463
464void QDeclarativeGeoServiceProvider::setPreferred(const QStringList &val)
465{
466 prefer_ = val;
467 emit preferredChanged(prefer_);
468}
469
470/*!
471 \qmlproperty bool Plugin::isAttached
472
473 This property indicates if the Plugin item is attached to a geoservice provider plugin.
474*/
475bool QDeclarativeGeoServiceProvider::isAttached() const
476{
477 return (sharedProvider_ != 0);
478}
479
480/*!
481 \qmlproperty bool Plugin::allowExperimental
482
483 This property indicates if experimental plugins can be used.
484*/
485bool QDeclarativeGeoServiceProvider::allowExperimental() const
486{
487 return experimental_;
488}
489
490void QDeclarativeGeoServiceProvider::setAllowExperimental(bool allow)
491{
492 if (experimental_ == allow)
493 return;
494
495 experimental_ = allow;
496 if (sharedProvider_)
497 sharedProvider_->setAllowExperimental(allow);
498
499 emit allowExperimentalChanged(allow);
500}
501
502/*!
503 \internal
504*/
505QGeoServiceProvider *QDeclarativeGeoServiceProvider::sharedGeoServiceProvider() const
506{
507 return sharedProvider_.get();
508}
509
510/*!
511 \qmlproperty stringlist Plugin::locales
512
513 This property contains an ordered list of preferred plugin locales. If the first locale cannot be accommodated, then
514 the backend falls back to using the second, and so on. By default the locales property contains the system locale.
515
516 The locales are specified as strings which have the format
517 "language[_script][_country]" or "C", where:
518
519 \list
520 \li language is a lowercase, two-letter, ISO 639 language code,
521 \li script is a titlecase, four-letter, ISO 15924 script code,
522 \li country is an uppercase, two- or three-letter, ISO 3166 country code (also "419" as defined by United Nations),
523 \li the "C" locale is identical in behavior to English/UnitedStates as per QLocale
524 \endlist
525
526 If the first specified locale cannot be accommodated, the \l {Plugin} falls back to the next and so forth.
527 Some \l {Plugin} backends may not support a set of locales which are rigidly defined. An arbitrary
528 example is that some \l {Place}'s in France could have French and English localizations, while
529 certain areas in America may only have the English localization available. In the above scenario,
530 the set of supported locales is context dependent on the search location.
531
532 If the \l {Plugin} cannot accommodate any of the preferred locales, the manager falls
533 back to using a supported language that is backend specific.
534
535 For \l {Plugin}'s that do not support locales, the locales list is always empty.
536
537 The following code demonstrates how to set a single and multiple locales:
538 \snippet declarative/plugin.qml Plugin locale
539*/
540QStringList QDeclarativeGeoServiceProvider::locales() const
541{
542 return locales_;
543}
544
545void QDeclarativeGeoServiceProvider::setLocales(const QStringList &locales)
546{
547 if (locales_ == locales)
548 return;
549
550 locales_ = locales;
551
552 if (locales_.isEmpty())
553 locales_.append(QLocale().name());
554
555 if (sharedProvider_)
556 sharedProvider_->setLocale(QLocale(locales_.at(0)));
557
558 emit localesChanged();
559}
560
561/*!
562 \qmlproperty list<PluginParameter> Plugin::parameters
563 \qmldefault
564
565 This property holds the list of plugin parameters.
566*/
567QQmlListProperty<QDeclarativePluginParameter> QDeclarativeGeoServiceProvider::parameters()
568{
569 return QQmlListProperty<QDeclarativePluginParameter>(this,
570 0,
571 parameter_append,
572 parameter_count,
573 parameter_at,
574 parameter_clear);
575}
576
577/*!
578 \internal
579*/
580void QDeclarativeGeoServiceProvider::parameter_append(QQmlListProperty<QDeclarativePluginParameter> *prop, QDeclarativePluginParameter *parameter)
581{
582 QDeclarativeGeoServiceProvider *p = static_cast<QDeclarativeGeoServiceProvider *>(prop->object);
583 p->parameters_.append(parameter);
584 if (p->sharedProvider_)
585 p->sharedProvider_->setParameters(p->parameterMap());
586}
587
588/*!
589 \internal
590*/
591qsizetype QDeclarativeGeoServiceProvider::parameter_count(QQmlListProperty<QDeclarativePluginParameter> *prop)
592{
593 return static_cast<QDeclarativeGeoServiceProvider *>(prop->object)->parameters_.count();
594}
595
596/*!
597 \internal
598*/
599QDeclarativePluginParameter *QDeclarativeGeoServiceProvider::parameter_at(QQmlListProperty<QDeclarativePluginParameter> *prop, qsizetype index)
600{
601 return static_cast<QDeclarativeGeoServiceProvider *>(prop->object)->parameters_[index];
602}
603
604/*!
605 \internal
606*/
607void QDeclarativeGeoServiceProvider::parameter_clear(QQmlListProperty<QDeclarativePluginParameter> *prop)
608{
609 QDeclarativeGeoServiceProvider *p = static_cast<QDeclarativeGeoServiceProvider *>(prop->object);
610 p->parameters_.clear();
611 if (p->sharedProvider_)
612 p->sharedProvider_->setParameters(p->parameterMap());
613}
614
615/*!
616 \internal
617*/
618QVariantMap QDeclarativeGeoServiceProvider::parameterMap() const
619{
620 QVariantMap map;
621
622 for (const auto *parameter : parameters_)
623 map.insert(parameter->name(), parameter->value());
624
625 return map;
626}
627
628/*******************************************************************************
629*******************************************************************************/
630
631QDeclarativeGeoServiceProviderRequirements::QDeclarativeGeoServiceProviderRequirements(QObject *parent)
632 : QObject(parent)
633{
634}
635
636QDeclarativeGeoServiceProviderRequirements::~QDeclarativeGeoServiceProviderRequirements()
637{
638}
639
640/*!
641 \internal
642*/
643QDeclarativeGeoServiceProvider::MappingFeatures QDeclarativeGeoServiceProviderRequirements::mappingRequirements() const
644{
645 return mapping_;
646}
647
648/*!
649 \internal
650*/
651void QDeclarativeGeoServiceProviderRequirements::setMappingRequirements(const QDeclarativeGeoServiceProvider::MappingFeatures &features)
652{
653 if (mapping_ == features)
654 return;
655
656 mapping_ = features;
657 emit mappingRequirementsChanged(mapping_);
658 emit requirementsChanged();
659}
660
661/*!
662 \internal
663*/
664QDeclarativeGeoServiceProvider::RoutingFeatures QDeclarativeGeoServiceProviderRequirements::routingRequirements() const
665{
666 return routing_;
667}
668
669/*!
670 \internal
671*/
672void QDeclarativeGeoServiceProviderRequirements::setRoutingRequirements(const QDeclarativeGeoServiceProvider::RoutingFeatures &features)
673{
674 if (routing_ == features)
675 return;
676
677 routing_ = features;
678 emit routingRequirementsChanged(routing_);
679 emit requirementsChanged();
680}
681
682/*!
683 \internal
684*/
685QDeclarativeGeoServiceProvider::GeocodingFeatures QDeclarativeGeoServiceProviderRequirements::geocodingRequirements() const
686{
687 return geocoding_;
688}
689
690/*!
691 \internal
692*/
693void QDeclarativeGeoServiceProviderRequirements::setGeocodingRequirements(const QDeclarativeGeoServiceProvider::GeocodingFeatures &features)
694{
695 if (geocoding_ == features)
696 return;
697
698 geocoding_ = features;
699 emit geocodingRequirementsChanged(geocoding_);
700 emit requirementsChanged();
701}
702
703/*!
704 \internal
705
706 */
707QDeclarativeGeoServiceProvider::PlacesFeatures QDeclarativeGeoServiceProviderRequirements::placesRequirements() const
708{
709 return places_;
710}
711
712/*!
713 \internal
714*/
715void QDeclarativeGeoServiceProviderRequirements::setPlacesRequirements(const QDeclarativeGeoServiceProvider::PlacesFeatures &features)
716{
717 if (places_ == features)
718 return;
719
720 places_ = features;
721 emit placesRequirementsChanged(places_);
722 emit requirementsChanged();
723}
724
725/*!
726 \internal
727*/
728QDeclarativeGeoServiceProvider::NavigationFeatures QDeclarativeGeoServiceProviderRequirements::navigationRequirements() const
729{
730 return navigation_;
731}
732
733/*!
734 \internal
735*/
736void QDeclarativeGeoServiceProviderRequirements::setNavigationRequirements(const QDeclarativeGeoServiceProvider::NavigationFeatures &features)
737{
738 if (navigation_ == features)
739 return;
740
741 navigation_ = features;
742 emit navigationRequirementsChanged(navigation_);
743 emit requirementsChanged();
744}
745
746/*!
747 \internal
748*/
749bool QDeclarativeGeoServiceProviderRequirements::matches(const QGeoServiceProvider *provider) const
750{
751 QGeoServiceProvider::MappingFeatures mapping =
752 static_cast<QGeoServiceProvider::MappingFeatures>(int(mapping_));
753
754 // extra curlies here to avoid "dangling" else, which could belong to either if
755 // same goes for all the rest of these blocks
756 if (mapping == QGeoServiceProvider::AnyMappingFeatures) {
757 if (provider->mappingFeatures() == QGeoServiceProvider::NoMappingFeatures)
758 return false;
759 } else {
760 if ((provider->mappingFeatures() & mapping) != mapping)
761 return false;
762 }
763
764 QGeoServiceProvider::RoutingFeatures routing =
765 static_cast<QGeoServiceProvider::RoutingFeatures>(int(routing_));
766
767 if (routing == QGeoServiceProvider::AnyRoutingFeatures) {
768 if (provider->routingFeatures() == QGeoServiceProvider::NoRoutingFeatures)
769 return false;
770 } else {
771 if ((provider->routingFeatures() & routing) != routing)
772 return false;
773 }
774
775 QGeoServiceProvider::GeocodingFeatures geocoding =
776 static_cast<QGeoServiceProvider::GeocodingFeatures>(int(geocoding_));
777
778 if (geocoding == QGeoServiceProvider::AnyGeocodingFeatures) {
779 if (provider->geocodingFeatures() == QGeoServiceProvider::NoGeocodingFeatures)
780 return false;
781 } else {
782 if ((provider->geocodingFeatures() & geocoding) != geocoding)
783 return false;
784 }
785
786 QGeoServiceProvider::PlacesFeatures places =
787 static_cast<QGeoServiceProvider::PlacesFeatures>(int(places_));
788
789 if (places == QGeoServiceProvider::AnyPlacesFeatures) {
790 if (provider->placesFeatures() == QGeoServiceProvider::NoPlacesFeatures)
791 return false;
792 } else {
793 if ((provider->placesFeatures() & places) != places)
794 return false;
795 }
796
797 QGeoServiceProvider::NavigationFeatures navigation =
798 static_cast<QGeoServiceProvider::NavigationFeatures>(int(navigation_));
799
800 if (navigation == QGeoServiceProvider::AnyNavigationFeatures) {
801 if (provider->navigationFeatures() == QGeoServiceProvider::NoNavigationFeatures)
802 return false;
803 } else {
804 if ((provider->navigationFeatures() & navigation) != navigation)
805 return false;
806 }
807
808 return true;
809}
810
811bool QDeclarativeGeoServiceProviderRequirements::operator == (const QDeclarativeGeoServiceProviderRequirements &rhs) const
812{
813 return (mapping_ == rhs.mapping_ && routing_ == rhs.routing_
814 && geocoding_ == rhs.geocoding_ && places_ == rhs.places_
815 && navigation_ == rhs.navigation_);
816}
817
818/*******************************************************************************
819*******************************************************************************/
820
821/*!
822 \qmltype PluginParameter
823 //! \nativetype QDeclarativePluginParameter
824 \inqmlmodule QtLocation
825 \ingroup qml-QtLocation5-common
826 \since QtLocation 5.5
827
828 \brief The PluginParameter type describes a parameter for a plugin.
829
830 The PluginParameter object is used to provide a parameter of some kind
831 to a plugin. Typically these parameters contain details like an application
832 token for access to a service, or a proxy server to use for network access,
833 or the serial port to which a serial GPS receiver is connected.
834
835 To set such a parameter, declare a PluginParameter inside an \l Plugin object
836 and give it \l{name} and \l{value} properties. A list of valid parameter names
837 is available from the
838 \l {Qt Location#Plugin References and Parameters}{plugin reference pages}.
839*/
840
841/*!
842 \qmlproperty string PluginParameter::name
843
844 This property holds the name of the plugin parameter as a single formatted string.
845 This property is a write-once property.
846*/
847
848/*!
849 \qmlproperty QVariant PluginParameter::value
850
851 This property holds the value of the plugin parameter which support different types of values (variant).
852 This property is a write-once property.
853*/
854
855/*******************************************************************************
856 * Implementation now in positioningquick
857*******************************************************************************/
858
859QT_END_NAMESPACE