1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtLocation module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#include <QtLocation/private/qdeclarativegeoserviceprovider_p.h>
38#include <QtPositioningQuick/private/qdeclarativepluginparameter_p.h>
39#include <QtLocation/private/qdeclarativegeomap_p.h>
40
41#include <QtLocation/private/qdeclarativegeoroute_p.h>
42#include <QtLocation/private/qdeclarativegeoroutemodel_p.h>
43#include <QtLocation/private/qdeclarativegeocodemodel_p.h>
44#include <QtLocation/private/qdeclarativegeomaneuver_p.h>
45#include <QtLocation/private/qdeclarativegeomapitembase_p.h>
46#include <QtLocation/private/qdeclarativegeomapquickitem_p.h>
47#include <QtLocation/private/qdeclarativegeomapitemview_p.h>
48#include <QtLocation/private/qdeclarativegeomaptype_p.h>
49#include <QtLocation/private/qdeclarativerectanglemapitem_p.h>
50#include <QtLocation/private/qdeclarativecirclemapitem_p.h>
51#include <QtLocation/private/qdeclarativeroutemapitem_p.h>
52#include <QtLocation/private/qdeclarativepolylinemapitem_p.h>
53#include <QtLocation/private/qdeclarativepolygonmapitem_p.h>
54#include <QtLocation/private/qdeclarativegeomapparameter_p.h>
55#include <QtLocation/private/qdeclarativegeomapcopyrightsnotice_p.h>
56#include <QtLocation/private/qdeclarativegeomapitemgroup_p.h>
57#include <QtLocation/private/qgeomapobject_p.h>
58
59//Place includes
60#include <QtLocation/private/qdeclarativecategory_p.h>
61#include <QtLocation/private/qdeclarativeplace_p.h>
62#include <QtLocation/private/qdeclarativeplaceattribute_p.h>
63#include <QtLocation/private/qdeclarativeplaceicon_p.h>
64#include <QtLocation/private/qdeclarativeratings_p.h>
65#include <QtLocation/private/qdeclarativesupplier_p.h>
66#include <QtLocation/private/qdeclarativeplaceuser_p.h>
67#include <QtLocation/private/qdeclarativecontactdetail_p.h>
68
69#include <QtLocation/private/qdeclarativesupportedcategoriesmodel_p.h>
70#include <QtLocation/private/qdeclarativesearchresultmodel_p.h>
71#include <QtLocation/private/qdeclarativesearchsuggestionmodel_p.h>
72
73#include <QtQml/qqmlextensionplugin.h>
74
75#include <QtCore/QDebug>
76
77QT_BEGIN_NAMESPACE
78
79
80class QtLocationDeclarativeModule: public QQmlExtensionPlugin
81{
82 Q_OBJECT
83
84 Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid
85 FILE "plugin.json")
86
87public:
88 QtLocationDeclarativeModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { }
89 virtual void registerTypes(const char *uri)
90 {
91 if (QLatin1String(uri) == QLatin1String("QtLocation")) {
92
93 // @uri QtLocation
94 int major = 5;
95 int minor = 0;
96
97 // Register the 5.0 types
98 // 5.0 is silent and not advertised
99
100 qmlRegisterType<QDeclarativeGeoServiceProvider >(uri, versionMajor: major, versionMinor: minor, qmlName: "Plugin");
101 qmlRegisterType<QDeclarativePluginParameter >(uri, versionMajor: major, versionMinor: minor, qmlName: "PluginParameter");
102 qmlRegisterUncreatableType<QDeclarativeGeoServiceProviderRequirements>(uri, versionMajor: major, versionMinor: minor, qmlName: "PluginRequirements",
103 QStringLiteral("PluginRequirements is not intended instantiable by developer."));
104 qmlRegisterType<QDeclarativeGeoMap >(uri, versionMajor: major, versionMinor: minor, qmlName: "Map");
105
106 qmlRegisterUncreatableType<QDeclarativeGeoMapItemBase >(uri, versionMajor: major, versionMinor: minor, qmlName: "GeoMapItemBase",
107 QStringLiteral("GeoMapItemBase is not intended instantiable by developer."));
108 qmlRegisterType<QDeclarativeGeoMapQuickItem >(uri, versionMajor: major, versionMinor: minor, qmlName: "MapQuickItem");
109 qmlRegisterType<QDeclarativeGeoMapItemView >(uri, versionMajor: major, versionMinor: minor, qmlName: "MapItemView");
110
111 qmlRegisterType<QDeclarativeGeocodeModel >(uri, versionMajor: major, versionMinor: minor, qmlName: "GeocodeModel"); // geocoding and reverse geocoding
112 qmlRegisterType<QDeclarativeGeoRouteModel >(uri, versionMajor: major, versionMinor: minor, qmlName: "RouteModel");
113 qmlRegisterType<QDeclarativeGeoRouteQuery >(uri, versionMajor: major, versionMinor: minor, qmlName: "RouteQuery");
114 qmlRegisterType<QDeclarativeGeoRoute >(uri, versionMajor: major, versionMinor: minor, qmlName: "Route"); // data type
115 qmlRegisterType<QDeclarativeGeoRouteSegment >(uri, versionMajor: major, versionMinor: minor, qmlName: "RouteSegment");
116 qmlRegisterType<QDeclarativeGeoManeuver >(uri, versionMajor: major, versionMinor: minor, qmlName: "RouteManeuver");
117 qmlRegisterUncreatableType<QGeoMapPinchEvent >(uri, versionMajor: major, versionMinor: minor, qmlName: "MapPinchEvent",
118 QStringLiteral("(Map)PinchEvent is not intended instantiable by developer."));
119 qmlRegisterUncreatableType<QQuickGeoMapGestureArea>(uri, versionMajor: major, versionMinor: minor, qmlName: "MapGestureArea",
120 QStringLiteral("(Map)GestureArea is not intended instantiable by developer."));
121 qmlRegisterUncreatableType<QDeclarativeGeoMapType >(uri, versionMajor: major, versionMinor: minor, qmlName: "MapType",
122 QStringLiteral("MapType is not intended instantiable by developer."));
123 qmlRegisterType<QDeclarativeCategory >(uri, versionMajor: major, versionMinor: minor, qmlName: "Category");
124 qmlRegisterType<QDeclarativePlaceEditorialModel >(uri, versionMajor: major, versionMinor: minor, qmlName: "EditorialModel");
125 qmlRegisterType<QDeclarativePlaceImageModel >(uri, versionMajor: major, versionMinor: minor, qmlName: "ImageModel");
126 qmlRegisterType<QDeclarativePlace >(uri, versionMajor: major, versionMinor: minor, qmlName: "Place");
127 qmlRegisterType<QDeclarativePlaceIcon >(uri, versionMajor: major, versionMinor: minor, qmlName: "Icon");
128 qmlRegisterType<QDeclarativeRatings >(uri, versionMajor: major, versionMinor: minor, qmlName: "Ratings");
129 qmlRegisterType<QDeclarativeReviewModel >(uri, versionMajor: major, versionMinor: minor, qmlName: "ReviewModel");
130 qmlRegisterType<QDeclarativeSupplier >(uri, versionMajor: major, versionMinor: minor, qmlName: "Supplier");
131 qmlRegisterType<QDeclarativePlaceUser >(uri, versionMajor: major, versionMinor: minor, qmlName: "User");
132 qmlRegisterType<QDeclarativeRectangleMapItem >(uri, versionMajor: major, versionMinor: minor, qmlName: "MapRectangle");
133 qmlRegisterType<QDeclarativeCircleMapItem >(uri, versionMajor: major, versionMinor: minor, qmlName: "MapCircle");
134 qmlRegisterAnonymousType<QDeclarativeMapLineProperties >(uri, versionMajor: major);
135 qmlRegisterType<QDeclarativePolylineMapItem >(uri, versionMajor: major, versionMinor: minor, qmlName: "MapPolyline");
136 qmlRegisterType<QDeclarativePolygonMapItem >(uri, versionMajor: major, versionMinor: minor, qmlName: "MapPolygon");
137 qmlRegisterType<QDeclarativeRouteMapItem >(uri, versionMajor: major, versionMinor: minor, qmlName: "MapRoute");
138
139 qmlRegisterType<QDeclarativeSupportedCategoriesModel >(uri, versionMajor: major, versionMinor: minor, qmlName: "CategoryModel");
140 qmlRegisterType<QDeclarativeSearchResultModel >(uri, versionMajor: major, versionMinor: minor, qmlName: "PlaceSearchModel");
141 qmlRegisterType<QDeclarativeSearchSuggestionModel >(uri, versionMajor: major, versionMinor: minor, qmlName: "PlaceSearchSuggestionModel");
142 qmlRegisterType<QDeclarativePlaceAttribute >(uri, versionMajor: major, versionMinor: minor, qmlName: "PlaceAttribute");
143 qmlRegisterUncreatableType<QQmlPropertyMap >(uri, versionMajor: major, versionMinor: minor, qmlName: "ExtendedAttributes", reason: "ExtendedAttributes instances cannot be instantiated. "
144 "Only Place types have ExtendedAttributes and they cannot be re-assigned "
145 "(but can be modified).");
146 qmlRegisterType<QDeclarativeContactDetail >(uri, versionMajor: major, versionMinor: minor, qmlName: "ContactDetail");
147 qmlRegisterUncreatableType<QDeclarativeContactDetails >(uri, versionMajor: major, versionMinor: minor, qmlName: "ContactDetails", reason: "ContactDetails instances cannot be instantiated. "
148 "Only Place types have ContactDetails and they cannot "
149 "be re-assigned (but can be modified).");
150
151 // Introduction of 5.3 version; existing 5.0 exports automatically become available under 5.3 as well
152 // 5.3 is committed QML API despite missing release of QtLocation 5.3
153
154 minor = 5;
155 //TODO: this is broken QTBUG-50990
156 qmlRegisterUncreatableType<QDeclarativeGeoMapType, 1>(uri, versionMajor: major, versionMinor: minor, qmlName: "MapType",
157 QStringLiteral("MapType is not intended instantiable by developer."));
158 minor = 6;
159 //TODO: this is broken QTBUG-50990
160 qmlRegisterUncreatableType<QQuickGeoMapGestureArea, 1>(uri, versionMajor: major, versionMinor: minor, qmlName: "MapGestureArea",
161 QStringLiteral("(Map)GestureArea is not intended instantiable by developer."));
162
163 // Register the 5.8 types
164 minor = 8;
165 qmlRegisterType<QDeclarativeGeoManeuver>(uri, versionMajor: major, versionMinor: minor, qmlName: "RouteManeuver");
166
167 // Register the 5.9 types
168 minor = 9;
169 qmlRegisterType<QDeclarativeGeoMapParameter>(uri, versionMajor: major, versionMinor: minor, qmlName: "MapParameter");
170 qmlRegisterType<QDeclarativeGeoMapCopyrightNotice>(uri, versionMajor: major, versionMinor: minor, qmlName: "MapCopyrightNotice");
171 qmlRegisterType<QDeclarativeGeoMapItemGroup>(uri, versionMajor: major, versionMinor: minor, qmlName: "MapItemGroup");
172
173 // Register the 5.10 types
174 minor = 10;
175 qmlRegisterUncreatableType<QDeclarativeGeoCameraCapabilities>(uri, versionMajor: major, versionMinor: minor, qmlName: "CameraCapabilities"
176 , QStringLiteral("CameraCapabilities is not intended instantiable by developer."));
177
178 // Register the 5.11 types
179 minor = 11;
180 qmlRegisterAnonymousType<QGeoMapObject>(uri, versionMajor: major);
181 qmlRegisterType<QDeclarativeGeoManeuver, 11>(uri, versionMajor: major, versionMinor: minor, qmlName: "RouteManeuver");
182 qmlRegisterType<QDeclarativeGeoMap, 11>(uri, versionMajor: major, versionMinor: minor, qmlName: "Map");
183 qmlRegisterUncreatableType<QDeclarativeGeoMapItemBase, 11>(uri, versionMajor: major, versionMinor: minor, qmlName: "GeoMapItemBase",
184 QStringLiteral("GeoMapItemBase is not intended instantiable by developer."));
185 qmlRegisterType<QDeclarativeGeoMapParameter>(uri, versionMajor: major, versionMinor: minor, qmlName: "DynamicParameter");
186 qmlRegisterType<QDeclarativeGeoRoute, 11>(uri, versionMajor: major, versionMinor: minor, qmlName: "Route");
187 qmlRegisterType<QDeclarativeGeoRouteQuery, 11>(uri, versionMajor: major, versionMinor: minor, qmlName: "RouteQuery");
188 qmlRegisterType<QDeclarativeGeoServiceProvider, 11>(uri, versionMajor: major, versionMinor: minor, qmlName: "Plugin");
189 qmlRegisterType<QDeclarativeGeoWaypoint>(uri, versionMajor: major, versionMinor: minor, qmlName: "Waypoint");
190
191 // Register the 5.12 types
192 minor = 12;
193 qmlRegisterType<QDeclarativeGeoMapItemView, 12>(uri, versionMajor: major, versionMinor: minor, qmlName: "MapItemView");
194 qmlRegisterType<QDeclarativeSearchResultModel, 12>(uri, versionMajor: major, versionMinor: minor, qmlName: "PlaceSearchModel");
195 qmlRegisterType<QDeclarativeGeoMap, 12>(uri, versionMajor: major, versionMinor: minor, qmlName: "Map");
196 qmlRegisterType<QDeclarativeGeoRoute, 12>(uri, versionMajor: major, versionMinor: minor, qmlName: "Route");
197 qmlRegisterType<QDeclarativeGeoRouteLeg, 12>(uri, versionMajor: major, versionMinor: minor, qmlName: "RouteLeg");
198
199 minor = 13;
200 qmlRegisterType<QDeclarativeGeoMap, 13>(uri, versionMajor: major, versionMinor: minor, qmlName: "Map");
201 qmlRegisterType<QDeclarativeGeoRoute, 13>(uri, versionMajor: major, versionMinor: minor, qmlName: "Route");
202 qmlRegisterType<QDeclarativeGeoRouteQuery, 13>(uri, versionMajor: major, versionMinor: minor, qmlName: "RouteQuery");
203
204 minor = 14;
205 qmlRegisterType<QDeclarativeGeoMap, 14>(uri, versionMajor: major, versionMinor: minor, qmlName: "Map");
206 qmlRegisterUncreatableType<QDeclarativeGeoMapItemBase, 14>(uri, versionMajor: major, versionMinor: minor, qmlName: "GeoMapItemBase",
207 QStringLiteral("GeoMapItemBase is not intended instantiable by developer."));
208
209 minor = 15;
210 qmlRegisterType<QDeclarativePolylineMapItem, 15>(uri, versionMajor: major, versionMinor: minor, qmlName: "MapPolyline");
211 qmlRegisterType<QDeclarativePolygonMapItem, 15>(uri, versionMajor: major, versionMinor: minor, qmlName: "MapPolygon");
212 qmlRegisterType<QDeclarativeRectangleMapItem, 15>(uri, versionMajor: major, versionMinor: minor, qmlName: "MapRectangle");
213 qmlRegisterType<QDeclarativeCircleMapItem, 15>(uri, versionMajor: major, versionMinor: minor, qmlName: "MapCircle");
214 qmlRegisterUncreatableType<QDeclarativeGeoMapItemBase, 15>(uri, versionMajor: major, versionMinor: minor, qmlName: "GeoMapItemBase",
215 QStringLiteral("GeoMapItemBase is not intended instantiable by developer."));
216
217 // Register the latest Qt version as QML type version
218 qmlRegisterModule(uri, QT_VERSION_MAJOR, QT_VERSION_MINOR);
219
220 //registrations below are version independent
221 qRegisterMetaType<QPlaceCategory>();
222 qRegisterMetaType<QPlace>();
223 qRegisterMetaType<QPlaceIcon>();
224 qRegisterMetaType<QPlaceRatings>();
225 qRegisterMetaType<QPlaceSupplier>();
226 qRegisterMetaType<QPlaceUser>();
227 qRegisterMetaType<QPlaceAttribute>();
228 qRegisterMetaType<QPlaceContactDetail>();
229 } else {
230 qDebug() << "Unsupported URI given to load location QML plugin: " << QLatin1String(uri);
231 }
232 }
233};
234
235QT_END_NAMESPACE
236
237#include "location.moc"
238

source code of qtlocation/src/imports/location/location.cpp