Skip to content
Permalink
Browse files

Fix #11420 (Quick calculation bar updates wrong column when using ali…

…ases)
  • Loading branch information
wonder-sk committed Oct 20, 2014
1 parent 09691ba commit d11597a5b7b301e755d188c3f381e3339cf95f39
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/gui/qgsfieldmodel.cpp
@@ -30,7 +30,19 @@ QgsFieldModel::QgsFieldModel( QObject *parent )

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 );
if ( idx.isValid() )
{
@@ -39,7 +51,7 @@ QModelIndex QgsFieldModel::indexFromName( const QString &fieldName )

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

0 comments on commit d11597a

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