27 return QStringLiteral(
"RelationReference" );
35 if ( !config.contains( QStringLiteral(
"Relation" ) ) )
38 return value.toString();
44 return value.toString();
47 if ( layer != referencingLayer )
49 QgsMessageLog::logMessage( QObject::tr(
"representValue() with inconsistent layer parameter w.r.t relation referencingLayer" ) );
50 return value.toString();
53 if ( referencingFieldIdx != fieldIndex )
55 QgsMessageLog::logMessage( QObject::tr(
"representValue() with inconsistent fieldIndex parameter w.r.t relation referencingFieldIdx" ) );
56 return value.toString();
59 if ( !referencedLayer )
62 return value.toString();
68 attrs[ referencingFieldIdx ] = value;
74 return value.toString();
78 context.setFeature( feature );
79 QString title = expr.evaluate( &context ).toString();
80 if ( expr.hasEvalError() )
83 title = feature.
attribute( referencedFieldIdx ).toString();
Class for parsing and evaluation of expressions (formerly called "search strings").
bool isValid() const
Returns the validity of this feature.
QgsVectorLayer referencingLayer
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsFeatureRequest getReferencedFeatureRequest(const QgsAttributes &attributes) const
Creates a request to return the feature on the referenced (parent) layer which is referenced by the p...
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Q_INVOKABLE QgsRelation relation(const QString &id) const
Gets access to a relation by its id.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
This class wraps a request for features to a vector layer (or directly its vector data provider)...
int count() const
Returns number of items.
QgsVectorLayer referencedLayer
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QgsRelationManager relationManager
QString displayExpression
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QList< QgsRelation::FieldPair > fieldPairs() const
Returns the field pairs which form this relation The first element of each pair are the field names o...
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Query the layer for features specified in request.
bool nextFeature(QgsFeature &f)
Represents a vector layer which manages a vector based data sets.