31 mLayerSettings.emplace( layer, QgsLayerSettings() );
32 QgsLayerSettings &settings = mLayerSettings[layer];
34 settings.name = layer->name();
35 settings.mNamedStyle = layer->styleManager()->currentStyle();
37 switch ( layer->type() )
45 settings.mOpacity = vLayer->
opacity();
81 for (
auto it = mLayerSettings.begin(); it != mLayerSettings.end(); it++ )
86 const QString sldStyleName { layer->
customProperty(
"sldStyleName",
"" ).toString() };
87 if ( !sldStyleName.isEmpty() )
94 QgsLayerSettings &settings = it->second;
96 layer->
setName( settings.name );
98 switch ( layer->
type() )
107 vLayer->
selectByIds( settings.mSelectedFeatureIds );
109 if ( settings.mLabeling )
111 vLayer->
setLabeling( settings.mLabeling.release() );
142 : mLayerRestorer( context.layers() )
@ Group
Composite group layer. Added in QGIS 3.24.
@ Plugin
Plugin based layer.
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
@ Annotation
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
@ Mesh
Mesh layer. Added in QGIS 3.2.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
virtual QgsAbstractVectorLayerLabeling * clone() const =0
Returns a new copy of the object.
~QgsLayerRestorer()
Destructor.
QgsLayerRestorer(const QList< QgsMapLayer * > &layers)
Constructor for QgsLayerRestorer.
bool removeStyle(const QString &name)
Remove a stored style.
bool setCurrentStyle(const QString &name)
Set a different style as the current style - will apply it to the layer.
Base class for all map layer types.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
void removeCustomProperty(const QString &key)
Remove a custom property from layer.
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
void setName(const QString &name)
Set the display name of the layer.
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
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.
void setLabeling(QgsAbstractVectorLayerLabeling *labeling)
Sets labeling configuration.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
Q_INVOKABLE const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
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.
Median cut implementation.