load_save_connections.diff
src/app/postgres/qgspgsourceselect.h (working copy) | ||
---|---|---|
131 | 131 |
void on_btnBuildQuery_clicked(); |
132 | 132 |
//! Deletes the selected connection |
133 | 133 |
void on_btnDelete_clicked(); |
134 |
//! Saves the selected connections to the file |
|
135 |
void on_btnSave_clicked(); |
|
136 |
//! Loads the selected connections from the file |
|
137 |
void on_btnLoad_clicked(); |
|
134 | 138 |
void on_mSearchOptionsButton_clicked(); |
135 | 139 |
void on_mSearchTableEdit_textChanged( const QString & text ); |
136 | 140 |
void on_mSearchColumnComboBox_currentIndexChanged( const QString & text ); |
src/app/postgres/qgspgsourceselect.cpp (working copy) | ||
---|---|---|
24 | 24 |
#include "qgsapplication.h" |
25 | 25 |
#include "qgscontexthelp.h" |
26 | 26 |
#include "qgspgnewconnection.h" |
27 |
#include "qgsmanageconnectionsdialog.h" |
|
27 | 28 |
#include "qgsquerybuilder.h" |
28 | 29 |
#include "qgsdatasourceuri.h" |
29 | 30 |
#include "qgsvectorlayer.h" |
... | ... | |
126 | 127 |
populateConnectionList(); |
127 | 128 |
} |
128 | 129 | |
130 |
void QgsPgSourceSelect::on_btnSave_clicked() |
|
131 |
{ |
|
132 |
QgsManageConnectionsDialog dlg( this, 0, 1 ); |
|
133 |
dlg.exec(); |
|
134 |
} |
|
135 | ||
136 |
void QgsPgSourceSelect::on_btnLoad_clicked() |
|
137 |
{ |
|
138 |
QgsManageConnectionsDialog dlg( this, 1, 1 ); |
|
139 |
dlg.exec(); |
|
140 |
populateConnectionList(); |
|
141 |
} |
|
142 | ||
129 | 143 |
// Slot for editing a connection |
130 | 144 |
void QgsPgSourceSelect::on_btnEdit_clicked() |
131 | 145 |
{ |
src/app/qgsmanageconnectionsdialog.h (revision 0) | ||
---|---|---|
1 |
/*************************************************************************** |
|
2 |
qgsmanageconnectionsdialog.h |
|
3 |
--------------------- |
|
4 |
begin : Dec 2009 |
|
5 |
copyright : (C) 2009 by Alexander Bruy |
|
6 |
email : alexander dot bruy at gmail dot com |
|
7 | ||
8 |
*************************************************************************** |
|
9 |
* * |
|
10 |
* This program is free software; you can redistribute it and/or modify * |
|
11 |
* it under the terms of the GNU General Public License as published by * |
|
12 |
* the Free Software Foundation; either version 2 of the License, or * |
|
13 |
* (at your option) any later version. * |
|
14 |
* * |
|
15 |
***************************************************************************/ |
|
16 | ||
17 |
/* $Id$ */ |
|
18 | ||
19 |
#ifndef QGSMANAGECONNECTIONSDIALOG_H |
|
20 |
#define QGSMANAGECONNECTIONSDIALOG_H |
|
21 | ||
22 |
#include <QDialog> |
|
23 |
#include <QDomDocument> |
|
24 |
#include "ui_qgsmanageconnectionsdialogbase.h" |
|
25 | ||
26 |
class QgsManageConnectionsDialog : public QDialog, private Ui::QgsManageConnectionsDialogBase |
|
27 |
{ |
|
28 |
Q_OBJECT |
|
29 | ||
30 |
public: |
|
31 |
// constructor |
|
32 |
// mode argument must be 0 for saving and 1 for loading |
|
33 |
// type argument must be 0 for WMS and 1 for PostGIS |
|
34 |
QgsManageConnectionsDialog( QWidget *parent = NULL, int mode = 0, int type = 0 ); |
|
35 | ||
36 |
public slots: |
|
37 |
void on_btnBrowse_clicked(); |
|
38 |
void on_buttonBox_accepted(); |
|
39 | ||
40 |
void populateConnections(); |
|
41 | ||
42 |
private: |
|
43 |
QDomDocument saveWMSConnections( const QStringList &connections ); |
|
44 |
QDomDocument savePgConnections( const QStringList & connections ); |
|
45 |
void loadWMSConnections( const QDomDocument &doc, const QStringList &items ); |
|
46 |
void loadPgConnections( const QDomDocument &doc, const QStringList &items ); |
|
47 | ||
48 |
QString mFileName; |
|
49 |
int mDialogMode; |
|
50 |
int mConnectionType; |
|
51 |
}; |
|
52 | ||
53 |
#endif // QGSMANAGECONNECTIONSDIALOG_H |
|
54 |
src/app/qgsmanageconnectionsdialog.cpp (revision 0) | ||
---|---|---|
1 |
/*************************************************************************** |
|
2 |
qgsmanageconnectionsdialog.cpp |
|
3 |
--------------------- |
|
4 |
begin : Dec 2009 |
|
5 |
copyright : (C) 2009 by Alexander Bruy |
|
6 |
email : alexander dot bruy at gmail dot com |
|
7 | ||
8 |
*************************************************************************** |
|
9 |
* * |
|
10 |
* This program is free software; you can redistribute it and/or modify * |
|
11 |
* it under the terms of the GNU General Public License as published by * |
|
12 |
* the Free Software Foundation; either version 2 of the License, or * |
|
13 |
* (at your option) any later version. * |
|
14 |
* * |
|
15 |
***************************************************************************/ |
|
16 | ||
17 |
/* $Id$ */ |
|
18 | ||
19 |
#include <QFileDialog> |
|
20 |
#include <QMessageBox> |
|
21 |
#include <QSettings> |
|
22 |
#include <QTextStream> |
|
23 |
#include <QDebug> |
|
24 | ||
25 |
#include "qgsmanageconnectionsdialog.h" |
|
26 | ||
27 |
QgsManageConnectionsDialog::QgsManageConnectionsDialog( QWidget *parent, int mode, int type ) |
|
28 |
: QDialog( parent ) |
|
29 |
{ |
|
30 |
setupUi( this ); |
|
31 |
mDialogMode = mode; |
|
32 |
mConnectionType = type; |
|
33 | ||
34 |
if ( mDialogMode == 1 ) |
|
35 |
{ |
|
36 |
label->setText( tr( "Load from file" ) ); |
|
37 |
buttonBox->button( QDialogButtonBox::Ok )->setText( tr( "Load" ) ); |
|
38 |
} |
|
39 |
else |
|
40 |
{ |
|
41 |
buttonBox->button( QDialogButtonBox::Ok )->setText( tr( "Save" ) ); |
|
42 |
populateConnections(); |
|
43 |
} |
|
44 | ||
45 |
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false ); |
|
46 |
} |
|
47 | ||
48 |
void QgsManageConnectionsDialog::on_btnBrowse_clicked() |
|
49 |
{ |
|
50 |
QString fileName; |
|
51 |
if ( mDialogMode == 0 ) |
|
52 |
{ |
|
53 |
fileName = QFileDialog::getSaveFileName( this, tr( "Save connections" ), ".", tr( "XML files (*.xml *.XML)" ) ); |
|
54 |
} |
|
55 |
else |
|
56 |
{ |
|
57 |
fileName = QFileDialog::getOpenFileName( this, tr( "Load connections" ), ".", tr( "XML files (*.xml *XML)" ) ); |
|
58 |
} |
|
59 | ||
60 |
if ( fileName.isEmpty() ) |
|
61 |
{ |
|
62 |
return; |
|
63 |
} |
|
64 | ||
65 |
// ensure the user never ommited the extension from the file name |
|
66 |
if ( !fileName.toLower().endsWith( ".xml" ) ) |
|
67 |
{ |
|
68 |
fileName += ".xml"; |
|
69 |
} |
|
70 | ||
71 |
mFileName = fileName; |
|
72 |
leFileName->setText( mFileName ); |
|
73 |
//buttonBox->button( QDialogButtonBox::Ok )->setEnabled( true ); |
|
74 | ||
75 |
if ( mDialogMode == 1 ) |
|
76 |
{ |
|
77 |
populateConnections(); |
|
78 |
} |
|
79 | ||
80 |
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( true ); |
|
81 |
} |
|
82 | ||
83 |
void QgsManageConnectionsDialog::on_buttonBox_accepted() |
|
84 |
{ |
|
85 |
QList<QListWidgetItem *> selection = listConnections->selectedItems(); |
|
86 |
if ( selection.isEmpty() ) |
|
87 |
{ |
|
88 |
return; |
|
89 |
} |
|
90 |
QStringList items; |
|
91 |
for (int i = 0; i < selection.size(); ++i ) |
|
92 |
{ |
|
93 |
items.append( selection.at( i )->text() ); |
|
94 |
} |
|
95 | ||
96 |
if ( mDialogMode == 0 ) |
|
97 |
{ |
|
98 |
QDomDocument doc; |
|
99 |
if ( mConnectionType == 0 ) |
|
100 |
{ |
|
101 |
doc = saveWMSConnections( items ); |
|
102 |
} |
|
103 |
else |
|
104 |
{ |
|
105 |
doc = savePgConnections( items ); |
|
106 |
} |
|
107 | ||
108 |
QFile file( mFileName ); |
|
109 |
if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) ) |
|
110 |
{ |
|
111 |
QMessageBox::warning( this, tr( "Saving connections" ), |
|
112 |
tr( "Cannot write file %1:\n%2." ) |
|
113 |
.arg( mFileName ) |
|
114 |
.arg( file.errorString() ) ); |
|
115 |
return; |
|
116 |
} |
|
117 | ||
118 |
QTextStream out( &file ); |
|
119 |
doc.save( out, 4 ); |
|
120 |
} |
|
121 |
else // load connections |
|
122 |
{ |
|
123 |
QFile file( mFileName ); |
|
124 |
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) |
|
125 |
{ |
|
126 |
QMessageBox::warning( this, tr( "Loading connections" ), |
|
127 |
tr( "Cannot read file %1:\n%2." ) |
|
128 |
.arg( mFileName ) |
|
129 |
.arg( file.errorString() ) ); |
|
130 |
return; |
|
131 |
} |
|
132 |
|
|
133 |
QDomDocument doc; |
|
134 |
QString errorStr; |
|
135 |
int errorLine; |
|
136 |
int errorColumn; |
|
137 | ||
138 |
if ( !doc.setContent( &file, true, &errorStr, &errorLine, &errorColumn ) ) |
|
139 |
{ |
|
140 |
QMessageBox::warning( this, tr( "Loading connections" ), |
|
141 |
tr( "Parse error at line %1, column %2:\n%3" ) |
|
142 |
.arg( errorLine ) |
|
143 |
.arg( errorColumn ) |
|
144 |
.arg( errorStr ) ); |
|
145 |
return; |
|
146 |
} |
|
147 | ||
148 |
if ( mConnectionType == 0 ) |
|
149 |
{ |
|
150 |
loadWMSConnections( doc, items ); |
|
151 |
} |
|
152 |
else |
|
153 |
{ |
|
154 |
loadPgConnections( doc, items ); |
|
155 |
} |
|
156 |
} |
|
157 | ||
158 |
mFileName = ""; |
|
159 |
leFileName->clear(); |
|
160 |
listConnections->clear(); |
|
161 |
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false ); |
|
162 |
} |
|
163 | ||
164 |
void QgsManageConnectionsDialog::populateConnections() |
|
165 |
{ |
|
166 |
// Save mode. Populate connections list from settings |
|
167 |
if ( mDialogMode == 0 ) |
|
168 |
{ |
|
169 |
QSettings settings; |
|
170 |
if ( mConnectionType == 0 ) |
|
171 |
{ |
|
172 |
settings.beginGroup( "/Qgis/connections-wms" ); |
|
173 |
} |
|
174 |
else |
|
175 |
{ |
|
176 |
settings.beginGroup( "/PostgreSQL/connections" ); |
|
177 |
} |
|
178 |
QStringList keys = settings.childGroups(); |
|
179 |
QStringList::Iterator it = keys.begin(); |
|
180 |
while ( it != keys.end() ) |
|
181 |
{ |
|
182 |
QListWidgetItem *item = new QListWidgetItem(); |
|
183 |
item->setText( *it ); |
|
184 |
listConnections->addItem( item ); |
|
185 |
++it; |
|
186 |
} |
|
187 |
settings.endGroup(); |
|
188 |
} |
|
189 |
// Load mode. Populate connections list from file |
|
190 |
else |
|
191 |
{ |
|
192 |
QFile file( mFileName ); |
|
193 |
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) |
|
194 |
{ |
|
195 |
QMessageBox::warning( this, tr( "Loading connections" ), |
|
196 |
tr( "Cannot read file %1:\n%2." ) |
|
197 |
.arg( mFileName ) |
|
198 |
.arg( file.errorString() ) ); |
|
199 |
return; |
|
200 |
} |
|
201 | ||
202 |
QDomDocument doc; |
|
203 |
QString errorStr; |
|
204 |
int errorLine; |
|
205 |
int errorColumn; |
|
206 | ||
207 |
if ( !doc.setContent( &file, true, &errorStr, &errorLine, &errorColumn ) ) |
|
208 |
{ |
|
209 |
QMessageBox::warning( this, tr( "Loading connections" ), |
|
210 |
tr( "Parse error at line %1, column %2:\n%3" ) |
|
211 |
.arg( errorLine ) |
|
212 |
.arg( errorColumn ) |
|
213 |
.arg( errorStr ) ); |
|
214 |
return; |
|
215 |
} |
|
216 | ||
217 |
QDomElement root = doc.documentElement(); |
|
218 |
if ( mConnectionType == 0 ) |
|
219 |
{ |
|
220 |
if ( root.tagName() != "qgsWMSConnections" ) |
|
221 |
{ |
|
222 |
QMessageBox::information( this, tr( "Loading connections" ), |
|
223 |
tr( "The file is not an WMS connections exchange file." ) ); |
|
224 |
mFileName = ""; |
|
225 |
leFileName->clear(); |
|
226 |
listConnections->clear(); |
|
227 |
return; |
|
228 |
} |
|
229 |
} |
|
230 |
else |
|
231 |
{ |
|
232 |
if ( root.tagName() != "qgsPgConnections" ) |
|
233 |
{ |
|
234 |
QMessageBox::information( this, tr( "Loading connections" ), |
|
235 |
tr( "The file is not an PostGIS connections exchange file." ) ); |
|
236 |
mFileName = ""; |
|
237 |
leFileName->clear(); |
|
238 |
listConnections->clear(); |
|
239 |
return; |
|
240 |
} |
|
241 |
} |
|
242 | ||
243 |
QDomElement child = root.firstChildElement(); |
|
244 |
while ( !child.isNull() ) |
|
245 |
{ |
|
246 |
QListWidgetItem *item = new QListWidgetItem(); |
|
247 |
item->setText( child.attribute( "name" ) ); |
|
248 |
listConnections->addItem( item ); |
|
249 |
child = child.nextSiblingElement(); |
|
250 |
} |
|
251 |
} |
|
252 |
} |
|
253 | ||
254 |
QDomDocument QgsManageConnectionsDialog::saveWMSConnections( const QStringList &connections ) |
|
255 |
{ |
|
256 |
QDomDocument doc( "connections" ); |
|
257 |
QDomElement root = doc.createElement( "qgsWMSConnections" ); |
|
258 |
root.setAttribute( "version", "1.0" ); |
|
259 |
doc.appendChild( root ); |
|
260 | ||
261 |
QSettings settings; |
|
262 |
QString path; |
|
263 |
for ( int i = 0; i < connections.count(); ++i ) |
|
264 |
{ |
|
265 |
path = "/Qgis/connections-wms/"; |
|
266 |
QDomElement el = doc.createElement( "wms" ); |
|
267 |
el.setAttribute( "name", connections[ i ] ); |
|
268 |
el.setAttribute( "url", settings.value( path + connections[ i ] + "/url", "" ).toString() ); |
|
269 | ||
270 |
path = "/Qgis/WMS/"; |
|
271 |
el.setAttribute( "username", settings.value( path + connections[ i ] + "/username", "" ).toString() ); |
|
272 |
el.setAttribute( "password", settings.value( path + connections[ i ] + "/password", "" ).toString() ); |
|
273 |
root.appendChild( el ); |
|
274 |
} |
|
275 | ||
276 |
return doc; |
|
277 |
} |
|
278 | ||
279 |
QDomDocument QgsManageConnectionsDialog::savePgConnections( const QStringList &connections ) |
|
280 |
{ |
|
281 |
QDomDocument doc( "connections" ); |
|
282 |
QDomElement root = doc.createElement( "qgsPgConnections" ); |
|
283 |
root.setAttribute( "version", "1.0" ); |
|
284 |
doc.appendChild( root ); |
|
285 | ||
286 |
QSettings settings; |
|
287 |
QString path; |
|
288 |
for( int i = 0; i < connections.count(); ++i ) |
|
289 |
{ |
|
290 |
path = "/PostgreSQL/connections/" + connections[ i ]; |
|
291 |
QDomElement el = doc.createElement( "postgis" ); |
|
292 |
el.setAttribute( "name", connections[ i ] ); |
|
293 |
el.setAttribute( "host", settings.value( path + "/host", "" ).toString() ); |
|
294 |
el.setAttribute( "port", settings.value( path + "/port", "" ).toString() ); |
|
295 |
el.setAttribute( "db", settings.value( path + "/database", "" ).toString() ); |
|
296 |
el.setAttribute( "username", settings.value( path + "/username", "" ).toString() ); |
|
297 |
el.setAttribute( "password", settings.value( path + "/password", "" ).toString() ); |
|
298 |
el.setAttribute( "sslmode", settings.value( path + "/sslmode", "1" ).toString() ); |
|
299 |
root.appendChild( el ); |
|
300 |
} |
|
301 | ||
302 |
return doc; |
|
303 |
} |
|
304 | ||
305 |
void QgsManageConnectionsDialog::loadWMSConnections( const QDomDocument &doc, const QStringList &items ) |
|
306 |
{ |
|
307 |
QDomElement root = doc.documentElement(); |
|
308 |
if ( root.tagName() != "qgsWMSConnections" ) |
|
309 |
{ |
|
310 |
QMessageBox::information( this, tr( "Loading connections" ), |
|
311 |
tr( "The file is not an WMS connections exchange file." ) ); |
|
312 |
return; |
|
313 |
} |
|
314 | ||
315 |
QString connectionName; |
|
316 |
QSettings settings; |
|
317 |
settings.beginGroup( "/Qgis/connections-wms" ); |
|
318 |
QStringList keys = settings.childGroups(); |
|
319 |
settings.endGroup(); |
|
320 |
QDomElement child = root.firstChildElement(); |
|
321 |
while ( !child.isNull() ) |
|
322 |
{ |
|
323 |
connectionName = child.attribute( "name" ); |
|
324 |
if( !items.contains( connectionName ) ) |
|
325 |
{ |
|
326 |
child = child.nextSiblingElement(); |
|
327 |
continue; |
|
328 |
} |
|
329 |
|
|
330 |
// check for duplicates |
|
331 |
if ( keys.contains( connectionName ) ) |
|
332 |
{ |
|
333 |
int res = QMessageBox::warning( this, tr( "Loading connections" ), |
|
334 |
tr( "Connection with name %1 already exists. Overwrite?" ) |
|
335 |
.arg( connectionName ), |
|
336 |
QMessageBox::Yes | QMessageBox::No ); |
|
337 |
if ( res != QMessageBox::Yes ) |
|
338 |
{ |
|
339 |
child = child.nextSiblingElement(); |
|
340 |
continue; |
|
341 |
} |
|
342 |
} |
|
343 | ||
344 |
// no dups detected or overwrite is allowed |
|
345 |
settings.beginGroup( "/Qgis/connections-wms" ); |
|
346 |
settings.setValue( QString( "/" + connectionName + "/url" ) , child.attribute( "url" ) ); |
|
347 |
settings.endGroup(); |
|
348 | ||
349 |
if ( !child.attribute( "username" ).isEmpty() ) |
|
350 |
{ |
|
351 |
settings.beginGroup( "/Qgis/WMS/" + connectionName ); |
|
352 |
settings.setValue( "/username", child.attribute( "username" ) ); |
|
353 |
settings.setValue( "/password", child.attribute( "password" ) ); |
|
354 |
settings.endGroup(); |
|
355 |
} |
|
356 |
child = child.nextSiblingElement(); |
|
357 |
} |
|
358 |
} |
|
359 | ||
360 |
void QgsManageConnectionsDialog::loadPgConnections( const QDomDocument &doc, const QStringList &items ) |
|
361 |
{ |
|
362 |
QDomElement root = doc.documentElement(); |
|
363 |
if ( root.tagName() != "qgsPgConnections" ) |
|
364 |
{ |
|
365 |
QMessageBox::information( this, tr( "Loading connections" ), |
|
366 |
tr( "The file is not an PostGIS connections exchange file." ) ); |
|
367 |
return; |
|
368 |
} |
|
369 | ||
370 |
QString connectionName; |
|
371 |
QSettings settings; |
|
372 |
settings.beginGroup( "/PostgreSQL/connections" ); |
|
373 |
QStringList keys = settings.childGroups(); |
|
374 |
settings.endGroup(); |
|
375 |
QDomElement child = root.firstChildElement(); |
|
376 |
while ( !child.isNull() ) |
|
377 |
{ |
|
378 |
connectionName = child.attribute( "name" ); |
|
379 |
if( !items.contains( connectionName ) ) |
|
380 |
{ |
|
381 |
child = child.nextSiblingElement(); |
|
382 |
continue; |
|
383 |
} |
|
384 | ||
385 |
// check for duplicates |
|
386 |
if ( keys.contains( connectionName ) ) |
|
387 |
{ |
|
388 |
int res = QMessageBox::warning( this, tr( "Loading conections" ), |
|
389 |
tr( "Connection with name %1 already exists. Overwrite?" ) |
|
390 |
.arg( connectionName ), |
|
391 |
QMessageBox::Yes | QMessageBox::No ); |
|
392 |
if ( res != QMessageBox::Yes ) |
|
393 |
{ |
|
394 |
child = child.nextSiblingElement(); |
|
395 |
continue; |
|
396 |
} |
|
397 |
} |
|
398 | ||
399 |
//no dups detected or overwrite is allowed |
|
400 |
settings.beginGroup( "/PostgreSQL/connections/" + connectionName ); |
|
401 |
settings.setValue( "/host", child.attribute( "host" ) ); |
|
402 |
settings.setValue( "/port", child.attribute( "port" ) ); |
|
403 |
settings.setValue( "/database", child.attribute( "db" ) ); |
|
404 |
settings.setValue( "/sslmode", child.attribute( "sslmode" ) ); |
|
405 |
if ( !child.attribute( "username" ).isEmpty() ) |
|
406 |
{ |
|
407 |
settings.setValue( "/username", child.attribute( "username" ) ); |
|
408 |
settings.setValue( "/password", child.attribute( "password" ) ); |
|
409 |
settings.setValue( "/save", "true" ); |
|
410 |
} |
|
411 |
settings.endGroup(); |
|
412 | ||
413 |
child = child.nextSiblingElement(); |
|
414 |
} |
|
415 |
} |
|
416 |
src/app/qgswmssourceselect.h (working copy) | ||
---|---|---|
98 | 98 |
void on_btnEdit_clicked(); |
99 | 99 |
//! Deletes the selected connection |
100 | 100 |
void on_btnDelete_clicked(); |
101 |
//! Saves conncetions to the file |
|
102 |
void on_btnSave_clicked(); |
|
103 |
//! Loads connections from the file |
|
104 |
void on_btnLoad_clicked(); |
|
101 | 105 | |
102 | 106 |
/*! Connects to the database using the stored connection parameters. |
103 | 107 |
* Once connected, available layers are displayed. |
src/app/qgswmssourceselect.cpp (working copy) | ||
---|---|---|
27 | 27 |
#include "qgsgenericprojectionselector.h" |
28 | 28 |
#include "qgshttptransaction.h" |
29 | 29 |
#include "qgslogger.h" |
30 |
#include "qgsmanageconnectionsdialog.h" |
|
30 | 31 |
#include "qgsmessageviewer.h" |
31 | 32 |
#include "qgsnewhttpconnection.h" |
32 | 33 |
#include "qgsnumericsortlistviewitem.h" |
... | ... | |
35 | 36 |
#include "qgswmssourceselect.h" |
36 | 37 |
#include <qgisinterface.h> |
37 | 38 | |
38 | ||
39 | 39 |
#include <QButtonGroup> |
40 | 40 |
#include <QDomDocument> |
41 | 41 |
#include <QHeaderView> |
... | ... | |
203 | 203 |
if ( result == QMessageBox::Ok ) |
204 | 204 |
{ |
205 | 205 |
settings.remove( key ); |
206 |
settings.remove( "/Qgis/WMS/" + cmbConnections->currentText() ); |
|
206 | 207 |
cmbConnections->removeItem( cmbConnections->currentIndex() ); // populateConnectionList(); |
207 | 208 |
setConnectionListPosition(); |
208 | 209 |
} |
209 | 210 |
} |
210 | 211 | |
212 |
void QgsWMSSourceSelect::on_btnSave_clicked() |
|
213 |
{ |
|
214 |
QgsManageConnectionsDialog dlg( this, 0, 0 ); |
|
215 |
dlg.exec(); |
|
216 |
} |
|
217 | ||
218 |
void QgsWMSSourceSelect::on_btnLoad_clicked() |
|
219 |
{ |
|
220 |
QgsManageConnectionsDialog dlg( this, 1, 0 ); |
|
221 |
dlg.exec(); |
|
222 |
populateConnectionList(); |
|
223 |
} |
|
224 | ||
211 | 225 |
QgsNumericSortTreeWidgetItem *QgsWMSSourceSelect::createItem( |
212 | 226 |
int id, const QStringList &names, QMap<int, QgsNumericSortTreeWidgetItem *> &items, int &layerAndStyleCount, |
213 | 227 |
const QMap<int, int> &layerParents, const QMap<int, QStringList> &layerParentNames ) |
src/app/CMakeLists.txt (working copy) | ||
---|---|---|
72 | 72 |
qgsvectorlayerproperties.cpp |
73 | 73 |
qgsquerybuilder.cpp |
74 | 74 | |
75 |
qgsmanageconnectionsdialog.cpp |
|
76 | ||
75 | 77 |
composer/qgsattributeselectiondialog.cpp |
76 | 78 |
composer/qgscomposer.cpp |
77 | 79 |
composer/qgscomposerarrowwidget.cpp |
... | ... | |
138 | 140 |
qgsidentifyresults.h |
139 | 141 |
qgslabeldialog.h |
140 | 142 | |
143 |
qgsmanageconnectionsdialog.h |
|
144 | ||
141 | 145 |
qgsmaptoolidentify.h |
142 | 146 |
qgsmaptoolsplitfeatures.h |
143 | 147 |
qgsmaptoolvertexedit.h |
src/ui/qgswmssourceselectbase.ui (working copy) | ||
---|---|---|
140 | 140 |
</column> |
141 | 141 |
</widget> |
142 | 142 |
</item> |
143 |
<item row="3" column="3"> |
|
144 |
<widget class="QPushButton" name="btnLoad"> |
|
145 |
<property name="text"> |
|
146 |
<string>Load</string> |
|
147 |
</property> |
|
148 |
</widget> |
|
149 |
</item> |
|
150 |
<item row="3" column="2"> |
|
151 |
<widget class="QPushButton" name="btnSave"> |
|
152 |
<property name="text"> |
|
153 |
<string>Save</string> |
|
154 |
</property> |
|
155 |
</widget> |
|
156 |
</item> |
|
143 | 157 |
</layout> |
144 | 158 |
</widget> |
145 | 159 |
<widget class="QWidget" name="tabLayerOrder"> |
... | ... | |
311 | 325 |
</layout> |
312 | 326 |
</widget> |
313 | 327 |
</item> |
314 |
<item row="4" column="0" colspan="2">
|
|
328 |
<item row="5" column="0" colspan="2">
|
|
315 | 329 |
<widget class="QLabel" name="labelStatus"> |
316 | 330 |
<property name="sizePolicy"> |
317 | 331 |
<sizepolicy hsizetype="Ignored" vsizetype="Preferred"> |
... | ... | |
327 | 341 |
</property> |
328 | 342 |
</widget> |
329 | 343 |
</item> |
330 |
<item row="3" column="0" colspan="2">
|
|
344 |
<item row="4" column="0" colspan="2">
|
|
331 | 345 |
<widget class="QDialogButtonBox" name="buttonBox"> |
332 | 346 |
<property name="standardButtons"> |
333 | 347 |
<set>QDialogButtonBox::Close|QDialogButtonBox::Help</set> |
src/ui/qgspgsourceselectbase.ui (working copy) | ||
---|---|---|
7 | 7 |
<x>0</x> |
8 | 8 |
<y>0</y> |
9 | 9 |
<width>406</width> |
10 |
<height>470</height>
|
|
10 |
<height>500</height>
|
|
11 | 11 |
</rect> |
12 | 12 |
</property> |
13 | 13 |
<property name="windowTitle"> |
... | ... | |
37 | 37 |
<property name="spacing"> |
38 | 38 |
<number>6</number> |
39 | 39 |
</property> |
40 |
<item row="1" column="3">
|
|
40 |
<item row="2" column="3">
|
|
41 | 41 |
<widget class="QPushButton" name="btnDelete"> |
42 | 42 |
<property name="text"> |
43 | 43 |
<string>Delete</string> |
44 | 44 |
</property> |
45 | 45 |
</widget> |
46 | 46 |
</item> |
47 |
<item row="1" column="2">
|
|
47 |
<item row="2" column="2">
|
|
48 | 48 |
<widget class="QPushButton" name="btnEdit"> |
49 | 49 |
<property name="text"> |
50 | 50 |
<string>Edit</string> |
51 | 51 |
</property> |
52 | 52 |
</widget> |
53 | 53 |
</item> |
54 |
<item row="1" column="1">
|
|
54 |
<item row="2" column="1">
|
|
55 | 55 |
<widget class="QPushButton" name="btnNew"> |
56 | 56 |
<property name="text"> |
57 | 57 |
<string>New</string> |
58 | 58 |
</property> |
59 | 59 |
</widget> |
60 | 60 |
</item> |
61 |
<item row="1" column="0">
|
|
61 |
<item row="2" column="0">
|
|
62 | 62 |
<widget class="QPushButton" name="btnConnect"> |
63 | 63 |
<property name="text"> |
64 | 64 |
<string>Connect</string> |
... | ... | |
72 | 72 |
</widget> |
73 | 73 |
</item> |
74 | 74 |
<item> |
75 |
<layout class="QHBoxLayout" name="horizontalLayout"> |
|
76 |
<item> |
|
77 |
<widget class="QPushButton" name="btnSave"> |
|
78 |
<property name="text"> |
|
79 |
<string>Save</string> |
|
80 |
</property> |
|
81 |
</widget> |
|
82 |
</item> |
|
83 |
<item> |
|
84 |
<widget class="QPushButton" name="btnLoad"> |
|
85 |
<property name="text"> |
|
86 |
<string>Load</string> |
|
87 |
</property> |
|
88 |
</widget> |
|
89 |
</item> |
|
90 |
</layout> |
|
91 |
</item> |
|
92 |
<item> |
|
75 | 93 |
<widget class="QTreeView" name="mTablesTreeView"> |
76 | 94 |
<property name="selectionMode"> |
77 | 95 |
<enum>QAbstractItemView::ExtendedSelection</enum> |
src/ui/qgsmanageconnectionsdialogbase.ui (revision 0) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ui version="4.0"> |
|
3 |
<class>QgsManageConnectionsDialogBase</class> |
|
4 |
<widget class="QDialog" name="QgsManageConnectionsDialogBase"> |
|
5 |
<property name="geometry"> |
|
6 |
<rect> |
|
7 |
<x>0</x> |
|
8 |
<y>0</y> |
|
9 |
<width>400</width> |
|
10 |
<height>300</height> |
|
11 |
</rect> |
|
12 |
</property> |
|
13 |
<property name="windowTitle"> |
|
14 |
<string>Manage connections</string> |
|
15 |
</property> |
|
16 |
<layout class="QVBoxLayout" name="verticalLayout"> |
|
17 |
<item> |
|
18 |
<layout class="QHBoxLayout" name="horizontalLayout"> |
|
19 |
<item> |
|
20 |
<widget class="QLabel" name="label"> |
|
21 |
<property name="text"> |
|
22 |
<string>Save to file</string> |
|
23 |
</property> |
|
24 |
</widget> |
|
25 |
</item> |
|
26 |
<item> |
|
27 |
<widget class="QLineEdit" name="leFileName"/> |
|
28 |
</item> |
|
29 |
<item> |
|
30 |
<widget class="QPushButton" name="btnBrowse"> |
|
31 |
<property name="text"> |
|
32 |
<string>Browse</string> |
|
33 |
</property> |
|
34 |
</widget> |
|
35 |
</item> |
|
36 |
</layout> |
|
37 |
</item> |
|
38 |
<item> |
|
39 |
<widget class="QListWidget" name="listConnections"> |
|
40 |
<property name="editTriggers"> |
|
41 |
<set>QAbstractItemView::NoEditTriggers</set> |
|
42 |
</property> |
|
43 |
<property name="alternatingRowColors"> |
|
44 |
<bool>true</bool> |
|
45 |
</property> |
|
46 |
<property name="selectionMode"> |
|
47 |
<enum>QAbstractItemView::ExtendedSelection</enum> |
|
48 |
</property> |
|
49 |
</widget> |
|
50 |
</item> |
|
51 |
<item> |
|
52 |
<widget class="QDialogButtonBox" name="buttonBox"> |
|
53 |
<property name="orientation"> |
|
54 |
<enum>Qt::Horizontal</enum> |
|
55 |
</property> |
|
56 |
<property name="standardButtons"> |
|
57 |
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
|
58 |
</property> |
|
59 |
</widget> |
|
60 |
</item> |
|
61 |
</layout> |
|
62 |
</widget> |
|
63 |
<resources/> |
|
64 |
<connections> |
|
65 |
<connection> |
|
66 |
<sender>buttonBox</sender> |
|
67 |
<signal>accepted()</signal> |
|
68 |
<receiver>QgsManageConnectionsDialogBase</receiver> |
|
69 |
<slot>accept()</slot> |
|
70 |
<hints> |
|
71 |
<hint type="sourcelabel"> |
|
72 |
<x>248</x> |
|
73 |
<y>254</y> |
|
74 |
</hint> |
|
75 |
<hint type="destinationlabel"> |
|
76 |
<x>157</x> |
|
77 |
<y>274</y> |
|
78 |
</hint> |
|
79 |
</hints> |
|
80 |
</connection> |
|
81 |
<connection> |
|
82 |
<sender>buttonBox</sender> |
|
83 |
<signal>rejected()</signal> |
|
84 |
<receiver>QgsManageConnectionsDialogBase</receiver> |
|
85 |
<slot>reject()</slot> |
|
86 |
<hints> |
|
87 |
<hint type="sourcelabel"> |
|
88 |
<x>316</x> |
|
89 |
<y>260</y> |
|
90 |
</hint> |
|
91 |
<hint type="destinationlabel"> |
|
92 |
<x>286</x> |
|
93 |
<y>274</y> |
|
94 |
</hint> |
|
95 |
</hints> |
|
96 |
</connection> |
|
97 |
</connections> |
|
98 |
</ui> |