Skip to content

Commit

Permalink
use messagebar to report test connection results in the Add new BD2
Browse files Browse the repository at this point in the history
connection dialog

Also reduce debug noise
  • Loading branch information
alexbruy committed May 23, 2017
1 parent 9b7d389 commit 1f8d1e7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
11 changes: 5 additions & 6 deletions src/providers/db2/qgsdb2newconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down Expand Up @@ -129,7 +128,6 @@ void QgsDb2NewConnection::accept()

void QgsDb2NewConnection::on_btnConnect_clicked()
{
QgsDebugMsg( "DB2: TestDatabase; button clicked" );
testConnection();
}

Expand All @@ -147,7 +145,7 @@ void QgsDb2NewConnection::on_cb_trustedConnection_clicked()

QgsDb2NewConnection::~QgsDb2NewConnection()
{

delete bar;
}

bool QgsDb2NewConnection::testConnection()
Expand Down Expand Up @@ -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" );
}
36 changes: 19 additions & 17 deletions src/ui/qgsdb2newconnectionbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,6 @@
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QLabel" name="db2ConnectStatus">
<property name="text">
<string>DB2 Connect Status: </string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Connection Information</string>
Expand Down Expand Up @@ -196,6 +179,19 @@
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QgsMessageBar" name="bar" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
Expand All @@ -204,6 +200,12 @@
<extends>QLineEdit</extends>
<header>qgspasswordlineedit.h</header>
</customwidget>
<customwidget>
<class>QgsMessageBar</class>
<extends>QWidget</extends>
<header>qgsmessagebar.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>txtName</tabstop>
Expand Down

0 comments on commit 1f8d1e7

Please sign in to comment.