Skip to content
Permalink
Browse files

project in the DeleteContext

  • Loading branch information
signedav committed May 13, 2020
1 parent 5a21574 commit 3ea7b28aeae96b6892517ad662074911b913f8b5
@@ -377,7 +377,7 @@ Constructor for LayerOptions.
struct DeleteContext
{

explicit DeleteContext( bool cascade = false );
explicit DeleteContext( bool cascade = false, QgsProject *project = 0 );
%Docstring
Constructor for DeleteContext.
%End
@@ -386,6 +386,7 @@ Constructor for DeleteContext.
QgsFeatureIds handledFeatures( QgsVectorLayer *layer ) const;

bool cascade;
QgsProject *project;
};

explicit QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
@@ -9023,7 +9023,7 @@ void QgisApp::deleteSelected( QgsMapLayer *layer, QWidget *parent, bool checkFea

vlayer->beginEditCommand( tr( "Features deleted" ) );
int deletedCount = 0;
QgsVectorLayer::DeleteContext context { true };
QgsVectorLayer::DeleteContext context( true, QgsProject::instance() );
if ( !vlayer->deleteSelectedFeatures( &deletedCount, &context ) )
{
visibleMessageBar()->pushMessage( tr( "Problem deleting features" ),
@@ -885,9 +885,8 @@ void QgsAttributeTableDialog::deleteFeature( const QgsFeatureId fid )
return;
}

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

const auto contextLayers = context.handledLayers();
//if it effected more than one layer, print feedback for all descendants
if ( contextLayers.size() > 1 )
@@ -3192,7 +3192,7 @@ bool QgsVectorLayer::deleteFeatureCascade( QgsFeatureId fid, QgsVectorLayer::Del
context->mHandledFeatures.insert( this, QgsFeatureIds() << fid );
}

const QList<QgsRelation> relations = QgsProject::instance()->relationManager()->referencedRelations( this );
const QList<QgsRelation> relations = context->project->relationManager()->referencedRelations( this );

for ( const QgsRelation &relation : relations )
{
@@ -514,13 +514,14 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
/**
* Constructor for DeleteContext.
*/
explicit DeleteContext( bool cascade = false ): cascade( cascade ) {}
explicit DeleteContext( bool cascade = false, QgsProject *project = nullptr ): cascade( cascade ), project( project ) {}

QList<QgsVectorLayer *> handledLayers() const;
QgsFeatureIds handledFeatures( QgsVectorLayer *layer ) const;

QMap<QgsVectorLayer *, QgsFeatureIds> mHandledFeatures SIP_SKIP;
bool cascade;
QgsProject *project;
};

/**
@@ -750,7 +750,7 @@ void QgsRelationEditorWidget::deleteFeatures( const QgsFeatureIds &featureids )

if ( deleteFeatures )
{
QgsVectorLayer::DeleteContext context { true };
QgsVectorLayer::DeleteContext context( true, QgsProject::instance() );
layer->deleteFeatures( featureids, &context );
const auto contextLayers = context.handledLayers();
if ( contextLayers.size() > 1 )

0 comments on commit 3ea7b28

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