##// END OF EJS Templates
Fix multiline alignment...
Titta Heikkala -
r2607:dfd05e587e31
parent child
Show More
@@ -77,6 +77,7 void HorizontalAxis::updateGeometry()
77 77 title->setHtml(ChartPresenter::truncatedText(axis()->titleFont(), titleText, qreal(0.0),
78 78 gridRect.width(), titleSpace,
79 79 titleBoundingRect));
80 title->setTextWidth(titleBoundingRect.width());
80 81
81 82 titleBoundingRect = title->boundingRect();
82 83
@@ -106,9 +107,13 void HorizontalAxis::updateGeometry()
106 107 labelItem->setHtml(text);
107 108 } else {
108 109 qreal labelWidth = axisRect.width() / layout.count() - (2 * labelPadding());
109 labelItem->setHtml(ChartPresenter::truncatedText(axis()->labelsFont(), text,
110 axis()->labelsAngle(), labelWidth,
111 availableSpace, boundingRect));
110 QString truncatedText = ChartPresenter::truncatedText(axis()->labelsFont(), text,
111 axis()->labelsAngle(),
112 labelWidth,
113 availableSpace, boundingRect);
114 labelItem->setTextWidth(ChartPresenter::textBoundingRect(axis()->labelsFont(),
115 truncatedText).width());
116 labelItem->setHtml(truncatedText);
112 117 }
113 118
114 119 //label transformation origin point
@@ -120,11 +120,14 void PolarChartAxisAngular::updateGeometry()
120 120
121 121 // Angular axis label
122 122 if (axis()->labelsVisible() && labelVisible) {
123 QRectF boundingRect = ChartPresenter::textBoundingRect(axis()->labelsFont(),
124 labelList.at(i),
125 axis()->labelsAngle());
126 labelItem->setTextWidth(boundingRect.width());
123 127 labelItem->setHtml(labelList.at(i));
124 128 const QRectF &rect = labelItem->boundingRect();
125 129 QPointF labelCenter = rect.center();
126 130 labelItem->setTransformOriginPoint(labelCenter.x(), labelCenter.y());
127 QRectF boundingRect = ChartPresenter::textBoundingRect(axis()->labelsFont(), labelList.at(i), axis()->labelsAngle());
128 131 boundingRect.moveCenter(labelCenter);
129 132 QPointF positionDiff(rect.topLeft() - boundingRect.topLeft());
130 133
@@ -221,13 +224,14 void PolarChartAxisAngular::updateGeometry()
221 224 // Title, centered above the chart
222 225 QString titleText = axis()->titleText();
223 226 if (!titleText.isEmpty() && axis()->isTitleVisible()) {
224 QRectF dummyRect;
227 QRectF truncatedRect;
225 228 qreal availableTitleHeight = axisGeometry().height() - labelPadding() - titlePadding() * 2.0;
226 229 qreal minimumLabelHeight = ChartPresenter::textBoundingRect(axis()->labelsFont(), "...").height();
227 230 availableTitleHeight -= minimumLabelHeight;
228 231 title->setHtml(ChartPresenter::truncatedText(axis()->titleFont(), titleText, qreal(0.0),
229 232 axisGeometry().width(), availableTitleHeight,
230 dummyRect));
233 truncatedRect));
234 title->setTextWidth(truncatedRect.width());
231 235
232 236 QRectF titleBoundingRect = title->boundingRect();
233 237 QPointF titleCenter = center - titleBoundingRect.center();
@@ -107,11 +107,14 void PolarChartAxisRadial::updateGeometry()
107 107
108 108 // Radial axis label
109 109 if (axis()->labelsVisible() && labelVisible) {
110 QRectF boundingRect = ChartPresenter::textBoundingRect(axis()->labelsFont(),
111 labelList.at(i),
112 axis()->labelsAngle());
113 labelItem->setTextWidth(boundingRect.width());
110 114 labelItem->setHtml(labelList.at(i));
111 115 QRectF labelRect = labelItem->boundingRect();
112 116 QPointF labelCenter = labelRect.center();
113 117 labelItem->setTransformOriginPoint(labelCenter.x(), labelCenter.y());
114 QRectF boundingRect = ChartPresenter::textBoundingRect(axis()->labelsFont(), labelList.at(i), axis()->labelsAngle());
115 118 boundingRect.moveCenter(labelCenter);
116 119 QPointF positionDiff(labelRect.topLeft() - boundingRect.topLeft());
117 120 QPointF labelPoint = center;
@@ -204,9 +207,10 void PolarChartAxisRadial::updateGeometry()
204 207 // Title, along the 0 axis
205 208 QString titleText = axis()->titleText();
206 209 if (!titleText.isEmpty() && axis()->isTitleVisible()) {
207 QRectF dummyRect;
210 QRectF truncatedRect;
208 211 title->setHtml(ChartPresenter::truncatedText(axis()->titleFont(), titleText, qreal(0.0),
209 radius, radius, dummyRect));
212 radius, radius, truncatedRect));
213 title->setTextWidth(truncatedRect.width());
210 214
211 215 QRectF titleBoundingRect = title->boundingRect();
212 216 QPointF titleCenter = titleBoundingRect.center();
@@ -78,6 +78,7 void VerticalAxis::updateGeometry()
78 78 title->setHtml(ChartPresenter::truncatedText(axis()->titleFont(), titleText, qreal(90.0),
79 79 titleSpace, gridRect.height(),
80 80 titleBoundingRect));
81 title->setTextWidth(titleBoundingRect.height());
81 82
82 83 titleBoundingRect = title->boundingRect();
83 84
@@ -110,9 +111,13 void VerticalAxis::updateGeometry()
110 111 labelItem->setHtml(text);
111 112 } else {
112 113 qreal labelHeight = (axisRect.height() / layout.count()) - (2 * labelPadding());
113 labelItem->setHtml(ChartPresenter::truncatedText(axis()->labelsFont(), text,
114 axis()->labelsAngle(), availableSpace,
115 labelHeight, boundingRect));
114 QString truncatedText = ChartPresenter::truncatedText(axis()->labelsFont(), text,
115 axis()->labelsAngle(),
116 availableSpace,
117 labelHeight, boundingRect);
118 labelItem->setTextWidth(ChartPresenter::textBoundingRect(axis()->labelsFont(),
119 truncatedText).width());
120 labelItem->setHtml(truncatedText);
116 121 }
117 122
118 123 //label transformation origin point
@@ -50,10 +50,11 QString ChartTitle::text() const
50 50
51 51 void ChartTitle::setGeometry(const QRectF &rect)
52 52 {
53 QRectF dummyRect;
53 QRectF truncatedRect;
54 54 QGraphicsTextItem::setHtml(ChartPresenter::truncatedText(font(), m_text, qreal(0.0),
55 55 rect.width(), rect.height(),
56 dummyRect));
56 truncatedRect));
57 QGraphicsTextItem::setTextWidth(truncatedRect.width());
57 58 setPos(rect.topLeft());
58 59 }
59 60
@@ -118,6 +118,7 void LegendMarkerItem::setGeometry(const QRectF &rect)
118 118
119 119 m_textItem->setHtml(ChartPresenter::truncatedText(m_textItem->font(), m_label, qreal(0.0),
120 120 width - x, rect.height(), truncatedRect));
121 m_textItem->setTextWidth(truncatedRect.width());
121 122
122 123 qreal y = qMax(m_markerRect.height() + 2 * m_margin, truncatedRect.height() + 2 * m_margin);
123 124
General Comments 0
You need to be logged in to leave comments. Login now