31 QgsLayerSettings settings;
32 settings.name = layer->name();
34 settings.mNamedStyle = layer->styleManager()->currentStyle();
36 switch ( layer->type() )
44 settings.mOpacity = vLayer->
opacity();
70 mLayerSettings[layer] = settings;
79 const QString sldStyleName { layer->customProperty(
"sldStyleName",
"" ).toString() };
80 if ( !sldStyleName.isEmpty() )
82 layer->styleManager()->removeStyle( sldStyleName );
83 layer->removeCustomProperty(
"sldStyleName" );
87 const QgsLayerSettings settings = mLayerSettings[layer];
88 layer->styleManager()->setCurrentStyle( settings.mNamedStyle );
89 layer->setName( mLayerSettings[layer].name );
91 switch ( layer->type() )
100 vLayer->
selectByIds( settings.mSelectedFeatureIds );
130 : mLayerRestorer( context.layers() )
~QgsLayerRestorer()
Destructor.
QgsLayerRestorer(const QList< QgsMapLayer * > &layers)
Constructor for QgsLayerRestorer.
Base class for all map layer types.
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
Represents a raster layer.
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
double opacity() const
Returns the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
void setOpacity(double opacity)
Sets the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
Q_INVOKABLE void selectByIds(const QgsFeatureIds &ids, Qgis::SelectBehavior behavior=Qgis::SelectBehavior::SetSelection)
Selects matching features using a list of feature IDs.
virtual bool setSubsetString(const QString &subset)
Sets the string (typically sql) used to define a subset of the layer.
Rendering context for the WMS renderer.
QgsWmsRestorer(const QgsWmsRenderContext &context)
Constructor for QgsWmsRestorer.
@ PointCloudLayer
Point cloud layer. Added in QGIS 3.18.
@ MeshLayer
Mesh layer. Added in QGIS 3.2.
@ VectorLayer
Vector layer.
@ RasterLayer
Raster layer.
@ GroupLayer
Composite group layer. Added in QGIS 3.24.
@ VectorTileLayer
Vector tile layer. Added in QGIS 3.14.
@ AnnotationLayer
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
@ PluginLayer
Plugin based layer.
Median cut implementation.