26
26
#include " qgsoracleconnpool.h"
27
27
28
28
QgsOracleNewConnection::QgsOracleNewConnection ( QWidget *parent, const QString &connName, Qt::WindowFlags fl )
29
- : QDialog( parent, fl ), mOriginalConnName( connName )
29
+ : QDialog( parent, fl )
30
+ , mOriginalConnName( connName )
30
31
{
31
32
setupUi ( this );
32
33
connect ( buttonBox, &QDialogButtonBox::helpRequested, this , &QgsOracleNewConnection::showHelp );
34
+ connect ( btnConnect, &QPushButton::clicked, this , &QgsOracleNewConnection::testConnection );
33
35
34
36
if ( !connName.isEmpty () )
35
37
{
36
38
// populate the dialog with the information stored for the connection
37
39
// populate the fields with the stored setting parameters
38
40
QgsSettings settings;
39
41
40
- QString key = " /Oracle/connections/" + connName;
41
- txtDatabase->setText ( settings.value ( key + " /database" ).toString () );
42
- txtHost->setText ( settings.value ( key + " /host" ).toString () );
43
- QString port = settings.value ( key + " /port" ).toString ();
42
+ QString key = QStringLiteral ( " /Oracle/connections/" ) + connName;
43
+ txtDatabase->setText ( settings.value ( key + QStringLiteral ( " /database" ) ).toString () );
44
+ txtHost->setText ( settings.value ( key + QStringLiteral ( " /host" ) ).toString () );
45
+ QString port = settings.value ( key + QStringLiteral ( " /port" ) ).toString ();
44
46
if ( port.length () == 0 )
45
47
{
46
- port = " 1521" ;
48
+ port = QStringLiteral ( " 1521" ) ;
47
49
}
48
50
txtPort->setText ( port );
49
- txtOptions->setText ( settings.value ( key + " /dboptions" ).toString () );
50
- txtWorkspace->setText ( settings.value ( key + " /dbworkspace" ).toString () );
51
- cb_userTablesOnly->setChecked ( settings.value ( key + " /userTablesOnly" , false ).toBool () );
52
- cb_geometryColumnsOnly->setChecked ( settings.value ( key + " /geometryColumnsOnly" , true ).toBool () );
53
- cb_allowGeometrylessTables->setChecked ( settings.value ( key + " /allowGeometrylessTables" , false ).toBool () );
54
- cb_useEstimatedMetadata->setChecked ( settings.value ( key + " /estimatedMetadata" , false ).toBool () );
55
- cb_onlyExistingTypes->setChecked ( settings.value ( key + " /onlyExistingTypes" , true ).toBool () );
56
- cb_includeGeoAttributes->setChecked ( settings.value ( key + " /includeGeoAttributes" , false ).toBool () );
57
-
58
- if ( settings.value ( key + " /saveUsername" ).toString () == " true" )
51
+ txtOptions->setText ( settings.value ( key + QStringLiteral ( " /dboptions" ) ).toString () );
52
+ txtWorkspace->setText ( settings.value ( key + QStringLiteral ( " /dbworkspace" ) ).toString () );
53
+ cb_userTablesOnly->setChecked ( settings.value ( key + QStringLiteral ( " /userTablesOnly" ) , false ).toBool () );
54
+ cb_geometryColumnsOnly->setChecked ( settings.value ( key + QStringLiteral ( " /geometryColumnsOnly" ) , true ).toBool () );
55
+ cb_allowGeometrylessTables->setChecked ( settings.value ( key + QStringLiteral ( " /allowGeometrylessTables" ) , false ).toBool () );
56
+ cb_useEstimatedMetadata->setChecked ( settings.value ( key + QStringLiteral ( " /estimatedMetadata" ) , false ).toBool () );
57
+ cb_onlyExistingTypes->setChecked ( settings.value ( key + QStringLiteral ( " /onlyExistingTypes" ) , true ).toBool () );
58
+ cb_includeGeoAttributes->setChecked ( settings.value ( key + QStringLiteral ( " /includeGeoAttributes" ) , false ).toBool () );
59
+
60
+ if ( settings.value ( key + QStringLiteral ( " /saveUsername" ) ) .toString () == QLatin1String ( " true" ) )
59
61
{
60
- txtUsername->setText ( settings.value ( key + " /username" ).toString () );
62
+ txtUsername->setText ( settings.value ( key + QStringLiteral ( " /username" ) ).toString () );
61
63
chkStoreUsername->setChecked ( true );
62
64
}
63
65
64
- if ( settings.value ( key + " /savePassword" ).toString () == " true" )
66
+ if ( settings.value ( key + QStringLiteral ( " /savePassword" ) ) .toString () == QLatin1String ( " true" ) )
65
67
{
66
- txtPassword->setText ( settings.value ( key + " /password" ).toString () );
68
+ txtPassword->setText ( settings.value ( key + QStringLiteral ( " /password" ) ).toString () );
67
69
chkStorePassword->setChecked ( true );
68
70
}
69
71
70
72
// Old save setting
71
- if ( settings.contains ( key + " /save" ) )
73
+ if ( settings.contains ( key + QStringLiteral ( " /save" ) ) )
72
74
{
73
- txtUsername->setText ( settings.value ( key + " /username" ).toString () );
75
+ txtUsername->setText ( settings.value ( key + QStringLiteral ( " /username" ) ).toString () );
74
76
chkStoreUsername->setChecked ( !txtUsername->text ().isEmpty () );
75
77
76
- if ( settings.value ( key + " /save" ).toString () == " true" )
77
- txtPassword->setText ( settings.value ( key + " /password" ).toString () );
78
+ if ( settings.value ( key + QStringLiteral ( " /save" ) ) .toString () == QLatin1String ( " true" ) )
79
+ txtPassword->setText ( settings.value ( key + QStringLiteral ( " /password" ) ).toString () );
78
80
79
81
chkStorePassword->setChecked ( true );
80
82
}
81
83
82
84
txtName->setText ( connName );
83
85
}
84
- txtName->setValidator ( new QRegExpValidator ( QRegExp ( " [^\\ /]+" ), txtName ) );
86
+ txtName->setValidator ( new QRegExpValidator ( QRegExp ( QStringLiteral ( " [^\\ /]+" ) ), txtName ) );
85
87
}
86
- // ! Autoconnected SLOTS *
88
+
87
89
void QgsOracleNewConnection::accept ()
88
90
{
89
91
QgsSettings settings;
90
- QString baseKey = " /Oracle/connections/" ;
91
- settings.setValue ( baseKey + " selected" , txtName->text () );
92
+ QString baseKey = QStringLiteral ( " /Oracle/connections/" ) ;
93
+ settings.setValue ( baseKey + QStringLiteral ( " selected" ) , txtName->text () );
92
94
93
95
if ( chkStorePassword->isChecked () &&
94
96
QMessageBox::question ( this ,
@@ -101,8 +103,8 @@ void QgsOracleNewConnection::accept()
101
103
102
104
// warn if entry was renamed to an existing connection
103
105
if ( ( mOriginalConnName .isNull () || mOriginalConnName .compare ( txtName->text (), Qt::CaseInsensitive ) != 0 ) &&
104
- ( settings.contains ( baseKey + txtName->text () + " /service" ) ||
105
- settings.contains ( baseKey + txtName->text () + " /host" ) ) &&
106
+ ( settings.contains ( baseKey + txtName->text () + QStringLiteral ( " /service" ) ) ||
107
+ settings.contains ( baseKey + txtName->text () + QStringLiteral ( " /host" ) ) ) &&
106
108
QMessageBox::question ( this ,
107
109
tr ( " Save Connection" ),
108
110
tr ( " Should the existing connection %1 be overwritten?" ).arg ( txtName->text () ),
@@ -119,33 +121,33 @@ void QgsOracleNewConnection::accept()
119
121
}
120
122
121
123
baseKey += txtName->text ();
122
- settings.setValue ( baseKey + " /database" , txtDatabase->text () );
123
- settings.setValue ( baseKey + " /host" , txtHost->text () );
124
- settings.setValue ( baseKey + " /port" , txtPort->text () );
125
- settings.setValue ( baseKey + " /username" , chkStoreUsername->isChecked () ? txtUsername->text () : " " );
126
- settings.setValue ( baseKey + " /password" , chkStorePassword->isChecked () ? txtPassword->text () : " " );
127
- settings.setValue ( baseKey + " /userTablesOnly" , cb_userTablesOnly->isChecked () );
128
- settings.setValue ( baseKey + " /geometryColumnsOnly" , cb_geometryColumnsOnly->isChecked () );
129
- settings.setValue ( baseKey + " /allowGeometrylessTables" , cb_allowGeometrylessTables->isChecked () );
130
- settings.setValue ( baseKey + " /estimatedMetadata" , cb_useEstimatedMetadata->isChecked () ? " true" : " false" );
131
- settings.setValue ( baseKey + " /onlyExistingTypes" , cb_onlyExistingTypes->isChecked () ? " true" : " false" );
132
- settings.setValue ( baseKey + " /includeGeoAttributes" , cb_includeGeoAttributes->isChecked () ? " true" : " false" );
133
- settings.setValue ( baseKey + " /saveUsername" , chkStoreUsername->isChecked () ? " true" : " false" );
134
- settings.setValue ( baseKey + " /savePassword" , chkStorePassword->isChecked () ? " true" : " false" );
135
- settings.setValue ( baseKey + " /dboptions" , txtOptions->text () );
136
- settings.setValue ( baseKey + " /dbworkspace" , txtWorkspace->text () );
124
+ settings.setValue ( baseKey + QStringLiteral ( " /database" ) , txtDatabase->text () );
125
+ settings.setValue ( baseKey + QStringLiteral ( " /host" ) , txtHost->text () );
126
+ settings.setValue ( baseKey + QStringLiteral ( " /port" ) , txtPort->text () );
127
+ settings.setValue ( baseKey + QStringLiteral ( " /username" ) , chkStoreUsername->isChecked () ? txtUsername->text () : QString () );
128
+ settings.setValue ( baseKey + QStringLiteral ( " /password" ) , chkStorePassword->isChecked () ? txtPassword->text () : QString () );
129
+ settings.setValue ( baseKey + QStringLiteral ( " /userTablesOnly" ) , cb_userTablesOnly->isChecked () );
130
+ settings.setValue ( baseKey + QStringLiteral ( " /geometryColumnsOnly" ) , cb_geometryColumnsOnly->isChecked () );
131
+ settings.setValue ( baseKey + QStringLiteral ( " /allowGeometrylessTables" ) , cb_allowGeometrylessTables->isChecked () );
132
+ settings.setValue ( baseKey + QStringLiteral ( " /estimatedMetadata" ) , cb_useEstimatedMetadata->isChecked () ? QStringLiteral ( " true" ) : QStringLiteral ( " false" ) );
133
+ settings.setValue ( baseKey + QStringLiteral ( " /onlyExistingTypes" ) , cb_onlyExistingTypes->isChecked () ? QStringLiteral ( " true" ) : QStringLiteral ( " false" ) );
134
+ settings.setValue ( baseKey + QStringLiteral ( " /includeGeoAttributes" ) , cb_includeGeoAttributes->isChecked () ? QStringLiteral ( " true" ) : QStringLiteral ( " false" ) );
135
+ settings.setValue ( baseKey + QStringLiteral ( " /saveUsername" ) , chkStoreUsername->isChecked () ? QStringLiteral ( " true" ) : QStringLiteral ( " false" ) );
136
+ settings.setValue ( baseKey + QStringLiteral ( " /savePassword" ) , chkStorePassword->isChecked () ? QStringLiteral ( " true" ) : QStringLiteral ( " false" ) );
137
+ settings.setValue ( baseKey + QStringLiteral ( " /dboptions" ) , txtOptions->text () );
138
+ settings.setValue ( baseKey + QStringLiteral ( " /dbworkspace" ) , txtWorkspace->text () );
137
139
138
140
QDialog::accept ();
139
141
}
140
142
141
- void QgsOracleNewConnection::on_btnConnect_clicked ()
143
+ void QgsOracleNewConnection::testConnection ()
142
144
{
143
145
QgsDataSourceUri uri;
144
146
uri.setConnection ( txtHost->text (), txtPort->text (), txtDatabase->text (), txtUsername->text (), txtPassword->text () );
145
147
if ( !txtOptions->text ().isEmpty () )
146
- uri.setParam ( " dboptions" , txtOptions->text () );
148
+ uri.setParam ( QStringLiteral ( " dboptions" ) , txtOptions->text () );
147
149
if ( !txtWorkspace->text ().isEmpty () )
148
- uri.setParam ( " dbworkspace" , txtWorkspace->text () );
150
+ uri.setParam ( QStringLiteral ( " dbworkspace" ) , txtWorkspace->text () );
149
151
150
152
QgsOracleConn *conn = QgsOracleConnPool::instance ()->acquireConnection ( QgsOracleConn::toPoolName ( uri ) );
151
153
@@ -164,13 +166,6 @@ void QgsOracleNewConnection::on_btnConnect_clicked()
164
166
}
165
167
}
166
168
167
- // ! End Autoconnected SLOTS *
168
-
169
- QgsOracleNewConnection::~QgsOracleNewConnection ()
170
- {
171
- }
172
-
173
-
174
169
void QgsOracleNewConnection::showHelp ()
175
170
{
176
171
QgsHelp::openHelp ( QStringLiteral ( " managing_data_source/opening_data.html#connecting-to-oracle-spatial" ) );
0 commit comments