Skip to content
Permalink
Browse files

read related fields on relationreference widget

  • Loading branch information
signedav committed Dec 16, 2019
1 parent 3b4437b commit 9ebe42ad2b3a15ce8b48ed2388b998227b92a6c8
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/gui/qgsexpressionbuilderwidget.cpp
@@ -468,7 +468,17 @@ void QgsExpressionBuilderWidget::fillFieldValues( const QString &fieldName, int
const QgsEditorWidgetSetup setup = fields.at( fieldIndex ).editorWidgetSetup();
const QgsFieldFormatter *formatter = QgsApplication::fieldFormatterRegistry()->fieldFormatter( setup.type() );

QList<QVariant> values = mLayer->uniqueValues( fieldIndex, countLimit ).toList();
const QgsVectorLayer * layer = mLayer;
int layerFieldIndex = fieldIndex;

// if it's a request for the values of the referenced layer
if ( setup.config().contains( QStringLiteral( "Relation" ) ) )
{
layer = mProject->relationManager()->relation( setup.config()[QStringLiteral( "Relation" )].toString() ).referencedLayer();
layerFieldIndex = mProject->relationManager()->relation( setup.config()[QStringLiteral( "Relation" )].toString() ).referencedFields().first();
}

QList<QVariant> values = layer->uniqueValues( layerFieldIndex, countLimit ).toList();
std::sort( values.begin(), values.end() );

for ( const QVariant &value : qgis::as_const( values ) )

0 comments on commit 9ebe42a

Please sign in to comment.
You can’t perform that action at this time.