18
18
#include " qgsvectorlayer.h"
19
19
#include " qgsexpressionbuilderdialog.h"
20
20
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 )
23
23
{
24
24
setupUi ( this );
25
25
mLayerName ->setFilters ( QgsMapLayerProxyModel::VectorLayer );
26
26
connect ( mLayerName , SIGNAL ( layerChanged ( QgsMapLayer* ) ), mKeyColumn , SLOT ( setLayer ( QgsMapLayer* ) ) );
27
27
connect ( mLayerName , SIGNAL ( layerChanged ( QgsMapLayer* ) ), mValueColumn , SLOT ( setLayer ( QgsMapLayer* ) ) );
28
+ connect ( mEditExpression , SIGNAL ( clicked () ), this , SLOT ( editExpression () ) );
28
29
}
29
30
30
31
QgsEditorWidgetConfig QgsValueRelationConfigDlg::config ()
@@ -51,5 +52,20 @@ void QgsValueRelationConfigDlg::setConfig( const QgsEditorWidgetConfig& config )
51
52
mAllowMulti ->setChecked ( config.value ( " AllowMulti" ).toBool () );
52
53
mAllowNull ->setChecked ( config.value ( " AllowNull" ).toBool () );
53
54
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
+ }
55
71
}
0 commit comments