@@ -0,0 +1,5 | |||
|
1 | !include( ../auto.pri ) { | |
|
2 | error( "Couldn't find the auto.pri file!" ) | |
|
3 | } | |
|
4 | HEADERS += ../qabstractaxis/tst_qabstractaxis.h | |
|
5 | SOURCES += tst_qintervalsaxis.cpp ../qabstractaxis/tst_qabstractaxis.cpp |
@@ -0,0 +1,299 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | #include "../qabstractaxis/tst_qabstractaxis.h" | |
|
22 | #include "qintervalsaxis.h" | |
|
23 | #include <qlineseries.h> | |
|
24 | ||
|
25 | class tst_QIntervalsAxis: public tst_QAbstractAxis | |
|
26 | { | |
|
27 | Q_OBJECT | |
|
28 | ||
|
29 | public slots: | |
|
30 | void initTestCase(); | |
|
31 | void cleanupTestCase(); | |
|
32 | void init(); | |
|
33 | void cleanup(); | |
|
34 | ||
|
35 | private slots: | |
|
36 | void qintervalsaxis_data(); | |
|
37 | void qintervalsaxis(); | |
|
38 | ||
|
39 | void max_raw_data(); | |
|
40 | void max_raw(); | |
|
41 | void max_data(); | |
|
42 | void max(); | |
|
43 | void max_animation_data(); | |
|
44 | void max_animation(); | |
|
45 | void min_raw_data(); | |
|
46 | void min_raw(); | |
|
47 | void min_data(); | |
|
48 | void min(); | |
|
49 | void min_animation_data(); | |
|
50 | void min_animation(); | |
|
51 | void range_raw_data(); | |
|
52 | void range_raw(); | |
|
53 | void range_data(); | |
|
54 | void range(); | |
|
55 | void range_animation_data(); | |
|
56 | void range_animation(); | |
|
57 | ||
|
58 | void interval_data(); | |
|
59 | void interval(); | |
|
60 | ||
|
61 | private: | |
|
62 | QIntervalsAxis* m_intervalsaxis; | |
|
63 | QLineSeries* m_series; | |
|
64 | }; | |
|
65 | ||
|
66 | void tst_QIntervalsAxis::initTestCase() | |
|
67 | { | |
|
68 | } | |
|
69 | ||
|
70 | void tst_QIntervalsAxis::cleanupTestCase() | |
|
71 | { | |
|
72 | } | |
|
73 | ||
|
74 | void tst_QIntervalsAxis::init() | |
|
75 | { | |
|
76 | m_intervalsaxis = new QIntervalsAxis(); | |
|
77 | m_series = new QLineSeries(); | |
|
78 | *m_series << QPointF(-100, -100) << QPointF(0, 0) << QPointF(100, 100); | |
|
79 | tst_QAbstractAxis::init(m_intervalsaxis, m_series); | |
|
80 | m_chart->addSeries(m_series); | |
|
81 | m_chart->createDefaultAxes(); | |
|
82 | } | |
|
83 | ||
|
84 | void tst_QIntervalsAxis::cleanup() | |
|
85 | { | |
|
86 | delete m_series; | |
|
87 | delete m_intervalsaxis; | |
|
88 | m_series = 0; | |
|
89 | m_intervalsaxis = 0; | |
|
90 | tst_QAbstractAxis::cleanup(); | |
|
91 | } | |
|
92 | ||
|
93 | void tst_QIntervalsAxis::qintervalsaxis_data() | |
|
94 | { | |
|
95 | } | |
|
96 | ||
|
97 | void tst_QIntervalsAxis::qintervalsaxis() | |
|
98 | { | |
|
99 | qabstractaxis(); | |
|
100 | ||
|
101 | QVERIFY(qFuzzyIsNull(m_intervalsaxis->max())); | |
|
102 | QVERIFY(qFuzzyIsNull(m_intervalsaxis->min())); | |
|
103 | QCOMPARE(m_intervalsaxis->type(), QAbstractAxis::AxisTypeIntervals); | |
|
104 | ||
|
105 | m_chart->setAxisX(m_intervalsaxis, m_series); | |
|
106 | m_view->show(); | |
|
107 | QTest::qWaitForWindowShown(m_view); | |
|
108 | ||
|
109 | QVERIFY(!qFuzzyIsNull(m_intervalsaxis->max())); | |
|
110 | QVERIFY(!qFuzzyIsNull(m_intervalsaxis->min())); | |
|
111 | } | |
|
112 | ||
|
113 | void tst_QIntervalsAxis::max_raw_data() | |
|
114 | { | |
|
115 | QTest::addColumn<qreal>("max"); | |
|
116 | QTest::newRow("1.0") << 1.0; | |
|
117 | QTest::newRow("50.0") << 50.0; | |
|
118 | QTest::newRow("101.0") << 101.0; | |
|
119 | } | |
|
120 | ||
|
121 | void tst_QIntervalsAxis::max_raw() | |
|
122 | { | |
|
123 | QFETCH(qreal, max); | |
|
124 | ||
|
125 | QSignalSpy spy0(m_intervalsaxis, SIGNAL(maxChanged(qreal))); | |
|
126 | QSignalSpy spy1(m_intervalsaxis, SIGNAL(minChanged(qreal))); | |
|
127 | QSignalSpy spy2(m_intervalsaxis, SIGNAL(rangeChanged(qreal, qreal))); | |
|
128 | ||
|
129 | m_intervalsaxis->setMax(max); | |
|
130 | QVERIFY2(qFuzzyIsNull(m_intervalsaxis->max() - max), "Not equal"); | |
|
131 | ||
|
132 | QCOMPARE(spy0.count(), 1); | |
|
133 | QCOMPARE(spy1.count(), 0); | |
|
134 | QCOMPARE(spy2.count(), 1); | |
|
135 | } | |
|
136 | ||
|
137 | void tst_QIntervalsAxis::max_data() | |
|
138 | { | |
|
139 | max_raw_data(); | |
|
140 | } | |
|
141 | ||
|
142 | void tst_QIntervalsAxis::max() | |
|
143 | { | |
|
144 | m_chart->setAxisX(m_intervalsaxis, m_series); | |
|
145 | m_view->show(); | |
|
146 | QTest::qWaitForWindowShown(m_view); | |
|
147 | max_raw(); | |
|
148 | } | |
|
149 | ||
|
150 | void tst_QIntervalsAxis::max_animation_data() | |
|
151 | { | |
|
152 | max_data(); | |
|
153 | } | |
|
154 | ||
|
155 | void tst_QIntervalsAxis::max_animation() | |
|
156 | { | |
|
157 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); | |
|
158 | max(); | |
|
159 | } | |
|
160 | ||
|
161 | void tst_QIntervalsAxis::min_raw_data() | |
|
162 | { | |
|
163 | QTest::addColumn<qreal>("min"); | |
|
164 | QTest::newRow("-1.0") << -1.0; | |
|
165 | QTest::newRow("-50.0") << -50.0; | |
|
166 | QTest::newRow("-101.0") << -101.0; | |
|
167 | } | |
|
168 | ||
|
169 | void tst_QIntervalsAxis::min_raw() | |
|
170 | { | |
|
171 | QFETCH(qreal, min); | |
|
172 | ||
|
173 | QSignalSpy spy0(m_intervalsaxis, SIGNAL(maxChanged(qreal))); | |
|
174 | QSignalSpy spy1(m_intervalsaxis, SIGNAL(minChanged(qreal))); | |
|
175 | QSignalSpy spy2(m_intervalsaxis, SIGNAL(rangeChanged(qreal, qreal))); | |
|
176 | ||
|
177 | m_intervalsaxis->setMin(min); | |
|
178 | QVERIFY2(qFuzzyIsNull(m_intervalsaxis->min() - min), "Not equal"); | |
|
179 | ||
|
180 | QCOMPARE(spy0.count(), 0); | |
|
181 | QCOMPARE(spy1.count(), 1); | |
|
182 | QCOMPARE(spy2.count(), 1); | |
|
183 | } | |
|
184 | ||
|
185 | void tst_QIntervalsAxis::min_data() | |
|
186 | { | |
|
187 | min_raw_data(); | |
|
188 | } | |
|
189 | ||
|
190 | void tst_QIntervalsAxis::min() | |
|
191 | { | |
|
192 | m_chart->setAxisX(m_intervalsaxis, m_series); | |
|
193 | m_view->show(); | |
|
194 | QTest::qWaitForWindowShown(m_view); | |
|
195 | min_raw(); | |
|
196 | } | |
|
197 | ||
|
198 | void tst_QIntervalsAxis::min_animation_data() | |
|
199 | { | |
|
200 | min_data(); | |
|
201 | } | |
|
202 | ||
|
203 | void tst_QIntervalsAxis::min_animation() | |
|
204 | { | |
|
205 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); | |
|
206 | min(); | |
|
207 | } | |
|
208 | ||
|
209 | void tst_QIntervalsAxis::range_raw_data() | |
|
210 | { | |
|
211 | QTest::addColumn<qreal>("min"); | |
|
212 | QTest::addColumn<qreal>("max"); | |
|
213 | QTest::newRow("1.0 - 101.0") << -1.0 << 101.0; | |
|
214 | QTest::newRow("25.0 - 75.0") << 25.0 << 75.0; | |
|
215 | QTest::newRow("101.0") << 40.0 << 60.0; | |
|
216 | } | |
|
217 | ||
|
218 | void tst_QIntervalsAxis::range_raw() | |
|
219 | { | |
|
220 | QFETCH(qreal, min); | |
|
221 | QFETCH(qreal, max); | |
|
222 | ||
|
223 | QSignalSpy spy0(m_intervalsaxis, SIGNAL(maxChanged(qreal))); | |
|
224 | QSignalSpy spy1(m_intervalsaxis, SIGNAL(minChanged(qreal))); | |
|
225 | QSignalSpy spy2(m_intervalsaxis, SIGNAL(rangeChanged(qreal, qreal))); | |
|
226 | ||
|
227 | m_intervalsaxis->setRange(min, max); | |
|
228 | QVERIFY2(qFuzzyIsNull(m_intervalsaxis->min() - min), "Min not equal"); | |
|
229 | QVERIFY2(qFuzzyIsNull(m_intervalsaxis->max() - max), "Max not equal"); | |
|
230 | ||
|
231 | QCOMPARE(spy0.count(), 1); | |
|
232 | QCOMPARE(spy1.count(), 1); | |
|
233 | QCOMPARE(spy2.count(), 1); | |
|
234 | } | |
|
235 | ||
|
236 | void tst_QIntervalsAxis::range_data() | |
|
237 | { | |
|
238 | range_raw_data(); | |
|
239 | } | |
|
240 | ||
|
241 | void tst_QIntervalsAxis::range() | |
|
242 | { | |
|
243 | m_chart->setAxisX(m_intervalsaxis, m_series); | |
|
244 | m_view->show(); | |
|
245 | QTest::qWaitForWindowShown(m_view); | |
|
246 | range_raw(); | |
|
247 | } | |
|
248 | ||
|
249 | void tst_QIntervalsAxis::range_animation_data() | |
|
250 | { | |
|
251 | range_data(); | |
|
252 | } | |
|
253 | ||
|
254 | void tst_QIntervalsAxis::range_animation() | |
|
255 | { | |
|
256 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); | |
|
257 | range(); | |
|
258 | } | |
|
259 | ||
|
260 | void tst_QIntervalsAxis::interval_data() | |
|
261 | { | |
|
262 | // | |
|
263 | } | |
|
264 | ||
|
265 | void tst_QIntervalsAxis::interval() | |
|
266 | { | |
|
267 | // append one correct interval | |
|
268 | m_intervalsaxis->append("first", (qreal)45); | |
|
269 | QCOMPARE(m_intervalsaxis->intervalMin("first"), (qreal)0); | |
|
270 | QCOMPARE(m_intervalsaxis->intervalMax("first"), (qreal)45); | |
|
271 | ||
|
272 | // append one more correct interval | |
|
273 | m_intervalsaxis->append("second", (qreal)75); | |
|
274 | QCOMPARE(m_intervalsaxis->intervalMin("second"), (qreal)45); | |
|
275 | QCOMPARE(m_intervalsaxis->intervalMax("second"), (qreal)75); | |
|
276 | ||
|
277 | // append one incorrect interval | |
|
278 | m_intervalsaxis->append("third", (qreal)15); | |
|
279 | QCOMPARE(m_intervalsaxis->count(), 2); | |
|
280 | QCOMPARE(m_intervalsaxis->intervalMax(m_intervalsaxis->intervalsLabels().last()), (qreal)75); | |
|
281 | // QCOMPARE(intervalMax("first"), (qreal)75); | |
|
282 | ||
|
283 | // append one more correct interval | |
|
284 | m_intervalsaxis->append("third", (qreal)100); | |
|
285 | QCOMPARE(m_intervalsaxis->count(), 3); | |
|
286 | QCOMPARE(m_intervalsaxis->intervalMin("third"), (qreal)75); | |
|
287 | QCOMPARE(m_intervalsaxis->intervalMax("third"), (qreal)100); | |
|
288 | ||
|
289 | // remove one interval | |
|
290 | m_intervalsaxis->remove("first"); | |
|
291 | QCOMPARE(m_intervalsaxis->count(), 2); | |
|
292 | QCOMPARE(m_intervalsaxis->intervalMin("second"), (qreal)0); // second interval should extend to firstInterval minimum | |
|
293 | QCOMPARE(m_intervalsaxis->intervalMax("second"), (qreal)75); | |
|
294 | ||
|
295 | } | |
|
296 | ||
|
297 | QTEST_MAIN(tst_QIntervalsAxis) | |
|
298 | #include "tst_qintervalsaxis.moc" | |
|
299 |
@@ -1,122 +1,126 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "chartintervalsaxisx_p.h" |
|
22 | 22 | #include "qabstractaxis.h" |
|
23 | 23 | #include "chartpresenter_p.h" |
|
24 | 24 | #include "chartanimator_p.h" |
|
25 | 25 | #include <QGraphicsLayout> |
|
26 | 26 | #include <QDebug> |
|
27 | 27 | #include <QFontMetrics> |
|
28 | 28 | #include <cmath> |
|
29 | 29 | #include <QIntervalsAxis> |
|
30 | 30 | |
|
31 | 31 | static int label_padding = 5; |
|
32 | 32 | |
|
33 | 33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | 34 | |
|
35 | 35 | ChartIntervalAxisX::ChartIntervalAxisX(QAbstractAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter) |
|
36 | 36 | { |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | ChartIntervalAxisX::~ChartIntervalAxisX() |
|
40 | 40 | { |
|
41 | 41 | } |
|
42 | 42 | |
|
43 | 43 | QVector<qreal> ChartIntervalAxisX::calculateLayout() const |
|
44 | 44 | { |
|
45 | 45 | QIntervalsAxis *axis = qobject_cast<QIntervalsAxis *>(m_chartAxis); |
|
46 | 46 | int tickCount = axis->intervalsLabels().count() + 1; |
|
47 | 47 | QVector<qreal> points; |
|
48 | ||
|
49 | if (tickCount < 2) | |
|
50 | return points; | |
|
51 | ||
|
48 | 52 | points.resize(tickCount); |
|
49 | 53 | |
|
50 | 54 | qreal scale = m_rect.width() / axis->max(); |
|
51 | 55 | for (int i = 0; i < tickCount; ++i) |
|
52 | 56 | if (i < tickCount - 1) { |
|
53 | 57 | int x = axis->intervalMin(axis->intervalsLabels().at(i)) * scale + m_rect.left(); |
|
54 | 58 | points[i] = x; |
|
55 | 59 | } else { |
|
56 | 60 | int x = axis->intervalMax(axis->intervalsLabels().at(i - 1)) * scale + m_rect.left(); |
|
57 | 61 | points[i] = x; |
|
58 | 62 | } |
|
59 | 63 | |
|
60 | 64 | return points; |
|
61 | 65 | } |
|
62 | 66 | |
|
63 | 67 | void ChartIntervalAxisX::updateGeometry() |
|
64 | 68 | { |
|
65 | 69 | const QVector<qreal>& layout = ChartAxis::layout(); |
|
66 | 70 | |
|
67 | 71 | m_minWidth = 0; |
|
68 | 72 | m_minHeight = 0; |
|
69 | 73 | |
|
70 | 74 | if(layout.isEmpty()) return; |
|
71 | 75 | |
|
72 | 76 | QIntervalsAxis *intervalAxis = qobject_cast<QIntervalsAxis *>(m_chartAxis); |
|
73 | 77 | |
|
74 | 78 | QStringList ticksList = intervalAxis->intervalsLabels(); |
|
75 | 79 | |
|
76 | 80 | // createNumberLabels(ticksList,m_min,m_max,layout.size()); |
|
77 | 81 | |
|
78 | 82 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
79 | 83 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
80 | 84 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
81 | 85 | QList<QGraphicsItem *> axis = m_axis->childItems(); |
|
82 | 86 | |
|
83 | 87 | // Q_ASSERT(labels.size() == ticksList.size()); |
|
84 | 88 | // Q_ASSERT(layout.size() == ticksList.size()); |
|
85 | 89 | |
|
86 | 90 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(axis.at(0)); |
|
87 | 91 | lineItem->setLine(m_rect.left(), m_rect.bottom(), m_rect.right(), m_rect.bottom()); |
|
88 | 92 | |
|
89 | 93 | // qreal width = 0; |
|
90 | 94 | for (int i = 0; i < layout.size(); ++i) { |
|
91 | 95 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i)); |
|
92 | 96 | lineItem->setLine(layout[i], m_rect.top(), layout[i], m_rect.bottom()); |
|
93 | 97 | QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i)); |
|
94 | 98 | if (i < ticksList.count()) { |
|
95 | 99 | labelItem->setText(ticksList.at(i)); |
|
96 | 100 | } |
|
97 | 101 | const QRectF& rect = labelItem->boundingRect(); |
|
98 | 102 | QPointF center = rect.center(); |
|
99 | 103 | labelItem->setTransformOriginPoint(center.x(), center.y()); |
|
100 | 104 | if (i < ticksList.count()) |
|
101 | 105 | labelItem->setPos(layout[i] + (layout[i + 1] - layout[i]) / 2 - center.x(), m_rect.bottom() + label_padding); |
|
102 | 106 | else |
|
103 | 107 | labelItem->setPos(layout[i] - center.x(), m_rect.bottom() + label_padding); |
|
104 | 108 | |
|
105 | 109 | if(labelItem->pos().x() > m_rect.width() + m_rect.left() - rect.width() / 2){ |
|
106 | 110 | labelItem->setVisible(false); |
|
107 | 111 | lineItem->setVisible(false); |
|
108 | 112 | } |
|
109 | 113 | |
|
110 | 114 | m_minWidth += rect.width(); |
|
111 | 115 | m_minHeight = qMax(rect.height(), m_minHeight); |
|
112 | 116 | |
|
113 | 117 | if ((i + 1) % 2 && i > 1) { |
|
114 | 118 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i / 2 - 1)); |
|
115 | 119 | rectItem->setRect(layout[i - 1],m_rect.top(),layout[i]-layout[i - 1],m_rect.height()); |
|
116 | 120 | } |
|
117 | 121 | lineItem = static_cast<QGraphicsLineItem*>(axis.at(i+1)); |
|
118 | 122 | lineItem->setLine(layout[i],m_rect.bottom(),layout[i], m_rect.bottom() + 5); |
|
119 | 123 | } |
|
120 | 124 | } |
|
121 | 125 | |
|
122 | 126 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,128 +1,132 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "chartintervalsaxisy_p.h" |
|
22 | 22 | #include "qabstractaxis.h" |
|
23 | 23 | #include "chartpresenter_p.h" |
|
24 | 24 | #include "chartanimator_p.h" |
|
25 | 25 | #include <QGraphicsLayout> |
|
26 | 26 | #include <QDebug> |
|
27 | 27 | #include <QFontMetrics> |
|
28 | 28 | #include <cmath> |
|
29 | 29 | #include <QIntervalsAxis> |
|
30 | 30 | |
|
31 | 31 | static int label_padding = 5; |
|
32 | 32 | |
|
33 | 33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | 34 | |
|
35 | 35 | ChartIntervalAxisY::ChartIntervalAxisY(QAbstractAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter) |
|
36 | 36 | { |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | ChartIntervalAxisY::~ChartIntervalAxisY() |
|
40 | 40 | { |
|
41 | 41 | } |
|
42 | 42 | |
|
43 | 43 | QVector<qreal> ChartIntervalAxisY::calculateLayout() const |
|
44 | 44 | { |
|
45 | 45 | QIntervalsAxis *axis = qobject_cast<QIntervalsAxis *>(m_chartAxis); |
|
46 | 46 | int tickCount = axis->intervalsLabels().count() + 1; |
|
47 | 47 | QVector<qreal> points; |
|
48 | ||
|
49 | if (tickCount < 2) | |
|
50 | return points; | |
|
51 | ||
|
48 | 52 | points.resize(tickCount); |
|
49 | 53 | |
|
50 | 54 | qreal scale = m_rect.height() / axis->max(); |
|
51 | 55 | for (int i = 0; i < tickCount; ++i) |
|
52 | 56 | if (i < tickCount - 1) { |
|
53 | 57 | int y = -axis->intervalMin(axis->intervalsLabels().at(i)) * scale + m_rect.bottom(); |
|
54 | 58 | points[i] = y; |
|
55 | 59 | } else { |
|
56 | 60 | int y = -axis->intervalMax(axis->intervalsLabels().at(i - 1)) * scale + m_rect.bottom(); |
|
57 | 61 | points[i] = y; |
|
58 | 62 | } |
|
59 | 63 | |
|
60 | 64 | return points; |
|
61 | 65 | } |
|
62 | 66 | |
|
63 | 67 | void ChartIntervalAxisY::updateGeometry() |
|
64 | 68 | { |
|
65 | 69 | const QVector<qreal> &layout = ChartAxis::layout(); |
|
66 | 70 | m_minWidth = 0; |
|
67 | 71 | m_minHeight = 0; |
|
68 | 72 | |
|
69 | 73 | if(layout.isEmpty()) return; |
|
70 | 74 | |
|
71 | 75 | QIntervalsAxis *intervalAxis = qobject_cast<QIntervalsAxis *>(m_chartAxis); |
|
72 | 76 | |
|
73 | 77 | QStringList ticksList = intervalAxis->intervalsLabels(); |
|
74 | 78 | |
|
75 | 79 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
76 | 80 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
77 | 81 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
78 | 82 | QList<QGraphicsItem *> axis = m_axis->childItems(); |
|
79 | 83 | |
|
80 | 84 | // Q_ASSERT(labels.size() == ticksList.size()); |
|
81 | 85 | // Q_ASSERT(layout.size() == ticksList.size()); |
|
82 | 86 | |
|
83 | 87 | qreal height = 2*m_rect.bottom(); |
|
84 | 88 | |
|
85 | 89 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(axis.at(0)); |
|
86 | 90 | lineItem->setLine(m_rect.left() , m_rect.top(), m_rect.left(), m_rect.bottom()); |
|
87 | 91 | |
|
88 | 92 | for (int i = 0; i < layout.size(); ++i) { |
|
89 | 93 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i)); |
|
90 | 94 | lineItem->setLine(m_rect.left() , layout[i], m_rect.right(), layout[i]); |
|
91 | 95 | QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i)); |
|
92 | 96 | |
|
93 | 97 | if (i < ticksList.count()) { |
|
94 | 98 | labelItem->setText(ticksList.at(i)); |
|
95 | 99 | } |
|
96 | 100 | const QRectF& rect = labelItem->boundingRect(); |
|
97 | 101 | |
|
98 | 102 | QPointF center = rect.center(); |
|
99 | 103 | labelItem->setTransformOriginPoint(center.x(), center.y()); |
|
100 | 104 | |
|
101 | 105 | if (i < ticksList.count()) |
|
102 | 106 | labelItem->setPos(m_rect.left() - rect.width() - label_padding , layout[i] + (layout[i + 1] - layout[i]) / 2 - center.y()); |
|
103 | 107 | else |
|
104 | 108 | labelItem->setPos(m_rect.left() - rect.width() - label_padding , layout[i]-center.y()); |
|
105 | 109 | |
|
106 | 110 | if(labelItem->pos().y()+rect.height()>height) { |
|
107 | 111 | labelItem->setVisible(false); |
|
108 | 112 | lineItem->setVisible(false); |
|
109 | 113 | } |
|
110 | 114 | else { |
|
111 | 115 | labelItem->setVisible(true); |
|
112 | 116 | lineItem->setVisible(true); |
|
113 | 117 | height=labelItem->pos().y(); |
|
114 | 118 | } |
|
115 | 119 | |
|
116 | 120 | m_minWidth=qMax(rect.width()+label_padding,m_minWidth); |
|
117 | 121 | m_minHeight+=rect.height(); |
|
118 | 122 | |
|
119 | 123 | if ((i+1)%2 && i>1) { |
|
120 | 124 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2-1)); |
|
121 | 125 | rectItem->setRect(m_rect.left(),layout[i],m_rect.width(),layout[i-1]-layout[i]); |
|
122 | 126 | } |
|
123 | 127 | lineItem = static_cast<QGraphicsLineItem*>(axis.at(i+1)); |
|
124 | 128 | lineItem->setLine(m_rect.left()-5,layout[i],m_rect.left(),layout[i]); |
|
125 | 129 | } |
|
126 | 130 | } |
|
127 | 131 | |
|
128 | 132 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,190 +1,210 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qintervalsaxis.h" |
|
22 | 22 | #include "qintervalsaxis_p.h" |
|
23 | 23 | #include "chartintervalsaxisx_p.h" |
|
24 | 24 | #include "chartintervalsaxisy_p.h" |
|
25 | 25 | #include <qmath.h> |
|
26 | 26 | #include <QDebug> |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 29 | /*! |
|
30 | 30 | \internal |
|
31 | 31 | \class QIntervalsAxis |
|
32 | 32 | \brief The QIntervalsAxis class is used for manipulating chart's axis. |
|
33 | 33 | \mainclass |
|
34 | 34 | |
|
35 | 35 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
36 | 36 | */ |
|
37 | 37 | |
|
38 | 38 | /*! |
|
39 | 39 | \qmlclass Axis QIntervalsAxis |
|
40 | 40 | \brief The Axis element is used for manipulating chart's axes. |
|
41 | 41 | |
|
42 | 42 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
43 | 43 | |
|
44 | 44 | To access Axes you can use ChartView API. For example: |
|
45 | 45 | \code |
|
46 | 46 | // TODO :) |
|
47 | 47 | \endcode |
|
48 | 48 | */ |
|
49 | 49 | |
|
50 | 50 | /*! |
|
51 | 51 | Constructs an axis object which is a child of \a parent. |
|
52 | 52 | */ |
|
53 | 53 | QIntervalsAxis::QIntervalsAxis(QObject *parent): |
|
54 | 54 | QValuesAxis(*new QIntervalsAxisPrivate(this),parent) |
|
55 | 55 | { |
|
56 | 56 | } |
|
57 | 57 | |
|
58 | 58 | /*! |
|
59 | 59 | Destroys the object |
|
60 | 60 | */ |
|
61 | 61 | QIntervalsAxis::~QIntervalsAxis() |
|
62 | 62 | { |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | /*! |
|
66 | 66 | \internal |
|
67 | 67 | */ |
|
68 | 68 | QIntervalsAxis::QIntervalsAxis(QIntervalsAxisPrivate &d,QObject *parent):QValuesAxis(d,parent) |
|
69 | 69 | { |
|
70 | 70 | |
|
71 | 71 | } |
|
72 | 72 | |
|
73 | 73 | /*! |
|
74 | 74 | Appends \a category to axis |
|
75 | 75 | */ |
|
76 | 76 | void QIntervalsAxis::append(const QString& intervalLabel, qreal interval) |
|
77 | 77 | { |
|
78 | 78 | Q_D(QIntervalsAxis); |
|
79 | ||
|
79 | 80 | if (!d->m_intervals.contains(intervalLabel)) |
|
80 | 81 | { |
|
81 | 82 | if(d->m_intervals.isEmpty()){ |
|
82 | 83 | Range range(d->m_categoryMinimum,interval); |
|
83 | 84 | d->m_intervalsMap.insert(intervalLabel, range); |
|
84 | 85 | d->m_intervals.append(intervalLabel); |
|
85 | }else{ | |
|
86 | }else if (interval > intervalMax(d->m_intervals.last())){ | |
|
86 | 87 | Range range = d->m_intervalsMap.value(d->m_intervals.last()); |
|
87 | 88 | d->m_intervalsMap.insert(intervalLabel, Range(range.second,interval)); |
|
88 | 89 | d->m_intervals.append(intervalLabel); |
|
89 |
|
|
|
90 | // setRange(d->m_min,interval); | |
|
90 | } | |
|
91 | 91 | } |
|
92 | 92 | } |
|
93 | 93 | |
|
94 | 94 | void QIntervalsAxis::setFisrtIntervalMinimum(qreal min) |
|
95 | 95 | { |
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 | } | |
|
96 | Q_D(QIntervalsAxis); | |
|
97 | if(d->m_intervals.isEmpty()){ | |
|
98 | d->m_categoryMinimum = min; | |
|
99 | }else{ | |
|
100 | Range range = d->m_intervalsMap.value(d->m_intervals.first()); | |
|
101 | d->m_intervalsMap.insert(d->m_intervals.first(), Range(min, range.second)); | |
|
102 | // setRange(min, d->m_min); | |
|
103 | } | |
|
104 | 104 | } |
|
105 | 105 | |
|
106 | 106 | qreal QIntervalsAxis::intervalMin(const QString& intervalLabel) const |
|
107 | 107 | { |
|
108 | 108 | Q_D(const QIntervalsAxis); |
|
109 | 109 | return d->m_intervalsMap.value(intervalLabel).first; |
|
110 | 110 | } |
|
111 | 111 | |
|
112 | 112 | qreal QIntervalsAxis::intervalMax(const QString& intervalLabel) const |
|
113 | 113 | { |
|
114 | 114 | Q_D(const QIntervalsAxis); |
|
115 | 115 | return d->m_intervalsMap.value(intervalLabel).second; |
|
116 | 116 | } |
|
117 | 117 | |
|
118 | 118 | /*! |
|
119 | 119 | Removes \a category from axis |
|
120 | 120 | */ |
|
121 | 121 | void QIntervalsAxis::remove(const QString &intervalLabel) |
|
122 | 122 | { |
|
123 |
Q_ |
|
|
124 | //TODO | |
|
123 | Q_D(QIntervalsAxis); | |
|
124 | int labelIndex = d->m_intervals.indexOf(intervalLabel); | |
|
125 | ||
|
126 | // check if such label exists | |
|
127 | if (labelIndex != -1) { | |
|
128 | d->m_intervals.removeAt(labelIndex); | |
|
129 | d->m_intervalsMap.remove(intervalLabel); | |
|
130 | ||
|
131 | // the range of the interval that follows (if exists) needs to be updated | |
|
132 | if (labelIndex < d->m_intervals.count()) { | |
|
133 | QString label = d->m_intervals.at(labelIndex); | |
|
134 | Range range = d->m_intervalsMap.value(label); | |
|
135 | ||
|
136 | // set the range | |
|
137 | if (labelIndex == 0) { | |
|
138 | range.first = d->m_categoryMinimum; | |
|
139 | d->m_intervalsMap.insert(label, range); | |
|
140 | } else { | |
|
141 | range.first = d->m_intervalsMap.value(d->m_intervals.at(labelIndex - 1)).second; | |
|
142 | d->m_intervalsMap.insert(label, range); | |
|
143 | } | |
|
144 | } | |
|
145 | } | |
|
125 | 146 | } |
|
126 | 147 | |
|
127 | 148 | QStringList QIntervalsAxis::intervalsLabels() |
|
128 | 149 | { |
|
129 | 150 | Q_D(QIntervalsAxis); |
|
130 | 151 | return d->m_intervals; |
|
131 | 152 | } |
|
132 | 153 | |
|
133 | 154 | /*! |
|
134 | 155 | Returns number of categories. |
|
135 | 156 | */ |
|
136 | 157 | int QIntervalsAxis::count() const |
|
137 | 158 | { |
|
138 | 159 | Q_D(const QIntervalsAxis); |
|
139 | 160 | return d->m_intervals.count(); |
|
140 | 161 | } |
|
141 | 162 | |
|
142 | 163 | /*! |
|
143 | 164 | Returns the type of the axis |
|
144 | 165 | */ |
|
145 | 166 | QAbstractAxis::AxisType QIntervalsAxis::type() const |
|
146 | 167 | { |
|
147 |
return AxisType |
|
|
168 | return QAbstractAxis::AxisTypeIntervals; | |
|
148 | 169 | } |
|
149 | 170 | |
|
150 | 171 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
151 | 172 | |
|
152 | 173 | QIntervalsAxisPrivate::QIntervalsAxisPrivate(QIntervalsAxis* q): |
|
153 | 174 | QValuesAxisPrivate(q), |
|
154 | 175 | m_categoryMinimum(0) |
|
155 | 176 | { |
|
156 | 177 | |
|
157 | 178 | } |
|
158 | 179 | |
|
159 | 180 | QIntervalsAxisPrivate::~QIntervalsAxisPrivate() |
|
160 | 181 | { |
|
161 | 182 | |
|
162 | 183 | } |
|
163 | 184 | |
|
164 | 185 | int QIntervalsAxisPrivate::ticksCount() const |
|
165 | 186 | { |
|
166 | 187 | return m_intervals.count() + 1; |
|
167 | 188 | } |
|
168 | 189 | |
|
169 | 190 | void QIntervalsAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) |
|
170 | 191 | { |
|
171 | 192 | Q_UNUSED(count); |
|
172 | 193 | m_min = min; |
|
173 | 194 | m_max = max; |
|
174 | // m_ticksCount = count; | |
|
175 | 195 | } |
|
176 | 196 | |
|
177 | 197 | ChartAxis* QIntervalsAxisPrivate::createGraphics(ChartPresenter* presenter) |
|
178 | 198 | { |
|
179 | 199 | Q_Q(QIntervalsAxis); |
|
180 | 200 | if(m_orientation == Qt::Vertical){ |
|
181 | 201 | return new ChartIntervalAxisY(q,presenter); |
|
182 | 202 | }else{ |
|
183 | 203 | return new ChartIntervalAxisX(q,presenter); |
|
184 | 204 | } |
|
185 | 205 | } |
|
186 | 206 | |
|
187 | 207 | #include "moc_qintervalsaxis.cpp" |
|
188 | 208 | #include "moc_qintervalsaxis_p.cpp" |
|
189 | 209 | |
|
190 | 210 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,141 +1,142 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #ifndef QABSTRACTAXIS_H |
|
22 | 22 | #define QABSTRACTAXIS_H |
|
23 | 23 | |
|
24 | 24 | #include <qchartglobal.h> |
|
25 | 25 | #include <QPen> |
|
26 | 26 | #include <QFont> |
|
27 | 27 | #include <QVariant> |
|
28 | 28 | |
|
29 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 30 | |
|
31 | 31 | class QAbstractAxisPrivate; |
|
32 | 32 | |
|
33 | 33 | class QTCOMMERCIALCHART_EXPORT QAbstractAxis : public QObject |
|
34 | 34 | { |
|
35 | 35 | Q_OBJECT |
|
36 | 36 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) |
|
37 | 37 | Q_PROPERTY(bool arrowVisible READ isArrowVisible WRITE setArrowVisible NOTIFY arrowVisibleChanged) |
|
38 | 38 | Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged) |
|
39 | 39 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) |
|
40 | 40 | Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle) |
|
41 | 41 | Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont) |
|
42 | 42 | Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) |
|
43 | 43 | Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged) |
|
44 | 44 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) |
|
45 | 45 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) |
|
46 | 46 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) |
|
47 | 47 | |
|
48 | 48 | public: |
|
49 | 49 | |
|
50 | 50 | enum AxisType { |
|
51 | 51 | AxisTypeNoAxis = 0x0, |
|
52 | 52 | AxisTypeValues = 0x1, |
|
53 | AxisTypeCategories = 0x2 | |
|
53 | AxisTypeCategories = 0x2, | |
|
54 | AxisTypeIntervals = 0x3 | |
|
54 | 55 | }; |
|
55 | 56 | |
|
56 | 57 | Q_DECLARE_FLAGS(AxisTypes, AxisType) |
|
57 | 58 | |
|
58 | 59 | protected: |
|
59 | 60 | explicit QAbstractAxis(QAbstractAxisPrivate &d,QObject *parent = 0); |
|
60 | 61 | |
|
61 | 62 | public: |
|
62 | 63 | ~QAbstractAxis(); |
|
63 | 64 | |
|
64 | 65 | virtual AxisType type() const = 0; |
|
65 | 66 | |
|
66 | 67 | //visibilty hadnling |
|
67 | 68 | bool isVisible() const; |
|
68 | 69 | void setVisible(bool visible = true); |
|
69 | 70 | |
|
70 | 71 | |
|
71 | 72 | //axis handling |
|
72 | 73 | bool isArrowVisible() const; |
|
73 | 74 | void setArrowVisible(bool visible = true); |
|
74 | 75 | void setAxisPen(const QPen &pen); |
|
75 | 76 | QPen axisPen() const; |
|
76 | 77 | void setAxisPenColor(QColor color); |
|
77 | 78 | QColor axisPenColor() const; |
|
78 | 79 | |
|
79 | 80 | //grid handling |
|
80 | 81 | bool isGridLineVisible() const; |
|
81 | 82 | void setGridLineVisible(bool visible = true); |
|
82 | 83 | void setGridLinePen(const QPen &pen); |
|
83 | 84 | QPen gridLinePen() const; |
|
84 | 85 | |
|
85 | 86 | //labels handling |
|
86 | 87 | bool labelsVisible() const; |
|
87 | 88 | void setLabelsVisible(bool visible = true); |
|
88 | 89 | void setLabelsPen(const QPen &pen); |
|
89 | 90 | QPen labelsPen() const; |
|
90 | 91 | void setLabelsBrush(const QBrush &brush); |
|
91 | 92 | QBrush labelsBrush() const; |
|
92 | 93 | void setLabelsFont(const QFont &font); |
|
93 | 94 | QFont labelsFont() const; |
|
94 | 95 | void setLabelsAngle(int angle); |
|
95 | 96 | int labelsAngle() const; |
|
96 | 97 | void setLabelsColor(QColor color); |
|
97 | 98 | QColor labelsColor() const; |
|
98 | 99 | |
|
99 | 100 | //shades handling |
|
100 | 101 | bool shadesVisible() const; |
|
101 | 102 | void setShadesVisible(bool visible = true); |
|
102 | 103 | void setShadesPen(const QPen &pen); |
|
103 | 104 | QPen shadesPen() const; |
|
104 | 105 | void setShadesBrush(const QBrush &brush); |
|
105 | 106 | QBrush shadesBrush() const; |
|
106 | 107 | void setShadesColor(QColor color); |
|
107 | 108 | QColor shadesColor() const; |
|
108 | 109 | void setShadesBorderColor(QColor color); |
|
109 | 110 | QColor shadesBorderColor() const; |
|
110 | 111 | |
|
111 | 112 | Qt::Orientation orientation(); |
|
112 | 113 | |
|
113 | 114 | //range handling |
|
114 | 115 | void setMin(const QVariant &min); |
|
115 | 116 | void setMax(const QVariant &max); |
|
116 | 117 | void setRange(const QVariant &min, const QVariant &max); |
|
117 | 118 | |
|
118 | 119 | void show(); |
|
119 | 120 | void hide(); |
|
120 | 121 | |
|
121 | 122 | Q_SIGNALS: |
|
122 | 123 | void visibleChanged(bool visible); |
|
123 | 124 | void arrowVisibleChanged(bool visible); |
|
124 | 125 | void labelsVisibleChanged(bool visible); |
|
125 | 126 | void gridVisibleChanged(bool visible); |
|
126 | 127 | void colorChanged(QColor color); |
|
127 | 128 | void labelsColorChanged(QColor color); |
|
128 | 129 | void shadesVisibleChanged(bool visible); |
|
129 | 130 | void shadesColorChanged(QColor color); |
|
130 | 131 | void shadesBorderColorChanged(QColor color); |
|
131 | 132 | |
|
132 | 133 | protected: |
|
133 | 134 | QScopedPointer<QAbstractAxisPrivate> d_ptr; |
|
134 | 135 | Q_DISABLE_COPY(QAbstractAxis); |
|
135 | 136 | friend class ChartDataSet; |
|
136 | 137 | friend class ChartAxis; |
|
137 | 138 | friend class ChartPresenter; |
|
138 | 139 | }; |
|
139 | 140 | |
|
140 | 141 | QTCOMMERCIALCHART_END_NAMESPACE |
|
141 | 142 | #endif |
@@ -1,27 +1,28 | |||
|
1 | 1 | !include( ../tests.pri ) { |
|
2 | 2 | error( "Couldn't find the tests.pri file!" ) |
|
3 | 3 | } |
|
4 | 4 | |
|
5 | 5 | TEMPLATE = subdirs |
|
6 | 6 | SUBDIRS += \ |
|
7 | 7 | qchartview \ |
|
8 | 8 | qchart \ |
|
9 | 9 | qlineseries \ |
|
10 | 10 | qbarset \ |
|
11 | 11 | qbarseries \ |
|
12 | 12 | qstackedbarseries \ |
|
13 | 13 | qpercentbarseries \ |
|
14 | 14 | qpieslice qpieseries \ |
|
15 | 15 | qpiemodelmapper \ |
|
16 | 16 | qsplineseries \ |
|
17 | 17 | qscatterseries \ |
|
18 | 18 | qxymodelmapper \ |
|
19 | 19 | qbarmodelmapper \ |
|
20 | 20 | qhorizontalbarseries \ |
|
21 | 21 | qhorizontalstackedbarseries \ |
|
22 | 22 | qhorizontalpercentbarseries \ |
|
23 | qvaluesaxis | |
|
23 | qvaluesaxis \ | |
|
24 | qintervalsaxis | |
|
24 | 25 | |
|
25 | 26 | test_private:{ |
|
26 | 27 | SUBDIRS += domain chartdataset |
|
27 | 28 | } |
@@ -1,848 +1,848 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "tst_qabstractaxis.h" |
|
22 | 22 | |
|
23 | 23 | Q_DECLARE_METATYPE(QPen) |
|
24 | 24 | Q_DECLARE_METATYPE(Qt::Orientation) |
|
25 | 25 | |
|
26 | 26 | void tst_QAbstractAxis::initTestCase() |
|
27 | 27 | { |
|
28 | 28 | } |
|
29 | 29 | |
|
30 | 30 | void tst_QAbstractAxis::cleanupTestCase() |
|
31 | 31 | { |
|
32 | 32 | } |
|
33 | 33 | |
|
34 | void tst_QAbstractAxis::init(QAbstractAxis* axis,QAbstractSeries* series) | |
|
34 | void tst_QAbstractAxis::init(QAbstractAxis* axis, QAbstractSeries* series) | |
|
35 | 35 | { |
|
36 | 36 | m_axis = axis; |
|
37 | 37 | m_series = series; |
|
38 | 38 | m_view = new QChartView(new QChart()); |
|
39 | 39 | m_chart = m_view->chart(); |
|
40 | 40 | } |
|
41 | 41 | |
|
42 | 42 | void tst_QAbstractAxis::cleanup() |
|
43 | 43 | { |
|
44 | 44 | |
|
45 | 45 | delete m_view; |
|
46 | 46 | m_view = 0; |
|
47 | 47 | m_chart = 0; |
|
48 | 48 | m_axis = 0; |
|
49 | 49 | } |
|
50 | 50 | |
|
51 | 51 | void tst_QAbstractAxis::qabstractaxis() |
|
52 | 52 | { |
|
53 | 53 | QCOMPARE(m_axis->axisPen(), QPen()); |
|
54 | 54 | //TODO QCOMPARE(m_axis->axisPenColor(), QColor()); |
|
55 | 55 | QCOMPARE(m_axis->gridLinePen(), QPen()); |
|
56 | 56 | QCOMPARE(m_axis->isArrowVisible(), true); |
|
57 | 57 | QCOMPARE(m_axis->isGridLineVisible(), true); |
|
58 | 58 | QCOMPARE(m_axis->isVisible(), false); |
|
59 | 59 | QCOMPARE(m_axis->labelsAngle(), 0); |
|
60 | 60 | QCOMPARE(m_axis->labelsBrush(), QBrush()); |
|
61 | 61 | //TODO QCOMPARE(m_axis->labelsColor(), QColor()); |
|
62 | 62 | QCOMPARE(m_axis->labelsFont(), QFont()); |
|
63 | 63 | QCOMPARE(m_axis->labelsPen(), QPen()); |
|
64 | 64 | QCOMPARE(m_axis->labelsVisible(), true); |
|
65 | 65 | QCOMPARE(m_axis->orientation(), Qt::Orientation(0)); |
|
66 | 66 | m_axis->setArrowVisible(false); |
|
67 | 67 | m_axis->setAxisPen(QPen()); |
|
68 | 68 | m_axis->setAxisPenColor(QColor()); |
|
69 | 69 | m_axis->setGridLinePen(QPen()); |
|
70 | 70 | m_axis->setGridLineVisible(false); |
|
71 | 71 | m_axis->setLabelsAngle(-1); |
|
72 | 72 | m_axis->setLabelsBrush(QBrush()); |
|
73 | 73 | m_axis->setLabelsColor(QColor()); |
|
74 | 74 | m_axis->setLabelsFont(QFont()); |
|
75 | 75 | m_axis->setLabelsPen(QPen()); |
|
76 | 76 | m_axis->setLabelsVisible(false); |
|
77 | 77 | m_axis->setMax(QVariant()); |
|
78 | 78 | m_axis->setMin(QVariant()); |
|
79 | 79 | m_axis->setRange(QVariant(), QVariant()); |
|
80 | 80 | m_axis->setShadesBorderColor(QColor()); |
|
81 | 81 | m_axis->setShadesBrush(QBrush()); |
|
82 | 82 | m_axis->setShadesColor(QColor()); |
|
83 | 83 | m_axis->setShadesPen(QPen()); |
|
84 | 84 | m_axis->setShadesVisible(false); |
|
85 | 85 | m_axis->setVisible(false); |
|
86 | 86 | //TODO QCOMPARE(m_axis->shadesBorderColor(), QColor()); |
|
87 | 87 | //TODO QCOMPARE(m_axis->shadesBrush(), QBrush()); |
|
88 | 88 | //TODO QCOMPARE(m_axis->shadesColor(), QColor()); |
|
89 | 89 | QCOMPARE(m_axis->shadesPen(), QPen()); |
|
90 | 90 | QCOMPARE(m_axis->shadesVisible(), false); |
|
91 | 91 | m_axis->show(); |
|
92 | 92 | m_axis->hide(); |
|
93 | 93 | } |
|
94 | 94 | |
|
95 | 95 | void tst_QAbstractAxis::axisPen_data() |
|
96 | 96 | { |
|
97 | 97 | QTest::addColumn<QPen>("axisPen"); |
|
98 | 98 | QTest::newRow("null") << QPen(); |
|
99 | 99 | QTest::newRow("blue") << QPen(Qt::blue); |
|
100 | 100 | QTest::newRow("black") << QPen(Qt::black); |
|
101 | 101 | QTest::newRow("red") << QPen(Qt::red); |
|
102 | 102 | } |
|
103 | 103 | |
|
104 | 104 | void tst_QAbstractAxis::axisPen() |
|
105 | 105 | { |
|
106 | 106 | QFETCH(QPen, axisPen); |
|
107 | 107 | |
|
108 | 108 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
109 | 109 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
110 | 110 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
111 | 111 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
112 | 112 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
113 | 113 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
114 | 114 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
115 | 115 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
116 | 116 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
117 | 117 | |
|
118 | 118 | m_axis->setAxisPen(axisPen); |
|
119 | 119 | QCOMPARE(m_axis->axisPen(), axisPen); |
|
120 | 120 | |
|
121 | 121 | QCOMPARE(spy0.count(), 0); |
|
122 | 122 | QCOMPARE(spy1.count(), 0); |
|
123 | 123 | QCOMPARE(spy2.count(), 0); |
|
124 | 124 | QCOMPARE(spy3.count(), 0); |
|
125 | 125 | QCOMPARE(spy4.count(), 0); |
|
126 | 126 | QCOMPARE(spy5.count(), 0); |
|
127 | 127 | QCOMPARE(spy6.count(), 0); |
|
128 | 128 | QCOMPARE(spy7.count(), 0); |
|
129 | 129 | QCOMPARE(spy8.count(), 0); |
|
130 | 130 | |
|
131 | 131 | m_chart->setAxisX(m_axis, m_series); |
|
132 | 132 | m_view->show(); |
|
133 | 133 | QTest::qWaitForWindowShown(m_view); |
|
134 | 134 | //TODO QCOMPARE(m_axis->axisPen(), axisPen); |
|
135 | 135 | } |
|
136 | 136 | |
|
137 | 137 | void tst_QAbstractAxis::axisPenColor_data() |
|
138 | 138 | { |
|
139 | 139 | } |
|
140 | 140 | |
|
141 | 141 | void tst_QAbstractAxis::axisPenColor() |
|
142 | 142 | { |
|
143 | 143 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); |
|
144 | 144 | } |
|
145 | 145 | |
|
146 | 146 | void tst_QAbstractAxis::gridLinePen_data() |
|
147 | 147 | { |
|
148 | 148 | |
|
149 | 149 | QTest::addColumn<QPen>("gridLinePen"); |
|
150 | 150 | QTest::newRow("null") << QPen(); |
|
151 | 151 | QTest::newRow("blue") << QPen(Qt::blue); |
|
152 | 152 | QTest::newRow("black") << QPen(Qt::black); |
|
153 | 153 | QTest::newRow("red") << QPen(Qt::red); |
|
154 | 154 | |
|
155 | 155 | } |
|
156 | 156 | |
|
157 | 157 | void tst_QAbstractAxis::gridLinePen() |
|
158 | 158 | { |
|
159 | 159 | QFETCH(QPen, gridLinePen); |
|
160 | 160 | |
|
161 | 161 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
162 | 162 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
163 | 163 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
164 | 164 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
165 | 165 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
166 | 166 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
167 | 167 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
168 | 168 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
169 | 169 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
170 | 170 | |
|
171 | 171 | m_axis->setGridLinePen(gridLinePen); |
|
172 | 172 | QCOMPARE(m_axis->gridLinePen(), gridLinePen); |
|
173 | 173 | |
|
174 | 174 | QCOMPARE(spy0.count(), 0); |
|
175 | 175 | QCOMPARE(spy1.count(), 0); |
|
176 | 176 | QCOMPARE(spy2.count(), 0); |
|
177 | 177 | QCOMPARE(spy3.count(), 0); |
|
178 | 178 | QCOMPARE(spy4.count(), 0); |
|
179 | 179 | QCOMPARE(spy5.count(), 0); |
|
180 | 180 | QCOMPARE(spy6.count(), 0); |
|
181 | 181 | QCOMPARE(spy7.count(), 0); |
|
182 | 182 | QCOMPARE(spy8.count(), 0); |
|
183 | 183 | |
|
184 | 184 | m_chart->setAxisX(m_axis, m_series); |
|
185 | 185 | m_view->show(); |
|
186 | 186 | QTest::qWaitForWindowShown(m_view); |
|
187 | 187 | //TODO QCOMPARE(m_axis->gridLinePen(), gridLinePen); |
|
188 | 188 | } |
|
189 | 189 | |
|
190 | 190 | void tst_QAbstractAxis::arrowVisible_data() |
|
191 | 191 | { |
|
192 | 192 | QTest::addColumn<bool>("arrowVisible"); |
|
193 | 193 | QTest::newRow("true") << true; |
|
194 | 194 | QTest::newRow("false") << false; |
|
195 | 195 | } |
|
196 | 196 | |
|
197 | 197 | void tst_QAbstractAxis::arrowVisible() |
|
198 | 198 | { |
|
199 | 199 | QFETCH(bool, arrowVisible); |
|
200 | 200 | |
|
201 | 201 | m_axis->setArrowVisible(!arrowVisible); |
|
202 | 202 | |
|
203 | 203 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
204 | 204 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
205 | 205 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
206 | 206 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
207 | 207 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
208 | 208 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
209 | 209 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
210 | 210 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
211 | 211 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
212 | 212 | |
|
213 | 213 | m_axis->setArrowVisible(arrowVisible); |
|
214 | 214 | QCOMPARE(m_axis->isArrowVisible(), arrowVisible); |
|
215 | 215 | |
|
216 | 216 | QCOMPARE(spy0.count(), 1); |
|
217 | 217 | QCOMPARE(spy1.count(), 0); |
|
218 | 218 | QCOMPARE(spy2.count(), 0); |
|
219 | 219 | QCOMPARE(spy3.count(), 0); |
|
220 | 220 | QCOMPARE(spy4.count(), 0); |
|
221 | 221 | QCOMPARE(spy5.count(), 0); |
|
222 | 222 | QCOMPARE(spy6.count(), 0); |
|
223 | 223 | QCOMPARE(spy7.count(), 0); |
|
224 | 224 | QCOMPARE(spy8.count(), 0); |
|
225 | 225 | |
|
226 | 226 | m_chart->setAxisX(m_axis, m_series); |
|
227 | 227 | m_view->show(); |
|
228 | 228 | QTest::qWaitForWindowShown(m_view); |
|
229 | 229 | QCOMPARE(m_axis->isArrowVisible(), arrowVisible); |
|
230 | 230 | } |
|
231 | 231 | |
|
232 | 232 | void tst_QAbstractAxis::gridLineVisible_data() |
|
233 | 233 | { |
|
234 | 234 | QTest::addColumn<bool>("gridLineVisible"); |
|
235 | 235 | QTest::newRow("true") << true; |
|
236 | 236 | QTest::newRow("false") << false; |
|
237 | 237 | } |
|
238 | 238 | |
|
239 | 239 | void tst_QAbstractAxis::gridLineVisible() |
|
240 | 240 | { |
|
241 | 241 | QFETCH(bool, gridLineVisible); |
|
242 | 242 | |
|
243 | 243 | m_axis->setGridLineVisible(!gridLineVisible); |
|
244 | 244 | |
|
245 | 245 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
246 | 246 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
247 | 247 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
248 | 248 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
249 | 249 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
250 | 250 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
251 | 251 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
252 | 252 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
253 | 253 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
254 | 254 | |
|
255 | 255 | m_axis->setGridLineVisible(gridLineVisible); |
|
256 | 256 | QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible); |
|
257 | 257 | |
|
258 | 258 | QCOMPARE(spy0.count(), 0); |
|
259 | 259 | QCOMPARE(spy1.count(), 0); |
|
260 | 260 | QCOMPARE(spy2.count(), 1); |
|
261 | 261 | QCOMPARE(spy3.count(), 0); |
|
262 | 262 | QCOMPARE(spy4.count(), 0); |
|
263 | 263 | QCOMPARE(spy5.count(), 0); |
|
264 | 264 | QCOMPARE(spy6.count(), 0); |
|
265 | 265 | QCOMPARE(spy7.count(), 0); |
|
266 | 266 | QCOMPARE(spy8.count(), 0); |
|
267 | 267 | |
|
268 | 268 | m_chart->setAxisX(m_axis, m_series); |
|
269 | 269 | m_view->show(); |
|
270 | 270 | QTest::qWaitForWindowShown(m_view); |
|
271 | 271 | QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible); |
|
272 | 272 | |
|
273 | 273 | } |
|
274 | 274 | |
|
275 | 275 | void tst_QAbstractAxis::visible_data() |
|
276 | 276 | { |
|
277 | 277 | QTest::addColumn<bool>("visible"); |
|
278 | 278 | QTest::newRow("true") << true; |
|
279 | 279 | QTest::newRow("false") << false; |
|
280 | 280 | } |
|
281 | 281 | |
|
282 | 282 | void tst_QAbstractAxis::visible() |
|
283 | 283 | { |
|
284 | 284 | QFETCH(bool, visible); |
|
285 | 285 | |
|
286 | 286 | m_axis->setVisible(!visible); |
|
287 | 287 | |
|
288 | 288 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
289 | 289 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
290 | 290 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
291 | 291 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
292 | 292 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
293 | 293 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
294 | 294 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
295 | 295 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
296 | 296 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
297 | 297 | |
|
298 | 298 | m_axis->setVisible(visible); |
|
299 | 299 | QCOMPARE(m_axis->isVisible(), visible); |
|
300 | 300 | |
|
301 | 301 | QCOMPARE(spy0.count(), 0); |
|
302 | 302 | QCOMPARE(spy1.count(), 0); |
|
303 | 303 | QCOMPARE(spy2.count(), 0); |
|
304 | 304 | QCOMPARE(spy3.count(), 0); |
|
305 | 305 | QCOMPARE(spy4.count(), 0); |
|
306 | 306 | QCOMPARE(spy5.count(), 0); |
|
307 | 307 | QCOMPARE(spy6.count(), 0); |
|
308 | 308 | QCOMPARE(spy7.count(), 0); |
|
309 | 309 | QCOMPARE(spy8.count(), 1); |
|
310 | 310 | |
|
311 | 311 | m_chart->setAxisX(m_axis, m_series); |
|
312 | 312 | m_view->show(); |
|
313 | 313 | QTest::qWaitForWindowShown(m_view); |
|
314 | 314 | QCOMPARE(m_axis->isVisible(), true); |
|
315 | 315 | } |
|
316 | 316 | |
|
317 | 317 | void tst_QAbstractAxis::labelsAngle_data() |
|
318 | 318 | { |
|
319 | 319 | QTest::addColumn<int>("labelsAngle"); |
|
320 | 320 | QTest::newRow("0") << 0; |
|
321 | 321 | QTest::newRow("45") << 45; |
|
322 | 322 | QTest::newRow("90") << 90; |
|
323 | 323 | } |
|
324 | 324 | |
|
325 | 325 | void tst_QAbstractAxis::labelsAngle() |
|
326 | 326 | { |
|
327 | 327 | QFETCH(int, labelsAngle); |
|
328 | 328 | |
|
329 | 329 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
330 | 330 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
331 | 331 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
332 | 332 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
333 | 333 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
334 | 334 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
335 | 335 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
336 | 336 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
337 | 337 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
338 | 338 | |
|
339 | 339 | m_axis->setLabelsAngle(labelsAngle); |
|
340 | 340 | QCOMPARE(m_axis->labelsAngle(), labelsAngle); |
|
341 | 341 | |
|
342 | 342 | QCOMPARE(spy0.count(), 0); |
|
343 | 343 | QCOMPARE(spy1.count(), 0); |
|
344 | 344 | QCOMPARE(spy2.count(), 0); |
|
345 | 345 | QCOMPARE(spy3.count(), 0); |
|
346 | 346 | QCOMPARE(spy4.count(), 0); |
|
347 | 347 | QCOMPARE(spy5.count(), 0); |
|
348 | 348 | QCOMPARE(spy6.count(), 0); |
|
349 | 349 | QCOMPARE(spy7.count(), 0); |
|
350 | 350 | QCOMPARE(spy8.count(), 0); |
|
351 | 351 | |
|
352 | 352 | m_chart->setAxisX(m_axis, m_series); |
|
353 | 353 | m_view->show(); |
|
354 | 354 | QTest::qWaitForWindowShown(m_view); |
|
355 | 355 | QCOMPARE(m_axis->labelsAngle(), labelsAngle); |
|
356 | 356 | } |
|
357 | 357 | |
|
358 | 358 | void tst_QAbstractAxis::labelsBrush_data() |
|
359 | 359 | { |
|
360 | 360 | QTest::addColumn<QBrush>("labelsBrush"); |
|
361 | 361 | QTest::newRow("null") << QBrush(); |
|
362 | 362 | QTest::newRow("blue") << QBrush(Qt::blue); |
|
363 | 363 | QTest::newRow("black") << QBrush(Qt::black); |
|
364 | 364 | |
|
365 | 365 | } |
|
366 | 366 | |
|
367 | 367 | void tst_QAbstractAxis::labelsBrush() |
|
368 | 368 | { |
|
369 | 369 | |
|
370 | 370 | QFETCH(QBrush, labelsBrush); |
|
371 | 371 | |
|
372 | 372 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
373 | 373 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
374 | 374 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
375 | 375 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
376 | 376 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
377 | 377 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
378 | 378 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
379 | 379 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
380 | 380 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
381 | 381 | |
|
382 | 382 | m_axis->setLabelsBrush(labelsBrush); |
|
383 | 383 | QCOMPARE(m_axis->labelsBrush(), labelsBrush); |
|
384 | 384 | |
|
385 | 385 | QCOMPARE(spy0.count(), 0); |
|
386 | 386 | QCOMPARE(spy1.count(), 0); |
|
387 | 387 | QCOMPARE(spy2.count(), 0); |
|
388 | 388 | QCOMPARE(spy3.count(), 0); |
|
389 | 389 | QCOMPARE(spy4.count(), 0); |
|
390 | 390 | QCOMPARE(spy5.count(), 0); |
|
391 | 391 | //TODO QCOMPARE(spy6.count(), 0); |
|
392 | 392 | QCOMPARE(spy7.count(), 0); |
|
393 | 393 | QCOMPARE(spy8.count(), 0); |
|
394 | 394 | |
|
395 | 395 | m_view->show(); |
|
396 | 396 | QTest::qWaitForWindowShown(m_view); |
|
397 | 397 | QCOMPARE(m_axis->labelsBrush(), labelsBrush); |
|
398 | 398 | |
|
399 | 399 | } |
|
400 | 400 | |
|
401 | 401 | void tst_QAbstractAxis::labelsColor_data() |
|
402 | 402 | { |
|
403 | 403 | |
|
404 | 404 | } |
|
405 | 405 | |
|
406 | 406 | void tst_QAbstractAxis::labelsColor() |
|
407 | 407 | { |
|
408 | 408 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); |
|
409 | 409 | } |
|
410 | 410 | |
|
411 | 411 | void tst_QAbstractAxis::labelsFont_data() |
|
412 | 412 | { |
|
413 | 413 | QTest::addColumn<QFont>("labelsFont"); |
|
414 | 414 | QTest::newRow("null") << QFont(); |
|
415 | 415 | QTest::newRow("serif") << QFont("SansSerif"); |
|
416 | 416 | } |
|
417 | 417 | |
|
418 | 418 | void tst_QAbstractAxis::labelsFont() |
|
419 | 419 | { |
|
420 | 420 | |
|
421 | 421 | QFETCH(QFont, labelsFont); |
|
422 | 422 | |
|
423 | 423 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
424 | 424 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
425 | 425 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
426 | 426 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
427 | 427 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
428 | 428 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
429 | 429 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
430 | 430 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
431 | 431 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
432 | 432 | |
|
433 | 433 | m_axis->setLabelsFont(labelsFont); |
|
434 | 434 | QCOMPARE(m_axis->labelsFont(), labelsFont); |
|
435 | 435 | |
|
436 | 436 | QCOMPARE(spy0.count(), 0); |
|
437 | 437 | QCOMPARE(spy1.count(), 0); |
|
438 | 438 | QCOMPARE(spy2.count(), 0); |
|
439 | 439 | QCOMPARE(spy3.count(), 0); |
|
440 | 440 | QCOMPARE(spy4.count(), 0); |
|
441 | 441 | QCOMPARE(spy5.count(), 0); |
|
442 | 442 | QCOMPARE(spy6.count(), 0); |
|
443 | 443 | QCOMPARE(spy7.count(), 0); |
|
444 | 444 | QCOMPARE(spy8.count(), 0); |
|
445 | 445 | |
|
446 | 446 | m_view->show(); |
|
447 | 447 | QTest::qWaitForWindowShown(m_view); |
|
448 | 448 | QCOMPARE(m_axis->labelsFont(), labelsFont); |
|
449 | 449 | |
|
450 | 450 | } |
|
451 | 451 | |
|
452 | 452 | void tst_QAbstractAxis::labelsPen_data() |
|
453 | 453 | { |
|
454 | 454 | QTest::addColumn<QPen>("labelsPen"); |
|
455 | 455 | QTest::newRow("null") << QPen(); |
|
456 | 456 | QTest::newRow("blue") << QPen(Qt::blue); |
|
457 | 457 | QTest::newRow("black") << QPen(Qt::black); |
|
458 | 458 | QTest::newRow("red") << QPen(Qt::red); |
|
459 | 459 | } |
|
460 | 460 | |
|
461 | 461 | void tst_QAbstractAxis::labelsPen() |
|
462 | 462 | { |
|
463 | 463 | QFETCH(QPen, labelsPen); |
|
464 | 464 | |
|
465 | 465 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
466 | 466 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
467 | 467 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
468 | 468 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
469 | 469 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
470 | 470 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
471 | 471 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
472 | 472 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
473 | 473 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
474 | 474 | |
|
475 | 475 | m_axis->setLabelsPen(labelsPen); |
|
476 | 476 | QCOMPARE(m_axis->labelsPen(), labelsPen); |
|
477 | 477 | |
|
478 | 478 | QCOMPARE(spy0.count(), 0); |
|
479 | 479 | QCOMPARE(spy1.count(), 0); |
|
480 | 480 | QCOMPARE(spy2.count(), 0); |
|
481 | 481 | QCOMPARE(spy3.count(), 0); |
|
482 | 482 | QCOMPARE(spy4.count(), 0); |
|
483 | 483 | QCOMPARE(spy5.count(), 0); |
|
484 | 484 | QCOMPARE(spy6.count(), 0); |
|
485 | 485 | QCOMPARE(spy7.count(), 0); |
|
486 | 486 | QCOMPARE(spy8.count(), 0); |
|
487 | 487 | |
|
488 | 488 | m_chart->setAxisX(m_axis, m_series); |
|
489 | 489 | m_view->show(); |
|
490 | 490 | QTest::qWaitForWindowShown(m_view); |
|
491 | 491 | //TODO QCOMPARE(m_axis->labelsPen(), labelsPen); |
|
492 | 492 | } |
|
493 | 493 | |
|
494 | 494 | void tst_QAbstractAxis::labelsVisible_data() |
|
495 | 495 | { |
|
496 | 496 | QTest::addColumn<bool>("labelsVisible"); |
|
497 | 497 | QTest::newRow("true") << true; |
|
498 | 498 | QTest::newRow("false") << false; |
|
499 | 499 | } |
|
500 | 500 | |
|
501 | 501 | void tst_QAbstractAxis::labelsVisible() |
|
502 | 502 | { |
|
503 | 503 | QFETCH(bool, labelsVisible); |
|
504 | 504 | |
|
505 | 505 | m_axis->setLabelsVisible(!labelsVisible); |
|
506 | 506 | |
|
507 | 507 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
508 | 508 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
509 | 509 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
510 | 510 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
511 | 511 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
512 | 512 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
513 | 513 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
514 | 514 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
515 | 515 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
516 | 516 | |
|
517 | 517 | m_axis->setLabelsVisible(labelsVisible); |
|
518 | 518 | QCOMPARE(m_axis->labelsVisible(), labelsVisible); |
|
519 | 519 | |
|
520 | 520 | QCOMPARE(spy0.count(), 0); |
|
521 | 521 | QCOMPARE(spy1.count(), 0); |
|
522 | 522 | QCOMPARE(spy2.count(), 0); |
|
523 | 523 | QCOMPARE(spy3.count(), 0); |
|
524 | 524 | QCOMPARE(spy4.count(), 1); |
|
525 | 525 | QCOMPARE(spy5.count(), 0); |
|
526 | 526 | QCOMPARE(spy6.count(), 0); |
|
527 | 527 | QCOMPARE(spy7.count(), 0); |
|
528 | 528 | QCOMPARE(spy8.count(), 0); |
|
529 | 529 | |
|
530 | 530 | m_chart->setAxisX(m_axis, m_series); |
|
531 | 531 | m_view->show(); |
|
532 | 532 | QTest::qWaitForWindowShown(m_view); |
|
533 | 533 | QCOMPARE(m_axis->labelsVisible(), labelsVisible); |
|
534 | 534 | } |
|
535 | 535 | |
|
536 | 536 | void tst_QAbstractAxis::orientation_data() |
|
537 | 537 | { |
|
538 | 538 | QTest::addColumn<Qt::Orientation>("orientation"); |
|
539 | 539 | QTest::newRow("Vertical") << Qt::Vertical; |
|
540 | 540 | QTest::newRow("Horizontal") << Qt::Horizontal; |
|
541 | 541 | } |
|
542 | 542 | |
|
543 | 543 | void tst_QAbstractAxis::orientation() |
|
544 | 544 | { |
|
545 | 545 | QFETCH(Qt::Orientation, orientation); |
|
546 | 546 | |
|
547 | 547 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
548 | 548 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
549 | 549 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
550 | 550 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
551 | 551 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
552 | 552 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
553 | 553 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
554 | 554 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
555 | 555 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
556 | 556 | |
|
557 | 557 | if(orientation==Qt::Vertical){ |
|
558 | 558 | m_chart->setAxisY(m_axis,m_series); |
|
559 | 559 | }else{ |
|
560 | 560 | m_chart->setAxisX(m_axis,m_series); |
|
561 | 561 | } |
|
562 | 562 | QCOMPARE(m_axis->orientation(), orientation); |
|
563 | 563 | |
|
564 | 564 | QCOMPARE(spy0.count(), 0); |
|
565 | 565 | QCOMPARE(spy1.count(), 0); |
|
566 | 566 | QCOMPARE(spy2.count(), 0); |
|
567 | 567 | QCOMPARE(spy3.count(), 0); |
|
568 | 568 | QCOMPARE(spy4.count(), 0); |
|
569 | 569 | QCOMPARE(spy5.count(), 0); |
|
570 | 570 | QCOMPARE(spy6.count(), 0); |
|
571 | 571 | QCOMPARE(spy7.count(), 0); |
|
572 | 572 | QCOMPARE(spy8.count(), 1); |
|
573 | 573 | |
|
574 | 574 | m_view->show(); |
|
575 | 575 | QTest::qWaitForWindowShown(m_view); |
|
576 | 576 | QCOMPARE(m_axis->orientation(), orientation); |
|
577 | 577 | } |
|
578 | 578 | |
|
579 | 579 | void tst_QAbstractAxis::setMax_data() |
|
580 | 580 | { |
|
581 | 581 | //just check if it does not crash |
|
582 | 582 | QTest::addColumn<QVariant>("max"); |
|
583 | 583 | QTest::newRow("something") << QVariant("something"); |
|
584 | 584 | QTest::newRow("1.0") << QVariant(1.0); |
|
585 | 585 | } |
|
586 | 586 | |
|
587 | 587 | void tst_QAbstractAxis::setMax() |
|
588 | 588 | { |
|
589 | 589 | QFETCH(QVariant, max); |
|
590 | 590 | m_axis->setMax(max); |
|
591 | 591 | } |
|
592 | 592 | |
|
593 | 593 | void tst_QAbstractAxis::setMin_data() |
|
594 | 594 | { |
|
595 | 595 | //just check if it does not crash |
|
596 | 596 | QTest::addColumn<QVariant>("min"); |
|
597 | 597 | QTest::newRow("something") << QVariant("something"); |
|
598 | 598 | QTest::newRow("1.0") << QVariant(1.0); |
|
599 | 599 | } |
|
600 | 600 | |
|
601 | 601 | // public void setMin(QVariant const& min) |
|
602 | 602 | void tst_QAbstractAxis::setMin() |
|
603 | 603 | { |
|
604 | 604 | QFETCH(QVariant, min); |
|
605 | 605 | m_axis->setMin(min); |
|
606 | 606 | } |
|
607 | 607 | |
|
608 | 608 | void tst_QAbstractAxis::setRange_data() |
|
609 | 609 | { |
|
610 | 610 | //just check if it does not crash |
|
611 | 611 | QTest::addColumn<QVariant>("min"); |
|
612 | 612 | QTest::addColumn<QVariant>("max"); |
|
613 | 613 | QTest::newRow("something") << QVariant("something0") << QVariant("something1"); |
|
614 | 614 | QTest::newRow("-1 1") << QVariant(-1.0) << QVariant(1.0); |
|
615 | 615 | } |
|
616 | 616 | |
|
617 | 617 | // public void setRange(QVariant const& min, QVariant const& max) |
|
618 | 618 | void tst_QAbstractAxis::setRange() |
|
619 | 619 | { |
|
620 | 620 | |
|
621 | 621 | QFETCH(QVariant, min); |
|
622 | 622 | QFETCH(QVariant, max); |
|
623 | 623 | m_axis->setRange(min,max); |
|
624 | 624 | } |
|
625 | 625 | |
|
626 | 626 | void tst_QAbstractAxis::shadesBorderColor_data() |
|
627 | 627 | { |
|
628 | 628 | |
|
629 | 629 | } |
|
630 | 630 | |
|
631 | 631 | void tst_QAbstractAxis::shadesBorderColor() |
|
632 | 632 | { |
|
633 | 633 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); |
|
634 | 634 | } |
|
635 | 635 | |
|
636 | 636 | void tst_QAbstractAxis::shadesBrush_data() |
|
637 | 637 | { |
|
638 | 638 | QTest::addColumn<QBrush>("shadesBrush"); |
|
639 | 639 | QTest::newRow("null") << QBrush(); |
|
640 | 640 | QTest::newRow("blue") << QBrush(Qt::blue); |
|
641 | 641 | QTest::newRow("black") << QBrush(Qt::black); |
|
642 | 642 | } |
|
643 | 643 | |
|
644 | 644 | void tst_QAbstractAxis::shadesBrush() |
|
645 | 645 | { |
|
646 | 646 | QFETCH(QBrush, shadesBrush); |
|
647 | 647 | |
|
648 | 648 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
649 | 649 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
650 | 650 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
651 | 651 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
652 | 652 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
653 | 653 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
654 | 654 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
655 | 655 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
656 | 656 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
657 | 657 | |
|
658 | 658 | m_axis->setShadesBrush(shadesBrush); |
|
659 | 659 | QCOMPARE(m_axis->shadesBrush(), shadesBrush); |
|
660 | 660 | |
|
661 | 661 | QCOMPARE(spy0.count(), 0); |
|
662 | 662 | QCOMPARE(spy1.count(), 0); |
|
663 | 663 | QCOMPARE(spy2.count(), 0); |
|
664 | 664 | QCOMPARE(spy3.count(), 0); |
|
665 | 665 | QCOMPARE(spy4.count(), 0); |
|
666 | 666 | QCOMPARE(spy5.count(), 0); |
|
667 | 667 | //TODO QCOMPARE(spy6.count(), 0); |
|
668 | 668 | QCOMPARE(spy7.count(), 0); |
|
669 | 669 | QCOMPARE(spy8.count(), 0); |
|
670 | 670 | |
|
671 | 671 | m_view->show(); |
|
672 | 672 | QTest::qWaitForWindowShown(m_view); |
|
673 | 673 | QCOMPARE(m_axis->shadesBrush(), shadesBrush); |
|
674 | 674 | } |
|
675 | 675 | |
|
676 | 676 | void tst_QAbstractAxis::shadesColor_data() |
|
677 | 677 | { |
|
678 | 678 | } |
|
679 | 679 | |
|
680 | 680 | // public QColor shadesColor() const |
|
681 | 681 | void tst_QAbstractAxis::shadesColor() |
|
682 | 682 | { |
|
683 | 683 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); |
|
684 | 684 | } |
|
685 | 685 | |
|
686 | 686 | void tst_QAbstractAxis::shadesPen_data() |
|
687 | 687 | { |
|
688 | 688 | QTest::addColumn<QPen>("shadesPen"); |
|
689 | 689 | QTest::newRow("null") << QPen(); |
|
690 | 690 | QTest::newRow("blue") << QPen(Qt::blue); |
|
691 | 691 | QTest::newRow("black") << QPen(Qt::black); |
|
692 | 692 | QTest::newRow("red") << QPen(Qt::red); |
|
693 | 693 | } |
|
694 | 694 | |
|
695 | 695 | void tst_QAbstractAxis::shadesPen() |
|
696 | 696 | { |
|
697 | 697 | QFETCH(QPen, shadesPen); |
|
698 | 698 | |
|
699 | 699 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
700 | 700 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
701 | 701 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
702 | 702 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
703 | 703 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
704 | 704 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
705 | 705 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
706 | 706 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
707 | 707 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
708 | 708 | |
|
709 | 709 | m_axis->setShadesPen(shadesPen); |
|
710 | 710 | QCOMPARE(m_axis->shadesPen(), shadesPen); |
|
711 | 711 | |
|
712 | 712 | QCOMPARE(spy0.count(), 0); |
|
713 | 713 | QCOMPARE(spy1.count(), 0); |
|
714 | 714 | QCOMPARE(spy2.count(), 0); |
|
715 | 715 | QCOMPARE(spy3.count(), 0); |
|
716 | 716 | QCOMPARE(spy4.count(), 0); |
|
717 | 717 | QCOMPARE(spy5.count(), 0); |
|
718 | 718 | QCOMPARE(spy6.count(), 0); |
|
719 | 719 | QCOMPARE(spy7.count(), 0); |
|
720 | 720 | QCOMPARE(spy8.count(), 0); |
|
721 | 721 | |
|
722 | 722 | m_chart->setAxisX(m_axis, m_series); |
|
723 | 723 | m_view->show(); |
|
724 | 724 | QTest::qWaitForWindowShown(m_view); |
|
725 | 725 | QCOMPARE(m_axis->shadesPen(), shadesPen); |
|
726 | 726 | } |
|
727 | 727 | |
|
728 | 728 | void tst_QAbstractAxis::shadesVisible_data() |
|
729 | 729 | { |
|
730 | 730 | QTest::addColumn<bool>("shadesVisible"); |
|
731 | 731 | QTest::newRow("true") << true; |
|
732 | 732 | QTest::newRow("false") << false; |
|
733 | 733 | } |
|
734 | 734 | |
|
735 | 735 | void tst_QAbstractAxis::shadesVisible() |
|
736 | 736 | { |
|
737 | 737 | QFETCH(bool, shadesVisible); |
|
738 | 738 | |
|
739 | 739 | m_axis->setShadesVisible(!shadesVisible); |
|
740 | 740 | |
|
741 | 741 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
742 | 742 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
743 | 743 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
744 | 744 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
745 | 745 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
746 | 746 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
747 | 747 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
748 | 748 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
749 | 749 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
750 | 750 | |
|
751 | 751 | m_axis->setShadesVisible(shadesVisible); |
|
752 | 752 | QCOMPARE(m_axis->shadesVisible(), shadesVisible); |
|
753 | 753 | |
|
754 | 754 | QCOMPARE(spy0.count(), 0); |
|
755 | 755 | QCOMPARE(spy1.count(), 0); |
|
756 | 756 | QCOMPARE(spy2.count(), 0); |
|
757 | 757 | QCOMPARE(spy3.count(), 0); |
|
758 | 758 | QCOMPARE(spy4.count(), 0); |
|
759 | 759 | QCOMPARE(spy5.count(), 0); |
|
760 | 760 | QCOMPARE(spy6.count(), 0); |
|
761 | 761 | QCOMPARE(spy7.count(), 1); |
|
762 | 762 | QCOMPARE(spy8.count(), 0); |
|
763 | 763 | |
|
764 | 764 | m_chart->setAxisX(m_axis, m_series); |
|
765 | 765 | m_view->show(); |
|
766 | 766 | QTest::qWaitForWindowShown(m_view); |
|
767 | 767 | QCOMPARE(m_axis->shadesVisible(), shadesVisible); |
|
768 | 768 | } |
|
769 | 769 | |
|
770 | 770 | void tst_QAbstractAxis::show_data() |
|
771 | 771 | { |
|
772 | 772 | |
|
773 | 773 | } |
|
774 | 774 | |
|
775 | 775 | void tst_QAbstractAxis::show() |
|
776 | 776 | { |
|
777 | 777 | m_axis->hide(); |
|
778 | 778 | QCOMPARE(m_axis->isVisible(), false); |
|
779 | 779 | |
|
780 | 780 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
781 | 781 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
782 | 782 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
783 | 783 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
784 | 784 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
785 | 785 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
786 | 786 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
787 | 787 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
788 | 788 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
789 | 789 | |
|
790 | 790 | m_axis->show(); |
|
791 | 791 | |
|
792 | 792 | QCOMPARE(spy0.count(), 0); |
|
793 | 793 | QCOMPARE(spy1.count(), 0); |
|
794 | 794 | QCOMPARE(spy2.count(), 0); |
|
795 | 795 | QCOMPARE(spy3.count(), 0); |
|
796 | 796 | QCOMPARE(spy4.count(), 0); |
|
797 | 797 | QCOMPARE(spy5.count(), 0); |
|
798 | 798 | QCOMPARE(spy6.count(), 0); |
|
799 | 799 | QCOMPARE(spy7.count(), 0); |
|
800 | 800 | QCOMPARE(spy8.count(), 1); |
|
801 | 801 | QCOMPARE(m_axis->isVisible(), true); |
|
802 | 802 | } |
|
803 | 803 | |
|
804 | 804 | void tst_QAbstractAxis::hide_data() |
|
805 | 805 | { |
|
806 | 806 | |
|
807 | 807 | } |
|
808 | 808 | |
|
809 | 809 | void tst_QAbstractAxis::hide() |
|
810 | 810 | { |
|
811 | 811 | m_axis->show(); |
|
812 | 812 | QCOMPARE(m_axis->isVisible(),true); |
|
813 | 813 | |
|
814 | 814 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
815 | 815 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
816 | 816 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
817 | 817 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
818 | 818 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
819 | 819 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
820 | 820 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
821 | 821 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
822 | 822 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
823 | 823 | |
|
824 | 824 | m_axis->hide(); |
|
825 | 825 | |
|
826 | 826 | QCOMPARE(spy0.count(), 0); |
|
827 | 827 | QCOMPARE(spy1.count(), 0); |
|
828 | 828 | QCOMPARE(spy2.count(), 0); |
|
829 | 829 | QCOMPARE(spy3.count(), 0); |
|
830 | 830 | QCOMPARE(spy4.count(), 0); |
|
831 | 831 | QCOMPARE(spy5.count(), 0); |
|
832 | 832 | QCOMPARE(spy6.count(), 0); |
|
833 | 833 | QCOMPARE(spy7.count(), 0); |
|
834 | 834 | QCOMPARE(spy8.count(), 1); |
|
835 | 835 | QCOMPARE(m_axis->isVisible(),false); |
|
836 | 836 | } |
|
837 | 837 | |
|
838 | 838 | |
|
839 | 839 | |
|
840 | 840 | |
|
841 | 841 | |
|
842 | 842 | |
|
843 | 843 | |
|
844 | 844 | |
|
845 | 845 | |
|
846 | 846 | |
|
847 | 847 | |
|
848 | 848 |
General Comments 0
You need to be logged in to leave comments.
Login now