Skip to content
Permalink
Browse files

Make sure WFS/WMS settings are respected when adding GeoNode layers f…

…rom source select dialog
  • Loading branch information
nyalldawson committed Sep 12, 2017
1 parent ac15df9 commit 687fc52a1d8f341dacb185e27e4c454c8a1667ea
@@ -21,7 +21,7 @@
#include "qgsgeonoderequest.h"

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

@@ -150,7 +150,7 @@ void QgsGeoNodeSourceSelect::showHelp()

void QgsGeoNodeSourceSelect::connectToGeonodeConnection()
{
QgsGeoNodeConnection connection( cmbConnections->currentText() );
QgsGeoNodeConnection connection = currentConnection();

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

QgsGeoNodeConnection connection = currentConnection();

QModelIndexList modelIndexList = treeView->selectionModel()->selectedRows();
for ( int i = 0; i < modelIndexList.size(); i++ )
{
@@ -396,6 +398,8 @@ void QgsGeoNodeSourceSelect::addButtonClicked()
QString styles;
QString contextualWMSLegend( QStringLiteral( "0" ) );

connection.addWmsConnectionSettings( uri );

uri.setParam( QStringLiteral( "contextualWMSLegend" ), contextualWMSLegend );
uri.setParam( QStringLiteral( "layers" ), layerName );
uri.setParam( QStringLiteral( "styles" ), styles );
@@ -414,25 +418,28 @@ void QgsGeoNodeSourceSelect::addButtonClicked()
// typeName, titleName, sql,
// Build url for WFS
// restrictToRequestBBOX='1' srsname='EPSG:26719' typename='geonode:cab_mun' url='http://demo.geonode.org/geoserver/geonode/wms' table=\"\" sql="
QString uri;
uri += QStringLiteral( " restrictToRequestBBOX='1'" );
uri += QStringLiteral( " srsname='%1'" ).arg( crs );
QgsDataSourceUri uri;

uri.setParam( QStringLiteral( "restrictToRequestBBOX" ), "1" );
uri.setParam( QStringLiteral( "srsname" ), crs );
if ( serviceURL.contains( QStringLiteral( "qgis-server" ) ) )
{
// I need to do this since the typename used in qgis-server is without the workspace.
QString qgisServerTypeName = QString( typeName ).split( ':' ).last();
uri += QStringLiteral( " typename='%1'" ).arg( qgisServerTypeName );
uri.setParam( QStringLiteral( "typename" ), qgisServerTypeName );
}
else
{
uri += QStringLiteral( " typename='%1'" ).arg( typeName );
uri.setParam( QStringLiteral( "typename" ), typeName );
}
uri += QStringLiteral( " url='%1'" ).arg( serviceURL );
uri += QStringLiteral( " table=\"\"" );
uri += QStringLiteral( " sql=" );
uri.setParam( QStringLiteral( "url" ), serviceURL );
//uri.setParam( QStringLiteral( "table" ), QStringLiteral( "\"\"" ) );
//uri.setParam( QStringLiteral( "sql" ), QString() );

QgsDebugMsg( "Add WFS from GeoNode : " + uri + " and typename: " + typeName );
emit addVectorLayer( uri, typeName, QStringLiteral( "WFS" ) );
connection.addWfsConnectionSettings( uri );

QgsDebugMsg( "Add WFS from GeoNode : " + uri.uri() + " and typename: " + typeName );
emit addVectorLayer( uri.uri(), typeName, QStringLiteral( "WFS" ) );
}
else if ( webServiceType == QStringLiteral( "XYZ" ) )
{
@@ -458,3 +465,8 @@ void QgsGeoNodeSourceSelect::updateButtonStateForAvailableConnections()
btnDelete->setEnabled( connectionsAvailable );
btnSave->setEnabled( connectionsAvailable );
}

QgsGeoNodeConnection QgsGeoNodeSourceSelect::currentConnection() const
{
return QgsGeoNodeConnection( cmbConnections->currentText() );
}
@@ -26,6 +26,7 @@
#include "qgsapplication.h"
#include "ui_qgsgeonodesourceselectbase.h"
#include "qgis_gui.h"
#include "qgsgeonodeconnection.h"

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

void updateButtonStateForAvailableConnections();
QgsGeoNodeConnection currentConnection() const;

private slots:
void addConnectionsEntryList();
@@ -96,16 +96,16 @@ QStringList QgsGeoNodeConnectionUtils::connectionList()
{
QgsSettings settings;
// Add Section manually
settings.beginGroup( QStringLiteral( "providers/qgis/connections-geonode" ) );
settings.beginGroup( QStringLiteral( "qgis/connections-geonode" ) );
return settings.childGroups();
}

void QgsGeoNodeConnectionUtils::deleteConnection( const QString &name )
{
QgsSettings settings;
// Add Section manually
settings.remove( QStringLiteral( "providers/qgis/connections-geonode/" ) + name );
settings.remove( QStringLiteral( "providers/qgis/geonode/" ) + name );
settings.remove( QStringLiteral( "qgis/connections-geonode/" ) + name );
settings.remove( QStringLiteral( "qgis/geonode/" ) + name );
}

QString QgsGeoNodeConnectionUtils::pathGeoNodeConnection()

0 comments on commit 687fc52

Please sign in to comment.
You can’t perform that action at this time.