26 const QString& field )
28 , mUseExpression( useexpr )
29 , mExpressionString( expr )
33 mExpressionPrepared =
false;
37 : mActive( bool( expression ) )
38 , mUseExpression( expression && expression->rootNode() && !dynamic_cast<const
QgsExpression::NodeColumnRef*>( expression->rootNode() ) )
39 , mExpressionString( mUseExpression ? expression->expression() :
"" )
40 , mField( !mUseExpression ? ( expression ? expression->expression() :
"" ) :
"" )
43 mExpressionPrepared =
false;
48 mExpressionParams.clear();
54 return ( !mActive && !mUseExpression && mExpressionString.isEmpty() && mField.isEmpty() );
59 mExpressionString = expr;
60 mExpressionPrepared =
false;
65 if ( !mUseExpression || mExpressionString.isEmpty() )
78 QVariant scaleV = mExpressionParams.value(
"scale" );
79 if ( scaleV.isValid() )
82 double scale = scaleV.toDouble( &ok );
106 mExpressionPrepared =
true;
114 if ( !mExprRefColmuns.isEmpty() )
116 return mExprRefColmuns;
119 if ( mUseExpression )
121 if ( !mExpression || !mExpressionPrepared )
126 else if ( !mField.isEmpty() )
128 mExprRefColmuns << mField;
131 return mExprRefColmuns;
136 mExpressionParams.insert( key, param );
141 QMap< QString, QString > map;
142 map.insert(
"active", ( mActive ?
"1" :
"0" ) );
143 map.insert(
"useexpr", ( mUseExpression ?
"1" :
"0" ) );
144 map.insert(
"expression", mExpressionString );
145 map.insert(
"field", mField );
152 QDomElement element = document.createElement( elementName );
153 element.setAttribute(
"active", mActive ?
"true" :
"false" );
154 element.setAttribute(
"useExpr", mUseExpression ?
"true" :
"false" );
155 element.setAttribute(
"expr", mExpressionString );
156 element.setAttribute(
"field", mField );
162 if ( element.isNull() )
167 mActive = element.attribute(
"active" ).compare(
"true", Qt::CaseInsensitive ) == 0;
168 mUseExpression = element.attribute(
"useExpr" ).compare(
"true", Qt::CaseInsensitive ) == 0;
169 mField = element.attribute(
"field" );
182 return !( *
this == other );