Skip to content

Commit

Permalink
Fix #11420 (Quick calculation bar updates wrong column when using ali…
Browse files Browse the repository at this point in the history
…ases)
  • Loading branch information
wonder-sk committed Oct 20, 2014
1 parent 09691ba commit d11597a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/gui/qgsfieldmodel.cpp
Expand Up @@ -30,7 +30,19 @@ QgsFieldModel::QgsFieldModel( QObject *parent )


QModelIndex QgsFieldModel::indexFromName( const QString &fieldName ) QModelIndex QgsFieldModel::indexFromName( const QString &fieldName )
{ {
int r = mFields.indexFromName( fieldName ); QString fldName( fieldName ); // we may need a copy

if ( mLayer )
{
// the name could be an alias
// it would be better to have "display name" directly in QgsFields
// rather than having to consult layer in various places in code!
QString fieldNameWithAlias = mLayer->attributeAliases().key( fldName );
if ( !fieldNameWithAlias.isNull() )
fldName = fieldNameWithAlias;
}

int r = mFields.indexFromName( fldName );
QModelIndex idx = index( r, 0 ); QModelIndex idx = index( r, 0 );
if ( idx.isValid() ) if ( idx.isValid() )
{ {
Expand All @@ -39,7 +51,7 @@ QModelIndex QgsFieldModel::indexFromName( const QString &fieldName )


if ( mAllowExpression ) if ( mAllowExpression )
{ {
int exprIdx = mExpression.indexOf( fieldName ); int exprIdx = mExpression.indexOf( fldName );
if ( exprIdx != -1 ) if ( exprIdx != -1 )
{ {
return index( mFields.count() + exprIdx , 0 ); return index( mFields.count() + exprIdx , 0 );
Expand Down

0 comments on commit d11597a

Please sign in to comment.