Skip to content
Permalink
Browse files

Fixes for search widgets

  • Loading branch information
carolinux authored and m-kuhn committed Jun 27, 2015
1 parent 4ebf087 commit b6ae2e7d1e3f98c6850a36830cc360afe1de931f
Showing with 20 additions and 14 deletions.
  1. +17 −11 src/app/qgsattributetabledialog.cpp
  2. +3 −3 src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.cpp
@@ -423,6 +423,7 @@ void QgsAttributeTableDialog::filterColumnChanged( QObject* filterAction )
// delete previous widget
if ( mCurrentSearchWidgetWrapper != 0 )
{
mCurrentSearchWidgetWrapper->widget()->setVisible( false );
delete mCurrentSearchWidgetWrapper;
}
QString fieldName = mFilterButton->defaultAction()->text();
@@ -434,14 +435,14 @@ void QgsAttributeTableDialog::filterColumnChanged( QObject* filterAction )
const QgsEditorWidgetConfig widgetConfig = mLayer->editorWidgetV2Config( fldIdx );
mCurrentSearchWidgetWrapper = QgsEditorWidgetRegistry::instance()->
createSearchWidget( widgetType, mLayer, fldIdx, widgetConfig, mFilterContainer );
if (mCurrentSearchWidgetWrapper->applyDirectly())
if ( mCurrentSearchWidgetWrapper->applyDirectly() )
{
connect( mCurrentSearchWidgetWrapper, SIGNAL( expressionChanged(QString) ), SLOT( filterQueryChanged(QString) ) );
mApplyFilterButton->setVisible(false);
connect( mCurrentSearchWidgetWrapper, SIGNAL( expressionChanged( QString ) ), SLOT( filterQueryChanged( QString ) ) );
mApplyFilterButton->setVisible( false );
}
else
{
mApplyFilterButton->setVisible(true);
mApplyFilterButton->setVisible( true );
}

replaceSearchWidget( mFilterQuery, mCurrentSearchWidgetWrapper->widget() );
@@ -730,15 +731,20 @@ void QgsAttributeTableDialog::filterQueryAccepted()

void QgsAttributeTableDialog::setFilterExpression( QString filterString )
{
mFilterQuery->setText( filterString );
mFilterButton->setDefaultAction( mActionAdvancedFilter );
mFilterButton->setPopupMode( QToolButton::MenuButtonPopup );
mFilterQuery->setVisible( true );
if ( mCurrentSearchWidgetWrapper != 0 )
if ( mCurrentSearchWidgetWrapper == 0 || !mCurrentSearchWidgetWrapper->applyDirectly() )
{
replaceSearchWidget( mCurrentSearchWidgetWrapper->widget(), mFilterQuery );
mFilterQuery->setText( filterString );
mFilterButton->setDefaultAction( mActionAdvancedFilter );
mFilterButton->setPopupMode( QToolButton::MenuButtonPopup );
mFilterQuery->setVisible( true );
mApplyFilterButton->setVisible( true );
if ( mCurrentSearchWidgetWrapper != 0 )
{
// replace search widget widget with the normal filter query line edit
replaceSearchWidget( mCurrentSearchWidgetWrapper->widget(), mFilterQuery );
}
}
mApplyFilterButton->setVisible( true );

mMainView->setFilterMode( QgsAttributeTableFilterModel::ShowFilteredList );

QgsFeatureIds filteredFeatures;
@@ -52,7 +52,6 @@ void QgsDefaultSearchWidgetWrapper::setCaseString(int caseSensitiveCheckState)

void QgsDefaultSearchWidgetWrapper::setExpression(QString exp)
{
QString sensString = mCaseString;
QVariant::Type fldType = layer()->pendingFields()[mFieldIdx].type();
bool numeric = ( fldType == QVariant::Int || fldType == QVariant::Double || fldType == QVariant::LongLong );

@@ -68,7 +67,7 @@ void QgsDefaultSearchWidgetWrapper::setExpression(QString exp)
{
str = QString( "%1 %2 '%3'" )
.arg( QgsExpression::quotedColumnRef( fieldName ) )
.arg( numeric ? "=" : sensString )
.arg( numeric ? "=" : mCaseString )
.arg( numeric
? exp.replace( "'", "''" )
:
@@ -94,9 +93,10 @@ void QgsDefaultSearchWidgetWrapper::initWidget( QWidget* widget )
mContainer->setLayout(new QHBoxLayout() );
mLineEdit = new QgsFilterLineEdit();
mCheckbox = new QCheckBox("Case sensitive");
mCheckbox->setChecked(Qt::Unchecked);
mContainer->layout()->addWidget(mLineEdit);
mContainer->layout()->addWidget(mCheckbox);
connect( mLineEdit, SIGNAL( textChanged( QString ) ), this, SLOT( setExpression( QString ) ) );
connect( mCheckbox, SIGNAL( stateChanged( int ) ), this, SLOT( setCaseString(int) ) );
mCheckbox->setChecked(Qt::Unchecked);
mCaseString = "ILIKE";
}

1 comment on commit b6ae2e7

@3nids

This comment has been minimized.

Copy link
Member

@3nids 3nids commented on b6ae2e7 Jun 29, 2015

The widget is not showing up in the attribute table for a value relation widget. Something changed?

Please sign in to comment.
You can’t perform that action at this time.