Skip to content
Permalink
Browse files

Class shuffle

  • Loading branch information
nyalldawson committed Sep 8, 2017
1 parent e6a8980 commit 1a1928363461b2776e54b1ba8199f552b8d758c9
@@ -7,22 +7,6 @@
************************************************************************/




struct QgsServiceLayerDetail
{
%TypeHeaderCode
#include <qgsgeonoderequest.h>
%End
QUuid uuid;
QString name;
QString typeName;
QString title;
QString wmsURL;
QString wfsURL;
QString xyzURL;
};

struct QgsGeoNodeStyle
{
%TypeHeaderCode
@@ -43,6 +27,17 @@ class QgsGeoNodeRequest : QObject
%End
public:

struct ServiceLayerDetail
{
QUuid uuid;
QString name;
QString typeName;
QString title;
QString wmsURL;
QString wfsURL;
QString xyzURL;
};

explicit QgsGeoNodeRequest( bool forceRefresh, QObject *parent = 0 );
%Docstring
Constructor for QgsGeoNodeRequest.
@@ -57,9 +52,9 @@ class QgsGeoNodeRequest : QObject
:rtype: bool
%End

QList<QgsServiceLayerDetail> getLayers();
QList<QgsGeoNodeRequest::ServiceLayerDetail> getLayers();
%Docstring
:rtype: list of QgsServiceLayerDetail
:rtype: list of QgsGeoNodeRequest.ServiceLayerDetail
%End

QList<QgsGeoNodeStyle> getStyles( const QString &layerName );
@@ -249,7 +249,7 @@ void QgsGeoNodeNewConnection::testConnection()
QString url = txtUrl->text();
QgsGeoNodeRequest geonodeRequest( url, true );

QList<QgsServiceLayerDetail> layers = geonodeRequest.getLayers();
QList<QgsGeoNodeRequest::ServiceLayerDetail> layers = geonodeRequest.getLayers();
QApplication::restoreOverrideCursor();

if ( !layers.empty() )
@@ -154,7 +154,7 @@ void QgsGeoNodeSourceSelect::connectToGeonodeConnection()
QgsGeoNodeRequest geonodeRequest( url, true );

QApplication::setOverrideCursor( Qt::WaitCursor );
const QList<QgsServiceLayerDetail> layers = geonodeRequest.getLayers();
const QList<QgsGeoNodeRequest::ServiceLayerDetail> layers = geonodeRequest.getLayers();
QApplication::restoreOverrideCursor();

if ( !layers.empty() )
@@ -173,7 +173,7 @@ void QgsGeoNodeSourceSelect::connectToGeonodeConnection()

if ( !layers.isEmpty() )
{
for ( const QgsServiceLayerDetail &layer : layers )
for ( const QgsGeoNodeRequest::ServiceLayerDetail &layer : layers )
{
QUuid uuid = layer.uuid;

@@ -57,9 +57,9 @@ void QgsGeoNodeRequest::abort()
}
}

QList<QgsServiceLayerDetail> QgsGeoNodeRequest::getLayers()
QList<QgsGeoNodeRequest::ServiceLayerDetail> QgsGeoNodeRequest::getLayers()
{
QList<QgsServiceLayerDetail> layers;
QList<QgsGeoNodeRequest::ServiceLayerDetail> layers;
bool success = request( QStringLiteral( "/api/layers/" ) );
if ( !success )
{
@@ -240,9 +240,9 @@ void QgsGeoNodeRequest::replyFinished()

}

QList<QgsServiceLayerDetail> QgsGeoNodeRequest::parseLayers( const QByteArray &layerResponse )
QList<QgsGeoNodeRequest::ServiceLayerDetail> QgsGeoNodeRequest::parseLayers( const QByteArray &layerResponse )
{
QList<QgsServiceLayerDetail> layers;
QList<QgsGeoNodeRequest::ServiceLayerDetail> layers;
if ( layerResponse.isEmpty() )
{
return layers;
@@ -270,7 +270,7 @@ QList<QgsServiceLayerDetail> QgsGeoNodeRequest::parseLayers( const QByteArray &l
{
for ( const QVariant &layer : qgsAsConst( layerList ) )
{
QgsServiceLayerDetail layerStruct;
QgsGeoNodeRequest::ServiceLayerDetail layerStruct;
const QVariantMap layerMap = layer.toMap();
// Find WMS and WFS. XYZ is not available
// Trick to get layer's typename from distribution_url or detail_url
@@ -309,7 +309,7 @@ QList<QgsServiceLayerDetail> QgsGeoNodeRequest::parseLayers( const QByteArray &l
{
for ( const QVariant &layer : qgsAsConst( layerList ) )
{
QgsServiceLayerDetail layerStruct;
QgsGeoNodeRequest::ServiceLayerDetail layerStruct;
const QVariantMap layerMap = layer.toMap();
// Find WMS, WFS, and XYZ link
const QVariantList layerLinks = layerMap.value( QStringLiteral( "links" ) ).toList();
@@ -387,14 +387,14 @@ QStringList QgsGeoNodeRequest::serviceUrls( const QString &serviceType )
{
QStringList urls;

const QList<QgsServiceLayerDetail> layers = getLayers();
const QList<QgsGeoNodeRequest::ServiceLayerDetail> layers = getLayers();

if ( layers.empty() )
{
return urls;
}

for ( const QgsServiceLayerDetail &layer : layers )
for ( const QgsGeoNodeRequest::ServiceLayerDetail &layer : layers )
{
QString url;
if ( QString::compare( serviceType, QStringLiteral( "wms" ), Qt::CaseInsensitive ) == 0 )
@@ -430,14 +430,14 @@ QgsStringMap QgsGeoNodeRequest::serviceUrlData( const QString &serviceType )
{
QgsStringMap urls;

const QList<QgsServiceLayerDetail> layers = getLayers();
const QList<QgsGeoNodeRequest::ServiceLayerDetail> layers = getLayers();

if ( layers.empty() )
{
return urls;
}

for ( const QgsServiceLayerDetail &layer : layers )
for ( const QgsGeoNodeRequest::ServiceLayerDetail &layer : layers )
{
QString url;

@@ -17,29 +17,11 @@

#include "qgis.h"
#include "qgis_core.h"
#include <qnetworkreply.h>
#include <QNetworkReply>
#include <QDomDocument>


#include <QObject>
#include <QUuid>

struct CORE_EXPORT QgsServiceLayerDetail
{
#ifdef SIP_RUN
% TypeHeaderCode
#include <qgsgeonoderequest.h>
% End
#endif
QUuid uuid;
QString name;
QString typeName;
QString title;
QString wmsURL;
QString wfsURL;
QString xyzURL;
};

struct CORE_EXPORT QgsGeoNodeStyle
{
#ifdef SIP_RUN
@@ -59,6 +41,17 @@ class CORE_EXPORT QgsGeoNodeRequest : public QObject
Q_OBJECT
public:

struct ServiceLayerDetail
{
QUuid uuid;
QString name;
QString typeName;
QString title;
QString wmsURL;
QString wfsURL;
QString xyzURL;
};

/**
* Constructor for QgsGeoNodeRequest.
*
@@ -70,7 +63,7 @@ class CORE_EXPORT QgsGeoNodeRequest : public QObject

bool request( const QString &endPoint );

QList<QgsServiceLayerDetail> getLayers();
QList<QgsGeoNodeRequest::ServiceLayerDetail> getLayers();

QList<QgsGeoNodeStyle> getStyles( const QString &layerName );

@@ -97,7 +90,7 @@ class CORE_EXPORT QgsGeoNodeRequest : public QObject
void setProtocol( const QString &protocol );

private:
QList<QgsServiceLayerDetail> parseLayers( const QByteArray &layerResponse );
QList<QgsGeoNodeRequest::ServiceLayerDetail> parseLayers( const QByteArray &layerResponse );
QgsGeoNodeStyle retrieveStyle( const QString &styleUrl );

signals:
@@ -129,7 +129,7 @@ void TestQgsGeoNodeConnection::testLayerAPI()
}

QgsGeoNodeRequest geonodeRequest( mKartozaGeoNodeQGISServerURL, true );
QList<QgsServiceLayerDetail> layers = geonodeRequest.getLayers();
QList<QgsGeoNodeRequest::ServiceLayerDetail> layers = geonodeRequest.getLayers();
QString msg = QStringLiteral( "Number of layers: %1" ).arg( layers.count() );
QgsDebugMsg( msg );
QVERIFY( layers.count() > 0 );

0 comments on commit 1a19283

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