@@ -84,17 +84,44 @@ QgsPgSourceSelect::QgsPgSourceSelect( QWidget *parent, Qt::WFlags fl )
84
84
// for Qt < 4.3.2, passing -1 to include all model columns
85
85
// in search does not seem to work
86
86
mSearchColumnComboBox ->setCurrentIndex ( 2 );
87
+
88
+ restoreGeometry ( settings.value ( " /Windows/PgSourceSelect/geometry" ).toByteArray () );
87
89
}
88
90
/* * Autoconnected SLOTS **/
89
91
// Slot for adding a new connection
90
92
void QgsPgSourceSelect::on_btnNew_clicked ()
91
93
{
92
- addNewConnection ();
94
+ QgsNewConnection *nc = new QgsNewConnection ( this );
95
+
96
+ if ( nc->exec () )
97
+ {
98
+ populateConnectionList ();
99
+ }
93
100
}
94
101
// Slot for deleting an existing connection
95
102
void QgsPgSourceSelect::on_btnDelete_clicked ()
96
103
{
97
- deleteConnection ();
104
+ QSettings settings;
105
+ QString key = " /Postgresql/connections/" + cmbConnections->currentText ();
106
+ QString msg = tr ( " Are you sure you want to remove the %1 connection and all associated settings?" )
107
+ .arg ( cmbConnections->currentText () );
108
+ QMessageBox::StandardButton result = QMessageBox::information ( this , tr ( " Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
109
+ if ( result == QMessageBox::Ok )
110
+ {
111
+ settings.remove ( key + " /host" );
112
+ settings.remove ( key + " /database" );
113
+ settings.remove ( key + " /username" );
114
+ settings.remove ( key + " /password" );
115
+ settings.remove ( key + " /port" );
116
+ settings.remove ( key + " /sslmode" );
117
+ settings.remove ( key + " /save" );
118
+ settings.remove ( key );
119
+ // if(!success){
120
+ // QMessageBox::information(this,"Unable to Remove","Unable to remove the connection " + cmbConnections->currentText());
121
+ // }
122
+ cmbConnections->removeItem ( cmbConnections->currentIndex () ); // populateConnectionList();
123
+ setConnectionListPosition ();
124
+ }
98
125
}
99
126
// Slot for performing action when the Add button is clicked
100
127
void QgsPgSourceSelect::addClicked ()
@@ -105,15 +132,23 @@ void QgsPgSourceSelect::addClicked()
105
132
// Slot for editing a connection
106
133
void QgsPgSourceSelect::on_btnEdit_clicked ()
107
134
{
108
- editConnection ();
135
+ QgsNewConnection *nc = new QgsNewConnection ( this , cmbConnections->currentText () );
136
+
137
+ if ( nc->exec () )
138
+ {
139
+ nc->saveConnection ();
140
+ }
141
+ populateConnectionList ();
109
142
}
110
143
111
144
/* * End Autoconnected SLOTS **/
112
145
113
146
// Remember which database is selected
114
147
void QgsPgSourceSelect::on_cmbConnections_activated ( int )
115
148
{
116
- dbChanged ();
149
+ // Remember which database was selected.
150
+ QSettings settings;
151
+ settings.setValue ( " /PostgreSQL/connections/selected" , cmbConnections->currentText () );
117
152
}
118
153
119
154
void QgsPgSourceSelect::on_btnBuildQuery_clicked ()
@@ -220,6 +255,9 @@ QgsPgSourceSelect::~QgsPgSourceSelect()
220
255
delete mColumnTypeThread ;
221
256
mColumnTypeThread = NULL ;
222
257
}
258
+
259
+ QSettings settings;
260
+ settings.setValue ( " /Windows/PgSourceSelect/geometry" , saveGeometry () );
223
261
}
224
262
225
263
void QgsPgSourceSelect::populateConnectionList ()
@@ -238,52 +276,6 @@ void QgsPgSourceSelect::populateConnectionList()
238
276
setConnectionListPosition ();
239
277
}
240
278
241
- void QgsPgSourceSelect::addNewConnection ()
242
- {
243
- QgsNewConnection *nc = new QgsNewConnection ( this );
244
-
245
- if ( nc->exec () )
246
- {
247
- populateConnectionList ();
248
- }
249
- }
250
-
251
- void QgsPgSourceSelect::editConnection ()
252
- {
253
- QgsNewConnection *nc = new QgsNewConnection ( this , cmbConnections->currentText () );
254
-
255
- if ( nc->exec () )
256
- {
257
- nc->saveConnection ();
258
- }
259
- populateConnectionList ();
260
- }
261
-
262
- void QgsPgSourceSelect::deleteConnection ()
263
- {
264
- QSettings settings;
265
- QString key = " /Postgresql/connections/" + cmbConnections->currentText ();
266
- QString msg = tr ( " Are you sure you want to remove the %1 connection and all associated settings?" )
267
- .arg ( cmbConnections->currentText () );
268
- QMessageBox::StandardButton result = QMessageBox::information ( this , tr ( " Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
269
- if ( result == QMessageBox::Ok )
270
- {
271
- settings.remove ( key + " /host" );
272
- settings.remove ( key + " /database" );
273
- settings.remove ( key + " /username" );
274
- settings.remove ( key + " /password" );
275
- settings.remove ( key + " /port" );
276
- settings.remove ( key + " /sslmode" );
277
- settings.remove ( key + " /save" );
278
- settings.remove ( key );
279
- // if(!success){
280
- // QMessageBox::information(this,"Unable to Remove","Unable to remove the connection " + cmbConnections->currentText());
281
- // }
282
- cmbConnections->removeItem ( cmbConnections->currentIndex () ); // populateConnectionList();
283
- setConnectionListPosition ();
284
- }
285
- }
286
-
287
279
QString QgsPgSourceSelect::layerURI ( const QModelIndex &index )
288
280
{
289
281
QString schemaName = mTableModel .itemFromIndex ( index.sibling ( index.row (), QgsDbTableModel::dbtmSchema ) )->text ();
@@ -735,14 +727,6 @@ QString QgsPgSourceSelect::fullDescription( QString schema, QString table,
735
727
return full_desc;
736
728
}
737
729
738
- void QgsPgSourceSelect::dbChanged ()
739
- {
740
- // Remember which database was selected.
741
- QSettings settings;
742
- settings.setValue ( " /PostgreSQL/connections/selected" ,
743
- cmbConnections->currentText () );
744
- }
745
-
746
730
void QgsPgSourceSelect::setConnectionListPosition ()
747
731
{
748
732
QSettings settings;
0 commit comments