Skip to content
Permalink
Browse files

fix #2276

git-svn-id: http://svn.osgeo.org/qgis/trunk@12442 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Dec 13, 2009
1 parent 8b0c041 commit 57ac8f888e00beca47c5665df42b0a3602ce8887
@@ -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();
@@ -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
@@ -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 )
@@ -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();
@@ -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.
@@ -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()
{
@@ -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;
@@ -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();
@@ -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()
@@ -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
@@ -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 );
@@ -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()
@@ -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()
@@ -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>
@@ -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>

0 comments on commit 57ac8f8

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