QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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 "qgsquickutils.h"
40
41static QObject *buildUtilsSingleton( QQmlEngine *engine, QJSEngine *scriptEngine )
42{
43 Q_UNUSED( engine )
44 Q_UNUSED( scriptEngine )
45 return new QgsQuickUtils(); // the object will be owned by QML engine and destroyed by the engine on exit
46}
47
48void QgsQuickPlugin::registerTypes( const char *uri )
49{
50 qRegisterMetaType< QList<QgsMapLayer *> >( "QList<QgsMapLayer*>" );
51 qRegisterMetaType< QgsAttributes > ( "QgsAttributes" );
52 qRegisterMetaType< QgsCoordinateReferenceSystem >( "QgsCoordinateReferenceSystem" );
53 qRegisterMetaType< QgsCoordinateTransformContext >( "QgsCoordinateTransformContext" );
54 qRegisterMetaType< QgsFeature > ( "QgsFeature" );
55 qRegisterMetaType< QgsFeatureId > ( "QgsFeatureId" );
56 qRegisterMetaType< QgsPoint >( "QgsPoint" );
57 qRegisterMetaType< QgsPointXY >( "QgsPointXY" );
58 qRegisterMetaType< Qgis::SystemOfMeasurement >( "Qgis::SystemOfMeasurement" );
59 qRegisterMetaType< Qgis::DistanceUnit >( "Qgis::DistanceUnit" );
60 qRegisterMetaType< QgsCoordinateFormatter::FormatFlags >( "QgsCoordinateFormatter::FormatFlags" );
61 qRegisterMetaType< QgsCoordinateFormatter::Format >( "QgsCoordinateFormatter::Format" );
62 qRegisterMetaType< QVariant::Type >( "QVariant::Type" );
63
64 qmlRegisterUncreatableType< QgsUnitTypes >( uri, 0, 1, "QgsUnitTypes", "Only enums from QgsUnitTypes can be used" );
65 qmlRegisterType< QgsProject >( uri, 0, 1, "Project" );
66 qmlRegisterType< QgsQuickMapCanvasMap >( uri, 0, 1, "MapCanvasMap" );
67 qmlRegisterType< QgsQuickMapSettings >( uri, 0, 1, "MapSettings" );
68 qmlRegisterType< QgsQuickMapTransform >( uri, 0, 1, "MapTransform" );
69 qmlRegisterType< QgsQuickElevationProfileCanvas >( uri, 0, 1, "ElevationProfileCanvas" );
70 qmlRegisterType< QgsVectorLayer >( uri, 0, 1, "VectorLayer" );
71
72 qmlRegisterSingletonType< QgsQuickUtils >( uri, 0, 1, "Utils", buildUtilsSingleton );
73
74}
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...