Skip to content

Commit e1562df

Browse files
committedSep 12, 2017
[geonode] Don't block data source manager while connecting to a server
Also add missing docstrings
1 parent 1a19283 commit e1562df

File tree

10 files changed

+510
-220
lines changed

10 files changed

+510
-220
lines changed
 

‎python/core/geocms/geonode/qgsgeonoderequest.sip

Lines changed: 144 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,43 @@ struct QgsGeoNodeStyle
1212
%TypeHeaderCode
1313
#include <qgsgeonoderequest.h>
1414
%End
15+
1516
QString id;
17+
%Docstring
18+
Unique style ID
19+
%End
20+
1621
QString name;
22+
%Docstring
23+
Style name
24+
%End
25+
1726
QString title;
27+
%Docstring
28+
Style title
29+
%End
30+
1831
QDomDocument body;
32+
%Docstring
33+
DOM documenting containing style
34+
%End
35+
1936
QString styleUrl;
37+
%Docstring
38+
Associated URL
39+
%End
2040
};
2141

2242
class QgsGeoNodeRequest : QObject
2343
{
44+
%Docstring
45+
Request handler for GeoNode servers.
46+
47+
QgsGeoNodeRequest handles requesting and parsing service details from a GeoNode
48+
server instance, for instance requesting all available layers or layer styles.
49+
50+
.. versionadded:: 3.0
51+
%End
2452

2553
%TypeHeaderCode
2654
#include "qgsgeonoderequest.h"
@@ -30,110 +58,192 @@ class QgsGeoNodeRequest : QObject
3058
struct ServiceLayerDetail
3159
{
3260
QUuid uuid;
61+
%Docstring
62+
Unique identifier (generate on the client side, not at the GeoNode server)
63+
%End
3364
QString name;
65+
%Docstring
66+
Layer name
67+
%End
3468
QString typeName;
69+
%Docstring
70+
Layer type name
71+
%End
3572
QString title;
73+
%Docstring
74+
Layer title
75+
%End
3676
QString wmsURL;
77+
%Docstring
78+
WMS URL for layer
79+
%End
3780
QString wfsURL;
81+
%Docstring
82+
WFS URL for layer
83+
%End
3884
QString xyzURL;
85+
%Docstring
86+
XYZ tileserver URL for layer
87+
%End
3988
};
4089

41-
explicit QgsGeoNodeRequest( bool forceRefresh, QObject *parent = 0 );
90+
QgsGeoNodeRequest( const QString &baseUrl, bool forceRefresh, QObject *parent = 0 );
4291
%Docstring
4392
Constructor for QgsGeoNodeRequest.
4493

4594
If ``forceRefresh`` is false, then cached copies of the request may be reused.
4695
%End
47-
QgsGeoNodeRequest( const QString &baseUrl, bool forceRefresh, QObject *parent = 0 );
96+
4897
virtual ~QgsGeoNodeRequest();
4998

50-
bool request( const QString &endPoint );
99+
void request( const QString &endPoint );
100+
%Docstring
101+
Triggers a new request to the GeoNode server, with the requested ``endPoint``.
102+
Any existing request will be aborted.
103+
104+
Calling this method does not block while waiting for a result.
105+
106+
\warning When using the non-blocking methods in this class, sending
107+
overlapping requests results in undefined behavior. Use separate instances
108+
of QgsGeoNodeRequest instead to avoid this.
109+
110+
.. seealso:: requestBlocking()
111+
%End
112+
113+
bool requestBlocking( const QString &endPoint );
51114
%Docstring
115+
Triggers a new request to the GeoNode server, with the requested ``endPoint``.
116+
Any existing request will be aborted.
117+
118+
Calling this method will block while waiting for a result. It should not be
119+
used from any code which potentially blocks operation in the main GUI thread.
120+
121+
.. seealso:: request()
52122
:rtype: bool
53123
%End
54124

55-
QList<QgsGeoNodeRequest::ServiceLayerDetail> getLayers();
125+
void fetchLayers();
56126
%Docstring
127+
Triggers a new request to fetch the list of available layers from the
128+
server. When complete, the layersFetched() signal will be emitted
129+
with the result.
130+
131+
This method is non-blocking and returns immediately.
132+
133+
\warning When using the non-blocking methods in this class, sending
134+
overlapping requests results in undefined behavior. Use separate instances
135+
of QgsGeoNodeRequest instead to avoid this.
136+
137+
.. seealso:: layersFetched()
138+
.. seealso:: fetchLayersBlocking()
139+
%End
140+
141+
QList<QgsGeoNodeRequest::ServiceLayerDetail> fetchLayersBlocking();
142+
%Docstring
143+
Requests the list of available layers from the server.
144+
145+
This method is blocking and will wait for results from the server before returning.
146+
Accordingly it should not be used from any code which potentially blocks operation in the main GUI thread.
147+
148+
.. seealso:: fetchLayers()
57149
:rtype: list of QgsGeoNodeRequest.ServiceLayerDetail
58150
%End
59151

60-
QList<QgsGeoNodeStyle> getStyles( const QString &layerName );
152+
QList<QgsGeoNodeStyle> fetchStylesBlocking( const QString &layerName );
61153
%Docstring
154+
Requests the list of available styles for the layer
155+
with matching ``layerName`` from the server.
156+
157+
This method is blocking and will wait for results from the server before returning.
158+
Accordingly it should not be used from any code which potentially blocks operation in the main GUI thread.
62159
:rtype: list of QgsGeoNodeStyle
63160
%End
64161

65-
QgsGeoNodeStyle getDefaultStyle( const QString &layerName );
162+
QgsGeoNodeStyle fetchDefaultStyleBlocking( const QString &layerName );
66163
%Docstring
164+
Requests the default style for the layer with matching ``layerName`` from the server.
165+
166+
This method is blocking and will wait for results from the server before returning.
167+
Accordingly it should not be used from any code which potentially blocks operation in the main GUI thread.
67168
:rtype: QgsGeoNodeStyle
68169
%End
69170

70-
QgsGeoNodeStyle getStyle( const QString &styleID );
171+
QgsGeoNodeStyle fetchStyleBlocking( const QString &styleId );
71172
%Docstring
173+
Requests the details for the style with matching ``styleId`` from the server.
174+
175+
This method is blocking and will wait for results from the server before returning.
176+
Accordingly it should not be used from any code which potentially blocks operation in the main GUI thread.
72177
:rtype: QgsGeoNodeStyle
73178
%End
74179

75-
QStringList serviceUrls( const QString &serviceType );
180+
QStringList fetchServiceUrlsBlocking( const QString &serviceType );
76181
%Docstring
77-
Obtain list of unique URLs in the geonode
182+
Requests the list of unique URLs for available services with matching ``serviceType`` from the server.
183+
184+
This method is blocking and will wait for results from the server before returning.
185+
Accordingly it should not be used from any code which potentially blocks operation in the main GUI thread.
78186
:rtype: list of str
79187
%End
80188

81-
QgsStringMap serviceUrlData( const QString &serviceType );
189+
QgsStringMap fetchServiceUrlDataBlocking( const QString &serviceType );
82190
%Docstring
83-
Obtain map of layer name and url for a service type
191+
Obtains a map of layer name to URL for available services with matching ``serviceType`` from the server.
192+
193+
This method is blocking and will wait for results from the server before returning.
194+
Accordingly it should not be used from any code which potentially blocks operation in the main GUI thread.
84195
:rtype: QgsStringMap
85196
%End
86197

87198
QString lastError() const;
88199
%Docstring
200+
Returns the most recent error string for any encountered errors, or an empty string if
201+
no errors have been encountered.
89202
:rtype: str
90203
%End
91204

92-
QByteArray response() const;
205+
QByteArray lastResponse() const;
93206
%Docstring
207+
Returns the most recent response obtained from the server.
94208
:rtype: QByteArray
95209
%End
96210

97-
QNetworkReply *reply() const;
211+
QString protocol() const;
98212
%Docstring
99-
:rtype: QNetworkReply
213+
Returns the network protocol (e.g. 'http') used for connecting with the server.
214+
.. seealso:: setProtocol()
215+
:rtype: str
100216
%End
101217

102-
void abort();
218+
void setProtocol( const QString &protocol );
103219
%Docstring
104-
Abort network request immediately
220+
Sets the network ``protocol`` (e.g. 'http') used for connecting with the server.
221+
.. seealso:: protocol()
105222
%End
106223

107-
QString getProtocol() const;
224+
public slots:
225+
226+
void abort();
108227
%Docstring
109-
:rtype: str
228+
Aborts any active network request immediately.
110229
%End
111-
void setProtocol( const QString &protocol );
112230

113231
signals:
232+
114233
void statusChanged( const QString &statusQString );
115234
%Docstring
116-
emit a signal to be caught by qgisapp and display a statusQString on status bar
235+
Emitted when the status of an ongoing request is changed.
117236
%End
118237

119238
void requestFinished();
120239
%Docstring
121-
emit a signal once the request is finished
240+
Emitted when the existing request has been completed.
122241
%End
123242

124-
protected slots:
125-
void replyFinished();
126-
void replyProgress( qint64, qint64 );
127-
128-
protected:
129-
130-
131-
132-
133-
134-
135-
136-
243+
void layersFetched( const QList<QgsGeoNodeRequest::ServiceLayerDetail> &layers );
244+
%Docstring
245+
Emitted when the result of a fetchLayers call has been received and processed.
246+
%End
137247

138248
};
139249

‎src/app/geocms/geonode/qgsgeonodedataitems.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ QVector<QgsDataItem *> QgsGeoNodeConnectionItem::createChildren()
3838
QString url = mConnection->uri().param( QStringLiteral( "url" ) );
3939
QgsGeoNodeRequest geonodeRequest( url, true );
4040

41-
QStringList wmsUrl = geonodeRequest.serviceUrls( QStringLiteral( "WMS" ) );
42-
QStringList wfsUrl = geonodeRequest.serviceUrls( QStringLiteral( "WFS" ) );
43-
QStringList xyzUrl = geonodeRequest.serviceUrls( QStringLiteral( "XYZ" ) );
41+
QStringList wmsUrl = geonodeRequest.fetchServiceUrlsBlocking( QStringLiteral( "WMS" ) );
42+
QStringList wfsUrl = geonodeRequest.fetchServiceUrlsBlocking( QStringLiteral( "WFS" ) );
43+
QStringList xyzUrl = geonodeRequest.fetchServiceUrlsBlocking( QStringLiteral( "XYZ" ) );
4444

4545
if ( !wmsUrl.isEmpty() )
4646
{

‎src/app/geocms/geonode/qgsgeonodenewconnection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void QgsGeoNodeNewConnection::testConnection()
249249
QString url = txtUrl->text();
250250
QgsGeoNodeRequest geonodeRequest( url, true );
251251

252-
QList<QgsGeoNodeRequest::ServiceLayerDetail> layers = geonodeRequest.getLayers();
252+
QList<QgsGeoNodeRequest::ServiceLayerDetail> layers = geonodeRequest.fetchLayersBlocking();
253253
QApplication::restoreOverrideCursor();
254254

255255
if ( !layers.empty() )

‎src/app/geocms/geonode/qgsgeonodesourceselect.cpp

Lines changed: 114 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ QgsGeoNodeSourceSelect::QgsGeoNodeSourceSelect( QWidget *parent, Qt::WindowFlags
7272
treeView->setModel( mModelProxy );
7373
}
7474

75+
QgsGeoNodeSourceSelect::~QgsGeoNodeSourceSelect()
76+
{
77+
emit abortRequests();
78+
}
79+
7580
void QgsGeoNodeSourceSelect::addConnectionsEntryList()
7681
{
7782
QgsGeoNodeNewConnection nc( this );
@@ -147,141 +152,146 @@ void QgsGeoNodeSourceSelect::showHelp()
147152

148153
void QgsGeoNodeSourceSelect::connectToGeonodeConnection()
149154
{
150-
QApplication::setOverrideCursor( Qt::BusyCursor );
151155
QgsGeoNodeConnection connection( cmbConnections->currentText() );
152156

153157
QString url = connection.uri().param( QStringLiteral( "url" ) );
154-
QgsGeoNodeRequest geonodeRequest( url, true );
155-
156-
QApplication::setOverrideCursor( Qt::WaitCursor );
157-
const QList<QgsGeoNodeRequest::ServiceLayerDetail> layers = geonodeRequest.getLayers();
158-
QApplication::restoreOverrideCursor();
159-
160-
if ( !layers.empty() )
158+
QgsGeoNodeRequest *geonodeRequest = new QgsGeoNodeRequest( url, true );
159+
connect( this, &QgsGeoNodeSourceSelect::abortRequests, geonodeRequest, &QgsGeoNodeRequest::abort );
160+
connect( geonodeRequest, &QgsGeoNodeRequest::requestFinished, geonodeRequest, [geonodeRequest]
161161
{
162-
QgsDebugMsg( QStringLiteral( "Success, non empty layers %1" ).arg( layers.count( ) ) );
163-
}
164-
else
162+
QApplication::restoreOverrideCursor();
163+
geonodeRequest->deleteLater();
164+
} );
165+
connect( geonodeRequest, &QgsGeoNodeRequest::layersFetched, this, [ = ]( const QList< QgsGeoNodeRequest::ServiceLayerDetail > layers )
165166
{
166-
QgsMessageLog::logMessage( QStringLiteral( "Failed, empty layers" ), tr( "GeoNode" ) );
167-
}
167+
if ( !layers.empty() )
168+
{
169+
QgsDebugMsg( QStringLiteral( "Success, non empty layers %1" ).arg( layers.count( ) ) );
170+
}
171+
else
172+
{
173+
QgsMessageLog::logMessage( QStringLiteral( "Failed, empty layers" ), tr( "GeoNode" ) );
174+
}
168175

169-
if ( mModel )
170-
{
171-
mModel->removeRows( 0, mModel->rowCount() );
172-
}
176+
if ( mModel )
177+
{
178+
mModel->removeRows( 0, mModel->rowCount() );
179+
}
173180

174-
if ( !layers.isEmpty() )
175-
{
176-
for ( const QgsGeoNodeRequest::ServiceLayerDetail &layer : layers )
181+
if ( !layers.isEmpty() )
177182
{
178-
QUuid uuid = layer.uuid;
183+
for ( const QgsGeoNodeRequest::ServiceLayerDetail &layer : layers )
184+
{
185+
QUuid uuid = layer.uuid;
179186

180-
QString wmsURL = layer.wmsURL;
181-
QString wfsURL = layer.wfsURL;
182-
QString xyzURL = layer.xyzURL;
187+
QString wmsURL = layer.wmsURL;
188+
QString wfsURL = layer.wfsURL;
189+
QString xyzURL = layer.xyzURL;
183190

184-
if ( !wmsURL.isEmpty() )
185-
{
186-
QStandardItem *titleItem = new QStandardItem( layer.title );
187-
QStandardItem *nameItem;
188-
if ( !layer.name.isEmpty() )
191+
if ( !wmsURL.isEmpty() )
189192
{
190-
nameItem = new QStandardItem( layer.name );
193+
QStandardItem *titleItem = new QStandardItem( layer.title );
194+
QStandardItem *nameItem;
195+
if ( !layer.name.isEmpty() )
196+
{
197+
nameItem = new QStandardItem( layer.name );
198+
}
199+
else
200+
{
201+
nameItem = new QStandardItem( layer.title );
202+
}
203+
QStandardItem *serviceTypeItem = new QStandardItem( tr( "Layer" ) );
204+
QStandardItem *webServiceTypeItem = new QStandardItem( tr( "WMS" ) );
205+
206+
QString typeName = layer.typeName;
207+
208+
titleItem->setData( uuid, Qt::UserRole + 1 );
209+
titleItem->setData( wmsURL, Qt::UserRole + 2 );
210+
titleItem->setData( typeName, Qt::UserRole + 3 );
211+
typedef QList< QStandardItem * > StandardItemList;
212+
mModel->appendRow( StandardItemList() << titleItem << nameItem << serviceTypeItem << webServiceTypeItem );
191213
}
192214
else
193215
{
194-
nameItem = new QStandardItem( layer.title );
216+
QgsDebugMsgLevel( QStringLiteral( "Layer %1 does not have WMS url." ).arg( layer.title ), 3 );
195217
}
196-
QStandardItem *serviceTypeItem = new QStandardItem( tr( "Layer" ) );
197-
QStandardItem *webServiceTypeItem = new QStandardItem( tr( "WMS" ) );
198-
199-
QString typeName = layer.typeName;
200-
201-
titleItem->setData( uuid, Qt::UserRole + 1 );
202-
titleItem->setData( wmsURL, Qt::UserRole + 2 );
203-
titleItem->setData( typeName, Qt::UserRole + 3 );
204-
typedef QList< QStandardItem * > StandardItemList;
205-
mModel->appendRow( StandardItemList() << titleItem << nameItem << serviceTypeItem << webServiceTypeItem );
206-
}
207-
else
208-
{
209-
QgsDebugMsgLevel( QStringLiteral( "Layer %1 does not have WMS url." ).arg( layer.title ), 3 );
210-
}
211-
if ( !wfsURL.isEmpty() )
212-
{
213-
QStandardItem *titleItem = new QStandardItem( layer.title );
214-
QStandardItem *nameItem;
215-
if ( !layer.name.isEmpty() )
218+
if ( !wfsURL.isEmpty() )
216219
{
217-
nameItem = new QStandardItem( layer.name );
220+
QStandardItem *titleItem = new QStandardItem( layer.title );
221+
QStandardItem *nameItem;
222+
if ( !layer.name.isEmpty() )
223+
{
224+
nameItem = new QStandardItem( layer.name );
225+
}
226+
else
227+
{
228+
nameItem = new QStandardItem( layer.title );
229+
}
230+
QStandardItem *serviceTypeItem = new QStandardItem( tr( "Layer" ) );
231+
QStandardItem *webServiceTypeItem = new QStandardItem( tr( "WFS" ) );
232+
233+
QString typeName = layer.typeName;
234+
235+
titleItem->setData( uuid, Qt::UserRole + 1 );
236+
titleItem->setData( wfsURL, Qt::UserRole + 2 );
237+
titleItem->setData( typeName, Qt::UserRole + 3 );
238+
typedef QList< QStandardItem * > StandardItemList;
239+
mModel->appendRow( StandardItemList() << titleItem << nameItem << serviceTypeItem << webServiceTypeItem );
218240
}
219241
else
220242
{
221-
nameItem = new QStandardItem( layer.title );
243+
QgsDebugMsgLevel( QStringLiteral( "Layer %1 does not have WFS url." ).arg( layer.title ), 3 );
222244
}
223-
QStandardItem *serviceTypeItem = new QStandardItem( tr( "Layer" ) );
224-
QStandardItem *webServiceTypeItem = new QStandardItem( tr( "WFS" ) );
225-
226-
QString typeName = layer.typeName;
227-
228-
titleItem->setData( uuid, Qt::UserRole + 1 );
229-
titleItem->setData( wfsURL, Qt::UserRole + 2 );
230-
titleItem->setData( typeName, Qt::UserRole + 3 );
231-
typedef QList< QStandardItem * > StandardItemList;
232-
mModel->appendRow( StandardItemList() << titleItem << nameItem << serviceTypeItem << webServiceTypeItem );
233-
}
234-
else
235-
{
236-
QgsDebugMsgLevel( QStringLiteral( "Layer %1 does not have WFS url." ).arg( layer.title ), 3 );
237-
}
238-
if ( !xyzURL.isEmpty() )
239-
{
240-
QStandardItem *titleItem = new QStandardItem( layer.title );
241-
QStandardItem *nameItem;
242-
if ( !layer.name.isEmpty() )
245+
if ( !xyzURL.isEmpty() )
243246
{
244-
nameItem = new QStandardItem( layer.name );
247+
QStandardItem *titleItem = new QStandardItem( layer.title );
248+
QStandardItem *nameItem;
249+
if ( !layer.name.isEmpty() )
250+
{
251+
nameItem = new QStandardItem( layer.name );
252+
}
253+
else
254+
{
255+
nameItem = new QStandardItem( layer.title );
256+
}
257+
QStandardItem *serviceTypeItem = new QStandardItem( tr( "Layer" ) );
258+
QStandardItem *webServiceTypeItem = new QStandardItem( tr( "XYZ" ) );
259+
260+
QString typeName = layer.typeName;
261+
262+
titleItem->setData( uuid, Qt::UserRole + 1 );
263+
titleItem->setData( xyzURL, Qt::UserRole + 2 );
264+
titleItem->setData( typeName, Qt::UserRole + 3 );
265+
typedef QList< QStandardItem * > StandardItemList;
266+
mModel->appendRow( StandardItemList() << titleItem << nameItem << serviceTypeItem << webServiceTypeItem );
245267
}
246268
else
247269
{
248-
nameItem = new QStandardItem( layer.title );
270+
QgsDebugMsgLevel( QStringLiteral( "Layer %1 does not have XYZ url." ).arg( layer.title ), 3 );
249271
}
250-
QStandardItem *serviceTypeItem = new QStandardItem( tr( "Layer" ) );
251-
QStandardItem *webServiceTypeItem = new QStandardItem( tr( "XYZ" ) );
252-
253-
QString typeName = layer.typeName;
254-
255-
titleItem->setData( uuid, Qt::UserRole + 1 );
256-
titleItem->setData( xyzURL, Qt::UserRole + 2 );
257-
titleItem->setData( typeName, Qt::UserRole + 3 );
258-
typedef QList< QStandardItem * > StandardItemList;
259-
mModel->appendRow( StandardItemList() << titleItem << nameItem << serviceTypeItem << webServiceTypeItem );
260-
}
261-
else
262-
{
263-
QgsDebugMsgLevel( QStringLiteral( "Layer %1 does not have XYZ url." ).arg( layer.title ), 3 );
264272
}
265273
}
266-
}
267274

268-
else
269-
{
270-
QMessageBox::critical( this, tr( "Connect to GeoNode" ), tr( "Cannot get any feature services" ) );
271-
}
275+
else
276+
{
277+
QMessageBox::critical( this, tr( "Connect to GeoNode" ), tr( "Cannot get any feature services" ) );
278+
}
272279

273-
treeView->resizeColumnToContents( MODEL_IDX_TITLE );
274-
treeView->resizeColumnToContents( MODEL_IDX_NAME );
275-
treeView->resizeColumnToContents( MODEL_IDX_TYPE );
276-
treeView->resizeColumnToContents( MODEL_IDX_WEB_SERVICE );
277-
for ( int i = MODEL_IDX_TITLE; i < MODEL_IDX_WEB_SERVICE; i++ )
278-
{
279-
if ( treeView->columnWidth( i ) > 210 )
280+
treeView->resizeColumnToContents( MODEL_IDX_TITLE );
281+
treeView->resizeColumnToContents( MODEL_IDX_NAME );
282+
treeView->resizeColumnToContents( MODEL_IDX_TYPE );
283+
treeView->resizeColumnToContents( MODEL_IDX_WEB_SERVICE );
284+
for ( int i = MODEL_IDX_TITLE; i < MODEL_IDX_WEB_SERVICE; i++ )
280285
{
281-
treeView->setColumnWidth( i, 210 );
286+
if ( treeView->columnWidth( i ) > 210 )
287+
{
288+
treeView->setColumnWidth( i, 210 );
289+
}
282290
}
283-
}
284-
QApplication::restoreOverrideCursor();
291+
} );
292+
293+
QApplication::setOverrideCursor( Qt::BusyCursor );
294+
geonodeRequest->fetchLayers();
285295
}
286296

287297
void QgsGeoNodeSourceSelect::saveGeonodeConnection()

‎src/app/geocms/geonode/qgsgeonodesourceselect.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,16 @@ class QgsGeoNodeSourceSelect: public QgsAbstractDataSourceWidget, private Ui::Qg
4242
public:
4343

4444
QgsGeoNodeSourceSelect( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
45+
~QgsGeoNodeSourceSelect();
4546

4647
public slots:
4748

4849
void addButtonClicked() override;
4950

51+
signals:
52+
53+
void abortRequests();
54+
5055
private:
5156

5257
/** Stores the available CRS for a server connections.

‎src/core/geocms/geonode/qgsgeonoderequest.cpp

Lines changed: 70 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@
2727
#include <QUrl>
2828
#include <QDomDocument>
2929

30-
QgsGeoNodeRequest::QgsGeoNodeRequest( bool forceRefresh, QObject *parent )
31-
: QObject( parent )
32-
, mForceRefresh( forceRefresh )
33-
{
34-
35-
}
36-
3730
QgsGeoNodeRequest::QgsGeoNodeRequest( const QString &baseUrl, bool forceRefresh, QObject *parent )
3831
: QObject( parent )
3932
, mBaseUrl( baseUrl )
@@ -57,27 +50,51 @@ void QgsGeoNodeRequest::abort()
5750
}
5851
}
5952

60-
QList<QgsGeoNodeRequest::ServiceLayerDetail> QgsGeoNodeRequest::getLayers()
53+
void QgsGeoNodeRequest::fetchLayers()
54+
{
55+
request( QStringLiteral( "/api/layers/" ) );
56+
QObject *obj = new QObject( this );
57+
58+
connect( this, &QgsGeoNodeRequest::requestFinished, obj, [obj, this ]
59+
{
60+
QList<QgsGeoNodeRequest::ServiceLayerDetail> layers;
61+
if ( mError.isEmpty() )
62+
{
63+
layers = parseLayers( this->lastResponse() );
64+
}
65+
emit layersFetched( layers );
66+
67+
obj->deleteLater();
68+
} );
69+
}
70+
71+
QList<QgsGeoNodeRequest::ServiceLayerDetail> QgsGeoNodeRequest::fetchLayersBlocking()
6172
{
6273
QList<QgsGeoNodeRequest::ServiceLayerDetail> layers;
63-
bool success = request( QStringLiteral( "/api/layers/" ) );
64-
if ( !success )
74+
75+
QEventLoop loop;
76+
connect( this, &QgsGeoNodeRequest::requestFinished, &loop, &QEventLoop::quit );
77+
QObject *obj = new QObject( this );
78+
connect( this, &QgsGeoNodeRequest::layersFetched, obj, [&]( const QList<QgsGeoNodeRequest::ServiceLayerDetail> &fetched )
6579
{
66-
return layers;
67-
}
68-
return parseLayers( this->response() );
80+
layers = fetched;
81+
} );
82+
fetchLayers();
83+
loop.exec( QEventLoop::ExcludeUserInputEvents );
84+
delete obj;
85+
return layers;
6986
}
7087

71-
QgsGeoNodeStyle QgsGeoNodeRequest::getDefaultStyle( const QString &layerName )
88+
QgsGeoNodeStyle QgsGeoNodeRequest::fetchDefaultStyleBlocking( const QString &layerName )
7289
{
7390
QgsGeoNodeStyle defaultStyle;
74-
bool success = request( QStringLiteral( "/api/layers?name=" ) + layerName );
91+
bool success = requestBlocking( QStringLiteral( "/api/layers?name=" ) + layerName );
7592
if ( !success )
7693
{
7794
return defaultStyle;
7895
}
7996

80-
const QJsonDocument jsonDocument = QJsonDocument::fromJson( this->response() );
97+
const QJsonDocument jsonDocument = QJsonDocument::fromJson( this->lastResponse() );
8198
const QJsonObject jsonObject = jsonDocument.object();
8299
const QList<QVariant> layers = jsonObject.toVariantMap().value( QStringLiteral( "objects" ) ).toList();
83100
if ( layers.count() < 1 )
@@ -92,16 +109,16 @@ QgsGeoNodeStyle QgsGeoNodeRequest::getDefaultStyle( const QString &layerName )
92109

93110
}
94111

95-
QList<QgsGeoNodeStyle> QgsGeoNodeRequest::getStyles( const QString &layerName )
112+
QList<QgsGeoNodeStyle> QgsGeoNodeRequest::fetchStylesBlocking( const QString &layerName )
96113
{
97114
QList<QgsGeoNodeStyle> geoNodeStyles;
98-
bool success = request( QStringLiteral( "/api/styles?layer__name=" ) + layerName );
115+
bool success = requestBlocking( QStringLiteral( "/api/styles?layer__name=" ) + layerName );
99116
if ( !success )
100117
{
101118
return geoNodeStyles;
102119
}
103120

104-
const QJsonDocument jsonDocument = QJsonDocument::fromJson( this->response() );
121+
const QJsonDocument jsonDocument = QJsonDocument::fromJson( this->lastResponse() );
105122
const QJsonObject jsobObject = jsonDocument.object();
106123
const QList<QVariant> styles = jsobObject.toVariantMap().value( QStringLiteral( "objects" ) ).toList();
107124

@@ -120,9 +137,9 @@ QList<QgsGeoNodeStyle> QgsGeoNodeRequest::getStyles( const QString &layerName )
120137

121138
}
122139

123-
QgsGeoNodeStyle QgsGeoNodeRequest::getStyle( const QString &styleID )
140+
QgsGeoNodeStyle QgsGeoNodeRequest::fetchStyleBlocking( const QString &styleId )
124141
{
125-
QString endPoint = QStringLiteral( "/api/styles/" ) + styleID;
142+
QString endPoint = QStringLiteral( "/api/styles/" ) + styleId;
126143

127144
return retrieveStyle( endPoint );
128145
}
@@ -134,7 +151,7 @@ void QgsGeoNodeRequest::replyProgress( qint64 bytesReceived, qint64 bytesTotal )
134151
emit statusChanged( msg );
135152
}
136153

137-
QString QgsGeoNodeRequest::getProtocol() const
154+
QString QgsGeoNodeRequest::protocol() const
138155
{
139156
return mProtocol;
140157
}
@@ -159,7 +176,6 @@ void QgsGeoNodeRequest::replyFinished()
159176
emit statusChanged( QStringLiteral( "GeoNode request redirected." ) );
160177

161178
const QUrl &toUrl = redirect.toUrl();
162-
mGeoNodeReply->request();
163179
if ( toUrl == mGeoNodeReply->url() )
164180
{
165181
mError = tr( "Redirect loop detected: %1" ).arg( toUrl.toString() );
@@ -237,7 +253,6 @@ void QgsGeoNodeRequest::replyFinished()
237253
}
238254

239255
emit requestFinished();
240-
241256
}
242257

243258
QList<QgsGeoNodeRequest::ServiceLayerDetail> QgsGeoNodeRequest::parseLayers( const QByteArray &layerResponse )
@@ -354,12 +369,12 @@ QgsGeoNodeStyle QgsGeoNodeRequest::retrieveStyle( const QString &styleUrl )
354369
{
355370
QgsGeoNodeStyle geoNodeStyle;
356371

357-
bool success = request( styleUrl );
372+
bool success = requestBlocking( styleUrl );
358373
if ( !success )
359374
{
360375
return geoNodeStyle;
361376
}
362-
const QJsonDocument jsonDocument = QJsonDocument::fromJson( this->response() );
377+
const QJsonDocument jsonDocument = QJsonDocument::fromJson( this->lastResponse() );
363378
const QJsonObject jsonObject = jsonDocument.object();
364379

365380
const QVariantMap jsonMap = jsonObject.toVariantMap();
@@ -368,13 +383,13 @@ QgsGeoNodeStyle QgsGeoNodeRequest::retrieveStyle( const QString &styleUrl )
368383
geoNodeStyle.title = jsonMap.value( QStringLiteral( "title" ) ).toString();
369384
geoNodeStyle.styleUrl = jsonMap.value( QStringLiteral( "style_url" ) ).toString();
370385

371-
success = request( geoNodeStyle.styleUrl );
386+
success = requestBlocking( geoNodeStyle.styleUrl );
372387
if ( !success )
373388
{
374389
return geoNodeStyle;
375390
}
376391

377-
success = geoNodeStyle.body.setContent( this->response() );
392+
success = geoNodeStyle.body.setContent( this->lastResponse() );
378393
if ( !success )
379394
{
380395
return geoNodeStyle;
@@ -383,11 +398,11 @@ QgsGeoNodeStyle QgsGeoNodeRequest::retrieveStyle( const QString &styleUrl )
383398
return geoNodeStyle;
384399
}
385400

386-
QStringList QgsGeoNodeRequest::serviceUrls( const QString &serviceType )
401+
QStringList QgsGeoNodeRequest::fetchServiceUrlsBlocking( const QString &serviceType )
387402
{
388403
QStringList urls;
389404

390-
const QList<QgsGeoNodeRequest::ServiceLayerDetail> layers = getLayers();
405+
const QList<QgsGeoNodeRequest::ServiceLayerDetail> layers = fetchLayersBlocking();
391406

392407
if ( layers.empty() )
393408
{
@@ -415,7 +430,7 @@ QStringList QgsGeoNodeRequest::serviceUrls( const QString &serviceType )
415430

416431
if ( !url.contains( QLatin1String( "://" ) ) )
417432
{
418-
url.prepend( getProtocol() );
433+
url.prepend( protocol() );
419434
}
420435
if ( !urls.contains( url ) )
421436
{
@@ -426,11 +441,11 @@ QStringList QgsGeoNodeRequest::serviceUrls( const QString &serviceType )
426441
return urls;
427442
}
428443

429-
QgsStringMap QgsGeoNodeRequest::serviceUrlData( const QString &serviceType )
444+
QgsStringMap QgsGeoNodeRequest::fetchServiceUrlDataBlocking( const QString &serviceType )
430445
{
431446
QgsStringMap urls;
432447

433-
const QList<QgsGeoNodeRequest::ServiceLayerDetail> layers = getLayers();
448+
const QList<QgsGeoNodeRequest::ServiceLayerDetail> layers = fetchLayersBlocking();
434449

435450
if ( layers.empty() )
436451
{
@@ -460,7 +475,7 @@ QgsStringMap QgsGeoNodeRequest::serviceUrlData( const QString &serviceType )
460475
QString layerName = layer.name;
461476
if ( !url.contains( QLatin1String( "://" ) ) )
462477
{
463-
url.prepend( getProtocol() );
478+
url.prepend( protocol() );
464479
}
465480
if ( !urls.contains( url ) )
466481
{
@@ -471,7 +486,7 @@ QgsStringMap QgsGeoNodeRequest::serviceUrlData( const QString &serviceType )
471486
return urls;
472487
}
473488

474-
bool QgsGeoNodeRequest::request( const QString &endPoint )
489+
void QgsGeoNodeRequest::request( const QString &endPoint )
475490
{
476491
abort();
477492
mIsAborted = false;
@@ -480,25 +495,35 @@ bool QgsGeoNodeRequest::request( const QString &endPoint )
480495
QgsDebugMsg( "Requesting to " + url );
481496
setProtocol( url.split( QStringLiteral( "://" ) ).at( 0 ) );
482497
QUrl layerUrl( url );
483-
layerUrl.setScheme( getProtocol() );
498+
layerUrl.setScheme( protocol() );
484499

485500
mError.clear();
486501

487-
QNetworkRequest request( url );
488-
// Add authentication check here
489-
490-
request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, mForceRefresh ? QNetworkRequest::AlwaysNetwork : QNetworkRequest::PreferCache );
491-
request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );
492-
493-
mGeoNodeReply = QgsNetworkAccessManager::instance()->get( request );
494-
502+
mGeoNodeReply = requestUrl( url );
495503
connect( mGeoNodeReply, &QNetworkReply::finished, this, &QgsGeoNodeRequest::replyFinished, Qt::DirectConnection );
496504
connect( mGeoNodeReply, &QNetworkReply::downloadProgress, this, &QgsGeoNodeRequest::replyProgress, Qt::DirectConnection );
505+
}
506+
507+
bool QgsGeoNodeRequest::requestBlocking( const QString &endPoint )
508+
{
509+
request( endPoint );
497510

498511
QEventLoop loop;
499512
connect( this, &QgsGeoNodeRequest::requestFinished, &loop, &QEventLoop::quit );
500-
501513
loop.exec( QEventLoop::ExcludeUserInputEvents );
502514

503515
return mError.isEmpty();
504516
}
517+
518+
QNetworkReply *QgsGeoNodeRequest::requestUrl( const QString &url )
519+
{
520+
QNetworkRequest request( url );
521+
// Add authentication check here
522+
523+
request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, mForceRefresh ? QNetworkRequest::AlwaysNetwork : QNetworkRequest::PreferCache );
524+
request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );
525+
526+
return QgsNetworkAccessManager::instance()->get( request );
527+
}
528+
529+

‎src/core/geocms/geonode/qgsgeonoderequest.h

Lines changed: 165 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,69 @@
2222
#include <QObject>
2323
#include <QUuid>
2424

25+
/**
26+
* \ingroup core
27+
* \class QgsGeoNodeStyle
28+
* \brief Encapsulates information about a GeoNode layer style.
29+
* \since QGIS 3.0
30+
*/
2531
struct CORE_EXPORT QgsGeoNodeStyle
2632
{
2733
#ifdef SIP_RUN
2834
% TypeHeaderCode
2935
#include <qgsgeonoderequest.h>
3036
% End
3137
#endif
38+
39+
//! Unique style ID
3240
QString id;
41+
42+
//! Style name
3343
QString name;
44+
45+
//! Style title
3446
QString title;
47+
48+
//! DOM documenting containing style
3549
QDomDocument body;
50+
51+
//! Associated URL
3652
QString styleUrl;
3753
};
3854

55+
/**
56+
* \ingroup core
57+
* \class QgsGeoNodeRequest
58+
* \brief Request handler for GeoNode servers.
59+
*
60+
* QgsGeoNodeRequest handles requesting and parsing service details from a GeoNode
61+
* server instance, for instance requesting all available layers or layer styles.
62+
*
63+
* \since QGIS 3.0
64+
*/
3965
class CORE_EXPORT QgsGeoNodeRequest : public QObject
4066
{
4167
Q_OBJECT
4268
public:
4369

70+
/**
71+
* Service layer details for an individual layer from a GeoNode connection.
72+
*/
4473
struct ServiceLayerDetail
4574
{
75+
//! Unique identifier (generate on the client side, not at the GeoNode server)
4676
QUuid uuid;
77+
//! Layer name
4778
QString name;
79+
//! Layer type name
4880
QString typeName;
81+
//! Layer title
4982
QString title;
83+
//! WMS URL for layer
5084
QString wmsURL;
85+
//! WFS URL for layer
5186
QString wfsURL;
87+
//! XYZ tileserver URL for layer
5288
QString xyzURL;
5389
};
5490

@@ -57,63 +93,162 @@ class CORE_EXPORT QgsGeoNodeRequest : public QObject
5793
*
5894
* If \a forceRefresh is false, then cached copies of the request may be reused.
5995
*/
60-
explicit QgsGeoNodeRequest( bool forceRefresh, QObject *parent = nullptr );
6196
QgsGeoNodeRequest( const QString &baseUrl, bool forceRefresh, QObject *parent = nullptr );
97+
6298
virtual ~QgsGeoNodeRequest();
6399

64-
bool request( const QString &endPoint );
100+
/**
101+
* Triggers a new request to the GeoNode server, with the requested \a endPoint.
102+
* Any existing request will be aborted.
103+
*
104+
* Calling this method does not block while waiting for a result.
105+
*
106+
* \warning When using the non-blocking methods in this class, sending
107+
* overlapping requests results in undefined behavior. Use separate instances
108+
* of QgsGeoNodeRequest instead to avoid this.
109+
*
110+
* \see requestBlocking()
111+
*/
112+
void request( const QString &endPoint );
65113

66-
QList<QgsGeoNodeRequest::ServiceLayerDetail> getLayers();
114+
/**
115+
* Triggers a new request to the GeoNode server, with the requested \a endPoint.
116+
* Any existing request will be aborted.
117+
*
118+
* Calling this method will block while waiting for a result. It should not be
119+
* used from any code which potentially blocks operation in the main GUI thread.
120+
*
121+
* \see request()
122+
*/
123+
bool requestBlocking( const QString &endPoint );
67124

68-
QList<QgsGeoNodeStyle> getStyles( const QString &layerName );
125+
/**
126+
* Triggers a new request to fetch the list of available layers from the
127+
* server. When complete, the layersFetched() signal will be emitted
128+
* with the result.
129+
*
130+
* This method is non-blocking and returns immediately.
131+
*
132+
* \warning When using the non-blocking methods in this class, sending
133+
* overlapping requests results in undefined behavior. Use separate instances
134+
* of QgsGeoNodeRequest instead to avoid this.
135+
*
136+
* \see layersFetched()
137+
* \see fetchLayersBlocking()
138+
*/
139+
void fetchLayers();
69140

70-
QgsGeoNodeStyle getDefaultStyle( const QString &layerName );
141+
/**
142+
* Requests the list of available layers from the server.
143+
*
144+
* This method is blocking and will wait for results from the server before returning.
145+
* Accordingly it should not be used from any code which potentially blocks operation in the main GUI thread.
146+
*
147+
* \see fetchLayers()
148+
*/
149+
QList<QgsGeoNodeRequest::ServiceLayerDetail> fetchLayersBlocking();
71150

72-
QgsGeoNodeStyle getStyle( const QString &styleID );
151+
/**
152+
* Requests the list of available styles for the layer
153+
* with matching \a layerName from the server.
154+
*
155+
* This method is blocking and will wait for results from the server before returning.
156+
* Accordingly it should not be used from any code which potentially blocks operation in the main GUI thread.
157+
*
158+
*/
159+
QList<QgsGeoNodeStyle> fetchStylesBlocking( const QString &layerName );
73160

74-
//! Obtain list of unique URLs in the geonode
75-
QStringList serviceUrls( const QString &serviceType );
161+
/**
162+
* Requests the default style for the layer with matching \a layerName from the server.
163+
*
164+
* This method is blocking and will wait for results from the server before returning.
165+
* Accordingly it should not be used from any code which potentially blocks operation in the main GUI thread.
166+
*/
167+
QgsGeoNodeStyle fetchDefaultStyleBlocking( const QString &layerName );
76168

77-
//! Obtain map of layer name and url for a service type
78-
QgsStringMap serviceUrlData( const QString &serviceType );
169+
/**
170+
* Requests the details for the style with matching \a styleId from the server.
171+
*
172+
* This method is blocking and will wait for results from the server before returning.
173+
* Accordingly it should not be used from any code which potentially blocks operation in the main GUI thread.
174+
*/
175+
QgsGeoNodeStyle fetchStyleBlocking( const QString &styleId );
79176

80-
QString lastError() const { return mError; }
177+
/**
178+
* Requests the list of unique URLs for available services with matching \a serviceType from the server.
179+
*
180+
* This method is blocking and will wait for results from the server before returning.
181+
* Accordingly it should not be used from any code which potentially blocks operation in the main GUI thread.
182+
*/
183+
QStringList fetchServiceUrlsBlocking( const QString &serviceType );
81184

82-
QByteArray response() const { return mHttpGeoNodeResponse; }
185+
/**
186+
* Obtains a map of layer name to URL for available services with matching \a serviceType from the server.
187+
*
188+
* This method is blocking and will wait for results from the server before returning.
189+
* Accordingly it should not be used from any code which potentially blocks operation in the main GUI thread.
190+
*/
191+
QgsStringMap fetchServiceUrlDataBlocking( const QString &serviceType );
83192

84-
QNetworkReply *reply() const { return mGeoNodeReply; }
193+
/**
194+
* Returns the most recent error string for any encountered errors, or an empty string if
195+
* no errors have been encountered.
196+
*/
197+
QString lastError() const { return mError; }
85198

86-
//! Abort network request immediately
87-
void abort();
199+
/**
200+
* Returns the most recent response obtained from the server.
201+
*/
202+
QByteArray lastResponse() const { return mHttpGeoNodeResponse; }
88203

89-
QString getProtocol() const;
204+
/**
205+
* Returns the network protocol (e.g. 'http') used for connecting with the server.
206+
* \see setProtocol()
207+
*/
208+
QString protocol() const;
209+
210+
/**
211+
* Sets the network \a protocol (e.g. 'http') used for connecting with the server.
212+
* \see protocol()
213+
*/
90214
void setProtocol( const QString &protocol );
91215

92-
private:
93-
QList<QgsGeoNodeRequest::ServiceLayerDetail> parseLayers( const QByteArray &layerResponse );
94-
QgsGeoNodeStyle retrieveStyle( const QString &styleUrl );
216+
public slots:
217+
218+
/**
219+
* Aborts any active network request immediately.
220+
*/
221+
void abort();
95222

96223
signals:
97-
//! \brief emit a signal to be caught by qgisapp and display a statusQString on status bar
224+
225+
/**
226+
* Emitted when the status of an ongoing request is changed.
227+
*/
98228
void statusChanged( const QString &statusQString );
99229

100-
//! \brief emit a signal once the request is finished
230+
/**
231+
* Emitted when the existing request has been completed.
232+
*/
101233
void requestFinished();
102234

103-
protected slots:
235+
/**
236+
* Emitted when the result of a fetchLayers call has been received and processed.
237+
*/
238+
void layersFetched( const QList<QgsGeoNodeRequest::ServiceLayerDetail> &layers );
239+
240+
private slots:
104241
void replyFinished();
105242
void replyProgress( qint64, qint64 );
106243

107-
protected:
244+
private:
108245

109246
//! URL part of URI (httpuri)
110247
QString mProtocol;
111248

112249
//! URL part of URI (httpuri)
113250
QString mBaseUrl;
114251

115-
// QgsWmsAuthorization mAuth;
116-
117252
//! The reply to the geonode request
118253
QNetworkReply *mGeoNodeReply = nullptr;
119254

@@ -129,6 +264,11 @@ class CORE_EXPORT QgsGeoNodeRequest : public QObject
129264
bool mIsAborted = false;
130265
bool mForceRefresh = false;
131266

267+
QList<QgsGeoNodeRequest::ServiceLayerDetail> parseLayers( const QByteArray &layerResponse );
268+
QgsGeoNodeStyle retrieveStyle( const QString &styleUrl );
269+
270+
QNetworkReply *requestUrl( const QString &url );
271+
132272
};
133273

134274
#endif // QGSGEONODEREQUEST_H

‎src/providers/wfs/qgswfsdataitems.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ QgsDataItem *QgsWfsDataItemProvider::createDataItem( const QString &path, QgsDat
227227
QString url = connection.uri().param( "url" );
228228
QgsGeoNodeRequest geonodeRequest( url, true );
229229

230-
QgsWFSDataSourceURI sourceUri( geonodeRequest.serviceUrls( QStringLiteral( "WFS" ) )[0] );
230+
QgsWFSDataSourceURI sourceUri( geonodeRequest.fetchServiceUrlsBlocking( QStringLiteral( "WFS" ) )[0] );
231231

232232
QgsDebugMsg( QString( "WFS full uri: '%1'." ).arg( QString( sourceUri.uri() ) ) );
233233

@@ -251,7 +251,7 @@ QVector<QgsDataItem *> QgsWfsDataItemProvider::createDataItems( const QString &p
251251
QString url = connection.uri().param( "url" );
252252
QgsGeoNodeRequest geonodeRequest( url, true );
253253

254-
QStringList encodedUris( geonodeRequest.serviceUrls( QStringLiteral( "WFS" ) ) );
254+
QStringList encodedUris( geonodeRequest.fetchServiceUrlsBlocking( QStringLiteral( "WFS" ) ) );
255255

256256
if ( !encodedUris.isEmpty() )
257257
{

‎src/providers/wms/qgswmsdataitems.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ QVector<QgsDataItem *> QgsWmsDataItemProvider::createDataItems( const QString &p
566566
QString url = connection.uri().param( "url" );
567567
QgsGeoNodeRequest geonodeRequest( url, true );
568568

569-
QStringList encodedUris( geonodeRequest.serviceUrls( QStringLiteral( "WMS" ) ) );
569+
QStringList encodedUris( geonodeRequest.fetchServiceUrlsBlocking( QStringLiteral( "WMS" ) ) );
570570

571571
if ( !encodedUris.isEmpty() )
572572
{
@@ -612,7 +612,7 @@ QVector<QgsDataItem *> QgsXyzTileDataItemProvider::createDataItems( const QStrin
612612
QString url = connection.uri().param( "url" );
613613
QgsGeoNodeRequest geonodeRequest( url, true );
614614

615-
QgsStringMap urlData( geonodeRequest.serviceUrlData( QStringLiteral( "XYZ" ) ) );
615+
QgsStringMap urlData( geonodeRequest.fetchServiceUrlDataBlocking( QStringLiteral( "XYZ" ) ) );
616616

617617
if ( !urlData.isEmpty() )
618618
{

‎tests/src/core/testqgsgeonodeconnection.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void TestQgsGeoNodeConnection::testLayerAPI()
129129
}
130130

131131
QgsGeoNodeRequest geonodeRequest( mKartozaGeoNodeQGISServerURL, true );
132-
QList<QgsGeoNodeRequest::ServiceLayerDetail> layers = geonodeRequest.getLayers();
132+
QList<QgsGeoNodeRequest::ServiceLayerDetail> layers = geonodeRequest.fetchLayersBlocking();
133133
QString msg = QStringLiteral( "Number of layers: %1" ).arg( layers.count() );
134134
QgsDebugMsg( msg );
135135
QVERIFY( layers.count() > 0 );
@@ -144,17 +144,17 @@ void TestQgsGeoNodeConnection::testStyleAPI()
144144
}
145145

146146
QgsGeoNodeRequest geonodeRequest( mKartozaGeoNodeQGISServerURL, true );
147-
QgsGeoNodeStyle defaultStyle = geonodeRequest.getDefaultStyle( QStringLiteral( "airports" ) );
147+
QgsGeoNodeStyle defaultStyle = geonodeRequest.fetchDefaultStyleBlocking( QStringLiteral( "airports" ) );
148148
QVERIFY( !defaultStyle.name.isEmpty() );
149149
QVERIFY( defaultStyle.body.toString().startsWith( QStringLiteral( "<qgis" ) ) );
150150
QVERIFY( defaultStyle.body.toString().contains( QStringLiteral( "</qgis>" ) ) );
151151

152-
QgsGeoNodeStyle geoNodeStyle = geonodeRequest.getStyle( "76" );
152+
QgsGeoNodeStyle geoNodeStyle = geonodeRequest.fetchStyleBlocking( "76" );
153153
QVERIFY( !geoNodeStyle.name.isEmpty() );
154154
QVERIFY( geoNodeStyle.body.toString().startsWith( QStringLiteral( "<qgis" ) ) );
155155
QVERIFY( geoNodeStyle.body.toString().contains( QStringLiteral( "</qgis>" ) ) );
156156

157-
QList<QgsGeoNodeStyle> geoNodeStyles = geonodeRequest.getStyles( QStringLiteral( "airports" ) );
157+
QList<QgsGeoNodeStyle> geoNodeStyles = geonodeRequest.fetchStylesBlocking( QStringLiteral( "airports" ) );
158158
QgsDebugMsg( geoNodeStyles.count() );
159159
QVERIFY( geoNodeStyles.count() == 2 );
160160

0 commit comments

Comments
 (0)
Please sign in to comment.