mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-12 00:02:25 -04:00
delete selected layers on spatialite and pg
This commit is contained in:
parent
be0ce0ca4c
commit
7acd83fd09
@ -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 )
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user