Skip to content
Permalink
Browse files

Proper setup of connections

  • Loading branch information
signedav committed May 1, 2020
1 parent ef379f3 commit 11cd02295f4f444cbbc7e4f91903505b68205b6d
Showing with 27 additions and 15 deletions.
  1. +27 −15 src/gui/attributetable/qgsattributetablefiltermodel.cpp
@@ -318,25 +318,37 @@ void QgsAttributeTableFilterModel::setFilterMode( FilterMode filterMode )
{
if ( filterMode != mFilterMode )
{
if ( filterMode == ShowVisible )
// cleanup existing connections
switch ( mFilterMode )
{
connect( mCanvas, &QgsMapCanvas::extentsChanged, this, &QgsAttributeTableFilterModel::reloadVisible );
connect( mTableModel, &QgsAttributeTableModel::dataChanged, this, &QgsAttributeTableFilterModel::reloadVisible );
generateListOfVisibleFeatures();
}
else
{
disconnect( mCanvas, &QgsMapCanvas::extentsChanged, this, &QgsAttributeTableFilterModel::reloadVisible );
disconnect( mTableModel, &QgsAttributeTableModel::dataChanged, this, &QgsAttributeTableFilterModel::reloadVisible );
case ShowVisible:
disconnect( mCanvas, &QgsMapCanvas::extentsChanged, this, &QgsAttributeTableFilterModel::reloadVisible );
disconnect( mTableModel, &QgsAttributeTableModel::dataChanged, this, &QgsAttributeTableFilterModel::reloadVisible );
break;
case ShowAll:
case ShowEdited:
case ShowSelected:
break;
case ShowFilteredList:
disconnect( mTableModel, &QgsAttributeTableModel::dataChanged, this, &QgsAttributeTableFilterModel::filterFeatures );
break;
}

if ( filterMode == ShowFilteredList )
// setup new connections
switch ( filterMode )
{
connect( mTableModel, &QgsAttributeTableModel::dataChanged, this, &QgsAttributeTableFilterModel::filterFeatures );
}
else
{
disconnect( mTableModel, &QgsAttributeTableModel::dataChanged, this, &QgsAttributeTableFilterModel::filterFeatures );
case ShowVisible:
connect( mCanvas, &QgsMapCanvas::extentsChanged, this, &QgsAttributeTableFilterModel::reloadVisible );
connect( mTableModel, &QgsAttributeTableModel::dataChanged, this, &QgsAttributeTableFilterModel::reloadVisible );
generateListOfVisibleFeatures();
break;
case ShowAll:
case ShowEdited:
case ShowSelected:
break;
case ShowFilteredList:
connect( mTableModel, &QgsAttributeTableModel::dataChanged, this, &QgsAttributeTableFilterModel::filterFeatures );
break;
}

mFilterMode = filterMode;

0 comments on commit 11cd022

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