From 9b7d389736b0eb87b98c336628d5daad3fb1f72b Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Fri, 19 May 2017 13:57:16 +0300 Subject: [PATCH 1/5] use messagebar to report test connection results in the Add new PostGIS connection dialog --- src/providers/postgres/qgspgnewconnection.cpp | 16 +- src/providers/postgres/qgspgnewconnection.h | 2 + src/ui/qgspgnewconnectionbase.ui | 267 +++++++++--------- 3 files changed, 140 insertions(+), 145 deletions(-) diff --git a/src/providers/postgres/qgspgnewconnection.cpp b/src/providers/postgres/qgspgnewconnection.cpp index 646de64d30f..79f5da8d1a1 100644 --- a/src/providers/postgres/qgspgnewconnection.cpp +++ b/src/providers/postgres/qgspgnewconnection.cpp @@ -104,6 +104,12 @@ QgsPgNewConnection::QgsPgNewConnection( QWidget *parent, const QString &connName txtName->setText( connName ); } } + +QgsPgNewConnection::~QgsPgNewConnection() +{ + delete bar; +} + //! Autoconnected SLOTS * void QgsPgNewConnection::accept() { @@ -201,17 +207,15 @@ void QgsPgNewConnection::testConnection() if ( conn ) { // Database successfully opened; we can now issue SQL commands. - QMessageBox::information( this, - tr( "Test connection" ), - tr( "Connection to %1 was successful" ).arg( txtDatabase->text() ) ); + bar->pushMessage( tr( "Connection to %1 was successful" ).arg( txtDatabase->text() ), + QgsMessageBar::INFO ); // free pg connection resources conn->unref(); } else { - QMessageBox::information( this, - tr( "Test connection" ), - tr( "Connection failed - consult message log for details.\n\n" ) ); + bar->pushMessage( tr( "Connection failed - consult message log for details." ), + QgsMessageBar::WARNING ); } } diff --git a/src/providers/postgres/qgspgnewconnection.h b/src/providers/postgres/qgspgnewconnection.h index 6765a5f5fcb..f55197a8546 100644 --- a/src/providers/postgres/qgspgnewconnection.h +++ b/src/providers/postgres/qgspgnewconnection.h @@ -32,6 +32,8 @@ class QgsPgNewConnection : public QDialog, private Ui::QgsPgNewConnectionBase //! Constructor QgsPgNewConnection( QWidget *parent = nullptr, const QString &connName = QString::null, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags ); + ~QgsPgNewConnection(); + //! Tests the connection using the parameters supplied void testConnection(); public slots: diff --git a/src/ui/qgspgnewconnectionbase.ui b/src/ui/qgspgnewconnectionbase.ui index 35fe15a9fbe..81adf614acb 100644 --- a/src/ui/qgspgnewconnectionbase.ui +++ b/src/ui/qgspgnewconnectionbase.ui @@ -26,32 +26,110 @@ true - + QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok - + Connection Information - - - 5 - - - 5 - - - 0 - - - 5 - - + + + + + + + Name + + + txtName + + + + + + + Name of the new connection + + + + + + + Service + + + txtService + + + + + + + + + + Host + + + txtHost + + + + + + + + + + Port + + + txtPort + + + + + + + 5432 + + + + + + + Database + + + txtDatabase + + + + + + + + + + SSL mode + + + cbxSSLmode + + + + + + + + + @@ -127,7 +205,14 @@ - + + + + &Test Connection + + + + Restrict the displayed tables to those that are in the layer registries. @@ -140,112 +225,27 @@ - - - - - - - - Name - - - txtName - - - - - - - Service - - - txtService - - - - - - - Host - - - txtHost - - - - - - - Port - - - txtPort - - - - - - - Database - - - txtDatabase - - - - - - - SSL mode - - - cbxSSLmode - - - - - - - - - - - Name of the new connection - - - - - - - - - - - - - 5432 - - - - - - - - - - - - - - + Don't resolve type of unrestricted columns (GEOMETRY) - + + + + Restrict the search to the public schema for spatial tables not in the geometry_columns table + + + When searching for spatial tables that are not in the geometry_columns tables, restrict the search to tables that are in the public schema (for some databases this can save lots of time) + + + Only look in the 'public' schema + + + + Also list tables with no geometry @@ -255,7 +255,7 @@ - + Use estimated table statistics for the layer metadata. @@ -276,27 +276,7 @@ - - - - &Test Connection - - - - - - - Restrict the search to the public schema for spatial tables not in the geometry_columns table - - - When searching for spatial tables that are not in the geometry_columns tables, restrict the search to tables that are in the public schema (for some databases this can save lots of time) - - - Only look in the 'public' schema - - - - + Qt::Vertical @@ -312,6 +292,9 @@ + + + @@ -321,6 +304,12 @@ QLineEdit
qgspasswordlineedit.h
+ + QgsMessageBar + QWidget +
qgsmessagebar.h
+ 1 +
txtName From 1f8d1e7fe94afd8d11897826895671a7c8810544 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Fri, 19 May 2017 15:16:07 +0300 Subject: [PATCH 2/5] use messagebar to report test connection results in the Add new BD2 connection dialog Also reduce debug noise --- src/providers/db2/qgsdb2newconnection.cpp | 11 ++++--- src/ui/qgsdb2newconnectionbase.ui | 36 ++++++++++++----------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/providers/db2/qgsdb2newconnection.cpp b/src/providers/db2/qgsdb2newconnection.cpp index b7a6bb757fd..5799a99f228 100644 --- a/src/providers/db2/qgsdb2newconnection.cpp +++ b/src/providers/db2/qgsdb2newconnection.cpp @@ -50,7 +50,6 @@ QgsDb2NewConnection::QgsDb2NewConnection( QWidget *parent, const QString &connNa txtDriver->setText( settings.value( key + "/driver" ).toString() ); txtDatabase->setText( settings.value( key + "/database" ).toString() ); - if ( settings.value( key + "/saveUsername" ).toString() == QLatin1String( "true" ) ) { txtUsername->setText( settings.value( key + "/username" ).toString() ); @@ -129,7 +128,6 @@ void QgsDb2NewConnection::accept() void QgsDb2NewConnection::on_btnConnect_clicked() { - QgsDebugMsg( "DB2: TestDatabase; button clicked" ); testConnection(); } @@ -147,7 +145,7 @@ void QgsDb2NewConnection::on_cb_trustedConnection_clicked() QgsDb2NewConnection::~QgsDb2NewConnection() { - + delete bar; } bool QgsDb2NewConnection::testConnection() @@ -179,18 +177,19 @@ bool QgsDb2NewConnection::testConnection() if ( errMsg.isEmpty() ) { QgsDebugMsg( "connection open succeeded " + connInfo ); - db2ConnectStatus -> setText( QStringLiteral( "DB2 connection open succeeded" ) ); + bar->pushMessage( tr( "Connection to %1 was successful" ).arg( txtDatabase->text() ), + QgsMessageBar::INFO ); return true; } else { QgsDebugMsg( "connection open failed: " + errMsg ); - db2ConnectStatus -> setText( "DB2 connection failed : " + errMsg ); + bar->pushMessage( tr( "Connection failed: %1." ).arg( errMsg ), + QgsMessageBar::WARNING ); return false; } } void QgsDb2NewConnection::listDatabases() { - QgsDebugMsg( "DB2 New Connection Dialogue : list database" ); } diff --git a/src/ui/qgsdb2newconnectionbase.ui b/src/ui/qgsdb2newconnectionbase.ui index c89b7344e73..77ce1b3fb45 100644 --- a/src/ui/qgsdb2newconnectionbase.ui +++ b/src/ui/qgsdb2newconnectionbase.ui @@ -15,23 +15,6 @@ - - - DB2 Connect Status: - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - Connection Information @@ -196,6 +179,19 @@ + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + @@ -204,6 +200,12 @@ QLineEdit
qgspasswordlineedit.h
+ + QgsMessageBar + QWidget +
qgsmessagebar.h
+ 1 +
txtName From a49c17538c984b394161998bbca0ae0b9d5ad554 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Fri, 19 May 2017 15:19:33 +0300 Subject: [PATCH 3/5] use messagebar to report test connection results in the Add new Oracle connection dialog --- src/providers/oracle/qgsoraclenewconnection.cpp | 12 +++++------- src/ui/qgsoraclenewconnectionbase.ui | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/providers/oracle/qgsoraclenewconnection.cpp b/src/providers/oracle/qgsoraclenewconnection.cpp index f374a9349be..20d6f30dd60 100644 --- a/src/providers/oracle/qgsoraclenewconnection.cpp +++ b/src/providers/oracle/qgsoraclenewconnection.cpp @@ -150,18 +150,15 @@ void QgsOracleNewConnection::on_btnConnect_clicked() if ( conn ) { // Database successfully opened; we can now issue SQL commands. - QMessageBox::information( this, - tr( "Test connection" ), - tr( "Connection to %1 was successful" ).arg( txtDatabase->text() ) ); - + bar->pushMessage( tr( "Connection to %1 was successful" ).arg( txtDatabase->text() ), + QgsMessageBar::INFO ); // free connection resources QgsOracleConnPool::instance()->releaseConnection( conn ); } else { - QMessageBox::information( this, - tr( "Test connection" ), - tr( "Connection failed - consult message log for details.\n\n" ) ); + bar->pushMessage( tr( "Connection failed - consult message log for details." ), + QgsMessageBar::WARNING ); } } @@ -169,4 +166,5 @@ void QgsOracleNewConnection::on_btnConnect_clicked() QgsOracleNewConnection::~QgsOracleNewConnection() { + delete bar; } diff --git a/src/ui/qgsoraclenewconnectionbase.ui b/src/ui/qgsoraclenewconnectionbase.ui index 3daf938fdf8..6dcd1d5b35b 100644 --- a/src/ui/qgsoraclenewconnectionbase.ui +++ b/src/ui/qgsoraclenewconnectionbase.ui @@ -7,7 +7,7 @@ 0 0 400 - 513 + 529 @@ -41,14 +41,14 @@ 6 - + QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok - + Connection Information @@ -277,6 +277,9 @@ + + + @@ -286,6 +289,12 @@ QLineEdit
qgspasswordlineedit.h
+ + QgsMessageBar + QWidget +
qgsmessagebar.h
+ 1 +
txtName From 99cd1c2b9bc5ecd2754e41e3b7601dab6aa9b441 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Fri, 19 May 2017 17:55:31 +0300 Subject: [PATCH 4/5] manual deleting of messagebar is not necessary --- src/providers/db2/qgsdb2newconnection.cpp | 1 - src/providers/mssql/qgsmssqlnewconnection.cpp | 1 - src/providers/oracle/qgsoraclenewconnection.cpp | 1 - src/providers/postgres/qgspgnewconnection.cpp | 2 +- 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/providers/db2/qgsdb2newconnection.cpp b/src/providers/db2/qgsdb2newconnection.cpp index 5799a99f228..13530658e5d 100644 --- a/src/providers/db2/qgsdb2newconnection.cpp +++ b/src/providers/db2/qgsdb2newconnection.cpp @@ -145,7 +145,6 @@ void QgsDb2NewConnection::on_cb_trustedConnection_clicked() QgsDb2NewConnection::~QgsDb2NewConnection() { - delete bar; } bool QgsDb2NewConnection::testConnection() diff --git a/src/providers/mssql/qgsmssqlnewconnection.cpp b/src/providers/mssql/qgsmssqlnewconnection.cpp index abeaeefae8c..d6fdc0662a4 100644 --- a/src/providers/mssql/qgsmssqlnewconnection.cpp +++ b/src/providers/mssql/qgsmssqlnewconnection.cpp @@ -143,7 +143,6 @@ void QgsMssqlNewConnection::on_cb_trustedConnection_clicked() QgsMssqlNewConnection::~QgsMssqlNewConnection() { - delete bar; } bool QgsMssqlNewConnection::testConnection( const QString &testDatabase ) diff --git a/src/providers/oracle/qgsoraclenewconnection.cpp b/src/providers/oracle/qgsoraclenewconnection.cpp index 20d6f30dd60..5c299b4b258 100644 --- a/src/providers/oracle/qgsoraclenewconnection.cpp +++ b/src/providers/oracle/qgsoraclenewconnection.cpp @@ -166,5 +166,4 @@ void QgsOracleNewConnection::on_btnConnect_clicked() QgsOracleNewConnection::~QgsOracleNewConnection() { - delete bar; } diff --git a/src/providers/postgres/qgspgnewconnection.cpp b/src/providers/postgres/qgspgnewconnection.cpp index 79f5da8d1a1..444610a21d6 100644 --- a/src/providers/postgres/qgspgnewconnection.cpp +++ b/src/providers/postgres/qgspgnewconnection.cpp @@ -107,7 +107,7 @@ QgsPgNewConnection::QgsPgNewConnection( QWidget *parent, const QString &connName QgsPgNewConnection::~QgsPgNewConnection() { - delete bar; + } //! Autoconnected SLOTS * From 2c5e52b3f132cbb2eb792223b946af7228e5c978 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Tue, 23 May 2017 09:00:10 +0300 Subject: [PATCH 5/5] remove not used variable --- src/providers/db2/qgsdb2newconnection.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/providers/db2/qgsdb2newconnection.cpp b/src/providers/db2/qgsdb2newconnection.cpp index 13530658e5d..0b313c803d4 100644 --- a/src/providers/db2/qgsdb2newconnection.cpp +++ b/src/providers/db2/qgsdb2newconnection.cpp @@ -167,7 +167,8 @@ bool QgsDb2NewConnection::testConnection() if ( !rc ) { - db2ConnectStatus -> setText( errMsg ); + bar->pushMessage( tr( "Error: %1." ).arg( errMsg ), + QgsMessageBar::WARNING ); QgsDebugMsg( "errMsg: " + errMsg ); return false; }