Skip to content

Commit

Permalink
read related fields on relationreference widget
Browse files Browse the repository at this point in the history
  • Loading branch information
signedav committed Dec 16, 2019
1 parent 3b4437b commit 9ebe42a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/gui/qgsexpressionbuilderwidget.cpp
Expand Up @@ -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 ) )
Expand Down

0 comments on commit 9ebe42a

Please sign in to comment.