mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Add method to remove feature from a QgsExpressionContextScope
This commit is contained in:
parent
abc6129b60
commit
4790035efa
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user