36 return QStringLiteral(
"ValueRelation" );
42 Q_UNUSED( fieldIndex )
46 if ( cache.isValid() )
55 if ( config.value( QStringLiteral(
"AllowMulti" ) ).toBool() )
57 QStringList keyList = value.toString().remove( QChar(
'{' ) ).remove( QChar(
'}' ) ).split(
',' );
58 QStringList valueList;
62 if ( keyList.contains( item.key.toString() ) )
64 valueList << item.value;
68 return valueList.join( QStringLiteral(
", " ) ).prepend(
'{' ).append(
'}' );
79 if ( item.key == value )
86 return QStringLiteral(
"(%1)" ).arg( value.toString() );
97 Q_UNUSED( fieldIndex )
98 return QVariant::fromValue<ValueRelationCache>(
createCache( config ) );
112 int ki = fields.
indexOf( config.value( QStringLiteral(
"Key" ) ).toString() );
113 int vi = fields.
indexOf( config.value( QStringLiteral(
"Value" ) ).toString() );
119 if ( !config.value( QStringLiteral(
"FilterExpression" ) ).toString().isEmpty() )
123 request.
setFilterExpression( config.value( QStringLiteral(
"FilterExpression" ) ).toString() );
134 if ( config.value( QStringLiteral(
"OrderByValue" ) ).toBool() )
Wrapper for iterator of features from vector data provider or vector layer.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
Container of fields for a vector layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
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 override
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.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const override
Query the layer for features specified in request.
int indexOf(const QString &fieldName) const
Get the field index from the field name.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
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.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Set flags that affect how features will be fetched.