17
17
#include " qgsmaplayerlegend.h"
18
18
#include " qgsmaplayerrenderer.h"
19
19
20
+
21
+ /* *
22
+ A minimal data provider for plugin layers
23
+ */
24
+ // /@cond PRIVATE
25
+ class QgsPluginLayerDataProvider : public QgsDataProvider
26
+ {
27
+ public:
28
+ QgsPluginLayerDataProvider ( const QString &layerType ) : mName ( layerType ) {}
29
+ void setExtent ( const QgsRectangle &extent ) { mExtent = extent; }
30
+ virtual QgsCoordinateReferenceSystem crs () const { return QgsCoordinateReferenceSystem (); }
31
+ virtual QString name () const override { return mName ; }
32
+ QString description () const override { return " " ; }
33
+ virtual QgsRectangle extent () const { return mExtent ; }
34
+ virtual bool isValid () const { return true ; }
35
+
36
+ private:
37
+ QString mName ;
38
+ QgsRectangle mExtent ;
39
+ };
40
+ // /@endcond
41
+
20
42
QgsPluginLayer::QgsPluginLayer ( const QString &layerType, const QString &layerName )
21
43
: QgsMapLayer( PluginLayer, layerName )
22
44
, mPluginLayerType( layerType )
23
45
{
46
+ mDataProvider = new QgsPluginLayerDataProvider ( layerType );
24
47
}
25
48
26
49
QgsPluginLayer::~QgsPluginLayer ()
27
50
{
28
51
// TODO: shall we move the responsibility of emitting the signal to plugin
29
52
// layer implementations before they start doing their part of cleanup...?
30
53
emit willBeDeleted ();
54
+ delete mDataProvider ;
31
55
}
32
56
33
57
QString QgsPluginLayer::pluginLayerType ()
@@ -38,9 +62,20 @@ QString QgsPluginLayer::pluginLayerType()
38
62
void QgsPluginLayer::setExtent ( const QgsRectangle &extent )
39
63
{
40
64
mExtent = extent;
65
+ static_cast <QgsPluginLayerDataProvider *>( mDataProvider )->setExtent ( extent );
41
66
}
42
67
43
68
void QgsPluginLayer::setSource ( const QString &source )
44
69
{
45
70
mDataSource = source;
46
71
}
72
+
73
+ QgsDataProvider *QgsPluginLayer::dataProvider ()
74
+ {
75
+ return mDataProvider ;
76
+ }
77
+
78
+ const QgsDataProvider *QgsPluginLayer::dataProvider () const
79
+ {
80
+ return mDataProvider ;
81
+ }
0 commit comments