Skip to content
Permalink
Browse files

Make rule-based renderer rule keys persistent

So they can be used for visibility groups - before they got assigned new keys
on every instantiation of Rule
  • Loading branch information
wonder-sk committed Sep 10, 2014
1 parent 95f4a30 commit edd64c4912f73d7a3047121808f9ff7353690bd6
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/core/symbology-ng/qgsrulebasedrendererv2.cpp
@@ -254,6 +254,7 @@ QgsRuleBasedRendererV2::Rule* QgsRuleBasedRendererV2::Rule::clone() const
{
QgsSymbolV2* sym = mSymbol ? mSymbol->clone() : NULL;
Rule* newrule = new Rule( sym, mScaleMinDenom, mScaleMaxDenom, mFilterExp, mLabel, mDescription );
newrule->mRuleKey = mRuleKey;
newrule->setCheckState( mCheckState );
// clone children
foreach ( Rule* rule, mChildren )
@@ -283,6 +284,7 @@ QDomElement QgsRuleBasedRendererV2::Rule::save( QDomDocument& doc, QgsSymbolV2Ma
ruleElem.setAttribute( "description", mDescription );
if ( !mCheckState )
ruleElem.setAttribute( "checkstate", 0 );
ruleElem.setAttribute( "key", mRuleKey );

for ( RuleList::iterator it = mChildren.begin(); it != mChildren.end(); ++it )
{
@@ -589,8 +591,12 @@ QgsRuleBasedRendererV2::Rule* QgsRuleBasedRendererV2::Rule::create( QDomElement&
QString description = ruleElem.attribute( "description" );
int scaleMinDenom = ruleElem.attribute( "scalemindenom", "0" ).toInt();
int scaleMaxDenom = ruleElem.attribute( "scalemaxdenom", "0" ).toInt();
QString ruleKey = ruleElem.attribute( "key" );
Rule* rule = new Rule( symbol, scaleMinDenom, scaleMaxDenom, filterExp, label, description );

if ( !ruleKey.isEmpty() )
rule->mRuleKey = ruleKey;

rule->setCheckState( ruleElem.attribute( "checkstate", "1" ).toInt() );

QDomElement childRuleElem = ruleElem.firstChildElement( "rule" );

0 comments on commit edd64c4

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