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