Skip to content
Permalink
Browse files

Reflect changes in QgsExpressionFieldWidget when source fields change

  • Loading branch information
m-kuhn authored and 3nids committed Feb 1, 2016
1 parent e453c15 commit 4ddd1cc529cf668e02b19b50f179125922a0d0bd
Showing with 12 additions and 0 deletions.
  1. +9 −0 src/gui/qgsfieldexpressionwidget.cpp
  2. +3 −0 src/gui/qgsfieldexpressionwidget.h
@@ -148,13 +148,17 @@ void QgsFieldExpressionWidget::setLayer( QgsMapLayer *layer )

void QgsFieldExpressionWidget::setLayer( QgsVectorLayer *layer )
{
disconnect( mFieldProxyModel->sourceFieldModel()->layer(), SIGNAL( updatedFields() ), this, SLOT( reloadLayer() ) );

mExpressionContext.reset( new QgsExpressionContext() );
mExpressionContext->appendScope( QgsExpressionContextUtils::globalScope() );
mExpressionContext->appendScope( QgsExpressionContextUtils::projectScope() );
if ( layer )
mExpressionContext->appendScope( QgsExpressionContextUtils::layerScope( layer ) );

mFieldProxyModel->sourceFieldModel()->setLayer( layer );

connect( mFieldProxyModel->sourceFieldModel()->layer(), SIGNAL( updatedFields() ), this, SLOT( reloadLayer() ) );
}

void QgsFieldExpressionWidget::setField( const QString &fieldName )
@@ -231,6 +235,11 @@ void QgsFieldExpressionWidget::changeEvent( QEvent* event )
}
}

void QgsFieldExpressionWidget::reloadLayer()
{
setLayer( mFieldProxyModel->sourceFieldModel()->layer() );
}

void QgsFieldExpressionWidget::currentFieldChanged()
{
updateLineEditStyle();
@@ -147,6 +147,9 @@ class GUI_EXPORT QgsFieldExpressionWidget : public QWidget
protected:
void changeEvent( QEvent* event ) override;

private slots:
void reloadLayer();

private:
QComboBox* mCombo;
QToolButton* mButton;

0 comments on commit 4ddd1cc

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