Skip to content

Commit

Permalink
try to remove spaces and quotes to get a fieldname from an expression
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed May 26, 2014
1 parent dcbf893 commit 2fc65a9
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/gui/qgsfieldexpressionwidget.cpp
Expand Up @@ -124,8 +124,19 @@ void QgsFieldExpressionWidget::setField( const QString &fieldName )
QModelIndex idx = mFieldProxyModel->sourceFieldModel()->indexFromName( fieldName );
if ( !idx.isValid() )
{
// new expression
idx = mFieldProxyModel->sourceFieldModel()->setExpression( fieldName );
// try to remove quotes and white spaces
QString simpleFieldName = fieldName.trimmed();
if ( simpleFieldName.startsWith( '"' ) && simpleFieldName.endsWith( '"' ) )
{
simpleFieldName.remove( 0, 1 ).chop( 1 );
idx = mFieldProxyModel->sourceFieldModel()->indexFromName( simpleFieldName );
}

if ( !idx.isValid() )
{
// new expression
idx = mFieldProxyModel->sourceFieldModel()->setExpression( fieldName );
}
}
QModelIndex proxyIndex = mFieldProxyModel->mapFromSource( idx );
mCombo->setCurrentIndex( proxyIndex.row() );
Expand Down

0 comments on commit 2fc65a9

Please sign in to comment.