Skip to content

Commit 687fc52

Browse files
committed
Make sure WFS/WMS settings are respected when adding GeoNode layers from source select dialog
1 parent ac15df9 commit 687fc52

File tree

4 files changed

+29
-15
lines changed

4 files changed

+29
-15
lines changed

src/app/geocms/geonode/qgsgeonodenewconnection.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "qgsgeonoderequest.h"
2222

2323
QgsGeoNodeNewConnection::QgsGeoNodeNewConnection( QWidget *parent, const QString &connName, Qt::WindowFlags fl )
24-
: QgsNewHttpConnection( parent, 0, QgsGeoNodeConnectionUtils::pathGeoNodeConnection(), connName, QgsNewHttpConnection::FlagShowTestConnection, fl )
24+
: QgsNewHttpConnection( parent, 0, QgsGeoNodeConnectionUtils::pathGeoNodeConnection() + '/', connName, QgsNewHttpConnection::FlagShowTestConnection, fl )
2525
{
2626
setWindowTitle( tr( "Create a New GeoNode Connection" ) );
2727

src/app/geocms/geonode/qgsgeonodesourceselect.cpp

+23-11
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void QgsGeoNodeSourceSelect::showHelp()
150150

151151
void QgsGeoNodeSourceSelect::connectToGeonodeConnection()
152152
{
153-
QgsGeoNodeConnection connection( cmbConnections->currentText() );
153+
QgsGeoNodeConnection connection = currentConnection();
154154

155155
QString url = connection.uri().param( QStringLiteral( "url" ) );
156156
QgsGeoNodeRequest *geonodeRequest = new QgsGeoNodeRequest( url, true );
@@ -360,6 +360,8 @@ void QgsGeoNodeSourceSelect::addButtonClicked()
360360
return;
361361
}
362362

363+
QgsGeoNodeConnection connection = currentConnection();
364+
363365
QModelIndexList modelIndexList = treeView->selectionModel()->selectedRows();
364366
for ( int i = 0; i < modelIndexList.size(); i++ )
365367
{
@@ -396,6 +398,8 @@ void QgsGeoNodeSourceSelect::addButtonClicked()
396398
QString styles;
397399
QString contextualWMSLegend( QStringLiteral( "0" ) );
398400

401+
connection.addWmsConnectionSettings( uri );
402+
399403
uri.setParam( QStringLiteral( "contextualWMSLegend" ), contextualWMSLegend );
400404
uri.setParam( QStringLiteral( "layers" ), layerName );
401405
uri.setParam( QStringLiteral( "styles" ), styles );
@@ -414,25 +418,28 @@ void QgsGeoNodeSourceSelect::addButtonClicked()
414418
// typeName, titleName, sql,
415419
// Build url for WFS
416420
// 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 );
420425
if ( serviceURL.contains( QStringLiteral( "qgis-server" ) ) )
421426
{
422427
// I need to do this since the typename used in qgis-server is without the workspace.
423428
QString qgisServerTypeName = QString( typeName ).split( ':' ).last();
424-
uri += QStringLiteral( " typename='%1'" ).arg( qgisServerTypeName );
429+
uri.setParam( QStringLiteral( "typename" ), qgisServerTypeName );
425430
}
426431
else
427432
{
428-
uri += QStringLiteral( " typename='%1'" ).arg( typeName );
433+
uri.setParam( QStringLiteral( "typename" ), typeName );
429434
}
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() );
433438

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" ) );
436443
}
437444
else if ( webServiceType == QStringLiteral( "XYZ" ) )
438445
{
@@ -458,3 +465,8 @@ void QgsGeoNodeSourceSelect::updateButtonStateForAvailableConnections()
458465
btnDelete->setEnabled( connectionsAvailable );
459466
btnSave->setEnabled( connectionsAvailable );
460467
}
468+
469+
QgsGeoNodeConnection QgsGeoNodeSourceSelect::currentConnection() const
470+
{
471+
return QgsGeoNodeConnection( cmbConnections->currentText() );
472+
}

src/app/geocms/geonode/qgsgeonodesourceselect.h

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "qgsapplication.h"
2727
#include "ui_qgsgeonodesourceselectbase.h"
2828
#include "qgis_gui.h"
29+
#include "qgsgeonodeconnection.h"
2930

3031
class QgsGeonodeItemDelegate : public QItemDelegate
3132
{
@@ -66,6 +67,7 @@ class QgsGeoNodeSourceSelect: public QgsAbstractDataSourceWidget, private Ui::Qg
6667
QModelIndex mSQLIndex;
6768

6869
void updateButtonStateForAvailableConnections();
70+
QgsGeoNodeConnection currentConnection() const;
6971

7072
private slots:
7173
void addConnectionsEntryList();

src/core/geocms/geonode/qgsgeonodeconnection.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,16 @@ QStringList QgsGeoNodeConnectionUtils::connectionList()
9696
{
9797
QgsSettings settings;
9898
// Add Section manually
99-
settings.beginGroup( QStringLiteral( "providers/qgis/connections-geonode" ) );
99+
settings.beginGroup( QStringLiteral( "qgis/connections-geonode" ) );
100100
return settings.childGroups();
101101
}
102102

103103
void QgsGeoNodeConnectionUtils::deleteConnection( const QString &name )
104104
{
105105
QgsSettings settings;
106106
// Add Section manually
107-
settings.remove( QStringLiteral( "providers/qgis/connections-geonode/" ) + name );
108-
settings.remove( QStringLiteral( "providers/qgis/geonode/" ) + name );
107+
settings.remove( QStringLiteral( "qgis/connections-geonode/" ) + name );
108+
settings.remove( QStringLiteral( "qgis/geonode/" ) + name );
109109
}
110110

111111
QString QgsGeoNodeConnectionUtils::pathGeoNodeConnection()

0 commit comments

Comments
 (0)