Skip to content
Permalink
Browse files

followup to r7672: updated spitplugin

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7673 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Nov 27, 2007
1 parent 3e0b7e4 commit f7e689db4ec7e05fbb16930fae63ee639f3ba1dc
Showing with 20 additions and 16 deletions.
  1. +11 −10 src/plugins/spit/qgsconnectiondialog.cpp
  2. +9 −6 src/plugins/spit/qgsspit.cpp
@@ -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)
@@ -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);
}

@@ -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"
@@ -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 )
{

0 comments on commit f7e689d

Please sign in to comment.
You can’t perform that action at this time.