23
23
#include < QSizePolicy>
24
24
25
25
QgsValueMapSearchWidgetWrapper::QgsValueMapSearchWidgetWrapper ( QgsVectorLayer* vl, int fieldIdx, QWidget* parent )
26
- : QgsDefaultSearchWidgetWrapper ( vl, fieldIdx, parent ),
26
+ : QgsSearchWidgetWrapper ( vl, fieldIdx, parent ),
27
27
mComboBox( NULL )
28
28
{
29
29
}
@@ -33,17 +33,30 @@ QWidget* QgsValueMapSearchWidgetWrapper::createWidget( QWidget* parent )
33
33
return new QComboBox ( parent );
34
34
}
35
35
36
- void QgsValueMapSearchWidgetWrapper::comboBoxIndexChanged ( int )
36
+ void QgsValueMapSearchWidgetWrapper::comboBoxIndexChanged ( int idx )
37
37
{
38
38
if ( mComboBox )
39
- setExpression ( mComboBox ->itemData ( mComboBox ->currentIndex () ).toString () );
39
+ {
40
+ setExpression ( mComboBox ->itemData ( idx ).toString () );
41
+ emit expressionChanged ( mExpression );
42
+ }
40
43
}
41
44
42
45
bool QgsValueMapSearchWidgetWrapper::applyDirectly ()
43
46
{
44
47
return true ;
45
48
}
46
49
50
+ QString QgsValueMapSearchWidgetWrapper::expression ()
51
+ {
52
+ return mExpression ;
53
+ }
54
+
55
+ bool QgsValueMapSearchWidgetWrapper::valid ()
56
+ {
57
+ return true ;
58
+ }
59
+
47
60
void QgsValueMapSearchWidgetWrapper::initWidget ( QWidget* editor )
48
61
{
49
62
mComboBox = qobject_cast<QComboBox*>( editor );
@@ -63,3 +76,15 @@ void QgsValueMapSearchWidgetWrapper::initWidget( QWidget* editor )
63
76
}
64
77
}
65
78
79
+ void QgsValueMapSearchWidgetWrapper::setExpression ( QString exp )
80
+ {
81
+ QString fieldName = layer ()->fields ().at ( mFieldIdx ).name ();
82
+ QString str;
83
+
84
+ str = QString ( " %1 = '%2'" )
85
+ .arg ( QgsExpression::quotedColumnRef ( fieldName ),
86
+ exp .replace ( ' \' ' , " ''" ) );
87
+
88
+ mExpression = str;
89
+ }
90
+
0 commit comments