mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-17 00:09:36 -04:00
Only show failing constraint visual feedback when the attribute table is set to filter for invalid features
This commit is contained in:
parent
cda82949f2
commit
77df5b8d8a
@ -247,6 +247,22 @@ Any extra columns need to be implemented by proxy models in front of this model.
|
||||
%Docstring
|
||||
Empty extra columns to announce from this model.
|
||||
Any extra columns need to be implemented by proxy models in front of this model.
|
||||
%End
|
||||
|
||||
bool showValidityState() const;
|
||||
%Docstring
|
||||
Returns whether the attribute table will add a visual feedback to cells when an attribute
|
||||
constraint is not met.
|
||||
|
||||
.. versionadded:: 3.30
|
||||
%End
|
||||
|
||||
void setShowValidityState( const bool &show );
|
||||
%Docstring
|
||||
Sets whether the attribute table will add a visual feedback to cells when an attribute constraint
|
||||
is not met.
|
||||
|
||||
.. versionadded:: 3.30
|
||||
%End
|
||||
|
||||
public slots:
|
||||
|
@ -774,7 +774,7 @@ QVariant QgsAttributeTableModel::data( const QModelIndex &index, int role ) cons
|
||||
const QgsConditionalStyle rowstyle = QgsConditionalStyle::compressStyles( styles );
|
||||
|
||||
QgsConditionalStyle constraintstyle;
|
||||
if ( QgsVectorLayerUtils::attributeHasConstraints( mLayer, fieldId ) )
|
||||
if ( mShowValidityState && QgsVectorLayerUtils::attributeHasConstraints( mLayer, fieldId ) )
|
||||
{
|
||||
if ( mConstraintStylesMap.contains( mFeat.id() ) &&
|
||||
mConstraintStylesMap[mFeat.id()].contains( fieldId ) )
|
||||
|
@ -256,6 +256,20 @@ class GUI_EXPORT QgsAttributeTableModel: public QAbstractTableModel
|
||||
*/
|
||||
void setExtraColumns( int extraColumns );
|
||||
|
||||
/**
|
||||
* Returns whether the attribute table will add a visual feedback to cells when an attribute
|
||||
* constraint is not met.
|
||||
* \since QGIS 3.30
|
||||
*/
|
||||
bool showValidityState() const { return mShowValidityState; }
|
||||
|
||||
/**
|
||||
* Sets whether the attribute table will add a visual feedback to cells when an attribute constraint
|
||||
* is not met.
|
||||
* \since QGIS 3.30
|
||||
*/
|
||||
void setShowValidityState( const bool &show ) { mShowValidityState = show; }
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
@ -403,6 +417,8 @@ class GUI_EXPORT QgsAttributeTableModel: public QAbstractTableModel
|
||||
//! TRUE if triggered by afterRollback()
|
||||
bool mIsCleaningUpAfterRollback = false;
|
||||
|
||||
bool mShowValidityState = false;
|
||||
|
||||
friend class TestQgsAttributeTable;
|
||||
|
||||
};
|
||||
|
@ -328,6 +328,7 @@ void QgsDualView::setFilterMode( QgsAttributeTableFilterModel::FilterMode filter
|
||||
break;
|
||||
|
||||
case QgsAttributeTableFilterModel::ShowInvalid:
|
||||
mMasterModel->setShowValidityState( false );
|
||||
break;
|
||||
}
|
||||
|
||||
@ -368,6 +369,7 @@ void QgsDualView::setFilterMode( QgsAttributeTableFilterModel::FilterMode filter
|
||||
|
||||
case QgsAttributeTableFilterModel::ShowInvalid:
|
||||
{
|
||||
mMasterModel->setShowValidityState( true );
|
||||
const QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( mLayer ) );
|
||||
filterFeatures( QStringLiteral( "is_feature_valid() = false" ), context );
|
||||
connect( mFilterModel, &QgsAttributeTableFilterModel::featuresFiltered, this, &QgsDualView::filterChanged );
|
||||
|
Loading…
x
Reference in New Issue
Block a user