QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgspluginlayer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgspluginlayer.cpp
3  ---------------------
4  begin : January 2010
5  copyright : (C) 2010 by Martin Dobias
6  email : wonder dot sk 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 #include "qgspluginlayer.h"
16 
17 #include "qgsmaplayerlegend.h"
18 #include "qgsmaplayerrenderer.h"
19 
20 
21 QgsPluginLayer::QgsPluginLayer( const QString &layerType, const QString &layerName )
22  : QgsMapLayer( QgsMapLayerType::PluginLayer, layerName )
23  , mPluginLayerType( layerType )
24 {
25  mDataProvider = new QgsPluginLayerDataProvider( layerType, QgsDataProvider::ProviderOptions(), QgsDataProvider::ReadFlags() );
26 }
27 
29 {
30  // TODO: shall we move the responsibility of emitting the signal to plugin
31  // layer implementations before they start doing their part of cleanup...?
32  emit willBeDeleted();
33  delete mDataProvider;
34 }
35 
37 {
38  return mPluginLayerType;
39 }
40 
42 {
43  mExtent = extent;
44  static_cast<QgsPluginLayerDataProvider *>( mDataProvider )->setExtent( extent );
45 }
46 
47 void QgsPluginLayer::setSource( const QString &source )
48 {
50 }
51 
53 {
54  return mDataProvider;
55 }
56 
58 {
59  return mDataProvider;
60 }
61 
62 //
63 // QgsPluginLayerDataProvider
64 //
66 QgsPluginLayerDataProvider::QgsPluginLayerDataProvider( const QString &layerType,
67  const ProviderOptions &options,
68  QgsDataProvider::ReadFlags flags )
69  : QgsDataProvider( QString(), options, flags )
70  , mName( layerType )
71 {}
72 
74 {
76 }
77 
78 QString QgsPluginLayerDataProvider::name() const
79 {
80  return mName;
81 }
82 
83 QString QgsPluginLayerDataProvider::description() const
84 {
85  return QString();
86 }
87 
88 QgsRectangle QgsPluginLayerDataProvider::extent() const
89 {
90  return mExtent;
91 }
92 
93 bool QgsPluginLayerDataProvider::isValid() const
94 {
95  return true;
96 }
QgsMapLayer::willBeDeleted
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
QgsPluginLayer::setSource
void setSource(const QString &source)
Set source string.
Definition: qgspluginlayer.cpp:47
QgsPluginLayer::QgsPluginLayer
QgsPluginLayer(const QString &layerType, const QString &layerName=QString())
Definition: qgspluginlayer.cpp:21
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:105
QgsPluginLayer::mPluginLayerType
QString mPluginLayerType
Definition: qgspluginlayer.h:62
QgsPluginLayer::setExtent
void setExtent(const QgsRectangle &extent) override
Sets extent of the layer.
Definition: qgspluginlayer.cpp:41
QgsDataProvider
Abstract base class for spatial data provider implementations.
Definition: qgsdataprovider.h:42
QgsPluginLayer::dataProvider
QgsDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
Definition: qgspluginlayer.cpp:52
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:51
QgsMapLayerType
QgsMapLayerType
Types of layers that can be added to a map.
Definition: qgsmaplayer.h:68
QgsPluginLayer::~QgsPluginLayer
~QgsPluginLayer() override
Definition: qgspluginlayer.cpp:28
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsMapLayer::mExtent
QgsRectangle mExtent
Extent of the layer.
Definition: qgsmaplayer.h:1532
QgsMapLayer::extent
virtual QgsRectangle extent() const
Returns the extent of the layer.
Definition: qgsmaplayer.cpp:197
qgsmaplayerrenderer.h
QgsMapLayer::mDataSource
QString mDataSource
Data source description string, varies by layer type.
Definition: qgsmaplayer.h:1538
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsMapLayer::source
QString source() const
Returns the source for the layer.
Definition: qgsmaplayer.cpp:192
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
qgsmaplayerlegend.h
qgspluginlayer.h
QgsPluginLayer::pluginLayerType
QString pluginLayerType()
Returns plugin layer type (the same as used in QgsPluginLayerRegistry)
Definition: qgspluginlayer.cpp:36
QgsPluginLayer::mDataProvider
QgsDataProvider * mDataProvider
Definition: qgspluginlayer.h:63