QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgsquickplugin.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsquickplugin.cpp
3 --------------------------------------
4 Date : Nov 2017
5 Copyright : (C) 2017 by Peter Petrik
6 Email : zilolv at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include <qqml.h>
17
18#include <QObject>
19#include <QQmlEngine>
20#include <QJSEngine>
21
22#include "qgsfeature.h"
23#include "qgslogger.h"
24#include "qgsmaplayer.h"
25#include "qgsmessagelog.h"
26#include "qgspointxy.h"
27#include "qgsproject.h"
28#include "qgsrelationmanager.h"
31#include "qgsvectorlayer.h"
32#include "qgsunittypes.h"
33
35#include "qgsquickmapsettings.h"
38#include "qgsquickplugin.h"
39#include "moc_qgsquickplugin.cpp"
40#include "qgsquickutils.h"
41
42static QObject *buildUtilsSingleton( QQmlEngine *engine, QJSEngine *scriptEngine )
43{
44 Q_UNUSED( engine )
45 Q_UNUSED( scriptEngine )
46 return new QgsQuickUtils(); // the object will be owned by QML engine and destroyed by the engine on exit
47}
48
49void QgsQuickPlugin::registerTypes( const char *uri )
50{
51 qRegisterMetaType< QList<QgsMapLayer *> >( "QList<QgsMapLayer*>" );
52 qRegisterMetaType< QgsAttributes > ( "QgsAttributes" );
53 qRegisterMetaType< QgsCoordinateReferenceSystem >( "QgsCoordinateReferenceSystem" );
54 qRegisterMetaType< QgsCoordinateTransformContext >( "QgsCoordinateTransformContext" );
55 qRegisterMetaType< QgsFeature > ( "QgsFeature" );
56 qRegisterMetaType< QgsFeatureId > ( "QgsFeatureId" );
57 qRegisterMetaType< QgsPoint >( "QgsPoint" );
58 qRegisterMetaType< QgsPointXY >( "QgsPointXY" );
59 qRegisterMetaType< Qgis::SystemOfMeasurement >( "Qgis::SystemOfMeasurement" );
60 qRegisterMetaType< Qgis::DistanceUnit >( "Qgis::DistanceUnit" );
61 qRegisterMetaType< QgsCoordinateFormatter::FormatFlags >( "QgsCoordinateFormatter::FormatFlags" );
62 qRegisterMetaType< QgsCoordinateFormatter::Format >( "QgsCoordinateFormatter::Format" );
63 qRegisterMetaType< QVariant::Type >( "QVariant::Type" );
64
65 qmlRegisterUncreatableType< QgsUnitTypes >( uri, 0, 1, "QgsUnitTypes", "Only enums from QgsUnitTypes can be used" );
66 qmlRegisterType< QgsProject >( uri, 0, 1, "Project" );
67 qmlRegisterType< QgsQuickMapCanvasMap >( uri, 0, 1, "MapCanvasMap" );
68 qmlRegisterType< QgsQuickMapSettings >( uri, 0, 1, "MapSettings" );
69 qmlRegisterType< QgsQuickMapTransform >( uri, 0, 1, "MapTransform" );
70 qmlRegisterType< QgsQuickElevationProfileCanvas >( uri, 0, 1, "ElevationProfileCanvas" );
71 qmlRegisterType< QgsVectorLayer >( uri, 0, 1, "VectorLayer" );
72
73 qmlRegisterSingletonType< QgsQuickUtils >( uri, 0, 1, "Utils", buildUtilsSingleton );
74
75}
void registerTypes(const char *uri)
Registers the QGIS QML types in the given uri.
The QgsQuickUtils class serves as a utility class for common operations needed either from QML or cpp...