Skip to content

Commit

Permalink
reload visible filter on dataChange of table model and use the same (…
Browse files Browse the repository at this point in the history
…renamed) slot (extendsChanged to reloadVisibleChanged
  • Loading branch information
signedav committed Mar 16, 2020
1 parent afbb37f commit 18dddff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Expand Up @@ -234,9 +234,10 @@ selection state of the feature in case selected features are to be shown on top.

public slots:

void extentsChanged();
void reloadVisible();
%Docstring
Is called upon every change of the visible extents on the map canvas.
Is called upon every change of the visible extents on the map canvas or when data of
the master table model changes.
When a change is signalled, the filter is updated and invalidated if needed.
%End

Expand Down
8 changes: 5 additions & 3 deletions src/gui/attributetable/qgsattributetablefiltermodel.cpp
Expand Up @@ -313,12 +313,14 @@ void QgsAttributeTableFilterModel::setFilterMode( FilterMode filterMode )
{
if ( filterMode == ShowVisible )
{
connect( mCanvas, &QgsMapCanvas::extentsChanged, this, &QgsAttributeTableFilterModel::extentsChanged );
connect( mCanvas, &QgsMapCanvas::extentsChanged, this, &QgsAttributeTableFilterModel::reloadVisible );
connect( mTableModel, &QgsAttributeTableModel::dataChanged, this, &QgsAttributeTableFilterModel::reloadVisible );
generateListOfVisibleFeatures();
}
else
{
disconnect( mCanvas, &QgsMapCanvas::extentsChanged, this, &QgsAttributeTableFilterModel::extentsChanged );
disconnect( mCanvas, &QgsMapCanvas::extentsChanged, this, &QgsAttributeTableFilterModel::reloadVisible );
disconnect( mTableModel, &QgsAttributeTableModel::dataChanged, this, &QgsAttributeTableFilterModel::reloadVisible );
}

mFilterMode = filterMode;
Expand Down Expand Up @@ -371,7 +373,7 @@ bool QgsAttributeTableFilterModel::filterAcceptsRow( int sourceRow, const QModel
// returns are handled in their respective case statement above
}

void QgsAttributeTableFilterModel::extentsChanged()
void QgsAttributeTableFilterModel::reloadVisible()
{
generateListOfVisibleFeatures();
invalidateFilter();
Expand Down
5 changes: 3 additions & 2 deletions src/gui/attributetable/qgsattributetablefiltermodel.h
Expand Up @@ -255,10 +255,11 @@ class GUI_EXPORT QgsAttributeTableFilterModel: public QSortFilterProxyModel, pub
public slots:

/**
* Is called upon every change of the visible extents on the map canvas.
* Is called upon every change of the visible extents on the map canvas or when data of
* the master table model changes.
* When a change is signalled, the filter is updated and invalidated if needed.
*/
void extentsChanged();
void reloadVisible();

private slots:
void selectionChanged();
Expand Down

0 comments on commit 18dddff

Please sign in to comment.