mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Implements deleteCascade option
This commit is contained in:
parent
f92c23fdfb
commit
293f0f41ba
@ -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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user