[QGIS Commit] r12391 - trunk/qgis/src/app/ogr
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Wed Dec 9 16:42:16 EST 2009
Author: jef
Date: 2009-12-09 16:42:16 -0500 (Wed, 09 Dec 2009)
New Revision: 12391
Modified:
trunk/qgis/src/app/ogr/qgsnewogrconnection.cpp
Log:
missed a file in r12390
Modified: trunk/qgis/src/app/ogr/qgsnewogrconnection.cpp
===================================================================
--- trunk/qgis/src/app/ogr/qgsnewogrconnection.cpp 2009-12-09 21:35:43 UTC (rev 12390)
+++ trunk/qgis/src/app/ogr/qgsnewogrconnection.cpp 2009-12-09 21:42:16 UTC (rev 12391)
@@ -31,7 +31,8 @@
QgsNewOgrConnection::QgsNewOgrConnection( QWidget *parent, const QString& connType, const QString& connName, Qt::WFlags fl )
- : QDialog( parent, fl )
+ : QDialog( parent, fl ),
+ mOriginalConnName( connName )
{
setupUi( this );
@@ -94,11 +95,30 @@
}
}
-void QgsNewOgrConnection::saveConnection()
+/** Autoconnected SLOTS **/
+void QgsNewOgrConnection::accept()
{
QSettings settings;
QString baseKey = "/" + cmbDatabaseTypes->currentText() + "/connections/";
settings.setValue( baseKey + "selected", txtName->text() );
+
+ // warn if entry was renamed to an existing connection
+ if (( mOriginalConnName.isNull() || mOriginalConnName != txtName->text() ) &&
+ settings.contains( baseKey + txtName->text() + "/host" ) &&
+ QMessageBox::question( this,
+ tr( "Save connection" ),
+ tr( "Should the existing connection %1 be overwritten?" ).arg( txtName->text() ),
+ QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
+ {
+ return;
+ }
+
+ // on rename delete original entry first
+ if ( !mOriginalConnName.isNull() && mOriginalConnName != txtName->text() )
+ {
+ settings.remove( baseKey + mOriginalConnName );
+ }
+
baseKey += txtName->text();
settings.setValue( baseKey + "/host", txtHost->text() );
settings.setValue( baseKey + "/database", txtDatabase->text() );
@@ -106,12 +126,7 @@
settings.setValue( baseKey + "/username", txtUsername->text() );
settings.setValue( baseKey + "/password", chkStorePassword->isChecked() ? txtPassword->text() : "" );
settings.setValue( baseKey + "/save", chkStorePassword->isChecked() ? "true" : "false" );
-}
-/** Autoconnected SLOTS **/
-void QgsNewOgrConnection::accept()
-{
- saveConnection();
QDialog::accept();
}
More information about the QGIS-commit
mailing list