@@ -150,7 +150,7 @@ void QgsGeoNodeSourceSelect::showHelp()
150
150
151
151
void QgsGeoNodeSourceSelect::connectToGeonodeConnection ()
152
152
{
153
- QgsGeoNodeConnection connection ( cmbConnections-> currentText () );
153
+ QgsGeoNodeConnection connection = currentConnection ( );
154
154
155
155
QString url = connection.uri ().param ( QStringLiteral ( " url" ) );
156
156
QgsGeoNodeRequest *geonodeRequest = new QgsGeoNodeRequest ( url, true );
@@ -360,6 +360,8 @@ void QgsGeoNodeSourceSelect::addButtonClicked()
360
360
return ;
361
361
}
362
362
363
+ QgsGeoNodeConnection connection = currentConnection ();
364
+
363
365
QModelIndexList modelIndexList = treeView->selectionModel ()->selectedRows ();
364
366
for ( int i = 0 ; i < modelIndexList.size (); i++ )
365
367
{
@@ -396,6 +398,8 @@ void QgsGeoNodeSourceSelect::addButtonClicked()
396
398
QString styles;
397
399
QString contextualWMSLegend ( QStringLiteral ( " 0" ) );
398
400
401
+ connection.addWmsConnectionSettings ( uri );
402
+
399
403
uri.setParam ( QStringLiteral ( " contextualWMSLegend" ), contextualWMSLegend );
400
404
uri.setParam ( QStringLiteral ( " layers" ), layerName );
401
405
uri.setParam ( QStringLiteral ( " styles" ), styles );
@@ -414,25 +418,28 @@ void QgsGeoNodeSourceSelect::addButtonClicked()
414
418
// typeName, titleName, sql,
415
419
// Build url for WFS
416
420
// restrictToRequestBBOX='1' srsname='EPSG:26719' typename='geonode:cab_mun' url='http://demo.geonode.org/geoserver/geonode/wms' table=\"\" sql="
417
- QString uri;
418
- uri += QStringLiteral ( " restrictToRequestBBOX='1'" );
419
- uri += QStringLiteral ( " srsname='%1'" ).arg ( crs );
421
+ QgsDataSourceUri uri;
422
+
423
+ uri.setParam ( QStringLiteral ( " restrictToRequestBBOX" ), " 1" );
424
+ uri.setParam ( QStringLiteral ( " srsname" ), crs );
420
425
if ( serviceURL.contains ( QStringLiteral ( " qgis-server" ) ) )
421
426
{
422
427
// I need to do this since the typename used in qgis-server is without the workspace.
423
428
QString qgisServerTypeName = QString ( typeName ).split ( ' :' ).last ();
424
- uri += QStringLiteral ( " typename='%1' " ). arg ( qgisServerTypeName );
429
+ uri. setParam ( QStringLiteral ( " typename" ), qgisServerTypeName );
425
430
}
426
431
else
427
432
{
428
- uri += QStringLiteral ( " typename='%1' " ). arg ( typeName );
433
+ uri. setParam ( QStringLiteral ( " typename" ), typeName );
429
434
}
430
- uri += QStringLiteral ( " url='%1' " ). arg ( serviceURL );
431
- uri += QStringLiteral ( " table= \"\" " );
432
- uri += QStringLiteral ( " sql= " );
435
+ uri. setParam ( QStringLiteral ( " url" ), serviceURL );
436
+ // uri.setParam( QStringLiteral( "table" ), QStringLiteral( " \"\"" ) );
437
+ // uri.setParam( QStringLiteral( "sql" ), QString() );
433
438
434
- QgsDebugMsg ( " Add WFS from GeoNode : " + uri + " and typename: " + typeName );
435
- emit addVectorLayer ( uri, typeName, QStringLiteral ( " WFS" ) );
439
+ connection.addWfsConnectionSettings ( uri );
440
+
441
+ QgsDebugMsg ( " Add WFS from GeoNode : " + uri.uri () + " and typename: " + typeName );
442
+ emit addVectorLayer ( uri.uri (), typeName, QStringLiteral ( " WFS" ) );
436
443
}
437
444
else if ( webServiceType == QStringLiteral ( " XYZ" ) )
438
445
{
@@ -458,3 +465,8 @@ void QgsGeoNodeSourceSelect::updateButtonStateForAvailableConnections()
458
465
btnDelete->setEnabled ( connectionsAvailable );
459
466
btnSave->setEnabled ( connectionsAvailable );
460
467
}
468
+
469
+ QgsGeoNodeConnection QgsGeoNodeSourceSelect::currentConnection () const
470
+ {
471
+ return QgsGeoNodeConnection ( cmbConnections->currentText () );
472
+ }
0 commit comments