Skip to content
Permalink
Browse files
Set delete feature dialog parent. Fixes #5062
  • Loading branch information
NathanW2 committed Feb 21, 2012
1 parent 927dcbd commit 083e4c7338094e79c798793b138c16b4dda1c737
Showing with 14 additions and 9 deletions.
  1. +12 −7 src/app/qgisapp.cpp
  2. +1 −1 src/app/qgisapp.h
  3. +1 −1 src/app/qgsattributetabledialog.cpp
@@ -3512,16 +3512,21 @@ void QgisApp::layerProperties()
showLayerProperties( activeLayer() );
}

void QgisApp::deleteSelected( QgsMapLayer *layer )
void QgisApp::deleteSelected( QgsMapLayer *layer, QWidget* parent )
{
if ( !layer )
{
layer = mMapLegend->currentLayer();
}

if ( !parent )
{
parent = this;
}

if ( !layer )
{
QMessageBox::information( this,
QMessageBox::information( parent,
tr( "No Layer Selected" ),
tr( "To delete features, you must select a vector layer in the legend" ) );
return;
@@ -3530,37 +3535,37 @@ void QgisApp::deleteSelected( QgsMapLayer *layer )
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( layer );
if ( !vlayer )
{
QMessageBox::information( this,
QMessageBox::information( parent,
tr( "No Vector Layer Selected" ),
tr( "Deleting features only works on vector layers" ) );
return;
}

if ( !( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteFeatures ) )
{
QMessageBox::information( this, tr( "Provider does not support deletion" ),
QMessageBox::information( parent, tr( "Provider does not support deletion" ),
tr( "Data provider does not support deleting features" ) );
return;
}

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

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

vlayer->beginEditCommand( tr( "Features deleted" ) );
if ( !vlayer->deleteSelectedFeatures() )
{
QMessageBox::information( this, tr( "Problem deleting features" ),
QMessageBox::information( parent, tr( "Problem deleting features" ),
tr( "A problem occured during deletion of features" ) );
}

@@ -418,7 +418,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
void loadOGRSublayers( QString layertype, QString uri, QStringList list );

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

//! project was written
void writeProject( QDomDocument & );
@@ -246,7 +246,7 @@ void QgsAttributeTableDialog::on_mRemoveSelectionButton_clicked()

void QgsAttributeTableDialog::on_mDeleteSelectedButton_clicked()
{
QgisApp::instance()->deleteSelected( mLayer );
QgisApp::instance()->deleteSelected( mLayer, this );
}

void QgsAttributeTableDialog::on_cbxShowSelectedOnly_toggled( bool theFlag )

0 comments on commit 083e4c7

Please sign in to comment.