29 QgsLayerSettings settings;
30 settings.name = layer->name();
32 QString style = layer->styleManager()->currentStyle();
33 settings.mNamedStyle = layer->styleManager()->currentStyle();
37 layer->setCustomProperty(
"readSLD",
false );
41 layer->exportSldStyle( sldDoc, errMsg );
42 ( void )settings.mSldStyle.setContent( sldDoc.toString(), true );
44 switch ( layer->type() )
52 settings.mOpacity = vLayer->
opacity();
58 case QgsMapLayer::LayerType::RasterLayer:
74 mLayerSettings[layer] = settings;
82 QgsLayerSettings settings = mLayerSettings[layer];
83 layer->styleManager()->setCurrentStyle( settings.mNamedStyle );
84 layer->setName( mLayerSettings[layer].name );
88 QDomElement root = settings.mSldStyle.firstChildElement(
"StyledLayerDescriptor" );
89 QDomElement el = root.firstChildElement(
"NamedLayer" );
90 if ( layer->customProperty(
"readSLD",
false ).toBool() )
92 layer->readSld( el, errMsg );
94 layer->removeCustomProperty(
"readSLD" );
96 switch ( layer->type() )
98 case QgsMapLayer::LayerType::VectorLayer:
105 vLayer->
selectByIds( settings.mSelectedFeatureIds );
110 case QgsMapLayer::LayerType::RasterLayer:
Base class for all map layer types.
double opacity() const
Returns the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1...
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
void selectByIds(const QgsFeatureIds &ids, SelectBehavior behavior=SetSelection)
Select matching features using a list of feature IDs.
QgsRasterRenderer * renderer() const
const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
~QgsLayerRestorer()
Destructor.
QgsLayerRestorer(const QList< QgsMapLayer *> &layers)
Constructor for QgsLayerRestorer.
virtual bool setSubsetString(const QString &subset)
Set the string (typically sql) used to define a subset of the layer.
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 setOpacity(double opacity)
Sets the opacity for the vector layer, where opacity is a value between 0 (totally transparent) and 1...