Skip to content

Commit 92da308

Browse files
committed
Delete gpkg connections
1 parent bc921b4 commit 92da308

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/providers/ogr/qgsgeopackagedataitems.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,10 @@ QList<QAction *> QgsGeoPackageConnectionItem::actions()
201201
{
202202
QList<QAction *> lst;
203203

204-
// TODO: implement layer deletion
205204

206-
//QAction *actionRemoveConnection = new QAction( tr( "Remove connection" ), this );
207-
// connect( actionDeleteLayer, &QAction::triggered, this, &QgsGeoPackageLayerItem::deleteLayer );
208-
//lst.append( actionRemoveConnection );
205+
QAction *actiondeleteConnection = new QAction( tr( "Remove connection" ), this );
206+
connect( actiondeleteConnection, &QAction::triggered, this, &QgsGeoPackageConnectionItem::deleteConnection );
207+
lst.append( actiondeleteConnection );
209208
return lst;
210209
}
211210
#endif
@@ -240,15 +239,18 @@ QgsLayerItem::LayerType QgsGeoPackageConnectionItem::layerTypeFromDb( const QStr
240239
return QgsLayerItem::LayerType::NoType;
241240
}
242241

242+
void QgsGeoPackageConnectionItem::deleteConnection()
243+
{
244+
QgsGeoPackageConnection::deleteConnection( name() );
245+
mParent->refreshConnections();
246+
}
247+
243248
#ifdef HAVE_GUI
244249
QList<QAction *> QgsGeoPackageAbstractLayerItem::actions()
245250
{
246251
QList<QAction *> lst;
247252

248-
QAction *actionDeleteLayer = new QAction( tr( "Delete Layer" ), this );
249-
// TODO connect( actionDeleteLayer, &QAction::triggered, this, &QgsGeoPackageLayerItem::deleteLayer );
250-
lst.append( actionDeleteLayer );
251-
253+
// TODO: delete layer when the provider supports it (not currently implemented)
252254
return lst;
253255
}
254256
#endif
@@ -266,6 +268,7 @@ QgsGeoPackageVectorLayerItem::QgsGeoPackageVectorLayerItem( QgsDataItem *parent,
266268

267269
}
268270

271+
269272
QgsGeoPackageRasterLayerItem::QgsGeoPackageRasterLayerItem( QgsDataItem *parent, QString name, QString path, QString uri )
270273
: QgsGeoPackageAbstractLayerItem( parent, name, path, uri, QgsLayerItem::LayerType::Raster, QStringLiteral( "gdal" ) )
271274
{

src/providers/ogr/qgsgeopackagedataitems.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ class QgsGeoPackageAbstractLayerItem : public QgsLayerItem
3232
#ifdef HAVE_GUI
3333
QList<QAction *> actions() override;
3434
#endif
35-
36-
public slots:
37-
#ifdef HAVE_GUI
38-
void deleteLayer();
39-
#endif
4035
};
4136

4237

@@ -45,6 +40,7 @@ class QgsGeoPackageRasterLayerItem : public QgsGeoPackageAbstractLayerItem
4540
Q_OBJECT
4641
public:
4742
QgsGeoPackageRasterLayerItem( QgsDataItem *parent, QString name, QString path, QString uri );
43+
4844
};
4945

5046

@@ -53,6 +49,7 @@ class QgsGeoPackageVectorLayerItem : public QgsGeoPackageAbstractLayerItem
5349
Q_OBJECT
5450
public:
5551
QgsGeoPackageVectorLayerItem( QgsDataItem *parent, QString name, QString path, QString uri, LayerType layerType );
52+
5653
};
5754

5855

0 commit comments

Comments
 (0)