mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Set delete feature dialog parent. Fixes #5062
This commit is contained in:
parent
927dcbd755
commit
083e4c7338
@ -3512,16 +3512,21 @@ void QgisApp::layerProperties()
|
|||||||
showLayerProperties( activeLayer() );
|
showLayerProperties( activeLayer() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgisApp::deleteSelected( QgsMapLayer *layer )
|
void QgisApp::deleteSelected( QgsMapLayer *layer, QWidget* parent )
|
||||||
{
|
{
|
||||||
if ( !layer )
|
if ( !layer )
|
||||||
{
|
{
|
||||||
layer = mMapLegend->currentLayer();
|
layer = mMapLegend->currentLayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !parent )
|
||||||
|
{
|
||||||
|
parent = this;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !layer )
|
if ( !layer )
|
||||||
{
|
{
|
||||||
QMessageBox::information( this,
|
QMessageBox::information( parent,
|
||||||
tr( "No Layer Selected" ),
|
tr( "No Layer Selected" ),
|
||||||
tr( "To delete features, you must select a vector layer in the legend" ) );
|
tr( "To delete features, you must select a vector layer in the legend" ) );
|
||||||
return;
|
return;
|
||||||
@ -3530,7 +3535,7 @@ void QgisApp::deleteSelected( QgsMapLayer *layer )
|
|||||||
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( layer );
|
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( layer );
|
||||||
if ( !vlayer )
|
if ( !vlayer )
|
||||||
{
|
{
|
||||||
QMessageBox::information( this,
|
QMessageBox::information( parent,
|
||||||
tr( "No Vector Layer Selected" ),
|
tr( "No Vector Layer Selected" ),
|
||||||
tr( "Deleting features only works on vector layers" ) );
|
tr( "Deleting features only works on vector layers" ) );
|
||||||
return;
|
return;
|
||||||
@ -3538,21 +3543,21 @@ void QgisApp::deleteSelected( QgsMapLayer *layer )
|
|||||||
|
|
||||||
if ( !( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteFeatures ) )
|
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" ) );
|
tr( "Data provider does not support deleting features" ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !vlayer->isEditable() )
|
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." ) );
|
tr( "The current layer is not editable. Choose 'Start editing' in the digitizing toolbar." ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//display a warning
|
//display a warning
|
||||||
int numberOfDeletedFeatures = vlayer->selectedFeaturesIds().size();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
@ -3560,7 +3565,7 @@ void QgisApp::deleteSelected( QgsMapLayer *layer )
|
|||||||
vlayer->beginEditCommand( tr( "Features deleted" ) );
|
vlayer->beginEditCommand( tr( "Features deleted" ) );
|
||||||
if ( !vlayer->deleteSelectedFeatures() )
|
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" ) );
|
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 );
|
void loadOGRSublayers( QString layertype, QString uri, QStringList list );
|
||||||
|
|
||||||
/**Deletes the selected attributes for the currently selected vector layer*/
|
/**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
|
//! project was written
|
||||||
void writeProject( QDomDocument & );
|
void writeProject( QDomDocument & );
|
||||||
|
@ -246,7 +246,7 @@ void QgsAttributeTableDialog::on_mRemoveSelectionButton_clicked()
|
|||||||
|
|
||||||
void QgsAttributeTableDialog::on_mDeleteSelectedButton_clicked()
|
void QgsAttributeTableDialog::on_mDeleteSelectedButton_clicked()
|
||||||
{
|
{
|
||||||
QgisApp::instance()->deleteSelected( mLayer );
|
QgisApp::instance()->deleteSelected( mLayer, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAttributeTableDialog::on_cbxShowSelectedOnly_toggled( bool theFlag )
|
void QgsAttributeTableDialog::on_cbxShowSelectedOnly_toggled( bool theFlag )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user