32 mLayerSettings.emplace( layer, QgsLayerSettings() );
33 QgsLayerSettings &settings = mLayerSettings[layer ];
35 settings.name = layer->name();
36 settings.mNamedStyle = layer->styleManager()->currentStyle();
38 switch ( layer->type() )
46 settings.mOpacity = vLayer->
opacity();
83 for (
auto it = mLayerSettings.begin(); it != mLayerSettings.end(); it++ )
88 const QString sldStyleName { layer->
customProperty(
"sldStyleName",
"" ).toString() };
89 if ( !sldStyleName.isEmpty() )
96 QgsLayerSettings &settings = it->second;
98 layer->
setName( settings.name );
100 switch ( layer->
type() )
109 vLayer->
selectByIds( settings.mSelectedFeatureIds );
111 if ( settings.mLabeling )
113 vLayer->
setLabeling( settings.mLabeling.release() );
144 : 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.