Skip to content

Commit fafe8fd

Browse files
committedJun 9, 2014
value relation: save filter expression correctly and re-enable filter expression button (fixes #10503)
1 parent 277d126 commit fafe8fd

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed
 

‎src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
#include "qgsvectorlayer.h"
1919
#include "qgsexpressionbuilderdialog.h"
2020

21-
QgsValueRelationConfigDlg::QgsValueRelationConfigDlg( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) :
22-
QgsEditorConfigWidget( vl, fieldIdx, parent )
21+
QgsValueRelationConfigDlg::QgsValueRelationConfigDlg( QgsVectorLayer* vl, int fieldIdx, QWidget* parent )
22+
: QgsEditorConfigWidget( vl, fieldIdx, parent )
2323
{
2424
setupUi( this );
2525
mLayerName->setFilters( QgsMapLayerProxyModel::VectorLayer );
2626
connect( mLayerName, SIGNAL( layerChanged( QgsMapLayer* ) ), mKeyColumn, SLOT( setLayer( QgsMapLayer* ) ) );
2727
connect( mLayerName, SIGNAL( layerChanged( QgsMapLayer* ) ), mValueColumn, SLOT( setLayer( QgsMapLayer* ) ) );
28+
connect( mEditExpression, SIGNAL( clicked() ), this, SLOT( editExpression() ) );
2829
}
2930

3031
QgsEditorWidgetConfig QgsValueRelationConfigDlg::config()
@@ -51,5 +52,20 @@ void QgsValueRelationConfigDlg::setConfig( const QgsEditorWidgetConfig& config )
5152
mAllowMulti->setChecked( config.value( "AllowMulti" ).toBool() );
5253
mAllowNull->setChecked( config.value( "AllowNull" ).toBool() );
5354
mOrderByValue->setChecked( config.value( "OrderByValue" ).toBool() );
54-
mFilterExpression->setPlainText( config.value( "EditExpression" ).toString() );
55+
mFilterExpression->setPlainText( config.value( "FilterExpression" ).toString() );
56+
}
57+
58+
void QgsValueRelationConfigDlg::editExpression()
59+
{
60+
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer*>( mLayerName->currentLayer() );
61+
if ( !vl )
62+
return;
63+
64+
QgsExpressionBuilderDialog dlg( vl, mFilterExpression->toPlainText(), this );
65+
dlg.setWindowTitle( tr( "Edit filter expression" ) );
66+
67+
if ( dlg.exec() == QDialog::Accepted )
68+
{
69+
mFilterExpression->setText( dlg.expressionBuilder()->expressionText() );
70+
}
5571
}

‎src/gui/editorwidgets/qgsvaluerelationconfigdlg.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class GUI_EXPORT QgsValueRelationConfigDlg : public QgsEditorConfigWidget, priva
2727
public:
2828
explicit QgsValueRelationConfigDlg( QgsVectorLayer* vl, int fieldIdx, QWidget *parent = 0 );
2929

30+
public slots:
31+
void editExpression();
32+
3033
// QgsEditorConfigWidget interface
3134
public:
3235
QgsEditorWidgetConfig config();

0 commit comments

Comments
 (0)
Please sign in to comment.