summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTitta Heikkala <titta.heikkala@digia.com>2013-10-31 12:31:13 +0200
committerTitta Heikkala <titta.heikkala@digia.com>2013-10-31 13:28:32 +0200
commita54f42bb13ad653a275ce7a75ba78411a9ca9fcf (patch)
treef6cbb6e64eeb64ac8770db9bd9851ab1a4361599
parentf49860f63006b719f48071eaeaae3538ee8120c1 (diff)
Fix pie chart label truncation
Adjust the pie label truncation so that the label is not divided into several rows, instead it's truncated correctly. Task-number: QTRD-2522 Change-Id: I6c0de83b5d7eef8af3a7caaee62bb2f4b674def6 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
-rw-r--r--src/piechart/piesliceitem.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/piechart/piesliceitem.cpp b/src/piechart/piesliceitem.cpp
index 79999daf..3b5bed70 100644
--- a/src/piechart/piesliceitem.cpp
+++ b/src/piechart/piesliceitem.cpp
@@ -135,7 +135,6 @@ void PieSliceItem::updateGeometry()
if (m_data.m_isLabelVisible) {
// text rect
- QFontMetricsF fm(m_data.m_labelFont);
m_labelTextRect = ChartPresenter::textBoundingRect(m_data.m_labelFont,
m_data.m_labelText,
0);
@@ -162,16 +161,14 @@ void PieSliceItem::updateGeometry()
if (m_labelTextRect.right() > parentItem()->boundingRect().right())
m_labelTextRect.setRight(parentItem()->boundingRect().right());
- if (fm.width(m_data.m_labelText) > m_labelTextRect.width()) {
- label = ChartPresenter::truncatedText(m_data.m_labelFont, m_data.m_labelText,
- qreal(0.0), m_labelTextRect.width(),
- m_labelTextRect.height(), m_labelTextRect);
- m_labelArmPath = labelArmPath(armStart, centerAngle,
- m_data.m_radius * m_data.m_labelArmLengthFactor,
- m_labelTextRect.width(), &labelTextStart);
+ label = ChartPresenter::truncatedText(m_data.m_labelFont, m_data.m_labelText,
+ qreal(0.0), m_labelTextRect.width(),
+ m_labelTextRect.height(), m_labelTextRect);
+ m_labelArmPath = labelArmPath(armStart, centerAngle,
+ m_data.m_radius * m_data.m_labelArmLengthFactor,
+ m_labelTextRect.width(), &labelTextStart);
+ m_labelTextRect.moveBottomLeft(labelTextStart);
- m_labelTextRect.moveBottomLeft(labelTextStart);
- }
m_labelItem->setTextWidth(m_labelTextRect.width()
+ m_labelItem->document()->documentMargin());
m_labelItem->setHtml(label);
@@ -193,7 +190,7 @@ void PieSliceItem::updateGeometry()
textCenter = m_data.m_center + offset(centerAngle, m_data.m_radius / 2);
}
m_labelItem->setPos(textCenter.x() - m_labelItem->boundingRect().width() / 2,
- textCenter.y() - fm.height() / 2);
+ textCenter.y() - m_labelTextRect.height() / 2);
QPointF labelCenter = m_labelItem->boundingRect().center();
m_labelItem->setTransformOriginPoint(labelCenter);