31 QgsLayerSettings settings;
32 settings.name = layer->name();
34 settings.mNamedStyle = layer->styleManager()->currentStyle();
36 switch ( layer->type() )
38 case Qgis::LayerType::Vector:
44 settings.mOpacity = vLayer->
opacity();
50 case Qgis::LayerType::Raster:
61 case Qgis::LayerType::Mesh:
62 case Qgis::LayerType::VectorTile:
63 case Qgis::LayerType::Plugin:
64 case Qgis::LayerType::Annotation:
65 case Qgis::LayerType::PointCloud:
66 case Qgis::LayerType::Group:
70 mLayerSettings[layer] = settings;
76 for (
auto it = mLayerSettings.constBegin(); it != mLayerSettings.constEnd(); it++ )
81 const QString sldStyleName { layer->
customProperty(
"sldStyleName",
"" ).toString() };
82 if ( !sldStyleName.isEmpty() )
89 const QgsLayerSettings settings = it.value();
91 layer->
setName( it.value().name );
93 switch ( layer->
type() )
95 case Qgis::LayerType::Vector:
102 vLayer->
selectByIds( settings.mSelectedFeatureIds );
107 case Qgis::LayerType::Raster:
118 case Qgis::LayerType::Mesh:
119 case Qgis::LayerType::VectorTile:
120 case Qgis::LayerType::Plugin:
121 case Qgis::LayerType::Annotation:
122 case Qgis::LayerType::PointCloud:
123 case Qgis::LayerType::Group:
132 : mLayerRestorer( context.layers() )
~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.
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.
Median cut implementation.