From 6d156d46703cde10834b41a907ffa5dd45fdb487 Mon Sep 17 00:00:00 2001 From: Samweli Date: Tue, 17 Dec 2019 17:38:21 +0300 Subject: [PATCH] removed if conditions in QgsWMTSRootItem assignments, now using explicit casts --- src/providers/wms/qgswmsdataitems.cpp | 36 +++------------------------ 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/src/providers/wms/qgswmsdataitems.cpp b/src/providers/wms/qgswmsdataitems.cpp index d4fc437c998..4dd0d560681 100644 --- a/src/providers/wms/qgswmsdataitems.cpp +++ b/src/providers/wms/qgswmsdataitems.cpp @@ -115,17 +115,8 @@ QVector QgsWMSConnectionItem::createChildren() for ( const QgsWmtsTileLayer &l : constTileLayers ) { QString title = l.title.isEmpty() ? l.identifier : l.title; - QgsDataItem *layerItem; - // Using if condition, ternary operator leads to type casting issue - if ( l.styles.size() == 1 ) - { - layerItem = this; - } - else - { - layerItem = new QgsWMTSRootItem( this, title, mPath + '/' + l.identifier ); - } + QgsDataItem *layerItem = l.styles.size() == 1 ? static_cast< QgsDataItem * >( this ) : static_cast< QgsDataItem * >( new QgsWMTSRootItem( this, title, mPath + '/' + l.identifier ) ); if ( layerItem != this ) { @@ -150,17 +141,7 @@ QVector QgsWMSConnectionItem::createChildren() } styleIdentifiers.push_back( stylePathIdentifier ); - QgsDataItem *styleItem; - - // Using if condition, ternary operator leads to type casting issue - if ( l.setLinks.size() == 1 ) - { - styleItem = layerItem; - } - else - { - styleItem = new QgsWMTSRootItem( layerItem, styleName, layerItem->path() + '/' + stylePathIdentifier ); - } + QgsDataItem *styleItem = l.setLinks.size() == 1 ? static_cast< QgsDataItem * >( layerItem ) : static_cast< QgsDataItem * >( new QgsWMTSRootItem( layerItem, styleName, layerItem->path() + '/' + stylePathIdentifier ) ); if ( styleItem != layerItem ) { @@ -192,18 +173,7 @@ QVector QgsWMSConnectionItem::createChildren() } linkIdentifiers.push_back( linkPathIdentifier ); - - QgsDataItem *linkItem; - - // Using if condition, ternary operator leads to type casting issue - if ( l.formats.size() == 1 ) - { - linkItem = styleItem; - } - else - { - linkItem = new QgsWMTSRootItem( styleItem, linkName, styleItem->path() + '/' + linkPathIdentifier ); - } + QgsDataItem *linkItem = l.formats.size() == 1 ? static_cast< QgsDataItem * >( styleItem ) : static_cast< QgsDataItem * >( new QgsWMTSRootItem( styleItem, linkName, styleItem->path() + '/' + linkPathIdentifier ) ); if ( linkItem != styleItem ) {