Skip to content

Commit

Permalink
followup to r7672: updated spitplugin
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7673 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 27, 2007
1 parent 3e0b7e4 commit f7e689d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
21 changes: 11 additions & 10 deletions src/plugins/spit/qgsconnectiondialog.cpp
Expand Up @@ -29,6 +29,7 @@ extern "C"

#include "qgsconnectiondialog.h"
#include "qgsmessageviewer.h"
#include "qgsdatasourceuri.h"

QgsConnectionDialog::QgsConnectionDialog(QWidget *parent, const QString& connName, Qt::WFlags fl)
: QDialog(parent, fl)
Expand Down Expand Up @@ -62,17 +63,17 @@ QgsConnectionDialog::~QgsConnectionDialog()

void QgsConnectionDialog::testConnection()
{
QString connInfo = "host=" + txtHost->text() + " dbname=" + txtDatabase->text() +
" port=" + txtPort->text() + " user=" + txtUsername->text() + " password=" + txtPassword->text();
PGconn *pd = PQconnectdb((const char *) connInfo);
QgsDataSourceURI uri;
uri.setConnection( txtHost->text(), txtPort->text(), txtDatabase->text(), txtUsername->text(), txtPassword->text() );
PGconn *pd = PQconnectdb((const char *) uri.connInfo() );

if (PQstatus(pd) == CONNECTION_OK) {
// Database successfully opened; we can now issue SQL commands.
QMessageBox::information(this, tr("Test connection"), tr("Connection to ") + txtDatabase->text() + tr(" was successfull"));
} else {
QMessageBox::information(this, tr("Test connection"), tr("Connection failed - Check settings and try again "));
}

if (PQstatus(pd) == CONNECTION_OK) {
// Database successfully opened; we can now issue SQL commands.
QMessageBox::information(this, tr("Test connection"), tr("Connection to ") + txtDatabase->text() + tr(" was successfull"));
} else {
QMessageBox::information(this, tr("Test connection"), tr("Connection failed - Check settings and try again "));
}

PQfinish(pd);
}

Expand Down
15 changes: 9 additions & 6 deletions src/plugins/spit/qgsspit.cpp
Expand Up @@ -36,6 +36,7 @@
#include "qgspgutil.h"
#include "qgsspit.h"
#include "qgsconnectiondialog.h"
#include "qgsdatasourceuri.h"
#include "qgseditreservedwordsdialog.h"
#include "qgsmessageviewer.h"
#include "spiticon.xpm"
Expand Down Expand Up @@ -431,12 +432,14 @@ PGconn* QgsSpit::checkConnection()
}
else
{
QString connInfo = "host=" + settings.readEntry( gl_key + connName + "/host" ) +
" dbname=" + settings.readEntry( gl_key + connName + "/database" ) +
" port=" + settings.readEntry( gl_key + connName + "/port" ) +
" user=" + settings.readEntry( gl_key + connName + "/username" ) +
" password=" + settings.readEntry( gl_key + connName + "/password" );
pd = PQconnectdb( ( const char * ) connInfo );
QgsDataSourceURI uri;
uri.setConnection( settings.readEntry( gl_key + connName + "/host" ),
settings.readEntry( gl_key + connName + "/port" ),
settings.readEntry( gl_key + connName + "/database" ),
settings.readEntry( gl_key + connName + "/username" ),
settings.readEntry( gl_key + connName + "/password" ) );

pd = PQconnectdb( ( const char * ) uri.connInfo() );

if ( PQstatus( pd ) != CONNECTION_OK )
{
Expand Down

0 comments on commit f7e689d

Please sign in to comment.