Skip to content
Permalink
Browse files

[search widgets] when selecting _Please select_ find all features

  • Loading branch information
3nids committed Nov 13, 2015
1 parent b2034f2 commit 31ac9be340e724ab777b2dc487a1a3817ed5b67c
@@ -33,3 +33,8 @@ void QgsSearchWidgetWrapper::setFeature( const QgsFeature& feature )
Q_UNUSED( feature )
}

void QgsSearchWidgetWrapper::clearExpression()
{
mExpression = QString( "TRUE" );
}

@@ -81,6 +81,9 @@ class GUI_EXPORT QgsSearchWidgetWrapper : public QgsWidgetWrapper
void setFeature( const QgsFeature& feature ) override;

protected:
//! clears the expression to search for all features
void clearExpression();

QString mExpression;
int mFieldIdx;

@@ -37,7 +37,14 @@ void QgsValueMapSearchWidgetWrapper::comboBoxIndexChanged( int idx )
{
if ( mComboBox )
{
setExpression( mComboBox->itemData( idx ).toString() );
if ( idx == 0 )
{
clearExpression();
}
else
{
setExpression( mComboBox->itemData( idx ).toString() );
}
emit expressionChanged( mExpression );
}
}
@@ -97,8 +97,15 @@ bool QgsValueRelationSearchWidgetWrapper::valid()
void QgsValueRelationSearchWidgetWrapper::valueChanged()
{
QVariant vl = value();
QSettings settings;
setExpression( vl.isNull() ? settings.value( "qgis/nullValue", "NULL" ).toString() : vl.toString() );
if ( !vl.isValid() )
{
clearExpression();
}
else
{
QSettings settings;
setExpression( vl.isNull() ? settings.value( "qgis/nullValue", "NULL" ).toString() : vl.toString() );
}
emit expressionChanged( mExpression );
}

@@ -149,7 +156,7 @@ void QgsValueRelationSearchWidgetWrapper::initWidget( QWidget* editor )

if ( mComboBox )
{
mComboBox->addItem( tr( "Please select" ), QVariant( layer()->fields().at( mFieldIdx ).type() ) );
mComboBox->addItem( tr( "Please select" ), QVariant() ); // creates an invalid to allow selecting all features
if ( config( "AllowNull" ).toBool() )
{
mComboBox->addItem( tr( "(no selection)" ), QVariant( layer()->fields().at( mFieldIdx ).type() ) );

0 comments on commit 31ac9be

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