Skip to content

Commit 529173f

Browse files
committed
[oracle] Fix clazy warnings in new connection dialog
1 parent 9242d2f commit 529173f

File tree

2 files changed

+54
-58
lines changed

2 files changed

+54
-58
lines changed

src/providers/oracle/qgsoraclenewconnection.cpp

+49-54
Original file line numberDiff line numberDiff line change
@@ -26,69 +26,71 @@
2626
#include "qgsoracleconnpool.h"
2727

2828
QgsOracleNewConnection::QgsOracleNewConnection( QWidget *parent, const QString &connName, Qt::WindowFlags fl )
29-
: QDialog( parent, fl ), mOriginalConnName( connName )
29+
: QDialog( parent, fl )
30+
, mOriginalConnName( connName )
3031
{
3132
setupUi( this );
3233
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsOracleNewConnection::showHelp );
34+
connect( btnConnect, &QPushButton::clicked, this, &QgsOracleNewConnection::testConnection );
3335

3436
if ( !connName.isEmpty() )
3537
{
3638
// populate the dialog with the information stored for the connection
3739
// populate the fields with the stored setting parameters
3840
QgsSettings settings;
3941

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();
4446
if ( port.length() == 0 )
4547
{
46-
port = "1521";
48+
port = QStringLiteral( "1521" );
4749
}
4850
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" ) )
5961
{
60-
txtUsername->setText( settings.value( key + "/username" ).toString() );
62+
txtUsername->setText( settings.value( key + QStringLiteral( "/username" ) ).toString() );
6163
chkStoreUsername->setChecked( true );
6264
}
6365

64-
if ( settings.value( key + "/savePassword" ).toString() == "true" )
66+
if ( settings.value( key + QStringLiteral( "/savePassword" ) ).toString() == QLatin1String( "true" ) )
6567
{
66-
txtPassword->setText( settings.value( key + "/password" ).toString() );
68+
txtPassword->setText( settings.value( key + QStringLiteral( "/password" ) ).toString() );
6769
chkStorePassword->setChecked( true );
6870
}
6971

7072
// Old save setting
71-
if ( settings.contains( key + "/save" ) )
73+
if ( settings.contains( key + QStringLiteral( "/save" ) ) )
7274
{
73-
txtUsername->setText( settings.value( key + "/username" ).toString() );
75+
txtUsername->setText( settings.value( key + QStringLiteral( "/username" ) ).toString() );
7476
chkStoreUsername->setChecked( !txtUsername->text().isEmpty() );
7577

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() );
7880

7981
chkStorePassword->setChecked( true );
8082
}
8183

8284
txtName->setText( connName );
8385
}
84-
txtName->setValidator( new QRegExpValidator( QRegExp( "[^\\/]+" ), txtName ) );
86+
txtName->setValidator( new QRegExpValidator( QRegExp( QStringLiteral( "[^\\/]+" ) ), txtName ) );
8587
}
86-
//! Autoconnected SLOTS *
88+
8789
void QgsOracleNewConnection::accept()
8890
{
8991
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() );
9294

9395
if ( chkStorePassword->isChecked() &&
9496
QMessageBox::question( this,
@@ -101,8 +103,8 @@ void QgsOracleNewConnection::accept()
101103

102104
// warn if entry was renamed to an existing connection
103105
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" ) ) ) &&
106108
QMessageBox::question( this,
107109
tr( "Save Connection" ),
108110
tr( "Should the existing connection %1 be overwritten?" ).arg( txtName->text() ),
@@ -119,33 +121,33 @@ void QgsOracleNewConnection::accept()
119121
}
120122

121123
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() );
137139

138140
QDialog::accept();
139141
}
140142

141-
void QgsOracleNewConnection::on_btnConnect_clicked()
143+
void QgsOracleNewConnection::testConnection()
142144
{
143145
QgsDataSourceUri uri;
144146
uri.setConnection( txtHost->text(), txtPort->text(), txtDatabase->text(), txtUsername->text(), txtPassword->text() );
145147
if ( !txtOptions->text().isEmpty() )
146-
uri.setParam( "dboptions", txtOptions->text() );
148+
uri.setParam( QStringLiteral( "dboptions" ), txtOptions->text() );
147149
if ( !txtWorkspace->text().isEmpty() )
148-
uri.setParam( "dbworkspace", txtWorkspace->text() );
150+
uri.setParam( QStringLiteral( "dbworkspace" ), txtWorkspace->text() );
149151

150152
QgsOracleConn *conn = QgsOracleConnPool::instance()->acquireConnection( QgsOracleConn::toPoolName( uri ) );
151153

@@ -164,13 +166,6 @@ void QgsOracleNewConnection::on_btnConnect_clicked()
164166
}
165167
}
166168

167-
//! End Autoconnected SLOTS *
168-
169-
QgsOracleNewConnection::~QgsOracleNewConnection()
170-
{
171-
}
172-
173-
174169
void QgsOracleNewConnection::showHelp()
175170
{
176171
QgsHelp::openHelp( QStringLiteral( "managing_data_source/opening_data.html#connecting-to-oracle-spatial" ) );

src/providers/oracle/qgsoraclenewconnection.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@ class QgsOracleNewConnection : public QDialog, private Ui::QgsOracleNewConnectio
3131
public:
3232
//! Constructor
3333
QgsOracleNewConnection( QWidget *parent = nullptr, const QString &connName = QString(), Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
34-
//! Destructor
35-
~QgsOracleNewConnection();
3634

3735
QString originalConnName() const { return mOriginalConnName; }
3836
QString connName() const { return txtName->text(); }
3937

4038
public slots:
41-
void accept();
42-
void on_btnConnect_clicked();
39+
void accept() override;
40+
41+
private slots:
42+
void testConnection();
43+
4344
private:
4445
QString mOriginalConnName; //store initial name to delete entry in case of rename
4546
void showHelp();

0 commit comments

Comments
 (0)