Skip to content

Commit 083e4c7

Browse files
committed
Set delete feature dialog parent. Fixes #5062
1 parent 927dcbd commit 083e4c7

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/app/qgisapp.cpp

+12-7
Original file line numberDiff line numberDiff line change
@@ -3512,16 +3512,21 @@ void QgisApp::layerProperties()
35123512
showLayerProperties( activeLayer() );
35133513
}
35143514

3515-
void QgisApp::deleteSelected( QgsMapLayer *layer )
3515+
void QgisApp::deleteSelected( QgsMapLayer *layer, QWidget* parent )
35163516
{
35173517
if ( !layer )
35183518
{
35193519
layer = mMapLegend->currentLayer();
35203520
}
35213521

3522+
if ( !parent )
3523+
{
3524+
parent = this;
3525+
}
3526+
35223527
if ( !layer )
35233528
{
3524-
QMessageBox::information( this,
3529+
QMessageBox::information( parent,
35253530
tr( "No Layer Selected" ),
35263531
tr( "To delete features, you must select a vector layer in the legend" ) );
35273532
return;
@@ -3530,37 +3535,37 @@ void QgisApp::deleteSelected( QgsMapLayer *layer )
35303535
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( layer );
35313536
if ( !vlayer )
35323537
{
3533-
QMessageBox::information( this,
3538+
QMessageBox::information( parent,
35343539
tr( "No Vector Layer Selected" ),
35353540
tr( "Deleting features only works on vector layers" ) );
35363541
return;
35373542
}
35383543

35393544
if ( !( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteFeatures ) )
35403545
{
3541-
QMessageBox::information( this, tr( "Provider does not support deletion" ),
3546+
QMessageBox::information( parent, tr( "Provider does not support deletion" ),
35423547
tr( "Data provider does not support deleting features" ) );
35433548
return;
35443549
}
35453550

35463551
if ( !vlayer->isEditable() )
35473552
{
3548-
QMessageBox::information( this, tr( "Layer not editable" ),
3553+
QMessageBox::information( parent, tr( "Layer not editable" ),
35493554
tr( "The current layer is not editable. Choose 'Start editing' in the digitizing toolbar." ) );
35503555
return;
35513556
}
35523557

35533558
//display a warning
35543559
int numberOfDeletedFeatures = vlayer->selectedFeaturesIds().size();
3555-
if ( QMessageBox::warning( this, tr( "Delete features" ), tr( "Delete %n feature(s)?", "number of features to delete", numberOfDeletedFeatures ), QMessageBox::Ok, QMessageBox::Cancel ) == QMessageBox::Cancel )
3560+
if ( QMessageBox::warning( parent, tr( "Delete features" ), tr( "Delete %n feature(s)?", "number of features to delete", numberOfDeletedFeatures ), QMessageBox::Ok, QMessageBox::Cancel ) == QMessageBox::Cancel )
35563561
{
35573562
return;
35583563
}
35593564

35603565
vlayer->beginEditCommand( tr( "Features deleted" ) );
35613566
if ( !vlayer->deleteSelectedFeatures() )
35623567
{
3563-
QMessageBox::information( this, tr( "Problem deleting features" ),
3568+
QMessageBox::information( parent, tr( "Problem deleting features" ),
35643569
tr( "A problem occured during deletion of features" ) );
35653570
}
35663571

src/app/qgisapp.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
418418
void loadOGRSublayers( QString layertype, QString uri, QStringList list );
419419

420420
/**Deletes the selected attributes for the currently selected vector layer*/
421-
void deleteSelected( QgsMapLayer *layer = 0 );
421+
void deleteSelected( QgsMapLayer *layer = 0, QWidget* parent = 0 );
422422

423423
//! project was written
424424
void writeProject( QDomDocument & );

src/app/qgsattributetabledialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ void QgsAttributeTableDialog::on_mRemoveSelectionButton_clicked()
246246

247247
void QgsAttributeTableDialog::on_mDeleteSelectedButton_clicked()
248248
{
249-
QgisApp::instance()->deleteSelected( mLayer );
249+
QgisApp::instance()->deleteSelected( mLayer, this );
250250
}
251251

252252
void QgsAttributeTableDialog::on_cbxShowSelectedOnly_toggled( bool theFlag )

0 commit comments

Comments
 (0)