Skip to content

Commit a8ee064

Browse files
committedFeb 27, 2014
wmts: show common upper levels in item name (relates to #9492)
1 parent b6d943e commit a8ee064

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed
 

‎src/providers/wms/qgswmsdataitems.cpp

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,34 +138,46 @@ QVector<QgsDataItem*> QgsWMSConnectionItem::createChildren()
138138
QString title = l.title.isEmpty() ? l.identifier : l.title;
139139
QgsDataItem *layerItem = l.styles.size() == 1 ? this : new QgsDataCollectionItem( this, title, mPath + "/" + l.identifier );
140140
if ( layerItem != this )
141+
{
142+
layerItem->setToolTip( title );
141143
addChildItem( layerItem );
144+
}
142145

143146
foreach ( const QgsWmtsStyle &style, l.styles )
144147
{
145-
QgsDataItem *styleItem = l.setLinks.size() == 1 ? layerItem : new QgsDataCollectionItem( layerItem, style.title.isEmpty() ? style.identifier : style.title, layerItem->path() + "/" + style.identifier );
148+
QString styleName = style.title.isEmpty() ? style.identifier : style.title;
149+
if ( layerItem == this )
150+
styleName.prepend( title + " - " );
151+
152+
QgsDataItem *styleItem = l.setLinks.size() == 1 ? layerItem : new QgsDataCollectionItem( layerItem, styleName, layerItem->path() + "/" + style.identifier );
146153
if ( styleItem != layerItem )
154+
{
155+
styleItem->setToolTip( styleName );
147156
layerItem->addChildItem( styleItem );
157+
}
148158

149159
foreach ( const QgsWmtsTileMatrixSetLink &setLink, l.setLinks )
150160
{
151-
QgsDataItem *linkItem = l.formats.size() == 1 ? styleItem : new QgsDataCollectionItem( styleItem, setLink.tileMatrixSet, styleItem->path() + "/" + setLink.tileMatrixSet );
161+
QString linkName = setLink.tileMatrixSet;
162+
if ( styleItem == layerItem )
163+
linkName.prepend( styleName + " - " );
164+
165+
QgsDataItem *linkItem = l.formats.size() == 1 ? styleItem : new QgsDataCollectionItem( styleItem, linkName, styleItem->path() + "/" + setLink.tileMatrixSet );
152166
if ( linkItem != styleItem )
167+
{
168+
linkItem->setToolTip( linkName );
153169
styleItem->addChildItem( linkItem );
170+
}
154171

155172
foreach ( QString format, l.formats )
156173
{
157-
QString name;
158-
if ( layerItem == this )
159-
name += ( l.title.isEmpty() ? l.identifier : l.title ) + " - ";
160-
if ( styleItem == layerItem )
161-
name += ( style.title.isEmpty() ? style.identifier : style.title ) + " - ";
174+
QString name = format;
162175
if ( linkItem == styleItem )
163-
name += setLink.tileMatrixSet + " - ";
164-
name += format;
176+
name.prepend( linkName + " - " );
165177

166178
QgsDataItem *layerItem = new QgsWMTSLayerItem( linkItem, name, linkItem->path() + "/" + name, uri,
167179
l.identifier, format, style.identifier, setLink.tileMatrixSet, tileMatrixSets[ setLink.tileMatrixSet ].crs, title );
168-
180+
layerItem->setToolTip( name );
169181
linkItem->addChildItem( layerItem );
170182
}
171183
}

0 commit comments

Comments
 (0)
Please sign in to comment.