4242#include " qgsexpressionselectiondialog.h"
4343#include " qgsfeaturelistmodel.h"
4444#include " qgsrubberband.h"
45+ #include " qgsfield.h"
46+ #include " qgseditorwidgetregistry.h"
4547
4648class QgsAttributeTableDock : public QDockWidget
4749{
@@ -64,6 +66,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
6466 , mDock( 0 )
6567 , mLayer( theLayer )
6668 , mRubberBand( 0 )
69+ , mCurrentSearchWidget( 0 )
6770{
6871 setupUi ( this );
6972
@@ -407,7 +410,24 @@ void QgsAttributeTableDialog::filterColumnChanged( QObject* filterAction )
407410 mFilterButton ->setDefaultAction ( qobject_cast<QAction *>( filterAction ) );
408411 mFilterButton ->setPopupMode ( QToolButton::InstantPopup );
409412 mCbxCaseSensitive ->setVisible ( true );
410- mFilterQuery ->setVisible ( true );
413+ // replace the search line edit with a search widget that is suited to the selected field
414+ mFilterQuery ->setVisible ( false );
415+ // delete previous widget
416+ if ( mCurrentSearchWidget != 0 )
417+ {
418+ // mFilterContainer->removeWidget(mCurrentSearchWidget);
419+ delete mCurrentSearchWidget ;
420+ }
421+ QString fieldName = mFilterButton ->defaultAction ()->text ();
422+ // get the search widget
423+ int fldIdx = mLayer ->fieldNameIndex ( fieldName );
424+ if ( fldIdx < 0 )
425+ return ;
426+ const QString widgetType = mLayer ->editorWidgetV2 ( fldIdx );
427+ const QgsEditorWidgetConfig widgetConfig = mLayer ->editorWidgetV2Config ( fldIdx );
428+ QgsEditorWidgetWrapper* eww = QgsEditorWidgetRegistry::instance ()->create ( widgetType, mLayer , fldIdx, widgetConfig, 0 , mFilterContainer );
429+ mCurrentSearchWidget = eww->widget ();
430+
411431 mApplyFilterButton ->setVisible ( true );
412432}
413433
@@ -677,7 +697,6 @@ void QgsAttributeTableDialog::filterQueryChanged( const QString& query )
677697 else
678698 {
679699 QString fieldName = mFilterButton ->defaultAction ()->text ();
680-
681700 const QgsFields& flds = mLayer ->pendingFields ();
682701 int fldIndex = mLayer ->fieldNameIndex ( fieldName );
683702 if ( fldIndex < 0 )
0 commit comments