31 QgsLayerSettings settings;
32 settings.name = layer->name();
34 settings.mNamedStyle = layer->styleManager()->currentStyle();
38 layer->setCustomProperty(
"readSLD",
false );
41 QDomDocument styleDoc( QStringLiteral(
"style" ) );
42 QDomElement styleXml = styleDoc.createElement( QStringLiteral(
"style" ) );
43 styleDoc.appendChild( styleXml );
46 QgsMessageLog::logMessage( QStringLiteral(
"QGIS Style has not been added to layer restorer for layer %1: %2" ).arg( layer->name(), errMsg ) );
48 ( void )settings.mQgisStyle.setContent( styleDoc.toString() );
50 switch ( layer->type() )
58 settings.mOpacity = vLayer->
opacity();
81 mLayerSettings[layer] = settings;
89 QgsLayerSettings settings = mLayerSettings[layer];
90 layer->styleManager()->setCurrentStyle( settings.mNamedStyle );
91 layer->setName( mLayerSettings[layer].name );
94 if ( layer->customProperty(
"readSLD",
false ).toBool() )
97 QDomElement root = settings.mQgisStyle.documentElement();
99 if ( !layer->readStyle( root, errMsg, context ) )
101 QgsMessageLog::logMessage( QStringLiteral(
"QGIS Style has not been read from layer restorer for layer %1: %2" ).arg( layer->name(), errMsg ) );
104 layer->removeCustomProperty(
"readSLD" );
106 switch ( layer->type() )
115 vLayer->
selectByIds( settings.mSelectedFeatureIds );
142 : mLayerRestorer( context.layers() )