Skip to content

Commit

Permalink
Class shuffle
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 12, 2017
1 parent e6a8980 commit 1a19283
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 53 deletions.
31 changes: 13 additions & 18 deletions python/core/geocms/geonode/qgsgeonoderequest.sip
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/app/geocms/geonode/qgsgeonodenewconnection.cpp
Expand Up @@ -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() )
Expand Down
4 changes: 2 additions & 2 deletions src/app/geocms/geonode/qgsgeonodesourceselect.cpp
Expand Up @@ -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() )
Expand All @@ -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;

Expand Down
20 changes: 10 additions & 10 deletions src/core/geocms/geonode/qgsgeonoderequest.cpp
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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;

Expand Down
35 changes: 14 additions & 21 deletions src/core/geocms/geonode/qgsgeonoderequest.h
Expand Up @@ -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
Expand All @@ -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.
*
Expand All @@ -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 );

Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/testqgsgeonodeconnection.cpp
Expand Up @@ -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 );
Expand Down

0 comments on commit 1a19283

Please sign in to comment.