QGIS API Documentation  3.2.0-Bonn (bc43194)
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"
30 #include "qgsvectorlayer.h"
31 
32 #include "qgsquickmapcanvasmap.h"
33 #include "qgsquickmapsettings.h"
35 #include "qgsquickplugin.h"
36 #include "qgsquickscalebarkit.h"
37 #include "qgsquickutils.h"
38 
39 static QObject *_utilsProvider( QQmlEngine *engine, QJSEngine *scriptEngine )
40 {
41  Q_UNUSED( engine )
42  Q_UNUSED( scriptEngine )
43  return new QgsQuickUtils(); // the object will be owned by QML engine and destroyed by the engine on exit
44 }
45 
46 void QgsQuickPlugin::registerTypes( const char *uri )
47 {
48  qRegisterMetaType< QList<QgsMapLayer *> >( "QList<QgsMapLayer*>" );
49  qRegisterMetaType< QgsAttributes > ( "QgsAttributes" );
50  qRegisterMetaType< QgsCoordinateReferenceSystem >( "QgsCoordinateReferenceSystem" );
51  qRegisterMetaType< QgsCoordinateTransformContext >( "QgsCoordinateTransformContext" );
52  qRegisterMetaType< QgsFeature > ( "QgsFeature" );
53  qRegisterMetaType< QgsFeatureId > ( "QgsFeatureId" );
54  qRegisterMetaType< QgsPoint >( "QgsPoint" );
55  qRegisterMetaType< QgsPointXY >( "QgsPointXY" );
56 
57  qmlRegisterType< QgsProject >( uri, 0, 1, "Project" );
58  qmlRegisterType< QgsQuickMapCanvasMap >( uri, 0, 1, "MapCanvasMap" );
59  qmlRegisterType< QgsQuickMapSettings >( uri, 0, 1, "MapSettings" );
60  qmlRegisterType< QgsQuickMessageLogModel >( uri, 0, 1, "MessageLogModel" );
61  qmlRegisterType< QgsQuickScaleBarKit >( uri, 0, 1, "ScaleBarKit" );
62  qmlRegisterType< QgsVectorLayer >( uri, 0, 1, "VectorLayer" );
63 
64  qmlRegisterSingletonType< QgsQuickUtils >( uri, 0, 1, "Utils", _utilsProvider );
65 }
66 
Encapsulating the common utilies for QgsQuick library.
Definition: qgsquickutils.h:40
void registerTypes(const char *uri)
Registers the QGIS QML types in the given uri.