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 77 QT_BEGIN_NAMESPACE 78 79 80 class QtLocationDeclarativeModule: public QQmlExtensionPlugin 81 { 82 Q_OBJECT 83 84 Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid 85 FILE "plugin.json") 86 87 public: QtLocationDeclarativeModule(QObject * parent=0)88 QtLocationDeclarativeModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { } registerTypes(const char * uri)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, major, minor, "Plugin"); 101 qmlRegisterType<QDeclarativePluginParameter >(uri, major, minor, "PluginParameter"); 102 qmlRegisterUncreatableType<QDeclarativeGeoServiceProviderRequirements>(uri, major, minor, "PluginRequirements", 103 QStringLiteral("PluginRequirements is not intended instantiable by developer.")); 104 qmlRegisterType<QDeclarativeGeoMap >(uri, major, minor, "Map"); 105 106 qmlRegisterUncreatableType<QDeclarativeGeoMapItemBase >(uri, major, minor, "GeoMapItemBase", 107 QStringLiteral("GeoMapItemBase is not intended instantiable by developer.")); 108 qmlRegisterType<QDeclarativeGeoMapQuickItem >(uri, major, minor, "MapQuickItem"); 109 qmlRegisterType<QDeclarativeGeoMapItemView >(uri, major, minor, "MapItemView"); 110 111 qmlRegisterType<QDeclarativeGeocodeModel >(uri, major, minor, "GeocodeModel"); // geocoding and reverse geocoding 112 qmlRegisterType<QDeclarativeGeoRouteModel >(uri, major, minor, "RouteModel"); 113 qmlRegisterType<QDeclarativeGeoRouteQuery >(uri, major, minor, "RouteQuery"); 114 qmlRegisterType<QDeclarativeGeoRoute >(uri, major, minor, "Route"); // data type 115 qmlRegisterType<QDeclarativeGeoRouteSegment >(uri, major, minor, "RouteSegment"); 116 qmlRegisterType<QDeclarativeGeoManeuver >(uri, major, minor, "RouteManeuver"); 117 qmlRegisterUncreatableType<QGeoMapPinchEvent >(uri, major, minor, "MapPinchEvent", 118 QStringLiteral("(Map)PinchEvent is not intended instantiable by developer.")); 119 qmlRegisterUncreatableType<QQuickGeoMapGestureArea>(uri, major, minor, "MapGestureArea", 120 QStringLiteral("(Map)GestureArea is not intended instantiable by developer.")); 121 qmlRegisterUncreatableType<QDeclarativeGeoMapType >(uri, major, minor, "MapType", 122 QStringLiteral("MapType is not intended instantiable by developer.")); 123 qmlRegisterType<QDeclarativeCategory >(uri, major, minor, "Category"); 124 qmlRegisterType<QDeclarativePlaceEditorialModel >(uri, major, minor, "EditorialModel"); 125 qmlRegisterType<QDeclarativePlaceImageModel >(uri, major, minor, "ImageModel"); 126 qmlRegisterType<QDeclarativePlace >(uri, major, minor, "Place"); 127 qmlRegisterType<QDeclarativePlaceIcon >(uri, major, minor, "Icon"); 128 qmlRegisterType<QDeclarativeRatings >(uri, major, minor, "Ratings"); 129 qmlRegisterType<QDeclarativeReviewModel >(uri, major, minor, "ReviewModel"); 130 qmlRegisterType<QDeclarativeSupplier >(uri, major, minor, "Supplier"); 131 qmlRegisterType<QDeclarativePlaceUser >(uri, major, minor, "User"); 132 qmlRegisterType<QDeclarativeRectangleMapItem >(uri, major, minor, "MapRectangle"); 133 qmlRegisterType<QDeclarativeCircleMapItem >(uri, major, minor, "MapCircle"); 134 qmlRegisterAnonymousType<QDeclarativeMapLineProperties >(uri, major); 135 qmlRegisterType<QDeclarativePolylineMapItem >(uri, major, minor, "MapPolyline"); 136 qmlRegisterType<QDeclarativePolygonMapItem >(uri, major, minor, "MapPolygon"); 137 qmlRegisterType<QDeclarativeRouteMapItem >(uri, major, minor, "MapRoute"); 138 139 qmlRegisterType<QDeclarativeSupportedCategoriesModel >(uri, major, minor, "CategoryModel"); 140 qmlRegisterType<QDeclarativeSearchResultModel >(uri, major, minor, "PlaceSearchModel"); 141 qmlRegisterType<QDeclarativeSearchSuggestionModel >(uri, major, minor, "PlaceSearchSuggestionModel"); 142 qmlRegisterType<QDeclarativePlaceAttribute >(uri, major, minor, "PlaceAttribute"); 143 qmlRegisterUncreatableType<QQmlPropertyMap >(uri, major, minor, "ExtendedAttributes", "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, major, minor, "ContactDetail"); 147 qmlRegisterUncreatableType<QDeclarativeContactDetails >(uri, major, minor, "ContactDetails", "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, major, minor, "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, major, minor, "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, major, minor, "RouteManeuver"); 166 167 // Register the 5.9 types 168 minor = 9; 169 qmlRegisterType<QDeclarativeGeoMapParameter>(uri, major, minor, "MapParameter"); 170 qmlRegisterType<QDeclarativeGeoMapCopyrightNotice>(uri, major, minor, "MapCopyrightNotice"); 171 qmlRegisterType<QDeclarativeGeoMapItemGroup>(uri, major, minor, "MapItemGroup"); 172 173 // Register the 5.10 types 174 minor = 10; 175 qmlRegisterUncreatableType<QDeclarativeGeoCameraCapabilities>(uri, major, minor, "CameraCapabilities" 176 , QStringLiteral("CameraCapabilities is not intended instantiable by developer.")); 177 178 // Register the 5.11 types 179 minor = 11; 180 qmlRegisterAnonymousType<QGeoMapObject>(uri, major); 181 qmlRegisterType<QDeclarativeGeoManeuver, 11>(uri, major, minor, "RouteManeuver"); 182 qmlRegisterType<QDeclarativeGeoMap, 11>(uri, major, minor, "Map"); 183 qmlRegisterUncreatableType<QDeclarativeGeoMapItemBase, 11>(uri, major, minor, "GeoMapItemBase", 184 QStringLiteral("GeoMapItemBase is not intended instantiable by developer.")); 185 qmlRegisterType<QDeclarativeGeoMapParameter>(uri, major, minor, "DynamicParameter"); 186 qmlRegisterType<QDeclarativeGeoRoute, 11>(uri, major, minor, "Route"); 187 qmlRegisterType<QDeclarativeGeoRouteQuery, 11>(uri, major, minor, "RouteQuery"); 188 qmlRegisterType<QDeclarativeGeoServiceProvider, 11>(uri, major, minor, "Plugin"); 189 qmlRegisterType<QDeclarativeGeoWaypoint>(uri, major, minor, "Waypoint"); 190 191 // Register the 5.12 types 192 minor = 12; 193 qmlRegisterType<QDeclarativeGeoMapItemView, 12>(uri, major, minor, "MapItemView"); 194 qmlRegisterType<QDeclarativeSearchResultModel, 12>(uri, major, minor, "PlaceSearchModel"); 195 qmlRegisterType<QDeclarativeGeoMap, 12>(uri, major, minor, "Map"); 196 qmlRegisterType<QDeclarativeGeoRoute, 12>(uri, major, minor, "Route"); 197 qmlRegisterType<QDeclarativeGeoRouteLeg, 12>(uri, major, minor, "RouteLeg"); 198 199 minor = 13; 200 qmlRegisterType<QDeclarativeGeoMap, 13>(uri, major, minor, "Map"); 201 qmlRegisterType<QDeclarativeGeoRoute, 13>(uri, major, minor, "Route"); 202 qmlRegisterType<QDeclarativeGeoRouteQuery, 13>(uri, major, minor, "RouteQuery"); 203 204 minor = 14; 205 qmlRegisterType<QDeclarativeGeoMap, 14>(uri, major, minor, "Map"); 206 qmlRegisterUncreatableType<QDeclarativeGeoMapItemBase, 14>(uri, major, minor, "GeoMapItemBase", 207 QStringLiteral("GeoMapItemBase is not intended instantiable by developer.")); 208 209 minor = 15; 210 qmlRegisterType<QDeclarativePolylineMapItem, 15>(uri, major, minor, "MapPolyline"); 211 qmlRegisterType<QDeclarativePolygonMapItem, 15>(uri, major, minor, "MapPolygon"); 212 qmlRegisterType<QDeclarativeRectangleMapItem, 15>(uri, major, minor, "MapRectangle"); 213 qmlRegisterType<QDeclarativeCircleMapItem, 15>(uri, major, minor, "MapCircle"); 214 qmlRegisterUncreatableType<QDeclarativeGeoMapItemBase, 15>(uri, major, minor, "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 235 QT_END_NAMESPACE 236 237 #include "location.moc" 238