QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsmanageconnectionsdialog.cpp
Go to the documentation of this file.
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#include <QCloseEvent>
18#include <QFileDialog>
19#include <QMessageBox>
20#include <QPushButton>
21#include <QTextStream>
22
23#include "qgssettings.h"
25#include "qgshttpheaders.h"
26#include "qgsowsconnection.h"
31
32
33QgsManageConnectionsDialog::QgsManageConnectionsDialog( QWidget *parent, Mode mode, Type type, const QString &fileName )
34 : QDialog( parent )
35 , mFileName( fileName )
36 , mDialogMode( mode )
37 , mConnectionType( type )
38{
39 setupUi( this );
40
41 // additional buttons
42 QPushButton *pb = nullptr;
43 pb = new QPushButton( tr( "Select All" ) );
44 buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
45 connect( pb, &QAbstractButton::clicked, this, &QgsManageConnectionsDialog::selectAll );
46
47 pb = new QPushButton( tr( "Clear Selection" ) );
48 buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
49 connect( pb, &QAbstractButton::clicked, this, &QgsManageConnectionsDialog::clearSelection );
50
51 if ( mDialogMode == Import )
52 {
53 label->setText( tr( "Select connections to import" ) );
54 buttonBox->button( QDialogButtonBox::Ok )->setText( tr( "Import" ) );
55 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
56 }
57 else
58 {
59 //label->setText( tr( "Select connections to export" ) );
60 buttonBox->button( QDialogButtonBox::Ok )->setText( tr( "Export" ) );
61 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
62 }
63
64 if ( !populateConnections() )
65 {
66 QApplication::postEvent( this, new QCloseEvent() );
67 }
68
69 // use OK button for starting import and export operations
70 disconnect( buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
71 connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsManageConnectionsDialog::doExportImport );
72
73 connect( listConnections, &QListWidget::itemSelectionChanged, this, &QgsManageConnectionsDialog::selectionChanged );
74}
75
77{
78 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( !listConnections->selectedItems().isEmpty() );
79}
80
82{
83 const QList<QListWidgetItem *> selection = listConnections->selectedItems();
84 if ( selection.isEmpty() )
85 {
86 QMessageBox::warning( this, tr( "Export/Import Error" ),
87 tr( "You should select at least one connection from list." ) );
88 return;
89 }
90
91 QStringList items;
92 items.reserve( selection.size() );
93 for ( int i = 0; i < selection.size(); ++i )
94 {
95 items.append( selection.at( i )->text() );
96 }
97
98 if ( mDialogMode == Export )
99 {
100 QString fileName = QFileDialog::getSaveFileName( this, tr( "Save Connections" ), QDir::homePath(),
101 tr( "XML files (*.xml *.XML)" ) );
102 // return dialog focus on Mac
103 activateWindow();
104 raise();
105 if ( fileName.isEmpty() )
106 {
107 return;
108 }
109
110 // ensure the user never omitted the extension from the file name
111 if ( !fileName.endsWith( QLatin1String( ".xml" ), Qt::CaseInsensitive ) )
112 {
113 fileName += QLatin1String( ".xml" );
114 }
115
116 mFileName = fileName;
117
118 QDomDocument doc;
119 switch ( mConnectionType )
120 {
121 case WMS:
122 doc = saveOWSConnections( items, QStringLiteral( "WMS" ) );
123 break;
124 case WFS:
125 doc = saveWfsConnections( items );
126 break;
127 case PostGIS:
128 doc = savePgConnections( items );
129 break;
130 case MSSQL:
131 doc = saveMssqlConnections( items );
132 break;
133 case WCS:
134 doc = saveOWSConnections( items, QStringLiteral( "WCS" ) );
135 break;
136 case Oracle:
137 doc = saveOracleConnections( items );
138 break;
139 case HANA:
140 doc = saveHanaConnections( items );
141 break;
142 case XyzTiles:
143 doc = saveXyzTilesConnections( items );
144 break;
145 case ArcgisMapServer:
147 doc = saveArcgisConnections( items );
148 break;
149 case VectorTile:
150 doc = saveVectorTileConnections( items );
151 break;
152 case TiledScene:
153 doc = saveTiledSceneConnections( items );
154 break;
155 }
156
157 QFile file( mFileName );
158 if ( !file.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate ) )
159 {
160 QMessageBox::warning( this, tr( "Saving Connections" ),
161 tr( "Cannot write file %1:\n%2." )
162 .arg( mFileName,
163 file.errorString() ) );
164 return;
165 }
166
167 QTextStream out( &file );
168 doc.save( out, 4 );
169 }
170 else // import connections
171 {
172 QFile file( mFileName );
173 if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
174 {
175 QMessageBox::warning( this, tr( "Loading Connections" ),
176 tr( "Cannot read file %1:\n%2." )
177 .arg( mFileName,
178 file.errorString() ) );
179 return;
180 }
181
182 QDomDocument doc;
183 QString errorStr;
184 int errorLine;
185 int errorColumn;
186
187 if ( !doc.setContent( &file, true, &errorStr, &errorLine, &errorColumn ) )
188 {
189 QMessageBox::warning( this, tr( "Loading Connections" ),
190 tr( "Parse error at line %1, column %2:\n%3" )
191 .arg( errorLine )
192 .arg( errorColumn )
193 .arg( errorStr ) );
194 return;
195 }
196
197 switch ( mConnectionType )
198 {
199 case WMS:
200 loadOWSConnections( doc, items, QStringLiteral( "WMS" ) );
201 break;
202 case WFS:
203 loadWfsConnections( doc, items );
204 break;
205 case PostGIS:
206 loadPgConnections( doc, items );
207 break;
208 case MSSQL:
209 loadMssqlConnections( doc, items );
210 break;
211 case WCS:
212 loadOWSConnections( doc, items, QStringLiteral( "WCS" ) );
213 break;
214 case Oracle:
215 loadOracleConnections( doc, items );
216 break;
217 case HANA:
218 loadHanaConnections( doc, items );
219 break;
220 case XyzTiles:
221 loadXyzTilesConnections( doc, items );
222 break;
223 case ArcgisMapServer:
224 loadArcgisConnections( doc, items, QStringLiteral( "ARCGISMAPSERVER" ) );
225 break;
227 loadArcgisConnections( doc, items, QStringLiteral( "ARCGISFEATURESERVER" ) );
228 break;
229 case VectorTile:
230 loadVectorTileConnections( doc, items );
231 break;
232 case TiledScene:
233 loadTiledSceneConnections( doc, items );
234 break;
235 }
236 // clear connections list and close window
237 listConnections->clear();
238 accept();
239 }
240
241 mFileName.clear();
242}
243
244bool QgsManageConnectionsDialog::populateConnections()
245{
246 // Export mode. Populate connections list from settings
247 if ( mDialogMode == Export )
248 {
249 QStringList connections;
250 QgsSettings settings;
251 switch ( mConnectionType )
252 {
253 case WMS:
254 connections = QgsOwsConnection::sTreeOwsConnections->items( {QStringLiteral( "wms" )} );
255 break;
256 case WFS:
257 connections = QgsOwsConnection::sTreeOwsConnections->items( {QStringLiteral( "wfs" )} );
258 break;
259 case WCS:
260 connections = QgsOwsConnection::sTreeOwsConnections->items( {QStringLiteral( "wcs" )} );
261 break;
262 case PostGIS:
263 settings.beginGroup( QStringLiteral( "/PostgreSQL/connections" ) );
264 connections = settings.childGroups();
265 break;
266 case MSSQL:
267 settings.beginGroup( QStringLiteral( "/MSSQL/connections" ) );
268 connections = settings.childGroups();
269 break;
270 case Oracle:
271 settings.beginGroup( QStringLiteral( "/Oracle/connections" ) );
272 connections = settings.childGroups();
273 break;
274 case HANA:
275 settings.beginGroup( QStringLiteral( "/HANA/connections" ) );
276 connections = settings.childGroups();
277 break;
278 case XyzTiles:
280 break;
281 case ArcgisMapServer:
284 break;
285 case VectorTile:
286 connections = QgsVectorTileProviderConnection::sTreeConnectionVectorTile->items();
287 break;
288 case TiledScene:
289 connections = QgsTiledSceneProviderConnection::sTreeConnectionTiledScene->items();
290 break;
291 }
292 for ( const QString &connection : std::as_const( connections ) )
293 {
294 QListWidgetItem *item = new QListWidgetItem();
295 item->setText( connection );
296 listConnections->addItem( item );
297 }
298 }
299 // Import mode. Populate connections list from file
300 else
301 {
302 QFile file( mFileName );
303 if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
304 {
305 QMessageBox::warning( this, tr( "Loading Connections" ),
306 tr( "Cannot read file %1:\n%2." )
307 .arg( mFileName,
308 file.errorString() ) );
309 return false;
310 }
311
312 QDomDocument doc;
313 QString errorStr;
314 int errorLine;
315 int errorColumn;
316
317 if ( !doc.setContent( &file, true, &errorStr, &errorLine, &errorColumn ) )
318 {
319 QMessageBox::warning( this, tr( "Loading Connections" ),
320 tr( "Parse error at line %1, column %2:\n%3" )
321 .arg( errorLine )
322 .arg( errorColumn )
323 .arg( errorStr ) );
324 return false;
325 }
326
327 const QDomElement root = doc.documentElement();
328 switch ( mConnectionType )
329 {
330 case WMS:
331 if ( root.tagName() != QLatin1String( "qgsWMSConnections" ) )
332 {
333 QMessageBox::information( this, tr( "Loading Connections" ),
334 tr( "The file is not a WMS connections exchange file." ) );
335 return false;
336 }
337 break;
338
339 case WFS:
340 if ( root.tagName() != QLatin1String( "qgsWFSConnections" ) )
341 {
342 QMessageBox::information( this, tr( "Loading Connections" ),
343 tr( "The file is not a WFS connections exchange file." ) );
344 return false;
345 }
346 break;
347
348 case WCS:
349 if ( root.tagName() != QLatin1String( "qgsWCSConnections" ) )
350 {
351 QMessageBox::information( this, tr( "Loading Connections" ),
352 tr( "The file is not a WCS connections exchange file." ) );
353 return false;
354 }
355 break;
356
357 case PostGIS:
358 if ( root.tagName() != QLatin1String( "qgsPgConnections" ) )
359 {
360 QMessageBox::information( this, tr( "Loading Connections" ),
361 tr( "The file is not a PostGIS connections exchange file." ) );
362 return false;
363 }
364 break;
365
366 case MSSQL:
367 if ( root.tagName() != QLatin1String( "qgsMssqlConnections" ) )
368 {
369 QMessageBox::information( this, tr( "Loading Connections" ),
370 tr( "The file is not a MS SQL Server connections exchange file." ) );
371 return false;
372 }
373 break;
374 case Oracle:
375 if ( root.tagName() != QLatin1String( "qgsOracleConnections" ) )
376 {
377 QMessageBox::information( this, tr( "Loading Connections" ),
378 tr( "The file is not an Oracle connections exchange file." ) );
379 return false;
380 }
381 break;
382 case HANA:
383 if ( root.tagName() != QLatin1String( "qgsHanaConnections" ) )
384 {
385 QMessageBox::warning( this, tr( "Loading Connections" ),
386 tr( "The file is not a HANA connections exchange file." ) );
387 return false;
388 }
389 break;
390 case XyzTiles:
391 if ( root.tagName() != QLatin1String( "qgsXYZTilesConnections" ) )
392 {
393 QMessageBox::information( this, tr( "Loading Connections" ),
394 tr( "The file is not a XYZ Tiles connections exchange file." ) );
395 return false;
396 }
397 break;
398 case ArcgisMapServer:
399 if ( root.tagName() != QLatin1String( "qgsARCGISMAPSERVERConnections" ) )
400 {
401 QMessageBox::information( this, tr( "Loading Connections" ),
402 tr( "The file is not a ArcGIS Map Service connections exchange file." ) );
403 return false;
404 }
405 break;
407 if ( root.tagName() != QLatin1String( "qgsARCGISFEATURESERVERConnections" ) )
408 {
409 QMessageBox::information( this, tr( "Loading Connections" ),
410 tr( "The file is not a ArcGIS Feature Service connections exchange file." ) );
411 return false;
412 }
413 break;
414 case VectorTile:
415 if ( root.tagName() != QLatin1String( "qgsVectorTileConnections" ) )
416 {
417 QMessageBox::information( this, tr( "Loading Connections" ),
418 tr( "The file is not a Vector Tile connections exchange file." ) );
419 return false;
420 }
421 break;
422 case TiledScene:
423 if ( root.tagName() != QLatin1String( "qgsTiledSceneConnections" ) )
424 {
425 QMessageBox::information( this, tr( "Loading Connections" ),
426 tr( "The file is not a tiled scene connections exchange file." ) );
427 return false;
428 }
429 break;
430 }
431
432 QDomElement child = root.firstChildElement();
433 while ( !child.isNull() )
434 {
435 QListWidgetItem *item = new QListWidgetItem();
436 item->setText( child.attribute( QStringLiteral( "name" ) ) );
437 listConnections->addItem( item );
438 child = child.nextSiblingElement();
439 }
440 }
441 return true;
442}
443
444QDomDocument QgsManageConnectionsDialog::saveOWSConnections( const QStringList &connections, const QString &service )
445{
446 QDomDocument doc( QStringLiteral( "connections" ) );
447 QDomElement root = doc.createElement( "qgs" + service.toUpper() + "Connections" );
448 root.setAttribute( QStringLiteral( "version" ), QStringLiteral( "1.0" ) );
449 doc.appendChild( root );
450
451 for ( int i = 0; i < connections.count(); ++i )
452 {
453 QDomElement el = doc.createElement( service.toLower() );
454 el.setAttribute( QStringLiteral( "name" ), connections[ i ] );
455 el.setAttribute( QStringLiteral( "url" ), QgsOwsConnection::settingsUrl->value( {service.toLower(), connections[i] } ) );
456
457 if ( service == QLatin1String( "WMS" ) )
458 {
459 el.setAttribute( QStringLiteral( "ignoreGetMapURI" ), QgsOwsConnection::settingsIgnoreGetMapURI->value( {service.toLower(), connections[i] } ) );
460 el.setAttribute( QStringLiteral( "ignoreGetFeatureInfoURI" ), QgsOwsConnection::settingsIgnoreGetFeatureInfoURI->value( {service.toLower(), connections[i] } ) );
461 el.setAttribute( QStringLiteral( "ignoreAxisOrientation" ), QgsOwsConnection::settingsIgnoreAxisOrientation->value( {service.toLower(), connections[i] } ) );
462 el.setAttribute( QStringLiteral( "invertAxisOrientation" ), QgsOwsConnection::settingsInvertAxisOrientation->value( {service.toLower(), connections[i] } ) );
463 el.setAttribute( QStringLiteral( "smoothPixmapTransform" ), QgsOwsConnection::settingsSmoothPixmapTransform->value( {service.toLower(), connections[i] } ) );
464 el.setAttribute( QStringLiteral( "dpiMode" ), static_cast<int>( QgsOwsConnection::settingsDpiMode->value( {service.toLower(), connections[i] } ) ) );
465
466 QgsHttpHeaders httpHeader( QgsOwsConnection::settingsHeaders->value( {service.toLower(), connections[i] } ) );
467 httpHeader.updateDomElement( el );
468 }
469
470 el.setAttribute( QStringLiteral( "username" ), QgsOwsConnection::settingsUsername->value( {service.toLower(), connections[i] } ) );
471 el.setAttribute( QStringLiteral( "password" ), QgsOwsConnection::settingsPassword->value( {service.toLower(), connections[i] } ) );
472 root.appendChild( el );
473 }
474
475 return doc;
476}
477
478QDomDocument QgsManageConnectionsDialog::saveWfsConnections( const QStringList &connections )
479{
480 QDomDocument doc( QStringLiteral( "connections" ) );
481 QDomElement root = doc.createElement( QStringLiteral( "qgsWFSConnections" ) );
482 root.setAttribute( QStringLiteral( "version" ), QStringLiteral( "1.1" ) );
483 doc.appendChild( root );
484
485 for ( int i = 0; i < connections.count(); ++i )
486 {
487 QDomElement el = doc.createElement( QStringLiteral( "wfs" ) );
488 el.setAttribute( QStringLiteral( "name" ), connections[ i ] );
489 el.setAttribute( QStringLiteral( "url" ), QgsOwsConnection::settingsUrl->value( {QStringLiteral( "wfs" ), connections[i] } ) );
490
491 el.setAttribute( QStringLiteral( "version" ), QgsOwsConnection::settingsVersion->value( {QStringLiteral( "wfs" ), connections[i] } ) );
492 el.setAttribute( QStringLiteral( "maxnumfeatures" ), QgsOwsConnection::settingsMaxNumFeatures->value( {QStringLiteral( "wfs" ), connections[i] } ) );
493 el.setAttribute( QStringLiteral( "pagesize" ), QgsOwsConnection::settingsPagesize->value( {QStringLiteral( "wfs" ), connections[i] } ) );
494 el.setAttribute( QStringLiteral( "pagingenabled" ), QgsOwsConnection::settingsPagingEnabled->value( {QStringLiteral( "wfs" ), connections[i] } ) );
495 el.setAttribute( QStringLiteral( "ignoreAxisOrientation" ), QgsOwsConnection::settingsIgnoreAxisOrientation->value( {QStringLiteral( "wfs" ), connections[i] } ) );
496 el.setAttribute( QStringLiteral( "invertAxisOrientation" ), QgsOwsConnection::settingsInvertAxisOrientation->value( {QStringLiteral( "wfs" ), connections[i] } ) );
497 el.setAttribute( QStringLiteral( "username" ), QgsOwsConnection::settingsUsername->value( {QStringLiteral( "wfs" ), connections[i] } ) );
498 el.setAttribute( QStringLiteral( "password" ), QgsOwsConnection::settingsPassword->value( {QStringLiteral( "wfs" ), connections[i] } ) );
499 root.appendChild( el );
500 }
501
502 return doc;
503}
504
505QDomDocument QgsManageConnectionsDialog::savePgConnections( const QStringList &connections )
506{
507 QDomDocument doc( QStringLiteral( "connections" ) );
508 QDomElement root = doc.createElement( QStringLiteral( "qgsPgConnections" ) );
509 root.setAttribute( QStringLiteral( "version" ), QStringLiteral( "1.0" ) );
510 doc.appendChild( root );
511
512 const QgsSettings settings;
513 QString path;
514 for ( int i = 0; i < connections.count(); ++i )
515 {
516 path = "/PostgreSQL/connections/" + connections[ i ];
517 QDomElement el = doc.createElement( QStringLiteral( "postgis" ) );
518 el.setAttribute( QStringLiteral( "name" ), connections[ i ] );
519 el.setAttribute( QStringLiteral( "host" ), settings.value( path + "/host" ).toString() );
520 el.setAttribute( QStringLiteral( "port" ), settings.value( path + "/port" ).toString() );
521 el.setAttribute( QStringLiteral( "database" ), settings.value( path + "/database" ).toString() );
522 el.setAttribute( QStringLiteral( "service" ), settings.value( path + "/service" ).toString() );
523 el.setAttribute( QStringLiteral( "sslmode" ), settings.value( path + "/sslmode", "1" ).toString() );
524 el.setAttribute( QStringLiteral( "estimatedMetadata" ), settings.value( path + "/estimatedMetadata", "0" ).toString() );
525 el.setAttribute( QStringLiteral( "projectsInDatabase" ), settings.value( path + "/projectsInDatabase", "0" ).toString() );
526 el.setAttribute( QStringLiteral( "dontResolveType" ), settings.value( path + "/dontResolveType", "0" ).toString() );
527 el.setAttribute( QStringLiteral( "allowGeometrylessTables" ), settings.value( path + "/allowGeometrylessTables", "0" ).toString() );
528 el.setAttribute( QStringLiteral( "geometryColumnsOnly" ), settings.value( path + "/geometryColumnsOnly", "0" ).toString() );
529 el.setAttribute( QStringLiteral( "publicOnly" ), settings.value( path + "/publicOnly", "0" ).toString() );
530
531 el.setAttribute( QStringLiteral( "saveUsername" ), settings.value( path + "/saveUsername", "false" ).toString() );
532
533 if ( settings.value( path + "/saveUsername", "false" ).toString() == QLatin1String( "true" ) )
534 {
535 el.setAttribute( QStringLiteral( "username" ), settings.value( path + "/username" ).toString() );
536 }
537
538 el.setAttribute( QStringLiteral( "savePassword" ), settings.value( path + "/savePassword", "false" ).toString() );
539
540 if ( settings.value( path + "/savePassword", "false" ).toString() == QLatin1String( "true" ) )
541 {
542 el.setAttribute( QStringLiteral( "password" ), settings.value( path + "/password" ).toString() );
543 }
544
545 root.appendChild( el );
546 }
547
548 return doc;
549}
550
551QDomDocument QgsManageConnectionsDialog::saveMssqlConnections( const QStringList &connections )
552{
553 QDomDocument doc( QStringLiteral( "connections" ) );
554 QDomElement root = doc.createElement( QStringLiteral( "qgsMssqlConnections" ) );
555 root.setAttribute( QStringLiteral( "version" ), QStringLiteral( "1.0" ) );
556 doc.appendChild( root );
557
558 const QgsSettings settings;
559 QString path;
560 for ( int i = 0; i < connections.count(); ++i )
561 {
562 path = "/MSSQL/connections/" + connections[ i ];
563 QDomElement el = doc.createElement( QStringLiteral( "mssql" ) );
564 el.setAttribute( QStringLiteral( "name" ), connections[ i ] );
565 el.setAttribute( QStringLiteral( "host" ), settings.value( path + "/host" ).toString() );
566 el.setAttribute( QStringLiteral( "port" ), settings.value( path + "/port" ).toString() );
567 el.setAttribute( QStringLiteral( "database" ), settings.value( path + "/database" ).toString() );
568 el.setAttribute( QStringLiteral( "service" ), settings.value( path + "/service" ).toString() );
569 el.setAttribute( QStringLiteral( "sslmode" ), settings.value( path + "/sslmode", "1" ).toString() );
570 el.setAttribute( QStringLiteral( "estimatedMetadata" ), settings.value( path + "/estimatedMetadata", "0" ).toString() );
571
572 el.setAttribute( QStringLiteral( "saveUsername" ), settings.value( path + "/saveUsername", "false" ).toString() );
573
574 if ( settings.value( path + "/saveUsername", "false" ).toString() == QLatin1String( "true" ) )
575 {
576 el.setAttribute( QStringLiteral( "username" ), settings.value( path + "/username" ).toString() );
577 }
578
579 el.setAttribute( QStringLiteral( "savePassword" ), settings.value( path + "/savePassword", "false" ).toString() );
580
581 if ( settings.value( path + "/savePassword", "false" ).toString() == QLatin1String( "true" ) )
582 {
583 el.setAttribute( QStringLiteral( "password" ), settings.value( path + "/password" ).toString() );
584 }
585
586 root.appendChild( el );
587 }
588
589 return doc;
590}
591
592QDomDocument QgsManageConnectionsDialog::saveOracleConnections( const QStringList &connections )
593{
594 QDomDocument doc( QStringLiteral( "connections" ) );
595 QDomElement root = doc.createElement( QStringLiteral( "qgsOracleConnections" ) );
596 root.setAttribute( QStringLiteral( "version" ), QStringLiteral( "1.0" ) );
597 doc.appendChild( root );
598
599 const QgsSettings settings;
600 QString path;
601 for ( int i = 0; i < connections.count(); ++i )
602 {
603 path = "/Oracle/connections/" + connections[ i ];
604 QDomElement el = doc.createElement( QStringLiteral( "oracle" ) );
605 el.setAttribute( QStringLiteral( "name" ), connections[ i ] );
606 el.setAttribute( QStringLiteral( "host" ), settings.value( path + "/host" ).toString() );
607 el.setAttribute( QStringLiteral( "port" ), settings.value( path + "/port" ).toString() );
608 el.setAttribute( QStringLiteral( "database" ), settings.value( path + "/database" ).toString() );
609 el.setAttribute( QStringLiteral( "dboptions" ), settings.value( path + "/dboptions" ).toString() );
610 el.setAttribute( QStringLiteral( "dbworkspace" ), settings.value( path + "/dbworkspace" ).toString() );
611 el.setAttribute( QStringLiteral( "schema" ), settings.value( path + "/schema" ).toString() );
612 el.setAttribute( QStringLiteral( "estimatedMetadata" ), settings.value( path + "/estimatedMetadata", "0" ).toString() );
613 el.setAttribute( QStringLiteral( "userTablesOnly" ), settings.value( path + "/userTablesOnly", "0" ).toString() );
614 el.setAttribute( QStringLiteral( "geometryColumnsOnly" ), settings.value( path + "/geometryColumnsOnly", "0" ).toString() );
615 el.setAttribute( QStringLiteral( "allowGeometrylessTables" ), settings.value( path + "/allowGeometrylessTables", "0" ).toString() );
616
617 el.setAttribute( QStringLiteral( "saveUsername" ), settings.value( path + "/saveUsername", "false" ).toString() );
618
619 if ( settings.value( path + "/saveUsername", "false" ).toString() == QLatin1String( "true" ) )
620 {
621 el.setAttribute( QStringLiteral( "username" ), settings.value( path + "/username" ).toString() );
622 }
623
624 el.setAttribute( QStringLiteral( "savePassword" ), settings.value( path + "/savePassword", "false" ).toString() );
625
626 if ( settings.value( path + "/savePassword", "false" ).toString() == QLatin1String( "true" ) )
627 {
628 el.setAttribute( QStringLiteral( "password" ), settings.value( path + "/password" ).toString() );
629 }
630
631 root.appendChild( el );
632 }
633
634 return doc;
635}
636
637QDomDocument QgsManageConnectionsDialog::saveHanaConnections( const QStringList &connections )
638{
639 QDomDocument doc( QStringLiteral( "connections" ) );
640 QDomElement root = doc.createElement( QStringLiteral( "qgsHanaConnections" ) );
641 root.setAttribute( QStringLiteral( "version" ), QStringLiteral( "1.0" ) );
642 doc.appendChild( root );
643
644 const QgsSettings settings;
645 QString path;
646 for ( int i = 0; i < connections.count(); ++i )
647 {
648 path = "/HANA/connections/" + connections[i];
649 QDomElement el = doc.createElement( QStringLiteral( "hana" ) );
650 el.setAttribute( QStringLiteral( "name" ), connections[i] );
651 el.setAttribute( QStringLiteral( "driver" ), settings.value( path + "/driver", QString() ).toString() );
652 el.setAttribute( QStringLiteral( "host" ), settings.value( path + "/host", QString() ).toString() );
653 el.setAttribute( QStringLiteral( "identifierType" ), settings.value( path + "/identifierType", QString() ).toString() );
654 el.setAttribute( QStringLiteral( "identifier" ), settings.value( path + "/identifier", QString() ).toString() );
655 el.setAttribute( QStringLiteral( "multitenant" ), settings.value( path + "/multitenant", QString() ).toString() );
656 el.setAttribute( QStringLiteral( "database" ), settings.value( path + "/database", QString() ).toString() );
657 el.setAttribute( QStringLiteral( "schema" ), settings.value( path + "/schema", QString() ).toString() );
658 el.setAttribute( QStringLiteral( "userTablesOnly" ), settings.value( path + "/userTablesOnly", QStringLiteral( "0" ) ).toString() );
659 el.setAttribute( QStringLiteral( "allowGeometrylessTables" ), settings.value( path + "/allowGeometrylessTables", QStringLiteral( "0" ) ).toString() );
660
661 el.setAttribute( QStringLiteral( "saveUsername" ), settings.value( path + "/saveUsername", QStringLiteral( "false" ) ).toString() );
662 if ( settings.value( path + "/saveUsername", "false" ).toString() == QLatin1String( "true" ) )
663 {
664 el.setAttribute( QStringLiteral( "username" ), settings.value( path + "/username", QString() ).toString() );
665 }
666
667 el.setAttribute( QStringLiteral( "savePassword" ), settings.value( path + "/savePassword", QStringLiteral( "false" ) ).toString() );
668 if ( settings.value( path + "/savePassword", "false" ).toString() == QLatin1String( "true" ) )
669 {
670 el.setAttribute( QStringLiteral( "password" ), settings.value( path + "/password", QString() ).toString() );
671 }
672
673 el.setAttribute( QStringLiteral( "sslEnabled" ), settings.value( path + "/sslEnabled", QStringLiteral( "false" ) ).toString() );
674 el.setAttribute( QStringLiteral( "sslCryptoProvider" ), settings.value( path + "/sslCryptoProvider", QStringLiteral( "openssl" ) ).toString() );
675 el.setAttribute( QStringLiteral( "sslKeyStore" ), settings.value( path + "/sslKeyStore", QString() ).toString() );
676 el.setAttribute( QStringLiteral( "sslTrustStore" ), settings.value( path + "/sslTrustStore", QString() ).toString() );
677 el.setAttribute( QStringLiteral( "sslValidateCertificate" ), settings.value( path + "/sslValidateCertificate", QStringLiteral( "false" ) ).toString() );
678 el.setAttribute( QStringLiteral( "sslHostNameInCertificate" ), settings.value( path + "/sslHostNameInCertificate", QString() ).toString() );
679
680 root.appendChild( el );
681 }
682
683 return doc;
684}
685
686QDomDocument QgsManageConnectionsDialog::saveXyzTilesConnections( const QStringList &connections )
687{
688 QDomDocument doc( QStringLiteral( "connections" ) );
689 QDomElement root = doc.createElement( QStringLiteral( "qgsXYZTilesConnections" ) );
690 root.setAttribute( QStringLiteral( "version" ), QStringLiteral( "1.0" ) );
691 doc.appendChild( root );
692
693 for ( int i = 0; i < connections.count(); ++i )
694 {
695
696 QDomElement el = doc.createElement( QStringLiteral( "xyztiles" ) );
697
698 el.setAttribute( QStringLiteral( "name" ), connections[ i ] );
699 el.setAttribute( QStringLiteral( "url" ), QgsXyzConnectionSettings::settingsUrl->value( connections[ i ] ) );
700 el.setAttribute( QStringLiteral( "zmin" ), QgsXyzConnectionSettings::settingsZmin->value( connections[ i ] ) );
701 el.setAttribute( QStringLiteral( "zmax" ), QgsXyzConnectionSettings::settingsZmax->value( connections[ i ] ) );
702 el.setAttribute( QStringLiteral( "authcfg" ), QgsXyzConnectionSettings::settingsAuthcfg->value( connections[ i ] ) );
703 el.setAttribute( QStringLiteral( "username" ), QgsXyzConnectionSettings::settingsUsername->value( connections[ i ] ) );
704 el.setAttribute( QStringLiteral( "password" ), QgsXyzConnectionSettings::settingsPassword->value( connections[ i ] ) );
705 el.setAttribute( QStringLiteral( "tilePixelRatio" ), QgsXyzConnectionSettings::settingsTilePixelRatio->value( connections[ i ] ) );
706
707 QgsHttpHeaders httpHeader( QgsXyzConnectionSettings::settingsHeaders->value( connections[ i ] ) );
708 httpHeader.updateDomElement( el );
709
710 root.appendChild( el );
711 }
712
713 return doc;
714}
715
716QDomDocument QgsManageConnectionsDialog::saveArcgisConnections( const QStringList &connections )
717{
718 QDomDocument doc( QStringLiteral( "connections" ) );
719 QDomElement root = doc.createElement( "qgsARCGISFEATURESERVERConnections" );
720 root.setAttribute( QStringLiteral( "version" ), QStringLiteral( "1.0" ) );
721 doc.appendChild( root );
722
723 for ( const QString &connection : connections )
724 {
725 QDomElement el = doc.createElement( QStringLiteral( "arcgisfeatureserver" ) );
726 el.setAttribute( QStringLiteral( "name" ), connection );
727 el.setAttribute( QStringLiteral( "url" ), QgsArcGisConnectionSettings::settingsUrl->value( connection ) );
728
729 QgsHttpHeaders httpHeader( QgsArcGisConnectionSettings::settingsHeaders->value( connection ) );
730 httpHeader.updateDomElement( el );
731
732 el.setAttribute( QStringLiteral( "username" ), QgsArcGisConnectionSettings::settingsUsername->value( connection ) );
733 el.setAttribute( QStringLiteral( "password" ), QgsArcGisConnectionSettings::settingsPassword->value( connection ) );
734 el.setAttribute( QStringLiteral( "authcfg" ), QgsArcGisConnectionSettings::settingsAuthcfg->value( connection ) );
735
736 root.appendChild( el );
737 }
738
739 return doc;
740}
741
742QDomDocument QgsManageConnectionsDialog::saveVectorTileConnections( const QStringList &connections )
743{
744 QDomDocument doc( QStringLiteral( "connections" ) );
745 QDomElement root = doc.createElement( QStringLiteral( "qgsVectorTileConnections" ) );
746 root.setAttribute( QStringLiteral( "version" ), QStringLiteral( "1.0" ) );
747 doc.appendChild( root );
748
749 for ( int i = 0; i < connections.count(); ++i )
750 {
751 QDomElement el = doc.createElement( QStringLiteral( "vectortile" ) );
752
753 el.setAttribute( QStringLiteral( "name" ), connections[ i ] );
754 el.setAttribute( QStringLiteral( "url" ), QgsVectorTileProviderConnection::settingsUrl->value( connections[ i ] ) );
755 el.setAttribute( QStringLiteral( "zmin" ), QgsVectorTileProviderConnection::settingsZmin->value( connections[ i ] ) );
756 el.setAttribute( QStringLiteral( "zmax" ), QgsVectorTileProviderConnection::settingsZmax->value( connections[ i ] ) );
757 el.setAttribute( QStringLiteral( "serviceType" ), QgsVectorTileProviderConnection::settingsServiceType->value( connections[ i ] ) );
758 el.setAttribute( QStringLiteral( "authcfg" ), QgsVectorTileProviderConnection::settingsAuthcfg->value( connections[ i ] ) );
759 el.setAttribute( QStringLiteral( "username" ), QgsVectorTileProviderConnection::settingsUsername->value( connections[ i ] ) );
760 el.setAttribute( QStringLiteral( "password" ), QgsVectorTileProviderConnection::settingsPassword->value( connections[ i ] ) );
761 el.setAttribute( QStringLiteral( "styleUrl" ), QgsVectorTileProviderConnection::settingsStyleUrl->value( connections[ i ] ) );
762
763 QgsHttpHeaders httpHeader( QgsVectorTileProviderConnection::settingsHeaders->value( connections[ i ] ) );
764 httpHeader.updateDomElement( el );
765
766 root.appendChild( el );
767 }
768
769 return doc;
770}
771
772QDomDocument QgsManageConnectionsDialog::saveTiledSceneConnections( const QStringList &connections )
773{
774 QDomDocument doc( QStringLiteral( "connections" ) );
775 QDomElement root = doc.createElement( QStringLiteral( "qgsTiledSceneConnections" ) );
776 root.setAttribute( QStringLiteral( "version" ), QStringLiteral( "1.0" ) );
777 doc.appendChild( root );
778
779 for ( int i = 0; i < connections.count(); ++i )
780 {
781 QDomElement el = doc.createElement( QStringLiteral( "tiledscene" ) );
782
783 el.setAttribute( QStringLiteral( "name" ), connections[ i ] );
784 el.setAttribute( QStringLiteral( "provider" ), QgsTiledSceneProviderConnection::settingsProvider->value( connections[ i ] ) );
785 el.setAttribute( QStringLiteral( "url" ), QgsTiledSceneProviderConnection::settingsUrl->value( connections[ i ] ) );
786 el.setAttribute( QStringLiteral( "authcfg" ), QgsTiledSceneProviderConnection::settingsAuthcfg->value( connections[ i ] ) );
787 el.setAttribute( QStringLiteral( "username" ), QgsTiledSceneProviderConnection::settingsUsername->value( connections[ i ] ) );
788 el.setAttribute( QStringLiteral( "password" ), QgsTiledSceneProviderConnection::settingsPassword->value( connections[ i ] ) );
789
790 QgsHttpHeaders httpHeader( QgsTiledSceneProviderConnection::settingsHeaders->value( connections[ i ] ) );
791 httpHeader.updateDomElement( el );
792
793 root.appendChild( el );
794 }
795
796 return doc;
797}
798
799void QgsManageConnectionsDialog::loadOWSConnections( const QDomDocument &doc, const QStringList &items, const QString &service )
800{
801 const QDomElement root = doc.documentElement();
802 if ( root.tagName() != "qgs" + service.toUpper() + "Connections" )
803 {
804 QMessageBox::information( this, tr( "Loading Connections" ),
805 tr( "The file is not a %1 connections exchange file." ).arg( service ) );
806 return;
807 }
808
809 QString connectionName;
810
811 QDomElement child = root.firstChildElement();
812 bool prompt = true;
813 bool overwrite = true;
814
815 while ( !child.isNull() )
816 {
817 connectionName = child.attribute( QStringLiteral( "name" ) );
818 if ( !items.contains( connectionName ) )
819 {
820 child = child.nextSiblingElement();
821 continue;
822 }
823
824 // check for duplicates
825 if ( QgsOwsConnection::settingsUrl->exists( {service.toLower(), connectionName} ) && prompt )
826 {
827 const int res = QMessageBox::warning( this,
828 tr( "Loading Connections" ),
829 tr( "Connection with name '%1' already exists. Overwrite?" )
830 .arg( connectionName ),
831 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
832
833 switch ( res )
834 {
835 case QMessageBox::Cancel:
836 return;
837 case QMessageBox::No:
838 child = child.nextSiblingElement();
839 continue;
840 case QMessageBox::Yes:
841 overwrite = true;
842 break;
843 case QMessageBox::YesToAll:
844 prompt = false;
845 overwrite = true;
846 break;
847 case QMessageBox::NoToAll:
848 prompt = false;
849 overwrite = false;
850 break;
851 }
852 }
853
854 if ( QgsOwsConnection::settingsUrl->exists( {service.toLower(), connectionName} ) && !overwrite )
855 {
856 child = child.nextSiblingElement();
857 continue;
858 }
859
860 // no dups detected or overwrite is allowed
861 QgsOwsConnection::settingsUrl->setValue( child.attribute( QStringLiteral( "url" ) ), {service.toLower(), connectionName} );
862 QgsOwsConnection::settingsIgnoreGetMapURI->setValue( child.attribute( QStringLiteral( "ignoreGetMapURI" ) ) == QLatin1String( "true" ), {service.toLower(), connectionName} );
863 QgsOwsConnection::settingsIgnoreGetFeatureInfoURI->setValue( child.attribute( QStringLiteral( "ignoreGetFeatureInfoURI" ) ) == QLatin1String( "true" ), {service.toLower(), connectionName} );
864 QgsOwsConnection::settingsIgnoreAxisOrientation->setValue( child.attribute( QStringLiteral( "ignoreAxisOrientation" ) ) == QLatin1String( "true" ), {service.toLower(), connectionName} );
865 QgsOwsConnection::settingsInvertAxisOrientation->setValue( child.attribute( QStringLiteral( "invertAxisOrientation" ) ) == QLatin1String( "true" ), {service.toLower(), connectionName} );
866 QgsOwsConnection::settingsSmoothPixmapTransform->setValue( child.attribute( QStringLiteral( "smoothPixmapTransform" ) ) == QLatin1String( "true" ), {service.toLower(), connectionName} );
867 QgsOwsConnection::settingsDpiMode->setValue( static_cast<Qgis::DpiMode>( child.attribute( QStringLiteral( "dpiMode" ), QStringLiteral( "7" ) ).toInt() ), {service.toLower(), connectionName} );
868
869 QgsHttpHeaders httpHeader( child );
870 QgsOwsConnection::settingsHeaders->setValue( httpHeader.headers(), {service.toLower(), connectionName} );
871
872 if ( !child.attribute( QStringLiteral( "username" ) ).isEmpty() )
873 {
874 QgsOwsConnection::settingsUsername->setValue( child.attribute( QStringLiteral( "username" ) ), {service.toUpper(), connectionName} );
875 QgsOwsConnection::settingsPassword->setValue( child.attribute( QStringLiteral( "password" ) ), {service.toUpper(), connectionName} );
876 }
877 child = child.nextSiblingElement();
878 }
879}
880
881void QgsManageConnectionsDialog::loadWfsConnections( const QDomDocument &doc, const QStringList &items )
882{
883 const QDomElement root = doc.documentElement();
884 if ( root.tagName() != QLatin1String( "qgsWFSConnections" ) )
885 {
886 QMessageBox::information( this, tr( "Loading Connections" ),
887 tr( "The file is not a WFS connections exchange file." ) );
888 return;
889 }
890
891 QString connectionName;
892 QStringList keys = QgsOwsConnection::sTreeOwsConnections->items( {QStringLiteral( "geonode" ) } );
893
894 QDomElement child = root.firstChildElement();
895 bool prompt = true;
896 bool overwrite = true;
897
898 while ( !child.isNull() )
899 {
900 connectionName = child.attribute( QStringLiteral( "name" ) );
901 if ( !items.contains( connectionName ) )
902 {
903 child = child.nextSiblingElement();
904 continue;
905 }
906
907 // check for duplicates
908 if ( keys.contains( connectionName ) && prompt )
909 {
910 const int res = QMessageBox::warning( this,
911 tr( "Loading Connections" ),
912 tr( "Connection with name '%1' already exists. Overwrite?" )
913 .arg( connectionName ),
914 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
915
916 switch ( res )
917 {
918 case QMessageBox::Cancel:
919 return;
920 case QMessageBox::No:
921 child = child.nextSiblingElement();
922 continue;
923 case QMessageBox::Yes:
924 overwrite = true;
925 break;
926 case QMessageBox::YesToAll:
927 prompt = false;
928 overwrite = true;
929 break;
930 case QMessageBox::NoToAll:
931 prompt = false;
932 overwrite = false;
933 break;
934 }
935 }
936
937 if ( keys.contains( connectionName ) )
938 {
939 if ( !overwrite )
940 {
941 child = child.nextSiblingElement();
942 continue;
943 }
944 }
945 else
946 {
947 keys << connectionName;
948 }
949
950 // no dups detected or overwrite is allowed
951
952 QgsOwsConnection::settingsUrl->setValue( child.attribute( QStringLiteral( "url" ) ), {QStringLiteral( "wfs" ), connectionName} );
953 QgsOwsConnection::settingsVersion->setValue( child.attribute( QStringLiteral( "version" ) ), {QStringLiteral( "wfs" ), connectionName} );
954 QgsOwsConnection::settingsMaxNumFeatures->setValue( child.attribute( QStringLiteral( "maxnumfeatures" ) ), {QStringLiteral( "wfs" ), connectionName} );
955 QgsOwsConnection::settingsPagesize->setValue( child.attribute( QStringLiteral( "pagesize" ) ), {QStringLiteral( "wfs" ), connectionName} );
956 QgsOwsConnection::settingsPagingEnabled->setValue( child.attribute( QStringLiteral( "pagingenabled" ) ).toInt(), {QStringLiteral( "wfs" ), connectionName} );
957 QgsOwsConnection::settingsIgnoreAxisOrientation->setValue( child.attribute( QStringLiteral( "ignoreAxisOrientation" ) ).toInt(), {QStringLiteral( "wfs" ), connectionName} );
958 QgsOwsConnection::settingsInvertAxisOrientation->setValue( child.attribute( QStringLiteral( "invertAxisOrientation" ) ).toInt(), {QStringLiteral( "wfs" ), connectionName} );
959
960 if ( !child.attribute( QStringLiteral( "username" ) ).isEmpty() )
961 {
962 QgsOwsConnection::settingsUsername->setValue( child.attribute( QStringLiteral( "username" ) ), {QStringLiteral( "wfs" ), connectionName} );
963 QgsOwsConnection::settingsPassword->setValue( child.attribute( QStringLiteral( "password" ) ), {QStringLiteral( "wfs" ), connectionName} );
964 }
965 child = child.nextSiblingElement();
966 }
967}
968
969void QgsManageConnectionsDialog::loadPgConnections( const QDomDocument &doc, const QStringList &items )
970{
971 const QDomElement root = doc.documentElement();
972 if ( root.tagName() != QLatin1String( "qgsPgConnections" ) )
973 {
974 QMessageBox::information( this,
975 tr( "Loading Connections" ),
976 tr( "The file is not a PostGIS connections exchange file." ) );
977 return;
978 }
979
980 QString connectionName;
981 QgsSettings settings;
982 settings.beginGroup( QStringLiteral( "/PostgreSQL/connections" ) );
983 QStringList keys = settings.childGroups();
984 settings.endGroup();
985 QDomElement child = root.firstChildElement();
986 bool prompt = true;
987 bool overwrite = true;
988
989 while ( !child.isNull() )
990 {
991 connectionName = child.attribute( QStringLiteral( "name" ) );
992 if ( !items.contains( connectionName ) )
993 {
994 child = child.nextSiblingElement();
995 continue;
996 }
997
998 // check for duplicates
999 if ( keys.contains( connectionName ) && prompt )
1000 {
1001 const int res = QMessageBox::warning( this,
1002 tr( "Loading Connections" ),
1003 tr( "Connection with name '%1' already exists. Overwrite?" )
1004 .arg( connectionName ),
1005 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1006 switch ( res )
1007 {
1008 case QMessageBox::Cancel:
1009 return;
1010 case QMessageBox::No:
1011 child = child.nextSiblingElement();
1012 continue;
1013 case QMessageBox::Yes:
1014 overwrite = true;
1015 break;
1016 case QMessageBox::YesToAll:
1017 prompt = false;
1018 overwrite = true;
1019 break;
1020 case QMessageBox::NoToAll:
1021 prompt = false;
1022 overwrite = false;
1023 break;
1024 }
1025 }
1026
1027 if ( keys.contains( connectionName ) )
1028 {
1029 if ( !overwrite )
1030 {
1031 child = child.nextSiblingElement();
1032 continue;
1033 }
1034 }
1035 else
1036 {
1037 keys << connectionName;
1038 }
1039
1040 //no dups detected or overwrite is allowed
1041 settings.beginGroup( "/PostgreSQL/connections/" + connectionName );
1042
1043 settings.setValue( QStringLiteral( "/host" ), child.attribute( QStringLiteral( "host" ) ) );
1044 settings.setValue( QStringLiteral( "/port" ), child.attribute( QStringLiteral( "port" ) ) );
1045 settings.setValue( QStringLiteral( "/database" ), child.attribute( QStringLiteral( "database" ) ) );
1046 if ( child.hasAttribute( QStringLiteral( "service" ) ) )
1047 {
1048 settings.setValue( QStringLiteral( "/service" ), child.attribute( QStringLiteral( "service" ) ) );
1049 }
1050 else
1051 {
1052 settings.setValue( QStringLiteral( "/service" ), "" );
1053 }
1054 settings.setValue( QStringLiteral( "/sslmode" ), child.attribute( QStringLiteral( "sslmode" ) ) );
1055 settings.setValue( QStringLiteral( "/estimatedMetadata" ), child.attribute( QStringLiteral( "estimatedMetadata" ) ) );
1056 settings.setValue( QStringLiteral( "/projectsInDatabase" ), child.attribute( QStringLiteral( "projectsInDatabase" ), 0 ) );
1057 settings.setValue( QStringLiteral( "/dontResolveType" ), child.attribute( QStringLiteral( "dontResolveType" ), 0 ) );
1058 settings.setValue( QStringLiteral( "/allowGeometrylessTables" ), child.attribute( QStringLiteral( "allowGeometrylessTables" ), 0 ) );
1059 settings.setValue( QStringLiteral( "/geometryColumnsOnly" ), child.attribute( QStringLiteral( "geometryColumnsOnly" ), 0 ) );
1060 settings.setValue( QStringLiteral( "/publicOnly" ), child.attribute( QStringLiteral( "publicOnly" ), 0 ) );
1061 settings.setValue( QStringLiteral( "/saveUsername" ), child.attribute( QStringLiteral( "saveUsername" ) ) );
1062 settings.setValue( QStringLiteral( "/username" ), child.attribute( QStringLiteral( "username" ) ) );
1063 settings.setValue( QStringLiteral( "/savePassword" ), child.attribute( QStringLiteral( "savePassword" ) ) );
1064 settings.setValue( QStringLiteral( "/password" ), child.attribute( QStringLiteral( "password" ) ) );
1065 settings.endGroup();
1066
1067 child = child.nextSiblingElement();
1068 }
1069}
1070
1071void QgsManageConnectionsDialog::loadMssqlConnections( const QDomDocument &doc, const QStringList &items )
1072{
1073 const QDomElement root = doc.documentElement();
1074 if ( root.tagName() != QLatin1String( "qgsMssqlConnections" ) )
1075 {
1076 QMessageBox::information( this,
1077 tr( "Loading Connections" ),
1078 tr( "The file is not a MS SQL Server connections exchange file." ) );
1079 return;
1080 }
1081
1082 QString connectionName;
1083 QgsSettings settings;
1084 settings.beginGroup( QStringLiteral( "/MSSQL/connections" ) );
1085 QStringList keys = settings.childGroups();
1086 settings.endGroup();
1087 QDomElement child = root.firstChildElement();
1088 bool prompt = true;
1089 bool overwrite = true;
1090
1091 while ( !child.isNull() )
1092 {
1093 connectionName = child.attribute( QStringLiteral( "name" ) );
1094 if ( !items.contains( connectionName ) )
1095 {
1096 child = child.nextSiblingElement();
1097 continue;
1098 }
1099
1100 // check for duplicates
1101 if ( keys.contains( connectionName ) && prompt )
1102 {
1103 const int res = QMessageBox::warning( this,
1104 tr( "Loading Connections" ),
1105 tr( "Connection with name '%1' already exists. Overwrite?" )
1106 .arg( connectionName ),
1107 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1108 switch ( res )
1109 {
1110 case QMessageBox::Cancel:
1111 return;
1112 case QMessageBox::No:
1113 child = child.nextSiblingElement();
1114 continue;
1115 case QMessageBox::Yes:
1116 overwrite = true;
1117 break;
1118 case QMessageBox::YesToAll:
1119 prompt = false;
1120 overwrite = true;
1121 break;
1122 case QMessageBox::NoToAll:
1123 prompt = false;
1124 overwrite = false;
1125 break;
1126 }
1127 }
1128
1129 if ( keys.contains( connectionName ) )
1130 {
1131 if ( !overwrite )
1132 {
1133 child = child.nextSiblingElement();
1134 continue;
1135 }
1136 }
1137 else
1138 {
1139 keys << connectionName;
1140 }
1141
1142 //no dups detected or overwrite is allowed
1143 settings.beginGroup( "/MSSQL/connections/" + connectionName );
1144
1145 settings.setValue( QStringLiteral( "/host" ), child.attribute( QStringLiteral( "host" ) ) );
1146 settings.setValue( QStringLiteral( "/port" ), child.attribute( QStringLiteral( "port" ) ) );
1147 settings.setValue( QStringLiteral( "/database" ), child.attribute( QStringLiteral( "database" ) ) );
1148 if ( child.hasAttribute( QStringLiteral( "service" ) ) )
1149 {
1150 settings.setValue( QStringLiteral( "/service" ), child.attribute( QStringLiteral( "service" ) ) );
1151 }
1152 else
1153 {
1154 settings.setValue( QStringLiteral( "/service" ), "" );
1155 }
1156 settings.setValue( QStringLiteral( "/sslmode" ), child.attribute( QStringLiteral( "sslmode" ) ) );
1157 settings.setValue( QStringLiteral( "/estimatedMetadata" ), child.attribute( QStringLiteral( "estimatedMetadata" ) ) );
1158 settings.setValue( QStringLiteral( "/saveUsername" ), child.attribute( QStringLiteral( "saveUsername" ) ) );
1159 settings.setValue( QStringLiteral( "/username" ), child.attribute( QStringLiteral( "username" ) ) );
1160 settings.setValue( QStringLiteral( "/savePassword" ), child.attribute( QStringLiteral( "savePassword" ) ) );
1161 settings.setValue( QStringLiteral( "/password" ), child.attribute( QStringLiteral( "password" ) ) );
1162 settings.endGroup();
1163
1164 child = child.nextSiblingElement();
1165 }
1166}
1167
1168void QgsManageConnectionsDialog::loadOracleConnections( const QDomDocument &doc, const QStringList &items )
1169{
1170 const QDomElement root = doc.documentElement();
1171 if ( root.tagName() != QLatin1String( "qgsOracleConnections" ) )
1172 {
1173 QMessageBox::information( this,
1174 tr( "Loading Connections" ),
1175 tr( "The file is not an Oracle connections exchange file." ) );
1176 return;
1177 }
1178
1179 QString connectionName;
1180 QgsSettings settings;
1181 settings.beginGroup( QStringLiteral( "/Oracle/connections" ) );
1182 QStringList keys = settings.childGroups();
1183 settings.endGroup();
1184 QDomElement child = root.firstChildElement();
1185 bool prompt = true;
1186 bool overwrite = true;
1187
1188 while ( !child.isNull() )
1189 {
1190 connectionName = child.attribute( QStringLiteral( "name" ) );
1191 if ( !items.contains( connectionName ) )
1192 {
1193 child = child.nextSiblingElement();
1194 continue;
1195 }
1196
1197 // check for duplicates
1198 if ( keys.contains( connectionName ) && prompt )
1199 {
1200 const int res = QMessageBox::warning( this,
1201 tr( "Loading Connections" ),
1202 tr( "Connection with name '%1' already exists. Overwrite?" )
1203 .arg( connectionName ),
1204 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1205 switch ( res )
1206 {
1207 case QMessageBox::Cancel:
1208 return;
1209 case QMessageBox::No:
1210 child = child.nextSiblingElement();
1211 continue;
1212 case QMessageBox::Yes:
1213 overwrite = true;
1214 break;
1215 case QMessageBox::YesToAll:
1216 prompt = false;
1217 overwrite = true;
1218 break;
1219 case QMessageBox::NoToAll:
1220 prompt = false;
1221 overwrite = false;
1222 break;
1223 }
1224 }
1225
1226 if ( keys.contains( connectionName ) )
1227 {
1228 if ( !overwrite )
1229 {
1230 child = child.nextSiblingElement();
1231 continue;
1232 }
1233 }
1234 else
1235 {
1236 keys << connectionName;
1237 }
1238
1239 //no dups detected or overwrite is allowed
1240 settings.beginGroup( "/Oracle/connections/" + connectionName );
1241
1242 settings.setValue( QStringLiteral( "/host" ), child.attribute( QStringLiteral( "host" ) ) );
1243 settings.setValue( QStringLiteral( "/port" ), child.attribute( QStringLiteral( "port" ) ) );
1244 settings.setValue( QStringLiteral( "/database" ), child.attribute( QStringLiteral( "database" ) ) );
1245 settings.setValue( QStringLiteral( "/dboptions" ), child.attribute( QStringLiteral( "dboptions" ) ) );
1246 settings.setValue( QStringLiteral( "/dbworkspace" ), child.attribute( QStringLiteral( "dbworkspace" ) ) );
1247 settings.setValue( QStringLiteral( "/schema" ), child.attribute( QStringLiteral( "schema" ) ) );
1248 settings.setValue( QStringLiteral( "/estimatedMetadata" ), child.attribute( QStringLiteral( "estimatedMetadata" ) ) );
1249 settings.setValue( QStringLiteral( "/userTablesOnly" ), child.attribute( QStringLiteral( "userTablesOnly" ) ) );
1250 settings.setValue( QStringLiteral( "/geometryColumnsOnly" ), child.attribute( QStringLiteral( "geometryColumnsOnly" ) ) );
1251 settings.setValue( QStringLiteral( "/allowGeometrylessTables" ), child.attribute( QStringLiteral( "allowGeometrylessTables" ) ) );
1252 settings.setValue( QStringLiteral( "/saveUsername" ), child.attribute( QStringLiteral( "saveUsername" ) ) );
1253 settings.setValue( QStringLiteral( "/username" ), child.attribute( QStringLiteral( "username" ) ) );
1254 settings.setValue( QStringLiteral( "/savePassword" ), child.attribute( QStringLiteral( "savePassword" ) ) );
1255 settings.setValue( QStringLiteral( "/password" ), child.attribute( QStringLiteral( "password" ) ) );
1256 settings.endGroup();
1257
1258 child = child.nextSiblingElement();
1259 }
1260}
1261
1262void QgsManageConnectionsDialog::loadHanaConnections( const QDomDocument &doc, const QStringList &items )
1263{
1264 QDomElement root = doc.documentElement();
1265 if ( root.tagName() != QLatin1String( "qgsHanaConnections" ) )
1266 {
1267 QMessageBox::warning( this,
1268 tr( "Loading Connections" ),
1269 tr( "The file is not a HANA connections exchange file." ) );
1270 return;
1271 }
1272
1273 const QDomAttr version = root.attributeNode( "version" );
1274 if ( version.value() != QLatin1String( "1.0" ) )
1275 {
1276 QMessageBox::warning( this,
1277 tr( "Loading Connections" ),
1278 tr( "The HANA connections exchange file version '%1' is not supported." ).arg( version.value() ) );
1279 return;
1280 }
1281
1282 QgsSettings settings;
1283 settings.beginGroup( QStringLiteral( "/HANA/connections" ) );
1284 QStringList keys = settings.childGroups();
1285 settings.endGroup();
1286 QDomElement child = root.firstChildElement();
1287 bool prompt = true;
1288 bool overwrite = true;
1289
1290 while ( !child.isNull() )
1291 {
1292 const QString connectionName = child.attribute( QStringLiteral( "name" ) );
1293 if ( !items.contains( connectionName ) )
1294 {
1295 child = child.nextSiblingElement();
1296 continue;
1297 }
1298
1299 // check for duplicates
1300 if ( keys.contains( connectionName ) && prompt )
1301 {
1302 const int res = QMessageBox::warning( this,
1303 tr( "Loading Connections" ),
1304 tr( "Connection with name '%1' already exists. Overwrite?" )
1305 .arg( connectionName ),
1306 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1307 switch ( res )
1308 {
1309 case QMessageBox::Cancel:
1310 return;
1311 case QMessageBox::No:
1312 child = child.nextSiblingElement();
1313 continue;
1314 case QMessageBox::Yes:
1315 overwrite = true;
1316 break;
1317 case QMessageBox::YesToAll:
1318 prompt = false;
1319 overwrite = true;
1320 break;
1321 case QMessageBox::NoToAll:
1322 prompt = false;
1323 overwrite = false;
1324 break;
1325 }
1326 }
1327
1328 if ( keys.contains( connectionName ) )
1329 {
1330 if ( !overwrite )
1331 {
1332 child = child.nextSiblingElement();
1333 continue;
1334 }
1335 }
1336 else
1337 {
1338 keys << connectionName;
1339 }
1340
1341 //no dups detected or overwrite is allowed
1342 settings.beginGroup( "/HANA/connections/" + connectionName );
1343
1344 for ( const QString param :
1345 {"driver", "host", "database", "identifierType", "identifier", "multitenant", "schema", "userTablesOnly",
1346 "allowGeometrylessTables", "saveUsername", "username", "savePassword", "password", "sslEnabled",
1347 "sslCryptoProvider", "sslKeyStore", "sslTrustStore", "sslValidateCertificate", "sslHostNameInCertificate"
1348 } )
1349 settings.setValue( QStringLiteral( "/" ) + param, child.attribute( param ) );
1350
1351 settings.endGroup();
1352
1353 child = child.nextSiblingElement();
1354 }
1355}
1356
1357void QgsManageConnectionsDialog::loadXyzTilesConnections( const QDomDocument &doc, const QStringList &items )
1358{
1359 const QDomElement root = doc.documentElement();
1360 if ( root.tagName() != QLatin1String( "qgsXYZTilesConnections" ) )
1361 {
1362 QMessageBox::information( this, tr( "Loading Connections" ),
1363 tr( "The file is not a XYZ Tiles connections exchange file." ) );
1364 return;
1365 }
1366
1367 QString connectionName;
1369 QDomElement child = root.firstChildElement();
1370 bool prompt = true;
1371 bool overwrite = true;
1372
1373 while ( !child.isNull() )
1374 {
1375 connectionName = child.attribute( QStringLiteral( "name" ) );
1376 if ( !items.contains( connectionName ) )
1377 {
1378 child = child.nextSiblingElement();
1379 continue;
1380 }
1381
1382 // check for duplicates
1383 if ( keys.contains( connectionName ) && prompt )
1384 {
1385 const int res = QMessageBox::warning( this,
1386 tr( "Loading Connections" ),
1387 tr( "Connection with name '%1' already exists. Overwrite?" )
1388 .arg( connectionName ),
1389 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1390
1391 switch ( res )
1392 {
1393 case QMessageBox::Cancel:
1394 return;
1395 case QMessageBox::No:
1396 child = child.nextSiblingElement();
1397 continue;
1398 case QMessageBox::Yes:
1399 overwrite = true;
1400 break;
1401 case QMessageBox::YesToAll:
1402 prompt = false;
1403 overwrite = true;
1404 break;
1405 case QMessageBox::NoToAll:
1406 prompt = false;
1407 overwrite = false;
1408 break;
1409 }
1410 }
1411
1412 if ( keys.contains( connectionName ) )
1413 {
1414 if ( !overwrite )
1415 {
1416 child = child.nextSiblingElement();
1417 continue;
1418 }
1419 }
1420 else
1421 {
1422 keys << connectionName;
1423 }
1424
1425
1426 QgsXyzConnectionSettings::settingsUrl->setValue( child.attribute( QStringLiteral( "url" ) ), connectionName );
1427 QgsXyzConnectionSettings::settingsZmin->setValue( child.attribute( QStringLiteral( "zmin" ) ).toInt(), connectionName );
1428 QgsXyzConnectionSettings::settingsZmax->setValue( child.attribute( QStringLiteral( "zmax" ) ).toInt(), connectionName );
1429 QgsXyzConnectionSettings::settingsAuthcfg->setValue( child.attribute( QStringLiteral( "authcfg" ) ), connectionName );
1430 QgsXyzConnectionSettings::settingsUsername->setValue( child.attribute( QStringLiteral( "username" ) ), connectionName );
1431 QgsXyzConnectionSettings::settingsPassword->setValue( child.attribute( QStringLiteral( "password" ) ), connectionName );
1432 QgsXyzConnectionSettings::settingsTilePixelRatio->setValue( child.attribute( QStringLiteral( "tilePixelRatio" ) ).toInt(), connectionName );
1433
1434 QgsHttpHeaders httpHeader( child );
1435 QgsXyzConnectionSettings::settingsHeaders->setValue( httpHeader.headers(), connectionName );
1436
1437 child = child.nextSiblingElement();
1438 }
1439}
1440
1441void QgsManageConnectionsDialog::loadArcgisConnections( const QDomDocument &doc, const QStringList &items, const QString &service )
1442{
1443 const QDomElement root = doc.documentElement();
1444 if ( root.tagName() != "qgs" + service.toUpper() + "Connections" )
1445 {
1446 QMessageBox::information( this, tr( "Loading Connections" ),
1447 tr( "The file is not a %1 connections exchange file." ).arg( service ) );
1448 return;
1449 }
1450
1451 QString connectionName;
1453 QDomElement child = root.firstChildElement();
1454 bool prompt = true;
1455 bool overwrite = true;
1456
1457 while ( !child.isNull() )
1458 {
1459 connectionName = child.attribute( QStringLiteral( "name" ) );
1460 if ( !items.contains( connectionName ) )
1461 {
1462 child = child.nextSiblingElement();
1463 continue;
1464 }
1465
1466 // check for duplicates
1467 if ( keys.contains( connectionName ) && prompt )
1468 {
1469 const int res = QMessageBox::warning( this,
1470 tr( "Loading Connections" ),
1471 tr( "Connection with name '%1' already exists. Overwrite?" )
1472 .arg( connectionName ),
1473 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1474
1475 switch ( res )
1476 {
1477 case QMessageBox::Cancel:
1478 return;
1479 case QMessageBox::No:
1480 child = child.nextSiblingElement();
1481 continue;
1482 case QMessageBox::Yes:
1483 overwrite = true;
1484 break;
1485 case QMessageBox::YesToAll:
1486 prompt = false;
1487 overwrite = true;
1488 break;
1489 case QMessageBox::NoToAll:
1490 prompt = false;
1491 overwrite = false;
1492 break;
1493 }
1494 }
1495
1496 if ( keys.contains( connectionName ) )
1497 {
1498 if ( !overwrite )
1499 {
1500 child = child.nextSiblingElement();
1501 continue;
1502 }
1503 }
1504 else
1505 {
1506 keys << connectionName;
1507 }
1508
1509 // no dups detected or overwrite is allowed
1510 QgsArcGisConnectionSettings::settingsUrl->setValue( child.attribute( QStringLiteral( "url" ) ), connectionName );
1511
1512 QgsArcGisConnectionSettings::settingsHeaders->setValue( QgsHttpHeaders( child ).headers(), connectionName );
1513
1514
1515 QgsArcGisConnectionSettings::settingsUsername->setValue( child.attribute( QStringLiteral( "username" ) ), connectionName );
1516 QgsArcGisConnectionSettings::settingsPassword->setValue( child.attribute( QStringLiteral( "password" ) ), connectionName );
1517 QgsArcGisConnectionSettings::settingsAuthcfg->setValue( child.attribute( QStringLiteral( "authcfg" ) ), connectionName );
1518
1519 child = child.nextSiblingElement();
1520 }
1521}
1522
1523void QgsManageConnectionsDialog::loadVectorTileConnections( const QDomDocument &doc, const QStringList &items )
1524{
1525 const QDomElement root = doc.documentElement();
1526 if ( root.tagName() != QLatin1String( "qgsVectorTileConnections" ) )
1527 {
1528 QMessageBox::information( this, tr( "Loading Connections" ),
1529 tr( "The file is not a Vector Tile connections exchange file." ) );
1530 return;
1531 }
1532
1533 QString connectionName;
1534 QgsSettings settings;
1535 settings.beginGroup( QStringLiteral( "/qgis/connections-vector-tile" ) );
1536 QStringList keys = settings.childGroups();
1537 settings.endGroup();
1538 QDomElement child = root.firstChildElement();
1539 bool prompt = true;
1540 bool overwrite = true;
1541
1542 while ( !child.isNull() )
1543 {
1544 connectionName = child.attribute( QStringLiteral( "name" ) );
1545 if ( !items.contains( connectionName ) )
1546 {
1547 child = child.nextSiblingElement();
1548 continue;
1549 }
1550
1551 // check for duplicates
1552 if ( keys.contains( connectionName ) && prompt )
1553 {
1554 const int res = QMessageBox::warning( this,
1555 tr( "Loading Connections" ),
1556 tr( "Connection with name '%1' already exists. Overwrite?" )
1557 .arg( connectionName ),
1558 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1559
1560 switch ( res )
1561 {
1562 case QMessageBox::Cancel:
1563 return;
1564 case QMessageBox::No:
1565 child = child.nextSiblingElement();
1566 continue;
1567 case QMessageBox::Yes:
1568 overwrite = true;
1569 break;
1570 case QMessageBox::YesToAll:
1571 prompt = false;
1572 overwrite = true;
1573 break;
1574 case QMessageBox::NoToAll:
1575 prompt = false;
1576 overwrite = false;
1577 break;
1578 }
1579 }
1580
1581 if ( keys.contains( connectionName ) )
1582 {
1583 if ( !overwrite )
1584 {
1585 child = child.nextSiblingElement();
1586 continue;
1587 }
1588 }
1589 else
1590 {
1591 keys << connectionName;
1592 }
1593
1594 QgsVectorTileProviderConnection::settingsUrl->setValue( child.attribute( QStringLiteral( "url" ) ), connectionName );
1595 QgsVectorTileProviderConnection::settingsZmin->setValue( child.attribute( QStringLiteral( "zmin" ) ).toInt(), connectionName );
1596 QgsVectorTileProviderConnection::settingsZmax->setValue( child.attribute( QStringLiteral( "zmax" ) ).toInt(), connectionName );
1597 QgsVectorTileProviderConnection::settingsServiceType->setValue( child.attribute( QStringLiteral( "serviceType" ) ), connectionName );
1598 QgsVectorTileProviderConnection::settingsAuthcfg->setValue( child.attribute( QStringLiteral( "authcfg" ) ), connectionName );
1599 QgsVectorTileProviderConnection::settingsUsername->setValue( child.attribute( QStringLiteral( "username" ) ), connectionName );
1600 QgsVectorTileProviderConnection::settingsPassword->setValue( child.attribute( QStringLiteral( "password" ) ), connectionName );
1601 QgsVectorTileProviderConnection::settingsStyleUrl->setValue( child.attribute( QStringLiteral( "styleUrl" ) ), connectionName );
1602
1603 QgsHttpHeaders httpHeader( child );
1604 QgsVectorTileProviderConnection::settingsHeaders->setValue( httpHeader.headers(), connectionName );
1605
1606 child = child.nextSiblingElement();
1607 }
1608}
1609
1610void QgsManageConnectionsDialog::loadTiledSceneConnections( const QDomDocument &doc, const QStringList &items )
1611{
1612 const QDomElement root = doc.documentElement();
1613 if ( root.tagName() != QLatin1String( "qgsTiledSceneConnections" ) )
1614 {
1615 QMessageBox::information( this, tr( "Loading Connections" ),
1616 tr( "The file is not a tiled scene connections exchange file." ) );
1617 return;
1618 }
1619
1620 QString connectionName;
1621 QgsSettings settings;
1622 settings.beginGroup( QStringLiteral( "/qgis/connections-tiled-scene" ) );
1623 QStringList keys = settings.childGroups();
1624 settings.endGroup();
1625 QDomElement child = root.firstChildElement();
1626 bool prompt = true;
1627 bool overwrite = true;
1628
1629 while ( !child.isNull() )
1630 {
1631 connectionName = child.attribute( QStringLiteral( "name" ) );
1632 if ( !items.contains( connectionName ) )
1633 {
1634 child = child.nextSiblingElement();
1635 continue;
1636 }
1637
1638 // check for duplicates
1639 if ( keys.contains( connectionName ) && prompt )
1640 {
1641 const int res = QMessageBox::warning( this,
1642 tr( "Loading Connections" ),
1643 tr( "Connection with name '%1' already exists. Overwrite?" )
1644 .arg( connectionName ),
1645 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1646
1647 switch ( res )
1648 {
1649 case QMessageBox::Cancel:
1650 return;
1651 case QMessageBox::No:
1652 child = child.nextSiblingElement();
1653 continue;
1654 case QMessageBox::Yes:
1655 overwrite = true;
1656 break;
1657 case QMessageBox::YesToAll:
1658 prompt = false;
1659 overwrite = true;
1660 break;
1661 case QMessageBox::NoToAll:
1662 prompt = false;
1663 overwrite = false;
1664 break;
1665 }
1666 }
1667
1668 if ( keys.contains( connectionName ) )
1669 {
1670 if ( !overwrite )
1671 {
1672 child = child.nextSiblingElement();
1673 continue;
1674 }
1675 }
1676 else
1677 {
1678 keys << connectionName;
1679 }
1680
1681 QgsTiledSceneProviderConnection::settingsProvider->setValue( child.attribute( QStringLiteral( "provider" ) ), connectionName );
1682 QgsTiledSceneProviderConnection::settingsUrl->setValue( child.attribute( QStringLiteral( "url" ) ), connectionName );
1683 QgsTiledSceneProviderConnection::settingsAuthcfg->setValue( child.attribute( QStringLiteral( "authcfg" ) ), connectionName );
1684 QgsTiledSceneProviderConnection::settingsUsername->setValue( child.attribute( QStringLiteral( "username" ) ), connectionName );
1685 QgsTiledSceneProviderConnection::settingsPassword->setValue( child.attribute( QStringLiteral( "password" ) ), connectionName );
1686
1687 QgsHttpHeaders httpHeader( child );
1688 QgsTiledSceneProviderConnection::settingsHeaders->setValue( httpHeader.headers(), connectionName );
1689
1690 child = child.nextSiblingElement();
1691 }
1692}
1693
1695{
1696 listConnections->selectAll();
1697 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( !listConnections->selectedItems().isEmpty() );
1698}
1699
1701{
1702 listConnections->clearSelection();
1703 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
1704}
DpiMode
DpiMode enum.
Definition qgis.h:2462
static const QgsSettingsEntryString * settingsUsername
static const QgsSettingsEntryString * settingsUrl
static const QgsSettingsEntryString * settingsPassword
static const QgsSettingsEntryVariantMap * settingsHeaders
static QgsSettingsTreeNamedListNode * sTreeConnectionArcgis
static const QgsSettingsEntryString * settingsAuthcfg
This class implements simple http header management.
QgsManageConnectionsDialog(QWidget *parent=nullptr, Mode mode=Export, Type type=WMS, const QString &fileName=QString())
Constructor for QgsManageConnectionsDialog.
@ TiledScene
Tiled scene connection (since QGIS 3.34)
static const QgsSettingsEntryBool * settingsPagingEnabled
static const QgsSettingsEntryString * settingsMaxNumFeatures
static QgsSettingsTreeNamedListNode * sTreeOwsConnections
static const QgsSettingsEntryBool * settingsIgnoreGetFeatureInfoURI
static const QgsSettingsEntryString * settingsPassword
static const QgsSettingsEntryEnumFlag< Qgis::DpiMode > * settingsDpiMode
static const QgsSettingsEntryBool * settingsIgnoreAxisOrientation
static const QgsSettingsEntryBool * settingsInvertAxisOrientation
static const QgsSettingsEntryString * settingsVersion
static const QgsSettingsEntryString * settingsPagesize
static const QgsSettingsEntryVariantMap * settingsHeaders
static const QgsSettingsEntryString * settingsUsername
static const QgsSettingsEntryBool * settingsSmoothPixmapTransform
static const QgsSettingsEntryString * settingsUrl
static const QgsSettingsEntryBool * settingsIgnoreGetMapURI
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
bool setValue(const T &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
QStringList items(const QStringList &parentsNamedItems=QStringList()) const
Returns the list of items.
This class is a composition of two QSettings instances:
Definition qgssettings.h:63
QStringList childGroups(Qgis::SettingsOrigin origin=Qgis::SettingsOrigin::Any) const
Returns a list of all key top-level groups that contain keys that can be read using the QSettings obj...
void endGroup()
Resets the group to what it was before the corresponding beginGroup() call.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void beginGroup(const QString &prefix, QgsSettings::Section section=QgsSettings::NoSection)
Appends prefix to the current group.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
static QgsSettingsTreeNamedListNode * sTreeXyzConnections
static const QgsSettingsEntryString * settingsPassword
static const QgsSettingsEntryDouble * settingsTilePixelRatio
static const QgsSettingsEntryString * settingsUsername
static const QgsSettingsEntryString * settingsAuthcfg
static const QgsSettingsEntryInteger * settingsZmin
static const QgsSettingsEntryInteger * settingsZmax
static const QgsSettingsEntryString * settingsUrl
static const QgsSettingsEntryVariantMap * settingsHeaders