@@ -1,120 +1,127 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "chartdatetimeaxisx_p.h" |
|
21 | #include "chartdatetimeaxisx_p.h" | |
22 | #include "chartpresenter_p.h" |
|
22 | #include "chartpresenter_p.h" | |
23 | #include "qdatetimeaxis.h" |
|
23 | #include "qdatetimeaxis.h" | |
24 | #include "chartlayout_p.h" |
|
24 | #include "chartlayout_p.h" | |
25 | #include <QGraphicsLayout> |
|
25 | #include <QGraphicsLayout> | |
26 | #include <QDateTime> |
|
26 | #include <QDateTime> | |
27 | #include <QFontMetrics> |
|
27 | #include <QFontMetrics> | |
28 | #include <qmath.h> |
|
28 | #include <qmath.h> | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | ChartDateTimeAxisX::ChartDateTimeAxisX(QDateTimeAxis *axis, QGraphicsItem* item) |
|
32 | ChartDateTimeAxisX::ChartDateTimeAxisX(QDateTimeAxis *axis, QGraphicsItem* item) | |
33 | : HorizontalAxis(axis, item), |
|
33 | : HorizontalAxis(axis, item), | |
34 | m_axis(axis) |
|
34 | m_axis(axis) | |
35 | { |
|
35 | { | |
36 | QObject::connect(m_axis,SIGNAL(tickCountChanged(int)),this, SLOT(handleTickCountChanged(int))); |
|
36 | QObject::connect(m_axis,SIGNAL(tickCountChanged(int)),this, SLOT(handleTickCountChanged(int))); | |
|
37 | QObject::connect(m_axis,SIGNAL(formatChanged(QString)),this, SLOT(handleFormatChanged(QString))); | |||
37 | } |
|
38 | } | |
38 |
|
39 | |||
39 | ChartDateTimeAxisX::~ChartDateTimeAxisX() |
|
40 | ChartDateTimeAxisX::~ChartDateTimeAxisX() | |
40 | { |
|
41 | { | |
41 | } |
|
42 | } | |
42 |
|
43 | |||
43 | QVector<qreal> ChartDateTimeAxisX::calculateLayout() const |
|
44 | QVector<qreal> ChartDateTimeAxisX::calculateLayout() const | |
44 | { |
|
45 | { | |
45 | int tickCount = m_axis->tickCount(); |
|
46 | int tickCount = m_axis->tickCount(); | |
46 |
|
47 | |||
47 | Q_ASSERT(tickCount >= 2); |
|
48 | Q_ASSERT(tickCount >= 2); | |
48 |
|
49 | |||
49 | QVector<qreal> points; |
|
50 | QVector<qreal> points; | |
50 | points.resize(tickCount); |
|
51 | points.resize(tickCount); | |
51 | const QRectF &gridRect = gridGeometry(); |
|
52 | const QRectF &gridRect = gridGeometry(); | |
52 | const qreal deltaX = gridRect.width() / (tickCount - 1); |
|
53 | const qreal deltaX = gridRect.width() / (tickCount - 1); | |
53 | for (int i = 0; i < tickCount; ++i) { |
|
54 | for (int i = 0; i < tickCount; ++i) { | |
54 | int x = i * deltaX + gridRect.left(); |
|
55 | int x = i * deltaX + gridRect.left(); | |
55 | points[i] = x; |
|
56 | points[i] = x; | |
56 | } |
|
57 | } | |
57 | return points; |
|
58 | return points; | |
58 | } |
|
59 | } | |
59 |
|
60 | |||
60 | void ChartDateTimeAxisX::updateGeometry() |
|
61 | void ChartDateTimeAxisX::updateGeometry() | |
61 | { |
|
62 | { | |
62 | const QVector<qreal>& layout = ChartAxis::layout(); |
|
63 | const QVector<qreal>& layout = ChartAxis::layout(); | |
63 | if (layout.isEmpty()) |
|
64 | if (layout.isEmpty()) | |
64 | return; |
|
65 | return; | |
65 | setLabels(createDateTimeLabels(min(),max(), layout.size(),m_axis->format())); |
|
66 | setLabels(createDateTimeLabels(min(),max(), layout.size(),m_axis->format())); | |
66 | HorizontalAxis::updateGeometry(); |
|
67 | HorizontalAxis::updateGeometry(); | |
67 | } |
|
68 | } | |
68 |
|
69 | |||
69 | void ChartDateTimeAxisX::handleTickCountChanged(int tick) |
|
70 | void ChartDateTimeAxisX::handleTickCountChanged(int tick) | |
70 | { |
|
71 | { | |
71 | Q_UNUSED(tick) |
|
72 | Q_UNUSED(tick) | |
72 | if(presenter()) presenter()->layout()->invalidate(); |
|
73 | if(presenter()) presenter()->layout()->invalidate(); | |
73 | } |
|
74 | } | |
74 |
|
75 | |||
|
76 | void ChartDateTimeAxisX::handleFormatChanged(const QString &format) | |||
|
77 | { | |||
|
78 | Q_UNUSED(format); | |||
|
79 | if(presenter()) presenter()->layout()->invalidate(); | |||
|
80 | } | |||
|
81 | ||||
75 | QSizeF ChartDateTimeAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
|
82 | QSizeF ChartDateTimeAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const | |
76 | { |
|
83 | { | |
77 | Q_UNUSED(constraint) |
|
84 | Q_UNUSED(constraint) | |
78 |
|
85 | |||
79 | QFontMetrics fn(font()); |
|
86 | QFontMetrics fn(font()); | |
80 | QSizeF sh; |
|
87 | QSizeF sh; | |
81 |
|
88 | |||
82 | QSizeF base = HorizontalAxis::sizeHint(which, constraint); |
|
89 | QSizeF base = HorizontalAxis::sizeHint(which, constraint); | |
83 | QStringList ticksList = createDateTimeLabels(min(),max(),m_axis->tickCount(),m_axis->format()); |
|
90 | QStringList ticksList = createDateTimeLabels(min(),max(),m_axis->tickCount(),m_axis->format()); | |
84 | qreal width = 0; |
|
91 | qreal width = 0; | |
85 | qreal height = 0; |
|
92 | qreal height = 0; | |
86 |
|
93 | |||
87 | if(ticksList.empty()){ |
|
94 | if(ticksList.empty()){ | |
88 | return sh; |
|
95 | return sh; | |
89 | } |
|
96 | } | |
90 |
|
97 | |||
91 |
|
98 | |||
92 | switch (which) { |
|
99 | switch (which) { | |
93 | case Qt::MinimumSize:{ |
|
100 | case Qt::MinimumSize:{ | |
94 | int count = qMax(ticksList.last().count(),ticksList.first().count()); |
|
101 | int count = qMax(ticksList.last().count(),ticksList.first().count()); | |
95 | width = fn.averageCharWidth() * count; |
|
102 | width = fn.averageCharWidth() * count; | |
96 | height = fn.height() + labelPadding(); |
|
103 | height = fn.height() + labelPadding(); | |
97 | width = qMax(width,base.width()); |
|
104 | width = qMax(width,base.width()); | |
98 | height += base.height(); |
|
105 | height += base.height(); | |
99 | sh = QSizeF(width,height); |
|
106 | sh = QSizeF(width,height); | |
100 | break; |
|
107 | break; | |
101 | } |
|
108 | } | |
102 | case Qt::PreferredSize: { |
|
109 | case Qt::PreferredSize: { | |
103 | int count = qMax(ticksList.last().count(),ticksList.first().count()); |
|
110 | int count = qMax(ticksList.last().count(),ticksList.first().count()); | |
104 | width=fn.averageCharWidth() * count; |
|
111 | width=fn.averageCharWidth() * count; | |
105 | height=fn.height()+labelPadding(); |
|
112 | height=fn.height()+labelPadding(); | |
106 | width=qMax(width,base.width()); |
|
113 | width=qMax(width,base.width()); | |
107 | height+=base.height(); |
|
114 | height+=base.height(); | |
108 | sh = QSizeF(width,height); |
|
115 | sh = QSizeF(width,height); | |
109 | break; |
|
116 | break; | |
110 | } |
|
117 | } | |
111 | default: |
|
118 | default: | |
112 | break; |
|
119 | break; | |
113 | } |
|
120 | } | |
114 |
|
121 | |||
115 | return sh; |
|
122 | return sh; | |
116 | } |
|
123 | } | |
117 |
|
124 | |||
118 | #include "moc_chartdatetimeaxisx_p.cpp" |
|
125 | #include "moc_chartdatetimeaxisx_p.cpp" | |
119 |
|
126 | |||
120 | QTCOMMERCIALCHART_END_NAMESPACE |
|
127 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,60 +1,61 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef CHARTDATETIMEAXISX_H |
|
30 | #ifndef CHARTDATETIMEAXISX_H | |
31 | #define CHARTDATETIMEAXISX_H |
|
31 | #define CHARTDATETIMEAXISX_H | |
32 |
|
32 | |||
33 | #include "horizontalaxis_p.h" |
|
33 | #include "horizontalaxis_p.h" | |
34 |
|
34 | |||
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QDateTimeAxis; |
|
37 | class QDateTimeAxis; | |
38 | class ChartPresenter; |
|
38 | class ChartPresenter; | |
39 |
|
39 | |||
40 | class ChartDateTimeAxisX : public HorizontalAxis |
|
40 | class ChartDateTimeAxisX : public HorizontalAxis | |
41 | { |
|
41 | { | |
42 | Q_OBJECT |
|
42 | Q_OBJECT | |
43 | public: |
|
43 | public: | |
44 | ChartDateTimeAxisX(QDateTimeAxis *axis, QGraphicsItem* item = 0); |
|
44 | ChartDateTimeAxisX(QDateTimeAxis *axis, QGraphicsItem* item = 0); | |
45 | ~ChartDateTimeAxisX(); |
|
45 | ~ChartDateTimeAxisX(); | |
46 |
|
46 | |||
47 | QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; |
|
47 | QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; | |
48 | protected: |
|
48 | protected: | |
49 | QVector<qreal> calculateLayout() const; |
|
49 | QVector<qreal> calculateLayout() const; | |
50 | void updateGeometry(); |
|
50 | void updateGeometry(); | |
51 | private Q_SLOTS: |
|
51 | private Q_SLOTS: | |
52 | void handleTickCountChanged(int tick); |
|
52 | void handleTickCountChanged(int tick); | |
|
53 | void handleFormatChanged(const QString &format); | |||
53 |
|
54 | |||
54 | private: |
|
55 | private: | |
55 | QDateTimeAxis *m_axis; |
|
56 | QDateTimeAxis *m_axis; | |
56 | }; |
|
57 | }; | |
57 |
|
58 | |||
58 | QTCOMMERCIALCHART_END_NAMESPACE |
|
59 | QTCOMMERCIALCHART_END_NAMESPACE | |
59 |
|
60 | |||
60 | #endif /* CHARTDATETIMEAXISX_H */ |
|
61 | #endif /* CHARTDATETIMEAXISX_H */ |
@@ -1,119 +1,126 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "chartdatetimeaxisy_p.h" |
|
21 | #include "chartdatetimeaxisy_p.h" | |
22 | #include "chartpresenter_p.h" |
|
22 | #include "chartpresenter_p.h" | |
23 | #include "qdatetimeaxis.h" |
|
23 | #include "qdatetimeaxis.h" | |
24 | #include "chartlayout_p.h" |
|
24 | #include "chartlayout_p.h" | |
25 | #include <QGraphicsLayout> |
|
25 | #include <QGraphicsLayout> | |
26 | #include <QFontMetrics> |
|
26 | #include <QFontMetrics> | |
27 | #include <QDateTime> |
|
27 | #include <QDateTime> | |
28 | #include <qmath.h> |
|
28 | #include <qmath.h> | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | ChartDateTimeAxisY::ChartDateTimeAxisY(QDateTimeAxis *axis, QGraphicsItem* item) |
|
32 | ChartDateTimeAxisY::ChartDateTimeAxisY(QDateTimeAxis *axis, QGraphicsItem* item) | |
33 | : VerticalAxis(axis, item), |
|
33 | : VerticalAxis(axis, item), | |
34 | m_axis(axis) |
|
34 | m_axis(axis) | |
35 | { |
|
35 | { | |
36 | QObject::connect(m_axis,SIGNAL(tickCountChanged(int)),this, SLOT(handleTickCountChanged(int))); |
|
36 | QObject::connect(m_axis,SIGNAL(tickCountChanged(int)),this, SLOT(handleTickCountChanged(int))); | |
|
37 | QObject::connect(m_axis,SIGNAL(formatChanged(QString)),this, SLOT(handleFormatChanged(QString))); | |||
37 | } |
|
38 | } | |
38 |
|
39 | |||
39 | ChartDateTimeAxisY::~ChartDateTimeAxisY() |
|
40 | ChartDateTimeAxisY::~ChartDateTimeAxisY() | |
40 | { |
|
41 | { | |
41 | } |
|
42 | } | |
42 |
|
43 | |||
43 | QVector<qreal> ChartDateTimeAxisY::calculateLayout() const |
|
44 | QVector<qreal> ChartDateTimeAxisY::calculateLayout() const | |
44 | { |
|
45 | { | |
45 | int tickCount = m_axis->tickCount(); |
|
46 | int tickCount = m_axis->tickCount(); | |
46 |
|
47 | |||
47 | Q_ASSERT(tickCount >= 2); |
|
48 | Q_ASSERT(tickCount >= 2); | |
48 |
|
49 | |||
49 | QVector<qreal> points; |
|
50 | QVector<qreal> points; | |
50 | points.resize(tickCount); |
|
51 | points.resize(tickCount); | |
51 | const QRectF &gridRect = gridGeometry(); |
|
52 | const QRectF &gridRect = gridGeometry(); | |
52 | const qreal deltaY = gridRect.height() / (tickCount - 1); |
|
53 | const qreal deltaY = gridRect.height() / (tickCount - 1); | |
53 | for (int i = 0; i < tickCount; ++i) { |
|
54 | for (int i = 0; i < tickCount; ++i) { | |
54 | int y = i * -deltaY + gridRect.bottom(); |
|
55 | int y = i * -deltaY + gridRect.bottom(); | |
55 | points[i] = y; |
|
56 | points[i] = y; | |
56 | } |
|
57 | } | |
57 |
|
58 | |||
58 | return points; |
|
59 | return points; | |
59 | } |
|
60 | } | |
60 |
|
61 | |||
61 | void ChartDateTimeAxisY::updateGeometry() |
|
62 | void ChartDateTimeAxisY::updateGeometry() | |
62 | { |
|
63 | { | |
63 | const QVector<qreal> &layout = ChartAxis::layout(); |
|
64 | const QVector<qreal> &layout = ChartAxis::layout(); | |
64 | if (layout.isEmpty()) |
|
65 | if (layout.isEmpty()) | |
65 | return; |
|
66 | return; | |
66 | setLabels(createDateTimeLabels(min(),max(), layout.size(),m_axis->format())); |
|
67 | setLabels(createDateTimeLabels(min(),max(), layout.size(),m_axis->format())); | |
67 | VerticalAxis::updateGeometry(); |
|
68 | VerticalAxis::updateGeometry(); | |
68 | } |
|
69 | } | |
69 |
|
70 | |||
70 | void ChartDateTimeAxisY::handleTickCountChanged(int tick) |
|
71 | void ChartDateTimeAxisY::handleTickCountChanged(int tick) | |
71 | { |
|
72 | { | |
72 | Q_UNUSED(tick) |
|
73 | Q_UNUSED(tick) | |
73 | if(presenter()) presenter()->layout()->invalidate(); |
|
74 | if(presenter()) presenter()->layout()->invalidate(); | |
74 | } |
|
75 | } | |
75 |
|
76 | |||
|
77 | void ChartDateTimeAxisY::handleFormatChanged(const QString &format) | |||
|
78 | { | |||
|
79 | Q_UNUSED(format); | |||
|
80 | if(presenter()) presenter()->layout()->invalidate(); | |||
|
81 | } | |||
|
82 | ||||
76 | QSizeF ChartDateTimeAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
|
83 | QSizeF ChartDateTimeAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const | |
77 | { |
|
84 | { | |
78 | Q_UNUSED(constraint) |
|
85 | Q_UNUSED(constraint) | |
79 |
|
86 | |||
80 | QFontMetrics fn(font()); |
|
87 | QFontMetrics fn(font()); | |
81 | QSizeF sh; |
|
88 | QSizeF sh; | |
82 |
|
89 | |||
83 | QSizeF base = VerticalAxis::sizeHint(which, constraint); |
|
90 | QSizeF base = VerticalAxis::sizeHint(which, constraint); | |
84 | QStringList ticksList = createDateTimeLabels(min(),max(),m_axis->tickCount(),m_axis->format()); |
|
91 | QStringList ticksList = createDateTimeLabels(min(),max(),m_axis->tickCount(),m_axis->format()); | |
85 | qreal width = 0; |
|
92 | qreal width = 0; | |
86 | qreal height = 0; |
|
93 | qreal height = 0; | |
87 |
|
94 | |||
88 | if(ticksList.empty()){ |
|
95 | if(ticksList.empty()){ | |
89 | return sh; |
|
96 | return sh; | |
90 | } |
|
97 | } | |
91 |
|
98 | |||
92 | switch (which) { |
|
99 | switch (which) { | |
93 | case Qt::MinimumSize: { |
|
100 | case Qt::MinimumSize: { | |
94 | width = fn.boundingRect("...").width() + labelPadding(); |
|
101 | width = fn.boundingRect("...").width() + labelPadding(); | |
95 | width += base.width(); |
|
102 | width += base.width(); | |
96 | height = fn.height(); |
|
103 | height = fn.height(); | |
97 | height = qMax(height,base.height()); |
|
104 | height = qMax(height,base.height()); | |
98 | sh = QSizeF(width,height); |
|
105 | sh = QSizeF(width,height); | |
99 | break; |
|
106 | break; | |
100 | } |
|
107 | } | |
101 | case Qt::PreferredSize: { |
|
108 | case Qt::PreferredSize: { | |
102 | int count = qMax(ticksList.first().count() , ticksList.last().count()); |
|
109 | int count = qMax(ticksList.first().count() , ticksList.last().count()); | |
103 | width = count*fn.averageCharWidth() + labelPadding() + 2; //two pixels of tolerance |
|
110 | width = count*fn.averageCharWidth() + labelPadding() + 2; //two pixels of tolerance | |
104 | width += base.width(); |
|
111 | width += base.width(); | |
105 | height = fn.height() * ticksList.count(); |
|
112 | height = fn.height() * ticksList.count(); | |
106 | height = qMax(height,base.height()); |
|
113 | height = qMax(height,base.height()); | |
107 | sh = QSizeF(width,height); |
|
114 | sh = QSizeF(width,height); | |
108 | break; |
|
115 | break; | |
109 | } |
|
116 | } | |
110 | default: |
|
117 | default: | |
111 | break; |
|
118 | break; | |
112 | } |
|
119 | } | |
113 |
|
120 | |||
114 | return sh; |
|
121 | return sh; | |
115 | } |
|
122 | } | |
116 |
|
123 | |||
117 | #include "moc_chartdatetimeaxisy_p.cpp" |
|
124 | #include "moc_chartdatetimeaxisy_p.cpp" | |
118 |
|
125 | |||
119 | QTCOMMERCIALCHART_END_NAMESPACE |
|
126 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,59 +1,61 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef CHARTDATETIMEAXISY_H |
|
30 | #ifndef CHARTDATETIMEAXISY_H | |
31 | #define CHARTDATETIMEAXISY_H |
|
31 | #define CHARTDATETIMEAXISY_H | |
32 |
|
32 | |||
33 | #include "verticalaxis_p.h" |
|
33 | #include "verticalaxis_p.h" | |
34 |
|
34 | |||
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QDateTimeAxis; |
|
37 | class QDateTimeAxis; | |
38 | class ChartPresenter; |
|
38 | class ChartPresenter; | |
39 |
|
39 | |||
40 | class ChartDateTimeAxisY : public VerticalAxis |
|
40 | class ChartDateTimeAxisY : public VerticalAxis | |
41 | { |
|
41 | { | |
42 | Q_OBJECT |
|
42 | Q_OBJECT | |
43 | public: |
|
43 | public: | |
44 | ChartDateTimeAxisY(QDateTimeAxis *axis, QGraphicsItem* item = 0); |
|
44 | ChartDateTimeAxisY(QDateTimeAxis *axis, QGraphicsItem* item = 0); | |
45 | ~ChartDateTimeAxisY(); |
|
45 | ~ChartDateTimeAxisY(); | |
46 |
|
46 | |||
47 | QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; |
|
47 | QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; | |
48 | protected: |
|
48 | protected: | |
49 | QVector<qreal> calculateLayout() const; |
|
49 | QVector<qreal> calculateLayout() const; | |
50 | void updateGeometry(); |
|
50 | void updateGeometry(); | |
51 | private Q_SLOTS: |
|
51 | private Q_SLOTS: | |
52 | void handleTickCountChanged(int tick); |
|
52 | void handleTickCountChanged(int tick); | |
|
53 | void handleFormatChanged(const QString &format); | |||
|
54 | ||||
53 | private: |
|
55 | private: | |
54 | QDateTimeAxis *m_axis; |
|
56 | QDateTimeAxis *m_axis; | |
55 | }; |
|
57 | }; | |
56 |
|
58 | |||
57 | QTCOMMERCIALCHART_END_NAMESPACE |
|
59 | QTCOMMERCIALCHART_END_NAMESPACE | |
58 |
|
60 | |||
59 | #endif /* CHARTDATETIMEAXISY_H */ |
|
61 | #endif /* CHARTDATETIMEAXISY_H */ |
General Comments 0
You need to be logged in to leave comments.
Login now