Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rule based renderer: empty rule matches all
Fix #13218
  • Loading branch information
m-kuhn committed Aug 15, 2015
1 parent 67a7d13 commit abf2398
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayerrenderer.cpp
Expand Up @@ -145,7 +145,7 @@ bool QgsVectorLayerRenderer::render()
.setFilterRect( requestExtent )
.setSubsetOfAttributes( mAttrNames, mFields );

if ( !rendererFilter.isNull() )
if ( !rendererFilter.isEmpty() )
{
featureRequest.setFilterExpression( rendererFilter );
}
Expand Down
19 changes: 14 additions & 5 deletions src/core/symbology-ng/qgsrulebasedrendererv2.cpp
Expand Up @@ -427,24 +427,33 @@ bool QgsRuleBasedRendererV2::Rule::startRender( QgsRenderContext& context, const
}
}

// subfilters (on the same level) are joined with OR and finally joined with AND with their parent (this) filter
// subfilters (on the same level) are joined with OR
// Finally they are joined with their parent (this) with AND
QString sf;
if ( subfilters.length() )
// If there are subfilters present (and it's not a single empty one), group them and join them with OR
if ( subfilters.length() > 1 || subfilters.value( 0 ).trimmed().length() > 0 )
sf = subfilters.join( ") OR (" ).prepend( "(" ).append( ")" );

// Now join the subfilters with their parent (this) based on if
// * The parent is an else rule
// * The existence of parent filter and subfilters

if ( isElse() )
{
if ( !sf.length() )
if ( !sf.trimmed().length() )
filter = "TRUE";
else
filter = sf;
}
else if ( mFilterExp.length() && sf.length() )
else if ( mFilterExp.trimmed().length() && sf.trimmed().length() )
filter = QString( "(%1) AND (%2)" ).arg( mFilterExp ).arg( sf );
else if ( mFilterExp.length() )
else if ( mFilterExp.trimmed().length() )
filter = mFilterExp;
else
filter = sf;

filter = filter.trimmed();

return true;
}

Expand Down

0 comments on commit abf2398

Please sign in to comment.