Skip to content
Permalink
Browse files
change after review
  • Loading branch information
speillet authored and nyalldawson committed Jun 21, 2021
1 parent 4ca6872 commit 46dad154ef997b8b03b61fa9b9d5e648c513e762
@@ -217,7 +217,7 @@ void QgsGeoPackageCollectionItem::addConnection()

void QgsGeoPackageCollectionItem::deleteConnection()
{
QgsOgrDbConnection::deleteConnection( name(), QStringLiteral( "GPKG" ) );
QgsOgrDbConnection::deleteConnection( name() );
mParent->refreshConnections( QStringLiteral( "GPKG" ) );
}

@@ -435,9 +435,6 @@ bool QgsOgrDataCollectionItem::saveConnection( const QString &path, const QStrin
}
if ( ok && ! connName.isEmpty() )
{
QgsOgrDbConnection connection( connName, ogrDriverName );
connection.setPath( path );
connection.save();
QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "ogr" ) );
QgsGeoPackageProviderConnection *providerConnection = static_cast<QgsGeoPackageProviderConnection *>( providerMetadata->createConnection( connName ) );
providerMetadata->saveConnection( providerConnection, connName );
@@ -87,11 +87,8 @@ void QgsOgrDbConnection::setSelectedConnection( const QString &connName, const Q
settings.setValue( QStringLiteral( "%1/selected" ).arg( connectionsPath( settingsKey ) ), connName );
}

void QgsOgrDbConnection::deleteConnection( const QString &connName, const QString &settingsKey )
void QgsOgrDbConnection::deleteConnection( const QString &connName )
{
QgsSettings settings;
settings.remove( QStringLiteral( "%1/%2" ).arg( connectionsPath( settingsKey ), connName ) );

QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "ogr" ) );
providerMetadata->deleteConnection( connName );
}
@@ -38,7 +38,7 @@ class CORE_EXPORT QgsOgrDbConnection : public QObject
explicit QgsOgrDbConnection( const QString &connName, const QString &settingsKey );

static const QStringList connectionList( const QString &driverName = QStringLiteral( "GPKG" ) );
static void deleteConnection( const QString &connName, const QString &settingsKey );
static void deleteConnection( const QString &connName );
static QString selectedConnection( const QString &settingsKey );
static void setSelectedConnection( const QString &connName, const QString &settingsKey );

@@ -247,7 +247,7 @@ void QgsOgrDbSourceSelect::btnDelete_clicked()
if ( result != QMessageBox::Yes )
return;

QgsOgrDbConnection::deleteConnection( subKey, ogrDriverName() );
QgsOgrDbConnection::deleteConnection( subKey );
populateConnectionList();
emit connectionsChanged();
}
@@ -24,8 +24,6 @@
#include "qgsoracletablemodel.h"
#include "qgssettings.h"
#include "qgsoracleconnpool.h"
#include "qgsprovidermetadata.h"
#include "qgsproviderregistry.h"

#include <QSqlError>

@@ -268,7 +268,8 @@ void QgsOracleSourceSelect::on_btnDelete_clicked()
if ( QMessageBox::Ok != QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel ) )
return;

QgsOracleConn::deleteConnection( cmbConnections->currentText() );
QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "oracle" ) );
providerMetadata->deleteConnection( cmbConnections->currentText() );

QgsOracleTableCache::removeFromCache( cmbConnections->currentText() );

@@ -19,6 +19,7 @@
#include "qgsspatialitesourceselect.h"
#include "qgsproviderregistry.h"
#include "qgsprovidermetadata.h"
#include "qgsspatialiteproviderconnection.h"

#include "qgsapplication.h"
#include "qgsmessageoutput.h"
@@ -118,8 +119,9 @@ void QgsSpatiaLiteDataItemGuiProvider::createDatabase( QgsDataItem *item )
QString errCause;
if ( SpatiaLiteUtils::createDb( filename, errCause ) )
{
// add connection
settings.setValue( "/SpatiaLite/connections/" + QFileInfo( filename ).fileName() + "/sqlitepath", filename );
QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "spatialite" ) );
QgsSpatiaLiteProviderConnection *providerConnection = static_cast<QgsSpatiaLiteProviderConnection *>( providerMetadata->createConnection( filename ) );
providerMetadata->saveConnection( providerConnection, filename );

item->refresh();
}
@@ -312,9 +312,6 @@ bool QgsSpatiaLiteSourceSelect::newConnection( QWidget *parent )
// Persist last used SpatiaLite dir
settings.setValue( QStringLiteral( "UI/lastSpatiaLiteDir" ), myPath );
// inserting this SQLite DB path
settings.setValue( baseKey + "selected", savedName );
settings.setValue( baseKey + savedName + "/sqlitepath", myFI.canonicalFilePath() );

QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "spatialite" ) );
QgsSpatiaLiteProviderConnection *providerConnection = static_cast<QgsSpatiaLiteProviderConnection *>( providerMetadata->createConnection( savedName ) );
providerMetadata->saveConnection( providerConnection, savedName );
@@ -378,7 +375,8 @@ void QgsSpatiaLiteSourceSelect::btnDelete_clicked()
if ( result != QMessageBox::Yes )
return;

QgsSpatiaLiteConnection::deleteConnection( subKey );
QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "spatialite" ) );
providerMetadata->deleteConnection( subKey );

populateConnectionList();
emit connectionsChanged();

0 comments on commit 46dad15

Please sign in to comment.