Skip to content
Permalink
Browse files

More use of QgsLayerStyleOverride

  • Loading branch information
nirvn committed Jun 11, 2018
1 parent d62c34a commit b7502b82d405a2a4621b4ec89166d905d1d2bde6
Showing with 8 additions and 20 deletions.
  1. +3 −11 src/core/dxf/qgsdxfexport.cpp
  2. +3 −6 src/core/layertree/qgslayertreemodel.cpp
  3. +2 −3 src/core/qgsmapthemecollection.cpp
@@ -979,11 +979,11 @@ void QgsDxfExport::writeEntities()
continue;
}

bool hasStyleOverride = mMapSettings.layerStyleOverrides().contains( vl->id() );
if ( hasStyleOverride )
QgsLayerStyleOverride styleOverride( vl );
if ( mMapSettings.layerStyleOverrides().contains( vl->id() ) )
{
QgsDebugMsg( QString( "%1: apply override style" ).arg( vl->id() ) );
vl->styleManager()->setOverrideStyle( mMapSettings.layerStyleOverrides().value( vl->id() ) );
styleOverride.setOverrideStyle( mMapSettings.layerStyleOverrides().value( vl->id() ) );
}
else
{
@@ -993,8 +993,6 @@ void QgsDxfExport::writeEntities()
QgsSymbolRenderContext sctx( ctx, QgsUnitTypes::RenderMillimeters, 1.0, false, nullptr, nullptr );
if ( !vl->renderer() )
{
if ( hasStyleOverride )
vl->styleManager()->restoreOverrideStyle();
continue;
}

@@ -1044,9 +1042,6 @@ void QgsDxfExport::writeEntities()
writeEntitiesSymbolLevels( vl );
renderer->stopRender( ctx );

if ( hasStyleOverride )
vl->styleManager()->restoreOverrideStyle();

continue;
}

@@ -1108,9 +1103,6 @@ void QgsDxfExport::writeEntities()
}

renderer->stopRender( ctx );

if ( hasStyleOverride )
vl->styleManager()->restoreOverrideStyle();
}

engine.run( ctx );
@@ -1188,9 +1188,9 @@ void QgsLayerTreeModel::addLegendToLayer( QgsLayerTreeLayer *nodeL )
if ( !layerLegend )
return;

bool hasStyleOverride = mLayerStyleOverrides.contains( ml->id() );
if ( hasStyleOverride )
ml->styleManager()->setOverrideStyle( mLayerStyleOverrides.value( ml->id() ) );
QgsLayerStyleOverride styleOverride( ml );
if ( mLayerStyleOverrides.contains( ml->id() ) )
styleOverride.setOverrideStyle( mLayerStyleOverrides.value( ml->id() ) );

QList<QgsLayerTreeModelLegendNode *> lstNew = layerLegend->createLayerTreeModelLegendNodes( nodeL );

@@ -1250,9 +1250,6 @@ void QgsLayerTreeModel::addLegendToLayer( QgsLayerTreeLayer *nodeL )

if ( !filteredLstNew.isEmpty() ) endInsertRows();

if ( hasStyleOverride )
ml->styleManager()->restoreOverrideStyle();

// invalidate map based data even if the data is not map-based to make sure
// the symbol sizes are computed at least once
legendInvalidateMapBasedData();
@@ -365,7 +365,8 @@ QMap<QString, QString> QgsMapThemeCollection::mapThemeStyleOverrides( const QStr
if ( layerRec.usingCurrentStyle )
{
QgsMapLayer *layer = layerRec.layer();
layer->styleManager()->setOverrideStyle( layerRec.currentStyle );
QgsLayerStyleOverride styleOverride( layer );
styleOverride.setOverrideStyle( layerRec.currentStyle );

// set the checked legend nodes
applyMapThemeCheckedLegendNodesToLayer( layerRec, layer );
@@ -374,8 +375,6 @@ QMap<QString, QString> QgsMapThemeCollection::mapThemeStyleOverrides( const QStr
QgsMapLayerStyle layerStyle;
layerStyle.readFromLayer( layer );
styleOverrides[layer->id()] = layerStyle.xmlData();

layer->styleManager()->restoreOverrideStyle();
}
}
return styleOverrides;

0 comments on commit b7502b8

Please sign in to comment.
You can’t perform that action at this time.