Skip to content

Commit 0c5ea3a

Browse files
author
jef
committed
missed a file in r12390
git-svn-id: http://svn.osgeo.org/qgis/trunk@12391 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 80c1cf3 commit 0c5ea3a

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/app/ogr/qgsnewogrconnection.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131

3232

3333
QgsNewOgrConnection::QgsNewOgrConnection( QWidget *parent, const QString& connType, const QString& connName, Qt::WFlags fl )
34-
: QDialog( parent, fl )
34+
: QDialog( parent, fl ),
35+
mOriginalConnName( connName )
3536
{
3637
setupUi( this );
3738

@@ -94,24 +95,38 @@ void QgsNewOgrConnection::testConnection()
9495
}
9596
}
9697

97-
void QgsNewOgrConnection::saveConnection()
98+
/** Autoconnected SLOTS **/
99+
void QgsNewOgrConnection::accept()
98100
{
99101
QSettings settings;
100102
QString baseKey = "/" + cmbDatabaseTypes->currentText() + "/connections/";
101103
settings.setValue( baseKey + "selected", txtName->text() );
104+
105+
// warn if entry was renamed to an existing connection
106+
if (( mOriginalConnName.isNull() || mOriginalConnName != txtName->text() ) &&
107+
settings.contains( baseKey + txtName->text() + "/host" ) &&
108+
QMessageBox::question( this,
109+
tr( "Save connection" ),
110+
tr( "Should the existing connection %1 be overwritten?" ).arg( txtName->text() ),
111+
QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
112+
{
113+
return;
114+
}
115+
116+
// on rename delete original entry first
117+
if ( !mOriginalConnName.isNull() && mOriginalConnName != txtName->text() )
118+
{
119+
settings.remove( baseKey + mOriginalConnName );
120+
}
121+
102122
baseKey += txtName->text();
103123
settings.setValue( baseKey + "/host", txtHost->text() );
104124
settings.setValue( baseKey + "/database", txtDatabase->text() );
105125
settings.setValue( baseKey + "/port", txtPort->text() );
106126
settings.setValue( baseKey + "/username", txtUsername->text() );
107127
settings.setValue( baseKey + "/password", chkStorePassword->isChecked() ? txtPassword->text() : "" );
108128
settings.setValue( baseKey + "/save", chkStorePassword->isChecked() ? "true" : "false" );
109-
}
110129

111-
/** Autoconnected SLOTS **/
112-
void QgsNewOgrConnection::accept()
113-
{
114-
saveConnection();
115130
QDialog::accept();
116131
}
117132

0 commit comments

Comments
 (0)