Skip to content

Commit

Permalink
getter for handledFeatures in DeleteContext
Browse files Browse the repository at this point in the history
  • Loading branch information
signedav committed May 11, 2020
1 parent 3c963ab commit d6a038b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
8 changes: 6 additions & 2 deletions python/core/auto_generated/qgsvectorlayer.sip.in
Expand Up @@ -374,15 +374,19 @@ Constructor for LayerOptions.

};

struct DeleteContext
struct DeleteContext
{

explicit DeleteContext( bool cascade = false );
%Docstring
Constructor for DeleteContext.
%End

QMap<QgsVectorLayer *, QgsFeatureIds> handledFeatures;
QMap<QgsVectorLayer *, QgsFeatureIds> handledFeatures();
%Docstring
Returns all the layers on which features have been deleted
%End

bool cascade;
};

Expand Down
8 changes: 4 additions & 4 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -3171,9 +3171,9 @@ bool QgsVectorLayer::deleteFeatureCascade( QgsFeatureId fid, QgsVectorLayer::Del

if ( context && context->cascade )
{
if ( context->handledFeatures.contains( this ) )
if ( context->mHandledFeatures.contains( this ) )
{
QgsFeatureIds handledFeatureIds = context->handledFeatures.value( this );
QgsFeatureIds handledFeatureIds = context->mHandledFeatures.value( this );
if ( handledFeatureIds.contains( fid ) )
{
// avoid endless recursion
Expand All @@ -3183,13 +3183,13 @@ bool QgsVectorLayer::deleteFeatureCascade( QgsFeatureId fid, QgsVectorLayer::Del
{
// add feature id
handledFeatureIds << fid;
context->handledFeatures.insert( this, handledFeatureIds );
context->mHandledFeatures.insert( this, handledFeatureIds );
}
}
else
{
// add layer and feature id
context->handledFeatures.insert( this, QgsFeatureIds() << fid );
context->mHandledFeatures.insert( this, QgsFeatureIds() << fid );
}

const QList<QgsRelation> relations = QgsProject::instance()->relationManager()->referencedRelations( this );
Expand Down
11 changes: 8 additions & 3 deletions src/core/qgsvectorlayer.h
Expand Up @@ -508,16 +508,21 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* Context for deleting features
* \since QGIS 3.14
*/
struct DeleteContext
struct DeleteContext
{

/**
* Constructor for DeleteContext.
*/
explicit DeleteContext( bool cascade = false ): cascade( cascade ) {}

QMap<QgsVectorLayer *, QgsFeatureIds> handledFeatures;
bool cascade ;
/**
* Returns all the layers on which features have been deleted
*/
QMap<QgsVectorLayer *, QgsFeatureIds> handledFeatures() { return mHandledFeatures; }

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

/**
Expand Down

0 comments on commit d6a038b

Please sign in to comment.