Skip to content
Permalink
Browse files

make confirmation on layer deletion optional (fixes #9094)

  • Loading branch information
jef-n committed Feb 25, 2014
1 parent af17dbf commit e9f808ad0fe780f954a89c17397f6d4f2959e56b
Showing with 21 additions and 10 deletions.
  1. +7 −5 src/app/qgisapp.cpp
  2. +1 −1 src/app/qgisapp.h
  3. +2 −0 src/app/qgsoptions.cpp
  4. +11 −4 src/ui/qgsoptionsbase.ui
@@ -6394,7 +6394,7 @@ void QgisApp::removeAllLayers()
QgsMapLayerRegistry::instance()->removeAllMapLayers();
}

void QgisApp::removeLayer( bool promptConfirmation )
void QgisApp::removeLayer()
{
if ( !mMapLegend )
{
@@ -6412,20 +6412,22 @@ void QgisApp::removeLayer( bool promptConfirmation )
int numberOfRemovedItems = mMapLegend->selectedItems().size();
if ( numberOfRemovedItems == 0 )
{
messageBar()->pushMessage( tr( "No Object Selected" ),
tr( "To remove objects, you must select them in the legend" ),
messageBar()->pushMessage( tr( "No layers selected" ),
tr( "To remove layers, you must select them in the legend" ),
QgsMessageBar::INFO, messageTimeout() );
return;
}

bool promptConfirmation = QSettings().value( "qgis/askToDeleteLayers", true ).toBool();
//display a warning
if ( promptConfirmation && QMessageBox::warning( this, tr( "Remove objects" ), tr( "Remove %n object(s)?", "number of objects to remove", numberOfRemovedItems ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
if ( promptConfirmation && QMessageBox::warning( this, tr( "Remove layers" ), tr( "Remove %n layers(s)?", "number of layers to remove", numberOfRemovedItems ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
{
return;
}

mMapLegend->removeSelectedLayers();

showStatusMessage( tr( "%n object(s) removed.", "number of objects removed", numberOfRemovedItems ) );
showStatusMessage( tr( "%n layers(s) removed.", "number of layers to removed", numberOfRemovedItems ) );

This comment has been minimized.

Copy link
@etiennesky

etiennesky Feb 25, 2014

Contributor

thanks Jurgen!
a small typo - should read "number of layers to remove"

This comment has been minimized.

Copy link
@jef-n

jef-n Feb 25, 2014

Author Member

oh, well - but I guess the translators can cope ;)

This comment has been minimized.

Copy link
@3nids

3nids Feb 25, 2014

Member

I think that "layers" was previously renamed to "objects" since it can be related to groups too.

This comment has been minimized.

Copy link
@ahuarte47

ahuarte47 Feb 25, 2014

Contributor

Thanks @3nids, you are right.
@jef-n, IMHO http://hub.qgis.org/issues/9094#note-49 is a very interesting comment


mMapCanvas->refresh();
}
@@ -689,7 +689,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! Slot to handle user center input;
void userCenter();
//! Remove a layer from the map and legend
void removeLayer( bool promptConfirmation = true );
void removeLayer();
/** Duplicate map layer(s) in legend
* @note added in 1.9 */
void duplicateLayers( const QList<QgsMapLayer *> lyrList = QList<QgsMapLayer *>() );
@@ -635,6 +635,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
mProjectOnLaunchPushBtn->setEnabled( projOpen == 2 );

chbAskToSaveProjectChanges->setChecked( settings.value( "qgis/askToSaveProjectChanges", QVariant( true ) ).toBool() );
mLayerDeleteConfirmationChkBx->setChecked( settings.value( "qgis/askToDeleteLayers", true ).toBool() );
chbWarnOldProjectVersion->setChecked( settings.value( "/qgis/warnOldProjectVersion", QVariant( true ) ).toBool() );
cmbEnableMacros->setCurrentIndex( settings.value( "/qgis/enableMacros", 1 ).toInt() );

@@ -1086,6 +1087,7 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/projOpenAtLaunchPath", mProjectOnLaunchLineEdit->text() );

settings.setValue( "/qgis/askToSaveProjectChanges", chbAskToSaveProjectChanges->isChecked() );
settings.setValue( "qgis/askToDeleteLayers", mLayerDeleteConfirmationChkBx->isChecked() );
settings.setValue( "/qgis/warnOldProjectVersion", chbWarnOldProjectVersion->isChecked() );
if (( settings.value( "/qgis/projectTemplateDir" ).toString() != leTemplateFolder->text() ) ||
( settings.value( "/qgis/newProjectDefault" ).toBool() != cbxProjectDefaultNew->isChecked() ) )
@@ -823,6 +823,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mLayerDeleteConfirmationChkBx">
<property name="text">
<string>Prompt for confirmation when a layer is to be removed</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chbWarnOldProjectVersion">
<property name="text">
@@ -1618,7 +1625,7 @@
</widget>
</item>
<item>
<spacer name="horizontalSpacer_38">
<spacer name="horizontalSpacer_41">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -1656,7 +1663,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_56">
<widget class="QLabel" name="label_65">
<property name="text">
<string>Simplification threshold (higher values result in more simplification): </string>
</property>
@@ -2896,7 +2903,7 @@
</layout>
</widget>
<widget class="QWidget" name="mOptionsPageComposer">
<layout class="QVBoxLayout" name="verticalLayout_9">
<layout class="QVBoxLayout" name="verticalLayout_36">
<property name="margin">
<number>0</number>
</property>
@@ -2928,7 +2935,7 @@
</property>
<layout class="QGridLayout" name="gridLayout_8">
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<layout class="QHBoxLayout" name="horizontalLayout_39">
<item>
<widget class="QLabel" name="label_60">
<property name="text">

0 comments on commit e9f808a

Please sign in to comment.
You can’t perform that action at this time.