@@ -52,10 +52,15 QString ChartTitle::text() const | |||||
52 | void ChartTitle::setGeometry(const QRectF &rect) |
|
52 | void ChartTitle::setGeometry(const QRectF &rect) | |
53 | { |
|
53 | { | |
54 | QRectF truncatedRect; |
|
54 | QRectF truncatedRect; | |
55 | QGraphicsTextItem::setHtml(ChartPresenter::truncatedText(font(), m_text, qreal(0.0), |
|
55 | if (m_text.isEmpty()) { | |
56 | rect.width(), rect.height(), |
|
56 | QGraphicsTextItem::setHtml(m_text); | |
57 | truncatedRect)); |
|
57 | QGraphicsTextItem::setTextWidth(0.0); | |
58 | QGraphicsTextItem::setTextWidth(truncatedRect.width()); |
|
58 | } else { | |
|
59 | QGraphicsTextItem::setHtml(ChartPresenter::truncatedText(font(), m_text, qreal(0.0), | |||
|
60 | rect.width(), rect.height(), | |||
|
61 | truncatedRect)); | |||
|
62 | QGraphicsTextItem::setTextWidth(truncatedRect.width()); | |||
|
63 | } | |||
59 | setPos(rect.topLeft()); |
|
64 | setPos(rect.topLeft()); | |
60 | } |
|
65 | } | |
61 |
|
66 |
@@ -57,7 +57,7 void AbstractChartLayout::setGeometry(const QRectF &rect) | |||||
57 |
|
57 | |||
58 | contentGeometry = calculateContentGeometry(contentGeometry); |
|
58 | contentGeometry = calculateContentGeometry(contentGeometry); | |
59 |
|
59 | |||
60 |
if (title && title->isVisible() |
|
60 | if (title && title->isVisible()) | |
61 | contentGeometry = calculateTitleGeometry(contentGeometry, title); |
|
61 | contentGeometry = calculateTitleGeometry(contentGeometry, title); | |
62 |
|
62 | |||
63 | if (legend->isAttachedToChart() && legend->isVisible()) |
|
63 | if (legend->isAttachedToChart() && legend->isVisible()) | |
@@ -159,11 +159,15 QRectF AbstractChartLayout::calculateLegendMinimum(const QRectF &geometry, QLege | |||||
159 | QRectF AbstractChartLayout::calculateTitleGeometry(const QRectF &geometry, ChartTitle *title) const |
|
159 | QRectF AbstractChartLayout::calculateTitleGeometry(const QRectF &geometry, ChartTitle *title) const | |
160 | { |
|
160 | { | |
161 | title->setGeometry(geometry); |
|
161 | title->setGeometry(geometry); | |
162 | // Round to full pixel via QPoint to avoid one pixel clipping on the edge in some cases |
|
162 | if (title->text().isEmpty()) { | |
163 | QPointF center((geometry.center() - title->boundingRect().center()).toPoint()); |
|
163 | return geometry; | |
164 |
|
164 | } else { | ||
165 | title->setPos(center.x(), title->pos().y()); |
|
165 | // Round to full pixel via QPoint to avoid one pixel clipping on the edge in some cases | |
166 | return geometry.adjusted(0, title->boundingRect().height()+1, 0, 0); |
|
166 | QPointF center((geometry.center() - title->boundingRect().center()).toPoint()); | |
|
167 | ||||
|
168 | title->setPos(center.x(), title->pos().y()); | |||
|
169 | return geometry.adjusted(0, title->boundingRect().height() + 1, 0, 0); | |||
|
170 | } | |||
167 | } |
|
171 | } | |
168 |
|
172 | |||
169 | QRectF AbstractChartLayout::calculateTitleMinimum(const QRectF &minimum, ChartTitle *title) const |
|
173 | QRectF AbstractChartLayout::calculateTitleMinimum(const QRectF &minimum, ChartTitle *title) const |
General Comments 0
You need to be logged in to leave comments.
Login now