mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-15 00:04:37 -04:00
Geopackage: switch the action from add/remove connection
depending on the connection being already stored or not, this allows the user to remove and existing connection.
This commit is contained in:
parent
808cbf3526
commit
d7029bb5a5
@ -166,10 +166,19 @@ QList<QAction *> QgsGeoPackageCollectionItem::actions()
|
||||
{
|
||||
QList<QAction *> lst;
|
||||
|
||||
if ( QgsOgrDbConnection::connectionList( QStringLiteral( "GPKG" ) ).contains( mName ) )
|
||||
{
|
||||
QAction *actionDeleteConnection = new QAction( tr( "Remove connection" ), this );
|
||||
connect( actionDeleteConnection, &QAction::triggered, this, &QgsGeoPackageConnectionItem::deleteConnection );
|
||||
lst.append( actionDeleteConnection );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add to stored connections
|
||||
QAction *actionAddConnection = new QAction( tr( "Add connection" ), this );
|
||||
connect( actionAddConnection, &QAction::triggered, this, &QgsGeoPackageCollectionItem::addConnection );
|
||||
lst.append( actionAddConnection );
|
||||
}
|
||||
|
||||
// Add table to existing DB
|
||||
QAction *actionAddTable = new QAction( tr( "Create a new layer or table..." ), this );
|
||||
@ -481,7 +490,7 @@ QList<QAction *> QgsGeoPackageConnectionItem::actions()
|
||||
return lst;
|
||||
}
|
||||
|
||||
void QgsGeoPackageConnectionItem::deleteConnection()
|
||||
void QgsGeoPackageCollectionItem::deleteConnection()
|
||||
{
|
||||
QgsOgrDbConnection::deleteConnection( name(), QStringLiteral( "GPKG" ) );
|
||||
mParent->refreshConnections();
|
||||
|
@ -93,6 +93,7 @@ class QgsGeoPackageCollectionItem : public QgsDataCollectionItem
|
||||
#ifdef HAVE_GUI
|
||||
void addTable();
|
||||
void addConnection();
|
||||
void deleteConnection();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
@ -119,7 +120,6 @@ class QgsGeoPackageConnectionItem : public QgsGeoPackageCollectionItem
|
||||
public slots:
|
||||
#ifdef HAVE_GUI
|
||||
void editConnection();
|
||||
void deleteConnection();
|
||||
#endif
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user