37 return QStringLiteral(
"ValueRelation" );
43 Q_UNUSED( fieldIndex )
47 if ( cache.isValid() )
56 if ( config.value( QStringLiteral(
"AllowMulti" ) ).toBool() )
59 QStringList valueList;
63 if ( keyList.contains( item.key.toString() ) )
65 valueList << item.value;
69 return valueList.join( QStringLiteral(
", " ) ).prepend(
'{' ).append(
'}' );
80 if ( item.key == value )
87 return QStringLiteral(
"(%1)" ).arg( value.toString() );
98 Q_UNUSED( fieldIndex )
99 return QVariant::fromValue<ValueRelationCache>(
createCache( config ) );
113 int ki = fields.
indexOf( config.value( QStringLiteral(
"Key" ) ).toString() );
114 int vi = fields.
indexOf( config.value( QStringLiteral(
"Value" ) ).toString() );
121 const QString expression = config.value( QStringLiteral(
"FilterExpression" ) ).toString();
143 if ( config.value( QStringLiteral(
"OrderByValue" ) ).toBool() )
157 QStringList checkList;
158 if ( value.type() == QVariant::StringList )
159 checkList = value.toStringList();
160 else if ( value.type() == QVariant::String )
161 checkList = value.toString().remove( QChar(
'{' ) ).remove( QChar(
'}' ) ).split(
',' );
162 else if ( value.type() == QVariant::List )
164 QVariantList valuesList( value.toList( ) );
165 for (
const QVariant &listItem : qgis::as_const( valuesList ) )
167 QString v( listItem.toString( ) );
169 checkList.append( v );
179 QSet< QString > formVariables = scope->variableNames().toSet();
181 formVariables.intersect( usedVariables );
182 return formVariables;
192 QSet<QString> attributes;
196 const QSet<QString> formFunctions( scope->functionNames()
201 for (
const auto &f : expFunctions )
204 if ( formFunctions.contains( fd->
name( ) ) )
206 for (
const auto ¶m : f->args( )->list() )
208 attributes.insert( param->eval( &exp, &context ).toString() );
218 for (
auto it = attrs.constBegin() ; it != attrs.constEnd(); it++ )
220 if ( ! feature.
attribute( *it ).isValid() )
Class for parsing and evaluation of expressions (formerly called "search strings").
Wrapper for iterator of features from vector data provider or vector layer.
QSet< QString > referencedVariables() const
Returns a list of all variables which are used in this expression.
bool isValid() const
Returns the validity of this feature.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
Container of fields for a vector layer.
QSet< QString > referencedFunctions() const
Returns a list of the names of all functions which are used in this expression.
QString name() const
The name of the function.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
static QgsExpressionContextScope * formScope(const QgsFeature &formFeature=QgsFeature(), const QString &formMode=QString())
Creates a new scope which contains functions and variables from the current attribute form/table feat...
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
This class wraps a request for features to a vector layer (or directly its vector data provider)...
static QString nullRepresentation()
This string is used to represent the value NULL throughout QGIS.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
An expression node for expression functions.
int indexOf(const QString &fieldName) const
Gets the field index from the field name.
A abstract base class for defining QgsExpression functions.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Query the layer for features specified in request.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
QList< int > QgsAttributeList
bool nextFeature(QgsFeature &f)
Geometry is not required. It may still be returned if e.g. required for a filter condition.
Represents a vector layer which manages a vector based data sets.
QList< const T * > findNodes() const
Returns a list of all nodes of the given class which are used in this expression. ...
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.