35 , mFileName( fileName )
37 , mConnectionType( type )
42 QPushButton *pb =
nullptr;
43 pb =
new QPushButton( tr(
"Select All" ) );
44 buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
47 pb =
new QPushButton( tr(
"Clear Selection" ) );
48 buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
51 if ( mDialogMode ==
Import )
53 label->setText( tr(
"Select connections to import" ) );
54 buttonBox->button( QDialogButtonBox::Ok )->setText( tr(
"Import" ) );
55 buttonBox->button( QDialogButtonBox::Ok )->setEnabled(
false );
60 buttonBox->button( QDialogButtonBox::Ok )->setText( tr(
"Export" ) );
61 buttonBox->button( QDialogButtonBox::Ok )->setEnabled(
false );
64 if ( !populateConnections() )
66 QApplication::postEvent(
this,
new QCloseEvent() );
70 disconnect( buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
78 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( !listConnections->selectedItems().isEmpty() );
83 const QList<QListWidgetItem *> selection = listConnections->selectedItems();
84 if ( selection.isEmpty() )
86 QMessageBox::warning(
this, tr(
"Export/Import Error" ),
87 tr(
"You should select at least one connection from list." ) );
92 items.reserve( selection.size() );
93 for (
int i = 0; i < selection.size(); ++i )
95 items.append( selection.at( i )->text() );
98 if ( mDialogMode ==
Export )
100 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save Connections" ), QDir::homePath(),
101 tr(
"XML files (*.xml *.XML)" ) );
105 if ( fileName.isEmpty() )
111 if ( !fileName.endsWith( QLatin1String(
".xml" ), Qt::CaseInsensitive ) )
113 fileName += QLatin1String(
".xml" );
116 mFileName = fileName;
119 switch ( mConnectionType )
122 doc = saveOWSConnections( items, QStringLiteral(
"WMS" ) );
125 doc = saveWfsConnections( items );
128 doc = savePgConnections( items );
131 doc = saveMssqlConnections( items );
134 doc = saveOWSConnections( items, QStringLiteral(
"WCS" ) );
137 doc = saveOracleConnections( items );
140 doc = saveHanaConnections( items );
143 doc = saveXyzTilesConnections( items );
147 doc = saveArcgisConnections( items );
150 doc = saveVectorTileConnections( items );
153 doc = saveTiledSceneConnections( items );
156 doc = saveSensorThingsConnections( items );
160 QFile file( mFileName );
161 if ( !file.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate ) )
163 QMessageBox::warning(
this, tr(
"Saving Connections" ),
164 tr(
"Cannot write file %1:\n%2." )
166 file.errorString() ) );
170 QTextStream out( &file );
175 QFile file( mFileName );
176 if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
178 QMessageBox::warning(
this, tr(
"Loading Connections" ),
179 tr(
"Cannot read file %1:\n%2." )
181 file.errorString() ) );
190 if ( !doc.setContent( &file,
true, &errorStr, &errorLine, &errorColumn ) )
192 QMessageBox::warning(
this, tr(
"Loading Connections" ),
193 tr(
"Parse error at line %1, column %2:\n%3" )
200 switch ( mConnectionType )
203 loadOWSConnections( doc, items, QStringLiteral(
"WMS" ) );
206 loadWfsConnections( doc, items );
209 loadPgConnections( doc, items );
212 loadMssqlConnections( doc, items );
215 loadOWSConnections( doc, items, QStringLiteral(
"WCS" ) );
218 loadOracleConnections( doc, items );
221 loadHanaConnections( doc, items );
224 loadXyzTilesConnections( doc, items );
227 loadArcgisConnections( doc, items, QStringLiteral(
"ARCGISMAPSERVER" ) );
230 loadArcgisConnections( doc, items, QStringLiteral(
"ARCGISFEATURESERVER" ) );
233 loadVectorTileConnections( doc, items );
236 loadTiledSceneConnections( doc, items );
239 loadSensorThingsConnections( doc, items );
243 listConnections->clear();
250bool QgsManageConnectionsDialog::populateConnections()
253 if ( mDialogMode ==
Export )
255 QStringList connections;
257 switch ( mConnectionType )
269 settings.
beginGroup( QStringLiteral(
"/PostgreSQL/connections" ) );
273 settings.
beginGroup( QStringLiteral(
"/MSSQL/connections" ) );
277 settings.
beginGroup( QStringLiteral(
"/Oracle/connections" ) );
281 settings.
beginGroup( QStringLiteral(
"/HANA/connections" ) );
292 connections = QgsVectorTileProviderConnection::sTreeConnectionVectorTile->items();
295 connections = QgsTiledSceneProviderConnection::sTreeConnectionTiledScene->items();
298 connections = QgsSensorThingsProviderConnection::sTreeSensorThingsConnections->items();
301 for (
const QString &connection : std::as_const( connections ) )
303 QListWidgetItem *item =
new QListWidgetItem();
304 item->setText( connection );
305 listConnections->addItem( item );
311 QFile file( mFileName );
312 if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
314 QMessageBox::warning(
this, tr(
"Loading Connections" ),
315 tr(
"Cannot read file %1:\n%2." )
317 file.errorString() ) );
326 if ( !doc.setContent( &file,
true, &errorStr, &errorLine, &errorColumn ) )
328 QMessageBox::warning(
this, tr(
"Loading Connections" ),
329 tr(
"Parse error at line %1, column %2:\n%3" )
336 const QDomElement root = doc.documentElement();
337 switch ( mConnectionType )
340 if ( root.tagName() != QLatin1String(
"qgsWMSConnections" ) )
342 QMessageBox::information(
this, tr(
"Loading Connections" ),
343 tr(
"The file is not a WMS connections exchange file." ) );
349 if ( root.tagName() != QLatin1String(
"qgsWFSConnections" ) )
351 QMessageBox::information(
this, tr(
"Loading Connections" ),
352 tr(
"The file is not a WFS connections exchange file." ) );
358 if ( root.tagName() != QLatin1String(
"qgsWCSConnections" ) )
360 QMessageBox::information(
this, tr(
"Loading Connections" ),
361 tr(
"The file is not a WCS connections exchange file." ) );
367 if ( root.tagName() != QLatin1String(
"qgsPgConnections" ) )
369 QMessageBox::information(
this, tr(
"Loading Connections" ),
370 tr(
"The file is not a PostGIS connections exchange file." ) );
376 if ( root.tagName() != QLatin1String(
"qgsMssqlConnections" ) )
378 QMessageBox::information(
this, tr(
"Loading Connections" ),
379 tr(
"The file is not a MS SQL Server connections exchange file." ) );
384 if ( root.tagName() != QLatin1String(
"qgsOracleConnections" ) )
386 QMessageBox::information(
this, tr(
"Loading Connections" ),
387 tr(
"The file is not an Oracle connections exchange file." ) );
392 if ( root.tagName() != QLatin1String(
"qgsHanaConnections" ) )
394 QMessageBox::warning(
this, tr(
"Loading Connections" ),
395 tr(
"The file is not a HANA connections exchange file." ) );
400 if ( root.tagName() != QLatin1String(
"qgsXYZTilesConnections" ) )
402 QMessageBox::information(
this, tr(
"Loading Connections" ),
403 tr(
"The file is not a XYZ Tiles connections exchange file." ) );
408 if ( root.tagName() != QLatin1String(
"qgsARCGISMAPSERVERConnections" ) )
410 QMessageBox::information(
this, tr(
"Loading Connections" ),
411 tr(
"The file is not a ArcGIS Map Service connections exchange file." ) );
416 if ( root.tagName() != QLatin1String(
"qgsARCGISFEATURESERVERConnections" ) )
418 QMessageBox::information(
this, tr(
"Loading Connections" ),
419 tr(
"The file is not a ArcGIS Feature Service connections exchange file." ) );
424 if ( root.tagName() != QLatin1String(
"qgsVectorTileConnections" ) )
426 QMessageBox::information(
this, tr(
"Loading Connections" ),
427 tr(
"The file is not a Vector Tile connections exchange file." ) );
432 if ( root.tagName() != QLatin1String(
"qgsTiledSceneConnections" ) )
434 QMessageBox::information(
this, tr(
"Loading Connections" ),
435 tr(
"The file is not a tiled scene connections exchange file." ) );
440 if ( root.tagName() != QLatin1String(
"qgsSensorThingsConnections" ) )
442 QMessageBox::information(
this, tr(
"Loading Connections" ),
443 tr(
"The file is not a SensorThings connections exchange file." ) );
449 QDomElement child = root.firstChildElement();
450 while ( !child.isNull() )
452 QListWidgetItem *item =
new QListWidgetItem();
453 item->setText( child.attribute( QStringLiteral(
"name" ) ) );
454 listConnections->addItem( item );
455 child = child.nextSiblingElement();
461QDomDocument QgsManageConnectionsDialog::saveOWSConnections(
const QStringList &connections,
const QString &service )
463 QDomDocument doc( QStringLiteral(
"connections" ) );
464 QDomElement root = doc.createElement(
"qgs" + service.toUpper() +
"Connections" );
465 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
466 doc.appendChild( root );
468 for (
int i = 0; i < connections.count(); ++i )
470 QDomElement el = doc.createElement( service.toLower() );
471 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
474 if ( service == QLatin1String(
"WMS" ) )
484 httpHeader.updateDomElement( el );
489 root.appendChild( el );
495QDomDocument QgsManageConnectionsDialog::saveWfsConnections(
const QStringList &connections )
497 QDomDocument doc( QStringLiteral(
"connections" ) );
498 QDomElement root = doc.createElement( QStringLiteral(
"qgsWFSConnections" ) );
499 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.1" ) );
500 doc.appendChild( root );
502 for (
int i = 0; i < connections.count(); ++i )
504 QDomElement el = doc.createElement( QStringLiteral(
"wfs" ) );
505 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
516 root.appendChild( el );
522QDomDocument QgsManageConnectionsDialog::savePgConnections(
const QStringList &connections )
524 QDomDocument doc( QStringLiteral(
"connections" ) );
525 QDomElement root = doc.createElement( QStringLiteral(
"qgsPgConnections" ) );
526 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
527 doc.appendChild( root );
531 for (
int i = 0; i < connections.count(); ++i )
533 path =
"/PostgreSQL/connections/" + connections[ i ];
534 QDomElement el = doc.createElement( QStringLiteral(
"postgis" ) );
535 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
536 el.setAttribute( QStringLiteral(
"host" ), settings.
value( path +
"/host" ).toString() );
537 el.setAttribute( QStringLiteral(
"port" ), settings.
value( path +
"/port" ).toString() );
538 el.setAttribute( QStringLiteral(
"database" ), settings.
value( path +
"/database" ).toString() );
539 el.setAttribute( QStringLiteral(
"service" ), settings.
value( path +
"/service" ).toString() );
540 el.setAttribute( QStringLiteral(
"sslmode" ), settings.
value( path +
"/sslmode",
"1" ).toString() );
541 el.setAttribute( QStringLiteral(
"estimatedMetadata" ), settings.
value( path +
"/estimatedMetadata",
"0" ).toString() );
542 el.setAttribute( QStringLiteral(
"projectsInDatabase" ), settings.
value( path +
"/projectsInDatabase",
"0" ).toString() );
543 el.setAttribute( QStringLiteral(
"dontResolveType" ), settings.
value( path +
"/dontResolveType",
"0" ).toString() );
544 el.setAttribute( QStringLiteral(
"allowGeometrylessTables" ), settings.
value( path +
"/allowGeometrylessTables",
"0" ).toString() );
545 el.setAttribute( QStringLiteral(
"geometryColumnsOnly" ), settings.
value( path +
"/geometryColumnsOnly",
"0" ).toString() );
546 el.setAttribute( QStringLiteral(
"publicOnly" ), settings.
value( path +
"/publicOnly",
"0" ).toString() );
548 el.setAttribute( QStringLiteral(
"saveUsername" ), settings.
value( path +
"/saveUsername",
"false" ).toString() );
550 if ( settings.
value( path +
"/saveUsername",
"false" ).toString() == QLatin1String(
"true" ) )
552 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path +
"/username" ).toString() );
555 el.setAttribute( QStringLiteral(
"savePassword" ), settings.
value( path +
"/savePassword",
"false" ).toString() );
557 if ( settings.
value( path +
"/savePassword",
"false" ).toString() == QLatin1String(
"true" ) )
559 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path +
"/password" ).toString() );
562 root.appendChild( el );
568QDomDocument QgsManageConnectionsDialog::saveMssqlConnections(
const QStringList &connections )
570 QDomDocument doc( QStringLiteral(
"connections" ) );
571 QDomElement root = doc.createElement( QStringLiteral(
"qgsMssqlConnections" ) );
572 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
573 doc.appendChild( root );
577 for (
int i = 0; i < connections.count(); ++i )
579 path =
"/MSSQL/connections/" + connections[ i ];
580 QDomElement el = doc.createElement( QStringLiteral(
"mssql" ) );
581 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
582 el.setAttribute( QStringLiteral(
"host" ), settings.
value( path +
"/host" ).toString() );
583 el.setAttribute( QStringLiteral(
"port" ), settings.
value( path +
"/port" ).toString() );
584 el.setAttribute( QStringLiteral(
"database" ), settings.
value( path +
"/database" ).toString() );
585 el.setAttribute( QStringLiteral(
"service" ), settings.
value( path +
"/service" ).toString() );
586 el.setAttribute( QStringLiteral(
"sslmode" ), settings.
value( path +
"/sslmode",
"1" ).toString() );
587 el.setAttribute( QStringLiteral(
"estimatedMetadata" ), settings.
value( path +
"/estimatedMetadata",
"0" ).toString() );
589 el.setAttribute( QStringLiteral(
"saveUsername" ), settings.
value( path +
"/saveUsername",
"false" ).toString() );
591 if ( settings.
value( path +
"/saveUsername",
"false" ).toString() == QLatin1String(
"true" ) )
593 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path +
"/username" ).toString() );
596 el.setAttribute( QStringLiteral(
"savePassword" ), settings.
value( path +
"/savePassword",
"false" ).toString() );
598 if ( settings.
value( path +
"/savePassword",
"false" ).toString() == QLatin1String(
"true" ) )
600 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path +
"/password" ).toString() );
603 root.appendChild( el );
609QDomDocument QgsManageConnectionsDialog::saveOracleConnections(
const QStringList &connections )
611 QDomDocument doc( QStringLiteral(
"connections" ) );
612 QDomElement root = doc.createElement( QStringLiteral(
"qgsOracleConnections" ) );
613 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
614 doc.appendChild( root );
618 for (
int i = 0; i < connections.count(); ++i )
620 path =
"/Oracle/connections/" + connections[ i ];
621 QDomElement el = doc.createElement( QStringLiteral(
"oracle" ) );
622 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
623 el.setAttribute( QStringLiteral(
"host" ), settings.
value( path +
"/host" ).toString() );
624 el.setAttribute( QStringLiteral(
"port" ), settings.
value( path +
"/port" ).toString() );
625 el.setAttribute( QStringLiteral(
"database" ), settings.
value( path +
"/database" ).toString() );
626 el.setAttribute( QStringLiteral(
"dboptions" ), settings.
value( path +
"/dboptions" ).toString() );
627 el.setAttribute( QStringLiteral(
"dbworkspace" ), settings.
value( path +
"/dbworkspace" ).toString() );
628 el.setAttribute( QStringLiteral(
"schema" ), settings.
value( path +
"/schema" ).toString() );
629 el.setAttribute( QStringLiteral(
"estimatedMetadata" ), settings.
value( path +
"/estimatedMetadata",
"0" ).toString() );
630 el.setAttribute( QStringLiteral(
"userTablesOnly" ), settings.
value( path +
"/userTablesOnly",
"0" ).toString() );
631 el.setAttribute( QStringLiteral(
"geometryColumnsOnly" ), settings.
value( path +
"/geometryColumnsOnly",
"0" ).toString() );
632 el.setAttribute( QStringLiteral(
"allowGeometrylessTables" ), settings.
value( path +
"/allowGeometrylessTables",
"0" ).toString() );
634 el.setAttribute( QStringLiteral(
"saveUsername" ), settings.
value( path +
"/saveUsername",
"false" ).toString() );
636 if ( settings.
value( path +
"/saveUsername",
"false" ).toString() == QLatin1String(
"true" ) )
638 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path +
"/username" ).toString() );
641 el.setAttribute( QStringLiteral(
"savePassword" ), settings.
value( path +
"/savePassword",
"false" ).toString() );
643 if ( settings.
value( path +
"/savePassword",
"false" ).toString() == QLatin1String(
"true" ) )
645 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path +
"/password" ).toString() );
648 root.appendChild( el );
654QDomDocument QgsManageConnectionsDialog::saveHanaConnections(
const QStringList &connections )
656 QDomDocument doc( QStringLiteral(
"connections" ) );
657 QDomElement root = doc.createElement( QStringLiteral(
"qgsHanaConnections" ) );
658 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
659 doc.appendChild( root );
663 for (
int i = 0; i < connections.count(); ++i )
665 path =
"/HANA/connections/" + connections[i];
666 QDomElement el = doc.createElement( QStringLiteral(
"hana" ) );
667 el.setAttribute( QStringLiteral(
"name" ), connections[i] );
668 el.setAttribute( QStringLiteral(
"driver" ), settings.
value( path +
"/driver", QString() ).toString() );
669 el.setAttribute( QStringLiteral(
"host" ), settings.
value( path +
"/host", QString() ).toString() );
670 el.setAttribute( QStringLiteral(
"identifierType" ), settings.
value( path +
"/identifierType", QString() ).toString() );
671 el.setAttribute( QStringLiteral(
"identifier" ), settings.
value( path +
"/identifier", QString() ).toString() );
672 el.setAttribute( QStringLiteral(
"multitenant" ), settings.
value( path +
"/multitenant", QString() ).toString() );
673 el.setAttribute( QStringLiteral(
"database" ), settings.
value( path +
"/database", QString() ).toString() );
674 el.setAttribute( QStringLiteral(
"schema" ), settings.
value( path +
"/schema", QString() ).toString() );
675 el.setAttribute( QStringLiteral(
"userTablesOnly" ), settings.
value( path +
"/userTablesOnly", QStringLiteral(
"0" ) ).toString() );
676 el.setAttribute( QStringLiteral(
"allowGeometrylessTables" ), settings.
value( path +
"/allowGeometrylessTables", QStringLiteral(
"0" ) ).toString() );
678 el.setAttribute( QStringLiteral(
"saveUsername" ), settings.
value( path +
"/saveUsername", QStringLiteral(
"false" ) ).toString() );
679 if ( settings.
value( path +
"/saveUsername",
"false" ).toString() == QLatin1String(
"true" ) )
681 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path +
"/username", QString() ).toString() );
684 el.setAttribute( QStringLiteral(
"savePassword" ), settings.
value( path +
"/savePassword", QStringLiteral(
"false" ) ).toString() );
685 if ( settings.
value( path +
"/savePassword",
"false" ).toString() == QLatin1String(
"true" ) )
687 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path +
"/password", QString() ).toString() );
690 el.setAttribute( QStringLiteral(
"sslEnabled" ), settings.
value( path +
"/sslEnabled", QStringLiteral(
"false" ) ).toString() );
691 el.setAttribute( QStringLiteral(
"sslCryptoProvider" ), settings.
value( path +
"/sslCryptoProvider", QStringLiteral(
"openssl" ) ).toString() );
692 el.setAttribute( QStringLiteral(
"sslKeyStore" ), settings.
value( path +
"/sslKeyStore", QString() ).toString() );
693 el.setAttribute( QStringLiteral(
"sslTrustStore" ), settings.
value( path +
"/sslTrustStore", QString() ).toString() );
694 el.setAttribute( QStringLiteral(
"sslValidateCertificate" ), settings.
value( path +
"/sslValidateCertificate", QStringLiteral(
"false" ) ).toString() );
695 el.setAttribute( QStringLiteral(
"sslHostNameInCertificate" ), settings.
value( path +
"/sslHostNameInCertificate", QString() ).toString() );
697 root.appendChild( el );
703QDomDocument QgsManageConnectionsDialog::saveXyzTilesConnections(
const QStringList &connections )
705 QDomDocument doc( QStringLiteral(
"connections" ) );
706 QDomElement root = doc.createElement( QStringLiteral(
"qgsXYZTilesConnections" ) );
707 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
708 doc.appendChild( root );
710 for (
int i = 0; i < connections.count(); ++i )
713 QDomElement el = doc.createElement( QStringLiteral(
"xyztiles" ) );
715 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
725 httpHeader.updateDomElement( el );
727 root.appendChild( el );
733QDomDocument QgsManageConnectionsDialog::saveArcgisConnections(
const QStringList &connections )
735 QDomDocument doc( QStringLiteral(
"connections" ) );
736 QDomElement root = doc.createElement(
"qgsARCGISFEATURESERVERConnections" );
737 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
738 doc.appendChild( root );
740 for (
const QString &connection : connections )
742 QDomElement el = doc.createElement( QStringLiteral(
"arcgisfeatureserver" ) );
743 el.setAttribute( QStringLiteral(
"name" ), connection );
747 httpHeader.updateDomElement( el );
753 root.appendChild( el );
759QDomDocument QgsManageConnectionsDialog::saveVectorTileConnections(
const QStringList &connections )
761 QDomDocument doc( QStringLiteral(
"connections" ) );
762 QDomElement root = doc.createElement( QStringLiteral(
"qgsVectorTileConnections" ) );
763 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
764 doc.appendChild( root );
766 for (
int i = 0; i < connections.count(); ++i )
768 QDomElement el = doc.createElement( QStringLiteral(
"vectortile" ) );
770 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
771 el.setAttribute( QStringLiteral(
"url" ), QgsVectorTileProviderConnection::settingsUrl->value( connections[ i ] ) );
772 el.setAttribute( QStringLiteral(
"zmin" ), QgsVectorTileProviderConnection::settingsZmin->value( connections[ i ] ) );
773 el.setAttribute( QStringLiteral(
"zmax" ), QgsVectorTileProviderConnection::settingsZmax->value( connections[ i ] ) );
774 el.setAttribute( QStringLiteral(
"serviceType" ), QgsVectorTileProviderConnection::settingsServiceType->value( connections[ i ] ) );
775 el.setAttribute( QStringLiteral(
"authcfg" ), QgsVectorTileProviderConnection::settingsAuthcfg->value( connections[ i ] ) );
776 el.setAttribute( QStringLiteral(
"username" ), QgsVectorTileProviderConnection::settingsUsername->value( connections[ i ] ) );
777 el.setAttribute( QStringLiteral(
"password" ), QgsVectorTileProviderConnection::settingsPassword->value( connections[ i ] ) );
778 el.setAttribute( QStringLiteral(
"styleUrl" ), QgsVectorTileProviderConnection::settingsStyleUrl->value( connections[ i ] ) );
780 QgsHttpHeaders httpHeader( QgsVectorTileProviderConnection::settingsHeaders->value( connections[ i ] ) );
781 httpHeader.updateDomElement( el );
783 root.appendChild( el );
789QDomDocument QgsManageConnectionsDialog::saveTiledSceneConnections(
const QStringList &connections )
791 QDomDocument doc( QStringLiteral(
"connections" ) );
792 QDomElement root = doc.createElement( QStringLiteral(
"qgsTiledSceneConnections" ) );
793 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
794 doc.appendChild( root );
796 for (
int i = 0; i < connections.count(); ++i )
798 QDomElement el = doc.createElement( QStringLiteral(
"tiledscene" ) );
800 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
801 el.setAttribute( QStringLiteral(
"provider" ), QgsTiledSceneProviderConnection::settingsProvider->value( connections[ i ] ) );
802 el.setAttribute( QStringLiteral(
"url" ), QgsTiledSceneProviderConnection::settingsUrl->value( connections[ i ] ) );
803 el.setAttribute( QStringLiteral(
"authcfg" ), QgsTiledSceneProviderConnection::settingsAuthcfg->value( connections[ i ] ) );
804 el.setAttribute( QStringLiteral(
"username" ), QgsTiledSceneProviderConnection::settingsUsername->value( connections[ i ] ) );
805 el.setAttribute( QStringLiteral(
"password" ), QgsTiledSceneProviderConnection::settingsPassword->value( connections[ i ] ) );
807 QgsHttpHeaders httpHeader( QgsTiledSceneProviderConnection::settingsHeaders->value( connections[ i ] ) );
808 httpHeader.updateDomElement( el );
810 root.appendChild( el );
816QDomDocument QgsManageConnectionsDialog::saveSensorThingsConnections(
const QStringList &connections )
818 QDomDocument doc( QStringLiteral(
"connections" ) );
819 QDomElement root = doc.createElement( QStringLiteral(
"qgsSensorThingsConnections" ) );
820 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
821 doc.appendChild( root );
823 for (
int i = 0; i < connections.count(); ++i )
825 QDomElement el = doc.createElement( QStringLiteral(
"sensorthings" ) );
827 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
828 el.setAttribute( QStringLiteral(
"url" ), QgsSensorThingsProviderConnection::settingsUrl->value( connections[ i ] ) );
829 el.setAttribute( QStringLiteral(
"authcfg" ), QgsSensorThingsProviderConnection::settingsAuthcfg->value( connections[ i ] ) );
830 el.setAttribute( QStringLiteral(
"username" ), QgsSensorThingsProviderConnection::settingsUsername->value( connections[ i ] ) );
831 el.setAttribute( QStringLiteral(
"password" ), QgsSensorThingsProviderConnection::settingsPassword->value( connections[ i ] ) );
833 QgsHttpHeaders httpHeader( QgsTiledSceneProviderConnection::settingsHeaders->value( connections[ i ] ) );
834 httpHeader.updateDomElement( el );
836 root.appendChild( el );
842void QgsManageConnectionsDialog::loadOWSConnections(
const QDomDocument &doc,
const QStringList &items,
const QString &service )
844 const QDomElement root = doc.documentElement();
845 if ( root.tagName() !=
"qgs" + service.toUpper() +
"Connections" )
847 QMessageBox::information(
this, tr(
"Loading Connections" ),
848 tr(
"The file is not a %1 connections exchange file." ).arg( service ) );
852 QString connectionName;
854 QDomElement child = root.firstChildElement();
856 bool overwrite =
true;
858 while ( !child.isNull() )
860 connectionName = child.attribute( QStringLiteral(
"name" ) );
861 if ( !items.contains( connectionName ) )
863 child = child.nextSiblingElement();
870 const int res = QMessageBox::warning(
this,
871 tr(
"Loading Connections" ),
872 tr(
"Connection with name '%1' already exists. Overwrite?" )
873 .arg( connectionName ),
874 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
878 case QMessageBox::Cancel:
880 case QMessageBox::No:
881 child = child.nextSiblingElement();
883 case QMessageBox::Yes:
886 case QMessageBox::YesToAll:
890 case QMessageBox::NoToAll:
899 child = child.nextSiblingElement();
915 if ( !child.attribute( QStringLiteral(
"username" ) ).isEmpty() )
920 child = child.nextSiblingElement();
924void QgsManageConnectionsDialog::loadWfsConnections(
const QDomDocument &doc,
const QStringList &items )
926 const QDomElement root = doc.documentElement();
927 if ( root.tagName() != QLatin1String(
"qgsWFSConnections" ) )
929 QMessageBox::information(
this, tr(
"Loading Connections" ),
930 tr(
"The file is not a WFS connections exchange file." ) );
934 QString connectionName;
937 QDomElement child = root.firstChildElement();
939 bool overwrite =
true;
941 while ( !child.isNull() )
943 connectionName = child.attribute( QStringLiteral(
"name" ) );
944 if ( !items.contains( connectionName ) )
946 child = child.nextSiblingElement();
951 if ( keys.contains( connectionName ) && prompt )
953 const int res = QMessageBox::warning(
this,
954 tr(
"Loading Connections" ),
955 tr(
"Connection with name '%1' already exists. Overwrite?" )
956 .arg( connectionName ),
957 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
961 case QMessageBox::Cancel:
963 case QMessageBox::No:
964 child = child.nextSiblingElement();
966 case QMessageBox::Yes:
969 case QMessageBox::YesToAll:
973 case QMessageBox::NoToAll:
980 if ( keys.contains( connectionName ) )
984 child = child.nextSiblingElement();
990 keys << connectionName;
1003 if ( !child.attribute( QStringLiteral(
"username" ) ).isEmpty() )
1008 child = child.nextSiblingElement();
1012void QgsManageConnectionsDialog::loadPgConnections(
const QDomDocument &doc,
const QStringList &items )
1014 const QDomElement root = doc.documentElement();
1015 if ( root.tagName() != QLatin1String(
"qgsPgConnections" ) )
1017 QMessageBox::information(
this,
1018 tr(
"Loading Connections" ),
1019 tr(
"The file is not a PostGIS connections exchange file." ) );
1023 QString connectionName;
1025 settings.
beginGroup( QStringLiteral(
"/PostgreSQL/connections" ) );
1028 QDomElement child = root.firstChildElement();
1030 bool overwrite =
true;
1032 while ( !child.isNull() )
1034 connectionName = child.attribute( QStringLiteral(
"name" ) );
1035 if ( !items.contains( connectionName ) )
1037 child = child.nextSiblingElement();
1042 if ( keys.contains( connectionName ) && prompt )
1044 const int res = QMessageBox::warning(
this,
1045 tr(
"Loading Connections" ),
1046 tr(
"Connection with name '%1' already exists. Overwrite?" )
1047 .arg( connectionName ),
1048 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1051 case QMessageBox::Cancel:
1053 case QMessageBox::No:
1054 child = child.nextSiblingElement();
1056 case QMessageBox::Yes:
1059 case QMessageBox::YesToAll:
1063 case QMessageBox::NoToAll:
1070 if ( keys.contains( connectionName ) )
1074 child = child.nextSiblingElement();
1080 keys << connectionName;
1084 settings.
beginGroup(
"/PostgreSQL/connections/" + connectionName );
1086 settings.
setValue( QStringLiteral(
"/host" ), child.attribute( QStringLiteral(
"host" ) ) );
1087 settings.
setValue( QStringLiteral(
"/port" ), child.attribute( QStringLiteral(
"port" ) ) );
1088 settings.
setValue( QStringLiteral(
"/database" ), child.attribute( QStringLiteral(
"database" ) ) );
1089 if ( child.hasAttribute( QStringLiteral(
"service" ) ) )
1091 settings.
setValue( QStringLiteral(
"/service" ), child.attribute( QStringLiteral(
"service" ) ) );
1095 settings.
setValue( QStringLiteral(
"/service" ),
"" );
1097 settings.
setValue( QStringLiteral(
"/sslmode" ), child.attribute( QStringLiteral(
"sslmode" ) ) );
1098 settings.
setValue( QStringLiteral(
"/estimatedMetadata" ), child.attribute( QStringLiteral(
"estimatedMetadata" ) ) );
1099 settings.
setValue( QStringLiteral(
"/projectsInDatabase" ), child.attribute( QStringLiteral(
"projectsInDatabase" ), 0 ) );
1100 settings.
setValue( QStringLiteral(
"/dontResolveType" ), child.attribute( QStringLiteral(
"dontResolveType" ), 0 ) );
1101 settings.
setValue( QStringLiteral(
"/allowGeometrylessTables" ), child.attribute( QStringLiteral(
"allowGeometrylessTables" ), 0 ) );
1102 settings.
setValue( QStringLiteral(
"/geometryColumnsOnly" ), child.attribute( QStringLiteral(
"geometryColumnsOnly" ), 0 ) );
1103 settings.
setValue( QStringLiteral(
"/publicOnly" ), child.attribute( QStringLiteral(
"publicOnly" ), 0 ) );
1104 settings.
setValue( QStringLiteral(
"/saveUsername" ), child.attribute( QStringLiteral(
"saveUsername" ) ) );
1105 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
1106 settings.
setValue( QStringLiteral(
"/savePassword" ), child.attribute( QStringLiteral(
"savePassword" ) ) );
1107 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
1110 child = child.nextSiblingElement();
1114void QgsManageConnectionsDialog::loadMssqlConnections(
const QDomDocument &doc,
const QStringList &items )
1116 const QDomElement root = doc.documentElement();
1117 if ( root.tagName() != QLatin1String(
"qgsMssqlConnections" ) )
1119 QMessageBox::information(
this,
1120 tr(
"Loading Connections" ),
1121 tr(
"The file is not a MS SQL Server connections exchange file." ) );
1125 QString connectionName;
1127 settings.
beginGroup( QStringLiteral(
"/MSSQL/connections" ) );
1130 QDomElement child = root.firstChildElement();
1132 bool overwrite =
true;
1134 while ( !child.isNull() )
1136 connectionName = child.attribute( QStringLiteral(
"name" ) );
1137 if ( !items.contains( connectionName ) )
1139 child = child.nextSiblingElement();
1144 if ( keys.contains( connectionName ) && prompt )
1146 const int res = QMessageBox::warning(
this,
1147 tr(
"Loading Connections" ),
1148 tr(
"Connection with name '%1' already exists. Overwrite?" )
1149 .arg( connectionName ),
1150 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1153 case QMessageBox::Cancel:
1155 case QMessageBox::No:
1156 child = child.nextSiblingElement();
1158 case QMessageBox::Yes:
1161 case QMessageBox::YesToAll:
1165 case QMessageBox::NoToAll:
1172 if ( keys.contains( connectionName ) )
1176 child = child.nextSiblingElement();
1182 keys << connectionName;
1186 settings.
beginGroup(
"/MSSQL/connections/" + connectionName );
1188 settings.
setValue( QStringLiteral(
"/host" ), child.attribute( QStringLiteral(
"host" ) ) );
1189 settings.
setValue( QStringLiteral(
"/port" ), child.attribute( QStringLiteral(
"port" ) ) );
1190 settings.
setValue( QStringLiteral(
"/database" ), child.attribute( QStringLiteral(
"database" ) ) );
1191 if ( child.hasAttribute( QStringLiteral(
"service" ) ) )
1193 settings.
setValue( QStringLiteral(
"/service" ), child.attribute( QStringLiteral(
"service" ) ) );
1197 settings.
setValue( QStringLiteral(
"/service" ),
"" );
1199 settings.
setValue( QStringLiteral(
"/sslmode" ), child.attribute( QStringLiteral(
"sslmode" ) ) );
1200 settings.
setValue( QStringLiteral(
"/estimatedMetadata" ), child.attribute( QStringLiteral(
"estimatedMetadata" ) ) );
1201 settings.
setValue( QStringLiteral(
"/saveUsername" ), child.attribute( QStringLiteral(
"saveUsername" ) ) );
1202 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
1203 settings.
setValue( QStringLiteral(
"/savePassword" ), child.attribute( QStringLiteral(
"savePassword" ) ) );
1204 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
1207 child = child.nextSiblingElement();
1211void QgsManageConnectionsDialog::loadOracleConnections(
const QDomDocument &doc,
const QStringList &items )
1213 const QDomElement root = doc.documentElement();
1214 if ( root.tagName() != QLatin1String(
"qgsOracleConnections" ) )
1216 QMessageBox::information(
this,
1217 tr(
"Loading Connections" ),
1218 tr(
"The file is not an Oracle connections exchange file." ) );
1222 QString connectionName;
1224 settings.
beginGroup( QStringLiteral(
"/Oracle/connections" ) );
1227 QDomElement child = root.firstChildElement();
1229 bool overwrite =
true;
1231 while ( !child.isNull() )
1233 connectionName = child.attribute( QStringLiteral(
"name" ) );
1234 if ( !items.contains( connectionName ) )
1236 child = child.nextSiblingElement();
1241 if ( keys.contains( connectionName ) && prompt )
1243 const int res = QMessageBox::warning(
this,
1244 tr(
"Loading Connections" ),
1245 tr(
"Connection with name '%1' already exists. Overwrite?" )
1246 .arg( connectionName ),
1247 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1250 case QMessageBox::Cancel:
1252 case QMessageBox::No:
1253 child = child.nextSiblingElement();
1255 case QMessageBox::Yes:
1258 case QMessageBox::YesToAll:
1262 case QMessageBox::NoToAll:
1269 if ( keys.contains( connectionName ) )
1273 child = child.nextSiblingElement();
1279 keys << connectionName;
1283 settings.
beginGroup(
"/Oracle/connections/" + connectionName );
1285 settings.
setValue( QStringLiteral(
"/host" ), child.attribute( QStringLiteral(
"host" ) ) );
1286 settings.
setValue( QStringLiteral(
"/port" ), child.attribute( QStringLiteral(
"port" ) ) );
1287 settings.
setValue( QStringLiteral(
"/database" ), child.attribute( QStringLiteral(
"database" ) ) );
1288 settings.
setValue( QStringLiteral(
"/dboptions" ), child.attribute( QStringLiteral(
"dboptions" ) ) );
1289 settings.
setValue( QStringLiteral(
"/dbworkspace" ), child.attribute( QStringLiteral(
"dbworkspace" ) ) );
1290 settings.
setValue( QStringLiteral(
"/schema" ), child.attribute( QStringLiteral(
"schema" ) ) );
1291 settings.
setValue( QStringLiteral(
"/estimatedMetadata" ), child.attribute( QStringLiteral(
"estimatedMetadata" ) ) );
1292 settings.
setValue( QStringLiteral(
"/userTablesOnly" ), child.attribute( QStringLiteral(
"userTablesOnly" ) ) );
1293 settings.
setValue( QStringLiteral(
"/geometryColumnsOnly" ), child.attribute( QStringLiteral(
"geometryColumnsOnly" ) ) );
1294 settings.
setValue( QStringLiteral(
"/allowGeometrylessTables" ), child.attribute( QStringLiteral(
"allowGeometrylessTables" ) ) );
1295 settings.
setValue( QStringLiteral(
"/saveUsername" ), child.attribute( QStringLiteral(
"saveUsername" ) ) );
1296 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
1297 settings.
setValue( QStringLiteral(
"/savePassword" ), child.attribute( QStringLiteral(
"savePassword" ) ) );
1298 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
1301 child = child.nextSiblingElement();
1305void QgsManageConnectionsDialog::loadHanaConnections(
const QDomDocument &doc,
const QStringList &items )
1307 QDomElement root = doc.documentElement();
1308 if ( root.tagName() != QLatin1String(
"qgsHanaConnections" ) )
1310 QMessageBox::warning(
this,
1311 tr(
"Loading Connections" ),
1312 tr(
"The file is not a HANA connections exchange file." ) );
1316 const QDomAttr version = root.attributeNode(
"version" );
1317 if ( version.value() != QLatin1String(
"1.0" ) )
1319 QMessageBox::warning(
this,
1320 tr(
"Loading Connections" ),
1321 tr(
"The HANA connections exchange file version '%1' is not supported." ).arg( version.value() ) );
1326 settings.
beginGroup( QStringLiteral(
"/HANA/connections" ) );
1329 QDomElement child = root.firstChildElement();
1331 bool overwrite =
true;
1333 while ( !child.isNull() )
1335 const QString connectionName = child.attribute( QStringLiteral(
"name" ) );
1336 if ( !items.contains( connectionName ) )
1338 child = child.nextSiblingElement();
1343 if ( keys.contains( connectionName ) && prompt )
1345 const int res = QMessageBox::warning(
this,
1346 tr(
"Loading Connections" ),
1347 tr(
"Connection with name '%1' already exists. Overwrite?" )
1348 .arg( connectionName ),
1349 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1352 case QMessageBox::Cancel:
1354 case QMessageBox::No:
1355 child = child.nextSiblingElement();
1357 case QMessageBox::Yes:
1360 case QMessageBox::YesToAll:
1364 case QMessageBox::NoToAll:
1371 if ( keys.contains( connectionName ) )
1375 child = child.nextSiblingElement();
1381 keys << connectionName;
1385 settings.
beginGroup(
"/HANA/connections/" + connectionName );
1387 for (
const QString param :
1388 {
"driver",
"host",
"database",
"identifierType",
"identifier",
"multitenant",
"schema",
"userTablesOnly",
1389 "allowGeometrylessTables",
"saveUsername",
"username",
"savePassword",
"password",
"sslEnabled",
1390 "sslCryptoProvider",
"sslKeyStore",
"sslTrustStore",
"sslValidateCertificate",
"sslHostNameInCertificate"
1392 settings.
setValue( QStringLiteral(
"/" ) + param, child.attribute( param ) );
1396 child = child.nextSiblingElement();
1400void QgsManageConnectionsDialog::loadXyzTilesConnections(
const QDomDocument &doc,
const QStringList &items )
1402 const QDomElement root = doc.documentElement();
1403 if ( root.tagName() != QLatin1String(
"qgsXYZTilesConnections" ) )
1405 QMessageBox::information(
this, tr(
"Loading Connections" ),
1406 tr(
"The file is not a XYZ Tiles connections exchange file." ) );
1410 QString connectionName;
1412 QDomElement child = root.firstChildElement();
1414 bool overwrite =
true;
1416 while ( !child.isNull() )
1418 connectionName = child.attribute( QStringLiteral(
"name" ) );
1419 if ( !items.contains( connectionName ) )
1421 child = child.nextSiblingElement();
1426 if ( keys.contains( connectionName ) && prompt )
1428 const int res = QMessageBox::warning(
this,
1429 tr(
"Loading Connections" ),
1430 tr(
"Connection with name '%1' already exists. Overwrite?" )
1431 .arg( connectionName ),
1432 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1436 case QMessageBox::Cancel:
1438 case QMessageBox::No:
1439 child = child.nextSiblingElement();
1441 case QMessageBox::Yes:
1444 case QMessageBox::YesToAll:
1448 case QMessageBox::NoToAll:
1455 if ( keys.contains( connectionName ) )
1459 child = child.nextSiblingElement();
1465 keys << connectionName;
1480 child = child.nextSiblingElement();
1484void QgsManageConnectionsDialog::loadArcgisConnections(
const QDomDocument &doc,
const QStringList &items,
const QString &service )
1486 const QDomElement root = doc.documentElement();
1487 if ( root.tagName() !=
"qgs" + service.toUpper() +
"Connections" )
1489 QMessageBox::information(
this, tr(
"Loading Connections" ),
1490 tr(
"The file is not a %1 connections exchange file." ).arg( service ) );
1494 QString connectionName;
1496 QDomElement child = root.firstChildElement();
1498 bool overwrite =
true;
1500 while ( !child.isNull() )
1502 connectionName = child.attribute( QStringLiteral(
"name" ) );
1503 if ( !items.contains( connectionName ) )
1505 child = child.nextSiblingElement();
1510 if ( keys.contains( connectionName ) && prompt )
1512 const int res = QMessageBox::warning(
this,
1513 tr(
"Loading Connections" ),
1514 tr(
"Connection with name '%1' already exists. Overwrite?" )
1515 .arg( connectionName ),
1516 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1520 case QMessageBox::Cancel:
1522 case QMessageBox::No:
1523 child = child.nextSiblingElement();
1525 case QMessageBox::Yes:
1528 case QMessageBox::YesToAll:
1532 case QMessageBox::NoToAll:
1539 if ( keys.contains( connectionName ) )
1543 child = child.nextSiblingElement();
1549 keys << connectionName;
1562 child = child.nextSiblingElement();
1566void QgsManageConnectionsDialog::loadVectorTileConnections(
const QDomDocument &doc,
const QStringList &items )
1568 const QDomElement root = doc.documentElement();
1569 if ( root.tagName() != QLatin1String(
"qgsVectorTileConnections" ) )
1571 QMessageBox::information(
this, tr(
"Loading Connections" ),
1572 tr(
"The file is not a Vector Tile connections exchange file." ) );
1576 QString connectionName;
1578 settings.
beginGroup( QStringLiteral(
"/qgis/connections-vector-tile" ) );
1581 QDomElement child = root.firstChildElement();
1583 bool overwrite =
true;
1585 while ( !child.isNull() )
1587 connectionName = child.attribute( QStringLiteral(
"name" ) );
1588 if ( !items.contains( connectionName ) )
1590 child = child.nextSiblingElement();
1595 if ( keys.contains( connectionName ) && prompt )
1597 const int res = QMessageBox::warning(
this,
1598 tr(
"Loading Connections" ),
1599 tr(
"Connection with name '%1' already exists. Overwrite?" )
1600 .arg( connectionName ),
1601 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1605 case QMessageBox::Cancel:
1607 case QMessageBox::No:
1608 child = child.nextSiblingElement();
1610 case QMessageBox::Yes:
1613 case QMessageBox::YesToAll:
1617 case QMessageBox::NoToAll:
1624 if ( keys.contains( connectionName ) )
1628 child = child.nextSiblingElement();
1634 keys << connectionName;
1637 QgsVectorTileProviderConnection::settingsUrl->setValue( child.attribute( QStringLiteral(
"url" ) ), connectionName );
1638 QgsVectorTileProviderConnection::settingsZmin->setValue( child.attribute( QStringLiteral(
"zmin" ) ).toInt(), connectionName );
1639 QgsVectorTileProviderConnection::settingsZmax->setValue( child.attribute( QStringLiteral(
"zmax" ) ).toInt(), connectionName );
1640 QgsVectorTileProviderConnection::settingsServiceType->setValue( child.attribute( QStringLiteral(
"serviceType" ) ), connectionName );
1641 QgsVectorTileProviderConnection::settingsAuthcfg->setValue( child.attribute( QStringLiteral(
"authcfg" ) ), connectionName );
1642 QgsVectorTileProviderConnection::settingsUsername->setValue( child.attribute( QStringLiteral(
"username" ) ), connectionName );
1643 QgsVectorTileProviderConnection::settingsPassword->setValue( child.attribute( QStringLiteral(
"password" ) ), connectionName );
1644 QgsVectorTileProviderConnection::settingsStyleUrl->setValue( child.attribute( QStringLiteral(
"styleUrl" ) ), connectionName );
1647 QgsVectorTileProviderConnection::settingsHeaders->setValue( httpHeader.headers(), connectionName );
1649 child = child.nextSiblingElement();
1653void QgsManageConnectionsDialog::loadTiledSceneConnections(
const QDomDocument &doc,
const QStringList &items )
1655 const QDomElement root = doc.documentElement();
1656 if ( root.tagName() != QLatin1String(
"qgsTiledSceneConnections" ) )
1658 QMessageBox::information(
this, tr(
"Loading Connections" ),
1659 tr(
"The file is not a tiled scene connections exchange file." ) );
1663 QString connectionName;
1665 settings.
beginGroup( QStringLiteral(
"/qgis/connections-tiled-scene" ) );
1668 QDomElement child = root.firstChildElement();
1670 bool overwrite =
true;
1672 while ( !child.isNull() )
1674 connectionName = child.attribute( QStringLiteral(
"name" ) );
1675 if ( !items.contains( connectionName ) )
1677 child = child.nextSiblingElement();
1682 if ( keys.contains( connectionName ) && prompt )
1684 const int res = QMessageBox::warning(
this,
1685 tr(
"Loading Connections" ),
1686 tr(
"Connection with name '%1' already exists. Overwrite?" )
1687 .arg( connectionName ),
1688 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1692 case QMessageBox::Cancel:
1694 case QMessageBox::No:
1695 child = child.nextSiblingElement();
1697 case QMessageBox::Yes:
1700 case QMessageBox::YesToAll:
1704 case QMessageBox::NoToAll:
1711 if ( keys.contains( connectionName ) )
1715 child = child.nextSiblingElement();
1721 keys << connectionName;
1724 QgsTiledSceneProviderConnection::settingsProvider->setValue( child.attribute( QStringLiteral(
"provider" ) ), connectionName );
1725 QgsTiledSceneProviderConnection::settingsUrl->setValue( child.attribute( QStringLiteral(
"url" ) ), connectionName );
1726 QgsTiledSceneProviderConnection::settingsAuthcfg->setValue( child.attribute( QStringLiteral(
"authcfg" ) ), connectionName );
1727 QgsTiledSceneProviderConnection::settingsUsername->setValue( child.attribute( QStringLiteral(
"username" ) ), connectionName );
1728 QgsTiledSceneProviderConnection::settingsPassword->setValue( child.attribute( QStringLiteral(
"password" ) ), connectionName );
1731 QgsTiledSceneProviderConnection::settingsHeaders->setValue( httpHeader.headers(), connectionName );
1733 child = child.nextSiblingElement();
1737void QgsManageConnectionsDialog::loadSensorThingsConnections(
const QDomDocument &doc,
const QStringList &items )
1739 const QDomElement root = doc.documentElement();
1740 if ( root.tagName() != QLatin1String(
"qgsSensorThingsConnections" ) )
1742 QMessageBox::information(
this, tr(
"Loading Connections" ),
1743 tr(
"The file is not a SensorThings connections exchange file." ) );
1747 QString connectionName;
1749 settings.
beginGroup( QStringLiteral(
"/connections/sensorthings/items" ) );
1752 QDomElement child = root.firstChildElement();
1754 bool overwrite =
true;
1756 while ( !child.isNull() )
1758 connectionName = child.attribute( QStringLiteral(
"name" ) );
1759 if ( !items.contains( connectionName ) )
1761 child = child.nextSiblingElement();
1766 if ( keys.contains( connectionName ) && prompt )
1768 const int res = QMessageBox::warning(
this,
1769 tr(
"Loading Connections" ),
1770 tr(
"Connection with name '%1' already exists. Overwrite?" )
1771 .arg( connectionName ),
1772 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1776 case QMessageBox::Cancel:
1778 case QMessageBox::No:
1779 child = child.nextSiblingElement();
1781 case QMessageBox::Yes:
1784 case QMessageBox::YesToAll:
1788 case QMessageBox::NoToAll:
1795 if ( keys.contains( connectionName ) )
1799 child = child.nextSiblingElement();
1805 keys << connectionName;
1808 QgsSensorThingsProviderConnection::settingsUrl->setValue( child.attribute( QStringLiteral(
"url" ) ), connectionName );
1809 QgsSensorThingsProviderConnection::settingsAuthcfg->setValue( child.attribute( QStringLiteral(
"authcfg" ) ), connectionName );
1810 QgsSensorThingsProviderConnection::settingsUsername->setValue( child.attribute( QStringLiteral(
"username" ) ), connectionName );
1811 QgsSensorThingsProviderConnection::settingsPassword->setValue( child.attribute( QStringLiteral(
"password" ) ), connectionName );
1814 QgsSensorThingsProviderConnection::settingsHeaders->setValue( httpHeader.headers(), connectionName );
1816 child = child.nextSiblingElement();
1822 listConnections->selectAll();
1823 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( !listConnections->selectedItems().isEmpty() );
1828 listConnections->clearSelection();
1829 buttonBox->button( QDialogButtonBox::Ok )->setEnabled(
false );
static const QgsSettingsEntryString * settingsUsername
static const QgsSettingsEntryString * settingsUrl
static const QgsSettingsEntryString * settingsPassword
static const QgsSettingsEntryVariantMap * settingsHeaders
static QgsSettingsTreeNamedListNode * sTreeConnectionArcgis
static const QgsSettingsEntryString * settingsAuthcfg
QgsManageConnectionsDialog(QWidget *parent=nullptr, Mode mode=Export, Type type=WMS, const QString &fileName=QString())
Constructor for QgsManageConnectionsDialog.
@ SensorThings
SensorThings connections (since QGIS 3.36)
@ TiledScene
Tiled scene connection (since QGIS 3.34)
static const QgsSettingsEntryString * 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:
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