@@ -166,10 +166,19 @@ QList<QAction *> QgsGeoPackageCollectionItem::actions()
166
166
{
167
167
QList<QAction *> lst;
168
168
169
- // Add to stored connections
170
- QAction *actionAddConnection = new QAction ( tr ( " Add connection" ), this );
171
- connect ( actionAddConnection, &QAction::triggered, this , &QgsGeoPackageCollectionItem::addConnection );
172
- lst.append ( actionAddConnection );
169
+ if ( QgsOgrDbConnection::connectionList ( QStringLiteral ( " GPKG" ) ).contains ( mName ) )
170
+ {
171
+ QAction *actionDeleteConnection = new QAction ( tr ( " Remove connection" ), this );
172
+ connect ( actionDeleteConnection, &QAction::triggered, this , &QgsGeoPackageConnectionItem::deleteConnection );
173
+ lst.append ( actionDeleteConnection );
174
+ }
175
+ else
176
+ {
177
+ // Add to stored connections
178
+ QAction *actionAddConnection = new QAction ( tr ( " Add connection" ), this );
179
+ connect ( actionAddConnection, &QAction::triggered, this , &QgsGeoPackageCollectionItem::addConnection );
180
+ lst.append ( actionAddConnection );
181
+ }
173
182
174
183
// Add table to existing DB
175
184
QAction *actionAddTable = new QAction ( tr ( " Create a new layer or table..." ), this );
@@ -481,7 +490,7 @@ QList<QAction *> QgsGeoPackageConnectionItem::actions()
481
490
return lst;
482
491
}
483
492
484
- void QgsGeoPackageConnectionItem ::deleteConnection ()
493
+ void QgsGeoPackageCollectionItem ::deleteConnection ()
485
494
{
486
495
QgsOgrDbConnection::deleteConnection ( name (), QStringLiteral ( " GPKG" ) );
487
496
mParent ->refreshConnections ();
0 commit comments