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( 
"smoothPixmapTransform" ), settings.
value( path + connections[i] + 
"/smoothPixmapTransform", 
false ).toBool() ? 
"true" : 
"false" );
 
  461       el.setAttribute( QStringLiteral( 
"dpiMode" ), settings.
value( path + connections[i] + 
"/dpiMode", 
"7" ).toInt() );
 
  464       httpHeader.updateDomElement( el );
 
  467     path = 
"/qgis/" + service.toUpper() + 
'/';
 
  468     el.setAttribute( QStringLiteral( 
"username" ), settings.
value( path + connections[ i ] + 
"/username" ).toString() );
 
  469     el.setAttribute( QStringLiteral( 
"password" ), settings.
value( path + connections[ i ] + 
"/password" ).toString() );
 
  470     root.appendChild( el );
 
  476 QDomDocument QgsManageConnectionsDialog::saveWfsConnections( 
const QStringList &connections )
 
  478   QDomDocument doc( QStringLiteral( 
"connections" ) );
 
  479   QDomElement root = doc.createElement( QStringLiteral( 
"qgsWFSConnections" ) );
 
  480   root.setAttribute( QStringLiteral( 
"version" ), QStringLiteral( 
"1.1" ) );
 
  481   doc.appendChild( root );
 
  485   for ( 
int i = 0; i < connections.count(); ++i )
 
  487     path = QStringLiteral( 
"/qgis/connections-wfs/" );
 
  488     QDomElement el = doc.createElement( QStringLiteral( 
"wfs" ) );
 
  489     el.setAttribute( QStringLiteral( 
"name" ), connections[ i ] );
 
  490     el.setAttribute( QStringLiteral( 
"url" ), settings.
value( path + connections[ i ] + 
"/url" ).toString() );
 
  492     el.setAttribute( QStringLiteral( 
"version" ), settings.
value( path + connections[ i ] + 
"/version" ).toString() );
 
  493     el.setAttribute( QStringLiteral( 
"maxnumfeatures" ), settings.
value( path + connections[ i ] + 
"/maxnumfeatures" ).toString() );
 
  494     el.setAttribute( QStringLiteral( 
"pagesize" ), settings.
value( path + connections[ i ] + 
"/pagesize" ).toString() );
 
  495     el.setAttribute( QStringLiteral( 
"pagingenabled" ), settings.
value( path + connections[ i ] + 
"/pagingenabled", 
false ).toString() );
 
  496     el.setAttribute( QStringLiteral( 
"ignoreAxisOrientation" ), settings.
value( path + connections[ i ] + 
"/ignoreAxisOrientation", 
false ).toString() );
 
  497     el.setAttribute( QStringLiteral( 
"invertAxisOrientation" ), settings.
value( path + connections[ i ] + 
"/invertAxisOrientation", 
false ).toString() );
 
  499     path = QStringLiteral( 
"/qgis/WFS/" );
 
  500     el.setAttribute( QStringLiteral( 
"username" ), settings.
value( path + connections[ i ] + 
"/username" ).toString() );
 
  501     el.setAttribute( QStringLiteral( 
"password" ), settings.
value( path + connections[ i ] + 
"/password" ).toString() );
 
  502     root.appendChild( el );
 
  508 QDomDocument QgsManageConnectionsDialog::savePgConnections( 
const QStringList &connections )
 
  510   QDomDocument doc( QStringLiteral( 
"connections" ) );
 
  511   QDomElement root = doc.createElement( QStringLiteral( 
"qgsPgConnections" ) );
 
  512   root.setAttribute( QStringLiteral( 
"version" ), QStringLiteral( 
"1.0" ) );
 
  513   doc.appendChild( root );
 
  517   for ( 
int i = 0; i < connections.count(); ++i )
 
  519     path = 
"/PostgreSQL/connections/" + connections[ i ];
 
  520     QDomElement el = doc.createElement( QStringLiteral( 
"postgis" ) );
 
  521     el.setAttribute( QStringLiteral( 
"name" ), connections[ i ] );
 
  522     el.setAttribute( QStringLiteral( 
"host" ), settings.
value( path + 
"/host" ).toString() );
 
  523     el.setAttribute( QStringLiteral( 
"port" ), settings.
value( path + 
"/port" ).toString() );
 
  524     el.setAttribute( QStringLiteral( 
"database" ), settings.
value( path + 
"/database" ).toString() );
 
  525     el.setAttribute( QStringLiteral( 
"service" ), settings.
value( path + 
"/service" ).toString() );
 
  526     el.setAttribute( QStringLiteral( 
"sslmode" ), settings.
value( path + 
"/sslmode", 
"1" ).toString() );
 
  527     el.setAttribute( QStringLiteral( 
"estimatedMetadata" ), settings.
value( path + 
"/estimatedMetadata", 
"0" ).toString() );
 
  528     el.setAttribute( QStringLiteral( 
"projectsInDatabase" ), settings.
value( path + 
"/projectsInDatabase", 
"0" ).toString() );
 
  529     el.setAttribute( QStringLiteral( 
"dontResolveType" ), settings.
value( path + 
"/dontResolveType", 
"0" ).toString() );
 
  530     el.setAttribute( QStringLiteral( 
"allowGeometrylessTables" ), settings.
value( path + 
"/allowGeometrylessTables", 
"0" ).toString() );
 
  531     el.setAttribute( QStringLiteral( 
"geometryColumnsOnly" ), settings.
value( path + 
"/geometryColumnsOnly", 
"0" ).toString() );
 
  532     el.setAttribute( QStringLiteral( 
"publicOnly" ), settings.
value( path + 
"/publicOnly", 
"0" ).toString() );
 
  534     el.setAttribute( QStringLiteral( 
"saveUsername" ), settings.
value( path + 
"/saveUsername", 
"false" ).toString() );
 
  536     if ( settings.
value( path + 
"/saveUsername", 
"false" ).toString() == QLatin1String( 
"true" ) )
 
  538       el.setAttribute( QStringLiteral( 
"username" ), settings.
value( path + 
"/username" ).toString() );
 
  541     el.setAttribute( QStringLiteral( 
"savePassword" ), settings.
value( path + 
"/savePassword", 
"false" ).toString() );
 
  543     if ( settings.
value( path + 
"/savePassword", 
"false" ).toString() == QLatin1String( 
"true" ) )
 
  545       el.setAttribute( QStringLiteral( 
"password" ), settings.
value( path + 
"/password" ).toString() );
 
  548     root.appendChild( el );
 
  554 QDomDocument QgsManageConnectionsDialog::saveMssqlConnections( 
const QStringList &connections )
 
  556   QDomDocument doc( QStringLiteral( 
"connections" ) );
 
  557   QDomElement root = doc.createElement( QStringLiteral( 
"qgsMssqlConnections" ) );
 
  558   root.setAttribute( QStringLiteral( 
"version" ), QStringLiteral( 
"1.0" ) );
 
  559   doc.appendChild( root );
 
  563   for ( 
int i = 0; i < connections.count(); ++i )
 
  565     path = 
"/MSSQL/connections/" + connections[ i ];
 
  566     QDomElement el = doc.createElement( QStringLiteral( 
"mssql" ) );
 
  567     el.setAttribute( QStringLiteral( 
"name" ), connections[ i ] );
 
  568     el.setAttribute( QStringLiteral( 
"host" ), settings.
value( path + 
"/host" ).toString() );
 
  569     el.setAttribute( QStringLiteral( 
"port" ), settings.
value( path + 
"/port" ).toString() );
 
  570     el.setAttribute( QStringLiteral( 
"database" ), settings.
value( path + 
"/database" ).toString() );
 
  571     el.setAttribute( QStringLiteral( 
"service" ), settings.
value( path + 
"/service" ).toString() );
 
  572     el.setAttribute( QStringLiteral( 
"sslmode" ), settings.
value( path + 
"/sslmode", 
"1" ).toString() );
 
  573     el.setAttribute( QStringLiteral( 
"estimatedMetadata" ), settings.
value( path + 
"/estimatedMetadata", 
"0" ).toString() );
 
  575     el.setAttribute( QStringLiteral( 
"saveUsername" ), settings.
value( path + 
"/saveUsername", 
"false" ).toString() );
 
  577     if ( settings.
value( path + 
"/saveUsername", 
"false" ).toString() == QLatin1String( 
"true" ) )
 
  579       el.setAttribute( QStringLiteral( 
"username" ), settings.
value( path + 
"/username" ).toString() );
 
  582     el.setAttribute( QStringLiteral( 
"savePassword" ), settings.
value( path + 
"/savePassword", 
"false" ).toString() );
 
  584     if ( settings.
value( path + 
"/savePassword", 
"false" ).toString() == QLatin1String( 
"true" ) )
 
  586       el.setAttribute( QStringLiteral( 
"password" ), settings.
value( path + 
"/password" ).toString() );
 
  589     root.appendChild( el );
 
  595 QDomDocument QgsManageConnectionsDialog::saveOracleConnections( 
const QStringList &connections )
 
  597   QDomDocument doc( QStringLiteral( 
"connections" ) );
 
  598   QDomElement root = doc.createElement( QStringLiteral( 
"qgsOracleConnections" ) );
 
  599   root.setAttribute( QStringLiteral( 
"version" ), QStringLiteral( 
"1.0" ) );
 
  600   doc.appendChild( root );
 
  604   for ( 
int i = 0; i < connections.count(); ++i )
 
  606     path = 
"/Oracle/connections/" + connections[ i ];
 
  607     QDomElement el = doc.createElement( QStringLiteral( 
"oracle" ) );
 
  608     el.setAttribute( QStringLiteral( 
"name" ), connections[ i ] );
 
  609     el.setAttribute( QStringLiteral( 
"host" ), settings.
value( path + 
"/host" ).toString() );
 
  610     el.setAttribute( QStringLiteral( 
"port" ), settings.
value( path + 
"/port" ).toString() );
 
  611     el.setAttribute( QStringLiteral( 
"database" ), settings.
value( path + 
"/database" ).toString() );
 
  612     el.setAttribute( QStringLiteral( 
"dboptions" ), settings.
value( path + 
"/dboptions" ).toString() );
 
  613     el.setAttribute( QStringLiteral( 
"dbworkspace" ), settings.
value( path + 
"/dbworkspace" ).toString() );
 
  614     el.setAttribute( QStringLiteral( 
"schema" ), settings.
value( path + 
"/schema" ).toString() );
 
  615     el.setAttribute( QStringLiteral( 
"estimatedMetadata" ), settings.
value( path + 
"/estimatedMetadata", 
"0" ).toString() );
 
  616     el.setAttribute( QStringLiteral( 
"userTablesOnly" ), settings.
value( path + 
"/userTablesOnly", 
"0" ).toString() );
 
  617     el.setAttribute( QStringLiteral( 
"geometryColumnsOnly" ), settings.
value( path + 
"/geometryColumnsOnly", 
"0" ).toString() );
 
  618     el.setAttribute( QStringLiteral( 
"allowGeometrylessTables" ), settings.
value( path + 
"/allowGeometrylessTables", 
"0" ).toString() );
 
  620     el.setAttribute( QStringLiteral( 
"saveUsername" ), settings.
value( path + 
"/saveUsername", 
"false" ).toString() );
 
  622     if ( settings.
value( path + 
"/saveUsername", 
"false" ).toString() == QLatin1String( 
"true" ) )
 
  624       el.setAttribute( QStringLiteral( 
"username" ), settings.
value( path + 
"/username" ).toString() );
 
  627     el.setAttribute( QStringLiteral( 
"savePassword" ), settings.
value( path + 
"/savePassword", 
"false" ).toString() );
 
  629     if ( settings.
value( path + 
"/savePassword", 
"false" ).toString() == QLatin1String( 
"true" ) )
 
  631       el.setAttribute( QStringLiteral( 
"password" ), settings.
value( path + 
"/password" ).toString() );
 
  634     root.appendChild( el );
 
  640 QDomDocument QgsManageConnectionsDialog::saveHanaConnections( 
const QStringList &connections )
 
  642   QDomDocument doc( QStringLiteral( 
"connections" ) );
 
  643   QDomElement root = doc.createElement( QStringLiteral( 
"qgsHanaConnections" ) );
 
  644   root.setAttribute( QStringLiteral( 
"version" ), QStringLiteral( 
"1.0" ) );
 
  645   doc.appendChild( root );
 
  649   for ( 
int i = 0; i < connections.count(); ++i )
 
  651     path = 
"/HANA/connections/" + connections[i];
 
  652     QDomElement el = doc.createElement( QStringLiteral( 
"hana" ) );
 
  653     el.setAttribute( QStringLiteral( 
"name" ), connections[i] );
 
  654     el.setAttribute( QStringLiteral( 
"driver" ), settings.
value( path + 
"/driver", QString() ).toString() );
 
  655     el.setAttribute( QStringLiteral( 
"host" ), settings.
value( path + 
"/host", QString() ).toString() );
 
  656     el.setAttribute( QStringLiteral( 
"identifierType" ), settings.
value( path + 
"/identifierType", QString() ).toString() );
 
  657     el.setAttribute( QStringLiteral( 
"identifier" ), settings.
value( path + 
"/identifier", QString() ).toString() );
 
  658     el.setAttribute( QStringLiteral( 
"multitenant" ), settings.
value( path + 
"/multitenant", QString() ).toString() );
 
  659     el.setAttribute( QStringLiteral( 
"database" ), settings.
value( path + 
"/database", QString() ).toString() );
 
  660     el.setAttribute( QStringLiteral( 
"schema" ), settings.
value( path + 
"/schema", QString() ).toString() );
 
  661     el.setAttribute( QStringLiteral( 
"userTablesOnly" ), settings.
value( path + 
"/userTablesOnly", QStringLiteral( 
"0" ) ).toString() );
 
  662     el.setAttribute( QStringLiteral( 
"allowGeometrylessTables" ), settings.
value( path + 
"/allowGeometrylessTables", QStringLiteral( 
"0" ) ).toString() );
 
  664     el.setAttribute( QStringLiteral( 
"saveUsername" ), settings.
value( path + 
"/saveUsername", QStringLiteral( 
"false" ) ).toString() );
 
  665     if ( settings.
value( path + 
"/saveUsername", 
"false" ).toString() == QLatin1String( 
"true" ) )
 
  667       el.setAttribute( QStringLiteral( 
"username" ), settings.
value( path + 
"/username", QString() ).toString() );
 
  670     el.setAttribute( QStringLiteral( 
"savePassword" ), settings.
value( path + 
"/savePassword", QStringLiteral( 
"false" ) ).toString() );
 
  671     if ( settings.
value( path + 
"/savePassword", 
"false" ).toString() == QLatin1String( 
"true" ) )
 
  673       el.setAttribute( QStringLiteral( 
"password" ), settings.
value( path + 
"/password", QString() ).toString() );
 
  676     el.setAttribute( QStringLiteral( 
"sslEnabled" ), settings.
value( path + 
"/sslEnabled", QStringLiteral( 
"false" ) ).toString() );
 
  677     el.setAttribute( QStringLiteral( 
"sslCryptoProvider" ), settings.
value( path + 
"/sslCryptoProvider", QStringLiteral( 
"openssl" ) ).toString() );
 
  678     el.setAttribute( QStringLiteral( 
"sslKeyStore" ), settings.
value( path + 
"/sslKeyStore", QString() ).toString() );
 
  679     el.setAttribute( QStringLiteral( 
"sslTrustStore" ), settings.
value( path + 
"/sslTrustStore", QString() ).toString() );
 
  680     el.setAttribute( QStringLiteral( 
"sslValidateCertificate" ), settings.
value( path + 
"/sslValidateCertificate", QStringLiteral( 
"false" ) ).toString() );
 
  681     el.setAttribute( QStringLiteral( 
"sslHostNameInCertificate" ), settings.
value( path + 
"/sslHostNameInCertificate", QString() ).toString() );
 
  683     root.appendChild( el );
 
  689 QDomDocument QgsManageConnectionsDialog::saveGeonodeConnections( 
const QStringList &connections )
 
  691   QDomDocument doc( QStringLiteral( 
"connections" ) );
 
  692   QDomElement root = doc.createElement( QStringLiteral( 
"qgsGeoNodeConnections" ) );
 
  693   root.setAttribute( QStringLiteral( 
"version" ), QStringLiteral( 
"1.0" ) );
 
  694   doc.appendChild( root );
 
  698   for ( 
int i = 0; i < connections.count(); ++i )
 
  700     path = QStringLiteral( 
"/qgis/connections-geonode/" );
 
  701     QDomElement el = doc.createElement( QStringLiteral( 
"geonode" ) );
 
  702     el.setAttribute( QStringLiteral( 
"name" ), connections[ i ] );
 
  703     el.setAttribute( QStringLiteral( 
"url" ), settings.
value( path + connections[ i ] + 
"/url" ).toString() );
 
  705     path = QStringLiteral( 
"/qgis/GeoNode/" );
 
  706     el.setAttribute( QStringLiteral( 
"username" ), settings.
value( path + connections[ i ] + 
"/username" ).toString() );
 
  707     el.setAttribute( QStringLiteral( 
"password" ), settings.
value( path + connections[ i ] + 
"/password" ).toString() );
 
  708     root.appendChild( el );
 
  714 QDomDocument QgsManageConnectionsDialog::saveXyzTilesConnections( 
const QStringList &connections )
 
  716   QDomDocument doc( QStringLiteral( 
"connections" ) );
 
  717   QDomElement root = doc.createElement( QStringLiteral( 
"qgsXYZTilesConnections" ) );
 
  718   root.setAttribute( QStringLiteral( 
"version" ), QStringLiteral( 
"1.0" ) );
 
  719   doc.appendChild( root );
 
  723   for ( 
int i = 0; i < connections.count(); ++i )
 
  725     path = 
"qgis/connections-xyz/" + connections[ i ];
 
  726     QDomElement el = doc.createElement( QStringLiteral( 
"xyztiles" ) );
 
  728     el.setAttribute( QStringLiteral( 
"name" ), connections[ i ] );
 
  729     el.setAttribute( QStringLiteral( 
"url" ), settings.
value( path + 
"/url" ).toString() );
 
  730     el.setAttribute( QStringLiteral( 
"zmin" ), settings.
value( path + 
"/zmin", -1 ).toInt() );
 
  731     el.setAttribute( QStringLiteral( 
"zmax" ), settings.
value( path + 
"/zmax", -1 ).toInt() );
 
  732     el.setAttribute( QStringLiteral( 
"authcfg" ), settings.
value( path + 
"/authcfg" ).toString() );
 
  733     el.setAttribute( QStringLiteral( 
"username" ), settings.
value( path + 
"/username" ).toString() );
 
  734     el.setAttribute( QStringLiteral( 
"password" ), settings.
value( path + 
"/password" ).toString() );
 
  735     el.setAttribute( QStringLiteral( 
"tilePixelRatio" ), settings.
value( path + 
"/tilePixelRatio", 0 ).toDouble() );
 
  738     httpHeader.updateDomElement( el );
 
  740     root.appendChild( el );
 
  746 QDomDocument QgsManageConnectionsDialog::saveArcgisConnections( 
const QStringList &connections, 
const QString &service )
 
  748   QDomDocument doc( QStringLiteral( 
"connections" ) );
 
  749   QDomElement root = doc.createElement( 
"qgs" + service.toUpper() + 
"Connections" );
 
  750   root.setAttribute( QStringLiteral( 
"version" ), QStringLiteral( 
"1.0" ) );
 
  751   doc.appendChild( root );
 
  755   for ( 
int i = 0; i < connections.count(); ++i )
 
  757     path = 
"/qgis/connections-" + service.toLower() + 
'/';
 
  758     QDomElement el = doc.createElement( service.toLower() );
 
  759     el.setAttribute( QStringLiteral( 
"name" ), connections[ i ] );
 
  760     el.setAttribute( QStringLiteral( 
"url" ), settings.
value( path + connections[ i ] + 
"/url" ).toString() );
 
  763     httpHeader.updateDomElement( el );
 
  765     path = 
"/qgis/" + service.toUpper() + 
'/';
 
  766     el.setAttribute( QStringLiteral( 
"username" ), settings.
value( path + connections[ i ] + 
"/username" ).toString() );
 
  767     el.setAttribute( QStringLiteral( 
"password" ), settings.
value( path + connections[ i ] + 
"/password" ).toString() );
 
  768     el.setAttribute( QStringLiteral( 
"authcfg" ), settings.
value( path + connections[ i ] + 
"/authcfg" ).toString() );
 
  769     root.appendChild( el );
 
  775 QDomDocument QgsManageConnectionsDialog::saveVectorTileConnections( 
const QStringList &connections )
 
  777   QDomDocument doc( QStringLiteral( 
"connections" ) );
 
  778   QDomElement root = doc.createElement( QStringLiteral( 
"qgsVectorTileConnections" ) );
 
  779   root.setAttribute( QStringLiteral( 
"version" ), QStringLiteral( 
"1.0" ) );
 
  780   doc.appendChild( root );
 
  784   for ( 
int i = 0; i < connections.count(); ++i )
 
  786     path = 
"qgis/connections-vector-tile/" + connections[ i ];
 
  787     QDomElement el = doc.createElement( QStringLiteral( 
"vectortile" ) );
 
  789     el.setAttribute( QStringLiteral( 
"name" ), connections[ i ] );
 
  790     el.setAttribute( QStringLiteral( 
"url" ), settings.
value( path + 
"/url" ).toString() );
 
  791     el.setAttribute( QStringLiteral( 
"zmin" ), settings.
value( path + 
"/zmin", -1 ).toInt() );
 
  792     el.setAttribute( QStringLiteral( 
"zmax" ), settings.
value( path + 
"/zmax", -1 ).toInt() );
 
  793     el.setAttribute( QStringLiteral( 
"serviceType" ), settings.
value( path + 
"/serviceType", QString() ).toString() );
 
  794     el.setAttribute( QStringLiteral( 
"authcfg" ), settings.
value( path + 
"/authcfg" ).toString() );
 
  795     el.setAttribute( QStringLiteral( 
"username" ), settings.
value( path + 
"/username" ).toString() );
 
  796     el.setAttribute( QStringLiteral( 
"password" ), settings.
value( path + 
"/password" ).toString() );
 
  797     el.setAttribute( QStringLiteral( 
"styleUrl" ), settings.
value( path + 
"/styleUrl" ).toString() );
 
  800     httpHeader.updateDomElement( el );
 
  802     root.appendChild( el );
 
  808 void QgsManageConnectionsDialog::loadOWSConnections( 
const QDomDocument &doc, 
const QStringList &items, 
const QString &service )
 
  810   const QDomElement root = doc.documentElement();
 
  811   if ( root.tagName() != 
"qgs" + service.toUpper() + 
"Connections" )
 
  813     QMessageBox::information( 
this, tr( 
"Loading Connections" ),
 
  814                               tr( 
"The file is not a %1 connections exchange file." ).arg( service ) );
 
  818   QString connectionName;
 
  820   settings.
beginGroup( 
"/qgis/connections-" + service.toLower() );
 
  823   QDomElement child = root.firstChildElement();
 
  825   bool overwrite = 
true;
 
  827   while ( !child.isNull() )
 
  829     connectionName = child.attribute( QStringLiteral( 
"name" ) );
 
  830     if ( !items.contains( connectionName ) )
 
  832       child = child.nextSiblingElement();
 
  837     if ( keys.contains( connectionName ) && prompt )
 
  839       const int res = QMessageBox::warning( 
this,
 
  840                                             tr( 
"Loading Connections" ),
 
  841                                             tr( 
"Connection with name '%1' already exists. Overwrite?" )
 
  842                                             .arg( connectionName ),
 
  843                                             QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
 
  847         case QMessageBox::Cancel:
 
  849         case QMessageBox::No:
 
  850           child = child.nextSiblingElement();
 
  852         case QMessageBox::Yes:
 
  855         case QMessageBox::YesToAll:
 
  859         case QMessageBox::NoToAll:
 
  866     if ( keys.contains( connectionName ) )
 
  870         child = child.nextSiblingElement();
 
  876       keys << connectionName;
 
  880     settings.
beginGroup( 
"/qgis/connections-" + service.toLower() );
 
  881     settings.
setValue( QString( 
'/' + connectionName + 
"/url" ), child.attribute( QStringLiteral( 
"url" ) ) );
 
  882     settings.
setValue( QString( 
'/' + connectionName + 
"/ignoreGetMapURI" ), child.attribute( QStringLiteral( 
"ignoreGetMapURI" ) ) == QLatin1String( 
"true" ) );
 
  883     settings.
setValue( QString( 
'/' + connectionName + 
"/ignoreGetFeatureInfoURI" ), child.attribute( QStringLiteral( 
"ignoreGetFeatureInfoURI" ) ) == QLatin1String( 
"true" ) );
 
  884     settings.
setValue( QString( 
'/' + connectionName + 
"/ignoreAxisOrientation" ), child.attribute( QStringLiteral( 
"ignoreAxisOrientation" ) ) == QLatin1String( 
"true" ) );
 
  885     settings.
setValue( QString( 
'/' + connectionName + 
"/invertAxisOrientation" ), child.attribute( QStringLiteral( 
"invertAxisOrientation" ) ) == QLatin1String( 
"true" ) );
 
  886     settings.
setValue( QString( 
'/' + connectionName + 
"/smoothPixmapTransform" ), child.attribute( QStringLiteral( 
"smoothPixmapTransform" ) ) == QLatin1String( 
"true" ) );
 
  887     settings.
setValue( QString( 
'/' + connectionName + 
"/dpiMode" ), child.attribute( QStringLiteral( 
"dpiMode" ), QStringLiteral( 
"7" ) ).toInt() );
 
  890     httpHeader.updateSettings( settings, QString( 
'/' + connectionName ) );
 
  894     if ( !child.attribute( QStringLiteral( 
"username" ) ).isEmpty() )
 
  896       settings.
beginGroup( 
"/qgis/" + service.toUpper() + 
'/' + connectionName );
 
  897       settings.
setValue( QStringLiteral( 
"/username" ), child.attribute( QStringLiteral( 
"username" ) ) );
 
  898       settings.
setValue( QStringLiteral( 
"/password" ), child.attribute( QStringLiteral( 
"password" ) ) );
 
  901     child = child.nextSiblingElement();
 
  905 void QgsManageConnectionsDialog::loadWfsConnections( 
const QDomDocument &doc, 
const QStringList &items )
 
  907   const QDomElement root = doc.documentElement();
 
  908   if ( root.tagName() != QLatin1String( 
"qgsWFSConnections" ) )
 
  910     QMessageBox::information( 
this, tr( 
"Loading Connections" ),
 
  911                               tr( 
"The file is not a WFS connections exchange file." ) );
 
  915   QString connectionName;
 
  917   settings.
beginGroup( QStringLiteral( 
"/qgis/connections-wfs" ) );
 
  920   QDomElement child = root.firstChildElement();
 
  922   bool overwrite = 
true;
 
  924   while ( !child.isNull() )
 
  926     connectionName = child.attribute( QStringLiteral( 
"name" ) );
 
  927     if ( !items.contains( connectionName ) )
 
  929       child = child.nextSiblingElement();
 
  934     if ( keys.contains( connectionName ) && prompt )
 
  936       const int res = QMessageBox::warning( 
this,
 
  937                                             tr( 
"Loading Connections" ),
 
  938                                             tr( 
"Connection with name '%1' already exists. Overwrite?" )
 
  939                                             .arg( connectionName ),
 
  940                                             QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
 
  944         case QMessageBox::Cancel:
 
  946         case QMessageBox::No:
 
  947           child = child.nextSiblingElement();
 
  949         case QMessageBox::Yes:
 
  952         case QMessageBox::YesToAll:
 
  956         case QMessageBox::NoToAll:
 
  963     if ( keys.contains( connectionName ) )
 
  967         child = child.nextSiblingElement();
 
  973       keys << connectionName;
 
  977     settings.
beginGroup( QStringLiteral( 
"/qgis/connections-wfs" ) );
 
  978     settings.
setValue( QString( 
'/' + connectionName + 
"/url" ), child.attribute( QStringLiteral( 
"url" ) ) );
 
  980     settings.
setValue( QString( 
'/' + connectionName + 
"/version" ), child.attribute( QStringLiteral( 
"version" ) ) );
 
  981     settings.
setValue( QString( 
'/' + connectionName + 
"/maxnumfeatures" ), child.attribute( QStringLiteral( 
"maxnumfeatures" ) ) );
 
  982     settings.
setValue( QString( 
'/' + connectionName + 
"/pagesize" ), child.attribute( QStringLiteral( 
"pagesize" ) ) );
 
  983     settings.
setValue( QString( 
'/' + connectionName + 
"/pagingenabled" ), child.attribute( QStringLiteral( 
"pagingenabled" ) ) );
 
  984     settings.
setValue( QString( 
'/' + connectionName + 
"/ignoreAxisOrientation" ), child.attribute( QStringLiteral( 
"ignoreAxisOrientation" ) ) );
 
  985     settings.
setValue( QString( 
'/' + connectionName + 
"/invertAxisOrientation" ), child.attribute( QStringLiteral( 
"invertAxisOrientation" ) ) );
 
  988     if ( !child.attribute( QStringLiteral( 
"username" ) ).isEmpty() )
 
  990       settings.
beginGroup( 
"/qgis/WFS/" + connectionName );
 
  991       settings.
setValue( QStringLiteral( 
"/username" ), child.attribute( QStringLiteral( 
"username" ) ) );
 
  992       settings.
setValue( QStringLiteral( 
"/password" ), child.attribute( QStringLiteral( 
"password" ) ) );
 
  995     child = child.nextSiblingElement();
 
  999 void QgsManageConnectionsDialog::loadPgConnections( 
const QDomDocument &doc, 
const QStringList &items )
 
 1001   const QDomElement root = doc.documentElement();
 
 1002   if ( root.tagName() != QLatin1String( 
"qgsPgConnections" ) )
 
 1004     QMessageBox::information( 
this,
 
 1005                               tr( 
"Loading Connections" ),
 
 1006                               tr( 
"The file is not a PostGIS connections exchange file." ) );
 
 1010   QString connectionName;
 
 1012   settings.
beginGroup( QStringLiteral( 
"/PostgreSQL/connections" ) );
 
 1015   QDomElement child = root.firstChildElement();
 
 1017   bool overwrite = 
true;
 
 1019   while ( !child.isNull() )
 
 1021     connectionName = child.attribute( QStringLiteral( 
"name" ) );
 
 1022     if ( !items.contains( connectionName ) )
 
 1024       child = child.nextSiblingElement();
 
 1029     if ( keys.contains( connectionName ) && prompt )
 
 1031       const int res = QMessageBox::warning( 
this,
 
 1032                                             tr( 
"Loading Connections" ),
 
 1033                                             tr( 
"Connection with name '%1' already exists. Overwrite?" )
 
 1034                                             .arg( connectionName ),
 
 1035                                             QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
 
 1038         case QMessageBox::Cancel:
 
 1040         case QMessageBox::No:
 
 1041           child = child.nextSiblingElement();
 
 1043         case QMessageBox::Yes:
 
 1046         case QMessageBox::YesToAll:
 
 1050         case QMessageBox::NoToAll:
 
 1057     if ( keys.contains( connectionName ) )
 
 1061         child = child.nextSiblingElement();
 
 1067       keys << connectionName;
 
 1071     settings.
beginGroup( 
"/PostgreSQL/connections/" + connectionName );
 
 1073     settings.
setValue( QStringLiteral( 
"/host" ), child.attribute( QStringLiteral( 
"host" ) ) );
 
 1074     settings.
setValue( QStringLiteral( 
"/port" ), child.attribute( QStringLiteral( 
"port" ) ) );
 
 1075     settings.
setValue( QStringLiteral( 
"/database" ), child.attribute( QStringLiteral( 
"database" ) ) );
 
 1076     if ( child.hasAttribute( QStringLiteral( 
"service" ) ) )
 
 1078       settings.
setValue( QStringLiteral( 
"/service" ), child.attribute( QStringLiteral( 
"service" ) ) );
 
 1082       settings.
setValue( QStringLiteral( 
"/service" ), 
"" );
 
 1084     settings.
setValue( QStringLiteral( 
"/sslmode" ), child.attribute( QStringLiteral( 
"sslmode" ) ) );
 
 1085     settings.
setValue( QStringLiteral( 
"/estimatedMetadata" ), child.attribute( QStringLiteral( 
"estimatedMetadata" ) ) );
 
 1086     settings.
setValue( QStringLiteral( 
"/projectsInDatabase" ), child.attribute( QStringLiteral( 
"projectsInDatabase" ), 0 ) );
 
 1087     settings.
setValue( QStringLiteral( 
"/dontResolveType" ), child.attribute( QStringLiteral( 
"dontResolveType" ), 0 ) );
 
 1088     settings.
setValue( QStringLiteral( 
"/allowGeometrylessTables" ), child.attribute( QStringLiteral( 
"allowGeometrylessTables" ), 0 ) );
 
 1089     settings.
setValue( QStringLiteral( 
"/geometryColumnsOnly" ), child.attribute( QStringLiteral( 
"geometryColumnsOnly" ), 0 ) );
 
 1090     settings.
setValue( QStringLiteral( 
"/publicOnly" ), child.attribute( QStringLiteral( 
"publicOnly" ), 0 ) );
 
 1091     settings.
setValue( QStringLiteral( 
"/saveUsername" ), child.attribute( QStringLiteral( 
"saveUsername" ) ) );
 
 1092     settings.
setValue( QStringLiteral( 
"/username" ), child.attribute( QStringLiteral( 
"username" ) ) );
 
 1093     settings.
setValue( QStringLiteral( 
"/savePassword" ), child.attribute( QStringLiteral( 
"savePassword" ) ) );
 
 1094     settings.
setValue( QStringLiteral( 
"/password" ), child.attribute( QStringLiteral( 
"password" ) ) );
 
 1097     child = child.nextSiblingElement();
 
 1101 void QgsManageConnectionsDialog::loadMssqlConnections( 
const QDomDocument &doc, 
const QStringList &items )
 
 1103   const QDomElement root = doc.documentElement();
 
 1104   if ( root.tagName() != QLatin1String( 
"qgsMssqlConnections" ) )
 
 1106     QMessageBox::information( 
this,
 
 1107                               tr( 
"Loading Connections" ),
 
 1108                               tr( 
"The file is not a MSSQL connections exchange file." ) );
 
 1112   QString connectionName;
 
 1114   settings.
beginGroup( QStringLiteral( 
"/MSSQL/connections" ) );
 
 1117   QDomElement child = root.firstChildElement();
 
 1119   bool overwrite = 
true;
 
 1121   while ( !child.isNull() )
 
 1123     connectionName = child.attribute( QStringLiteral( 
"name" ) );
 
 1124     if ( !items.contains( connectionName ) )
 
 1126       child = child.nextSiblingElement();
 
 1131     if ( keys.contains( connectionName ) && prompt )
 
 1133       const int res = QMessageBox::warning( 
this,
 
 1134                                             tr( 
"Loading Connections" ),
 
 1135                                             tr( 
"Connection with name '%1' already exists. Overwrite?" )
 
 1136                                             .arg( connectionName ),
 
 1137                                             QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
 
 1140         case QMessageBox::Cancel:
 
 1142         case QMessageBox::No:
 
 1143           child = child.nextSiblingElement();
 
 1145         case QMessageBox::Yes:
 
 1148         case QMessageBox::YesToAll:
 
 1152         case QMessageBox::NoToAll:
 
 1159     if ( keys.contains( connectionName ) )
 
 1163         child = child.nextSiblingElement();
 
 1169       keys << connectionName;
 
 1173     settings.
beginGroup( 
"/MSSQL/connections/" + connectionName );
 
 1175     settings.
setValue( QStringLiteral( 
"/host" ), child.attribute( QStringLiteral( 
"host" ) ) );
 
 1176     settings.
setValue( QStringLiteral( 
"/port" ), child.attribute( QStringLiteral( 
"port" ) ) );
 
 1177     settings.
setValue( QStringLiteral( 
"/database" ), child.attribute( QStringLiteral( 
"database" ) ) );
 
 1178     if ( child.hasAttribute( QStringLiteral( 
"service" ) ) )
 
 1180       settings.
setValue( QStringLiteral( 
"/service" ), child.attribute( QStringLiteral( 
"service" ) ) );
 
 1184       settings.
setValue( QStringLiteral( 
"/service" ), 
"" );
 
 1186     settings.
setValue( QStringLiteral( 
"/sslmode" ), child.attribute( QStringLiteral( 
"sslmode" ) ) );
 
 1187     settings.
setValue( QStringLiteral( 
"/estimatedMetadata" ), child.attribute( QStringLiteral( 
"estimatedMetadata" ) ) );
 
 1188     settings.
setValue( QStringLiteral( 
"/saveUsername" ), child.attribute( QStringLiteral( 
"saveUsername" ) ) );
 
 1189     settings.
setValue( QStringLiteral( 
"/username" ), child.attribute( QStringLiteral( 
"username" ) ) );
 
 1190     settings.
setValue( QStringLiteral( 
"/savePassword" ), child.attribute( QStringLiteral( 
"savePassword" ) ) );
 
 1191     settings.
setValue( QStringLiteral( 
"/password" ), child.attribute( QStringLiteral( 
"password" ) ) );
 
 1194     child = child.nextSiblingElement();
 
 1198 void QgsManageConnectionsDialog::loadOracleConnections( 
const QDomDocument &doc, 
const QStringList &items )
 
 1200   const QDomElement root = doc.documentElement();
 
 1201   if ( root.tagName() != QLatin1String( 
"qgsOracleConnections" ) )
 
 1203     QMessageBox::information( 
this,
 
 1204                               tr( 
"Loading Connections" ),
 
 1205                               tr( 
"The file is not an Oracle connections exchange file." ) );
 
 1209   QString connectionName;
 
 1211   settings.
beginGroup( QStringLiteral( 
"/Oracle/connections" ) );
 
 1214   QDomElement child = root.firstChildElement();
 
 1216   bool overwrite = 
true;
 
 1218   while ( !child.isNull() )
 
 1220     connectionName = child.attribute( QStringLiteral( 
"name" ) );
 
 1221     if ( !items.contains( connectionName ) )
 
 1223       child = child.nextSiblingElement();
 
 1228     if ( keys.contains( connectionName ) && prompt )
 
 1230       const int res = QMessageBox::warning( 
this,
 
 1231                                             tr( 
"Loading Connections" ),
 
 1232                                             tr( 
"Connection with name '%1' already exists. Overwrite?" )
 
 1233                                             .arg( connectionName ),
 
 1234                                             QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
 
 1237         case QMessageBox::Cancel:
 
 1239         case QMessageBox::No:
 
 1240           child = child.nextSiblingElement();
 
 1242         case QMessageBox::Yes:
 
 1245         case QMessageBox::YesToAll:
 
 1249         case QMessageBox::NoToAll:
 
 1256     if ( keys.contains( connectionName ) )
 
 1260         child = child.nextSiblingElement();
 
 1266       keys << connectionName;
 
 1270     settings.
beginGroup( 
"/Oracle/connections/" + connectionName );
 
 1272     settings.
setValue( QStringLiteral( 
"/host" ), child.attribute( QStringLiteral( 
"host" ) ) );
 
 1273     settings.
setValue( QStringLiteral( 
"/port" ), child.attribute( QStringLiteral( 
"port" ) ) );
 
 1274     settings.
setValue( QStringLiteral( 
"/database" ), child.attribute( QStringLiteral( 
"database" ) ) );
 
 1275     settings.
setValue( QStringLiteral( 
"/dboptions" ), child.attribute( QStringLiteral( 
"dboptions" ) ) );
 
 1276     settings.
setValue( QStringLiteral( 
"/dbworkspace" ), child.attribute( QStringLiteral( 
"dbworkspace" ) ) );
 
 1277     settings.
setValue( QStringLiteral( 
"/schema" ), child.attribute( QStringLiteral( 
"schema" ) ) );
 
 1278     settings.
setValue( QStringLiteral( 
"/estimatedMetadata" ), child.attribute( QStringLiteral( 
"estimatedMetadata" ) ) );
 
 1279     settings.
setValue( QStringLiteral( 
"/userTablesOnly" ), child.attribute( QStringLiteral( 
"userTablesOnly" ) ) );
 
 1280     settings.
setValue( QStringLiteral( 
"/geometryColumnsOnly" ), child.attribute( QStringLiteral( 
"geometryColumnsOnly" ) ) );
 
 1281     settings.
setValue( QStringLiteral( 
"/allowGeometrylessTables" ), child.attribute( QStringLiteral( 
"allowGeometrylessTables" ) ) );
 
 1282     settings.
setValue( QStringLiteral( 
"/saveUsername" ), child.attribute( QStringLiteral( 
"saveUsername" ) ) );
 
 1283     settings.
setValue( QStringLiteral( 
"/username" ), child.attribute( QStringLiteral( 
"username" ) ) );
 
 1284     settings.
setValue( QStringLiteral( 
"/savePassword" ), child.attribute( QStringLiteral( 
"savePassword" ) ) );
 
 1285     settings.
setValue( QStringLiteral( 
"/password" ), child.attribute( QStringLiteral( 
"password" ) ) );
 
 1288     child = child.nextSiblingElement();
 
 1292 void QgsManageConnectionsDialog::loadHanaConnections( 
const QDomDocument &doc, 
const QStringList &items )
 
 1294   QDomElement root = doc.documentElement();
 
 1295   if ( root.tagName() != QLatin1String( 
"qgsHanaConnections" ) )
 
 1297     QMessageBox::warning( 
this,
 
 1298                           tr( 
"Loading Connections" ),
 
 1299                           tr( 
"The file is not a HANA connections exchange file." ) );
 
 1303   const QDomAttr version = root.attributeNode( 
"version" );
 
 1304   if ( version.value() != QLatin1String( 
"1.0" ) )
 
 1306     QMessageBox::warning( 
this,
 
 1307                           tr( 
"Loading Connections" ),
 
 1308                           tr( 
"The HANA connections exchange file version '%1' is not supported." ).arg( version.value() ) );
 
 1313   settings.
beginGroup( QStringLiteral( 
"/HANA/connections" ) );
 
 1316   QDomElement child = root.firstChildElement();
 
 1318   bool overwrite = 
true;
 
 1320   while ( !child.isNull() )
 
 1322     const QString connectionName = child.attribute( QStringLiteral( 
"name" ) );
 
 1323     if ( !items.contains( connectionName ) )
 
 1325       child = child.nextSiblingElement();
 
 1330     if ( keys.contains( connectionName ) && prompt )
 
 1332       const int res = QMessageBox::warning( 
this,
 
 1333                                             tr( 
"Loading Connections" ),
 
 1334                                             tr( 
"Connection with name '%1' already exists. Overwrite?" )
 
 1335                                             .arg( connectionName ),
 
 1336                                             QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
 
 1339         case QMessageBox::Cancel:
 
 1341         case QMessageBox::No:
 
 1342           child = child.nextSiblingElement();
 
 1344         case QMessageBox::Yes:
 
 1347         case QMessageBox::YesToAll:
 
 1351         case QMessageBox::NoToAll:
 
 1358     if ( keys.contains( connectionName ) )
 
 1362         child = child.nextSiblingElement();
 
 1368       keys << connectionName;
 
 1372     settings.
beginGroup( 
"/HANA/connections/" + connectionName );
 
 1374     for ( 
const QString param :
 
 1375           {
"driver", 
"host", 
"database", 
"identifierType", 
"identifier", 
"multitenant", 
"schema", 
"userTablesOnly",
 
 1376            "allowGeometrylessTables", 
"saveUsername", 
"username", 
"savePassword", 
"password", 
"sslEnabled",
 
 1377            "sslCryptoProvider", 
"sslKeyStore", 
"sslTrustStore", 
"sslValidateCertificate", 
"sslHostNameInCertificate" 
 1379       settings.
setValue( QStringLiteral( 
"/" ) + param, child.attribute( param ) );
 
 1383     child = child.nextSiblingElement();
 
 1387 void QgsManageConnectionsDialog::loadGeonodeConnections( 
const QDomDocument &doc, 
const QStringList &items )
 
 1389   const QDomElement root = doc.documentElement();
 
 1390   if ( root.tagName() != QLatin1String( 
"qgsGeoNodeConnections" ) )
 
 1392     QMessageBox::information( 
this, tr( 
"Loading Connections" ),
 
 1393                               tr( 
"The file is not a GeoNode connections exchange file." ) );
 
 1397   QString connectionName;
 
 1399   settings.
beginGroup( QStringLiteral( 
"/qgis/connections-geonode" ) );
 
 1402   QDomElement child = root.firstChildElement();
 
 1404   bool overwrite = 
true;
 
 1406   while ( !child.isNull() )
 
 1408     connectionName = child.attribute( QStringLiteral( 
"name" ) );
 
 1409     if ( !items.contains( connectionName ) )
 
 1411       child = child.nextSiblingElement();
 
 1416     if ( keys.contains( connectionName ) && prompt )
 
 1418       const int res = QMessageBox::warning( 
this,
 
 1419                                             tr( 
"Loading Connections" ),
 
 1420                                             tr( 
"Connection with name '%1' already exists. Overwrite?" )
 
 1421                                             .arg( connectionName ),
 
 1422                                             QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
 
 1426         case QMessageBox::Cancel:
 
 1428         case QMessageBox::No:
 
 1429           child = child.nextSiblingElement();
 
 1431         case QMessageBox::Yes:
 
 1434         case QMessageBox::YesToAll:
 
 1438         case QMessageBox::NoToAll:
 
 1445     if ( keys.contains( connectionName ) )
 
 1449         child = child.nextSiblingElement();
 
 1455       keys << connectionName;
 
 1459     settings.
beginGroup( QStringLiteral( 
"/qgis/connections-geonode" ) );
 
 1460     settings.
setValue( QString( 
'/' + connectionName + 
"/url" ), child.attribute( QStringLiteral( 
"url" ) ) );
 
 1463     if ( !child.attribute( QStringLiteral( 
"username" ) ).isEmpty() )
 
 1465       settings.
beginGroup( 
"/qgis/GeoNode/" + connectionName );
 
 1466       settings.
setValue( QStringLiteral( 
"/username" ), child.attribute( QStringLiteral( 
"username" ) ) );
 
 1467       settings.
setValue( QStringLiteral( 
"/password" ), child.attribute( QStringLiteral( 
"password" ) ) );
 
 1470     child = child.nextSiblingElement();
 
 1474 void QgsManageConnectionsDialog::loadXyzTilesConnections( 
const QDomDocument &doc, 
const QStringList &items )
 
 1476   const QDomElement root = doc.documentElement();
 
 1477   if ( root.tagName() != QLatin1String( 
"qgsXYZTilesConnections" ) )
 
 1479     QMessageBox::information( 
this, tr( 
"Loading Connections" ),
 
 1480                               tr( 
"The file is not a XYZ Tiles connections exchange file." ) );
 
 1484   QString connectionName;
 
 1486   settings.
beginGroup( QStringLiteral( 
"/qgis/connections-xyz" ) );
 
 1489   QDomElement child = root.firstChildElement();
 
 1491   bool overwrite = 
true;
 
 1493   while ( !child.isNull() )
 
 1495     connectionName = child.attribute( QStringLiteral( 
"name" ) );
 
 1496     if ( !items.contains( connectionName ) )
 
 1498       child = child.nextSiblingElement();
 
 1503     if ( keys.contains( connectionName ) && prompt )
 
 1505       const int res = QMessageBox::warning( 
this,
 
 1506                                             tr( 
"Loading Connections" ),
 
 1507                                             tr( 
"Connection with name '%1' already exists. Overwrite?" )
 
 1508                                             .arg( connectionName ),
 
 1509                                             QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
 
 1513         case QMessageBox::Cancel:
 
 1515         case QMessageBox::No:
 
 1516           child = child.nextSiblingElement();
 
 1518         case QMessageBox::Yes:
 
 1521         case QMessageBox::YesToAll:
 
 1525         case QMessageBox::NoToAll:
 
 1532     if ( keys.contains( connectionName ) )
 
 1536         child = child.nextSiblingElement();
 
 1542       keys << connectionName;
 
 1545     settings.
beginGroup( 
"qgis/connections-xyz/" + connectionName );
 
 1546     settings.
setValue( QStringLiteral( 
"url" ), child.attribute( QStringLiteral( 
"url" ) ) );
 
 1547     settings.
setValue( QStringLiteral( 
"zmin" ), child.attribute( QStringLiteral( 
"zmin" ) ) );
 
 1548     settings.
setValue( QStringLiteral( 
"zmax" ), child.attribute( QStringLiteral( 
"zmax" ) ) );
 
 1549     settings.
setValue( QStringLiteral( 
"authcfg" ), child.attribute( QStringLiteral( 
"authcfg" ) ) );
 
 1550     settings.
setValue( QStringLiteral( 
"username" ), child.attribute( QStringLiteral( 
"username" ) ) );
 
 1551     settings.
setValue( QStringLiteral( 
"password" ), child.attribute( QStringLiteral( 
"password" ) ) );
 
 1552     settings.
setValue( QStringLiteral( 
"tilePixelRatio" ), child.attribute( QStringLiteral( 
"tilePixelRatio" ) ) );
 
 1555     httpHeader.updateSettings( settings );
 
 1559     child = child.nextSiblingElement();
 
 1563 void QgsManageConnectionsDialog::loadArcgisConnections( 
const QDomDocument &doc, 
const QStringList &items, 
const QString &service )
 
 1565   const QDomElement root = doc.documentElement();
 
 1566   if ( root.tagName() != 
"qgs" + service.toUpper() + 
"Connections" )
 
 1568     QMessageBox::information( 
this, tr( 
"Loading Connections" ),
 
 1569                               tr( 
"The file is not a %1 connections exchange file." ).arg( service ) );
 
 1573   QString connectionName;
 
 1575   settings.
beginGroup( 
"/qgis/connections-" + service.toLower() );
 
 1578   QDomElement child = root.firstChildElement();
 
 1580   bool overwrite = 
true;
 
 1582   while ( !child.isNull() )
 
 1584     connectionName = child.attribute( QStringLiteral( 
"name" ) );
 
 1585     if ( !items.contains( connectionName ) )
 
 1587       child = child.nextSiblingElement();
 
 1592     if ( keys.contains( connectionName ) && prompt )
 
 1594       const int res = QMessageBox::warning( 
this,
 
 1595                                             tr( 
"Loading Connections" ),
 
 1596                                             tr( 
"Connection with name '%1' already exists. Overwrite?" )
 
 1597                                             .arg( connectionName ),
 
 1598                                             QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
 
 1602         case QMessageBox::Cancel:
 
 1604         case QMessageBox::No:
 
 1605           child = child.nextSiblingElement();
 
 1607         case QMessageBox::Yes:
 
 1610         case QMessageBox::YesToAll:
 
 1614         case QMessageBox::NoToAll:
 
 1621     if ( keys.contains( connectionName ) )
 
 1625         child = child.nextSiblingElement();
 
 1631       keys << connectionName;
 
 1635     settings.
beginGroup( 
"/qgis/connections-" + service.toLower() );
 
 1636     settings.
setValue( QString( 
'/' + connectionName + 
"/url" ), child.attribute( QStringLiteral( 
"url" ) ) );
 
 1639     httpHeader.updateSettings( settings, QString( 
'/' + connectionName ) );
 
 1643     settings.
beginGroup( 
"/qgis/" + service.toUpper() + 
'/' + connectionName );
 
 1644     settings.
setValue( QStringLiteral( 
"/username" ), child.attribute( QStringLiteral( 
"username" ) ) );
 
 1645     settings.
setValue( QStringLiteral( 
"/password" ), child.attribute( QStringLiteral( 
"password" ) ) );
 
 1646     settings.
setValue( QStringLiteral( 
"/authcfg" ), child.attribute( QStringLiteral( 
"authcfg" ) ) );
 
 1649     child = child.nextSiblingElement();
 
 1653 void QgsManageConnectionsDialog::loadVectorTileConnections( 
const QDomDocument &doc, 
const QStringList &items )
 
 1655   const QDomElement root = doc.documentElement();
 
 1656   if ( root.tagName() != QLatin1String( 
"qgsVectorTileConnections" ) )
 
 1658     QMessageBox::information( 
this, tr( 
"Loading Connections" ),
 
 1659                               tr( 
"The file is not a Vector Tile connections exchange file." ) );
 
 1663   QString connectionName;
 
 1665   settings.
beginGroup( QStringLiteral( 
"/qgis/connections-vector-tile" ) );
 
 1668   QDomElement child = root.firstChildElement();
 
 1670   bool overwrite = 
true;
 
 1672   while ( !child.isNull() )
 
 1674     connectionName = child.attribute( QStringLiteral( 
"name" ) );
 
 1675     if ( !items.contains( connectionName ) )
 
 1677       child = child.nextSiblingElement();
 
 1682     if ( keys.contains( connectionName ) && prompt )
 
 1684       const int res = QMessageBox::warning( 
this,
 
 1685                                             tr( 
"Loading Connections" ),
 
 1686                                             tr( 
"Connection with name '%1' already exists. Overwrite?" )
 
 1687                                             .arg( connectionName ),
 
 1688                                             QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
 
 1692         case QMessageBox::Cancel:
 
 1694         case QMessageBox::No:
 
 1695           child = child.nextSiblingElement();
 
 1697         case QMessageBox::Yes:
 
 1700         case QMessageBox::YesToAll:
 
 1704         case QMessageBox::NoToAll:
 
 1711     if ( keys.contains( connectionName ) )
 
 1715         child = child.nextSiblingElement();
 
 1721       keys << connectionName;
 
 1724     settings.
beginGroup( 
"qgis/connections-vector-tile/" + connectionName );
 
 1725     settings.
setValue( QStringLiteral( 
"url" ), child.attribute( QStringLiteral( 
"url" ) ) );
 
 1726     settings.
setValue( QStringLiteral( 
"zmin" ), child.attribute( QStringLiteral( 
"zmin" ) ) );
 
 1727     settings.
setValue( QStringLiteral( 
"zmax" ), child.attribute( QStringLiteral( 
"zmax" ) ) );
 
 1728     settings.
setValue( QStringLiteral( 
"serviceType" ), child.attribute( QStringLiteral( 
"serviceType" ) ) );
 
 1729     settings.
setValue( QStringLiteral( 
"authcfg" ), child.attribute( QStringLiteral( 
"authcfg" ) ) );
 
 1730     settings.
setValue( QStringLiteral( 
"username" ), child.attribute( QStringLiteral( 
"username" ) ) );
 
 1731     settings.
setValue( QStringLiteral( 
"password" ), child.attribute( QStringLiteral( 
"password" ) ) );
 
 1732     settings.
setValue( QStringLiteral( 
"styleUrl" ), child.attribute( QStringLiteral( 
"styleUrl" ) ) );
 
 1735     httpHeader.updateSettings( settings );
 
 1739     child = child.nextSiblingElement();
 
 1745   listConnections->selectAll();
 
 1746   buttonBox->button( QDialogButtonBox::Ok )->setEnabled( !listConnections->selectedItems().isEmpty() );
 
 1751   listConnections->clearSelection();
 
 1752   buttonBox->button( QDialogButtonBox::Ok )->setEnabled( 
false );