Skip to content
Permalink
Browse files
Truncate very long filter strings in tooltip
Fixes #44217
  • Loading branch information
nyalldawson committed Jul 19, 2021
1 parent 8cd8bec commit 73f9020399952eaec2b841c3a7b3a78462067798
Showing with 12 additions and 3 deletions.
  1. +12 −3 src/app/qgslayertreeviewfilterindicator.cpp
@@ -49,15 +49,24 @@ QString QgsLayerTreeViewFilterIndicatorProvider::iconName( QgsMapLayer *layer )
QString QgsLayerTreeViewFilterIndicatorProvider::tooltipText( QgsMapLayer *layer )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
QString filter;
if ( vlayer )
return QStringLiteral( "<b>%1:</b><br>%2" ).arg( tr( "Filter" ), vlayer->subsetString().toHtmlEscaped() );
filter = vlayer->subsetString();

// PG raster
QgsRasterLayer *rlayer = qobject_cast<QgsRasterLayer *>( layer );
if ( rlayer && rlayer->dataProvider() && rlayer->dataProvider()->supportsSubsetString() )
return QStringLiteral( "<b>%1:</b><br>%2" ).arg( tr( "Filter" ), rlayer->subsetString().toHtmlEscaped() );
filter = rlayer->subsetString();

return QString();
if ( filter.isEmpty() )
return QString();

if ( filter.size() > 1024 )
{
filter = filter.left( 1023 ) + QString( QChar( 0x2026 ) );
}

return QStringLiteral( "<b>%1:</b><br>%2" ).arg( tr( "Filter" ), filter.toHtmlEscaped() );
}

void QgsLayerTreeViewFilterIndicatorProvider::connectSignals( QgsMapLayer *layer )

0 comments on commit 73f9020

Please sign in to comment.