mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Allow expression widget to be empty so expression could be removed (#9032)
* fixes #20516 : Allow Constraint widget in attribute type form to be empty so expression could be removed per widget modification * correct tests * Add the clear button on field expression widget when widget is allowed to be empty * Change API since version to 3.6
This commit is contained in:
parent
eceaea8c35
commit
1c34329234
@ -55,6 +55,24 @@ Returns the title used for the expression dialog
|
||||
void setFilters( QgsFieldProxyModel::Filters filters );
|
||||
%Docstring
|
||||
setFilters allows fitering according to the type of field
|
||||
%End
|
||||
|
||||
void setAllowEmptyFieldName( bool allowEmpty );
|
||||
%Docstring
|
||||
Sets whether an optional empty field ("not set") option is shown in the combo box.
|
||||
|
||||
.. seealso:: :py:func:`allowEmptyFieldName`
|
||||
|
||||
.. versionadded:: 3.6
|
||||
%End
|
||||
|
||||
bool allowEmptyFieldName() const;
|
||||
%Docstring
|
||||
Returns true if the combo box allows the empty field ("not set") choice.
|
||||
|
||||
.. seealso:: :py:func:`setAllowEmptyFieldName`
|
||||
|
||||
.. versionadded:: 3.6
|
||||
%End
|
||||
|
||||
void setLeftHandButtonStyle( bool isLeft );
|
||||
|
@ -91,6 +91,7 @@ QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx
|
||||
QgsSettings settings;
|
||||
restoreGeometry( settings.value( QStringLiteral( "Windows/QgsAttributeTypeDialog/geometry" ) ).toByteArray() );
|
||||
|
||||
constraintExpressionWidget->setAllowEmptyFieldName( true );
|
||||
constraintExpressionWidget->setLayer( vl );
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,17 @@ void QgsFieldExpressionWidget::setFilters( QgsFieldProxyModel::Filters filters )
|
||||
mFieldProxyModel->setFilters( filters );
|
||||
}
|
||||
|
||||
void QgsFieldExpressionWidget::setAllowEmptyFieldName( bool allowEmpty )
|
||||
{
|
||||
mCombo->lineEdit()->setClearButtonEnabled( allowEmpty );
|
||||
mFieldProxyModel->sourceFieldModel()->setAllowEmptyFieldName( allowEmpty );
|
||||
}
|
||||
|
||||
bool QgsFieldExpressionWidget::allowEmptyFieldName() const
|
||||
{
|
||||
return mFieldProxyModel->sourceFieldModel()->allowEmptyFieldName();
|
||||
}
|
||||
|
||||
void QgsFieldExpressionWidget::setLeftHandButtonStyle( bool isLeft )
|
||||
{
|
||||
QHBoxLayout *layout = dynamic_cast<QHBoxLayout *>( this->layout() );
|
||||
|
@ -48,6 +48,7 @@ class GUI_EXPORT QgsFieldExpressionWidget : public QWidget
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( QString expressionDialogTitle READ expressionDialogTitle WRITE setExpressionDialogTitle )
|
||||
Q_PROPERTY( QgsFieldProxyModel::Filters filters READ filters WRITE setFilters )
|
||||
Q_PROPERTY( bool allowEmptyFieldName READ allowEmptyFieldName WRITE setAllowEmptyFieldName )
|
||||
Q_PROPERTY( bool allowEvalErrors READ allowEvalErrors WRITE setAllowEvalErrors NOTIFY allowEvalErrorsChanged )
|
||||
|
||||
public:
|
||||
@ -75,6 +76,20 @@ class GUI_EXPORT QgsFieldExpressionWidget : public QWidget
|
||||
//! setFilters allows fitering according to the type of field
|
||||
void setFilters( QgsFieldProxyModel::Filters filters );
|
||||
|
||||
/**
|
||||
* Sets whether an optional empty field ("not set") option is shown in the combo box.
|
||||
* \see allowEmptyFieldName()
|
||||
* \since QGIS 3.6
|
||||
*/
|
||||
void setAllowEmptyFieldName( bool allowEmpty );
|
||||
|
||||
/**
|
||||
* Returns true if the combo box allows the empty field ("not set") choice.
|
||||
* \see setAllowEmptyFieldName()
|
||||
* \since QGIS 3.6
|
||||
*/
|
||||
bool allowEmptyFieldName() const;
|
||||
|
||||
void setLeftHandButtonStyle( bool isLeft );
|
||||
|
||||
//! currently used filter on list of fields
|
||||
|
@ -332,5 +332,3 @@ void TestQgsFieldExpressionWidget::setNull()
|
||||
|
||||
QGSTEST_MAIN( TestQgsFieldExpressionWidget )
|
||||
#include "testqgsfieldexpressionwidget.moc"
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user