Skip to content

Commit

Permalink
Works now for the default case
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinux committed May 22, 2015
1 parent b82a4d4 commit f1085b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/app/qgsattributetabledialog.cpp
Expand Up @@ -715,8 +715,9 @@ void QgsAttributeTableDialog::filterQueryChanged( const QString& query )

QSettings settings;
QString nullValue = settings.value( "qgis/nullValue", "NULL" ).toString();
QString value = mCurrentSearchWidgetWrapper->value().toString();

if ( mFilterQuery->displayText() == nullValue )
if ( value == nullValue )
{
str = QString( "%1 IS NULL" ).arg( QgsExpression::quotedColumnRef( fieldName ) );
}
Expand All @@ -726,9 +727,9 @@ void QgsAttributeTableDialog::filterQueryChanged( const QString& query )
.arg( QgsExpression::quotedColumnRef( fieldName ) )
.arg( numeric ? "=" : sensString )
.arg( numeric
? mFilterQuery->displayText().replace( "'", "''" )
? value.replace( "'", "''" )
:
"%" + mFilterQuery->displayText().replace( "'", "''" ) + "%" ); // escape quotes
"%" + value.replace( "'", "''" ) + "%" ); // escape quotes
}
}

Expand All @@ -738,7 +739,8 @@ void QgsAttributeTableDialog::filterQueryChanged( const QString& query )

void QgsAttributeTableDialog::filterQueryAccepted()
{
if ( mFilterQuery->text().isEmpty() )
if ( (mFilterQuery->isVisible() && mFilterQuery->text().isEmpty()) ||
(mCurrentSearchWidgetWrapper->widget()->isVisible() && mCurrentSearchWidgetWrapper->value().toString().isEmpty() ))
{
filterShowAll();
return;
Expand All @@ -753,6 +755,10 @@ void QgsAttributeTableDialog::setFilterExpression( QString filterString )
mFilterButton->setPopupMode( QToolButton::MenuButtonPopup );
mCbxCaseSensitive->setVisible( false );
mFilterQuery->setVisible( true );
if ( mCurrentSearchWidgetWrapper != 0 )
{
mCurrentSearchWidgetWrapper->widget()->setVisible( false );
}
mApplyFilterButton->setVisible( true );
mMainView->setFilterMode( QgsAttributeTableFilterModel::ShowFilteredList );

Expand Down
7 changes: 4 additions & 3 deletions src/gui/editorwidgets/core/qgsdefaultsearchwidgetwrapper.cpp
Expand Up @@ -28,17 +28,18 @@ QgsDefaultSearchWidgetWrapper::QgsDefaultSearchWidgetWrapper( QgsVectorLayer* vl

QVariant QgsDefaultSearchWidgetWrapper::value()
{
return QString("foo");
return mLineEdit->text();
}

QWidget* QgsDefaultSearchWidgetWrapper::createWidget( QWidget* parent )
{
return new QgsFilterLineEdit( parent );
}

void QgsDefaultSearchWidgetWrapper::initWidget( QWidget* editor )
void QgsDefaultSearchWidgetWrapper::initWidget( QWidget* widget )
{
connect( mLineEdit, SIGNAL( textChanged( QString ) ), this, SLOT( valueChanged( QString ) ) );
mLineEdit = qobject_cast<QgsFilterLineEdit*>( widget );
connect( widget, SIGNAL( textChanged( QString ) ), this, SLOT( valueChanged( QString ) ) );
}

void QgsDefaultSearchWidgetWrapper::setValue( const QVariant& value )
Expand Down

0 comments on commit f1085b8

Please sign in to comment.