[QGIS Commit] r12373 - trunk/qgis/src/app
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Tue Dec 8 06:22:50 EST 2009
Author: jef
Date: 2009-12-08 06:22:49 -0500 (Tue, 08 Dec 2009)
New Revision: 12373
Modified:
trunk/qgis/src/app/qgspgsourceselect.cpp
trunk/qgis/src/app/qgspgsourceselect.h
Log:
save geometry of postgresql selection dialog
Modified: trunk/qgis/src/app/qgspgsourceselect.cpp
===================================================================
--- trunk/qgis/src/app/qgspgsourceselect.cpp 2009-12-08 10:35:07 UTC (rev 12372)
+++ trunk/qgis/src/app/qgspgsourceselect.cpp 2009-12-08 11:22:49 UTC (rev 12373)
@@ -84,17 +84,44 @@
//for Qt < 4.3.2, passing -1 to include all model columns
//in search does not seem to work
mSearchColumnComboBox->setCurrentIndex( 2 );
+
+ restoreGeometry( settings.value( "/Windows/PgSourceSelect/geometry" ).toByteArray() );
}
/** Autoconnected SLOTS **/
// Slot for adding a new connection
void QgsPgSourceSelect::on_btnNew_clicked()
{
- addNewConnection();
+ QgsNewConnection *nc = new QgsNewConnection( this );
+
+ if ( nc->exec() )
+ {
+ populateConnectionList();
+ }
}
// Slot for deleting an existing connection
void QgsPgSourceSelect::on_btnDelete_clicked()
{
- deleteConnection();
+ QSettings settings;
+ 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 + "/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()
@@ -105,7 +132,13 @@
// Slot for editing a connection
void QgsPgSourceSelect::on_btnEdit_clicked()
{
- editConnection();
+ QgsNewConnection *nc = new QgsNewConnection( this, cmbConnections->currentText() );
+
+ if ( nc->exec() )
+ {
+ nc->saveConnection();
+ }
+ populateConnectionList();
}
/** End Autoconnected SLOTS **/
@@ -113,7 +146,9 @@
// Remember which database is selected
void QgsPgSourceSelect::on_cmbConnections_activated( int )
{
- dbChanged();
+ // Remember which database was selected.
+ QSettings settings;
+ settings.setValue( "/PostgreSQL/connections/selected", cmbConnections->currentText() );
}
void QgsPgSourceSelect::on_btnBuildQuery_clicked()
@@ -220,6 +255,9 @@
delete mColumnTypeThread;
mColumnTypeThread = NULL;
}
+
+ QSettings settings;
+ settings.setValue( "/Windows/PgSourceSelect/geometry", saveGeometry() );
}
void QgsPgSourceSelect::populateConnectionList()
@@ -238,52 +276,6 @@
setConnectionListPosition();
}
-void QgsPgSourceSelect::addNewConnection()
-{
- QgsNewConnection *nc = new QgsNewConnection( this );
-
- if ( nc->exec() )
- {
- populateConnectionList();
- }
-}
-
-void QgsPgSourceSelect::editConnection()
-{
- QgsNewConnection *nc = new QgsNewConnection( this, cmbConnections->currentText() );
-
- if ( nc->exec() )
- {
- nc->saveConnection();
- }
- populateConnectionList();
-}
-
-void QgsPgSourceSelect::deleteConnection()
-{
- QSettings settings;
- 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 + "/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();
- }
-}
-
QString QgsPgSourceSelect::layerURI( const QModelIndex &index )
{
QString schemaName = mTableModel.itemFromIndex( index.sibling( index.row(), QgsDbTableModel::dbtmSchema ) )->text();
@@ -735,14 +727,6 @@
return full_desc;
}
-void QgsPgSourceSelect::dbChanged()
-{
- // Remember which database was selected.
- QSettings settings;
- settings.setValue( "/PostgreSQL/connections/selected",
- cmbConnections->currentText() );
-}
-
void QgsPgSourceSelect::setConnectionListPosition()
{
QSettings settings;
Modified: trunk/qgis/src/app/qgspgsourceselect.h
===================================================================
--- trunk/qgis/src/app/qgspgsourceselect.h 2009-12-08 10:35:07 UTC (rev 12372)
+++ trunk/qgis/src/app/qgspgsourceselect.h 2009-12-08 11:22:49 UTC (rev 12373)
@@ -109,12 +109,6 @@
QgsPgSourceSelect( QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
//! Destructor
~QgsPgSourceSelect();
- //! Opens the create connection dialog to build a new connection
- 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
@@ -123,8 +117,6 @@
QStringList selectedTables();
//! Connection info (database, host, user, password)
QString connectionInfo();
- // Store the selected database
- void dbChanged();
public slots:
void addClicked();
@@ -133,15 +125,19 @@
* Once connected, available layers are displayed.
*/
void on_btnConnect_clicked();
+ //! Opens the create connection dialog to build a new connection
void on_btnNew_clicked();
+ //! Opens a dialog to edit an existing connection
void on_btnEdit_clicked();
void on_btnBuildQuery_clicked();
+ //! Deletes the selected connection
void on_btnDelete_clicked();
void on_mSearchOptionsButton_clicked();
void on_mSearchTableEdit_textChanged( const QString & text );
void on_mSearchColumnComboBox_currentIndexChanged( const QString & text );
void on_mSearchModeComboBox_currentIndexChanged( const QString & text );
void setSql( const QModelIndex& index );
+ //! Store the selected database
void on_cmbConnections_activated( int );
void setLayerType( QString schema, QString table, QString column,
QString type );
@@ -191,7 +187,7 @@
QgsDbFilterProxyModel mProxyModel;
QString layerURI( const QModelIndex &index );
- QPushButton * mAddButton;
+ QPushButton *mAddButton;
};
More information about the QGIS-commit
mailing list