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();
int lookupField(const QString &fieldName) const
Look up field's index from the field name.
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...
int count() const
Return number of items.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning)
add a message to the instance (and create it if necessary)
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 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)...
QgsVectorLayer referencedLayer
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
QgsRelationManager relationManager
QString displayExpression
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 override
Query the layer for features specified in request.
static QgsProject * instance()
Returns the QgsProject singleton instance.
bool nextFeature(QgsFeature &f)
Q_INVOKABLE QgsRelation relation(const QString &id) const
Get access to a relation by its id.
Represents a vector layer which manages a vector based data sets.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.