17 #include <QCloseEvent>
18 #include <QFileDialog>
19 #include <QMessageBox>
20 #include <QPushButton>
21 #include <QTextStream>
29 , mFileName( fileName )
31 , mConnectionType( type )
36 QPushButton *pb =
nullptr;
37 pb =
new QPushButton( tr(
"Select all" ) );
38 buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
41 pb =
new QPushButton( tr(
"Clear selection" ) );
42 buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
45 if ( mDialogMode ==
Import )
47 label->setText( tr(
"Select connections to import" ) );
48 buttonBox->button( QDialogButtonBox::Ok )->setText( tr(
"Import" ) );
49 buttonBox->button( QDialogButtonBox::Ok )->setEnabled(
false );
54 buttonBox->button( QDialogButtonBox::Ok )->setText( tr(
"Export" ) );
55 buttonBox->button( QDialogButtonBox::Ok )->setEnabled(
false );
58 if ( !populateConnections() )
60 QApplication::postEvent(
this,
new QCloseEvent() );
64 disconnect( buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
72 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( !listConnections->selectedItems().isEmpty() );
77 const QList<QListWidgetItem *> selection = listConnections->selectedItems();
78 if ( selection.isEmpty() )
80 QMessageBox::warning(
this, tr(
"Export/Import Error" ),
81 tr(
"You should select at least one connection from list." ) );
86 items.reserve( selection.size() );
87 for (
int i = 0; i < selection.size(); ++i )
89 items.append( selection.at( i )->text() );
92 if ( mDialogMode ==
Export )
94 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save Connections" ), QDir::homePath(),
95 tr(
"XML files (*.xml *.XML)" ) );
96 if ( fileName.isEmpty() )
102 if ( !fileName.endsWith( QLatin1String(
".xml" ), Qt::CaseInsensitive ) )
104 fileName += QLatin1String(
".xml" );
107 mFileName = fileName;
110 switch ( mConnectionType )
113 doc = saveOWSConnections( items, QStringLiteral(
"WMS" ) );
116 doc = saveWfsConnections( items );
119 doc = savePgConnections( items );
122 doc = saveMssqlConnections( items );
125 doc = saveOWSConnections( items, QStringLiteral(
"WCS" ) );
128 doc = saveOracleConnections( items );
131 doc = saveHanaConnections( items );
134 doc = saveGeonodeConnections( items );
137 doc = saveXyzTilesConnections( items );
140 doc = saveArcgisConnections( items, QStringLiteral(
"ARCGISMAPSERVER" ) );
143 doc = saveArcgisConnections( items, QStringLiteral(
"ARCGISFEATURESERVER" ) );
146 doc = saveVectorTileConnections( items );
150 QFile file( mFileName );
151 if ( !file.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate ) )
153 QMessageBox::warning(
this, tr(
"Saving Connections" ),
154 tr(
"Cannot write file %1:\n%2." )
156 file.errorString() ) );
160 QTextStream out( &file );
165 QFile file( mFileName );
166 if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
168 QMessageBox::warning(
this, tr(
"Loading Connections" ),
169 tr(
"Cannot read file %1:\n%2." )
171 file.errorString() ) );
180 if ( !doc.setContent( &file,
true, &errorStr, &errorLine, &errorColumn ) )
182 QMessageBox::warning(
this, tr(
"Loading Connections" ),
183 tr(
"Parse error at line %1, column %2:\n%3" )
190 switch ( mConnectionType )
193 loadOWSConnections( doc, items, QStringLiteral(
"WMS" ) );
196 loadWfsConnections( doc, items );
199 loadPgConnections( doc, items );
202 loadMssqlConnections( doc, items );
205 loadOWSConnections( doc, items, QStringLiteral(
"WCS" ) );
208 loadOracleConnections( doc, items );
211 loadHanaConnections( doc, items );
214 loadGeonodeConnections( doc, items );
217 loadXyzTilesConnections( doc, items );
220 loadArcgisConnections( doc, items, QStringLiteral(
"ARCGISMAPSERVER" ) );
223 loadArcgisConnections( doc, items, QStringLiteral(
"ARCGISFEATURESERVER" ) );
226 loadVectorTileConnections( doc, items );
230 listConnections->clear();
237 bool QgsManageConnectionsDialog::populateConnections()
240 if ( mDialogMode ==
Export )
243 switch ( mConnectionType )
246 settings.
beginGroup( QStringLiteral(
"/qgis/connections-wms" ) );
249 settings.
beginGroup( QStringLiteral(
"/qgis/connections-wfs" ) );
252 settings.
beginGroup( QStringLiteral(
"/qgis/connections-wcs" ) );
255 settings.
beginGroup( QStringLiteral(
"/PostgreSQL/connections" ) );
258 settings.
beginGroup( QStringLiteral(
"/MSSQL/connections" ) );
261 settings.
beginGroup( QStringLiteral(
"/Oracle/connections" ) );
264 settings.
beginGroup( QStringLiteral(
"/HANA/connections" ) );
267 settings.
beginGroup( QStringLiteral(
"/qgis/connections-geonode" ) );
270 settings.
beginGroup( QStringLiteral(
"/qgis/connections-xyz" ) );
273 settings.
beginGroup( QStringLiteral(
"/qgis/connections-arcgismapserver" ) );
276 settings.
beginGroup( QStringLiteral(
"/qgis/connections-arcgisfeatureserver" ) );
279 settings.
beginGroup( QStringLiteral(
"/qgis/connections-vector-tile" ) );
283 QStringList::Iterator it = keys.begin();
284 while ( it != keys.end() )
286 QListWidgetItem *item =
new QListWidgetItem();
287 item->setText( *it );
288 listConnections->addItem( item );
296 QFile file( mFileName );
297 if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
299 QMessageBox::warning(
this, tr(
"Loading Connections" ),
300 tr(
"Cannot read file %1:\n%2." )
302 file.errorString() ) );
311 if ( !doc.setContent( &file,
true, &errorStr, &errorLine, &errorColumn ) )
313 QMessageBox::warning(
this, tr(
"Loading Connections" ),
314 tr(
"Parse error at line %1, column %2:\n%3" )
321 const QDomElement root = doc.documentElement();
322 switch ( mConnectionType )
325 if ( root.tagName() != QLatin1String(
"qgsWMSConnections" ) )
327 QMessageBox::information(
this, tr(
"Loading Connections" ),
328 tr(
"The file is not a WMS connections exchange file." ) );
334 if ( root.tagName() != QLatin1String(
"qgsWFSConnections" ) )
336 QMessageBox::information(
this, tr(
"Loading Connections" ),
337 tr(
"The file is not a WFS connections exchange file." ) );
343 if ( root.tagName() != QLatin1String(
"qgsWCSConnections" ) )
345 QMessageBox::information(
this, tr(
"Loading Connections" ),
346 tr(
"The file is not a WCS connections exchange file." ) );
352 if ( root.tagName() != QLatin1String(
"qgsPgConnections" ) )
354 QMessageBox::information(
this, tr(
"Loading Connections" ),
355 tr(
"The file is not a PostGIS connections exchange file." ) );
361 if ( root.tagName() != QLatin1String(
"qgsMssqlConnections" ) )
363 QMessageBox::information(
this, tr(
"Loading Connections" ),
364 tr(
"The file is not a MSSQL connections exchange file." ) );
369 if ( root.tagName() != QLatin1String(
"qgsOracleConnections" ) )
371 QMessageBox::information(
this, tr(
"Loading Connections" ),
372 tr(
"The file is not an Oracle connections exchange file." ) );
377 if ( root.tagName() != QLatin1String(
"qgsHanaConnections" ) )
379 QMessageBox::warning(
this, tr(
"Loading Connections" ),
380 tr(
"The file is not a HANA connections exchange file." ) );
385 if ( root.tagName() != QLatin1String(
"qgsGeoNodeConnections" ) )
387 QMessageBox::information(
this, tr(
"Loading Connections" ),
388 tr(
"The file is not a GeoNode connections exchange file." ) );
393 if ( root.tagName() != QLatin1String(
"qgsXYZTilesConnections" ) )
395 QMessageBox::information(
this, tr(
"Loading Connections" ),
396 tr(
"The file is not a XYZ Tiles connections exchange file." ) );
401 if ( root.tagName() != QLatin1String(
"qgsARCGISMAPSERVERConnections" ) )
403 QMessageBox::information(
this, tr(
"Loading Connections" ),
404 tr(
"The file is not a ArcGIS Map Service connections exchange file." ) );
409 if ( root.tagName() != QLatin1String(
"qgsARCGISFEATURESERVERConnections" ) )
411 QMessageBox::information(
this, tr(
"Loading Connections" ),
412 tr(
"The file is not a ArcGIS Feature Service connections exchange file." ) );
417 if ( root.tagName() != QLatin1String(
"qgsVectorTileConnections" ) )
419 QMessageBox::information(
this, tr(
"Loading Connections" ),
420 tr(
"The file is not a Vector Tile connections exchange file." ) );
426 QDomElement child = root.firstChildElement();
427 while ( !child.isNull() )
429 QListWidgetItem *item =
new QListWidgetItem();
430 item->setText( child.attribute( QStringLiteral(
"name" ) ) );
431 listConnections->addItem( item );
432 child = child.nextSiblingElement();
438 QDomDocument QgsManageConnectionsDialog::saveOWSConnections(
const QStringList &connections,
const QString &service )
440 QDomDocument doc( QStringLiteral(
"connections" ) );
441 QDomElement root = doc.createElement(
"qgs" + service.toUpper() +
"Connections" );
442 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
443 doc.appendChild( root );
447 for (
int i = 0; i < connections.count(); ++i )
449 path =
"/qgis/connections-" + service.toLower() +
'/';
450 QDomElement el = doc.createElement( service.toLower() );
451 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
452 el.setAttribute( QStringLiteral(
"url" ), settings.
value( path + connections[ i ] +
"/url" ).toString() );
454 if ( service == QLatin1String(
"WMS" ) )
456 el.setAttribute( QStringLiteral(
"ignoreGetMapURI" ), settings.
value( path + connections[i] +
"/ignoreGetMapURI",
false ).toBool() ?
"true" :
"false" );
457 el.setAttribute( QStringLiteral(
"ignoreGetFeatureInfoURI" ), settings.
value( path + connections[i] +
"/ignoreGetFeatureInfoURI",
false ).toBool() ?
"true" :
"false" );
458 el.setAttribute( QStringLiteral(
"ignoreAxisOrientation" ), settings.
value( path + connections[i] +
"/ignoreAxisOrientation",
false ).toBool() ?
"true" :
"false" );
459 el.setAttribute( QStringLiteral(
"invertAxisOrientation" ), settings.
value( path + connections[i] +
"/invertAxisOrientation",
false ).toBool() ?
"true" :
"false" );
460 el.setAttribute( QStringLiteral(
"referer" ), settings.
value( path + connections[ i ] +
"/referer" ).toString() );
461 el.setAttribute( QStringLiteral(
"smoothPixmapTransform" ), settings.
value( path + connections[i] +
"/smoothPixmapTransform",
false ).toBool() ?
"true" :
"false" );
462 el.setAttribute( QStringLiteral(
"dpiMode" ), settings.
value( path + connections[i] +
"/dpiMode",
"7" ).toInt() );
465 path =
"/qgis/" + service.toUpper() +
'/';
466 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path + connections[ i ] +
"/username" ).toString() );
467 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path + connections[ i ] +
"/password" ).toString() );
468 root.appendChild( el );
474 QDomDocument QgsManageConnectionsDialog::saveWfsConnections(
const QStringList &connections )
476 QDomDocument doc( QStringLiteral(
"connections" ) );
477 QDomElement root = doc.createElement( QStringLiteral(
"qgsWFSConnections" ) );
478 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.1" ) );
479 doc.appendChild( root );
483 for (
int i = 0; i < connections.count(); ++i )
485 path = QStringLiteral(
"/qgis/connections-wfs/" );
486 QDomElement el = doc.createElement( QStringLiteral(
"wfs" ) );
487 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
488 el.setAttribute( QStringLiteral(
"url" ), settings.
value( path + connections[ i ] +
"/url" ).toString() );
490 el.setAttribute( QStringLiteral(
"version" ), settings.
value( path + connections[ i ] +
"/version" ).toString() );
491 el.setAttribute( QStringLiteral(
"maxnumfeatures" ), settings.
value( path + connections[ i ] +
"/maxnumfeatures" ).toString() );
492 el.setAttribute( QStringLiteral(
"pagesize" ), settings.
value( path + connections[ i ] +
"/pagesize" ).toString() );
493 el.setAttribute( QStringLiteral(
"pagingenabled" ), settings.
value( path + connections[ i ] +
"/pagingenabled",
false ).toString() );
494 el.setAttribute( QStringLiteral(
"ignoreAxisOrientation" ), settings.
value( path + connections[ i ] +
"/ignoreAxisOrientation",
false ).toString() );
495 el.setAttribute( QStringLiteral(
"invertAxisOrientation" ), settings.
value( path + connections[ i ] +
"/invertAxisOrientation",
false ).toString() );
497 path = QStringLiteral(
"/qgis/WFS/" );
498 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path + connections[ i ] +
"/username" ).toString() );
499 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path + connections[ i ] +
"/password" ).toString() );
500 root.appendChild( el );
506 QDomDocument QgsManageConnectionsDialog::savePgConnections(
const QStringList &connections )
508 QDomDocument doc( QStringLiteral(
"connections" ) );
509 QDomElement root = doc.createElement( QStringLiteral(
"qgsPgConnections" ) );
510 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
511 doc.appendChild( root );
515 for (
int i = 0; i < connections.count(); ++i )
517 path =
"/PostgreSQL/connections/" + connections[ i ];
518 QDomElement el = doc.createElement( QStringLiteral(
"postgis" ) );
519 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
520 el.setAttribute( QStringLiteral(
"host" ), settings.
value( path +
"/host" ).toString() );
521 el.setAttribute( QStringLiteral(
"port" ), settings.
value( path +
"/port" ).toString() );
522 el.setAttribute( QStringLiteral(
"database" ), settings.
value( path +
"/database" ).toString() );
523 el.setAttribute( QStringLiteral(
"service" ), settings.
value( path +
"/service" ).toString() );
524 el.setAttribute( QStringLiteral(
"sslmode" ), settings.
value( path +
"/sslmode",
"1" ).toString() );
525 el.setAttribute( QStringLiteral(
"estimatedMetadata" ), settings.
value( path +
"/estimatedMetadata",
"0" ).toString() );
526 el.setAttribute( QStringLiteral(
"projectsInDatabase" ), settings.
value( path +
"/projectsInDatabase",
"0" ).toString() );
527 el.setAttribute( QStringLiteral(
"dontResolveType" ), settings.
value( path +
"/dontResolveType",
"0" ).toString() );
528 el.setAttribute( QStringLiteral(
"allowGeometrylessTables" ), settings.
value( path +
"/allowGeometrylessTables",
"0" ).toString() );
529 el.setAttribute( QStringLiteral(
"geometryColumnsOnly" ), settings.
value( path +
"/geometryColumnsOnly",
"0" ).toString() );
530 el.setAttribute( QStringLiteral(
"publicOnly" ), settings.
value( path +
"/publicOnly",
"0" ).toString() );
532 el.setAttribute( QStringLiteral(
"saveUsername" ), settings.
value( path +
"/saveUsername",
"false" ).toString() );
534 if ( settings.
value( path +
"/saveUsername",
"false" ).toString() == QLatin1String(
"true" ) )
536 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path +
"/username" ).toString() );
539 el.setAttribute( QStringLiteral(
"savePassword" ), settings.
value( path +
"/savePassword",
"false" ).toString() );
541 if ( settings.
value( path +
"/savePassword",
"false" ).toString() == QLatin1String(
"true" ) )
543 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path +
"/password" ).toString() );
546 root.appendChild( el );
552 QDomDocument QgsManageConnectionsDialog::saveMssqlConnections(
const QStringList &connections )
554 QDomDocument doc( QStringLiteral(
"connections" ) );
555 QDomElement root = doc.createElement( QStringLiteral(
"qgsMssqlConnections" ) );
556 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
557 doc.appendChild( root );
561 for (
int i = 0; i < connections.count(); ++i )
563 path =
"/MSSQL/connections/" + connections[ i ];
564 QDomElement el = doc.createElement( QStringLiteral(
"mssql" ) );
565 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
566 el.setAttribute( QStringLiteral(
"host" ), settings.
value( path +
"/host" ).toString() );
567 el.setAttribute( QStringLiteral(
"port" ), settings.
value( path +
"/port" ).toString() );
568 el.setAttribute( QStringLiteral(
"database" ), settings.
value( path +
"/database" ).toString() );
569 el.setAttribute( QStringLiteral(
"service" ), settings.
value( path +
"/service" ).toString() );
570 el.setAttribute( QStringLiteral(
"sslmode" ), settings.
value( path +
"/sslmode",
"1" ).toString() );
571 el.setAttribute( QStringLiteral(
"estimatedMetadata" ), settings.
value( path +
"/estimatedMetadata",
"0" ).toString() );
573 el.setAttribute( QStringLiteral(
"saveUsername" ), settings.
value( path +
"/saveUsername",
"false" ).toString() );
575 if ( settings.
value( path +
"/saveUsername",
"false" ).toString() == QLatin1String(
"true" ) )
577 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path +
"/username" ).toString() );
580 el.setAttribute( QStringLiteral(
"savePassword" ), settings.
value( path +
"/savePassword",
"false" ).toString() );
582 if ( settings.
value( path +
"/savePassword",
"false" ).toString() == QLatin1String(
"true" ) )
584 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path +
"/password" ).toString() );
587 root.appendChild( el );
593 QDomDocument QgsManageConnectionsDialog::saveOracleConnections(
const QStringList &connections )
595 QDomDocument doc( QStringLiteral(
"connections" ) );
596 QDomElement root = doc.createElement( QStringLiteral(
"qgsOracleConnections" ) );
597 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
598 doc.appendChild( root );
602 for (
int i = 0; i < connections.count(); ++i )
604 path =
"/Oracle/connections/" + connections[ i ];
605 QDomElement el = doc.createElement( QStringLiteral(
"oracle" ) );
606 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
607 el.setAttribute( QStringLiteral(
"host" ), settings.
value( path +
"/host" ).toString() );
608 el.setAttribute( QStringLiteral(
"port" ), settings.
value( path +
"/port" ).toString() );
609 el.setAttribute( QStringLiteral(
"database" ), settings.
value( path +
"/database" ).toString() );
610 el.setAttribute( QStringLiteral(
"dboptions" ), settings.
value( path +
"/dboptions" ).toString() );
611 el.setAttribute( QStringLiteral(
"dbworkspace" ), settings.
value( path +
"/dbworkspace" ).toString() );
612 el.setAttribute( QStringLiteral(
"schema" ), settings.
value( path +
"/schema" ).toString() );
613 el.setAttribute( QStringLiteral(
"estimatedMetadata" ), settings.
value( path +
"/estimatedMetadata",
"0" ).toString() );
614 el.setAttribute( QStringLiteral(
"userTablesOnly" ), settings.
value( path +
"/userTablesOnly",
"0" ).toString() );
615 el.setAttribute( QStringLiteral(
"geometryColumnsOnly" ), settings.
value( path +
"/geometryColumnsOnly",
"0" ).toString() );
616 el.setAttribute( QStringLiteral(
"allowGeometrylessTables" ), settings.
value( path +
"/allowGeometrylessTables",
"0" ).toString() );
618 el.setAttribute( QStringLiteral(
"saveUsername" ), settings.
value( path +
"/saveUsername",
"false" ).toString() );
620 if ( settings.
value( path +
"/saveUsername",
"false" ).toString() == QLatin1String(
"true" ) )
622 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path +
"/username" ).toString() );
625 el.setAttribute( QStringLiteral(
"savePassword" ), settings.
value( path +
"/savePassword",
"false" ).toString() );
627 if ( settings.
value( path +
"/savePassword",
"false" ).toString() == QLatin1String(
"true" ) )
629 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path +
"/password" ).toString() );
632 root.appendChild( el );
638 QDomDocument QgsManageConnectionsDialog::saveHanaConnections(
const QStringList &connections )
640 QDomDocument doc( QStringLiteral(
"connections" ) );
641 QDomElement root = doc.createElement( QStringLiteral(
"qgsHanaConnections" ) );
642 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
643 doc.appendChild( root );
647 for (
int i = 0; i < connections.count(); ++i )
649 path =
"/HANA/connections/" + connections[i];
650 QDomElement el = doc.createElement( QStringLiteral(
"hana" ) );
651 el.setAttribute( QStringLiteral(
"name" ), connections[i] );
652 el.setAttribute( QStringLiteral(
"driver" ), settings.
value( path +
"/driver", QString() ).toString() );
653 el.setAttribute( QStringLiteral(
"host" ), settings.
value( path +
"/host", QString() ).toString() );
654 el.setAttribute( QStringLiteral(
"identifierType" ), settings.
value( path +
"/identifierType", QString() ).toString() );
655 el.setAttribute( QStringLiteral(
"identifier" ), settings.
value( path +
"/identifier", QString() ).toString() );
656 el.setAttribute( QStringLiteral(
"multitenant" ), settings.
value( path +
"/multitenant", QString() ).toString() );
657 el.setAttribute( QStringLiteral(
"database" ), settings.
value( path +
"/database", QString() ).toString() );
658 el.setAttribute( QStringLiteral(
"schema" ), settings.
value( path +
"/schema", QString() ).toString() );
659 el.setAttribute( QStringLiteral(
"userTablesOnly" ), settings.
value( path +
"/userTablesOnly", QStringLiteral(
"0" ) ).toString() );
660 el.setAttribute( QStringLiteral(
"allowGeometrylessTables" ), settings.
value( path +
"/allowGeometrylessTables", QStringLiteral(
"0" ) ).toString() );
662 el.setAttribute( QStringLiteral(
"saveUsername" ), settings.
value( path +
"/saveUsername", QStringLiteral(
"false" ) ).toString() );
663 if ( settings.
value( path +
"/saveUsername",
"false" ).toString() == QLatin1String(
"true" ) )
665 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path +
"/username", QString() ).toString() );
668 el.setAttribute( QStringLiteral(
"savePassword" ), settings.
value( path +
"/savePassword", QStringLiteral(
"false" ) ).toString() );
669 if ( settings.
value( path +
"/savePassword",
"false" ).toString() == QLatin1String(
"true" ) )
671 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path +
"/password", QString() ).toString() );
674 el.setAttribute( QStringLiteral(
"sslEnabled" ), settings.
value( path +
"/sslEnabled", QStringLiteral(
"false" ) ).toString() );
675 el.setAttribute( QStringLiteral(
"sslCryptoProvider" ), settings.
value( path +
"/sslCryptoProvider", QStringLiteral(
"openssl" ) ).toString() );
676 el.setAttribute( QStringLiteral(
"sslKeyStore" ), settings.
value( path +
"/sslKeyStore", QString() ).toString() );
677 el.setAttribute( QStringLiteral(
"sslTrustStore" ), settings.
value( path +
"/sslTrustStore", QString() ).toString() );
678 el.setAttribute( QStringLiteral(
"sslValidateCertificate" ), settings.
value( path +
"/sslValidateCertificate", QStringLiteral(
"false" ) ).toString() );
679 el.setAttribute( QStringLiteral(
"sslHostNameInCertificate" ), settings.
value( path +
"/sslHostNameInCertificate", QString() ).toString() );
681 root.appendChild( el );
687 QDomDocument QgsManageConnectionsDialog::saveGeonodeConnections(
const QStringList &connections )
689 QDomDocument doc( QStringLiteral(
"connections" ) );
690 QDomElement root = doc.createElement( QStringLiteral(
"qgsGeoNodeConnections" ) );
691 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
692 doc.appendChild( root );
696 for (
int i = 0; i < connections.count(); ++i )
698 path = QStringLiteral(
"/qgis/connections-geonode/" );
699 QDomElement el = doc.createElement( QStringLiteral(
"geonode" ) );
700 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
701 el.setAttribute( QStringLiteral(
"url" ), settings.
value( path + connections[ i ] +
"/url" ).toString() );
703 path = QStringLiteral(
"/qgis/GeoNode/" );
704 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path + connections[ i ] +
"/username" ).toString() );
705 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path + connections[ i ] +
"/password" ).toString() );
706 root.appendChild( el );
712 QDomDocument QgsManageConnectionsDialog::saveXyzTilesConnections(
const QStringList &connections )
714 QDomDocument doc( QStringLiteral(
"connections" ) );
715 QDomElement root = doc.createElement( QStringLiteral(
"qgsXYZTilesConnections" ) );
716 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
717 doc.appendChild( root );
721 for (
int i = 0; i < connections.count(); ++i )
723 path =
"qgis/connections-xyz/" + connections[ i ];
724 QDomElement el = doc.createElement( QStringLiteral(
"xyztiles" ) );
726 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
727 el.setAttribute( QStringLiteral(
"url" ), settings.
value( path +
"/url" ).toString() );
728 el.setAttribute( QStringLiteral(
"zmin" ), settings.
value( path +
"/zmin", -1 ).toInt() );
729 el.setAttribute( QStringLiteral(
"zmax" ), settings.
value( path +
"/zmax", -1 ).toInt() );
730 el.setAttribute( QStringLiteral(
"authcfg" ), settings.
value( path +
"/authcfg" ).toString() );
731 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path +
"/username" ).toString() );
732 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path +
"/password" ).toString() );
733 el.setAttribute( QStringLiteral(
"referer" ), settings.
value( path +
"/referer" ).toString() );
734 el.setAttribute( QStringLiteral(
"tilePixelRatio" ), settings.
value( path +
"/tilePixelRatio", 0 ).toDouble() );
736 root.appendChild( el );
742 QDomDocument QgsManageConnectionsDialog::saveArcgisConnections(
const QStringList &connections,
const QString &service )
744 QDomDocument doc( QStringLiteral(
"connections" ) );
745 QDomElement root = doc.createElement(
"qgs" + service.toUpper() +
"Connections" );
746 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
747 doc.appendChild( root );
751 for (
int i = 0; i < connections.count(); ++i )
753 path =
"/qgis/connections-" + service.toLower() +
'/';
754 QDomElement el = doc.createElement( service.toLower() );
755 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
756 el.setAttribute( QStringLiteral(
"url" ), settings.
value( path + connections[ i ] +
"/url" ).toString() );
757 el.setAttribute( QStringLiteral(
"referer" ), settings.
value( path + connections[ i ] +
"/referer" ).toString() );
759 path =
"/qgis/" + service.toUpper() +
'/';
760 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path + connections[ i ] +
"/username" ).toString() );
761 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path + connections[ i ] +
"/password" ).toString() );
762 el.setAttribute( QStringLiteral(
"authcfg" ), settings.
value( path + connections[ i ] +
"/authcfg" ).toString() );
763 root.appendChild( el );
769 QDomDocument QgsManageConnectionsDialog::saveVectorTileConnections(
const QStringList &connections )
771 QDomDocument doc( QStringLiteral(
"connections" ) );
772 QDomElement root = doc.createElement( QStringLiteral(
"qgsVectorTileConnections" ) );
773 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
774 doc.appendChild( root );
778 for (
int i = 0; i < connections.count(); ++i )
780 path =
"qgis/connections-vector-tile/" + connections[ i ];
781 QDomElement el = doc.createElement( QStringLiteral(
"vectortile" ) );
783 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
784 el.setAttribute( QStringLiteral(
"url" ), settings.
value( path +
"/url" ).toString() );
785 el.setAttribute( QStringLiteral(
"zmin" ), settings.
value( path +
"/zmin", -1 ).toInt() );
786 el.setAttribute( QStringLiteral(
"zmax" ), settings.
value( path +
"/zmax", -1 ).toInt() );
787 el.setAttribute( QStringLiteral(
"serviceType" ), settings.
value( path +
"/serviceType", QString() ).toString() );
788 el.setAttribute( QStringLiteral(
"authcfg" ), settings.
value( path +
"/authcfg" ).toString() );
789 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path +
"/username" ).toString() );
790 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path +
"/password" ).toString() );
791 el.setAttribute( QStringLiteral(
"referer" ), settings.
value( path +
"/referer" ).toString() );
792 el.setAttribute( QStringLiteral(
"styleUrl" ), settings.
value( path +
"/styleUrl" ).toString() );
794 root.appendChild( el );
800 void QgsManageConnectionsDialog::loadOWSConnections(
const QDomDocument &doc,
const QStringList &items,
const QString &service )
802 const QDomElement root = doc.documentElement();
803 if ( root.tagName() !=
"qgs" + service.toUpper() +
"Connections" )
805 QMessageBox::information(
this, tr(
"Loading Connections" ),
806 tr(
"The file is not a %1 connections exchange file." ).arg( service ) );
810 QString connectionName;
812 settings.
beginGroup(
"/qgis/connections-" + service.toLower() );
815 QDomElement child = root.firstChildElement();
817 bool overwrite =
true;
819 while ( !child.isNull() )
821 connectionName = child.attribute( QStringLiteral(
"name" ) );
822 if ( !items.contains( connectionName ) )
824 child = child.nextSiblingElement();
829 if ( keys.contains( connectionName ) && prompt )
831 const int res = QMessageBox::warning(
this,
832 tr(
"Loading Connections" ),
833 tr(
"Connection with name '%1' already exists. Overwrite?" )
834 .arg( connectionName ),
835 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
839 case QMessageBox::Cancel:
841 case QMessageBox::No:
842 child = child.nextSiblingElement();
844 case QMessageBox::Yes:
847 case QMessageBox::YesToAll:
851 case QMessageBox::NoToAll:
858 if ( keys.contains( connectionName ) )
862 child = child.nextSiblingElement();
868 keys << connectionName;
872 settings.
beginGroup(
"/qgis/connections-" + service.toLower() );
873 settings.
setValue( QString(
'/' + connectionName +
"/url" ), child.attribute( QStringLiteral(
"url" ) ) );
874 settings.
setValue( QString(
'/' + connectionName +
"/ignoreGetMapURI" ), child.attribute( QStringLiteral(
"ignoreGetMapURI" ) ) == QLatin1String(
"true" ) );
875 settings.
setValue( QString(
'/' + connectionName +
"/ignoreGetFeatureInfoURI" ), child.attribute( QStringLiteral(
"ignoreGetFeatureInfoURI" ) ) == QLatin1String(
"true" ) );
876 settings.
setValue( QString(
'/' + connectionName +
"/ignoreAxisOrientation" ), child.attribute( QStringLiteral(
"ignoreAxisOrientation" ) ) == QLatin1String(
"true" ) );
877 settings.
setValue( QString(
'/' + connectionName +
"/invertAxisOrientation" ), child.attribute( QStringLiteral(
"invertAxisOrientation" ) ) == QLatin1String(
"true" ) );
878 settings.
setValue( QString(
'/' + connectionName +
"/referer" ), child.attribute( QStringLiteral(
"referer" ) ) );
879 settings.
setValue( QString(
'/' + connectionName +
"/smoothPixmapTransform" ), child.attribute( QStringLiteral(
"smoothPixmapTransform" ) ) == QLatin1String(
"true" ) );
880 settings.
setValue( QString(
'/' + connectionName +
"/dpiMode" ), child.attribute( QStringLiteral(
"dpiMode" ), QStringLiteral(
"7" ) ).toInt() );
883 if ( !child.attribute( QStringLiteral(
"username" ) ).isEmpty() )
885 settings.
beginGroup(
"/qgis/" + service.toUpper() +
'/' + connectionName );
886 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
887 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
890 child = child.nextSiblingElement();
894 void QgsManageConnectionsDialog::loadWfsConnections(
const QDomDocument &doc,
const QStringList &items )
896 const QDomElement root = doc.documentElement();
897 if ( root.tagName() != QLatin1String(
"qgsWFSConnections" ) )
899 QMessageBox::information(
this, tr(
"Loading Connections" ),
900 tr(
"The file is not a WFS connections exchange file." ) );
904 QString connectionName;
906 settings.
beginGroup( QStringLiteral(
"/qgis/connections-wfs" ) );
909 QDomElement child = root.firstChildElement();
911 bool overwrite =
true;
913 while ( !child.isNull() )
915 connectionName = child.attribute( QStringLiteral(
"name" ) );
916 if ( !items.contains( connectionName ) )
918 child = child.nextSiblingElement();
923 if ( keys.contains( connectionName ) && prompt )
925 const int res = QMessageBox::warning(
this,
926 tr(
"Loading Connections" ),
927 tr(
"Connection with name '%1' already exists. Overwrite?" )
928 .arg( connectionName ),
929 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
933 case QMessageBox::Cancel:
935 case QMessageBox::No:
936 child = child.nextSiblingElement();
938 case QMessageBox::Yes:
941 case QMessageBox::YesToAll:
945 case QMessageBox::NoToAll:
952 if ( keys.contains( connectionName ) )
956 child = child.nextSiblingElement();
962 keys << connectionName;
966 settings.
beginGroup( QStringLiteral(
"/qgis/connections-wfs" ) );
967 settings.
setValue( QString(
'/' + connectionName +
"/url" ), child.attribute( QStringLiteral(
"url" ) ) );
969 settings.
setValue( QString(
'/' + connectionName +
"/version" ), child.attribute( QStringLiteral(
"version" ) ) );
970 settings.
setValue( QString(
'/' + connectionName +
"/maxnumfeatures" ), child.attribute( QStringLiteral(
"maxnumfeatures" ) ) );
971 settings.
setValue( QString(
'/' + connectionName +
"/pagesize" ), child.attribute( QStringLiteral(
"pagesize" ) ) );
972 settings.
setValue( QString(
'/' + connectionName +
"/pagingenabled" ), child.attribute( QStringLiteral(
"pagingenabled" ) ) );
973 settings.
setValue( QString(
'/' + connectionName +
"/ignoreAxisOrientation" ), child.attribute( QStringLiteral(
"ignoreAxisOrientation" ) ) );
974 settings.
setValue( QString(
'/' + connectionName +
"/invertAxisOrientation" ), child.attribute( QStringLiteral(
"invertAxisOrientation" ) ) );
977 if ( !child.attribute( QStringLiteral(
"username" ) ).isEmpty() )
979 settings.
beginGroup(
"/qgis/WFS/" + connectionName );
980 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
981 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
984 child = child.nextSiblingElement();
988 void QgsManageConnectionsDialog::loadPgConnections(
const QDomDocument &doc,
const QStringList &items )
990 const QDomElement root = doc.documentElement();
991 if ( root.tagName() != QLatin1String(
"qgsPgConnections" ) )
993 QMessageBox::information(
this,
994 tr(
"Loading Connections" ),
995 tr(
"The file is not a PostGIS connections exchange file." ) );
999 QString connectionName;
1001 settings.
beginGroup( QStringLiteral(
"/PostgreSQL/connections" ) );
1004 QDomElement child = root.firstChildElement();
1006 bool overwrite =
true;
1008 while ( !child.isNull() )
1010 connectionName = child.attribute( QStringLiteral(
"name" ) );
1011 if ( !items.contains( connectionName ) )
1013 child = child.nextSiblingElement();
1018 if ( keys.contains( connectionName ) && prompt )
1020 const int res = QMessageBox::warning(
this,
1021 tr(
"Loading Connections" ),
1022 tr(
"Connection with name '%1' already exists. Overwrite?" )
1023 .arg( connectionName ),
1024 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1027 case QMessageBox::Cancel:
1029 case QMessageBox::No:
1030 child = child.nextSiblingElement();
1032 case QMessageBox::Yes:
1035 case QMessageBox::YesToAll:
1039 case QMessageBox::NoToAll:
1046 if ( keys.contains( connectionName ) )
1050 child = child.nextSiblingElement();
1056 keys << connectionName;
1060 settings.
beginGroup(
"/PostgreSQL/connections/" + connectionName );
1062 settings.
setValue( QStringLiteral(
"/host" ), child.attribute( QStringLiteral(
"host" ) ) );
1063 settings.
setValue( QStringLiteral(
"/port" ), child.attribute( QStringLiteral(
"port" ) ) );
1064 settings.
setValue( QStringLiteral(
"/database" ), child.attribute( QStringLiteral(
"database" ) ) );
1065 if ( child.hasAttribute( QStringLiteral(
"service" ) ) )
1067 settings.
setValue( QStringLiteral(
"/service" ), child.attribute( QStringLiteral(
"service" ) ) );
1071 settings.
setValue( QStringLiteral(
"/service" ),
"" );
1073 settings.
setValue( QStringLiteral(
"/sslmode" ), child.attribute( QStringLiteral(
"sslmode" ) ) );
1074 settings.
setValue( QStringLiteral(
"/estimatedMetadata" ), child.attribute( QStringLiteral(
"estimatedMetadata" ) ) );
1075 settings.
setValue( QStringLiteral(
"/projectsInDatabase" ), child.attribute( QStringLiteral(
"projectsInDatabase" ), 0 ) );
1076 settings.
setValue( QStringLiteral(
"/dontResolveType" ), child.attribute( QStringLiteral(
"dontResolveType" ), 0 ) );
1077 settings.
setValue( QStringLiteral(
"/allowGeometrylessTables" ), child.attribute( QStringLiteral(
"allowGeometrylessTables" ), 0 ) );
1078 settings.
setValue( QStringLiteral(
"/geometryColumnsOnly" ), child.attribute( QStringLiteral(
"geometryColumnsOnly" ), 0 ) );
1079 settings.
setValue( QStringLiteral(
"/publicOnly" ), child.attribute( QStringLiteral(
"publicOnly" ), 0 ) );
1080 settings.
setValue( QStringLiteral(
"/saveUsername" ), child.attribute( QStringLiteral(
"saveUsername" ) ) );
1081 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
1082 settings.
setValue( QStringLiteral(
"/savePassword" ), child.attribute( QStringLiteral(
"savePassword" ) ) );
1083 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
1086 child = child.nextSiblingElement();
1090 void QgsManageConnectionsDialog::loadMssqlConnections(
const QDomDocument &doc,
const QStringList &items )
1092 const QDomElement root = doc.documentElement();
1093 if ( root.tagName() != QLatin1String(
"qgsMssqlConnections" ) )
1095 QMessageBox::information(
this,
1096 tr(
"Loading Connections" ),
1097 tr(
"The file is not a MSSQL connections exchange file." ) );
1101 QString connectionName;
1103 settings.
beginGroup( QStringLiteral(
"/MSSQL/connections" ) );
1106 QDomElement child = root.firstChildElement();
1108 bool overwrite =
true;
1110 while ( !child.isNull() )
1112 connectionName = child.attribute( QStringLiteral(
"name" ) );
1113 if ( !items.contains( connectionName ) )
1115 child = child.nextSiblingElement();
1120 if ( keys.contains( connectionName ) && prompt )
1122 const int res = QMessageBox::warning(
this,
1123 tr(
"Loading Connections" ),
1124 tr(
"Connection with name '%1' already exists. Overwrite?" )
1125 .arg( connectionName ),
1126 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1129 case QMessageBox::Cancel:
1131 case QMessageBox::No:
1132 child = child.nextSiblingElement();
1134 case QMessageBox::Yes:
1137 case QMessageBox::YesToAll:
1141 case QMessageBox::NoToAll:
1148 if ( keys.contains( connectionName ) )
1152 child = child.nextSiblingElement();
1158 keys << connectionName;
1162 settings.
beginGroup(
"/MSSQL/connections/" + connectionName );
1164 settings.
setValue( QStringLiteral(
"/host" ), child.attribute( QStringLiteral(
"host" ) ) );
1165 settings.
setValue( QStringLiteral(
"/port" ), child.attribute( QStringLiteral(
"port" ) ) );
1166 settings.
setValue( QStringLiteral(
"/database" ), child.attribute( QStringLiteral(
"database" ) ) );
1167 if ( child.hasAttribute( QStringLiteral(
"service" ) ) )
1169 settings.
setValue( QStringLiteral(
"/service" ), child.attribute( QStringLiteral(
"service" ) ) );
1173 settings.
setValue( QStringLiteral(
"/service" ),
"" );
1175 settings.
setValue( QStringLiteral(
"/sslmode" ), child.attribute( QStringLiteral(
"sslmode" ) ) );
1176 settings.
setValue( QStringLiteral(
"/estimatedMetadata" ), child.attribute( QStringLiteral(
"estimatedMetadata" ) ) );
1177 settings.
setValue( QStringLiteral(
"/saveUsername" ), child.attribute( QStringLiteral(
"saveUsername" ) ) );
1178 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
1179 settings.
setValue( QStringLiteral(
"/savePassword" ), child.attribute( QStringLiteral(
"savePassword" ) ) );
1180 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
1183 child = child.nextSiblingElement();
1187 void QgsManageConnectionsDialog::loadOracleConnections(
const QDomDocument &doc,
const QStringList &items )
1189 const QDomElement root = doc.documentElement();
1190 if ( root.tagName() != QLatin1String(
"qgsOracleConnections" ) )
1192 QMessageBox::information(
this,
1193 tr(
"Loading Connections" ),
1194 tr(
"The file is not an Oracle connections exchange file." ) );
1198 QString connectionName;
1200 settings.
beginGroup( QStringLiteral(
"/Oracle/connections" ) );
1203 QDomElement child = root.firstChildElement();
1205 bool overwrite =
true;
1207 while ( !child.isNull() )
1209 connectionName = child.attribute( QStringLiteral(
"name" ) );
1210 if ( !items.contains( connectionName ) )
1212 child = child.nextSiblingElement();
1217 if ( keys.contains( connectionName ) && prompt )
1219 const int res = QMessageBox::warning(
this,
1220 tr(
"Loading Connections" ),
1221 tr(
"Connection with name '%1' already exists. Overwrite?" )
1222 .arg( connectionName ),
1223 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1226 case QMessageBox::Cancel:
1228 case QMessageBox::No:
1229 child = child.nextSiblingElement();
1231 case QMessageBox::Yes:
1234 case QMessageBox::YesToAll:
1238 case QMessageBox::NoToAll:
1245 if ( keys.contains( connectionName ) )
1249 child = child.nextSiblingElement();
1255 keys << connectionName;
1259 settings.
beginGroup(
"/Oracle/connections/" + connectionName );
1261 settings.
setValue( QStringLiteral(
"/host" ), child.attribute( QStringLiteral(
"host" ) ) );
1262 settings.
setValue( QStringLiteral(
"/port" ), child.attribute( QStringLiteral(
"port" ) ) );
1263 settings.
setValue( QStringLiteral(
"/database" ), child.attribute( QStringLiteral(
"database" ) ) );
1264 settings.
setValue( QStringLiteral(
"/dboptions" ), child.attribute( QStringLiteral(
"dboptions" ) ) );
1265 settings.
setValue( QStringLiteral(
"/dbworkspace" ), child.attribute( QStringLiteral(
"dbworkspace" ) ) );
1266 settings.
setValue( QStringLiteral(
"/schema" ), child.attribute( QStringLiteral(
"schema" ) ) );
1267 settings.
setValue( QStringLiteral(
"/estimatedMetadata" ), child.attribute( QStringLiteral(
"estimatedMetadata" ) ) );
1268 settings.
setValue( QStringLiteral(
"/userTablesOnly" ), child.attribute( QStringLiteral(
"userTablesOnly" ) ) );
1269 settings.
setValue( QStringLiteral(
"/geometryColumnsOnly" ), child.attribute( QStringLiteral(
"geometryColumnsOnly" ) ) );
1270 settings.
setValue( QStringLiteral(
"/allowGeometrylessTables" ), child.attribute( QStringLiteral(
"allowGeometrylessTables" ) ) );
1271 settings.
setValue( QStringLiteral(
"/saveUsername" ), child.attribute( QStringLiteral(
"saveUsername" ) ) );
1272 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
1273 settings.
setValue( QStringLiteral(
"/savePassword" ), child.attribute( QStringLiteral(
"savePassword" ) ) );
1274 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
1277 child = child.nextSiblingElement();
1281 void QgsManageConnectionsDialog::loadHanaConnections(
const QDomDocument &doc,
const QStringList &items )
1283 QDomElement root = doc.documentElement();
1284 if ( root.tagName() != QLatin1String(
"qgsHanaConnections" ) )
1286 QMessageBox::warning(
this,
1287 tr(
"Loading Connections" ),
1288 tr(
"The file is not a HANA connections exchange file." ) );
1292 const QDomAttr version = root.attributeNode(
"version" );
1293 if ( version.value() != QLatin1String(
"1.0" ) )
1295 QMessageBox::warning(
this,
1296 tr(
"Loading Connections" ),
1297 tr(
"The HANA connections exchange file version '%1' is not supported." ).arg( version.value() ) );
1302 settings.
beginGroup( QStringLiteral(
"/HANA/connections" ) );
1305 QDomElement child = root.firstChildElement();
1307 bool overwrite =
true;
1309 while ( !child.isNull() )
1311 const QString connectionName = child.attribute( QStringLiteral(
"name" ) );
1312 if ( !items.contains( connectionName ) )
1314 child = child.nextSiblingElement();
1319 if ( keys.contains( connectionName ) && prompt )
1321 const int res = QMessageBox::warning(
this,
1322 tr(
"Loading Connections" ),
1323 tr(
"Connection with name '%1' already exists. Overwrite?" )
1324 .arg( connectionName ),
1325 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1328 case QMessageBox::Cancel:
1330 case QMessageBox::No:
1331 child = child.nextSiblingElement();
1333 case QMessageBox::Yes:
1336 case QMessageBox::YesToAll:
1340 case QMessageBox::NoToAll:
1347 if ( keys.contains( connectionName ) )
1351 child = child.nextSiblingElement();
1357 keys << connectionName;
1361 settings.
beginGroup(
"/HANA/connections/" + connectionName );
1363 for (
const QString param :
1364 {
"driver",
"host",
"database",
"identifierType",
"identifier",
"multitenant",
"schema",
"userTablesOnly",
1365 "allowGeometrylessTables",
"saveUsername",
"username",
"savePassword",
"password",
"sslEnabled",
1366 "sslCryptoProvider",
"sslKeyStore",
"sslTrustStore",
"sslValidateCertificate",
"sslHostNameInCertificate"
1368 settings.
setValue( QStringLiteral(
"/" ) + param, child.attribute( param ) );
1372 child = child.nextSiblingElement();
1376 void QgsManageConnectionsDialog::loadGeonodeConnections(
const QDomDocument &doc,
const QStringList &items )
1378 const QDomElement root = doc.documentElement();
1379 if ( root.tagName() != QLatin1String(
"qgsGeoNodeConnections" ) )
1381 QMessageBox::information(
this, tr(
"Loading Connections" ),
1382 tr(
"The file is not a GeoNode connections exchange file." ) );
1386 QString connectionName;
1388 settings.
beginGroup( QStringLiteral(
"/qgis/connections-geonode" ) );
1391 QDomElement child = root.firstChildElement();
1393 bool overwrite =
true;
1395 while ( !child.isNull() )
1397 connectionName = child.attribute( QStringLiteral(
"name" ) );
1398 if ( !items.contains( connectionName ) )
1400 child = child.nextSiblingElement();
1405 if ( keys.contains( connectionName ) && prompt )
1407 const int res = QMessageBox::warning(
this,
1408 tr(
"Loading Connections" ),
1409 tr(
"Connection with name '%1' already exists. Overwrite?" )
1410 .arg( connectionName ),
1411 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1415 case QMessageBox::Cancel:
1417 case QMessageBox::No:
1418 child = child.nextSiblingElement();
1420 case QMessageBox::Yes:
1423 case QMessageBox::YesToAll:
1427 case QMessageBox::NoToAll:
1434 if ( keys.contains( connectionName ) )
1438 child = child.nextSiblingElement();
1444 keys << connectionName;
1448 settings.
beginGroup( QStringLiteral(
"/qgis/connections-geonode" ) );
1449 settings.
setValue( QString(
'/' + connectionName +
"/url" ), child.attribute( QStringLiteral(
"url" ) ) );
1452 if ( !child.attribute( QStringLiteral(
"username" ) ).isEmpty() )
1454 settings.
beginGroup(
"/qgis/GeoNode/" + connectionName );
1455 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
1456 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
1459 child = child.nextSiblingElement();
1463 void QgsManageConnectionsDialog::loadXyzTilesConnections(
const QDomDocument &doc,
const QStringList &items )
1465 const QDomElement root = doc.documentElement();
1466 if ( root.tagName() != QLatin1String(
"qgsXYZTilesConnections" ) )
1468 QMessageBox::information(
this, tr(
"Loading Connections" ),
1469 tr(
"The file is not a XYZ Tiles connections exchange file." ) );
1473 QString connectionName;
1475 settings.
beginGroup( QStringLiteral(
"/qgis/connections-xyz" ) );
1478 QDomElement child = root.firstChildElement();
1480 bool overwrite =
true;
1482 while ( !child.isNull() )
1484 connectionName = child.attribute( QStringLiteral(
"name" ) );
1485 if ( !items.contains( connectionName ) )
1487 child = child.nextSiblingElement();
1492 if ( keys.contains( connectionName ) && prompt )
1494 const int res = QMessageBox::warning(
this,
1495 tr(
"Loading Connections" ),
1496 tr(
"Connection with name '%1' already exists. Overwrite?" )
1497 .arg( connectionName ),
1498 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1502 case QMessageBox::Cancel:
1504 case QMessageBox::No:
1505 child = child.nextSiblingElement();
1507 case QMessageBox::Yes:
1510 case QMessageBox::YesToAll:
1514 case QMessageBox::NoToAll:
1521 if ( keys.contains( connectionName ) )
1525 child = child.nextSiblingElement();
1531 keys << connectionName;
1534 settings.
beginGroup(
"qgis/connections-xyz/" + connectionName );
1535 settings.
setValue( QStringLiteral(
"url" ), child.attribute( QStringLiteral(
"url" ) ) );
1536 settings.
setValue( QStringLiteral(
"zmin" ), child.attribute( QStringLiteral(
"zmin" ) ) );
1537 settings.
setValue( QStringLiteral(
"zmax" ), child.attribute( QStringLiteral(
"zmax" ) ) );
1538 settings.
setValue( QStringLiteral(
"authcfg" ), child.attribute( QStringLiteral(
"authcfg" ) ) );
1539 settings.
setValue( QStringLiteral(
"username" ), child.attribute( QStringLiteral(
"username" ) ) );
1540 settings.
setValue( QStringLiteral(
"password" ), child.attribute( QStringLiteral(
"password" ) ) );
1541 settings.
setValue( QStringLiteral(
"referer" ), child.attribute( QStringLiteral(
"referer" ) ) );
1542 settings.
setValue( QStringLiteral(
"tilePixelRatio" ), child.attribute( QStringLiteral(
"tilePixelRatio" ) ) );
1545 child = child.nextSiblingElement();
1549 void QgsManageConnectionsDialog::loadArcgisConnections(
const QDomDocument &doc,
const QStringList &items,
const QString &service )
1551 const QDomElement root = doc.documentElement();
1552 if ( root.tagName() !=
"qgs" + service.toUpper() +
"Connections" )
1554 QMessageBox::information(
this, tr(
"Loading Connections" ),
1555 tr(
"The file is not a %1 connections exchange file." ).arg( service ) );
1559 QString connectionName;
1561 settings.
beginGroup(
"/qgis/connections-" + service.toLower() );
1564 QDomElement child = root.firstChildElement();
1566 bool overwrite =
true;
1568 while ( !child.isNull() )
1570 connectionName = child.attribute( QStringLiteral(
"name" ) );
1571 if ( !items.contains( connectionName ) )
1573 child = child.nextSiblingElement();
1578 if ( keys.contains( connectionName ) && prompt )
1580 const int res = QMessageBox::warning(
this,
1581 tr(
"Loading Connections" ),
1582 tr(
"Connection with name '%1' already exists. Overwrite?" )
1583 .arg( connectionName ),
1584 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1588 case QMessageBox::Cancel:
1590 case QMessageBox::No:
1591 child = child.nextSiblingElement();
1593 case QMessageBox::Yes:
1596 case QMessageBox::YesToAll:
1600 case QMessageBox::NoToAll:
1607 if ( keys.contains( connectionName ) )
1611 child = child.nextSiblingElement();
1617 keys << connectionName;
1621 settings.
beginGroup(
"/qgis/connections-" + service.toLower() );
1622 settings.
setValue( QString(
'/' + connectionName +
"/url" ), child.attribute( QStringLiteral(
"url" ) ) );
1623 settings.
setValue( QString(
'/' + connectionName +
"/referer" ), child.attribute( QStringLiteral(
"referer" ) ) );
1626 settings.
beginGroup(
"/qgis/" + service.toUpper() +
'/' + connectionName );
1627 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
1628 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
1629 settings.
setValue( QStringLiteral(
"/authcfg" ), child.attribute( QStringLiteral(
"authcfg" ) ) );
1632 child = child.nextSiblingElement();
1636 void QgsManageConnectionsDialog::loadVectorTileConnections(
const QDomDocument &doc,
const QStringList &items )
1638 const QDomElement root = doc.documentElement();
1639 if ( root.tagName() != QLatin1String(
"qgsVectorTileConnections" ) )
1641 QMessageBox::information(
this, tr(
"Loading Connections" ),
1642 tr(
"The file is not a Vector Tile connections exchange file." ) );
1646 QString connectionName;
1648 settings.
beginGroup( QStringLiteral(
"/qgis/connections-vector-tile" ) );
1651 QDomElement child = root.firstChildElement();
1653 bool overwrite =
true;
1655 while ( !child.isNull() )
1657 connectionName = child.attribute( QStringLiteral(
"name" ) );
1658 if ( !items.contains( connectionName ) )
1660 child = child.nextSiblingElement();
1665 if ( keys.contains( connectionName ) && prompt )
1667 const int res = QMessageBox::warning(
this,
1668 tr(
"Loading Connections" ),
1669 tr(
"Connection with name '%1' already exists. Overwrite?" )
1670 .arg( connectionName ),
1671 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1675 case QMessageBox::Cancel:
1677 case QMessageBox::No:
1678 child = child.nextSiblingElement();
1680 case QMessageBox::Yes:
1683 case QMessageBox::YesToAll:
1687 case QMessageBox::NoToAll:
1694 if ( keys.contains( connectionName ) )
1698 child = child.nextSiblingElement();
1704 keys << connectionName;
1707 settings.
beginGroup(
"qgis/connections-vector-tile/" + connectionName );
1708 settings.
setValue( QStringLiteral(
"url" ), child.attribute( QStringLiteral(
"url" ) ) );
1709 settings.
setValue( QStringLiteral(
"zmin" ), child.attribute( QStringLiteral(
"zmin" ) ) );
1710 settings.
setValue( QStringLiteral(
"zmax" ), child.attribute( QStringLiteral(
"zmax" ) ) );
1711 settings.
setValue( QStringLiteral(
"serviceType" ), child.attribute( QStringLiteral(
"serviceType" ) ) );
1712 settings.
setValue( QStringLiteral(
"authcfg" ), child.attribute( QStringLiteral(
"authcfg" ) ) );
1713 settings.
setValue( QStringLiteral(
"username" ), child.attribute( QStringLiteral(
"username" ) ) );
1714 settings.
setValue( QStringLiteral(
"password" ), child.attribute( QStringLiteral(
"password" ) ) );
1715 settings.
setValue( QStringLiteral(
"referer" ), child.attribute( QStringLiteral(
"referer" ) ) );
1716 settings.
setValue( QStringLiteral(
"styleUrl" ), child.attribute( QStringLiteral(
"styleUrl" ) ) );
1720 child = child.nextSiblingElement();
1726 listConnections->selectAll();
1727 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( !listConnections->selectedItems().isEmpty() );
1732 listConnections->clearSelection();
1733 buttonBox->button( QDialogButtonBox::Ok )->setEnabled(
false );
QgsManageConnectionsDialog(QWidget *parent=nullptr, Mode mode=Export, Type type=WMS, const QString &fileName=QString())
Constructor for QgsManageConnectionsDialog.
This class is a composition of two QSettings instances:
QStringList childGroups() 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.