@@ -50,6 +50,10 public: | |||||
50 | chart->setTitleFont(font); |
|
50 | chart->setTitleFont(font); | |
51 | chart->axisX()->setLabelsFont(font); |
|
51 | chart->axisX()->setLabelsFont(font); | |
52 | chart->axisY()->setLabelsFont(font); |
|
52 | chart->axisY()->setLabelsFont(font); | |
|
53 | chart->axisX()->setTitle("Axis X"); | |||
|
54 | chart->axisY()->setTitle("Axis Y"); | |||
|
55 | chart->axisX()->setTitleFont(font); | |||
|
56 | chart->axisY()->setTitleFont(font); | |||
53 | return chart; |
|
57 | return chart; | |
54 | } |
|
58 | } | |
55 |
|
59 |
@@ -234,9 +234,6 void ChartAxis::setLabelsBrush(const QBrush &brush) | |||||
234 |
|
234 | |||
235 | void ChartAxis::setLabelsFont(const QFont &font) |
|
235 | void ChartAxis::setLabelsFont(const QFont &font) | |
236 | { |
|
236 | { | |
237 | foreach (QGraphicsItem *item , m_labels->childItems()) |
|
|||
238 | static_cast<QGraphicsSimpleTextItem *>(item)->setFont(font); |
|
|||
239 |
|
||||
240 | if (m_font != font) { |
|
237 | if (m_font != font) { | |
241 | m_font = font; |
|
238 | m_font = font; | |
242 | foreach (QGraphicsItem *item , m_labels->childItems()) |
|
239 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
@@ -323,6 +320,7 void ChartAxis::handleAxisUpdated() | |||||
323 |
|
320 | |||
324 | bool visible = m_chartAxis->isVisible(); |
|
321 | bool visible = m_chartAxis->isVisible(); | |
325 |
|
322 | |||
|
323 | //TODO: split this into separate signal/slots ? | |||
326 | setArrowVisibility(visible && m_chartAxis->isLineVisible()); |
|
324 | setArrowVisibility(visible && m_chartAxis->isLineVisible()); | |
327 | setGridVisibility(visible && m_chartAxis->isGridLineVisible()); |
|
325 | setGridVisibility(visible && m_chartAxis->isGridLineVisible()); | |
328 | setLabelsVisibility(visible && m_chartAxis->labelsVisible()); |
|
326 | setLabelsVisibility(visible && m_chartAxis->labelsVisible()); | |
@@ -336,6 +334,9 void ChartAxis::handleAxisUpdated() | |||||
336 | setShadesPen(m_chartAxis->shadesPen()); |
|
334 | setShadesPen(m_chartAxis->shadesPen()); | |
337 | setShadesBrush(m_chartAxis->shadesBrush()); |
|
335 | setShadesBrush(m_chartAxis->shadesBrush()); | |
338 | setTitleText(m_chartAxis->title()); |
|
336 | setTitleText(m_chartAxis->title()); | |
|
337 | setTitleFont(m_chartAxis->titleFont()); | |||
|
338 | setTitlePen(m_chartAxis->titlePen()); | |||
|
339 | setTitleBrush(m_chartAxis->titleBrush()); | |||
339 | } |
|
340 | } | |
340 |
|
341 | |||
341 | void ChartAxis::setTitleText(const QString &title) |
|
342 | void ChartAxis::setTitleText(const QString &title) | |
@@ -347,6 +348,30 void ChartAxis::setTitleText(const QString &title) | |||||
347 | } |
|
348 | } | |
348 | } |
|
349 | } | |
349 |
|
350 | |||
|
351 | void ChartAxis::setTitlePen(const QPen &pen) | |||
|
352 | { | |||
|
353 | m_title->setPen(pen); | |||
|
354 | } | |||
|
355 | ||||
|
356 | void ChartAxis::setTitleBrush(const QBrush &brush) | |||
|
357 | { | |||
|
358 | m_title->setBrush(brush); | |||
|
359 | } | |||
|
360 | ||||
|
361 | void ChartAxis::setTitleFont(const QFont &font) | |||
|
362 | { | |||
|
363 | if(m_title->font() != font){ | |||
|
364 | m_title->setFont(font); | |||
|
365 | QGraphicsLayoutItem::updateGeometry(); | |||
|
366 | presenter()->layout()->invalidate(); | |||
|
367 | } | |||
|
368 | } | |||
|
369 | ||||
|
370 | QFont ChartAxis::titleFont() const | |||
|
371 | { | |||
|
372 | return m_title->font(); | |||
|
373 | } | |||
|
374 | ||||
350 | void ChartAxis::hide() |
|
375 | void ChartAxis::hide() | |
351 | { |
|
376 | { | |
352 | setArrowVisibility(false); |
|
377 | setArrowVisibility(false); |
@@ -87,7 +87,7 public: | |||||
87 | void setTitlePen(const QPen &pen); |
|
87 | void setTitlePen(const QPen &pen); | |
88 | void setTitleBrush(const QBrush &brush); |
|
88 | void setTitleBrush(const QBrush &brush); | |
89 | void setTitleFont(const QFont &font); |
|
89 | void setTitleFont(const QFont &font); | |
90 |
QFont titleFont() const |
|
90 | QFont titleFont() const; | |
91 | void setTitleText(const QString &title); |
|
91 | void setTitleText(const QString &title); | |
92 | QString titleText() const {return m_titleText; }; |
|
92 | QString titleText() const {return m_titleText; }; | |
93 |
|
93 | |||
@@ -158,7 +158,6 private: | |||||
158 | qreal m_max; |
|
158 | qreal m_max; | |
159 | AxisAnimation *m_animation; |
|
159 | AxisAnimation *m_animation; | |
160 | QFont m_font; |
|
160 | QFont m_font; | |
161 | QFont m_titleFont; |
|
|||
162 | QString m_titleText; |
|
161 | QString m_titleText; | |
163 | int m_labelPadding; |
|
162 | int m_labelPadding; | |
164 | QStringList m_labelsList; |
|
163 | QStringList m_labelsList; |
@@ -271,9 +271,16 void ChartTheme::decorate(QAbstractAxis *axis) | |||||
271 | if (m_force || brush == axis->labelsBrush()) |
|
271 | if (m_force || brush == axis->labelsBrush()) | |
272 | axis->setLabelsBrush(m_labelBrush); |
|
272 | axis->setLabelsBrush(m_labelBrush); | |
273 |
|
273 | |||
|
274 | //TODO: introduce axis brush | |||
|
275 | if (m_force || brush == axis->titleBrush()) | |||
|
276 | axis->setTitleBrush(m_labelBrush); | |||
|
277 | ||||
274 | if (m_force || pen == axis->labelsPen()) |
|
278 | if (m_force || pen == axis->labelsPen()) | |
275 | axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons |
|
279 | axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons | |
276 |
|
280 | |||
|
281 | if (m_force || pen == axis->titlePen()) | |||
|
282 | axis->setTitlePen(Qt::NoPen); // Noen for performance reasons | |||
|
283 | ||||
277 | if (m_force || axis->shadesVisible()) { |
|
284 | if (m_force || axis->shadesVisible()) { | |
278 |
|
285 | |||
279 | if (m_force || brush == axis->shadesBrush()) |
|
286 | if (m_force || brush == axis->shadesBrush()) | |
@@ -297,6 +304,13 void ChartTheme::decorate(QAbstractAxis *axis) | |||||
297 |
|
304 | |||
298 | if (m_force || font == axis->labelsFont()) |
|
305 | if (m_force || font == axis->labelsFont()) | |
299 | axis->setLabelsFont(m_labelFont); |
|
306 | axis->setLabelsFont(m_labelFont); | |
|
307 | ||||
|
308 | //TODO: discuss with Tero | |||
|
309 | if (m_force || font == axis->titleFont()){ | |||
|
310 | QFont font(m_labelFont); | |||
|
311 | font.setBold(true); | |||
|
312 | axis->setTitleFont(font); | |||
|
313 | } | |||
300 | } |
|
314 | } | |
301 | } |
|
315 | } | |
302 |
|
316 |
General Comments 0
You need to be logged in to leave comments.
Login now