[QGIS Commit] r8158 - branches/ogr-plugin-branch/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Feb 14 11:48:13 EST 2008


Author: gcontreras
Date: 2008-02-14 11:48:13 -0500 (Thu, 14 Feb 2008)
New Revision: 8158

Added:
   branches/ogr-plugin-branch/src/app/qgsnewogrgenericconnection.cpp
   branches/ogr-plugin-branch/src/app/qgsnewogrgenericconnection.h
Modified:
   branches/ogr-plugin-branch/src/app/CMakeLists.txt
Log:
Implementation of NewOgrGenericConnection dialog

Modified: branches/ogr-plugin-branch/src/app/CMakeLists.txt
===================================================================
--- branches/ogr-plugin-branch/src/app/CMakeLists.txt	2008-02-14 15:37:19 UTC (rev 8157)
+++ branches/ogr-plugin-branch/src/app/CMakeLists.txt	2008-02-14 16:48:13 UTC (rev 8158)
@@ -37,6 +37,7 @@
 qgsmeasuredialog.cpp
 qgsmeasuretool.cpp
 qgsnewhttpconnection.cpp
+qgsnewogrgenericconnection.cpp
 qgsnumericsortlistviewitem.cpp
 qgsoptions.cpp
 qgspastetransformations.cpp
@@ -64,6 +65,12 @@
 composer/qgscomposerview.cpp
 composer/qgscomposition.cpp
 
+dbutilities/qgsconnectionregistry.cpp
+dbutilities/qgsdatabaseconnection.cpp
+dbutilities/qgsgeomcolumntypethread.cpp
+dbutilities/qgsogrdatabaseconnection.cpp
+dbutilities/qgspostgresdatabaseconnection.cpp
+
 legend/qgslegendgroup.cpp
 legend/qgslegend.cpp
 legend/qgslegenditem.cpp
@@ -106,6 +113,7 @@
 qgsmarkerdialog.h
 qgsmeasuredialog.h
 qgsnewhttpconnection.h
+qgsnewogrgenericconnection.h
 qgsoptions.h
 qgspastetransformations.h
 qgspatterndialog.h
@@ -193,7 +201,7 @@
 
 
 INCLUDE_DIRECTORIES(
-     ${CMAKE_CURRENT_SOURCE_DIR} composer legend
+     ${CMAKE_CURRENT_SOURCE_DIR} composer legend dbutilities
      ${CMAKE_CURRENT_BINARY_DIR}
      ${CMAKE_CURRENT_BINARY_DIR}/../ui
      ../core

Added: branches/ogr-plugin-branch/src/app/qgsnewogrgenericconnection.cpp
===================================================================
--- branches/ogr-plugin-branch/src/app/qgsnewogrgenericconnection.cpp	                        (rev 0)
+++ branches/ogr-plugin-branch/src/app/qgsnewogrgenericconnection.cpp	2008-02-14 16:48:13 UTC (rev 8158)
@@ -0,0 +1,109 @@
+/***************************************************************************
+                    qgsnewogrgenericconnection.cpp  -  description
+                             -------------------
+    begin                : Wen Jan 08 2008
+    copyright            : (C) 2008 by Godofredo Contreras
+    email                : frdcn at hotmail.com
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+ /* $Id: qgsnewogrconnection.cpp 7413 2007-11-15 19:34:15Z godofredo $ */
+ 
+#include <iostream>
+
+#include <QSettings>
+#include <QMessageBox>
+
+#include "qgsnewogrgenericconnection.h"
+#include "qgscontexthelp.h"
+extern "C"
+{
+#include <libpq-fe.h>
+}
+QgsNewOgrGenericConnection::QgsNewOgrGenericConnection(QWidget *parent, const QgsConnectionParameters* conn, Qt::WFlags fl)
+: QDialog(parent, fl)
+{
+  setupUi(this);
+ 
+  //create member objects
+  mConnReg=new QgsConnectionRegistry;
+  
+  if (conn!=NULL)
+    {
+      txtName->setText(conn->name);
+      txtUri->setText(conn->uri);
+    } 
+      
+  
+}
+
+/** Autoconnected SLOTS **/
+void QgsNewOgrGenericConnection::on_btnOk_clicked()
+{
+  saveConnection();
+}
+void QgsNewOgrGenericConnection::on_btnHelp_clicked()
+{
+ helpInfo();
+}
+void QgsNewOgrGenericConnection::on_btnConnect_clicked()
+{
+  testConnection();
+}
+void QgsNewOgrGenericConnection::on_btnCancel_clicked(){
+  // cancel the dialog
+  reject();
+}
+
+
+/** end  Autoconnected SLOTS **/
+
+QgsNewOgrGenericConnection::~QgsNewOgrGenericConnection()
+{
+  delete mConnReg;                                   
+}
+void QgsNewOgrGenericConnection::testConnection()
+{
+  QgsConnectionParameters connPar;
+  connPar.type="OgrGeneric";
+  connPar.name=txtName->text();
+  connPar.uri=txtUri->text();
+  QgsDatabaseConnection* connection=new QgsOgrDatabaseConnection(&connPar);
+  connection->setUri(txtUri->text());
+  if (connection->connect())
+    {
+      // Database successfully opened; we can now issue SQL commands.
+      QMessageBox::information(this, tr("Test connection"), tr("Connection to %1 was successful").arg(txtUri->text()));
+    } else
+    {
+      QMessageBox::information(this, tr("Test connection"), tr("Connection failed - Check settings and try again.\n\nExtended error information:\n") +connection->error());
+    }
+ qDebug("Step three");
+ delete connection;
+}
+
+void QgsNewOgrGenericConnection::saveConnection()
+{
+  QgsConnectionParameters conn;   
+  
+  conn.type="OgrGeneric";
+  conn.name=txtName->text();
+  conn.uri=txtUri->text();
+  
+  mConnReg->saveConnection(conn);
+  mConnReg->setSelectedType(conn.type);
+  mConnReg->setSelected(conn.type,conn.name);                       
+  accept();
+}
+
+void QgsNewOgrGenericConnection::helpInfo()
+{
+  QgsContextHelp::run(context_id);
+}

Added: branches/ogr-plugin-branch/src/app/qgsnewogrgenericconnection.h
===================================================================
--- branches/ogr-plugin-branch/src/app/qgsnewogrgenericconnection.h	                        (rev 0)
+++ branches/ogr-plugin-branch/src/app/qgsnewogrgenericconnection.h	2008-02-14 16:48:13 UTC (rev 8158)
@@ -0,0 +1,55 @@
+/***************************************************************************
+                    qgsnewogrgenericconnection.cpp  -  description
+                             -------------------
+    begin                : Wen Jan 08 2008
+    copyright            : (C) 2008 by Godofredo Contreras
+    email                : frdcn at hotmail.com
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+ /* $Id: qgsnewogrconnection.cpp 7413 2007-11-15 19:34:15Z godofredo $ */
+#ifndef QGSNEWOGRGENERICCONNECTION_H
+#define QGSNEWOGRGENERICCONNECTION_H
+#include "ui_qgsnewogrgenericconnectionbase.h"
+#include "qgisgui.h"
+#include "qgsconnectionparameters.h"
+#include "qgsconnectionregistry.h"
+#include "qgsdatabaseconnection.h"
+#include "qgsogrdatabaseconnection.h"
+/*! \class QgsNewConnection
+ * \brief Dialog to allow the user to configure and save connection
+ * information for a PostgresQl database
+ */
+class QgsNewOgrGenericConnection : public QDialog, private Ui::QgsNewOgrGenericConnectionBase 
+{
+  Q_OBJECT
+  public:
+    //! Constructor
+    QgsNewOgrGenericConnection(QWidget *parent = 0, const QgsConnectionParameters* conn=0, Qt::WFlags fl = QgisGui::ModalDialogFlags);
+    //! Destructor
+    ~QgsNewOgrGenericConnection();
+    //! Tests the connection using the parameters supplied
+    void testConnection();
+    //! Saves the connection to ~/.qt/qgisrc
+    void saveConnection();
+    //! Display the context help
+    void helpInfo();
+  public slots:
+    void on_btnOk_clicked();
+    void on_btnCancel_clicked();
+    void on_btnHelp_clicked();
+    void on_btnConnect_clicked();
+    //void on_cb_geometryColumnsOnly_clicked();
+  private:
+    QgsConnectionRegistry* mConnReg;
+    static const int context_id = 929865718;
+};
+
+#endif //  QGSNEWCONNECTIONBASE_H



More information about the QGIS-commit mailing list