Skip to content
Permalink
Browse files

fix layer tooltip display

  • Loading branch information
jef-n committed Jan 24, 2018
1 parent 8c96eec commit 717a0f541f17322f86d1e79f02652a08d4127351
Showing with 23 additions and 11 deletions.
  1. +21 −9 src/core/layertree/qgslayertreemodel.cpp
  2. +2 −2 src/ui/qgsvectorlayerpropertiesbase.ui
@@ -283,24 +283,36 @@ QVariant QgsLayerTreeModel::data( const QModelIndex &index, int role ) const
{
if ( QgsMapLayer *layer = QgsLayerTree::toLayer( node )->layer() )
{
QStringList parts;
QString title = layer->title().isEmpty() ? layer->shortName() : layer->title();
if ( title.isEmpty() )
title = layer->name();
title = "<b>" + title + "</b>";
QString title =
!layer->title().isEmpty() ? layer->title() :
!layer->shortName().isEmpty() ? layer->shortName() :
layer->name();

title = "<b>" + title.toHtmlEscaped() + "</b>";

if ( layer->crs().isValid() )
{
if ( QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer ) )
title = tr( "%1 (%2 - %3)" ).arg( title, QgsWkbTypes::displayString( vl->wkbType() ), layer->crs().authid() );
title += tr( " (%1 - %2)" ).arg( QgsWkbTypes::displayString( vl->wkbType() ), layer->crs().authid() ).toHtmlEscaped();
else
title = tr( "%1 (%2) " ).arg( title, layer->crs().authid() );
title += tr( " (%1)" ).arg( layer->crs().authid() ).toHtmlEscaped();
}

QStringList parts;
parts << title;

if ( !layer->abstract().isEmpty() )
parts << "<br/>" + layer->abstract().replace( QLatin1String( "\n" ), QLatin1String( "<br/>" ) );
parts << "<i>" + layer->publicSource() + "</i>";
{
parts << QStringLiteral();
for ( const auto &l : layer->abstract().split( "\n" ) )
{
parts << l.toHtmlEscaped();
}
parts << QStringLiteral();
}

parts << "<i>" + layer->publicSource().toHtmlEscaped() + "</i>";

return parts.join( QStringLiteral( "<br/>" ) );
}
}
@@ -2036,7 +2036,7 @@ border-radius: 2px;</string>
</widget>
</item>
<item row="3" column="1">
<widget class="QTextEdit" name="mLayerAbstractTextEdit">
<widget class="QPlainTextEdit" name="mLayerAbstractTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
@@ -2046,7 +2046,7 @@ border-radius: 2px;</string>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
<height>150</height>
</size>
</property>
<property name="toolTip">

0 comments on commit 717a0f5

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