QGIS API Documentation  3.0.2-Girona (307d082)
qgsgeonoderequest.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgeonoderequest.h
3  ---------------------
4  begin : Jul 2017
5  copyright : (C) 2017 by Muhammad Yarjuna Rohmat, Ismail Sunni
6  email : rohmat at kartoza dot com, ismail at kartoza dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSGEONODEREQUEST_H
16 #define QGSGEONODEREQUEST_H
17 
18 #include "qgis.h"
19 #include "qgis_core.h"
20 #include <QNetworkReply>
21 #include <QDomDocument>
22 #include <QObject>
23 #include <QUuid>
24 
31 struct CORE_EXPORT QgsGeoNodeStyle
32 {
33 #ifdef SIP_RUN
34  % TypeHeaderCode
35 #include <qgsgeonoderequest.h>
36  % End
37 #endif
38 
40  QString id;
41 
43  QString name;
44 
46  QString title;
47 
49  QDomDocument body;
50 
52  QString styleUrl;
53 };
54 
65 class CORE_EXPORT QgsGeoNodeRequest : public QObject
66 {
67  Q_OBJECT
68  public:
69 
74  {
76  QUuid uuid;
78  QString name;
80  QString typeName;
82  QString title;
84  QString wmsURL;
86  QString wfsURL;
88  QString xyzURL;
89  };
90 
96  QgsGeoNodeRequest( const QString &baseUrl, bool forceRefresh, QObject *parent = nullptr );
97 
98  ~QgsGeoNodeRequest() override;
99 
112  void request( const QString &endPoint );
113 
123  bool requestBlocking( const QString &endPoint );
124 
139  void fetchLayers();
140 
149  QList<QgsGeoNodeRequest::ServiceLayerDetail> fetchLayersBlocking();
150 
159  QList<QgsGeoNodeStyle> fetchStylesBlocking( const QString &layerName );
160 
167  QgsGeoNodeStyle fetchDefaultStyleBlocking( const QString &layerName );
168 
175  QgsGeoNodeStyle fetchStyleBlocking( const QString &styleId );
176 
183  QStringList fetchServiceUrlsBlocking( const QString &serviceType );
184 
191  QgsStringMap fetchServiceUrlDataBlocking( const QString &serviceType );
192 
197  QString lastError() const { return mError; }
198 
202  QByteArray lastResponse() const { return mHttpGeoNodeResponse; }
203 
208  QString protocol() const;
209 
214  void setProtocol( const QString &protocol );
215 
216  public slots:
217 
221  void abort();
222 
223  signals:
224 
228  void statusChanged( const QString &statusQString );
229 
233  void requestFinished();
234 
238  void layersFetched( const QList<QgsGeoNodeRequest::ServiceLayerDetail> &layers );
239 
240  private slots:
241  void replyFinished();
242  void replyProgress( qint64, qint64 );
243 
244  private:
245 
247  QString mProtocol;
248 
250  QString mBaseUrl;
251 
253  QNetworkReply *mGeoNodeReply = nullptr;
254 
256  QString mError;
257 
259  QString mErrorFormat;
260 
262  QByteArray mHttpGeoNodeResponse;
263 
264  bool mIsAborted = false;
265  bool mForceRefresh = false;
266 
267  QList<QgsGeoNodeRequest::ServiceLayerDetail> parseLayers( const QByteArray &layerResponse );
268  QgsGeoNodeStyle retrieveStyle( const QString &styleUrl );
269 
270  QNetworkReply *requestUrl( const QString &url );
271 
272 };
273 
274 #endif // QGSGEONODEREQUEST_H
Request handler for GeoNode servers.
Encapsulates information about a GeoNode layer style.
QString styleUrl
Associated URL.
Service layer details for an individual layer from a GeoNode connection.
QByteArray lastResponse() const
Returns the most recent response obtained from the server.
QString wmsURL
WMS URL for layer.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:479
QDomDocument body
DOM documenting containing style.
QString xyzURL
XYZ tileserver URL for layer.
QString wfsURL
WFS URL for layer.
QString id
Unique style ID.
QString lastError() const
Returns the most recent error string for any encountered errors, or an empty string if no errors have...
QString name
Style name.
QUuid uuid
Unique identifier (generate on the client side, not at the GeoNode server)
QString title
Style title.