Skip to content
Permalink
Browse files

Implements deleteCascade option

  • Loading branch information
pblottiere committed Aug 28, 2017
1 parent f92c23f commit 293f0f41ba9dc740eb146f39879c491d6b632e79
Showing with 27 additions and 0 deletions.
  1. +26 −0 src/core/qgsvectorlayer.cpp
  2. +1 −0 src/core/qgsvectorlayer.h
@@ -2438,6 +2438,9 @@ bool QgsVectorLayer::deleteFeature( QgsFeatureId fid )
if ( !mEditBuffer )
return false;

if ( mJoinBuffer->containsJoins() )
deleteFeaturesFromJoinedLayers( QgsFeatureIds() << fid );

bool res = mEditBuffer->deleteFeature( fid );
if ( res )
{
@@ -2456,6 +2459,9 @@ bool QgsVectorLayer::deleteFeatures( const QgsFeatureIds &fids )
return false;
}

if ( mJoinBuffer->containsJoins() )
deleteFeaturesFromJoinedLayers( fids );

bool res = mEditBuffer->deleteFeatures( fids );

if ( res )
@@ -2467,6 +2473,26 @@ bool QgsVectorLayer::deleteFeatures( const QgsFeatureIds &fids )
return res;
}

bool QgsVectorLayer::deleteFeaturesFromJoinedLayers( QgsFeatureIds fids )
{
bool rc = false;

Q_FOREACH ( const QgsFeatureId &fid, fids )
{
Q_FOREACH ( const QgsVectorLayerJoinInfo &info, vectorJoins() )
{
if ( info.isEditable() && info.isDeleteCascade() )
{
QgsFeature joinFeature = mJoinBuffer->joinedFeatureOf( &info, getFeature( fid ) );
if ( joinFeature.isValid() )
info.joinLayer()->deleteFeature( joinFeature.id() );
}
}
}

return rc;
}

QgsAttributeList QgsVectorLayer::pkAttributeList() const
{
QgsAttributeList pkAttributesList;
@@ -1933,6 +1933,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
QgsAbstractVectorLayerLabeling *readLabelingFromCustomProperties();

bool addFeaturesToJoinedLayers( QgsFeatureList &features, Flags flags = 0 );
bool deleteFeaturesFromJoinedLayers( QgsFeatureIds fids );

#ifdef SIP_RUN
QgsVectorLayer( const QgsVectorLayer &rhs );

0 comments on commit 293f0f4

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