@@ -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_qbarcategoriesaxis.cpp ../qabstractaxis/tst_qabstractaxis.cpp |
This diff has been collapsed as it changes many lines, (702 lines changed) Show them Hide them | |||
@@ -0,0 +1,702 | |||
|
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 <qbarseries.h> | |
|
23 | #include <qbarset.h> | |
|
24 | #include <qbarcategoriesaxis.h> | |
|
25 | ||
|
26 | class tst_QBarCategoriesAxis: public tst_QAbstractAxis | |
|
27 | { | |
|
28 | Q_OBJECT | |
|
29 | ||
|
30 | public slots: | |
|
31 | void initTestCase(); | |
|
32 | void cleanupTestCase(); | |
|
33 | void init(); | |
|
34 | void cleanup(); | |
|
35 | ||
|
36 | private slots: | |
|
37 | void qbarcategoriesaxis_data(); | |
|
38 | void qbarcategoriesaxis(); | |
|
39 | ||
|
40 | void append_data(); | |
|
41 | void append(); | |
|
42 | void at_data(); | |
|
43 | void at(); | |
|
44 | void categories_data(); | |
|
45 | void categories(); | |
|
46 | void clear_data(); | |
|
47 | void clear(); | |
|
48 | void count_data(); | |
|
49 | void count(); | |
|
50 | void insert_data(); | |
|
51 | void insert(); | |
|
52 | void max_data(); | |
|
53 | void max(); | |
|
54 | void min_data(); | |
|
55 | void min(); | |
|
56 | void remove_data(); | |
|
57 | void remove(); | |
|
58 | void setCategories_data(); | |
|
59 | void setCategories(); | |
|
60 | void setMax_data(); | |
|
61 | void setMax(); | |
|
62 | void setMin_data(); | |
|
63 | void setMin(); | |
|
64 | void setRange_data(); | |
|
65 | void setRange(); | |
|
66 | void type_data(); | |
|
67 | void type(); | |
|
68 | void categoriesChanged_data(); | |
|
69 | void categoriesChanged(); | |
|
70 | void maxChanged_data(); | |
|
71 | void maxChanged(); | |
|
72 | void minChanged_data(); | |
|
73 | void minChanged(); | |
|
74 | void rangeChanged_data(); | |
|
75 | void rangeChanged(); | |
|
76 | private: | |
|
77 | QBarCategoriesAxis* m_baraxis; | |
|
78 | QBarSeries* m_series; | |
|
79 | }; | |
|
80 | ||
|
81 | void tst_QBarCategoriesAxis::initTestCase() | |
|
82 | { | |
|
83 | } | |
|
84 | ||
|
85 | void tst_QBarCategoriesAxis::cleanupTestCase() | |
|
86 | { | |
|
87 | } | |
|
88 | ||
|
89 | void tst_QBarCategoriesAxis::init() | |
|
90 | { | |
|
91 | m_baraxis = new QBarCategoriesAxis(); | |
|
92 | m_series = new QBarSeries(); | |
|
93 | ||
|
94 | QBarSet *set0 = new QBarSet("Jane"); | |
|
95 | QBarSet *set1 = new QBarSet("John"); | |
|
96 | QBarSet *set2 = new QBarSet("Axel"); | |
|
97 | QBarSet *set3 = new QBarSet("Mary"); | |
|
98 | QBarSet *set4 = new QBarSet("Samantha"); | |
|
99 | ||
|
100 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; | |
|
101 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; | |
|
102 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; | |
|
103 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; | |
|
104 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; | |
|
105 | ||
|
106 | m_series->append(set0); | |
|
107 | m_series->append(set1); | |
|
108 | m_series->append(set2); | |
|
109 | m_series->append(set3); | |
|
110 | m_series->append(set4); | |
|
111 | ||
|
112 | QStringList categories; | |
|
113 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
|
114 | ||
|
115 | m_baraxis->append(categories); | |
|
116 | ||
|
117 | tst_QAbstractAxis::init(m_baraxis, m_series); | |
|
118 | m_chart->addSeries(m_series); | |
|
119 | m_chart->createDefaultAxes(); | |
|
120 | } | |
|
121 | ||
|
122 | void tst_QBarCategoriesAxis::cleanup() | |
|
123 | { | |
|
124 | delete m_series; | |
|
125 | delete m_baraxis; | |
|
126 | m_series = 0; | |
|
127 | m_baraxis = 0; | |
|
128 | tst_QAbstractAxis::cleanup(); | |
|
129 | } | |
|
130 | ||
|
131 | void tst_QBarCategoriesAxis::qbarcategoriesaxis_data() | |
|
132 | { | |
|
133 | } | |
|
134 | ||
|
135 | void tst_QBarCategoriesAxis::qbarcategoriesaxis() | |
|
136 | { | |
|
137 | qabstractaxis(); | |
|
138 | QBarCategoriesAxis axis; | |
|
139 | axis.append(QStringList()); | |
|
140 | axis.append(QString()); | |
|
141 | QCOMPARE(axis.at(0), QString()); | |
|
142 | QStringList test; | |
|
143 | test.append(QString()); | |
|
144 | QCOMPARE(axis.categories(),test); | |
|
145 | axis.clear(); | |
|
146 | QCOMPARE(axis.count(), 0); | |
|
147 | axis.insert(-1, QString()); | |
|
148 | QCOMPARE(axis.max(), QString()); | |
|
149 | QCOMPARE(axis.min(), QString()); | |
|
150 | axis.remove(QString()); | |
|
151 | axis.setCategories(QStringList()); | |
|
152 | axis.setMax(QString()); | |
|
153 | axis.setMin(QString()); | |
|
154 | axis.setRange(QString(), QString()); | |
|
155 | QCOMPARE(axis.type(), QAbstractAxis::AxisTypeCategories); | |
|
156 | } | |
|
157 | ||
|
158 | void tst_QBarCategoriesAxis::append_data() | |
|
159 | { | |
|
160 | QTest::addColumn<QStringList>("categories"); | |
|
161 | QTest::newRow("null") << QStringList(); | |
|
162 | } | |
|
163 | ||
|
164 | // public void append(QStringList const& categories) | |
|
165 | void tst_QBarCategoriesAxis::append() | |
|
166 | { | |
|
167 | #if 0 | |
|
168 | QFETCH(QStringList, categories); | |
|
169 | ||
|
170 | SubQBarCategoriesAxis axis; | |
|
171 | ||
|
172 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
173 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
174 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
175 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
176 | ||
|
177 | axis.append(categories); | |
|
178 | ||
|
179 | QCOMPARE(spy0.count(), 0); | |
|
180 | QCOMPARE(spy1.count(), 0); | |
|
181 | QCOMPARE(spy2.count(), 0); | |
|
182 | QCOMPARE(spy3.count(), 0); | |
|
183 | #endif | |
|
184 | QSKIP("Test is not implemented.", SkipAll); | |
|
185 | } | |
|
186 | ||
|
187 | void tst_QBarCategoriesAxis::at_data() | |
|
188 | { | |
|
189 | QTest::addColumn<int>("index"); | |
|
190 | QTest::addColumn<QString>("at"); | |
|
191 | QTest::newRow("null") << 0 << QString(); | |
|
192 | } | |
|
193 | ||
|
194 | // public QString at(int index) const | |
|
195 | void tst_QBarCategoriesAxis::at() | |
|
196 | { | |
|
197 | #if 0 | |
|
198 | QFETCH(int, index); | |
|
199 | QFETCH(QString, at); | |
|
200 | ||
|
201 | SubQBarCategoriesAxis axis; | |
|
202 | ||
|
203 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
204 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
205 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
206 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
207 | ||
|
208 | QCOMPARE(axis.at(index), at); | |
|
209 | ||
|
210 | QCOMPARE(spy0.count(), 0); | |
|
211 | QCOMPARE(spy1.count(), 0); | |
|
212 | QCOMPARE(spy2.count(), 0); | |
|
213 | QCOMPARE(spy3.count(), 0); | |
|
214 | #endif | |
|
215 | QSKIP("Test is not implemented.", SkipAll); | |
|
216 | } | |
|
217 | ||
|
218 | void tst_QBarCategoriesAxis::categories_data() | |
|
219 | { | |
|
220 | QTest::addColumn<QStringList>("categories"); | |
|
221 | QTest::newRow("null") << QStringList(); | |
|
222 | } | |
|
223 | ||
|
224 | // public QStringList categories() | |
|
225 | void tst_QBarCategoriesAxis::categories() | |
|
226 | { | |
|
227 | #if 0 | |
|
228 | QFETCH(QStringList, categories); | |
|
229 | ||
|
230 | SubQBarCategoriesAxis axis; | |
|
231 | ||
|
232 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
233 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
234 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
235 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
236 | ||
|
237 | QCOMPARE(axis.categories(), categories); | |
|
238 | ||
|
239 | QCOMPARE(spy0.count(), 0); | |
|
240 | QCOMPARE(spy1.count(), 0); | |
|
241 | QCOMPARE(spy2.count(), 0); | |
|
242 | QCOMPARE(spy3.count(), 0); | |
|
243 | #endif | |
|
244 | QSKIP("Test is not implemented.", SkipAll); | |
|
245 | } | |
|
246 | ||
|
247 | void tst_QBarCategoriesAxis::clear_data() | |
|
248 | { | |
|
249 | QTest::addColumn<int>("foo"); | |
|
250 | QTest::newRow("0") << 0; | |
|
251 | QTest::newRow("-1") << -1; | |
|
252 | } | |
|
253 | ||
|
254 | // public void clear() | |
|
255 | void tst_QBarCategoriesAxis::clear() | |
|
256 | { | |
|
257 | #if 0 | |
|
258 | QFETCH(int, foo); | |
|
259 | ||
|
260 | SubQBarCategoriesAxis axis; | |
|
261 | ||
|
262 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
263 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
264 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
265 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
266 | ||
|
267 | axis.clear(); | |
|
268 | ||
|
269 | QCOMPARE(spy0.count(), 0); | |
|
270 | QCOMPARE(spy1.count(), 0); | |
|
271 | QCOMPARE(spy2.count(), 0); | |
|
272 | QCOMPARE(spy3.count(), 0); | |
|
273 | #endif | |
|
274 | QSKIP("Test is not implemented.", SkipAll); | |
|
275 | } | |
|
276 | ||
|
277 | void tst_QBarCategoriesAxis::count_data() | |
|
278 | { | |
|
279 | QTest::addColumn<int>("count"); | |
|
280 | QTest::newRow("0") << 0; | |
|
281 | QTest::newRow("-1") << -1; | |
|
282 | } | |
|
283 | ||
|
284 | // public int count() const | |
|
285 | void tst_QBarCategoriesAxis::count() | |
|
286 | { | |
|
287 | #if 0 | |
|
288 | QFETCH(int, count); | |
|
289 | ||
|
290 | SubQBarCategoriesAxis axis; | |
|
291 | ||
|
292 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
293 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
294 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
295 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
296 | ||
|
297 | QCOMPARE(axis.count(), count); | |
|
298 | ||
|
299 | QCOMPARE(spy0.count(), 0); | |
|
300 | QCOMPARE(spy1.count(), 0); | |
|
301 | QCOMPARE(spy2.count(), 0); | |
|
302 | QCOMPARE(spy3.count(), 0); | |
|
303 | #endif | |
|
304 | QSKIP("Test is not implemented.", SkipAll); | |
|
305 | } | |
|
306 | ||
|
307 | void tst_QBarCategoriesAxis::insert_data() | |
|
308 | { | |
|
309 | QTest::addColumn<int>("index"); | |
|
310 | QTest::addColumn<QString>("category"); | |
|
311 | QTest::newRow("null") << 0 << QString(); | |
|
312 | } | |
|
313 | ||
|
314 | // public void insert(int index, QString const& category) | |
|
315 | void tst_QBarCategoriesAxis::insert() | |
|
316 | { | |
|
317 | #if 0 | |
|
318 | QFETCH(int, index); | |
|
319 | QFETCH(QString, category); | |
|
320 | ||
|
321 | SubQBarCategoriesAxis axis; | |
|
322 | ||
|
323 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
324 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
325 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
326 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
327 | ||
|
328 | axis.insert(index, category); | |
|
329 | ||
|
330 | QCOMPARE(spy0.count(), 0); | |
|
331 | QCOMPARE(spy1.count(), 0); | |
|
332 | QCOMPARE(spy2.count(), 0); | |
|
333 | QCOMPARE(spy3.count(), 0); | |
|
334 | #endif | |
|
335 | QSKIP("Test is not implemented.", SkipAll); | |
|
336 | } | |
|
337 | ||
|
338 | void tst_QBarCategoriesAxis::max_data() | |
|
339 | { | |
|
340 | QTest::addColumn<QString>("max"); | |
|
341 | QTest::newRow("null") << QString(); | |
|
342 | QTest::newRow("foo") << QString("foo"); | |
|
343 | } | |
|
344 | ||
|
345 | // public QString max() const | |
|
346 | void tst_QBarCategoriesAxis::max() | |
|
347 | { | |
|
348 | #if 0 | |
|
349 | QFETCH(QString, max); | |
|
350 | ||
|
351 | SubQBarCategoriesAxis axis; | |
|
352 | ||
|
353 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
354 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
355 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
356 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
357 | ||
|
358 | QCOMPARE(axis.max(), max); | |
|
359 | ||
|
360 | QCOMPARE(spy0.count(), 0); | |
|
361 | QCOMPARE(spy1.count(), 0); | |
|
362 | QCOMPARE(spy2.count(), 0); | |
|
363 | QCOMPARE(spy3.count(), 0); | |
|
364 | #endif | |
|
365 | QSKIP("Test is not implemented.", SkipAll); | |
|
366 | } | |
|
367 | ||
|
368 | void tst_QBarCategoriesAxis::min_data() | |
|
369 | { | |
|
370 | QTest::addColumn<QString>("min"); | |
|
371 | QTest::newRow("null") << QString(); | |
|
372 | QTest::newRow("foo") << QString("foo"); | |
|
373 | } | |
|
374 | ||
|
375 | // public QString min() const | |
|
376 | void tst_QBarCategoriesAxis::min() | |
|
377 | { | |
|
378 | #if 0 | |
|
379 | QFETCH(QString, min); | |
|
380 | ||
|
381 | SubQBarCategoriesAxis axis; | |
|
382 | ||
|
383 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
384 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
385 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
386 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
387 | ||
|
388 | QCOMPARE(axis.min(), min); | |
|
389 | ||
|
390 | QCOMPARE(spy0.count(), 0); | |
|
391 | QCOMPARE(spy1.count(), 0); | |
|
392 | QCOMPARE(spy2.count(), 0); | |
|
393 | QCOMPARE(spy3.count(), 0); | |
|
394 | #endif | |
|
395 | QSKIP("Test is not implemented.", SkipAll); | |
|
396 | } | |
|
397 | ||
|
398 | void tst_QBarCategoriesAxis::remove_data() | |
|
399 | { | |
|
400 | QTest::addColumn<QString>("category"); | |
|
401 | QTest::newRow("null") << QString(); | |
|
402 | QTest::newRow("foo") << QString("foo"); | |
|
403 | } | |
|
404 | ||
|
405 | // public void remove(QString const& category) | |
|
406 | void tst_QBarCategoriesAxis::remove() | |
|
407 | { | |
|
408 | #if 0 | |
|
409 | QFETCH(QString, category); | |
|
410 | ||
|
411 | SubQBarCategoriesAxis axis; | |
|
412 | ||
|
413 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
414 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
415 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
416 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
417 | ||
|
418 | axis.remove(category); | |
|
419 | ||
|
420 | QCOMPARE(spy0.count(), 0); | |
|
421 | QCOMPARE(spy1.count(), 0); | |
|
422 | QCOMPARE(spy2.count(), 0); | |
|
423 | QCOMPARE(spy3.count(), 0); | |
|
424 | #endif | |
|
425 | QSKIP("Test is not implemented.", SkipAll); | |
|
426 | } | |
|
427 | ||
|
428 | void tst_QBarCategoriesAxis::setCategories_data() | |
|
429 | { | |
|
430 | QTest::addColumn<QStringList>("categories"); | |
|
431 | QTest::newRow("null") << QStringList(); | |
|
432 | } | |
|
433 | ||
|
434 | // public void setCategories(QStringList const& categories) | |
|
435 | void tst_QBarCategoriesAxis::setCategories() | |
|
436 | { | |
|
437 | #if 0 | |
|
438 | QFETCH(QStringList, categories); | |
|
439 | ||
|
440 | SubQBarCategoriesAxis axis; | |
|
441 | ||
|
442 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
443 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
444 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
445 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
446 | ||
|
447 | axis.setCategories(categories); | |
|
448 | ||
|
449 | QCOMPARE(spy0.count(), 0); | |
|
450 | QCOMPARE(spy1.count(), 0); | |
|
451 | QCOMPARE(spy2.count(), 0); | |
|
452 | QCOMPARE(spy3.count(), 0); | |
|
453 | #endif | |
|
454 | QSKIP("Test is not implemented.", SkipAll); | |
|
455 | } | |
|
456 | ||
|
457 | void tst_QBarCategoriesAxis::setMax_data() | |
|
458 | { | |
|
459 | QTest::addColumn<QString>("maxCategory"); | |
|
460 | QTest::newRow("null") << QString(); | |
|
461 | QTest::newRow("foo") << QString("foo"); | |
|
462 | } | |
|
463 | ||
|
464 | // public void setMax(QString const& maxCategory) | |
|
465 | void tst_QBarCategoriesAxis::setMax() | |
|
466 | { | |
|
467 | #if 0 | |
|
468 | QFETCH(QString, maxCategory); | |
|
469 | ||
|
470 | SubQBarCategoriesAxis axis; | |
|
471 | ||
|
472 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
473 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
474 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
475 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
476 | ||
|
477 | axis.setMax(maxCategory); | |
|
478 | ||
|
479 | QCOMPARE(spy0.count(), 0); | |
|
480 | QCOMPARE(spy1.count(), 0); | |
|
481 | QCOMPARE(spy2.count(), 0); | |
|
482 | QCOMPARE(spy3.count(), 0); | |
|
483 | #endif | |
|
484 | QSKIP("Test is not implemented.", SkipAll); | |
|
485 | } | |
|
486 | ||
|
487 | void tst_QBarCategoriesAxis::setMin_data() | |
|
488 | { | |
|
489 | QTest::addColumn<QString>("minCategory"); | |
|
490 | QTest::newRow("null") << QString(); | |
|
491 | QTest::newRow("foo") << QString("foo"); | |
|
492 | } | |
|
493 | ||
|
494 | // public void setMin(QString const& minCategory) | |
|
495 | void tst_QBarCategoriesAxis::setMin() | |
|
496 | { | |
|
497 | #if 0 | |
|
498 | QFETCH(QString, minCategory); | |
|
499 | ||
|
500 | SubQBarCategoriesAxis axis; | |
|
501 | ||
|
502 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
503 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
504 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
505 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
506 | ||
|
507 | axis.setMin(minCategory); | |
|
508 | ||
|
509 | QCOMPARE(spy0.count(), 0); | |
|
510 | QCOMPARE(spy1.count(), 0); | |
|
511 | QCOMPARE(spy2.count(), 0); | |
|
512 | QCOMPARE(spy3.count(), 0); | |
|
513 | #endif | |
|
514 | QSKIP("Test is not implemented.", SkipAll); | |
|
515 | } | |
|
516 | ||
|
517 | void tst_QBarCategoriesAxis::setRange_data() | |
|
518 | { | |
|
519 | QTest::addColumn<QString>("minCategory"); | |
|
520 | QTest::addColumn<QString>("maxCategory"); | |
|
521 | QTest::newRow("null") << QString() << QString(); | |
|
522 | } | |
|
523 | ||
|
524 | // public void setRange(QString const& minCategory, QString const& maxCategory) | |
|
525 | void tst_QBarCategoriesAxis::setRange() | |
|
526 | { | |
|
527 | #if 0 | |
|
528 | QFETCH(QString, minCategory); | |
|
529 | QFETCH(QString, maxCategory); | |
|
530 | ||
|
531 | SubQBarCategoriesAxis axis; | |
|
532 | ||
|
533 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
534 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
535 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
536 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
537 | ||
|
538 | axis.setRange(minCategory, maxCategory); | |
|
539 | ||
|
540 | QCOMPARE(spy0.count(), 0); | |
|
541 | QCOMPARE(spy1.count(), 0); | |
|
542 | QCOMPARE(spy2.count(), 0); | |
|
543 | QCOMPARE(spy3.count(), 0); | |
|
544 | #endif | |
|
545 | QSKIP("Test is not implemented.", SkipAll); | |
|
546 | } | |
|
547 | ||
|
548 | void tst_QBarCategoriesAxis::type_data() | |
|
549 | { | |
|
550 | #if 0 | |
|
551 | QTest::addColumn<AxisType>("type"); | |
|
552 | QTest::newRow("null") << AxisType(); | |
|
553 | #endif | |
|
554 | } | |
|
555 | ||
|
556 | // public AxisType type() const | |
|
557 | void tst_QBarCategoriesAxis::type() | |
|
558 | { | |
|
559 | #if 0 | |
|
560 | QFETCH(AxisType, type); | |
|
561 | ||
|
562 | SubQBarCategoriesAxis axis; | |
|
563 | ||
|
564 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
565 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
566 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
567 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
568 | ||
|
569 | QCOMPARE(axis.type(), type); | |
|
570 | ||
|
571 | QCOMPARE(spy0.count(), 0); | |
|
572 | QCOMPARE(spy1.count(), 0); | |
|
573 | QCOMPARE(spy2.count(), 0); | |
|
574 | QCOMPARE(spy3.count(), 0); | |
|
575 | #endif | |
|
576 | QSKIP("Test is not implemented.", SkipAll); | |
|
577 | } | |
|
578 | ||
|
579 | void tst_QBarCategoriesAxis::categoriesChanged_data() | |
|
580 | { | |
|
581 | QTest::addColumn<int>("foo"); | |
|
582 | QTest::newRow("0") << 0; | |
|
583 | QTest::newRow("-1") << -1; | |
|
584 | } | |
|
585 | ||
|
586 | // protected void categoriesChanged() | |
|
587 | void tst_QBarCategoriesAxis::categoriesChanged() | |
|
588 | { | |
|
589 | #if 0 | |
|
590 | QFETCH(int, foo); | |
|
591 | ||
|
592 | SubQBarCategoriesAxis axis; | |
|
593 | ||
|
594 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
595 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
596 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
597 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
598 | ||
|
599 | axis.call_categoriesChanged(); | |
|
600 | ||
|
601 | QCOMPARE(spy0.count(), 0); | |
|
602 | QCOMPARE(spy1.count(), 0); | |
|
603 | QCOMPARE(spy2.count(), 0); | |
|
604 | QCOMPARE(spy3.count(), 0); | |
|
605 | #endif | |
|
606 | QSKIP("Test is not implemented.", SkipAll); | |
|
607 | } | |
|
608 | ||
|
609 | void tst_QBarCategoriesAxis::maxChanged_data() | |
|
610 | { | |
|
611 | QTest::addColumn<QString>("max"); | |
|
612 | QTest::newRow("null") << QString(); | |
|
613 | QTest::newRow("foo") << QString("foo"); | |
|
614 | } | |
|
615 | ||
|
616 | // protected void maxChanged(QString const& max) | |
|
617 | void tst_QBarCategoriesAxis::maxChanged() | |
|
618 | { | |
|
619 | #if 0 | |
|
620 | QFETCH(QString, max); | |
|
621 | ||
|
622 | SubQBarCategoriesAxis axis; | |
|
623 | ||
|
624 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
625 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
626 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
627 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
628 | ||
|
629 | axis.call_maxChanged(max); | |
|
630 | ||
|
631 | QCOMPARE(spy0.count(), 0); | |
|
632 | QCOMPARE(spy1.count(), 0); | |
|
633 | QCOMPARE(spy2.count(), 0); | |
|
634 | QCOMPARE(spy3.count(), 0); | |
|
635 | #endif | |
|
636 | QSKIP("Test is not implemented.", SkipAll); | |
|
637 | } | |
|
638 | ||
|
639 | void tst_QBarCategoriesAxis::minChanged_data() | |
|
640 | { | |
|
641 | QTest::addColumn<QString>("min"); | |
|
642 | QTest::newRow("null") << QString(); | |
|
643 | QTest::newRow("foo") << QString("foo"); | |
|
644 | } | |
|
645 | ||
|
646 | // protected void minChanged(QString const& min) | |
|
647 | void tst_QBarCategoriesAxis::minChanged() | |
|
648 | { | |
|
649 | #if 0 | |
|
650 | QFETCH(QString, min); | |
|
651 | ||
|
652 | SubQBarCategoriesAxis axis; | |
|
653 | ||
|
654 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
655 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
656 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
657 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
658 | ||
|
659 | axis.call_minChanged(min); | |
|
660 | ||
|
661 | QCOMPARE(spy0.count(), 0); | |
|
662 | QCOMPARE(spy1.count(), 0); | |
|
663 | QCOMPARE(spy2.count(), 0); | |
|
664 | QCOMPARE(spy3.count(), 0); | |
|
665 | #endif | |
|
666 | QSKIP("Test is not implemented.", SkipAll); | |
|
667 | } | |
|
668 | ||
|
669 | void tst_QBarCategoriesAxis::rangeChanged_data() | |
|
670 | { | |
|
671 | QTest::addColumn<QString>("min"); | |
|
672 | QTest::addColumn<QString>("max"); | |
|
673 | QTest::newRow("null") << QString() << QString(); | |
|
674 | } | |
|
675 | ||
|
676 | // protected void rangeChanged(QString const& min, QString const& max) | |
|
677 | void tst_QBarCategoriesAxis::rangeChanged() | |
|
678 | { | |
|
679 | #if 0 | |
|
680 | QFETCH(QString, min); | |
|
681 | QFETCH(QString, max); | |
|
682 | ||
|
683 | SubQBarCategoriesAxis axis; | |
|
684 | ||
|
685 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
|
686 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); | |
|
687 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); | |
|
688 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); | |
|
689 | ||
|
690 | axis.call_rangeChanged(min, max); | |
|
691 | ||
|
692 | QCOMPARE(spy0.count(), 0); | |
|
693 | QCOMPARE(spy1.count(), 0); | |
|
694 | QCOMPARE(spy2.count(), 0); | |
|
695 | QCOMPARE(spy3.count(), 0); | |
|
696 | #endif | |
|
697 | QSKIP("Test is not implemented.", SkipAll); | |
|
698 | } | |
|
699 | ||
|
700 | QTEST_MAIN(tst_QBarCategoriesAxis) | |
|
701 | #include "tst_qbarcategoriesaxis.moc" | |
|
702 |
@@ -40,12 +40,14 ChartCategoriesAxisX::~ChartCategoriesAxisX() | |||
|
40 | 40 | |
|
41 | 41 | QVector<qreal> ChartCategoriesAxisX::calculateLayout() const |
|
42 | 42 | { |
|
43 |
|
|
|
43 | int count = m_categoriesAxis->d_ptr->count(); | |
|
44 | ||
|
45 | Q_ASSERT(count>=1); | |
|
44 | 46 | |
|
45 | 47 | QVector<qreal> points; |
|
46 |
points.resize( |
|
|
48 | points.resize(count+2); | |
|
47 | 49 | |
|
48 |
const qreal delta = m_rect.width()/( |
|
|
50 | const qreal delta = m_rect.width()/(count); | |
|
49 | 51 | qreal offset =-m_min-0.5; |
|
50 | 52 | |
|
51 | 53 | if(offset<=0) { |
@@ -56,9 +58,9 QVector<qreal> ChartCategoriesAxisX::calculateLayout() const | |||
|
56 | 58 | } |
|
57 | 59 | |
|
58 | 60 | points[0] = m_rect.left(); |
|
59 |
points[ |
|
|
61 | points[count+1] = m_rect.right(); | |
|
60 | 62 | |
|
61 |
for (int i = 0; i < |
|
|
63 | for (int i = 0; i < count; ++i) { | |
|
62 | 64 | qreal x = offset + i * delta + m_rect.left(); |
|
63 | 65 | points[i+1] = x; |
|
64 | 66 | } |
@@ -103,7 +105,7 void ChartCategoriesAxisX::updateGeometry() | |||
|
103 | 105 | Q_ASSERT(labels.size() == ticksList.size()); |
|
104 | 106 | Q_ASSERT(layout.size() == ticksList.size()); |
|
105 | 107 | |
|
106 |
const qreal delta = m_rect.width()/(m_categoriesAxis-> |
|
|
108 | const qreal delta = m_rect.width()/(m_categoriesAxis->d_ptr->count()); | |
|
107 | 109 | |
|
108 | 110 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(axis.at(0)); |
|
109 | 111 | lineItem->setLine(m_rect.left(), m_rect.bottom(), m_rect.right(), m_rect.bottom()); |
@@ -149,7 +151,7 void ChartCategoriesAxisX::handleAxisUpdated() | |||
|
149 | 151 | if(m_categoriesAxis->categories()!=m_categories) |
|
150 | 152 | { |
|
151 | 153 | m_categories=m_categoriesAxis->categories(); |
|
152 |
if(ChartAxis::layout().count()==m_categories |
|
|
154 | if(ChartAxis::layout().count()==m_categoriesAxis->d_ptr->count()+2) updateGeometry(); | |
|
153 | 155 | } |
|
154 | 156 | ChartAxis::handleAxisUpdated(); |
|
155 | 157 | } |
@@ -38,12 +38,14 ChartCategoriesAxisY::~ChartCategoriesAxisY() | |||
|
38 | 38 | |
|
39 | 39 | QVector<qreal> ChartCategoriesAxisY::calculateLayout() const |
|
40 | 40 | { |
|
41 |
|
|
|
41 | int count = m_categoriesAxis->d_ptr->count(); | |
|
42 | ||
|
43 | Q_ASSERT(count>=1); | |
|
42 | 44 | |
|
43 | 45 | QVector<qreal> points; |
|
44 |
points.resize( |
|
|
46 | points.resize(count+2); | |
|
45 | 47 | |
|
46 |
const qreal delta = m_rect.height()/( |
|
|
48 | const qreal delta = m_rect.height()/(count); | |
|
47 | 49 | qreal offset = - m_min - 0.5; |
|
48 | 50 | |
|
49 | 51 | if(offset<=0) { |
@@ -54,9 +56,9 QVector<qreal> ChartCategoriesAxisY::calculateLayout() const | |||
|
54 | 56 | } |
|
55 | 57 | |
|
56 | 58 | points[0] = m_rect.bottom(); |
|
57 |
points[ |
|
|
59 | points[count+1] = m_rect.top(); | |
|
58 | 60 | |
|
59 |
for (int i = 0; i < |
|
|
61 | for (int i = 0; i < count; ++i) { | |
|
60 | 62 | int y = m_rect.bottom() - i * delta - offset; |
|
61 | 63 | points[i+1] = y; |
|
62 | 64 | } |
@@ -100,7 +102,7 void ChartCategoriesAxisY::updateGeometry() | |||
|
100 | 102 | Q_ASSERT(labels.size() == ticksList.size()); |
|
101 | 103 | Q_ASSERT(layout.size() == ticksList.size()); |
|
102 | 104 | |
|
103 |
const qreal delta = m_rect.height()/(m_categoriesAxis-> |
|
|
105 | const qreal delta = m_rect.height()/(m_categoriesAxis->d_ptr->count()); | |
|
104 | 106 | |
|
105 | 107 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(axis.at(0)); |
|
106 | 108 | lineItem->setLine(m_rect.left() , m_rect.top(), m_rect.left(), m_rect.bottom()); |
@@ -148,8 +150,7 void ChartCategoriesAxisY::handleAxisUpdated() | |||
|
148 | 150 | if(m_categoriesAxis->categories()!=m_categories) |
|
149 | 151 | { |
|
150 | 152 | m_categories=m_categoriesAxis->categories(); |
|
151 |
if(ChartAxis::layout().count()==m_categories |
|
|
152 | ||
|
153 | if(ChartAxis::layout().count()==m_categoriesAxis->d_ptr->count()+2) { | |
|
153 | 154 | updateGeometry(); |
|
154 | 155 | } |
|
155 | 156 | } |
@@ -55,7 +55,6 Q_SLOTS | |||
|
55 | 55 | void handleAxisUpdated(); |
|
56 | 56 | private: |
|
57 | 57 | QStringList m_categories; |
|
58 | QVector<int> m_labelIndex; | |
|
59 | 58 | QBarCategoriesAxis *m_categoriesAxis; |
|
60 | 59 | }; |
|
61 | 60 |
@@ -23,8 +23,8 | |||
|
23 | 23 | #include "chartcategoriesaxisx_p.h" |
|
24 | 24 | #include "chartcategoriesaxisy_p.h" |
|
25 | 25 | #include "domain_p.h" |
|
26 | #include "chartdataset_p.h" | |
|
26 | 27 | #include <qmath.h> |
|
27 | #include <QDebug> | |
|
28 | 28 | |
|
29 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 30 | /*! |
@@ -124,6 +124,10 QBarCategoriesAxis::QBarCategoriesAxis(QObject *parent): | |||
|
124 | 124 | */ |
|
125 | 125 | QBarCategoriesAxis::~QBarCategoriesAxis() |
|
126 | 126 | { |
|
127 | Q_D(QBarCategoriesAxis); | |
|
128 | if(d->m_dataset){ | |
|
129 | d->m_dataset->removeAxis(this); | |
|
130 | } | |
|
127 | 131 | } |
|
128 | 132 | |
|
129 | 133 | /*! |
@@ -176,7 +180,10 void QBarCategoriesAxis::remove(const QString &category) | |||
|
176 | 180 | Q_D(QBarCategoriesAxis); |
|
177 | 181 | if (d->m_categories.contains(category)) { |
|
178 | 182 | d->m_categories.removeAt(d->m_categories.indexOf(category)); |
|
179 |
|
|
|
183 | if(!d->m_categories.isEmpty()) | |
|
184 | setRange(d->m_categories.first(),d->m_categories.last()); | |
|
185 | else | |
|
186 | setRange(QString::null,QString::null); | |
|
180 | 187 | emit d->updated(); |
|
181 | 188 | emit categoriesChanged(); |
|
182 | 189 | } |
@@ -251,12 +258,7 QString QBarCategoriesAxis::at(int index) const | |||
|
251 | 258 | void QBarCategoriesAxis::setMin(const QString& min) |
|
252 | 259 | { |
|
253 | 260 | Q_D(QBarCategoriesAxis); |
|
254 | if (d->m_minCategory!=min && d->m_categories.contains(min)) { | |
|
255 | d->m_minCategory = min; | |
|
256 | d->emitUpdated(); | |
|
257 | emit minChanged(min); | |
|
258 | } | |
|
259 | ||
|
261 | setRange(min,d->m_maxCategory); | |
|
260 | 262 | } |
|
261 | 263 | |
|
262 | 264 | /*! |
@@ -274,12 +276,7 QString QBarCategoriesAxis::min() const | |||
|
274 | 276 | void QBarCategoriesAxis::setMax(const QString& max) |
|
275 | 277 | { |
|
276 | 278 | Q_D(QBarCategoriesAxis); |
|
277 | if (d->m_maxCategory!=max && d->m_categories.contains(max)) { | |
|
278 | d->m_maxCategory = max; | |
|
279 | d->emitUpdated(); | |
|
280 | emit maxChanged(max); | |
|
281 | } | |
|
282 | ||
|
279 | setRange(d->m_minCategory,max); | |
|
283 | 280 | } |
|
284 | 281 | |
|
285 | 282 | /*! |
@@ -296,8 +293,31 QString QBarCategoriesAxis::max() const | |||
|
296 | 293 | */ |
|
297 | 294 | void QBarCategoriesAxis::setRange(const QString& minCategory, const QString& maxCategory) |
|
298 | 295 | { |
|
299 | setMin(minCategory); | |
|
300 | setMax(maxCategory); | |
|
296 | Q_D(QBarCategoriesAxis); | |
|
297 | ||
|
298 | if(d->m_categories.indexOf(d->m_maxCategory)<d->m_categories.indexOf(d->m_minCategory)) return; | |
|
299 | ||
|
300 | bool changed = false; | |
|
301 | ||
|
302 | if (!minCategory.isEmpty() && d->m_minCategory!=minCategory && d->m_categories.contains(minCategory)) { | |
|
303 | d->m_minCategory = minCategory; | |
|
304 | d->m_min = d->m_categories.indexOf(d->m_minCategory) - 0.5; | |
|
305 | changed = true; | |
|
306 | emit minChanged(minCategory); | |
|
307 | } | |
|
308 | ||
|
309 | if (!maxCategory.isEmpty() && d->m_maxCategory!=maxCategory && d->m_categories.contains(maxCategory)) { | |
|
310 | d->m_maxCategory = maxCategory; | |
|
311 | d->m_max = d->m_categories.indexOf(d->m_maxCategory) + 0.5; | |
|
312 | changed = true; | |
|
313 | emit maxChanged(maxCategory); | |
|
314 | } | |
|
315 | ||
|
316 | if (changed) { | |
|
317 | d->m_count=d->m_max - d->m_min; | |
|
318 | emit rangeChanged(d->m_minCategory,d->m_maxCategory); | |
|
319 | d->emitUpdated(); | |
|
320 | } | |
|
301 | 321 | } |
|
302 | 322 | |
|
303 | 323 | /*! |
@@ -313,7 +333,8 QAbstractAxis::AxisType QBarCategoriesAxis::type() const | |||
|
313 | 333 | QBarCategoriesAxisPrivate::QBarCategoriesAxisPrivate(QBarCategoriesAxis* q): |
|
314 | 334 | QAbstractAxisPrivate(q), |
|
315 | 335 | m_min(0.0), |
|
316 | m_max(0.0) | |
|
336 | m_max(0.0), | |
|
337 | m_count(0) | |
|
317 | 338 | { |
|
318 | 339 | |
|
319 | 340 | } |
@@ -341,64 +362,43 void QBarCategoriesAxisPrivate::setRange(const QVariant &min, const QVariant &ma | |||
|
341 | 362 | q->setRange(value1,value2); |
|
342 | 363 | } |
|
343 | 364 | |
|
344 | qreal QBarCategoriesAxisPrivate::min() | |
|
345 | { | |
|
346 | //TODO:: cache it | |
|
347 | return m_min;//m_categories.indexOf(m_minCategory) - 0.5; | |
|
348 | } | |
|
349 | ||
|
350 | qreal QBarCategoriesAxisPrivate::max() | |
|
351 | { | |
|
352 | //TODO:: cache it | |
|
353 | return m_max;//m_categories.indexOf(m_maxCategory) + 0.5; | |
|
354 | } | |
|
355 | ||
|
356 | 365 | void QBarCategoriesAxisPrivate::handleDomainUpdated() |
|
357 | 366 | { |
|
367 | Q_Q(QBarCategoriesAxis); | |
|
358 | 368 | Domain* domain = qobject_cast<Domain*>(sender()); |
|
359 | 369 | |
|
360 | if(m_orientation==Qt::Horizontal){ | |
|
370 | if(m_orientation==Qt::Horizontal) { | |
|
361 | 371 | m_min = domain->minX(); |
|
362 | 372 | m_max = domain->maxX(); |
|
363 | }else if(m_orientation==Qt::Vertical){ | |
|
373 | } | |
|
374 | else if(m_orientation==Qt::Vertical) { | |
|
364 | 375 | m_min = domain->minY(); |
|
365 | 376 | m_max = domain->maxY(); |
|
366 | 377 | } |
|
367 | 378 | |
|
368 | // Q_Q(QBarCategoriesAxis); | |
|
369 | ||
|
370 | // TODO: causes crash in some situations. added to known issues | |
|
371 | /* | |
|
372 | int minIndex = qFloor(min); | |
|
373 | int maxIndex = qFloor(max); | |
|
379 | bool changed = false; | |
|
374 | 380 | |
|
375 | if (minIndex < 0) { | |
|
376 | minIndex = 0; | |
|
377 | } | |
|
378 | if (maxIndex > m_categories.count()-1){ | |
|
379 | maxIndex = m_categories.count()-1; | |
|
380 | if (maxIndex<0) { | |
|
381 | maxIndex = 0; | |
|
381 | int min = m_min + 0.5; | |
|
382 | if(min>=0 && min<m_categories.count()) { | |
|
383 | QString minCategory = m_categories.at(min); | |
|
384 | if(m_minCategory!=minCategory && !minCategory.isEmpty()) { | |
|
385 | m_minCategory=minCategory; | |
|
386 | changed=true; | |
|
387 | emit q->minChanged(minCategory); | |
|
382 | 388 | } |
|
383 | 389 | } |
|
384 | ||
|
385 | bool changed = false; | |
|
386 |
|
|
|
387 | m_minCategory = m_categories.at(minIndex); | |
|
388 | emit q->minChanged(m_minCategory); | |
|
389 | changed = true; | |
|
390 | } | |
|
391 | ||
|
392 | if (m_maxCategory != m_categories.at(maxIndex)) { | |
|
393 | m_maxCategory = m_categories.at(maxIndex); | |
|
394 | emit q->maxChanged(m_maxCategory); | |
|
395 | changed = true; | |
|
390 | int max = m_max - 0.5; | |
|
391 | if(max>=0 && max<m_categories.count()) { | |
|
392 | QString maxCategory = m_categories.at(max); | |
|
393 | if(m_maxCategory!=maxCategory && !maxCategory.isEmpty()) { | |
|
394 | m_maxCategory=maxCategory; | |
|
395 | emit q->maxChanged(maxCategory); | |
|
396 | } | |
|
396 | 397 | } |
|
397 | 398 | |
|
398 | 399 | if (changed) { |
|
399 |
emit q->rangeChanged(m_minCategory, |
|
|
400 | emit q->rangeChanged(m_minCategory,m_maxCategory); | |
|
400 | 401 | } |
|
401 | */ | |
|
402 | 402 | } |
|
403 | 403 | |
|
404 | 404 | ChartAxis* QBarCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) |
@@ -411,13 +411,6 ChartAxis* QBarCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) | |||
|
411 | 411 | } |
|
412 | 412 | } |
|
413 | 413 | |
|
414 | /* | |
|
415 | void QBarCategoriesAxisPrivate::emitRange() | |
|
416 | { | |
|
417 | emit changed(m_min -0.5, m_max +0.5, qCeil(m_max + 0.5) -qCeil(m_min - 0.5) +1, false); | |
|
418 | } | |
|
419 | */ | |
|
420 | ||
|
421 | 414 | void QBarCategoriesAxisPrivate::intializeDomain(Domain* domain) |
|
422 | 415 | { |
|
423 | 416 | Q_UNUSED(domain); |
@@ -69,6 +69,8 Q_SIGNALS: | |||
|
69 | 69 | private: |
|
70 | 70 | Q_DECLARE_PRIVATE(QBarCategoriesAxis) |
|
71 | 71 | Q_DISABLE_COPY(QBarCategoriesAxis) |
|
72 | friend class ChartCategoriesAxisX; | |
|
73 | friend class ChartCategoriesAxisY; | |
|
72 | 74 | }; |
|
73 | 75 | |
|
74 | 76 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -49,8 +49,9 public: | |||
|
49 | 49 | ChartAxis* createGraphics(ChartPresenter* presenter); |
|
50 | 50 | void intializeDomain(Domain* domain); |
|
51 | 51 | void handleDomainUpdated(); |
|
52 | qreal min(); | |
|
53 | qreal max(); | |
|
52 | qreal min() { return m_min;}; | |
|
53 | qreal max() { return m_max;}; | |
|
54 | int count() const { return m_count; }; | |
|
54 | 55 | |
|
55 | 56 | private: |
|
56 | 57 | //range handling |
@@ -64,9 +65,10 private: | |||
|
64 | 65 | QString m_maxCategory; |
|
65 | 66 | qreal m_min; |
|
66 | 67 | qreal m_max; |
|
68 | int m_count; | |
|
67 | 69 | |
|
68 | 70 | private: |
|
69 | Q_DECLARE_PUBLIC(QBarCategoriesAxis) | |
|
71 | Q_DECLARE_PUBLIC(QBarCategoriesAxis); | |
|
70 | 72 | }; |
|
71 | 73 | |
|
72 | 74 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -49,6 +49,7 class QDateTimeAxisPrivate : public QAbstractAxisPrivate | |||
|
49 | 49 | void handleDomainUpdated(); |
|
50 | 50 | qreal min(){ return m_min.toMSecsSinceEpoch(); } |
|
51 | 51 | qreal max(){ return m_max.toMSecsSinceEpoch(); } |
|
52 | int count() const { /*TODO:*/ return 0;}; | |
|
52 | 53 | |
|
53 | 54 | protected: |
|
54 | 55 | void setMin(const QVariant &min); |
@@ -190,8 +190,10 int QIntervalsAxisPrivate::ticksCount() const | |||
|
190 | 190 | void QIntervalsAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) |
|
191 | 191 | { |
|
192 | 192 | Q_UNUSED(count); |
|
193 | m_min = min; | |
|
194 | m_max = max; | |
|
193 | Q_UNUSED(min); | |
|
194 | Q_UNUSED(max); | |
|
195 | //m_min = min; | |
|
196 | //m_max = max; | |
|
195 | 197 | } |
|
196 | 198 | |
|
197 | 199 | ChartAxis* QIntervalsAxisPrivate::createGraphics(ChartPresenter* presenter) |
@@ -270,6 +270,7 d_ptr(&d) | |||
|
270 | 270 | |
|
271 | 271 | QAbstractAxis::~QAbstractAxis() |
|
272 | 272 | { |
|
273 | if(d_ptr->m_dataset) qFatal("Still binded axis detected !"); | |
|
273 | 274 | } |
|
274 | 275 | |
|
275 | 276 | /*! |
@@ -608,6 +609,7 Qt::Orientation QAbstractAxis::orientation() | |||
|
608 | 609 | QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q): |
|
609 | 610 | q_ptr(q), |
|
610 | 611 | m_orientation(Qt::Orientation(0)), |
|
612 | m_dataset(0), | |
|
611 | 613 | m_visible(false), |
|
612 | 614 | m_arrowVisible(true), |
|
613 | 615 | m_gridLineVisible(true), |
@@ -37,6 +37,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
37 | 37 | class ChartPresenter; |
|
38 | 38 | class ChartAxis; |
|
39 | 39 | class Domain; |
|
40 | class ChartDataSet; | |
|
40 | 41 | |
|
41 | 42 | class QTCOMMERCIALCHART_AUTOTEST_EXPORT QAbstractAxisPrivate : public QObject |
|
42 | 43 | { |
@@ -62,6 +63,8 public: | |||
|
62 | 63 | virtual void setMax(const QVariant &max) = 0; |
|
63 | 64 | virtual qreal max() = 0; |
|
64 | 65 | |
|
66 | virtual int count() const = 0; | |
|
67 | ||
|
65 | 68 | virtual void setRange(const QVariant &min, const QVariant &max) = 0; |
|
66 | 69 | |
|
67 | 70 | public Q_SLOTS: |
@@ -73,6 +76,7 Q_SIGNALS: | |||
|
73 | 76 | protected: |
|
74 | 77 | QAbstractAxis *q_ptr; |
|
75 | 78 | Qt::Orientation m_orientation; |
|
79 | ChartDataSet *m_dataset; | |
|
76 | 80 | |
|
77 | 81 | private: |
|
78 | 82 | bool m_visible; |
@@ -98,6 +102,7 private: | |||
|
98 | 102 | bool m_dirty; |
|
99 | 103 | |
|
100 | 104 | friend class QAbstractAxis; |
|
105 | friend class ChartDataSet; | |
|
101 | 106 | }; |
|
102 | 107 | |
|
103 | 108 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -23,8 +23,9 | |||
|
23 | 23 | #include "chartvaluesaxisx_p.h" |
|
24 | 24 | #include "chartvaluesaxisy_p.h" |
|
25 | 25 | #include "domain_p.h" |
|
26 |
#include |
|
|
27 |
#include < |
|
|
26 | #include "chartdataset_p.h" | |
|
27 | #include <qmath.h> | |
|
28 | ||
|
28 | 29 | |
|
29 | 30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 31 | /*! |
@@ -139,7 +140,10 QValuesAxis::QValuesAxis(QValuesAxisPrivate &d,QObject *parent) : QAbstractAxis( | |||
|
139 | 140 | */ |
|
140 | 141 | QValuesAxis::~QValuesAxis() |
|
141 | 142 | { |
|
142 | ||
|
143 | Q_D(QValuesAxis); | |
|
144 | if(d->m_dataset) { | |
|
145 | d->m_dataset->removeAxis(this); | |
|
146 | } | |
|
143 | 147 | } |
|
144 | 148 | |
|
145 | 149 | void QValuesAxis::setMin(qreal min) |
@@ -171,6 +175,8 qreal QValuesAxis::max() const | |||
|
171 | 175 | */ |
|
172 | 176 | void QValuesAxis::setRange(qreal min, qreal max) |
|
173 | 177 | { |
|
178 | if(max<min) return; | |
|
179 | ||
|
174 | 180 | Q_D(QValuesAxis); |
|
175 | 181 | bool changed = false; |
|
176 | 182 | |
@@ -332,8 +338,8 void QValuesAxisPrivate::looseNiceNumbers(qreal &min, qreal &max, int &ticksCoun | |||
|
332 | 338 | { |
|
333 | 339 | qreal range = niceNumber(max-min,true); //range with ceiling |
|
334 | 340 | qreal step = niceNumber(range/(ticksCount-1),false); |
|
335 |
min = |
|
|
336 |
max = |
|
|
341 | min = qFloor(min/step); | |
|
342 | max = qCeil(max/step); | |
|
337 | 343 | ticksCount = int(max-min) +1; |
|
338 | 344 | min*=step; |
|
339 | 345 | max*=step; |
@@ -343,7 +349,7 void QValuesAxisPrivate::looseNiceNumbers(qreal &min, qreal &max, int &ticksCoun | |||
|
343 | 349 | |
|
344 | 350 | qreal QValuesAxisPrivate::niceNumber(qreal x,bool ceiling) const |
|
345 | 351 | { |
|
346 |
qreal z = |
|
|
352 | qreal z = qPow(10,qFloor(log10(x))); //find corresponding number of the form of 10^n than is smaller than x | |
|
347 | 353 | qreal q = x/z;//q<10 && q>=1; |
|
348 | 354 | |
|
349 | 355 | if(ceiling) { |
@@ -48,18 +48,18 public: | |||
|
48 | 48 | void handleDomainUpdated(); |
|
49 | 49 | qreal min(){ return m_min; }; |
|
50 | 50 | qreal max(){ return m_max; }; |
|
51 | int count() const { return m_tickCount;} | |
|
51 | 52 | |
|
52 | 53 | protected: |
|
53 | 54 | void setMin(const QVariant &min); |
|
54 | 55 | void setMax(const QVariant &max); |
|
55 | 56 | void setRange(const QVariant &min, const QVariant &max); |
|
56 | int ticksCount() const; | |
|
57 | 57 | |
|
58 | 58 | private: |
|
59 | 59 | void looseNiceNumbers(qreal &min, qreal &max, int &ticksCount) const; |
|
60 | 60 | qreal niceNumber(qreal x,bool ceiling) const; |
|
61 | 61 | |
|
62 | protected: | |
|
62 | private: | |
|
63 | 63 | qreal m_min; |
|
64 | 64 | qreal m_max; |
|
65 | 65 | int m_tickCount; |
@@ -201,10 +201,7 QAbstractBarSeries::QAbstractBarSeries(QObject *parent) : | |||
|
201 | 201 | */ |
|
202 | 202 | QAbstractBarSeries::~QAbstractBarSeries() |
|
203 | 203 | { |
|
204 | Q_D(QAbstractBarSeries); | |
|
205 | if(d->m_dataset){ | |
|
206 | d->m_dataset->removeSeries(this); | |
|
207 | } | |
|
204 | ||
|
208 | 205 | } |
|
209 | 206 | |
|
210 | 207 | /*! |
@@ -73,6 +73,14 QAbstractSeries::SeriesType QBarSeries::type() const | |||
|
73 | 73 | return QAbstractSeries::SeriesTypeBar; |
|
74 | 74 | } |
|
75 | 75 | |
|
76 | QBarSeries::~QBarSeries() { | |
|
77 | ||
|
78 | Q_D(QBarSeries); | |
|
79 | if(d->m_dataset) { | |
|
80 | d->m_dataset->removeSeries(this); | |
|
81 | } | |
|
82 | ||
|
83 | } | |
|
76 | 84 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
77 | 85 | |
|
78 | 86 | QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : QAbstractBarSeriesPrivate(q) |
@@ -32,6 +32,7 class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractBarSeries | |||
|
32 | 32 | Q_OBJECT |
|
33 | 33 | public: |
|
34 | 34 | explicit QBarSeries(QObject *parent = 0); |
|
35 | ~QBarSeries(); | |
|
35 | 36 | QAbstractSeries::SeriesType type() const; |
|
36 | 37 | |
|
37 | 38 | private: |
@@ -202,6 +202,7 QAbstractAxis* ChartDataSet::createAxis(QAbstractAxis::AxisType type,Qt::Orienta | |||
|
202 | 202 | void ChartDataSet::initializeAxis(QAbstractAxis* axis,QAbstractSeries* series) |
|
203 | 203 | { |
|
204 | 204 | Domain* domain = m_seriesDomainMap.value(series); |
|
205 | axis->d_ptr->m_dataset = this; | |
|
205 | 206 | axis->d_ptr->intializeDomain(domain); |
|
206 | 207 | series->d_ptr->initializeAxis(axis); |
|
207 | 208 | if(axis->orientation()==Qt::Horizontal) { |
@@ -227,6 +228,7 void ChartDataSet::removeAxes(QAbstractSeries* series) | |||
|
227 | 228 | |
|
228 | 229 | if(x==-1) { |
|
229 | 230 | emit axisRemoved(axisX); |
|
231 | axisX->d_ptr->m_dataset=0; | |
|
230 | 232 | axisX->deleteLater(); |
|
231 | 233 | } |
|
232 | 234 | } |
@@ -240,11 +242,38 void ChartDataSet::removeAxes(QAbstractSeries* series) | |||
|
240 | 242 | |
|
241 | 243 | if(y==-1) { |
|
242 | 244 | emit axisRemoved(axisY); |
|
245 | axisY->d_ptr->m_dataset=0; | |
|
243 | 246 | axisY->deleteLater(); |
|
244 | 247 | } |
|
245 | 248 | } |
|
246 | 249 | } |
|
247 | 250 | |
|
251 | void ChartDataSet::removeAxis(QAbstractAxis* axis) | |
|
252 | { | |
|
253 | if(!axis->d_ptr->m_dataset) { | |
|
254 | qWarning()<<"UnBound axis found !"; | |
|
255 | return; | |
|
256 | } | |
|
257 | ||
|
258 | QMap<QAbstractSeries*, QAbstractAxis*> *seriesAxisMap; | |
|
259 | ||
|
260 | if(axis->orientation()==Qt::Vertical) { | |
|
261 | seriesAxisMap= &m_seriesAxisYMap; | |
|
262 | } | |
|
263 | else { | |
|
264 | seriesAxisMap= &m_seriesAxisXMap; | |
|
265 | } | |
|
266 | ||
|
267 | QMapIterator<QAbstractSeries*, QAbstractAxis*> i(*seriesAxisMap); | |
|
268 | ||
|
269 | while (i.hasNext()) { | |
|
270 | i.next(); | |
|
271 | if(i.value()==axis) { | |
|
272 | removeSeries(i.key()); | |
|
273 | } | |
|
274 | } | |
|
275 | } | |
|
276 | ||
|
248 | 277 | void ChartDataSet::removeAllSeries() |
|
249 | 278 | { |
|
250 | 279 | QList<QAbstractSeries*> series = m_seriesDomainMap.keys(); |
@@ -398,6 +427,7 void ChartDataSet::setAxis(QAbstractSeries *series, QAbstractAxis *axis, Qt::Ori | |||
|
398 | 427 | if(oldAxis) { |
|
399 | 428 | if(axes.indexOf(oldAxis)==-1) { |
|
400 | 429 | emit axisRemoved(oldAxis); |
|
430 | oldAxis->d_ptr->m_dataset=0; | |
|
401 | 431 | oldAxis->deleteLater(); |
|
402 | 432 | } |
|
403 | 433 | } |
@@ -66,6 +66,7 public: | |||
|
66 | 66 | QList<QAbstractSeries*> series() const; |
|
67 | 67 | Domain* domain(QAbstractSeries *series) const; |
|
68 | 68 | |
|
69 | void removeAxis(QAbstractAxis* axis); | |
|
69 | 70 | void createDefaultAxes(); |
|
70 | 71 | |
|
71 | 72 | Q_SIGNALS: |
General Comments 0
You need to be logged in to leave comments.
Login now