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