Skip to content
Permalink
Browse files

Add confirmation prompt before deleting PostGIS and Spatialite

tables through the browser. Also add confirmation before dropping
connections (fix #12853).

Cherry-picked from aeda955
  • Loading branch information
nyalldawson committed Jun 8, 2015
1 parent 5378f73 commit 4fbda183e727be34563ec110b943b8e3ce1b7141
@@ -123,6 +123,11 @@ void QgsPGConnectionItem::editConnection()

void QgsPGConnectionItem::deleteConnection()
{
if ( QMessageBox::question( 0, QObject::tr( "Delete Connection" ),
QObject::tr( "Are you sure you want to delete the connection to %1?" ).arg( mName ),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes )
return;

QgsPostgresConn::deleteConnection( mName );
// the parent should be updated
if ( mParent )
@@ -227,7 +232,7 @@ QList<QAction*> QgsPGLayerItem::actions()
{
QList<QAction*> lst;

QAction* actionDeleteLayer = new QAction( tr( "Delete layer" ), this );
QAction* actionDeleteLayer = new QAction( tr( "Delete Layer" ), this );
connect( actionDeleteLayer, SIGNAL( triggered() ), this, SLOT( deleteLayer() ) );
lst.append( actionDeleteLayer );

@@ -236,15 +241,20 @@ QList<QAction*> QgsPGLayerItem::actions()

void QgsPGLayerItem::deleteLayer()
{
if ( QMessageBox::question( 0, QObject::tr( "Delete Object" ),
QObject::tr( "Are you sure you want to delete %1.%2?" ).arg( mLayerProperty.schemaName ).arg( mLayerProperty.tableName ),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes )
return;

QString errCause;
bool res = ::deleteLayer( mUri, errCause );
if ( !res )
{
QMessageBox::warning( 0, tr( "Delete layer" ), errCause );
QMessageBox::warning( 0, tr( "Delete Layer" ), errCause );
}
else
{
QMessageBox::information( 0, tr( "Delete layer" ), tr( "Layer deleted successfully." ) );
QMessageBox::information( 0, tr( "Delete Layer" ), tr( "Layer deleted successfully." ) );
if ( mParent )
mParent->refresh();
}
@@ -39,7 +39,7 @@ QList<QAction*> QgsSLLayerItem::actions()
{
QList<QAction*> lst;

QAction* actionDeleteLayer = new QAction( tr( "Delete layer" ), this );
QAction* actionDeleteLayer = new QAction( tr( "Delete Layer" ), this );
connect( actionDeleteLayer, SIGNAL( triggered() ), this, SLOT( deleteLayer() ) );
lst.append( actionDeleteLayer );

@@ -48,16 +48,21 @@ QList<QAction*> QgsSLLayerItem::actions()

void QgsSLLayerItem::deleteLayer()
{
if ( QMessageBox::question( 0, QObject::tr( "Delete Object" ),
QObject::tr( "Are you sure you want to delete %1?" ).arg( mName ),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes )
return;

QgsDataSourceURI uri( mUri );
QString errCause;
bool res = ::deleteLayer( uri.database(), uri.table(), errCause );
if ( !res )
{
QMessageBox::warning( 0, tr( "Delete layer" ), errCause );
QMessageBox::warning( 0, tr( "Delete Layer" ), errCause );
}
else
{
QMessageBox::information( 0, tr( "Delete layer" ), tr( "Layer deleted successfully." ) );
QMessageBox::information( 0, tr( "Delete Layer" ), tr( "Layer deleted successfully." ) );
mParent->refresh();
}
}
@@ -167,6 +172,11 @@ void QgsSLConnectionItem::editConnection()

void QgsSLConnectionItem::deleteConnection()
{
if ( QMessageBox::question( 0, QObject::tr( "Delete Connection" ),
QObject::tr( "Are you sure you want to delete the connection to %1?" ).arg( mName ),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes )
return;

QgsSpatiaLiteConnection::deleteConnection( mName );
// the parent should be updated
mParent->refresh();

0 comments on commit 4fbda18

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