Skip to content
Permalink
Browse files

Add method to remove feature from a QgsExpressionContextScope

  • Loading branch information
nyalldawson committed Feb 22, 2017
1 parent abc6129 commit 4790035efaa396e83e91bd1bf80126962bf5cc9c
@@ -197,10 +197,8 @@ class QgsExpressionContextScope

void setFeature( const QgsFeature& feature );

/** Convenience function for setting a fields for the scope. Any existing
* fields set by the scope will be overwritten.
* @param fields fields for scope
*/
void removeFeature();

void setFields( const QgsFields& fields );
};

@@ -269,9 +269,19 @@ class CORE_EXPORT QgsExpressionContextScope
/** Convenience function for setting a feature for the scope. Any existing
* feature set by the scope will be overwritten.
* @param feature feature for scope
* @see removeFeature()
* @see feature()
*/
void setFeature( const QgsFeature& feature ) { mHasFeature = true; mFeature = feature; }

/**
* Removes any feature associated with the scope.
* @note added in QGIS 3.0
* @see setFeature()
* @see hasFeature()
*/
void removeFeature() { mHasFeature = false; mFeature = QgsFeature(); }

/** Convenience function for setting a fields for the scope. Any existing
* fields set by the scope will be overwritten.
* @param fields fields for scope
@@ -437,6 +437,9 @@ void TestQgsExpressionContext::setFeature()
scope.setFeature( feature );
QVERIFY( scope.hasFeature() );
QCOMPARE( scope.feature().id(), 50LL );
scope.removeFeature();
QVERIFY( !scope.hasFeature() );
QVERIFY( !scope.feature().isValid() );

//test setting a feature in a context with no scopes
QgsExpressionContext emptyContext;

0 comments on commit 4790035

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