Skip to content
Permalink
Browse files

use getter methods of DeleteContext in gui functions

  • Loading branch information
signedav committed May 11, 2020
1 parent f5d35dd commit 74b5c09af17933b410e4d05210217e0d8187203b
Showing with 17 additions and 15 deletions.
  1. +5 −5 src/app/qgisapp.cpp
  2. +6 −5 src/app/qgsattributetabledialog.cpp
  3. +6 −5 src/gui/qgsrelationeditorwidget.cpp
@@ -9032,16 +9032,16 @@ void QgisApp::deleteSelected( QgsMapLayer *layer, QWidget *parent, bool checkFea
}
else
{
const auto contextLayers = context.handledLayers();
//if it effected more than one layer, print feedback for all descendants
if ( context.mHandledFeatures.size() > 1 )
if ( contextLayers.size() > 1 )
{
deletedCount = 0;
QString feedbackMessage;
QMap<QgsVectorLayer *, QgsFeatureIds>::const_iterator i;
for ( i = context.mHandledFeatures.begin(); i != context.mHandledFeatures.end(); ++i )
for ( QgsVectorLayer *contextLayer : contextLayers )
{
feedbackMessage += tr( " %1 on layer %2." ).arg( i.value().size() ).arg( i.key()->name() );
deletedCount += i.value().size();
feedbackMessage += tr( " %1 on layer %2." ).arg( context.handledFeatures( contextLayer ).size() ).arg( contextLayer->name() );
deletedCount += context.handledFeatures( contextLayer ).size();
}
visibleMessageBar()->pushMessage( tr( "%1 features deleted: %2" ).arg( deletedCount ).arg( feedbackMessage ), Qgis::Success );
}
@@ -887,16 +887,17 @@ void QgsAttributeTableDialog::deleteFeature( const QgsFeatureId fid )

QgsVectorLayer::DeleteContext context { true };
mLayer->deleteFeature( fid, &context );

const auto contextLayers = context.handledLayers();
//if it effected more than one layer, print feedback for all descendants
if ( context.mHandledFeatures.size() > 1 )
if ( contextLayers.size() > 1 )
{
int deletedCount = 0;
QString feedbackMessage;
QMap<QgsVectorLayer *, QgsFeatureIds>::const_iterator i;
for ( i = context.mHandledFeatures.begin(); i != context.mHandledFeatures.end(); ++i )
for ( QgsVectorLayer *contextLayer : contextLayers )
{
feedbackMessage += tr( " %1 on layer %2." ).arg( i.value().size() ).arg( i.key()->name() );
deletedCount += i.value().size();
feedbackMessage += tr( " %1 on layer %2." ).arg( context.handledFeatures( contextLayer ).size() ).arg( contextLayer->name() );
deletedCount += context.handledFeatures( contextLayer ).size();
}
QgisApp::instance()->messageBar()->pushMessage( tr( "%1 features deleted: %2" ).arg( deletedCount ).arg( feedbackMessage ), Qgis::Success );
}
@@ -752,18 +752,19 @@ void QgsRelationEditorWidget::deleteFeatures( const QgsFeatureIds &featureids )
{
QgsVectorLayer::DeleteContext context { true };
layer->deleteFeatures( featureids, &context );
if ( context.mHandledFeatures.size() > 1 )
const auto contextLayers = context.handledLayers();
if ( contextLayers.size() > 1 )
{
int deletedCount = 0;
QString feedbackMessage;
QMap<QgsVectorLayer *, QgsFeatureIds>::const_iterator i;
for ( i = context.mHandledFeatures.begin(); i != context.mHandledFeatures.end(); ++i )
for ( QgsVectorLayer *contextLayer : contextLayers )
{
feedbackMessage += tr( " %1 on layer %2." ).arg( i.value().size() ).arg( i.key()->name() );
deletedCount += i.value().size();
feedbackMessage += tr( " %1 on layer %2." ).arg( context.handledFeatures( contextLayer ).size() ).arg( contextLayer->name() );
deletedCount += context.handledFeatures( contextLayer ).size();
}
mEditorContext.mainMessageBar()->pushMessage( tr( "%1 features deleted: %2" ).arg( deletedCount ).arg( feedbackMessage ), Qgis::Success );
}

updateUi();
}
}

0 comments on commit 74b5c09

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