Skip to content
Permalink
Browse files

Merge pull request #4939 from mhugent/wms_toplevel_browser

Show toplevel wms group in browser
  • Loading branch information
mhugent committed Aug 17, 2017
2 parents 469eb0d + a0e453e commit 5fbd62885427043aa75baa732b5f3e4654a6976e
Showing with 6 additions and 28 deletions.
  1. +6 −28 src/providers/wms/qgswmsdataitems.cpp
@@ -94,37 +94,15 @@ QVector<QgsDataItem *> QgsWMSConnectionItem::createChildren()
QgsWmsCapabilitiesProperty capabilitiesProperty = caps.capabilitiesProperty();
const QgsWmsCapabilityProperty &capabilityProperty = capabilitiesProperty.capability;

// If we have several top-level layers, or if we just have one single top-level layer,
// then use those top-level layers directly
if ( capabilityProperty.layers.size() > 1 ||
( capabilityProperty.layers.size() == 1 && capabilityProperty.layers[0].layer.size() == 0 ) )
Q_FOREACH ( const QgsWmsLayerProperty &layerProperty, capabilityProperty.layers )
{
Q_FOREACH ( const QgsWmsLayerProperty &layerProperty, capabilityProperty.layers )
{
// Attention, the name may be empty
QgsDebugMsg( QString::number( layerProperty.orderId ) + ' ' + layerProperty.name + ' ' + layerProperty.title );
QString pathName = layerProperty.name.isEmpty() ? QString::number( layerProperty.orderId ) : layerProperty.name;

QgsWMSLayerItem *layer = new QgsWMSLayerItem( this, layerProperty.title, mPath + '/' + pathName, capabilitiesProperty, uri, layerProperty );

children << layer;
}
}
// Otherwise if we have just one single top-level layers with children, then
// skip this top-level layer and iterate directly on its children
// Note (E. Rouault): this was the historical behavior before fixing #13762
else if ( capabilityProperty.layers.size() == 1 )
{
Q_FOREACH ( const QgsWmsLayerProperty &layerProperty, capabilityProperty.layers[0].layer )
{
// Attention, the name may be empty
QgsDebugMsg( QString::number( layerProperty.orderId ) + ' ' + layerProperty.name + ' ' + layerProperty.title );
QString pathName = layerProperty.name.isEmpty() ? QString::number( layerProperty.orderId ) : layerProperty.name;
// Attention, the name may be empty
QgsDebugMsg( QString::number( layerProperty.orderId ) + ' ' + layerProperty.name + ' ' + layerProperty.title );
QString pathName = layerProperty.name.isEmpty() ? QString::number( layerProperty.orderId ) : layerProperty.name;

QgsWMSLayerItem *layer = new QgsWMSLayerItem( this, layerProperty.title, mPath + '/' + pathName, capabilitiesProperty, uri, layerProperty );
QgsWMSLayerItem *layer = new QgsWMSLayerItem( this, layerProperty.title, mPath + '/' + pathName, capabilitiesProperty, uri, layerProperty );

children << layer;
}
children << layer;
}
}

0 comments on commit 5fbd628

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