@@ -296,8 +296,9 void ChartAxis::handleShadesVisibleChanged(bool visible) | |||||
296 |
|
296 | |||
297 | void ChartAxis::handleTitleVisibleChanged(bool visible) |
|
297 | void ChartAxis::handleTitleVisibleChanged(bool visible) | |
298 | { |
|
298 | { | |
299 | m_title->setVisible(visible); |
|
299 | QGraphicsLayoutItem::updateGeometry(); | |
300 | presenter()->layout()->invalidate(); |
|
300 | presenter()->layout()->invalidate(); | |
|
301 | m_title->setVisible(visible); | |||
301 | } |
|
302 | } | |
302 |
|
303 | |||
303 | void ChartAxis::handleLabelsAngleChanged(int angle) |
|
304 | void ChartAxis::handleLabelsAngleChanged(int angle) | |
@@ -354,9 +355,9 void ChartAxis::handleGridPenChanged(const QPen &pen) | |||||
354 |
|
355 | |||
355 | void ChartAxis::handleTitleTextChanged(const QString &title) |
|
356 | void ChartAxis::handleTitleTextChanged(const QString &title) | |
356 | { |
|
357 | { | |
357 | Q_UNUSED(title) |
|
|||
358 | QGraphicsLayoutItem::updateGeometry(); |
|
358 | QGraphicsLayoutItem::updateGeometry(); | |
359 | presenter()->layout()->invalidate(); |
|
359 | presenter()->layout()->invalidate(); | |
|
360 | m_title->setText(title); | |||
360 | } |
|
361 | } | |
361 |
|
362 | |||
362 |
|
363 |
@@ -68,12 +68,11 void HorizontalAxis::updateGeometry() | |||||
68 | QFontMetrics fn(font()); |
|
68 | QFontMetrics fn(font()); | |
69 |
|
69 | |||
70 | //title |
|
70 | //title | |
71 |
|
71 | int titlePad = 0; | ||
72 | if (!titleText().isNull()) { |
|
72 | QRectF titleBoundingRect; | |
|
73 | if (!titleText().isEmpty() && titleItem()->isVisible()) { | |||
73 | QFontMetrics fn(title->font()); |
|
74 | QFontMetrics fn(title->font()); | |
74 |
|
||||
75 | int size(0); |
|
75 | int size(0); | |
76 |
|
||||
77 | size = gridRect.width(); |
|
76 | size = gridRect.width(); | |
78 | QString titleText = this->titleText(); |
|
77 | QString titleText = this->titleText(); | |
79 |
|
78 | |||
@@ -86,11 +85,14 void HorizontalAxis::updateGeometry() | |||||
86 | title->setText(titleText); |
|
85 | title->setText(titleText); | |
87 | } |
|
86 | } | |
88 |
|
87 | |||
89 | QPointF center = gridRect.center() - title->boundingRect().center(); |
|
88 | titlePad = titlePadding(); | |
|
89 | titleBoundingRect = title->boundingRect(); | |||
|
90 | ||||
|
91 | QPointF center = gridRect.center() - titleBoundingRect.center(); | |||
90 | if (alignment() == Qt::AlignTop) { |
|
92 | if (alignment() == Qt::AlignTop) { | |
91 |
title->setPos(center.x(), axisRect.top() + titlePad |
|
93 | title->setPos(center.x(), axisRect.top() + titlePad); | |
92 | } else if (alignment() == Qt::AlignBottom) { |
|
94 | } else if (alignment() == Qt::AlignBottom) { | |
93 |
title->setPos(center.x(), axisRect.bottom() - title |
|
95 | title->setPos(center.x(), axisRect.bottom() - titleBoundingRect.height() - titlePad); | |
94 | } |
|
96 | } | |
95 | } |
|
97 | } | |
96 |
|
98 | |||
@@ -107,7 +109,7 void HorizontalAxis::updateGeometry() | |||||
107 | //label text wrapping |
|
109 | //label text wrapping | |
108 | QString text = labelList.at(i); |
|
110 | QString text = labelList.at(i); | |
109 | QRectF boundingRect = labelBoundingRect(fn, text); |
|
111 | QRectF boundingRect = labelBoundingRect(fn, text); | |
110 |
qreal size = axisRect.bottom() - axisRect.top() - labelPadding() - title |
|
112 | qreal size = axisRect.bottom() - axisRect.top() - labelPadding() - titleBoundingRect.height() - (titlePad * 2); | |
111 | if (boundingRect.height() > size) { |
|
113 | if (boundingRect.height() > size) { | |
112 | QString label = text + "..."; |
|
114 | QString label = text + "..."; | |
113 | while (boundingRect.height() >= size && label.length() > 3) { |
|
115 | while (boundingRect.height() >= size && label.length() > 3) { | |
@@ -186,7 +188,7 QSizeF HorizontalAxis::sizeHint(Qt::SizeHint which, const QSizeF &constraint) co | |||||
186 | QFontMetrics fn(titleFont()); |
|
188 | QFontMetrics fn(titleFont()); | |
187 | QSizeF sh(0,0); |
|
189 | QSizeF sh(0,0); | |
188 |
|
190 | |||
189 |
if (titleText().is |
|
191 | if (titleText().isEmpty() || !titleItem()->isVisible()) | |
190 | return sh; |
|
192 | return sh; | |
191 |
|
193 | |||
192 | switch (which) { |
|
194 | switch (which) { |
@@ -72,10 +72,10 void VerticalAxis::updateGeometry() | |||||
72 | QFontMetrics fn(font()); |
|
72 | QFontMetrics fn(font()); | |
73 |
|
73 | |||
74 | //title |
|
74 | //title | |
75 |
|
75 | int titlePad = 0; | ||
76 | if (!titleText().isNull()) { |
|
76 | QRectF titleBoundingRect; | |
|
77 | if (!titleText().isEmpty() && titleItem()->isVisible()) { | |||
77 | QFontMetrics fn(title->font()); |
|
78 | QFontMetrics fn(title->font()); | |
78 |
|
||||
79 | int size(0); |
|
79 | int size(0); | |
80 | size = gridRect.height(); |
|
80 | size = gridRect.height(); | |
81 | QString titleText = this->titleText(); |
|
81 | QString titleText = this->titleText(); | |
@@ -90,14 +90,17 void VerticalAxis::updateGeometry() | |||||
90 | title->setText(titleText); |
|
90 | title->setText(titleText); | |
91 | } |
|
91 | } | |
92 |
|
92 | |||
93 | QPointF center = gridRect.center() - title->boundingRect().center(); |
|
93 | titlePad = titlePadding(); | |
|
94 | titleBoundingRect = title->boundingRect(); | |||
|
95 | ||||
|
96 | QPointF center = gridRect.center() - titleBoundingRect.center(); | |||
94 | if (alignment() == Qt::AlignLeft) { |
|
97 | if (alignment() == Qt::AlignLeft) { | |
95 |
title->setPos(axisRect.left() - title |
|
98 | title->setPos(axisRect.left() - titleBoundingRect.width() / 2 + titleBoundingRect.height() / 2 + titlePad, center.y()); | |
96 | } |
|
99 | } | |
97 | else if (alignment() == Qt::AlignRight) { |
|
100 | else if (alignment() == Qt::AlignRight) { | |
98 |
title->setPos(axisRect.right() - title |
|
101 | title->setPos(axisRect.right() - titleBoundingRect.width() / 2 - titleBoundingRect.height() / 2 - titlePad, center.y()); | |
99 | } |
|
102 | } | |
100 |
title->setTransformOriginPoint(title |
|
103 | title->setTransformOriginPoint(titleBoundingRect.center()); | |
101 | title->setRotation(270); |
|
104 | title->setRotation(270); | |
102 | } |
|
105 | } | |
103 |
|
106 | |||
@@ -115,7 +118,7 void VerticalAxis::updateGeometry() | |||||
115 | QString text = labelList.at(i); |
|
118 | QString text = labelList.at(i); | |
116 | QRectF boundingRect = labelBoundingRect(fn, text); |
|
119 | QRectF boundingRect = labelBoundingRect(fn, text); | |
117 |
|
120 | |||
118 |
qreal size = axisRect.right() - axisRect.left() - labelPadding() - title |
|
121 | qreal size = axisRect.right() - axisRect.left() - labelPadding() - titleBoundingRect.height() - (titlePad * 2); | |
119 | if (boundingRect.width() > size) { |
|
122 | if (boundingRect.width() > size) { | |
120 | QString label = text + "..."; |
|
123 | QString label = text + "..."; | |
121 | while (boundingRect.width() > size && label.length() > 3) { |
|
124 | while (boundingRect.width() > size && label.length() > 3) { | |
@@ -197,7 +200,7 QSizeF VerticalAxis::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons | |||||
197 | QFontMetrics fn(titleFont()); |
|
200 | QFontMetrics fn(titleFont()); | |
198 | QSizeF sh(0,0); |
|
201 | QSizeF sh(0,0); | |
199 |
|
202 | |||
200 |
if (titleText().is |
|
203 | if (titleText().isEmpty() || !titleItem()->isVisible()) | |
201 | return sh; |
|
204 | return sh; | |
202 |
|
205 | |||
203 | switch (which) { |
|
206 | switch (which) { |
General Comments 0
You need to be logged in to leave comments.
Login now