Skip to content
Permalink
Browse files
setExpression returns void
  • Loading branch information
3nids committed Jun 23, 2014
1 parent daefe3e commit c80bae57bef38dc47e6cdedd88ddc56f9125ad04
Showing with 9 additions and 11 deletions.
  1. +1 −2 python/gui/qgsfieldmodel.sip
  2. +4 −2 src/gui/qgsfieldexpressionwidget.cpp
  3. +3 −5 src/gui/qgsfieldmodel.cpp
  4. +1 −2 src/gui/qgsfieldmodel.h
@@ -36,9 +36,8 @@ class QgsFieldModel : QAbstractItemModel

/**
* @brief setExpression sets a single expression to be added after the fields at the end of the model
* @return the model index of the newly added expression
*/
QModelIndex setExpression( const QString &expression );
void setExpression( const QString &expression );

//! remove expressions from the model
void removeExpression();
@@ -152,7 +152,8 @@ void QgsFieldExpressionWidget::setField( const QString &fieldName )
if ( !idx.isValid() )
{
// new expression
idx = mFieldProxyModel->sourceFieldModel()->setExpression( fieldName );
mFieldProxyModel->sourceFieldModel()->setExpression( fieldName );
idx = mFieldProxyModel->sourceFieldModel()->indexFromName( fieldName );
}
}
QModelIndex proxyIndex = mFieldProxyModel->mapFromSource( idx );
@@ -189,7 +190,8 @@ void QgsFieldExpressionWidget::expressionEditingFinished()
{
QgsDebugMsg( "Editing finsihed" );
const QString expression = mCombo->lineEdit()->text();
QModelIndex idx = mFieldProxyModel->sourceFieldModel()->setExpression( expression );
mFieldProxyModel->sourceFieldModel()->setExpression( expression );
QModelIndex idx = mFieldProxyModel->sourceFieldModel()->indexFromName( expression );
QModelIndex proxyIndex = mFieldProxyModel->mapFromSource( idx );
mCombo->setCurrentIndex( proxyIndex.row() );
currentFieldChanged();
@@ -110,20 +110,18 @@ void QgsFieldModel::setAllowExpression( bool allowExpression )
}
}

QModelIndex QgsFieldModel::setExpression( const QString &expression )
void QgsFieldModel::setExpression( const QString &expression )
{
if ( !mAllowExpression )
return QModelIndex();
return;

QModelIndex idx = indexFromName( expression );
if ( idx.isValid() )
return idx;
return;

beginResetModel();
mExpression = QList<QString>() << expression;
endResetModel();

return index( mFields.count() , 0 );
}

void QgsFieldModel::removeExpression()
@@ -58,9 +58,8 @@ class GUI_EXPORT QgsFieldModel : public QAbstractItemModel

/**
* @brief setExpression sets a single expression to be added after the fields at the end of the model
* @return the model index of the newly added expression
*/
QModelIndex setExpression( const QString &expression );
void setExpression( const QString &expression );

//! remove expressions from the model
void removeExpression();

0 comments on commit c80bae5

Please sign in to comment.