@@ -150,11 +150,11 @@ void QgsGeoNodeSourceSelect::connectToGeonodeConnection()
150
150
QApplication::setOverrideCursor ( Qt::BusyCursor );
151
151
QgsGeoNodeConnection connection ( cmbConnections->currentText () );
152
152
153
- QString url = connection.uri ().param ( " url" );
153
+ QString url = connection.uri ().param ( QStringLiteral ( " url" ) );
154
154
QgsGeoNodeRequest geonodeRequest ( url, true );
155
155
156
156
QApplication::setOverrideCursor ( Qt::WaitCursor );
157
- QList<QgsServiceLayerDetail> layers = geonodeRequest.getLayers ();
157
+ const QList<QgsServiceLayerDetail> layers = geonodeRequest.getLayers ();
158
158
QApplication::restoreOverrideCursor ();
159
159
160
160
if ( !layers.empty () )
@@ -173,19 +173,19 @@ void QgsGeoNodeSourceSelect::connectToGeonodeConnection()
173
173
174
174
if ( !layers.isEmpty () )
175
175
{
176
- Q_FOREACH ( const QgsServiceLayerDetail &layer, layers )
176
+ for ( const QgsServiceLayerDetail &layer : layers )
177
177
{
178
178
QUuid uuid = layer.uuid ;
179
179
180
180
QString wmsURL = layer.wmsURL ;
181
181
QString wfsURL = layer.wfsURL ;
182
182
QString xyzURL = layer.xyzURL ;
183
183
184
- if ( wmsURL.length () > 0 )
184
+ if ( ! wmsURL.isEmpty () )
185
185
{
186
186
QStandardItem *titleItem = new QStandardItem ( layer.title );
187
187
QStandardItem *nameItem;
188
- if ( layer.name > 0 )
188
+ if ( ! layer.name . isEmpty () )
189
189
{
190
190
nameItem = new QStandardItem ( layer.name );
191
191
}
@@ -206,13 +206,13 @@ void QgsGeoNodeSourceSelect::connectToGeonodeConnection()
206
206
}
207
207
else
208
208
{
209
- qDebug () << " Layer " << layer. title << " does not have WMS url." ;
209
+ QgsDebugMsgLevel ( QStringLiteral ( " Layer %1 does not have WMS url." ). arg ( layer. title ), 3 ) ;
210
210
}
211
- if ( wfsURL.length () > 0 )
211
+ if ( ! wfsURL.isEmpty () )
212
212
{
213
213
QStandardItem *titleItem = new QStandardItem ( layer.title );
214
214
QStandardItem *nameItem;
215
- if ( layer.name .length () > 0 )
215
+ if ( ! layer.name .isEmpty () )
216
216
{
217
217
nameItem = new QStandardItem ( layer.name );
218
218
}
@@ -233,13 +233,13 @@ void QgsGeoNodeSourceSelect::connectToGeonodeConnection()
233
233
}
234
234
else
235
235
{
236
- qDebug () << " Layer " << layer. title << " does not have WFS url." ;
236
+ QgsDebugMsgLevel ( QStringLiteral ( " Layer %1 does not have WFS url." ). arg ( layer. title ), 3 ) ;
237
237
}
238
- if ( xyzURL.length () > 0 )
238
+ if ( ! xyzURL.isEmpty () )
239
239
{
240
240
QStandardItem *titleItem = new QStandardItem ( layer.title );
241
241
QStandardItem *nameItem;
242
- if ( layer.name .length () > 0 )
242
+ if ( ! layer.name .isEmpty () )
243
243
{
244
244
nameItem = new QStandardItem ( layer.name );
245
245
}
@@ -260,18 +260,14 @@ void QgsGeoNodeSourceSelect::connectToGeonodeConnection()
260
260
}
261
261
else
262
262
{
263
- qDebug () << " Layer " << layer. title << " does not have XYZ url." ;
263
+ QgsDebugMsgLevel ( QStringLiteral ( " Layer %1 does not have XYZ url." ). arg ( layer. title ), 3 ) ;
264
264
}
265
265
}
266
266
}
267
267
268
268
else
269
269
{
270
- QMessageBox *box = new QMessageBox ( QMessageBox::Critical, tr ( " Error" ), tr ( " Cannot get any feature services" ), QMessageBox::Ok, this );
271
- box->setAttribute ( Qt::WA_DeleteOnClose );
272
- box->setModal ( true );
273
- box->setObjectName ( QStringLiteral ( " GeonodeCapabilitiesErrorBox" ) );
274
- box->open ();
270
+ QMessageBox::critical ( this , tr ( " Connect to GeoNode" ), tr ( " Cannot get any feature services" ) );
275
271
}
276
272
277
273
treeView->resizeColumnToContents ( MODEL_IDX_TITLE );
@@ -297,7 +293,7 @@ void QgsGeoNodeSourceSelect::saveGeonodeConnection()
297
293
void QgsGeoNodeSourceSelect::loadGeonodeConnection ()
298
294
{
299
295
QString fileName = QFileDialog::getOpenFileName ( this , tr ( " Load connections" ), QDir::homePath (),
300
- tr ( " XML files (*.xml *XML)" ) );
296
+ tr ( " XML files (*.xml *. XML)" ) );
301
297
if ( fileName.isEmpty () )
302
298
{
303
299
return ;
@@ -323,7 +319,6 @@ void QgsGeoNodeSourceSelect::treeViewSelectionChanged()
323
319
QModelIndex currentIndex = treeView->selectionModel ()->currentIndex ();
324
320
if ( !currentIndex.isValid () )
325
321
{
326
- qDebug () << " Current index is invalid" ;
327
322
return ;
328
323
}
329
324
addButton ()->setEnabled ( false );
@@ -349,17 +344,14 @@ void QgsGeoNodeSourceSelect::treeViewSelectionChanged()
349
344
350
345
void QgsGeoNodeSourceSelect::addButtonClicked ()
351
346
{
352
- qDebug () << " Add button clicked" ;
353
347
QApplication::setOverrideCursor ( Qt::BusyCursor );
354
348
// Get selected entry in treeview
355
349
QModelIndex currentIndex = treeView->selectionModel ()->currentIndex ();
356
350
if ( !currentIndex.isValid () )
357
351
{
358
- qDebug () << " Current index is invalid" ;
359
352
return ;
360
353
}
361
354
362
- QgsGeoNodeConnection connection ( cmbConnections->currentText () );
363
355
QModelIndexList modelIndexList = treeView->selectionModel ()->selectedRows ();
364
356
for ( int i = 0 ; i < modelIndexList.size (); i++ )
365
357
{
@@ -370,12 +362,9 @@ void QgsGeoNodeSourceSelect::addButtonClicked()
370
362
}
371
363
int row = idx.row ();
372
364
373
- qDebug () << " Model index row " << row;
374
-
375
365
QString typeItem = mModel ->item ( row, MODEL_IDX_TYPE )->text ();
376
366
if ( typeItem == tr ( " Map" ) )
377
367
{
378
- qDebug () << " Skip adding map." ;
379
368
continue ;
380
369
}
381
370
QString serviceURL = mModel ->item ( row, MODEL_IDX_TITLE )->data ( Qt::UserRole + 2 ).toString ();
@@ -388,19 +377,16 @@ void QgsGeoNodeSourceSelect::addButtonClicked()
388
377
QString layerName = titleName;
389
378
}
390
379
391
- qDebug () << " Layer name: " << layerName << " Type: " << webServiceType;
392
-
393
- if ( webServiceType == " WMS" )
380
+ if ( webServiceType == QStringLiteral ( " WMS" ) )
394
381
{
395
- qDebug () << " Adding WMS layer of " << layerName;
396
382
QgsDataSourceUri uri;
397
383
uri.setParam ( QStringLiteral ( " url" ), serviceURL );
398
384
399
385
// Set static first, to see that it works. Need to think about the UI also.
400
- QString format ( " image/png" );
401
- QString crs ( " EPSG:4326" );
402
- QString styles ( " " ) ;
403
- QString contextualWMSLegend ( " 0" );
386
+ QString format ( QStringLiteral ( " image/png" ) );
387
+ QString crs ( QStringLiteral ( " EPSG:4326" ) );
388
+ QString styles;
389
+ QString contextualWMSLegend ( QStringLiteral ( " 0" ) );
404
390
405
391
uri.setParam ( QStringLiteral ( " contextualWMSLegend" ), contextualWMSLegend );
406
392
uri.setParam ( QStringLiteral ( " layers" ), layerName );
@@ -411,24 +397,22 @@ void QgsGeoNodeSourceSelect::addButtonClicked()
411
397
QgsDebugMsg ( " Add WMS from GeoNode : " + uri.encodedUri () );
412
398
emit addRasterLayer ( uri.encodedUri (), layerName, QStringLiteral ( " wms" ) );
413
399
}
414
- else if ( webServiceType == " WFS" )
400
+ else if ( webServiceType == QStringLiteral ( " WFS" ) )
415
401
{
416
- qDebug () << " Adding WFS layer of " << layerName;
417
-
418
402
// Set static first, to see that it works. Need to think about the UI also.
419
403
QString typeName = mModel ->item ( row, 0 )->data ( Qt::UserRole + 3 ).toString ();
420
- QString crs ( " EPSG:4326" );
404
+ QString crs ( QStringLiteral ( " EPSG:4326" ) );
421
405
422
406
// typeName, titleName, sql,
423
407
// Build url for WFS
424
408
// restrictToRequestBBOX='1' srsname='EPSG:26719' typename='geonode:cab_mun' url='http://demo.geonode.org/geoserver/geonode/wms' table=\"\" sql="
425
409
QString uri;
426
410
uri += QStringLiteral ( " restrictToRequestBBOX='1'" );
427
411
uri += QStringLiteral ( " srsname='%1'" ).arg ( crs );
428
- if ( serviceURL.contains ( " qgis-server" ) )
412
+ if ( serviceURL.contains ( QStringLiteral ( " qgis-server" ) ) )
429
413
{
430
414
// I need to do this since the typename used in qgis-server is without the workspace.
431
- QString qgisServerTypeName = QString ( typeName ).split ( " : " ).last ();
415
+ QString qgisServerTypeName = QString ( typeName ).split ( ' : ' ).last ();
432
416
uri += QStringLiteral ( " typename='%1'" ).arg ( qgisServerTypeName );
433
417
}
434
418
else
@@ -442,7 +426,7 @@ void QgsGeoNodeSourceSelect::addButtonClicked()
442
426
QgsDebugMsg ( " Add WFS from GeoNode : " + uri + " and typename: " + typeName );
443
427
emit addVectorLayer ( uri, typeName, QStringLiteral ( " WFS" ) );
444
428
}
445
- else if ( webServiceType == " XYZ" )
429
+ else if ( webServiceType == QStringLiteral ( " XYZ" ) )
446
430
{
447
431
QgsDebugMsg ( " XYZ Url: " + serviceURL );
448
432
QgsDebugMsg ( " Add XYZ from GeoNode : " + serviceURL );
0 commit comments