@@ -34,10 +34,10 @@ QgsNewConnection::QgsNewConnection( QWidget *parent, const QString& connName, Qt
3434{
3535 setupUi ( this );
3636
37- cbxSSLmode->insertItem ( QgsDataSourceURI::SSLprefer, tr ( " prefer " ) );
38- cbxSSLmode->insertItem ( QgsDataSourceURI::SSLrequire, tr ( " require " ) );
39- cbxSSLmode->insertItem ( QgsDataSourceURI::SSLallow, tr ( " allow " ) );
40- cbxSSLmode->insertItem ( QgsDataSourceURI::SSLdisable, tr ( " disable " ) );
37+ cbxSSLmode->addItem ( tr ( " disable " ), QgsDataSourceURI::SSLdisable );
38+ cbxSSLmode->addItem ( tr ( " allow " ), QgsDataSourceURI::SSLallow );
39+ cbxSSLmode->addItem ( tr ( " prefer " ), QgsDataSourceURI::SSLprefer );
40+ cbxSSLmode->addItem ( tr ( " require " ), QgsDataSourceURI::SSLrequire );
4141
4242 if ( !connName.isEmpty () )
4343 {
@@ -66,7 +66,7 @@ QgsNewConnection::QgsNewConnection( QWidget *parent, const QString& connName, Qt
6666 // Ensure that cb_plublicSchemaOnly is set correctly
6767 on_cb_geometryColumnsOnly_clicked ();
6868
69- cbxSSLmode->setCurrentIndex ( settings.value ( key + " /sslmode" , QgsDataSourceURI::SSLprefer ).toInt () );
69+ cbxSSLmode->setCurrentIndex ( cbxSSLmode-> findData ( settings.value ( key + " /sslmode" , QgsDataSourceURI::SSLprefer ).toInt () ) );
7070
7171 if ( settings.value ( key + " /save" ).toString () == " true" )
7272 {
@@ -110,7 +110,7 @@ void QgsNewConnection::accept()
110110 settings.setValue ( baseKey + " /publicOnly" , cb_publicSchemaOnly->isChecked () );
111111 settings.setValue ( baseKey + " /geometryColumnsOnly" , cb_geometryColumnsOnly->isChecked () );
112112 settings.setValue ( baseKey + " /save" , chkStorePassword->isChecked () ? " true" : " false" );
113- settings.setValue ( baseKey + " /sslmode" , cbxSSLmode->currentIndex () );
113+ settings.setValue ( baseKey + " /sslmode" , cbxSSLmode->itemData ( cbxSSLmode-> currentIndex () ). toInt () );
114114
115115 QDialog::accept ();
116116}
@@ -137,7 +137,7 @@ QgsNewConnection::~QgsNewConnection()
137137void QgsNewConnection::testConnection ()
138138{
139139 QgsDataSourceURI uri;
140- uri.setConnection ( txtHost->text (), txtPort->text (), txtDatabase->text (), txtUsername->text (), txtPassword->text (), ( QgsDataSourceURI::SSLmode ) cbxSSLmode->currentIndex () );
140+ uri.setConnection ( txtHost->text (), txtPort->text (), txtDatabase->text (), txtUsername->text (), txtPassword->text (), ( QgsDataSourceURI::SSLmode ) cbxSSLmode->itemData ( cbxSSLmode-> currentIndex () ). toInt () );
141141
142142 QgsDebugMsg ( " PQconnectdb(" + uri.connectionInfo () + " );" );
143143
0 commit comments