mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
parent
2722b7ccf3
commit
d79e1a9795
@ -234,6 +234,13 @@ Emitted when the filtering of the features has been done
|
||||
void visibleReloaded();
|
||||
%Docstring
|
||||
Emitted when the the visible features on extend are reloaded (the list is created)
|
||||
%End
|
||||
|
||||
void filterError( const QString &errorMessage );
|
||||
%Docstring
|
||||
Emitted when an error occurred while filtering features
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
@ -503,6 +503,9 @@ void QgsAttributeTableFilterModel::filterFeatures()
|
||||
|
||||
QgsFeature f;
|
||||
|
||||
// Record the first evaluation error
|
||||
QString error;
|
||||
|
||||
while ( featIt.nextFeature( f ) )
|
||||
{
|
||||
mFilterExpressionContext.setFeature( f );
|
||||
@ -510,8 +513,10 @@ void QgsAttributeTableFilterModel::filterFeatures()
|
||||
filteredFeatures << f.id();
|
||||
|
||||
// check if there were errors during evaluating
|
||||
if ( mFilterExpression.hasEvalError() )
|
||||
break;
|
||||
if ( mFilterExpression.hasEvalError() && error.isEmpty() )
|
||||
{
|
||||
error = mFilterExpression.evalErrorString( );
|
||||
}
|
||||
}
|
||||
|
||||
featIt.close();
|
||||
@ -521,6 +526,12 @@ void QgsAttributeTableFilterModel::filterFeatures()
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
emit featuresFiltered();
|
||||
|
||||
if ( ! error.isEmpty() )
|
||||
{
|
||||
emit filterError( error );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -258,6 +258,12 @@ class GUI_EXPORT QgsAttributeTableFilterModel: public QSortFilterProxyModel, pub
|
||||
*/
|
||||
void visibleReloaded();
|
||||
|
||||
/**
|
||||
* Emitted when an error occurred while filtering features
|
||||
* \since QGIS 3.18
|
||||
*/
|
||||
void filterError( const QString &errorMessage );
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
#include "qgsshortcutsmanager.h"
|
||||
#include "qgsfieldconditionalformatwidget.h"
|
||||
#include "qgsmapcanvasutils.h"
|
||||
#include "qgsmessagebar.h"
|
||||
|
||||
|
||||
QgsDualView::QgsDualView( QWidget *parent )
|
||||
@ -293,6 +294,7 @@ void QgsDualView::setFilterMode( QgsAttributeTableFilterModel::FilterMode filter
|
||||
case QgsAttributeTableFilterModel::ShowEdited:
|
||||
case QgsAttributeTableFilterModel::ShowFilteredList:
|
||||
disconnect( mFilterModel, &QgsAttributeTableFilterModel::featuresFiltered, this, &QgsDualView::filterChanged );
|
||||
disconnect( mFilterModel, &QgsAttributeTableFilterModel::filterError, this, &QgsDualView::filterError );
|
||||
break;
|
||||
|
||||
case QgsAttributeTableFilterModel::ShowSelected:
|
||||
@ -332,6 +334,7 @@ void QgsDualView::setFilterMode( QgsAttributeTableFilterModel::FilterMode filter
|
||||
case QgsAttributeTableFilterModel::ShowEdited:
|
||||
case QgsAttributeTableFilterModel::ShowFilteredList:
|
||||
connect( mFilterModel, &QgsAttributeTableFilterModel::featuresFiltered, this, &QgsDualView::filterChanged );
|
||||
connect( mFilterModel, &QgsAttributeTableFilterModel::filterError, this, &QgsDualView::filterError );
|
||||
break;
|
||||
|
||||
case QgsAttributeTableFilterModel::ShowSelected:
|
||||
@ -599,6 +602,14 @@ void QgsDualView::flashButtonClicked( bool clicked )
|
||||
canvas->flashFeatureIds( mLayer, mFeatureListView->currentEditSelection() );
|
||||
}
|
||||
|
||||
void QgsDualView::filterError( const QString &errorMessage )
|
||||
{
|
||||
if ( mEditorContext.mainMessageBar() )
|
||||
{
|
||||
mEditorContext.mainMessageBar()->pushWarning( tr( "An error occurred while filtering features" ), errorMessage );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsDualView::featureListAboutToChangeEditSelection( bool &ok )
|
||||
{
|
||||
if ( mLayer->isEditable() && !mAttributeForm->save() )
|
||||
|
||||
@ -388,6 +388,8 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas
|
||||
|
||||
void flashButtonClicked( bool clicked );
|
||||
|
||||
void filterError( const QString &errorMessage );
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user