Skip to content
Permalink
Browse files
Works now for the default case
  • Loading branch information
carolinux committed May 22, 2015
1 parent b82a4d4 commit f1085b833e83d7c1dea7082b010d16dbf745a727
Showing with 14 additions and 7 deletions.
  1. +10 −4 src/app/qgsattributetabledialog.cpp
  2. +4 −3 src/gui/editorwidgets/core/qgsdefaultsearchwidgetwrapper.cpp
@@ -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 ) );
}
@@ -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
}
}

@@ -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;
@@ -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 );

@@ -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 )

0 comments on commit f1085b8

Please sign in to comment.