QGIS API Documentation 3.41.0-Master (af5edcb665c)
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#include "moc_qgspluginlayer.cpp"
17#include "qgsiconutils.h"
18
19QgsPluginLayer::QgsPluginLayer( const QString &layerType, const QString &layerName )
20 : QgsMapLayer( Qgis::LayerType::Plugin, layerName )
21 , mPluginLayerType( layerType )
22{
23 mDataProvider = new QgsPluginLayerDataProvider( layerType, QgsDataProvider::ProviderOptions(), Qgis::DataProviderReadFlags() );
24}
25
27{
28 // TODO: shall we move the responsibility of emitting the signal to plugin
29 // layer implementations before they start doing their part of cleanup...?
30 emit willBeDeleted();
31 delete mDataProvider;
32}
33
38
40{
42 static_cast<QgsPluginLayerDataProvider *>( mDataProvider )->setExtent( extent );
43}
44
45void QgsPluginLayer::setSource( const QString &source )
46{
48}
49
54
59
64
65//
66// QgsPluginLayerDataProvider
67//
69QgsPluginLayerDataProvider::QgsPluginLayerDataProvider( const QString &layerType,
70 const ProviderOptions &options,
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}
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:450
@ Plugin
Plugin based layer.
This class 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.
Base class for all map layer types.
Definition qgsmaplayer.h:76
virtual QgsRectangle extent() const
Returns the extent of the layer.
QString source() const
Returns the source for the layer.
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
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.
QString pluginLayerType()
Returns plugin layer type (the same as used in QgsPluginLayerRegistry)
QgsDataProvider * mDataProvider
A rectangle specified with double values.
Setting options for creating vector data providers.