[QGIS Commit] r12442 - in trunk/qgis/src: app plugins/spit
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sun Dec 13 17:09:22 EST 2009
Author: jef
Date: 2009-12-13 17:09:22 -0500 (Sun, 13 Dec 2009)
New Revision: 12442
Modified:
trunk/qgis/src/app/qgspgsourceselect.cpp
trunk/qgis/src/app/qgspgsourceselect.h
trunk/qgis/src/app/qgsspatialitesourceselect.cpp
trunk/qgis/src/app/qgsspatialitesourceselect.h
trunk/qgis/src/plugins/spit/qgsspit.cpp
trunk/qgis/src/plugins/spit/qgsspitbase.ui
Log:
fix #2276
Modified: trunk/qgis/src/app/qgspgsourceselect.cpp
===================================================================
--- trunk/qgis/src/app/qgspgsourceselect.cpp 2009-12-13 22:05:52 UTC (rev 12441)
+++ trunk/qgis/src/app/qgspgsourceselect.cpp 2009-12-13 22:09:22 UTC (rev 12442)
@@ -46,7 +46,7 @@
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,28 +110,21 @@
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();
- }
+ 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 performing action when the Add button is clicked
-void QgsPgSourceSelect::addClicked()
-{
- addTables();
-}
// Slot for editing a connection
void QgsPgSourceSelect::on_btnEdit_clicked()
@@ -280,7 +273,13 @@
++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 @@
return uri;
}
+// Slot for performing action when the Add button is clicked
void QgsPgSourceSelect::addTables()
{
m_selectedTables.clear();
Modified: trunk/qgis/src/app/qgspgsourceselect.h
===================================================================
--- trunk/qgis/src/app/qgspgsourceselect.h 2009-12-13 22:05:52 UTC (rev 12441)
+++ trunk/qgis/src/app/qgspgsourceselect.h 2009-12-13 22:09:22 UTC (rev 12442)
@@ -111,15 +111,14 @@
~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.
Modified: trunk/qgis/src/app/qgsspatialitesourceselect.cpp
===================================================================
--- trunk/qgis/src/app/qgsspatialitesourceselect.cpp 2009-12-13 22:05:52 UTC (rev 12441)
+++ trunk/qgis/src/app/qgsspatialitesourceselect.cpp 2009-12-13 22:09:22 UTC (rev 12442)
@@ -71,19 +71,6 @@
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 @@
}
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 @@
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 @@
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()
Modified: trunk/qgis/src/app/qgsspatialitesourceselect.h
===================================================================
--- trunk/qgis/src/app/qgsspatialitesourceselect.h 2009-12-13 22:05:52 UTC (rev 12441)
+++ trunk/qgis/src/app/qgsspatialitesourceselect.h 2009-12-13 22:09:22 UTC (rev 12442)
@@ -60,14 +60,7 @@
//! 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 @@
*/
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 );
Modified: trunk/qgis/src/plugins/spit/qgsspit.cpp
===================================================================
--- trunk/qgis/src/plugins/spit/qgsspit.cpp 2009-12-13 22:05:52 UTC (rev 12441)
+++ trunk/qgis/src/plugins/spit/qgsspit.cpp 2009-12-13 22:09:22 UTC (rev 12442)
@@ -115,6 +115,12 @@
++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 @@
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 );
+ if ( result != QMessageBox::Ok )
+ return;
- cmbConnections->removeItem( cmbConnections->currentIndex() );
- }
+ 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()
Modified: trunk/qgis/src/plugins/spit/qgsspitbase.ui
===================================================================
--- trunk/qgis/src/plugins/spit/qgsspitbase.ui 2009-12-13 22:05:52 UTC (rev 12441)
+++ trunk/qgis/src/plugins/spit/qgsspitbase.ui 2009-12-13 22:09:22 UTC (rev 12442)
@@ -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,58 +55,62 @@
</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>
+ <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>
- <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>
</widget>
</item>
More information about the QGIS-commit
mailing list