@@ -758,6 +758,15 @@ void QgsWMSServer::legendParameters( double mmToPixelFactor, double fontOversamp
758
758
{
759
759
layerFontColor = QColor ( 0 , 0 , 0 );
760
760
}
761
+ QMap<QString, QString>::const_iterator layerTitleIt = mParameters .find ( " LAYERTITLE" );
762
+ if ( layerTitleIt != mParameters .constEnd () )
763
+ {
764
+ mDrawLegendLayerLabel = layerTitleIt.value ().compare ( " TRUE" , Qt::CaseInsensitive );
765
+ }
766
+ else
767
+ {
768
+ mDrawLegendLayerLabel = true ;
769
+ }
761
770
762
771
763
772
itemFont = mConfigParser ->legendItemFont ();
@@ -794,6 +803,15 @@ void QgsWMSServer::legendParameters( double mmToPixelFactor, double fontOversamp
794
803
{
795
804
itemFontColor = QColor ( 0 , 0 , 0 );
796
805
}
806
+ QMap<QString, QString>::const_iterator itemLabelIt = mParameters .find ( " RULELABEL" );
807
+ if ( itemLabelIt != mParameters .constEnd () )
808
+ {
809
+ mDrawLegendItemLabel = itemLabelIt.value ().compare ( " TRUE" , Qt::CaseInsensitive );
810
+ }
811
+ else
812
+ {
813
+ mDrawLegendItemLabel = true ;
814
+ }
797
815
}
798
816
799
817
QDomDocument QgsWMSServer::getStyle ()
@@ -1955,28 +1973,36 @@ void QgsWMSServer::drawLegendLayerItem( QgsComposerLayerItem* item, QPainter* p,
1955
1973
}
1956
1974
1957
1975
QFontMetricsF layerFontMetrics ( layerFont );
1958
- currentY += layerFontMetrics.ascent () / fontOversamplingFactor;
1976
+ if (mDrawLegendLayerLabel == true ) {
1977
+ currentY += layerFontMetrics.ascent () / fontOversamplingFactor;
1978
+ }
1959
1979
1960
1980
// draw layer title first
1961
1981
if ( p )
1962
1982
{
1963
- p->save ();
1964
- p->scale ( 1.0 / fontOversamplingFactor, 1.0 / fontOversamplingFactor );
1965
- p->setPen ( layerFontColor );
1966
- p->setFont ( layerFont );
1967
- p->drawText ( boxSpace * fontOversamplingFactor, currentY * fontOversamplingFactor, item->text () );
1968
- p->restore ();
1983
+ if (mDrawLegendLayerLabel == true ) {
1984
+ p->save ();
1985
+ p->scale ( 1.0 / fontOversamplingFactor, 1.0 / fontOversamplingFactor );
1986
+ p->setPen ( layerFontColor );
1987
+ p->setFont ( layerFont );
1988
+ p->drawText ( boxSpace * fontOversamplingFactor, currentY * fontOversamplingFactor, item->text () );
1989
+ p->restore ();
1990
+ }
1969
1991
}
1970
1992
else
1971
1993
{
1972
1994
double layerItemWidth = layerFontMetrics.width ( item->text () ) / fontOversamplingFactor + boxSpace;
1973
1995
if ( layerItemWidth > maxTextWidth )
1974
1996
{
1975
- maxTextWidth = layerItemWidth;
1997
+ if ( mDrawLegendLayerLabel == true ) {
1998
+ maxTextWidth = layerItemWidth;
1999
+ }
1976
2000
}
1977
2001
}
1978
2002
1979
- currentY += layerTitleSpace;
2003
+ if (mDrawLegendLayerLabel == true ) {
2004
+ currentY += layerTitleSpace;
2005
+ }
1980
2006
1981
2007
// then draw all the children
1982
2008
QFontMetricsF itemFontMetrics ( itemFont );
@@ -2023,25 +2049,33 @@ void QgsWMSServer::drawLegendLayerItem( QgsComposerLayerItem* item, QPainter* p,
2023
2049
break ;
2024
2050
}
2025
2051
2026
- // finally draw text
2027
- currentTextWidth = itemFontMetrics.width ( currentComposerItem->text () ) / fontOversamplingFactor;
2052
+ if ( mDrawLegendItemLabel == true ) {
2053
+ // finally draw text
2054
+ currentTextWidth = itemFontMetrics.width ( currentComposerItem->text () ) / fontOversamplingFactor;
2055
+ } else {
2056
+ currentTextWidth = 0 ;
2057
+ }
2028
2058
double symbolItemHeight = qMax ( itemFontMetrics.ascent () / fontOversamplingFactor, currentSymbolHeight );
2029
2059
2030
2060
if ( p )
2031
2061
{
2032
- p->save ();
2033
- p->scale ( 1.0 / fontOversamplingFactor, 1.0 / fontOversamplingFactor );
2034
- p->setPen ( itemFontColor );
2035
- p->setFont ( itemFont );
2036
- p->drawText ( maxSymbolWidth * fontOversamplingFactor,
2037
- ( currentY + symbolItemHeight / 2.0 ) * fontOversamplingFactor + itemFontMetrics.ascent () / 2.0 , currentComposerItem->text () );
2038
- p->restore ();
2062
+ if ( mDrawLegendItemLabel == true ) {
2063
+ p->save ();
2064
+ p->scale ( 1.0 / fontOversamplingFactor, 1.0 / fontOversamplingFactor );
2065
+ p->setPen ( itemFontColor );
2066
+ p->setFont ( itemFont );
2067
+ p->drawText ( maxSymbolWidth * fontOversamplingFactor,
2068
+ ( currentY + symbolItemHeight / 2.0 ) * fontOversamplingFactor + itemFontMetrics.ascent () / 2.0 , currentComposerItem->text () );
2069
+ p->restore ();
2070
+ }
2039
2071
}
2040
2072
else
2041
2073
{
2042
2074
if ( currentTextWidth > maxTextWidth )
2043
2075
{
2044
- maxTextWidth = currentTextWidth;
2076
+ if ( mDrawLegendItemLabel == true ) {
2077
+ maxTextWidth = currentTextWidth;
2078
+ }
2045
2079
}
2046
2080
double symbolWidth = boxSpace + currentSymbolWidth + iconLabelSpace;
2047
2081
if ( symbolWidth > maxSymbolWidth )
0 commit comments