mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
[search widgets] when selecting _Please select_ find all features
This commit is contained in:
parent
b2034f2ea6
commit
31ac9be340
@ -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() ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user