Skip to content
Permalink
Browse files
try to remove spaces and quotes to get a fieldname from an expression
  • Loading branch information
3nids committed May 26, 2014
1 parent dcbf893 commit 2fc65a9e9b2a725fe962b83e9c4f1bbc6ae8172d
Showing with 13 additions and 2 deletions.
  1. +13 −2 src/gui/qgsfieldexpressionwidget.cpp
@@ -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() );

0 comments on commit 2fc65a9

Please sign in to comment.