QGIS API Documentation 4.1.0-Master (467af3bbe65)
Loading...
Searching...
No Matches
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 "qgsiconutils.h"
18
19#include "moc_qgspluginlayer.cpp"
20
21QgsPluginLayer::QgsPluginLayer( const QString &layerType, const QString &layerName )
22 : QgsMapLayer( Qgis::LayerType::Plugin, layerName )
23 , mPluginLayerType( layerType )
24{
25 mDataProvider = new QgsPluginLayerDataProvider( layerType, QgsDataProvider::ProviderOptions(), Qgis::DataProviderReadFlags() );
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{
44 static_cast<QgsPluginLayerDataProvider *>( mDataProvider )->setExtent( extent );
45}
46
47void QgsPluginLayer::setSource( const QString &source )
48{
50}
51
56
61
66
67//
68// QgsPluginLayerDataProvider
69//
71QgsPluginLayerDataProvider::QgsPluginLayerDataProvider( const QString &layerType, const ProviderOptions &options, Qgis::DataProviderReadFlags flags )
72 : QgsDataProvider( QString(), options, flags )
73 , mName( layerType )
74{}
75
76QgsCoordinateReferenceSystem QgsPluginLayerDataProvider::crs() const
77{
79}
80
81QString QgsPluginLayerDataProvider::name() const
82{
83 return mName;
84}
85
86QString QgsPluginLayerDataProvider::description() const
87{
88 return QString();
89}
90
91QgsRectangle QgsPluginLayerDataProvider::extent() const
92{
93 return mExtent;
94}
95
96bool QgsPluginLayerDataProvider::isValid() const
97{
98 return true;
99}
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:512
@ Plugin
Plugin based layer.
Definition qgis.h:209
Represents a coordinate reference system (CRS).
Abstract base class for spatial data provider implementations.
static QIcon iconForLayerType(Qgis::LayerType type)
Returns the default icon for the specified layer type.
virtual Q_INVOKABLE QgsRectangle extent() const
Returns the extent of the layer.
QString source() const
Returns the source for the layer.
QgsMapLayer(Qgis::LayerType type=Qgis::LayerType::Vector, const QString &name=QString(), const QString &source=QString())
Constructor for QgsMapLayer.
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
virtual void setExtent(const QgsRectangle &rect)
Sets the extent.
QString mDataSource
Data source description string, varies by layer type.
QgsPluginLayer(const QString &layerType, const QString &layerName=QString())
void setSource(const QString &source)
Set source string.
~QgsPluginLayer() override
QString mPluginLayerType
QString pluginLayerType() const
Returns plugin layer type (the same as used in QgsPluginLayerRegistry).
QgsDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
virtual QIcon icon() const
Returns an icon for the layer.
void setExtent(const QgsRectangle &extent) override
Sets extent of the layer.
QgsDataProvider * mDataProvider
A rectangle specified with double values.
Setting options for creating vector data providers.