Skip to content

Commit

Permalink
fix #2276
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12442 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Dec 13, 2009
1 parent 8b0c041 commit 57ac8f8
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 143 deletions.
44 changes: 22 additions & 22 deletions src/app/qgspgsourceselect.cpp
Expand Up @@ -46,7 +46,7 @@ QgsPgSourceSelect::QgsPgSourceSelect( QWidget *parent, Qt::WFlags fl )

mAddButton = new QPushButton( tr( "&Add" ) );
buttonBox->addButton( mAddButton, QDialogButtonBox::ActionRole );
connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addClicked() ) );
connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addTables() ) );

mAddButton->setEnabled( false );
populateConnectionList();
Expand Down Expand Up @@ -110,27 +110,20 @@ void QgsPgSourceSelect::on_btnDelete_clicked()
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
.arg( cmbConnections->currentText() );
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
if ( result == QMessageBox::Ok )
{
settings.remove( key + "/host" );
settings.remove( key + "/database" );
settings.remove( key + "/username" );
settings.remove( key + "/password" );
settings.remove( key + "/port" );
settings.remove( key + "/sslmode" );
settings.remove( key + "/save" );
settings.remove( key );
//if(!success){
// QMessageBox::information(this,"Unable to Remove","Unable to remove the connection " + cmbConnections->currentText());
//}
cmbConnections->removeItem( cmbConnections->currentIndex() ); // populateConnectionList();
setConnectionListPosition();
}
}
// Slot for performing action when the Add button is clicked
void QgsPgSourceSelect::addClicked()
{
addTables();
if ( result != QMessageBox::Ok )
return;

settings.remove( key + "/host" );
settings.remove( key + "/database" );
settings.remove( key + "/username" );
settings.remove( key + "/password" );
settings.remove( key + "/port" );
settings.remove( key + "/sslmode" );
settings.remove( key + "/publicOnly" );
settings.remove( key + "/geometryColumnsOnly" );
settings.remove( key + "/save" );

populateConnectionList();
}

// Slot for editing a connection
Expand Down Expand Up @@ -280,7 +273,13 @@ void QgsPgSourceSelect::populateConnectionList()
++it;
}
settings.endGroup();

setConnectionListPosition();

btnEdit->setDisabled( cmbConnections->count() == 0 );
btnDelete->setDisabled( cmbConnections->count() == 0 );
btnConnect->setDisabled( cmbConnections->count() == 0 );
cmbConnections->setDisabled( cmbConnections->count() == 0 );
}

QString QgsPgSourceSelect::layerURI( const QModelIndex &index )
Expand Down Expand Up @@ -337,6 +336,7 @@ QString QgsPgSourceSelect::layerURI( const QModelIndex &index )
return uri;
}

// Slot for performing action when the Add button is clicked
void QgsPgSourceSelect::addTables()
{
m_selectedTables.clear();
Expand Down
5 changes: 2 additions & 3 deletions src/app/qgspgsourceselect.h
Expand Up @@ -111,15 +111,14 @@ class QgsPgSourceSelect : public QDialog, private Ui::QgsPgSourceSelectBase
~QgsPgSourceSelect();
//! Populate the connection list combo box
void populateConnectionList();
//! Determines the tables the user selected and closes the dialog
void addTables();
//! String list containing the selected tables
QStringList selectedTables();
//! Connection info (database, host, user, password)
QString connectionInfo();

public slots:
void addClicked();
//! Determines the tables the user selected and closes the dialog
void addTables();

/*! Connects to the database using the stored connection parameters.
* Once connected, available layers are displayed.
Expand Down
40 changes: 15 additions & 25 deletions src/app/qgsspatialitesourceselect.cpp
Expand Up @@ -71,19 +71,6 @@ QgsSpatiaLiteSourceSelect::QgsSpatiaLiteSourceSelect( QgisApp * app, Qt::WFlags
mSearchColumnComboBox->setCurrentIndex( 1 );
}

/** Autoconnected SLOTS **/
// Slot for adding a new connection
void QgsSpatiaLiteSourceSelect::on_btnNew_clicked()
{
addNewConnection();
}

// Slot for deleting an existing connection
void QgsSpatiaLiteSourceSelect::on_btnDelete_clicked()
{
deleteConnection();
}

// Slot for performing action when the Add button is clicked
void QgsSpatiaLiteSourceSelect::addClicked()
{
Expand Down Expand Up @@ -297,9 +284,14 @@ void QgsSpatiaLiteSourceSelect::populateConnectionList()
}
settings.endGroup();
setConnectionListPosition();

btnConnect->setDisabled( cmbConnections->count() == 0 );
btnDelete->setDisabled( cmbConnections->count() == 0 );

cmbConnections->setDisabled( cmbConnections->count() == 0 );
}

void QgsSpatiaLiteSourceSelect::addNewConnection()
void QgsSpatiaLiteSourceSelect::on_btnNew_clicked()
{
// Retrieve last used project dir from persistent settings
sqlite3 *handle;
Expand Down Expand Up @@ -335,7 +327,8 @@ void QgsSpatiaLiteSourceSelect::addNewConnection()
populateConnectionList();
}

void QgsSpatiaLiteSourceSelect::deleteConnection()
// Slot for deleting an existing connection
void QgsSpatiaLiteSourceSelect::on_btnDelete_clicked()
{
QSettings settings;
QString subKey = cmbConnections->currentText();
Expand All @@ -347,16 +340,13 @@ void QgsSpatiaLiteSourceSelect::deleteConnection()
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" ).arg( subKey );
QMessageBox::StandardButton result =
QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
if ( result == QMessageBox::Ok )
{
settings.remove( key + "/sqlitepath" );
settings.remove( key );
//if(!success){
// QMessageBox::information(this,"Unable to Remove","Unable to remove the connection " + cmbConnections->currentText());
//}
cmbConnections->removeItem( cmbConnections->currentIndex() ); // populateConnectionList();
setConnectionListPosition();
}
if ( result != QMessageBox::Ok )
return;

settings.remove( key + "/sqlitepath" );
settings.remove( key );

populateConnectionList();
}

void QgsSpatiaLiteSourceSelect::addTables()
Expand Down
11 changes: 3 additions & 8 deletions src/app/qgsspatialitesourceselect.h
Expand Up @@ -60,14 +60,7 @@ class QgsSpatiaLiteSourceSelect: public QDialog, private Ui::QgsSpatiaLiteSource
//! Constructor
QgsSpatiaLiteSourceSelect( QgisApp * app, Qt::WFlags fl = QgisGui::ModalDialogFlags );
//! Destructor
~QgsSpatiaLiteSourceSelect()
{
;
}
//! Opens the create connection dialog to build a new connection
void addNewConnection();
//! Deletes the selected connection
void deleteConnection();
~QgsSpatiaLiteSourceSelect() {}
//! Populate the connection list combo box
void populateConnectionList();
//! Determines the tables the user selected and closes the dialog
Expand All @@ -85,7 +78,9 @@ class QgsSpatiaLiteSourceSelect: public QDialog, private Ui::QgsSpatiaLiteSource
*/
void on_btnConnect_clicked();
void addClicked();
//! Opens the create connection dialog to build a new connection
void on_btnNew_clicked();
//! Deletes the selected connection
void on_btnDelete_clicked();
void on_mSearchOptionsButton_clicked();
void on_mSearchTableEdit_textChanged( const QString & text );
Expand Down
34 changes: 21 additions & 13 deletions src/plugins/spit/qgsspit.cpp
Expand Up @@ -115,6 +115,12 @@ void QgsSpit::populateConnectionList()
++it;
}
settings.endGroup();

btnConnect->setDisabled( cmbConnections->count() == 0 );
btnEdit->setDisabled( cmbConnections->count() == 0 );
btnRemove->setDisabled( cmbConnections->count() == 0 );

cmbConnections->setDisabled( cmbConnections->count() == 0 );
}

void QgsSpit::newConnection()
Expand All @@ -141,19 +147,21 @@ void QgsSpit::removeConnection()
QString key = "/PostgreSQL/connections/" + cmbConnections->currentText();
QString msg = tr( "Are you sure you want to remove the [%1] connection and all associated settings?" ).arg( cmbConnections->currentText() );
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
if ( result == QMessageBox::Ok )
{
settings.remove( key + "/host" );
settings.remove( key + "/database" );
settings.remove( key + "/port" );
settings.remove( key + "/username" );
settings.remove( key + "/password" );
settings.remove( key + "/sslmode" );
settings.remove( key + "/save" );
settings.remove( key );

cmbConnections->removeItem( cmbConnections->currentIndex() );
}
if ( result != QMessageBox::Ok )
return;

settings.remove( key + "/host" );
settings.remove( key + "/database" );
settings.remove( key + "/port" );
settings.remove( key + "/username" );
settings.remove( key + "/password" );
settings.remove( key + "/sslmode" );
settings.remove( key + "/publicOnly" );
settings.remove( key + "/geometryColumnsOnly" );
settings.remove( key + "/save" );
settings.remove( key );

populateConnectionList();
}

void QgsSpit::addFile()
Expand Down
129 changes: 57 additions & 72 deletions src/plugins/spit/qgsspitbase.ui
Expand Up @@ -44,27 +44,8 @@
<property name="title">
<string>PostgreSQL connections</string>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>11</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="1" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="4">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QComboBox" name="cmbConnections">
<property name="minimumSize">
<size>
Expand All @@ -74,57 +55,61 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="btnEdit">
<property name="toolTip">
<string>Edit the current PostGIS connection</string>
</property>
<property name="whatsThis">
<string>Edit the current PostGIS connection</string>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="btnRemove">
<property name="toolTip">
<string>Remove the current PostGIS connection</string>
</property>
<property name="whatsThis">
<string>Remove the current PostGIS connection</string>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="btnNew">
<property name="toolTip">
<string>Create a new PostGIS connection</string>
</property>
<property name="whatsThis">
<string>Create a new PostGIS connection</string>
</property>
<property name="text">
<string>New</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="btnConnect">
<property name="toolTip">
<string>Connect to PostGIS</string>
</property>
<property name="whatsThis">
<string>Connect to PostGIS</string>
</property>
<property name="text">
<string>Connect</string>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btnConnect">
<property name="toolTip">
<string>Connect to PostGIS</string>
</property>
<property name="whatsThis">
<string>Connect to PostGIS</string>
</property>
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnNew">
<property name="toolTip">
<string>Create a new PostGIS connection</string>
</property>
<property name="whatsThis">
<string>Create a new PostGIS connection</string>
</property>
<property name="text">
<string>New</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnEdit">
<property name="toolTip">
<string>Edit the current PostGIS connection</string>
</property>
<property name="whatsThis">
<string>Edit the current PostGIS connection</string>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRemove">
<property name="toolTip">
<string>Remove the current PostGIS connection</string>
</property>
<property name="whatsThis">
<string>Remove the current PostGIS connection</string>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
Expand Down

0 comments on commit 57ac8f8

Please sign in to comment.