QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgspluginlayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgspluginlayer.h
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 #ifndef QGSPLUGINLAYER_H
16 #define QGSPLUGINLAYER_H
17 
18 #include "qgis_core.h"
19 #include "qgsmaplayer.h"
20 #include "qgsdataprovider.h"
21 
31 class CORE_EXPORT QgsPluginLayer : public QgsMapLayer
32 {
33  Q_OBJECT
34 
35  public:
36  QgsPluginLayer( const QString &layerType, const QString &layerName = QString() );
37  ~QgsPluginLayer() override;
38 
39 #ifdef SIP_RUN
40  SIP_PYOBJECT __repr__();
41  % MethodCode
42  QString str = QStringLiteral( "<QgsPluginLayer: '%1'>" ).arg( sipCpp->name() );
43  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
44  % End
45 #endif
46 
52  QgsPluginLayer *clone() const override = 0;
53 
55  QString pluginLayerType();
56 
58  void setExtent( const QgsRectangle &extent ) override;
59 
64  void setSource( const QString &source );
65 
66  QgsDataProvider *dataProvider() override;
67  const QgsDataProvider *dataProvider() const override SIP_SKIP;
68 
69  protected:
70  QString mPluginLayerType;
71  QgsDataProvider *mDataProvider;
72 };
73 
74 #ifndef SIP_RUN
75 
80 class QgsPluginLayerDataProvider : public QgsDataProvider
81 {
82  Q_OBJECT
83 
84  public:
85  QgsPluginLayerDataProvider( const QString &layerType,
86  const QgsDataProvider::ProviderOptions &providerOptions,
87  QgsDataProvider::ReadFlags flags );
88  void setExtent( const QgsRectangle &extent ) { mExtent = extent; }
89  QgsCoordinateReferenceSystem crs() const override;
90  QString name() const override;
91  QString description() const override;
92  QgsRectangle extent() const override;
93  bool isValid() const override;
94 
95  private:
96  QString mName;
97  QgsRectangle mExtent;
98 };
100 #endif
101 
102 #endif // QGSPLUGINLAYER_H
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:107
QgsDataProvider
Abstract base class for spatial data provider implementations.
Definition: qgsdataprovider.h:40
QgsMapLayer::clone
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsDataProvider::description
virtual QString description() const =0
Returns description.
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsMapLayer::setExtent
virtual void setExtent(const QgsRectangle &rect)
Sets the extent.
Definition: qgsmaplayer.cpp:2151
QgsMapLayer::dataProvider
virtual Q_INVOKABLE QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be nullptr.
Definition: qgsmaplayer.cpp:190
qgsmaplayer.h
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsPluginLayer
Base class for plugin layers. These can be implemented by plugins and registered in QgsPluginLayerReg...
Definition: qgspluginlayer.h:31
str
#define str(x)
Definition: qgis.cpp:37
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
QgsDataProvider::extent
virtual QgsRectangle extent() const =0
Returns the extent of the layer.
qgsdataprovider.h
QgsDataProvider::name
virtual QString name() const =0
Returns a provider name.
QgsDataProvider::isValid
virtual bool isValid() const =0
Returns true if this is a valid layer.
QgsDataProvider::crs
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.