Marble

MarbleDeclarativePlugin.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2010 Dennis Nienhüser <[email protected]>
4 //
5 
6 #include "MarbleDeclarativePlugin.h"
7 
8 #include "Coordinate.h"
9 #include "DeclarativeMapThemeManager.h"
10 #include "MarbleDeclarativeObject.h"
11 #include "PositionSource.h"
12 #include "Bookmarks.h"
13 #include "Tracking.h"
14 #include "Routing.h"
15 #include "Navigation.h"
16 #include "RouteRequestModel.h"
17 #include "Settings.h"
18 #include "MapThemeModel.h"
19 #include "NewstuffModel.h"
20 #include "OfflineDataModel.h"
21 #include "Placemark.h"
22 #include "routing/SpeakersModel.h"
23 #include "routing/VoiceNavigationModel.h"
24 #include "routing/RoutingModel.h"
25 #include "AbstractFloatItem.h"
26 #include "RenderPlugin.h"
27 #include "MarblePlacemarkModel.h"
28 #include "SearchBackend.h"
29 #include "MarbleQuickItem.h"
30 #include "GeoItem.h"
31 #include "GeoPolyline.h"
32 
33 #include <QQmlEngine>
34 #include <QQmlContext>
35 
37 {
38  qRegisterMetaType<Marble::MarbleMap*>("MarbleMap*");
39 
40  //@uri org.kde.marble
41  qmlRegisterType<Coordinate>( uri, 0, 20, "Coordinate" );
42  qRegisterMetaType<Coordinate::Notation>();
43 
44  qmlRegisterType<Marble::Placemark>( uri, 0, 20, "Placemark" );
45  qmlRegisterType<Marble::PositionSource>( uri, 0, 20, "PositionSource" );
46  qmlRegisterType<Marble::Bookmarks>( uri, 0, 20, "Bookmarks" );
47  qmlRegisterType<Marble::Tracking>( uri, 0, 20, "Tracking" );
48  qmlRegisterType<Marble::Routing>( uri, 0, 20, "Routing" );
49  qmlRegisterType<Marble::Navigation>( uri, 0, 20, "Navigation" );
50  qmlRegisterType<RouteRequestModel>( uri, 0, 20, "RouteRequestModel" );
51  qmlRegisterType<Settings>( uri, 0, 20, "Settings" );
52 
53  qmlRegisterType<MapThemeManager>( uri, 0, 20, "MapThemeManager" );
54  qmlRegisterType<Marble::SpeakersModel>( uri, 0, 20, "SpeakersModel" );
55  qmlRegisterType<Marble::VoiceNavigationModel>( uri, 0, 20, "VoiceNavigation" );
56  qmlRegisterType<Marble::NewstuffModel>( uri, 0, 20, "NewstuffModel" );
57  qmlRegisterType<OfflineDataModel>( uri, 0, 20, "OfflineDataModel" );
58  qmlRegisterType<MapThemeModel>( uri, 0, 20, "MapThemeModel" );
59 
60  qmlRegisterType<Marble::SearchBackend>(uri, 0, 20, "SearchBackend");
61  qRegisterMetaType<Marble::MarblePlacemarkModel*>("MarblePlacemarkModel*");
62  qmlRegisterType<Marble::MarbleQuickItem>(uri, 0, 20, "MarbleItem");
63  qmlRegisterType<Marble::GeoItem>(uri, 0, 20, "GeoItem");
64  qmlRegisterType<Marble::GeoPolyline>(uri, 0, 20, "GeoPolyline");
65 
66  qmlRegisterUncreatableType<Marble::MarblePlacemarkModel>(uri, 1, 0, "MarblePlacemarkModel",
67  QStringLiteral("MarblePlacemarkModel is not instantiable"));
68  qmlRegisterUncreatableType<Marble::RoutingModel>(uri, 0, 20, "RoutingModel",
69  QStringLiteral("RoutingModel is not instantiable"));
70  qmlRegisterUncreatableType<Marble::RouteRelationModel>(uri, 0, 20, "RouteRelationModel",
71  QStringLiteral("RouteRelationModel is not instantiable"));
72  qmlRegisterUncreatableType<Marble::BookmarksModel>(uri, 0, 20, "BookmarksModel",
73  QStringLiteral("Do not create"));
74  qmlRegisterUncreatableType<Marble::AbstractFloatItem>(uri, 0, 20, "FloatItem",
75  QStringLiteral("Do not create"));
76  qmlRegisterUncreatableType<Marble::RenderPlugin>(uri, 0, 20, "RenderPlugin",
77  QStringLiteral("Do not create"));
78  qmlRegisterUncreatableType<Marble::MarbleMap>(uri, 0, 20, "MarbleMap",
79  QStringLiteral("Do not create"));
80 }
81 
82 void MarbleDeclarativePlugin::initializeEngine( QQmlEngine *engine, const char *)
83 {
84  engine->addImageProvider(QStringLiteral("maptheme"), new MapThemeImageProvider );
85  // Register the global Marble object. Can be used in .qml files for requests like Marble.resolvePath("some/icon.png")
86  const QString marbleObjectName = QStringLiteral("Marble");
87  if (!engine->rootContext()->contextProperty(marbleObjectName).isValid()) {
88  engine->rootContext()->setContextProperty(marbleObjectName, new MarbleDeclarativeObject(this));
89  }
90 }
91 
92 #include "moc_MarbleDeclarativePlugin.cpp"
void registerTypes(const char *uri) override
Overriding QQmlExtensionPlugin to register types.
void setContextProperty(const QString &name, QObject *value)
QQmlContext * rootContext() const const
void addImageProvider(const QString &providerId, QQmlImageProviderBase *provider)
Provides access to global Marble related properties and methods to QML (intended to be registered as ...
bool isValid() const const
QVariant contextProperty(const QString &name) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Nov 29 2021 23:11:03 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.