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 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 = saveDb2Connections( 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 loadDb2Connections( 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(
"/DB2/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 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(
"qgsDb2Connections" ) )
379 QMessageBox::information(
this, tr(
"Loading Connections" ),
380 tr(
"The file is not a DB2 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() );
527 el.setAttribute( QStringLiteral(
"saveUsername" ), settings.
value( path +
"/saveUsername",
"false" ).toString() );
529 if ( settings.
value( path +
"/saveUsername",
"false" ).toString() == QLatin1String(
"true" ) )
531 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path +
"/username" ).toString() );
534 el.setAttribute( QStringLiteral(
"savePassword" ), settings.
value( path +
"/savePassword",
"false" ).toString() );
536 if ( settings.
value( path +
"/savePassword",
"false" ).toString() == QLatin1String(
"true" ) )
538 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path +
"/password" ).toString() );
541 root.appendChild( el );
547 QDomDocument QgsManageConnectionsDialog::saveMssqlConnections(
const QStringList &connections )
549 QDomDocument doc( QStringLiteral(
"connections" ) );
550 QDomElement root = doc.createElement( QStringLiteral(
"qgsMssqlConnections" ) );
551 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
552 doc.appendChild( root );
556 for (
int i = 0; i < connections.count(); ++i )
558 path =
"/MSSQL/connections/" + connections[ i ];
559 QDomElement el = doc.createElement( QStringLiteral(
"mssql" ) );
560 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
561 el.setAttribute( QStringLiteral(
"host" ), settings.
value( path +
"/host" ).toString() );
562 el.setAttribute( QStringLiteral(
"port" ), settings.
value( path +
"/port" ).toString() );
563 el.setAttribute( QStringLiteral(
"database" ), settings.
value( path +
"/database" ).toString() );
564 el.setAttribute( QStringLiteral(
"service" ), settings.
value( path +
"/service" ).toString() );
565 el.setAttribute( QStringLiteral(
"sslmode" ), settings.
value( path +
"/sslmode",
"1" ).toString() );
566 el.setAttribute( QStringLiteral(
"estimatedMetadata" ), settings.
value( path +
"/estimatedMetadata",
"0" ).toString() );
568 el.setAttribute( QStringLiteral(
"saveUsername" ), settings.
value( path +
"/saveUsername",
"false" ).toString() );
570 if ( settings.
value( path +
"/saveUsername",
"false" ).toString() == QLatin1String(
"true" ) )
572 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path +
"/username" ).toString() );
575 el.setAttribute( QStringLiteral(
"savePassword" ), settings.
value( path +
"/savePassword",
"false" ).toString() );
577 if ( settings.
value( path +
"/savePassword",
"false" ).toString() == QLatin1String(
"true" ) )
579 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path +
"/password" ).toString() );
582 root.appendChild( el );
588 QDomDocument QgsManageConnectionsDialog::saveOracleConnections(
const QStringList &connections )
590 QDomDocument doc( QStringLiteral(
"connections" ) );
591 QDomElement root = doc.createElement( QStringLiteral(
"qgsOracleConnections" ) );
592 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
593 doc.appendChild( root );
597 for (
int i = 0; i < connections.count(); ++i )
599 path =
"/Oracle/connections/" + connections[ i ];
600 QDomElement el = doc.createElement( QStringLiteral(
"oracle" ) );
601 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
602 el.setAttribute( QStringLiteral(
"host" ), settings.
value( path +
"/host" ).toString() );
603 el.setAttribute( QStringLiteral(
"port" ), settings.
value( path +
"/port" ).toString() );
604 el.setAttribute( QStringLiteral(
"database" ), settings.
value( path +
"/database" ).toString() );
605 el.setAttribute( QStringLiteral(
"dboptions" ), settings.
value( path +
"/dboptions" ).toString() );
606 el.setAttribute( QStringLiteral(
"dbworkspace" ), settings.
value( path +
"/dbworkspace" ).toString() );
607 el.setAttribute( QStringLiteral(
"schema" ), settings.
value( path +
"/schema" ).toString() );
608 el.setAttribute( QStringLiteral(
"estimatedMetadata" ), settings.
value( path +
"/estimatedMetadata",
"0" ).toString() );
609 el.setAttribute( QStringLiteral(
"userTablesOnly" ), settings.
value( path +
"/userTablesOnly",
"0" ).toString() );
610 el.setAttribute( QStringLiteral(
"geometryColumnsOnly" ), settings.
value( path +
"/geometryColumnsOnly",
"0" ).toString() );
611 el.setAttribute( QStringLiteral(
"allowGeometrylessTables" ), settings.
value( path +
"/allowGeometrylessTables",
"0" ).toString() );
613 el.setAttribute( QStringLiteral(
"saveUsername" ), settings.
value( path +
"/saveUsername",
"false" ).toString() );
615 if ( settings.
value( path +
"/saveUsername",
"false" ).toString() == QLatin1String(
"true" ) )
617 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path +
"/username" ).toString() );
620 el.setAttribute( QStringLiteral(
"savePassword" ), settings.
value( path +
"/savePassword",
"false" ).toString() );
622 if ( settings.
value( path +
"/savePassword",
"false" ).toString() == QLatin1String(
"true" ) )
624 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path +
"/password" ).toString() );
627 root.appendChild( el );
633 QDomDocument QgsManageConnectionsDialog::saveDb2Connections(
const QStringList &connections )
635 QDomDocument doc( QStringLiteral(
"connections" ) );
636 QDomElement root = doc.createElement( QStringLiteral(
"qgsDb2Connections" ) );
637 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
638 doc.appendChild( root );
642 for (
int i = 0; i < connections.count(); ++i )
644 path =
"/DB2/connections/" + connections[ i ];
645 QDomElement el = doc.createElement( QStringLiteral(
"db2" ) );
646 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
647 el.setAttribute( QStringLiteral(
"host" ), settings.
value( path +
"/host" ).toString() );
648 el.setAttribute( QStringLiteral(
"port" ), settings.
value( path +
"/port" ).toString() );
649 el.setAttribute( QStringLiteral(
"database" ), settings.
value( path +
"/database" ).toString() );
650 el.setAttribute( QStringLiteral(
"service" ), settings.
value( path +
"/service" ).toString() );
651 el.setAttribute( QStringLiteral(
"sslmode" ), settings.
value( path +
"/sslmode",
"1" ).toString() );
652 el.setAttribute( QStringLiteral(
"estimatedMetadata" ), settings.
value( path +
"/estimatedMetadata",
"0" ).toString() );
654 el.setAttribute( QStringLiteral(
"saveUsername" ), settings.
value( path +
"/saveUsername",
"false" ).toString() );
656 if ( settings.
value( path +
"/saveUsername",
"false" ).toString() == QLatin1String(
"true" ) )
658 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path +
"/username" ).toString() );
661 el.setAttribute( QStringLiteral(
"savePassword" ), settings.
value( path +
"/savePassword",
"false" ).toString() );
663 if ( settings.
value( path +
"/savePassword",
"false" ).toString() == QLatin1String(
"true" ) )
665 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path +
"/password" ).toString() );
668 root.appendChild( el );
674 QDomDocument QgsManageConnectionsDialog::saveGeonodeConnections(
const QStringList &connections )
676 QDomDocument doc( QStringLiteral(
"connections" ) );
677 QDomElement root = doc.createElement( QStringLiteral(
"qgsGeoNodeConnections" ) );
678 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
679 doc.appendChild( root );
683 for (
int i = 0; i < connections.count(); ++i )
685 path = QStringLiteral(
"/qgis/connections-geonode/" );
686 QDomElement el = doc.createElement( QStringLiteral(
"geonode" ) );
687 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
688 el.setAttribute( QStringLiteral(
"url" ), settings.
value( path + connections[ i ] +
"/url" ).toString() );
690 path = QStringLiteral(
"/qgis/GeoNode/" );
691 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path + connections[ i ] +
"/username" ).toString() );
692 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path + connections[ i ] +
"/password" ).toString() );
693 root.appendChild( el );
699 QDomDocument QgsManageConnectionsDialog::saveXyzTilesConnections(
const QStringList &connections )
701 QDomDocument doc( QStringLiteral(
"connections" ) );
702 QDomElement root = doc.createElement( QStringLiteral(
"qgsXYZTilesConnections" ) );
703 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
704 doc.appendChild( root );
708 for (
int i = 0; i < connections.count(); ++i )
710 path =
"qgis/connections-xyz/" + connections[ i ];
711 QDomElement el = doc.createElement( QStringLiteral(
"xyztiles" ) );
713 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
714 el.setAttribute( QStringLiteral(
"url" ), settings.
value( path +
"/url" ).toString() );
715 el.setAttribute( QStringLiteral(
"zmin" ), settings.
value( path +
"/zmin", -1 ).toInt() );
716 el.setAttribute( QStringLiteral(
"zmax" ), settings.
value( path +
"/zmax", -1 ).toInt() );
717 el.setAttribute( QStringLiteral(
"authcfg" ), settings.
value( path +
"/authcfg" ).toString() );
718 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path +
"/username" ).toString() );
719 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path +
"/password" ).toString() );
720 el.setAttribute( QStringLiteral(
"referer" ), settings.
value( path +
"/referer" ).toString() );
721 el.setAttribute( QStringLiteral(
"tilePixelRatio" ), settings.
value( path +
"/tilePixelRatio", 0 ).toDouble() );
723 root.appendChild( el );
729 QDomDocument QgsManageConnectionsDialog::saveArcgisConnections(
const QStringList &connections,
const QString &service )
731 QDomDocument doc( QStringLiteral(
"connections" ) );
732 QDomElement root = doc.createElement(
"qgs" + service.toUpper() +
"Connections" );
733 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
734 doc.appendChild( root );
738 for (
int i = 0; i < connections.count(); ++i )
740 path =
"/qgis/connections-" + service.toLower() +
'/';
741 QDomElement el = doc.createElement( service.toLower() );
742 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
743 el.setAttribute( QStringLiteral(
"url" ), settings.
value( path + connections[ i ] +
"/url" ).toString() );
744 el.setAttribute( QStringLiteral(
"referer" ), settings.
value( path + connections[ i ] +
"/referer" ).toString() );
746 path =
"/qgis/" + service.toUpper() +
'/';
747 el.setAttribute( QStringLiteral(
"username" ), settings.
value( path + connections[ i ] +
"/username" ).toString() );
748 el.setAttribute( QStringLiteral(
"password" ), settings.
value( path + connections[ i ] +
"/password" ).toString() );
749 el.setAttribute( QStringLiteral(
"authcfg" ), settings.
value( path + connections[ i ] +
"/authcfg" ).toString() );
750 root.appendChild( el );
756 QDomDocument QgsManageConnectionsDialog::saveVectorTileConnections(
const QStringList &connections )
758 QDomDocument doc( QStringLiteral(
"connections" ) );
759 QDomElement root = doc.createElement( QStringLiteral(
"qgsVectorTileConnections" ) );
760 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
761 doc.appendChild( root );
765 for (
int i = 0; i < connections.count(); ++i )
767 path =
"qgis/connections-vector-tile/" + connections[ i ];
768 QDomElement el = doc.createElement( QStringLiteral(
"vectortile" ) );
770 el.setAttribute( QStringLiteral(
"name" ), connections[ i ] );
771 el.setAttribute( QStringLiteral(
"url" ), settings.
value( path +
"/url" ).toString() );
772 el.setAttribute( QStringLiteral(
"zmin" ), settings.
value( path +
"/zmin", -1 ).toInt() );
773 el.setAttribute( QStringLiteral(
"zmax" ), settings.
value( path +
"/zmax", -1 ).toInt() );
775 root.appendChild( el );
781 void QgsManageConnectionsDialog::loadOWSConnections(
const QDomDocument &doc,
const QStringList &items,
const QString &service )
783 QDomElement root = doc.documentElement();
784 if ( root.tagName() !=
"qgs" + service.toUpper() +
"Connections" )
786 QMessageBox::information(
this, tr(
"Loading Connections" ),
787 tr(
"The file is not a %1 connections exchange file." ).arg( service ) );
791 QString connectionName;
793 settings.
beginGroup(
"/qgis/connections-" + service.toLower() );
796 QDomElement child = root.firstChildElement();
798 bool overwrite =
true;
800 while ( !child.isNull() )
802 connectionName = child.attribute( QStringLiteral(
"name" ) );
803 if ( !items.contains( connectionName ) )
805 child = child.nextSiblingElement();
810 if ( keys.contains( connectionName ) && prompt )
812 int res = QMessageBox::warning(
this,
813 tr(
"Loading Connections" ),
814 tr(
"Connection with name '%1' already exists. Overwrite?" )
815 .arg( connectionName ),
816 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
820 case QMessageBox::Cancel:
822 case QMessageBox::No:
823 child = child.nextSiblingElement();
825 case QMessageBox::Yes:
828 case QMessageBox::YesToAll:
832 case QMessageBox::NoToAll:
839 if ( keys.contains( connectionName ) && !overwrite )
841 child = child.nextSiblingElement();
846 settings.
beginGroup(
"/qgis/connections-" + service.toLower() );
847 settings.
setValue( QString(
'/' + connectionName +
"/url" ), child.attribute( QStringLiteral(
"url" ) ) );
848 settings.
setValue( QString(
'/' + connectionName +
"/ignoreGetMapURI" ), child.attribute( QStringLiteral(
"ignoreGetMapURI" ) ) == QLatin1String(
"true" ) );
849 settings.
setValue( QString(
'/' + connectionName +
"/ignoreGetFeatureInfoURI" ), child.attribute( QStringLiteral(
"ignoreGetFeatureInfoURI" ) ) == QLatin1String(
"true" ) );
850 settings.
setValue( QString(
'/' + connectionName +
"/ignoreAxisOrientation" ), child.attribute( QStringLiteral(
"ignoreAxisOrientation" ) ) == QLatin1String(
"true" ) );
851 settings.
setValue( QString(
'/' + connectionName +
"/invertAxisOrientation" ), child.attribute( QStringLiteral(
"invertAxisOrientation" ) ) == QLatin1String(
"true" ) );
852 settings.
setValue( QString(
'/' + connectionName +
"/referer" ), child.attribute( QStringLiteral(
"referer" ) ) );
853 settings.
setValue( QString(
'/' + connectionName +
"/smoothPixmapTransform" ), child.attribute( QStringLiteral(
"smoothPixmapTransform" ) ) == QLatin1String(
"true" ) );
854 settings.
setValue( QString(
'/' + connectionName +
"/dpiMode" ), child.attribute( QStringLiteral(
"dpiMode" ), QStringLiteral(
"7" ) ).toInt() );
857 if ( !child.attribute( QStringLiteral(
"username" ) ).isEmpty() )
859 settings.
beginGroup(
"/qgis/" + service.toUpper() +
'/' + connectionName );
860 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
861 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
864 child = child.nextSiblingElement();
868 void QgsManageConnectionsDialog::loadWfsConnections(
const QDomDocument &doc,
const QStringList &items )
870 QDomElement root = doc.documentElement();
871 if ( root.tagName() != QLatin1String(
"qgsWFSConnections" ) )
873 QMessageBox::information(
this, tr(
"Loading Connections" ),
874 tr(
"The file is not a WFS connections exchange file." ) );
878 QString connectionName;
880 settings.
beginGroup( QStringLiteral(
"/qgis/connections-wfs" ) );
883 QDomElement child = root.firstChildElement();
885 bool overwrite =
true;
887 while ( !child.isNull() )
889 connectionName = child.attribute( QStringLiteral(
"name" ) );
890 if ( !items.contains( connectionName ) )
892 child = child.nextSiblingElement();
897 if ( keys.contains( connectionName ) && prompt )
899 int res = QMessageBox::warning(
this,
900 tr(
"Loading Connections" ),
901 tr(
"Connection with name '%1' already exists. Overwrite?" )
902 .arg( connectionName ),
903 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
907 case QMessageBox::Cancel:
909 case QMessageBox::No:
910 child = child.nextSiblingElement();
912 case QMessageBox::Yes:
915 case QMessageBox::YesToAll:
919 case QMessageBox::NoToAll:
926 if ( keys.contains( connectionName ) && !overwrite )
928 child = child.nextSiblingElement();
933 settings.
beginGroup( QStringLiteral(
"/qgis/connections-wfs" ) );
934 settings.
setValue( QString(
'/' + connectionName +
"/url" ), child.attribute( QStringLiteral(
"url" ) ) );
936 settings.
setValue( QString(
'/' + connectionName +
"/version" ), child.attribute( QStringLiteral(
"version" ) ) );
937 settings.
setValue( QString(
'/' + connectionName +
"/maxnumfeatures" ), child.attribute( QStringLiteral(
"maxnumfeatures" ) ) );
938 settings.
setValue( QString(
'/' + connectionName +
"/pagesize" ), child.attribute( QStringLiteral(
"pagesize" ) ) );
939 settings.
setValue( QString(
'/' + connectionName +
"/pagingenabled" ), child.attribute( QStringLiteral(
"pagingenabled" ) ) );
940 settings.
setValue( QString(
'/' + connectionName +
"/ignoreAxisOrientation" ), child.attribute( QStringLiteral(
"ignoreAxisOrientation" ) ) );
941 settings.
setValue( QString(
'/' + connectionName +
"/invertAxisOrientation" ), child.attribute( QStringLiteral(
"invertAxisOrientation" ) ) );
944 if ( !child.attribute( QStringLiteral(
"username" ) ).isEmpty() )
946 settings.
beginGroup(
"/qgis/WFS/" + connectionName );
947 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
948 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
951 child = child.nextSiblingElement();
955 void QgsManageConnectionsDialog::loadPgConnections(
const QDomDocument &doc,
const QStringList &items )
957 QDomElement root = doc.documentElement();
958 if ( root.tagName() != QLatin1String(
"qgsPgConnections" ) )
960 QMessageBox::information(
this,
961 tr(
"Loading Connections" ),
962 tr(
"The file is not a PostGIS connections exchange file." ) );
966 QString connectionName;
968 settings.
beginGroup( QStringLiteral(
"/PostgreSQL/connections" ) );
971 QDomElement child = root.firstChildElement();
973 bool overwrite =
true;
975 while ( !child.isNull() )
977 connectionName = child.attribute( QStringLiteral(
"name" ) );
978 if ( !items.contains( connectionName ) )
980 child = child.nextSiblingElement();
985 if ( keys.contains( connectionName ) && prompt )
987 int res = QMessageBox::warning(
this,
988 tr(
"Loading Connections" ),
989 tr(
"Connection with name '%1' already exists. Overwrite?" )
990 .arg( connectionName ),
991 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
994 case QMessageBox::Cancel:
996 case QMessageBox::No:
997 child = child.nextSiblingElement();
999 case QMessageBox::Yes:
1002 case QMessageBox::YesToAll:
1006 case QMessageBox::NoToAll:
1013 if ( keys.contains( connectionName ) && !overwrite )
1015 child = child.nextSiblingElement();
1020 settings.
beginGroup(
"/PostgreSQL/connections/" + connectionName );
1022 settings.
setValue( QStringLiteral(
"/host" ), child.attribute( QStringLiteral(
"host" ) ) );
1023 settings.
setValue( QStringLiteral(
"/port" ), child.attribute( QStringLiteral(
"port" ) ) );
1024 settings.
setValue( QStringLiteral(
"/database" ), child.attribute( QStringLiteral(
"database" ) ) );
1025 if ( child.hasAttribute( QStringLiteral(
"service" ) ) )
1027 settings.
setValue( QStringLiteral(
"/service" ), child.attribute( QStringLiteral(
"service" ) ) );
1031 settings.
setValue( QStringLiteral(
"/service" ),
"" );
1033 settings.
setValue( QStringLiteral(
"/sslmode" ), child.attribute( QStringLiteral(
"sslmode" ) ) );
1034 settings.
setValue( QStringLiteral(
"/estimatedMetadata" ), child.attribute( QStringLiteral(
"estimatedMetadata" ) ) );
1035 settings.
setValue( QStringLiteral(
"/saveUsername" ), child.attribute( QStringLiteral(
"saveUsername" ) ) );
1036 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
1037 settings.
setValue( QStringLiteral(
"/savePassword" ), child.attribute( QStringLiteral(
"savePassword" ) ) );
1038 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
1041 child = child.nextSiblingElement();
1045 void QgsManageConnectionsDialog::loadMssqlConnections(
const QDomDocument &doc,
const QStringList &items )
1047 QDomElement root = doc.documentElement();
1048 if ( root.tagName() != QLatin1String(
"qgsMssqlConnections" ) )
1050 QMessageBox::information(
this,
1051 tr(
"Loading Connections" ),
1052 tr(
"The file is not a MSSQL connections exchange file." ) );
1056 QString connectionName;
1058 settings.
beginGroup( QStringLiteral(
"/MSSQL/connections" ) );
1061 QDomElement child = root.firstChildElement();
1063 bool overwrite =
true;
1065 while ( !child.isNull() )
1067 connectionName = child.attribute( QStringLiteral(
"name" ) );
1068 if ( !items.contains( connectionName ) )
1070 child = child.nextSiblingElement();
1075 if ( keys.contains( connectionName ) && prompt )
1077 int res = QMessageBox::warning(
this,
1078 tr(
"Loading Connections" ),
1079 tr(
"Connection with name '%1' already exists. Overwrite?" )
1080 .arg( connectionName ),
1081 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1084 case QMessageBox::Cancel:
1086 case QMessageBox::No:
1087 child = child.nextSiblingElement();
1089 case QMessageBox::Yes:
1092 case QMessageBox::YesToAll:
1096 case QMessageBox::NoToAll:
1103 if ( keys.contains( connectionName ) && !overwrite )
1105 child = child.nextSiblingElement();
1110 settings.
beginGroup(
"/MSSQL/connections/" + connectionName );
1112 settings.
setValue( QStringLiteral(
"/host" ), child.attribute( QStringLiteral(
"host" ) ) );
1113 settings.
setValue( QStringLiteral(
"/port" ), child.attribute( QStringLiteral(
"port" ) ) );
1114 settings.
setValue( QStringLiteral(
"/database" ), child.attribute( QStringLiteral(
"database" ) ) );
1115 if ( child.hasAttribute( QStringLiteral(
"service" ) ) )
1117 settings.
setValue( QStringLiteral(
"/service" ), child.attribute( QStringLiteral(
"service" ) ) );
1121 settings.
setValue( QStringLiteral(
"/service" ),
"" );
1123 settings.
setValue( QStringLiteral(
"/sslmode" ), child.attribute( QStringLiteral(
"sslmode" ) ) );
1124 settings.
setValue( QStringLiteral(
"/estimatedMetadata" ), child.attribute( QStringLiteral(
"estimatedMetadata" ) ) );
1125 settings.
setValue( QStringLiteral(
"/saveUsername" ), child.attribute( QStringLiteral(
"saveUsername" ) ) );
1126 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
1127 settings.
setValue( QStringLiteral(
"/savePassword" ), child.attribute( QStringLiteral(
"savePassword" ) ) );
1128 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
1131 child = child.nextSiblingElement();
1135 void QgsManageConnectionsDialog::loadOracleConnections(
const QDomDocument &doc,
const QStringList &items )
1137 QDomElement root = doc.documentElement();
1138 if ( root.tagName() != QLatin1String(
"qgsOracleConnections" ) )
1140 QMessageBox::information(
this,
1141 tr(
"Loading Connections" ),
1142 tr(
"The file is not an Oracle connections exchange file." ) );
1146 QString connectionName;
1148 settings.
beginGroup( QStringLiteral(
"/Oracle/connections" ) );
1151 QDomElement child = root.firstChildElement();
1153 bool overwrite =
true;
1155 while ( !child.isNull() )
1157 connectionName = child.attribute( QStringLiteral(
"name" ) );
1158 if ( !items.contains( connectionName ) )
1160 child = child.nextSiblingElement();
1165 if ( keys.contains( connectionName ) && prompt )
1167 int res = QMessageBox::warning(
this,
1168 tr(
"Loading Connections" ),
1169 tr(
"Connection with name '%1' already exists. Overwrite?" )
1170 .arg( connectionName ),
1171 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1174 case QMessageBox::Cancel:
1176 case QMessageBox::No:
1177 child = child.nextSiblingElement();
1179 case QMessageBox::Yes:
1182 case QMessageBox::YesToAll:
1186 case QMessageBox::NoToAll:
1193 if ( keys.contains( connectionName ) && !overwrite )
1195 child = child.nextSiblingElement();
1200 settings.
beginGroup(
"/Oracle/connections/" + connectionName );
1202 settings.
setValue( QStringLiteral(
"/host" ), child.attribute( QStringLiteral(
"host" ) ) );
1203 settings.
setValue( QStringLiteral(
"/port" ), child.attribute( QStringLiteral(
"port" ) ) );
1204 settings.
setValue( QStringLiteral(
"/database" ), child.attribute( QStringLiteral(
"database" ) ) );
1205 settings.
setValue( QStringLiteral(
"/dboptions" ), child.attribute( QStringLiteral(
"dboptions" ) ) );
1206 settings.
setValue( QStringLiteral(
"/dbworkspace" ), child.attribute( QStringLiteral(
"dbworkspace" ) ) );
1207 settings.
setValue( QStringLiteral(
"/schema" ), child.attribute( QStringLiteral(
"schema" ) ) );
1208 settings.
setValue( QStringLiteral(
"/estimatedMetadata" ), child.attribute( QStringLiteral(
"estimatedMetadata" ) ) );
1209 settings.
setValue( QStringLiteral(
"/userTablesOnly" ), child.attribute( QStringLiteral(
"userTablesOnly" ) ) );
1210 settings.
setValue( QStringLiteral(
"/geometryColumnsOnly" ), child.attribute( QStringLiteral(
"geometryColumnsOnly" ) ) );
1211 settings.
setValue( QStringLiteral(
"/allowGeometrylessTables" ), child.attribute( QStringLiteral(
"allowGeometrylessTables" ) ) );
1212 settings.
setValue( QStringLiteral(
"/saveUsername" ), child.attribute( QStringLiteral(
"saveUsername" ) ) );
1213 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
1214 settings.
setValue( QStringLiteral(
"/savePassword" ), child.attribute( QStringLiteral(
"savePassword" ) ) );
1215 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
1218 child = child.nextSiblingElement();
1222 void QgsManageConnectionsDialog::loadDb2Connections(
const QDomDocument &doc,
const QStringList &items )
1224 QDomElement root = doc.documentElement();
1225 if ( root.tagName() != QLatin1String(
"qgsDb2Connections" ) )
1227 QMessageBox::information(
this,
1228 tr(
"Loading Connections" ),
1229 tr(
"The file is not a DB2 connections exchange file." ) );
1233 QString connectionName;
1235 settings.
beginGroup( QStringLiteral(
"/DB2/connections" ) );
1238 QDomElement child = root.firstChildElement();
1240 bool overwrite =
true;
1242 while ( !child.isNull() )
1244 connectionName = child.attribute( QStringLiteral(
"name" ) );
1245 if ( !items.contains( connectionName ) )
1247 child = child.nextSiblingElement();
1252 if ( keys.contains( connectionName ) && prompt )
1254 int res = QMessageBox::warning(
this,
1255 tr(
"Loading Connections" ),
1256 tr(
"Connection with name '%1' already exists. Overwrite?" )
1257 .arg( connectionName ),
1258 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1261 case QMessageBox::Cancel:
1263 case QMessageBox::No:
1264 child = child.nextSiblingElement();
1266 case QMessageBox::Yes:
1269 case QMessageBox::YesToAll:
1273 case QMessageBox::NoToAll:
1280 if ( keys.contains( connectionName ) && !overwrite )
1282 child = child.nextSiblingElement();
1287 settings.
beginGroup(
"/DB2/connections/" + connectionName );
1289 settings.
setValue( QStringLiteral(
"/host" ), child.attribute( QStringLiteral(
"host" ) ) );
1290 settings.
setValue( QStringLiteral(
"/port" ), child.attribute( QStringLiteral(
"port" ) ) );
1291 settings.
setValue( QStringLiteral(
"/database" ), child.attribute( QStringLiteral(
"database" ) ) );
1292 if ( child.hasAttribute( QStringLiteral(
"service" ) ) )
1294 settings.
setValue( QStringLiteral(
"/service" ), child.attribute( QStringLiteral(
"service" ) ) );
1298 settings.
setValue( QStringLiteral(
"/service" ),
"" );
1300 settings.
setValue( QStringLiteral(
"/sslmode" ), child.attribute( QStringLiteral(
"sslmode" ) ) );
1301 settings.
setValue( QStringLiteral(
"/estimatedMetadata" ), child.attribute( QStringLiteral(
"estimatedMetadata" ) ) );
1302 settings.
setValue( QStringLiteral(
"/saveUsername" ), child.attribute( QStringLiteral(
"saveUsername" ) ) );
1303 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
1304 settings.
setValue( QStringLiteral(
"/savePassword" ), child.attribute( QStringLiteral(
"savePassword" ) ) );
1305 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
1308 child = child.nextSiblingElement();
1312 void QgsManageConnectionsDialog::loadGeonodeConnections(
const QDomDocument &doc,
const QStringList &items )
1314 QDomElement root = doc.documentElement();
1315 if ( root.tagName() != QLatin1String(
"qgsGeoNodeConnections" ) )
1317 QMessageBox::information(
this, tr(
"Loading Connections" ),
1318 tr(
"The file is not a GeoNode connections exchange file." ) );
1322 QString connectionName;
1324 settings.
beginGroup( QStringLiteral(
"/qgis/connections-geonode" ) );
1327 QDomElement child = root.firstChildElement();
1329 bool overwrite =
true;
1331 while ( !child.isNull() )
1333 connectionName = child.attribute( QStringLiteral(
"name" ) );
1334 if ( !items.contains( connectionName ) )
1336 child = child.nextSiblingElement();
1341 if ( keys.contains( connectionName ) && prompt )
1343 int res = QMessageBox::warning(
this,
1344 tr(
"Loading Connections" ),
1345 tr(
"Connection with name '%1' already exists. Overwrite?" )
1346 .arg( connectionName ),
1347 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1351 case QMessageBox::Cancel:
1353 case QMessageBox::No:
1354 child = child.nextSiblingElement();
1356 case QMessageBox::Yes:
1359 case QMessageBox::YesToAll:
1363 case QMessageBox::NoToAll:
1370 if ( keys.contains( connectionName ) && !overwrite )
1372 child = child.nextSiblingElement();
1377 settings.
beginGroup( QStringLiteral(
"/qgis/connections-geonode" ) );
1378 settings.
setValue( QString(
'/' + connectionName +
"/url" ), child.attribute( QStringLiteral(
"url" ) ) );
1381 if ( !child.attribute( QStringLiteral(
"username" ) ).isEmpty() )
1383 settings.
beginGroup(
"/qgis/GeoNode/" + connectionName );
1384 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
1385 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
1388 child = child.nextSiblingElement();
1392 void QgsManageConnectionsDialog::loadXyzTilesConnections(
const QDomDocument &doc,
const QStringList &items )
1394 QDomElement root = doc.documentElement();
1395 if ( root.tagName() != QLatin1String(
"qgsXYZTilesConnections" ) )
1397 QMessageBox::information(
this, tr(
"Loading Connections" ),
1398 tr(
"The file is not a XYZ Tiles connections exchange file." ) );
1402 QString connectionName;
1404 settings.
beginGroup( QStringLiteral(
"/qgis/connections-xyz" ) );
1407 QDomElement child = root.firstChildElement();
1409 bool overwrite =
true;
1411 while ( !child.isNull() )
1413 connectionName = child.attribute( QStringLiteral(
"name" ) );
1414 if ( !items.contains( connectionName ) )
1416 child = child.nextSiblingElement();
1421 if ( keys.contains( connectionName ) && prompt )
1423 int res = QMessageBox::warning(
this,
1424 tr(
"Loading Connections" ),
1425 tr(
"Connection with name '%1' already exists. Overwrite?" )
1426 .arg( connectionName ),
1427 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1431 case QMessageBox::Cancel:
1433 case QMessageBox::No:
1434 child = child.nextSiblingElement();
1436 case QMessageBox::Yes:
1439 case QMessageBox::YesToAll:
1443 case QMessageBox::NoToAll:
1450 if ( keys.contains( connectionName ) && !overwrite )
1452 child = child.nextSiblingElement();
1456 settings.
beginGroup(
"qgis/connections-xyz/" + connectionName );
1457 settings.
setValue( QStringLiteral(
"url" ), child.attribute( QStringLiteral(
"url" ) ) );
1458 settings.
setValue( QStringLiteral(
"zmin" ), child.attribute( QStringLiteral(
"zmin" ) ) );
1459 settings.
setValue( QStringLiteral(
"zmax" ), child.attribute( QStringLiteral(
"zmax" ) ) );
1460 settings.
setValue( QStringLiteral(
"authcfg" ), child.attribute( QStringLiteral(
"authcfg" ) ) );
1461 settings.
setValue( QStringLiteral(
"username" ), child.attribute( QStringLiteral(
"username" ) ) );
1462 settings.
setValue( QStringLiteral(
"password" ), child.attribute( QStringLiteral(
"password" ) ) );
1463 settings.
setValue( QStringLiteral(
"referer" ), child.attribute( QStringLiteral(
"referer" ) ) );
1464 settings.
setValue( QStringLiteral(
"tilePixelRatio" ), child.attribute( QStringLiteral(
"tilePixelRatio" ) ) );
1467 child = child.nextSiblingElement();
1471 void QgsManageConnectionsDialog::loadArcgisConnections(
const QDomDocument &doc,
const QStringList &items,
const QString &service )
1473 QDomElement root = doc.documentElement();
1474 if ( root.tagName() !=
"qgs" + service.toUpper() +
"Connections" )
1476 QMessageBox::information(
this, tr(
"Loading Connections" ),
1477 tr(
"The file is not a %1 connections exchange file." ).arg( service ) );
1481 QString connectionName;
1483 settings.
beginGroup(
"/qgis/connections-" + service.toLower() );
1486 QDomElement child = root.firstChildElement();
1488 bool overwrite =
true;
1490 while ( !child.isNull() )
1492 connectionName = child.attribute( QStringLiteral(
"name" ) );
1493 if ( !items.contains( connectionName ) )
1495 child = child.nextSiblingElement();
1500 if ( keys.contains( connectionName ) && prompt )
1502 int res = QMessageBox::warning(
this,
1503 tr(
"Loading Connections" ),
1504 tr(
"Connection with name '%1' already exists. Overwrite?" )
1505 .arg( connectionName ),
1506 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1510 case QMessageBox::Cancel:
1512 case QMessageBox::No:
1513 child = child.nextSiblingElement();
1515 case QMessageBox::Yes:
1518 case QMessageBox::YesToAll:
1522 case QMessageBox::NoToAll:
1529 if ( keys.contains( connectionName ) && !overwrite )
1531 child = child.nextSiblingElement();
1536 settings.
beginGroup(
"/qgis/connections-" + service.toLower() );
1537 settings.
setValue( QString(
'/' + connectionName +
"/url" ), child.attribute( QStringLiteral(
"url" ) ) );
1538 settings.
setValue( QString(
'/' + connectionName +
"/referer" ), child.attribute( QStringLiteral(
"referer" ) ) );
1541 settings.
beginGroup(
"/qgis/" + service.toUpper() +
'/' + connectionName );
1542 settings.
setValue( QStringLiteral(
"/username" ), child.attribute( QStringLiteral(
"username" ) ) );
1543 settings.
setValue( QStringLiteral(
"/password" ), child.attribute( QStringLiteral(
"password" ) ) );
1544 settings.
setValue( QStringLiteral(
"/authcfg" ), child.attribute( QStringLiteral(
"authcfg" ) ) );
1547 child = child.nextSiblingElement();
1551 void QgsManageConnectionsDialog::loadVectorTileConnections(
const QDomDocument &doc,
const QStringList &items )
1553 QDomElement root = doc.documentElement();
1554 if ( root.tagName() != QLatin1String(
"qgsVectorTileConnections" ) )
1556 QMessageBox::information(
this, tr(
"Loading Connections" ),
1557 tr(
"The file is not a Vector Tile connections exchange file." ) );
1561 QString connectionName;
1563 settings.
beginGroup( QStringLiteral(
"/qgis/connections-vector-tile" ) );
1566 QDomElement child = root.firstChildElement();
1568 bool overwrite =
true;
1570 while ( !child.isNull() )
1572 connectionName = child.attribute( QStringLiteral(
"name" ) );
1573 if ( !items.contains( connectionName ) )
1575 child = child.nextSiblingElement();
1580 if ( keys.contains( connectionName ) && prompt )
1582 int res = QMessageBox::warning(
this,
1583 tr(
"Loading Connections" ),
1584 tr(
"Connection with name '%1' already exists. Overwrite?" )
1585 .arg( connectionName ),
1586 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1590 case QMessageBox::Cancel:
1592 case QMessageBox::No:
1593 child = child.nextSiblingElement();
1595 case QMessageBox::Yes:
1598 case QMessageBox::YesToAll:
1602 case QMessageBox::NoToAll:
1609 if ( keys.contains( connectionName ) && !overwrite )
1611 child = child.nextSiblingElement();
1615 settings.
beginGroup(
"qgis/connections-vector-tile/" + connectionName );
1616 settings.
setValue( QStringLiteral(
"url" ), child.attribute( QStringLiteral(
"url" ) ) );
1617 settings.
setValue( QStringLiteral(
"zmin" ), child.attribute( QStringLiteral(
"zmin" ) ) );
1618 settings.
setValue( QStringLiteral(
"zmax" ), child.attribute( QStringLiteral(
"zmax" ) ) );
1621 child = child.nextSiblingElement();
1627 listConnections->selectAll();
1628 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( !listConnections->selectedItems().isEmpty() );
1633 listConnections->clearSelection();
1634 buttonBox->button( QDialogButtonBox::Ok )->setEnabled(
false );