Skip to content
Permalink
Browse files

followup 5c267f2: apply @wonder-sk 's comments

  • Loading branch information
nirvn committed Jun 11, 2018
1 parent 03151f8 commit d1fa1508c096254fb77d68667f2c2426861888f3
@@ -224,7 +224,7 @@ Emitted when the current style has been changed
};


class QgsLayerStyleOverride
class QgsMapLayerStyleOverride
{
%Docstring
Restore overridden layer style on destruction.
@@ -237,13 +237,13 @@ Restore overridden layer style on destruction.
%End
public:

QgsLayerStyleOverride( QgsMapLayer *layer );
QgsMapLayerStyleOverride( QgsMapLayer *layer );
%Docstring
Construct a style override object associated with a map layer.
The overridden style will be restored upon object destruction.
%End

~QgsLayerStyleOverride();
~QgsMapLayerStyleOverride();

void setOverrideStyle( const QString &style );
%Docstring
@@ -979,7 +979,7 @@ void QgsDxfExport::writeEntities()
continue;
}

QgsLayerStyleOverride styleOverride( vl );
QgsMapLayerStyleOverride styleOverride( vl );
if ( mMapSettings.layerStyleOverrides().contains( vl->id() ) )
{
QgsDebugMsg( QString( "%1: apply override style" ).arg( vl->id() ) );
@@ -1186,7 +1186,7 @@ void QgsLayerTreeModel::addLegendToLayer( QgsLayerTreeLayer *nodeL )
if ( !layerLegend )
return;

QgsLayerStyleOverride styleOverride( ml );
QgsMapLayerStyleOverride styleOverride( ml );
if ( mLayerStyleOverrides.contains( ml->id() ) )
styleOverride.setOverrideStyle( mLayerStyleOverrides.value( ml->id() ) );

@@ -101,7 +101,7 @@ bool QgsMapHitTest::legendKeyVisible( const QString &ruleKey, QgsVectorLayer *la

void QgsMapHitTest::runHitTestLayer( QgsVectorLayer *vl, SymbolSet &usedSymbols, SymbolSet &usedSymbolsRuleKey, QgsRenderContext &context )
{
QgsLayerStyleOverride styleOverride( vl );
QgsMapLayerStyleOverride styleOverride( vl );
if ( mSettings.layerStyleOverrides().contains( vl->id() ) )
styleOverride.setOverrideStyle( mSettings.layerStyleOverrides().value( vl->id() ) );

@@ -201,20 +201,20 @@ class CORE_EXPORT QgsMapLayerStyleManager : public QObject
*
* \since QGIS 3.2
*/
class CORE_EXPORT QgsLayerStyleOverride
class CORE_EXPORT QgsMapLayerStyleOverride
{
public:

/**
* Construct a style override object associated with a map layer.
* The overridden style will be restored upon object destruction.
*/
QgsLayerStyleOverride( QgsMapLayer *layer )
QgsMapLayerStyleOverride( QgsMapLayer *layer )
: mLayer( layer )
{
}

~QgsLayerStyleOverride()
~QgsMapLayerStyleOverride()
{
if ( mLayer && mStyleOverridden )
mLayer->styleManager()->restoreOverrideStyle();
@@ -226,10 +226,14 @@ class CORE_EXPORT QgsLayerStyleOverride
*/
void setOverrideStyle( const QString &style )
{
if ( mLayer && mStyleOverridden )
mLayer->styleManager()->restoreOverrideStyle();
mLayer->styleManager()->setOverrideStyle( style );
mStyleOverridden = true;
if ( mLayer )
{
if ( mStyleOverridden )
mLayer->styleManager()->restoreOverrideStyle();

mLayer->styleManager()->setOverrideStyle( style );
mStyleOverridden = true;
}
}

private:
@@ -296,7 +296,7 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter *painter, QgsLabelingEn
if ( mFeatureFilterProvider )
job.context.setFeatureFilterProvider( mFeatureFilterProvider );

QgsLayerStyleOverride styleOverride( ml );
QgsMapLayerStyleOverride styleOverride( ml );
if ( mSettings.layerStyleOverrides().contains( ml->id() ) )
styleOverride.setOverrideStyle( mSettings.layerStyleOverrides().value( ml->id() ) );

@@ -365,7 +365,7 @@ QMap<QString, QString> QgsMapThemeCollection::mapThemeStyleOverrides( const QStr
if ( layerRec.usingCurrentStyle )
{
QgsMapLayer *layer = layerRec.layer();
QgsLayerStyleOverride styleOverride( layer );
QgsMapLayerStyleOverride styleOverride( layer );
styleOverride.setOverrideStyle( layerRec.currentStyle );

// set the checked legend nodes

0 comments on commit d1fa150

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