Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
value relation: save filter expression correctly and re-enable filter…
… expression button (fixes #10503)
  • Loading branch information
jef-n committed Jun 9, 2014
1 parent 277d126 commit fafe8fd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp
Expand Up @@ -18,13 +18,14 @@
#include "qgsvectorlayer.h"
#include "qgsexpressionbuilderdialog.h"

QgsValueRelationConfigDlg::QgsValueRelationConfigDlg( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) :
QgsEditorConfigWidget( vl, fieldIdx, parent )
QgsValueRelationConfigDlg::QgsValueRelationConfigDlg( QgsVectorLayer* vl, int fieldIdx, QWidget* parent )
: QgsEditorConfigWidget( vl, fieldIdx, parent )
{
setupUi( this );
mLayerName->setFilters( QgsMapLayerProxyModel::VectorLayer );
connect( mLayerName, SIGNAL( layerChanged( QgsMapLayer* ) ), mKeyColumn, SLOT( setLayer( QgsMapLayer* ) ) );
connect( mLayerName, SIGNAL( layerChanged( QgsMapLayer* ) ), mValueColumn, SLOT( setLayer( QgsMapLayer* ) ) );
connect( mEditExpression, SIGNAL( clicked() ), this, SLOT( editExpression() ) );
}

QgsEditorWidgetConfig QgsValueRelationConfigDlg::config()
Expand All @@ -51,5 +52,20 @@ void QgsValueRelationConfigDlg::setConfig( const QgsEditorWidgetConfig& config )
mAllowMulti->setChecked( config.value( "AllowMulti" ).toBool() );
mAllowNull->setChecked( config.value( "AllowNull" ).toBool() );
mOrderByValue->setChecked( config.value( "OrderByValue" ).toBool() );
mFilterExpression->setPlainText( config.value( "EditExpression" ).toString() );
mFilterExpression->setPlainText( config.value( "FilterExpression" ).toString() );
}

void QgsValueRelationConfigDlg::editExpression()
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer*>( mLayerName->currentLayer() );
if ( !vl )
return;

QgsExpressionBuilderDialog dlg( vl, mFilterExpression->toPlainText(), this );
dlg.setWindowTitle( tr( "Edit filter expression" ) );

if ( dlg.exec() == QDialog::Accepted )
{
mFilterExpression->setText( dlg.expressionBuilder()->expressionText() );
}
}
3 changes: 3 additions & 0 deletions src/gui/editorwidgets/qgsvaluerelationconfigdlg.h
Expand Up @@ -27,6 +27,9 @@ class GUI_EXPORT QgsValueRelationConfigDlg : public QgsEditorConfigWidget, priva
public:
explicit QgsValueRelationConfigDlg( QgsVectorLayer* vl, int fieldIdx, QWidget *parent = 0 );

public slots:
void editExpression();

// QgsEditorConfigWidget interface
public:
QgsEditorWidgetConfig config();
Expand Down

0 comments on commit fafe8fd

Please sign in to comment.