Skip to content

Commit

Permalink
Make rule-based renderer rule keys persistent
Browse files Browse the repository at this point in the history
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 edd64c4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/symbology-ng/qgsrulebasedrendererv2.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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" );
Expand Down

0 comments on commit edd64c4

Please sign in to comment.