Skip to content

Commit

Permalink
removed if conditions in QgsWMTSRootItem assignments, now using expli…
Browse files Browse the repository at this point in the history
…cit casts
  • Loading branch information
Samweli authored and nyalldawson committed Dec 17, 2019
1 parent db4a8ce commit 6d156d4
Showing 1 changed file with 3 additions and 33 deletions.
36 changes: 3 additions & 33 deletions src/providers/wms/qgswmsdataitems.cpp
Expand Up @@ -115,17 +115,8 @@ QVector<QgsDataItem *> 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 )
{
Expand All @@ -150,17 +141,7 @@ QVector<QgsDataItem *> 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 )
{
Expand Down Expand Up @@ -192,18 +173,7 @@ QVector<QgsDataItem *> 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 )
{
Expand Down

0 comments on commit 6d156d4

Please sign in to comment.