Skip to content
Permalink
Browse files

slots to filter features only if there changed something relevant

  • Loading branch information
signedav committed May 4, 2020
1 parent e303d1f commit 92547edb9ed2852ff5a44027b6b34487e964b961
@@ -333,7 +333,8 @@ void QgsAttributeTableFilterModel::setFilterMode( FilterMode filterMode )
break;
case ShowFilteredList:
disconnect( layer(), &QgsVectorLayer::featureAdded, this, &QgsAttributeTableFilterModel::filterFeatures );
disconnect( layer(), &QgsVectorLayer::attributeValueChanged, this, &QgsAttributeTableFilterModel::filterFeatures );
disconnect( layer(), &QgsVectorLayer::attributeValueChanged, this, &QgsAttributeTableFilterModel::onAttributeValueChanged );
disconnect( layer(), &QgsVectorLayer::geometryChanged, this, &QgsAttributeTableFilterModel::onGeometryChanged );
disconnect( mTableModel, &QgsAttributeTableModel::finished, this, &QgsAttributeTableFilterModel::filterFeatures );
break;
}
@@ -354,7 +355,8 @@ void QgsAttributeTableFilterModel::setFilterMode( FilterMode filterMode )
break;
case ShowFilteredList:
connect( layer(), &QgsVectorLayer::featureAdded, this, &QgsAttributeTableFilterModel::filterFeatures );
connect( layer(), &QgsVectorLayer::attributeValueChanged, this, &QgsAttributeTableFilterModel::filterFeatures );
connect( layer(), &QgsVectorLayer::attributeValueChanged, this, &QgsAttributeTableFilterModel::onAttributeValueChanged );
connect( layer(), &QgsVectorLayer::geometryChanged, this, &QgsAttributeTableFilterModel::onGeometryChanged );
connect( mTableModel, &QgsAttributeTableModel::finished, this, &QgsAttributeTableFilterModel::filterFeatures );
break;
}
@@ -420,6 +422,25 @@ void QgsAttributeTableFilterModel::reloadVisible()
invalidateFilter();
}

void QgsAttributeTableFilterModel::onAttributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value )
{
Q_UNUSED( fid );
Q_UNUSED( value );

if ( mFilterExpression.referencedAttributeIndexes( layer()->fields() ).contains( idx ) )
{
filterFeatures();
}
}

void QgsAttributeTableFilterModel::onGeometryChanged()
{
if ( mFilterExpression.needsGeometry() )
{
filterFeatures();
}
}

void QgsAttributeTableFilterModel::filterFeatures()
{
if ( !mFilterExpression.isValid() )
@@ -282,6 +282,8 @@ class GUI_EXPORT QgsAttributeTableFilterModel: public QSortFilterProxyModel, pub
void selectionChanged();
void onColumnsChanged();
void reloadVisible();
void onAttributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value );
void onGeometryChanged();

private:
QgsFeatureIds mFilteredFeatures;

0 comments on commit 92547ed

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