QGIS API Documentation 4.1.0-Master (60fea48833c)
Loading...
Searching...
No Matches
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 "qgsdataprovider.h"
20#include "qgsmaplayer.h"
21
22#include <QString>
23
24using namespace Qt::StringLiterals;
25
37class CORE_EXPORT QgsPluginLayer : public QgsMapLayer
38{
39 Q_OBJECT
40
41 public:
42 QgsPluginLayer( const QString &layerType, const QString &layerName = QString() );
43 ~QgsPluginLayer() override;
44
45#ifdef SIP_RUN
46 // clang-format off
47 SIP_PYOBJECT __repr__();
48 % MethodCode
49 QString str = u"<QgsPluginLayer: '%1'>"_s.arg( sipCpp->name() );
50 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
51 % End
52// clang-format on
53#endif
54
59 QgsPluginLayer *clone() const override
60 = 0;
61
63 QString pluginLayerType() const;
64
66 void setExtent( const QgsRectangle &extent ) override;
67
71 void setSource( const QString &source );
72
73 QgsDataProvider *dataProvider() override;
74 const QgsDataProvider *dataProvider() const override SIP_SKIP;
75
80 virtual QIcon icon() const;
81
82 protected:
85};
86
87#ifndef SIP_RUN
89
93class QgsPluginLayerDataProvider : public QgsDataProvider
94{
95 Q_OBJECT
96
97 public:
98 QgsPluginLayerDataProvider( const QString &layerType, const QgsDataProvider::ProviderOptions &providerOptions, Qgis::DataProviderReadFlags flags );
99 void setExtent( const QgsRectangle &extent ) { mExtent = extent; }
100 QgsCoordinateReferenceSystem crs() const override;
101 QString name() const override;
102 QString description() const override;
103 QgsRectangle extent() const override;
104 bool isValid() const override;
105
106 private:
107 QString mName;
108 QgsRectangle mExtent;
109};
111#endif
112
113#endif // QGSPLUGINLAYER_H
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:512
Represents a coordinate reference system (CRS).
Abstract base class for spatial data provider implementations.
QString name
Definition qgsmaplayer.h:87
virtual QgsRectangle extent() const
Returns the extent of the layer.
QString source() const
Returns the source for the layer.
QgsCoordinateReferenceSystem crs
Definition qgsmaplayer.h:90
QgsMapLayer(Qgis::LayerType type=Qgis::LayerType::Vector, const QString &name=QString(), const QString &source=QString())
Constructor for QgsMapLayer.
QgsMapLayer::LayerFlags flags
Definition qgsmaplayer.h:99
virtual void setExtent(const QgsRectangle &rect)
Sets the extent.
virtual Q_INVOKABLE QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be nullptr.
QgsPluginLayer(const QString &layerType, const QString &layerName=QString())
void setSource(const QString &source)
Set source string.
QString mPluginLayerType
QString pluginLayerType() const
Returns plugin layer type (the same as used in QgsPluginLayerRegistry).
virtual QIcon icon() const
Returns an icon for the layer.
void setExtent(const QgsRectangle &extent) override
Sets extent of the layer.
QgsDataProvider * mDataProvider
QgsPluginLayer * clone() const override=0
Returns a new instance equivalent to this one.
A rectangle specified with double values.
#define SIP_SKIP
Definition qgis_sip.h:133
Setting options for creating vector data providers.