Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make layer tooltips more user friendly
Now the layer tooltips (in the layer tree) contains:
* title (or the short name, if title empty)
* abstract (if not empty)
* URL
  • Loading branch information
Patrick Valsecchi committed Feb 26, 2016
1 parent 493d13d commit 0389a36
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/core/layertree/qgslayertreemodel.cpp
Expand Up @@ -276,7 +276,14 @@ QVariant QgsLayerTreeModel::data( const QModelIndex &index, int role ) const
if ( QgsLayerTree::isLayer( node ) )
{
if ( QgsMapLayer* layer = QgsLayerTree::toLayer( node )->layer() )
return layer->publicSource();
{
QString tooltip = "<b>" +
( layer->title().isEmpty() ? layer->shortName() : layer->title() ) + "</b>";
if ( !layer->abstract().isEmpty() )
tooltip += "<br/>" + layer->abstract().replace( "\n", "<br/>" );
tooltip += "<br/><i>" + layer->publicSource() + "</i>";
return tooltip;
}
}
}

Expand Down

0 comments on commit 0389a36

Please sign in to comment.