delete selected layers on spatialite and pg

This commit is contained in:
signedav 2018-11-15 10:23:50 +01:00
parent be0ce0ca4c
commit 7acd83fd09
2 changed files with 25 additions and 4 deletions

View File

@ -317,8 +317,18 @@ QList<QAction *> QgsPGLayerItem::actions( QWidget *parent )
connect( actionRenameLayer, &QAction::triggered, this, &QgsPGLayerItem::renameLayer );
lst.append( actionRenameLayer );
QAction *actionDeleteLayer = new QAction( tr( "Delete %1" ).arg( typeName ), parent );
connect( actionDeleteLayer, &QAction::triggered, this, &QgsPGLayerItem::deleteLayer );
const QString deleteText = selectedItems().count() == 1 ? tr( "Delete %1" ).arg( typeName )
: tr( "Delete Selected Tables" );
QAction *actionDeleteLayer = new QAction( deleteText, parent );
connect( actionDeleteLayer, &QAction::triggered, this, [ = ]
{
QList<QgsDataItem *> items = selectedItems();
for ( QgsDataItem *item : items )
{
if ( QgsPGLayerItem *pgLayerItem = qobject_cast< QgsPGLayerItem *>( item ) )
pgLayerItem->deleteLayer();
}
} ) ;
lst.append( actionDeleteLayer );
if ( !mLayerProperty.isView )

View File

@ -45,8 +45,19 @@ QList<QAction *> QgsSLLayerItem::actions( QWidget *parent )
{
QList<QAction *> lst;
QAction *actionDeleteLayer = new QAction( tr( "Delete Layer" ), parent );
connect( actionDeleteLayer, &QAction::triggered, this, &QgsSLLayerItem::deleteLayer );
const QString deleteText = selectedItems().count() == 1 ? tr( "Delete Layer '%1'…" ).arg( mName )
: tr( "Delete Selected Layers" );
QAction *actionDeleteLayer = new QAction( deleteText, parent );
connect( actionDeleteLayer, &QAction::triggered, this, [ = ]
{
QList<QgsDataItem *> items = selectedItems();
for ( QgsDataItem *item : items )
{
if ( QgsSLLayerItem *slLayerItem = qobject_cast< QgsSLLayerItem *>( item ) )
slLayerItem->deleteLayer();
}
} ) ;
lst.append( actionDeleteLayer );
return lst;