From 9acfe52f828e4ac1d70eb8c666aaf788caa12af3 Mon Sep 17 00:00:00 2001 From: Salvatore Larosa Date: Wed, 16 Sep 2015 17:37:25 +0200 Subject: [PATCH] [widget editor] enable returnPressed signal for the search widget --- src/app/qgsattributetabledialog.cpp | 5 +++++ src/gui/editorwidgets/core/qgssearchwidgetwrapper.h | 1 + src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.cpp | 6 ++++++ src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.h | 2 ++ 4 files changed, 14 insertions(+) diff --git a/src/app/qgsattributetabledialog.cpp b/src/app/qgsattributetabledialog.cpp index 346a09ea502d..48936a639a77 100644 --- a/src/app/qgsattributetabledialog.cpp +++ b/src/app/qgsattributetabledialog.cpp @@ -469,6 +469,7 @@ void QgsAttributeTableDialog::filterColumnChanged( QObject* filterAction ) } else { + connect( mCurrentSearchWidgetWrapper, SIGNAL( expressionChanged() ), SLOT( filterQueryAccepted() ) ); mApplyFilterButton->setVisible( true ); } @@ -504,6 +505,10 @@ void QgsAttributeTableDialog::filterShowAll() mFilterButton->setDefaultAction( mActionShowAllFilter ); mFilterButton->setPopupMode( QToolButton::InstantPopup ); mFilterQuery->setVisible( false ); + if ( mCurrentSearchWidgetWrapper != 0 ) + { + mCurrentSearchWidgetWrapper->widget()->setVisible( false ); + } mApplyFilterButton->setVisible( false ); mMainView->setFilterMode( QgsAttributeTableFilterModel::ShowAll ); } diff --git a/src/gui/editorwidgets/core/qgssearchwidgetwrapper.h b/src/gui/editorwidgets/core/qgssearchwidgetwrapper.h index f464040e9601..9f5fff944068 100644 --- a/src/gui/editorwidgets/core/qgssearchwidgetwrapper.h +++ b/src/gui/editorwidgets/core/qgssearchwidgetwrapper.h @@ -70,6 +70,7 @@ class GUI_EXPORT QgsSearchWidgetWrapper : public QgsWidgetWrapper signals: void expressionChanged( QString exp ); + void expressionChanged(); protected slots: diff --git a/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.cpp b/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.cpp index 13c11a86e777..29464fe9b5b1 100644 --- a/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.cpp +++ b/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.cpp @@ -96,6 +96,7 @@ void QgsDefaultSearchWidgetWrapper::initWidget( QWidget* widget ) mContainer->layout()->addWidget( mLineEdit ); mContainer->layout()->addWidget( mCheckbox ); connect( mLineEdit, SIGNAL( textChanged( QString ) ), this, SLOT( setExpression( QString ) ) ); + connect( mLineEdit, SIGNAL( returnPressed() ), this, SLOT( filterChanged() ) ); connect( mCheckbox, SIGNAL( stateChanged( int ) ), this, SLOT( setCaseString( int ) ) ); mCheckbox->setChecked( Qt::Unchecked ); mCaseString = "ILIKE"; @@ -105,3 +106,8 @@ bool QgsDefaultSearchWidgetWrapper::valid() { return true; } + +void QgsDefaultSearchWidgetWrapper::filterChanged() +{ + emit expressionChanged(); +} diff --git a/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.h b/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.h index afaba822fdcc..d9fd31f35588 100644 --- a/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.h +++ b/src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.h @@ -36,11 +36,13 @@ class GUI_EXPORT QgsDefaultSearchWidgetWrapper : public QgsSearchWidgetWrapper public: QString expression() override; bool applyDirectly() override; + protected slots: void setExpression( QString exp ) override; private slots: void setCaseString( int ); + void filterChanged(); protected: QWidget* createWidget( QWidget* parent ) override;