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