From 6e08a95191945066b7bc3a76a3f4833c7f394e0e Mon Sep 17 00:00:00 2001 From: gsherman Date: Fri, 30 May 2003 04:26:35 +0000 Subject: [PATCH] Fixes to PostGIS data selector git-svn-id: http://svn.osgeo.org/qgis/trunk@217 c8812cc2-4d05-0410-92ff-de0c093fc19c --- qgis/src/qgisapp.cpp | 7 +- qgis/src/qgsdbsourceselect.cpp | 40 +++++++-- qgis/src/qgsdbsourceselect.h | 4 + qgis/src/qgsdbsourceselectbase.ui | 127 ++++++++++++++++------------ qgis/src/qgsdbsourceselectbase.ui.h | 5 ++ 5 files changed, 116 insertions(+), 67 deletions(-) diff --git a/qgis/src/qgisapp.cpp b/qgis/src/qgisapp.cpp index bd20ffa0d69..ea08b929f7f 100644 --- a/qgis/src/qgisapp.cpp +++ b/qgis/src/qgisapp.cpp @@ -204,9 +204,10 @@ void QgisApp::about() abt->setURLs(urls); QString watsNew = "Version "; watsNew += qgisVersion; - watsNew += "\n*Fixes to project save/open support\n" - "*Enhancements to plugin tests\n" - "*Fixes to build system\n"; + watsNew += "\n*Preliminary Plugin Manager implementation\n" + "*Fix for PostGIS bug when srid != -1\n" + "*Database Connections can now be deleted\n" + "*Fixes to Database Connection dialog\n"; abt->setWhatsNew(watsNew); diff --git a/qgis/src/qgsdbsourceselect.cpp b/qgis/src/qgsdbsourceselect.cpp index 967dba1d0cf..47ae5fb77b8 100644 --- a/qgis/src/qgsdbsourceselect.cpp +++ b/qgis/src/qgsdbsourceselect.cpp @@ -31,14 +31,7 @@ QgsDbSourceSelect::QgsDbSourceSelect(QWidget *parent, const char *name):QgsDbSourceSelectBase() { - QSettings settings; - QStringList keys = settings.subkeyList("/Qgis/connections"); - QStringList::Iterator it = keys.begin(); - while (it != keys.end()) { - cmbConnections->insertItem(*it); - - ++it; - } + populateConnectionList(); // connect the double-click signal to the addSingleLayer slot in the parent @@ -46,6 +39,18 @@ QgsDbSourceSelect::QgsDbSourceSelect(QWidget *parent, const char *name):QgsDbSou QgsDbSourceSelect::~QgsDbSourceSelect() { +} +void QgsDbSourceSelect::populateConnectionList(){ + QSettings settings; + QStringList keys = settings.subkeyList("/Qgis/connections"); + QStringList::Iterator it = keys.begin(); + cmbConnections->clear(); + while (it != keys.end()) { + cmbConnections->insertItem(*it); + + ++it; + } + } void QgsDbSourceSelect::addNewConnection() { @@ -53,6 +58,7 @@ void QgsDbSourceSelect::addNewConnection() QgsNewConnection *nc = new QgsNewConnection(); if (nc->exec()) { + populateConnectionList(); } } void QgsDbSourceSelect::editConnection() @@ -64,6 +70,24 @@ void QgsDbSourceSelect::editConnection() nc->saveConnection(); } } + +void QgsDbSourceSelect::deleteConnection(){ + QSettings settings; + QString key = "/Qgis/connections/" + cmbConnections->currentText(); + QString msg = "Are you sure you want to remove the " + cmbConnections->currentText() + " connection and all associated settings?"; + int result = QMessageBox::information(this, "Confirm Delete", msg, "Yes", "No"); + if(result == 0){ + settings.removeEntry(key + "/host"); + settings.removeEntry(key + "/database"); + settings.removeEntry(key + "/username"); + settings.removeEntry(key + "/password"); + //if(!success){ + // QMessageBox::information(this,"Unable to Remove","Unable to remove the connection " + cmbConnections->currentText()); + //} + cmbConnections->removeItem(cmbConnections->currentItem());// populateConnectionList(); + } +} + void QgsDbSourceSelect::addTables() { //store the table info diff --git a/qgis/src/qgsdbsourceselect.h b/qgis/src/qgsdbsourceselect.h index 76a204d88c3..0f664425a1d 100644 --- a/qgis/src/qgsdbsourceselect.h +++ b/qgis/src/qgsdbsourceselect.h @@ -36,6 +36,10 @@ class QgsDbSourceSelect : public QgsDbSourceSelectBase void addNewConnection(); //! Opens a dialog to edit an existing connection void editConnection(); + //! Deletes the selected connection + void deleteConnection(); + //! Populate the connection list combo box + void populateConnectionList(); //! Determines the tables the user selected and closes the dialog void addTables(); /*! Connects to the database using the stored connection parameters. diff --git a/qgis/src/qgsdbsourceselectbase.ui b/qgis/src/qgsdbsourceselectbase.ui index eebd4d41382..a01ce18a8fc 100644 --- a/qgis/src/qgsdbsourceselectbase.ui +++ b/qgis/src/qgsdbsourceselectbase.ui @@ -1,4 +1,4 @@ - + QgsDbSourceSelectBase @@ -8,7 +8,7 @@ 0 0 - 305 + 327 338 @@ -56,7 +56,7 @@ Add - 0 + true @@ -73,7 +73,7 @@ Cancel - 0 + true @@ -87,7 +87,7 @@ Help - 4144 + F1 true @@ -112,54 +112,6 @@ - - - GroupBox1 - - - Connection Information - - - - unnamed - - - 11 - - - 6 - - - - cmbConnections - - - - - btnConnect - - - Connect - - - - - btnEdit - - - Edit - - - - - btnNew - - - New - - - - TextLabel3_2_2 @@ -181,6 +133,62 @@ Extended + + + GroupBox1 + + + Connection Information + + + + unnamed + + + 11 + + + 6 + + + + cmbConnections + + + + + btnConnect + + + Connect + + + + + btnNew + + + New + + + + + btnEdit + + + Edit + + + + + btnDelete + + + Delete + + + + @@ -214,6 +222,12 @@ QgsDbSourceSelectBase editConnection() + + btnDelete + clicked() + QgsDbSourceSelectBase + deleteConnection() + cmbConnections @@ -229,11 +243,12 @@ qgsdbsourceselectbase.ui.h - addNewConnection() - addTables() - dbConnect() init() + dbConnect() + addTables() + addNewConnection() editConnection() + deleteConnection() diff --git a/qgis/src/qgsdbsourceselectbase.ui.h b/qgis/src/qgsdbsourceselectbase.ui.h index e56411779b4..23eaa7e744f 100644 --- a/qgis/src/qgsdbsourceselectbase.ui.h +++ b/qgis/src/qgsdbsourceselectbase.ui.h @@ -31,4 +31,9 @@ void QgsDbSourceSelectBase::addNewConnection() void QgsDbSourceSelectBase::editConnection() { +} + +void QgsDbSourceSelectBase::deleteConnection() +{ + } \ No newline at end of file