Skip to content
Permalink
Browse files

feedback messages on delete cascade

  • Loading branch information
signedav committed May 7, 2020
1 parent 79d8601 commit 73b1b2d830f38302e05cac568cae7b8309bdc3cf
Showing with 45 additions and 4 deletions.
  1. +15 −1 src/app/qgisapp.cpp
  2. +13 −0 src/app/qgsattributetabledialog.cpp
  3. +5 −3 src/core/qgsvectorlayer.cpp
  4. +12 −0 src/gui/qgsrelationeditorwidget.cpp
@@ -9012,7 +9012,21 @@ void QgisApp::deleteSelected( QgsMapLayer *layer, QWidget *parent, bool checkFea
}
else
{
showStatusMessage( tr( "%n feature(s) deleted.", "number of features deleted", numberOfSelectedFeatures ) );
//if it effected more than one layer, print feedback for all descendants
if ( context.handledFeatures.count() > 1 )
{
deletedCount = 0;
QString feedbackMessage;
QMap<QgsVectorLayer *, QgsFeatureIds>::const_iterator i;
for ( i = context.handledFeatures.begin(); i != context.handledFeatures.end(); ++i )
{
feedbackMessage += tr( " %1 on layer %2." ).arg( i.value().count() ).arg( i.key()->name() );
deletedCount += i.value().count();
}
visibleMessageBar()->pushMessage( tr( "%1 features deleted: %2" ).arg( deletedCount ).arg( feedbackMessage ), Qgis::Success );
}

showStatusMessage( tr( "%n feature(s) deleted.", "number of features deleted", deletedCount ) );
}

vlayer->endEditCommand();
@@ -866,6 +866,19 @@ void QgsAttributeTableDialog::deleteFeature( const QgsFeatureId fid )
QgsDebugMsg( QStringLiteral( "Delete %1" ).arg( fid ) );
QgsVectorLayer::DeleteContext context { true };
mLayer->deleteFeature( fid, &context );
//if it effected more than one layer, print feedback for all descendants
if ( context.handledFeatures.count() > 1 )
{
int deletedCount = 0;
QString feedbackMessage;
QMap<QgsVectorLayer *, QgsFeatureIds>::const_iterator i;
for ( i = context.handledFeatures.begin(); i != context.handledFeatures.end(); ++i )
{
feedbackMessage += tr( " %1 on layer %2." ).arg( i.value().count() ).arg( i.key()->name() );
deletedCount += i.value().count();
}
QgisApp::instance()->messageBar()->pushMessage( tr( "%1 features deleted: %2" ).arg( deletedCount ).arg( feedbackMessage ), Qgis::Success );
}
}

void QgsAttributeTableDialog::showContextMenu( QgsActionMenu *menu, const QgsFeatureId fid )
@@ -3207,9 +3207,11 @@ bool QgsVectorLayer::deleteFeatureCascade( QgsFeatureId fid, QgsVectorLayer::Del
{
childFeatureIds.insert( childFeature.id() );
}

relation.referencingLayer()->startEditing();
relation.referencingLayer()->deleteFeatures( childFeatureIds, context );
if ( childFeatureIds.count() > 0 )
{
relation.referencingLayer()->startEditing();
relation.referencingLayer()->deleteFeatures( childFeatureIds, context );
}
}
}
}
@@ -732,6 +732,18 @@ void QgsRelationEditorWidget::deleteFeatures( const QgsFeatureIds &featureids )
{
QgsVectorLayer::DeleteContext context { true };
layer->deleteFeatures( featureids, &context );
if ( context.handledFeatures.count() > 1 )
{
int deletedCount = 0;
QString feedbackMessage;
QMap<QgsVectorLayer *, QgsFeatureIds>::const_iterator i;
for ( i = context.handledFeatures.begin(); i != context.handledFeatures.end(); ++i )
{
feedbackMessage += tr( " %1 on layer %2." ).arg( i.value().count() ).arg( i.key()->name() );
deletedCount += i.value().count();
}
mEditorContext.mainMessageBar()->pushMessage( tr( "%1 features deleted: %2" ).arg( deletedCount ).arg( feedbackMessage ), Qgis::Success );
}
updateUi();
}
}

0 comments on commit 73b1b2d

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