Skip to content
Permalink
Browse files

use layer's displayExpression in relation reference widget line edit

  • Loading branch information
3nids committed Oct 15, 2014
1 parent 69fc9bb commit cd59091b9cc86ca3bb149a474bbc57ab7492ab61
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/gui/editorwidgets/qgsrelationreferencewidget.cpp
@@ -230,7 +230,13 @@ void QgsRelationReferenceWidget::setForeignKey( const QVariant& value )

if ( mReadOnlySelector )
{
mLineEdit->setText( f.attribute( mFkeyFieldIdx ).toString() );
QgsExpression expr( mReferencedLayer->displayExpression() );
QString title = expr.evaluate( &f ).toString();
if ( expr.hasEvalError() )
{
title = f.attribute( mFkeyFieldIdx ).toString();
}
mLineEdit->setText( title );
mFeatureId = f.id();
}
else
@@ -565,7 +571,13 @@ void QgsRelationReferenceWidget::featureIdentified( const QgsFeature& feature )
{
if ( mReadOnlySelector )
{
mLineEdit->setText( feature.attribute( mFkeyFieldIdx ).toString() );
QgsExpression expr( mReferencedLayer->displayExpression() );
QString title = expr.evaluate( &feature ).toString();
if ( expr.hasEvalError() )
{
title = feature.attribute( mFkeyFieldIdx ).toString();
}
mLineEdit->setText( title );
mForeignKey = feature.attribute( mFkeyFieldIdx );
mFeatureId = feature.id();
}

0 comments on commit cd59091

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