From e045f46957d963e2e6d637dd3d0ed1a5222bc293 2013-12-30 07:56:19 From: Titta Heikkala Date: 2013-12-30 07:56:19 Subject: [PATCH] Fix signle legend truncation When there's just one legend item visible on a chart it needs to be truncated also. Task-number: QTRD-2747 Change-Id: Iae8d9c38ad3a0591c6dc224d743bdb581926420b Reviewed-by: Mika Salmela --- diff --git a/src/legend/legendlayout.cpp b/src/legend/legendlayout.cpp index c76cda5..eec41bf 100644 --- a/src/legend/legendlayout.cpp +++ b/src/legend/legendlayout.cpp @@ -158,7 +158,7 @@ void LegendLayout::setAttachedGeometry(const QRectF &rect) // If the items would occupy more space than is available, start truncating them // from the longest one. qreal availableGeometry = geometry.width() - right - left * 2 - itemMargins; - if (markerItemsWidth >= availableGeometry && legendWidthList.count() > 1) { + if (markerItemsWidth >= availableGeometry) { bool truncated(false); int count = legendWidthList.count(); for (int i = 1; i < count; i++) { @@ -193,7 +193,8 @@ void LegendLayout::setAttachedGeometry(const QRectF &rect) if (truncated) break; } - // Items are of same width and all of them need to be truncated. + // Items are of same width and all of them need to be truncated + // or there is just one item that is truncated. while (markerItemsWidth >= availableGeometry) { for (int i = 0; i < count; i++) { legendWidthList.at(i)->width--;