25 , mValidConstraint( true )
26 , mFieldIdx( fieldIdx )
37 if ( mFieldIdx <
layer()->fields().count() )
106 if ( constraintValid )
114 bool toEmit(
false );
115 QString errStr(
tr(
"predicate is True" ) );
137 else if ( ! mValidConstraint )
138 errStr =
tr(
"predicate is False" );
143 mValidConstraint =
true;
145 if (
layer()->editFormConfig()->notNull( mFieldIdx ) )
150 expression =
"( " + expression +
" ) AND ( " + fieldName +
" IS NOT NULL)";
151 description =
"( " + description +
" ) AND NotNull";
155 description =
"NotNull";
156 expression =
"NotNull";
159 mValidConstraint = mValidConstraint && !value.
isNull();
162 errStr =
tr(
"predicate is False" );
176 return mValidConstraint;
Class for parsing and evaluation of expressions (formerly called "search strings").
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
Q_DECL_DEPRECATED QVariant evaluate(const QgsFeature *f)
Evaluate the feature and return the result.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
static QgsExpressionContext createFeatureBasedContext(const QgsFeature &feature, const QgsFields &fields)
Helper function for creating an expression context which contains just a feature and fields collectio...
QString evalErrorString() const
Returns evaluation error.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QString parserErrorString() const
Returns parser error.
QString tr(const char *sourceText, const char *disambiguation, int n)
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
QgsEditFormConfig * editFormConfig() const
Get the configuration of the form used to represent this vector layer.
QgsFields fields() const
Returns the list of fields of this layer.
int fieldOriginIndex(int fieldIdx) const
Get field's origin index (its meaning is specific to each type of origin)
const QgsFields * fields() const
Returns the field map associated with the feature.
QVariant property(const char *name) const
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Encapsulate a field in an attribute table or data source.
virtual QVariant defaultValue(int fieldId, bool forceLazyEval=false)
Returns the default value for field specified by fieldId.
QgsVectorDataProvider * dataProvider()
Returns the data provider.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
Represents a vector layer which manages a vector based data sets.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QString attributeDisplayName(int attributeIndex) const
Convenience function that returns the attribute alias if defined or the field name else...