Skip to content
Permalink
Browse files

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.
  • Loading branch information
elpaso committed Sep 18, 2017
1 parent 808cbf3 commit d7029bb5a5325fc1a44de48272f4490fe94235cd
Showing with 15 additions and 6 deletions.
  1. +14 −5 src/providers/ogr/qgsgeopackagedataitems.cpp
  2. +1 −1 src/providers/ogr/qgsgeopackagedataitems.h
@@ -166,10 +166,19 @@ QList<QAction *> QgsGeoPackageCollectionItem::actions()
{
QList<QAction *> lst;

// Add to stored connections
QAction *actionAddConnection = new QAction( tr( "Add connection" ), this );
connect( actionAddConnection, &QAction::triggered, this, &QgsGeoPackageCollectionItem::addConnection );
lst.append( actionAddConnection );
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

};

0 comments on commit d7029bb

Please sign in to comment.
You can’t perform that action at this time.