mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-03 00:02:25 -05:00
project in the DeleteContext
This commit is contained in:
parent
5a21574518
commit
3ea7b28aea
@ -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 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user