@@ -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 | if (m_text.isEmpty()) { | |||
|
56 | QGraphicsTextItem::setHtml(m_text); | |||
|
57 | QGraphicsTextItem::setTextWidth(0.0); | |||
|
58 | } else { | |||
55 | QGraphicsTextItem::setHtml(ChartPresenter::truncatedText(font(), m_text, qreal(0.0), |
|
59 | QGraphicsTextItem::setHtml(ChartPresenter::truncatedText(font(), m_text, qreal(0.0), | |
56 | rect.width(), rect.height(), |
|
60 | rect.width(), rect.height(), | |
57 | truncatedRect)); |
|
61 | truncatedRect)); | |
58 | QGraphicsTextItem::setTextWidth(truncatedRect.width()); |
|
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,12 +159,16 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 | if (title->text().isEmpty()) { | |||
|
163 | return geometry; | |||
|
164 | } else { | |||
162 | // Round to full pixel via QPoint to avoid one pixel clipping on the edge in some cases |
|
165 | // Round to full pixel via QPoint to avoid one pixel clipping on the edge in some cases | |
163 | QPointF center((geometry.center() - title->boundingRect().center()).toPoint()); |
|
166 | QPointF center((geometry.center() - title->boundingRect().center()).toPoint()); | |
164 |
|
167 | |||
165 | title->setPos(center.x(), title->pos().y()); |
|
168 | title->setPos(center.x(), title->pos().y()); | |
166 | return geometry.adjusted(0, title->boundingRect().height()+1, 0, 0); |
|
169 | return geometry.adjusted(0, title->boundingRect().height() + 1, 0, 0); | |
167 | } |
|
170 | } | |
|
171 | } | |||
168 |
|
172 | |||
169 | QRectF AbstractChartLayout::calculateTitleMinimum(const QRectF &minimum, ChartTitle *title) const |
|
173 | QRectF AbstractChartLayout::calculateTitleMinimum(const QRectF &minimum, ChartTitle *title) const | |
170 | { |
|
174 | { |
General Comments 0
You need to be logged in to leave comments.
Login now