@@ -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 |
@@ -1,157 +1,159 | |||||
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 "chartcategoriesaxisx_p.h" |
|
21 | #include "chartcategoriesaxisx_p.h" | |
22 | #include "chartpresenter_p.h" |
|
22 | #include "chartpresenter_p.h" | |
23 | #include "qbarcategoriesaxis_p.h" |
|
23 | #include "qbarcategoriesaxis_p.h" | |
24 | #include <QDebug> |
|
24 | #include <QDebug> | |
25 | #include <qmath.h> |
|
25 | #include <qmath.h> | |
26 |
|
26 | |||
27 | static int label_padding = 5; |
|
27 | static int label_padding = 5; | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | ChartCategoriesAxisX::ChartCategoriesAxisX(QBarCategoriesAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter), |
|
31 | ChartCategoriesAxisX::ChartCategoriesAxisX(QBarCategoriesAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter), | |
32 | m_categoriesAxis(axis) |
|
32 | m_categoriesAxis(axis) | |
33 | { |
|
33 | { | |
34 |
|
34 | |||
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | ChartCategoriesAxisX::~ChartCategoriesAxisX() |
|
37 | ChartCategoriesAxisX::~ChartCategoriesAxisX() | |
38 | { |
|
38 | { | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | QVector<qreal> ChartCategoriesAxisX::calculateLayout() const |
|
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 | QVector<qreal> points; |
|
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 | qreal offset =-m_min-0.5; |
|
51 | qreal offset =-m_min-0.5; | |
50 |
|
52 | |||
51 | if(offset<=0) { |
|
53 | if(offset<=0) { | |
52 | offset = int(offset * m_rect.width()/(m_max - m_min))%int(delta) + delta; |
|
54 | offset = int(offset * m_rect.width()/(m_max - m_min))%int(delta) + delta; | |
53 | } |
|
55 | } | |
54 | else { |
|
56 | else { | |
55 | offset = int(offset * m_rect.width()/(m_max - m_min))%int(delta); |
|
57 | offset = int(offset * m_rect.width()/(m_max - m_min))%int(delta); | |
56 | } |
|
58 | } | |
57 |
|
59 | |||
58 | points[0] = m_rect.left(); |
|
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 | qreal x = offset + i * delta + m_rect.left(); |
|
64 | qreal x = offset + i * delta + m_rect.left(); | |
63 | points[i+1] = x; |
|
65 | points[i+1] = x; | |
64 | } |
|
66 | } | |
65 | return points; |
|
67 | return points; | |
66 | } |
|
68 | } | |
67 |
|
69 | |||
68 | QStringList ChartCategoriesAxisX::createCategoryLabels(const QVector<qreal>& layout) const |
|
70 | QStringList ChartCategoriesAxisX::createCategoryLabels(const QVector<qreal>& layout) const | |
69 | { |
|
71 | { | |
70 | QStringList result; |
|
72 | QStringList result; | |
71 | qreal d = (m_max - m_min)/m_rect.width(); |
|
73 | qreal d = (m_max - m_min)/m_rect.width(); | |
72 | for (int i = 0;i < layout.count()-1; ++i) { |
|
74 | for (int i = 0;i < layout.count()-1; ++i) { | |
73 | qreal x = qFloor((((layout[i+1] + layout[i])/2-m_rect.left())*d + m_min+0.5)); |
|
75 | qreal x = qFloor((((layout[i+1] + layout[i])/2-m_rect.left())*d + m_min+0.5)); | |
74 | if ((x < m_categoriesAxis->categories().count()) && (x >= 0)) { |
|
76 | if ((x < m_categoriesAxis->categories().count()) && (x >= 0)) { | |
75 | result << m_categoriesAxis->categories().at(x); |
|
77 | result << m_categoriesAxis->categories().at(x); | |
76 | } |
|
78 | } | |
77 | else { |
|
79 | else { | |
78 | // No label for x coordinate |
|
80 | // No label for x coordinate | |
79 | result << ""; |
|
81 | result << ""; | |
80 | } |
|
82 | } | |
81 | } |
|
83 | } | |
82 | result << ""; |
|
84 | result << ""; | |
83 | return result; |
|
85 | return result; | |
84 | } |
|
86 | } | |
85 |
|
87 | |||
86 |
|
88 | |||
87 | void ChartCategoriesAxisX::updateGeometry() |
|
89 | void ChartCategoriesAxisX::updateGeometry() | |
88 | { |
|
90 | { | |
89 | const QVector<qreal>& layout = ChartAxis::layout(); |
|
91 | const QVector<qreal>& layout = ChartAxis::layout(); | |
90 |
|
92 | |||
91 | m_minWidth = 0; |
|
93 | m_minWidth = 0; | |
92 | m_minHeight = 0; |
|
94 | m_minHeight = 0; | |
93 |
|
95 | |||
94 | if(layout.isEmpty()) return; |
|
96 | if(layout.isEmpty()) return; | |
95 |
|
97 | |||
96 | QStringList ticksList = createCategoryLabels(layout); |
|
98 | QStringList ticksList = createCategoryLabels(layout); | |
97 |
|
99 | |||
98 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
100 | QList<QGraphicsItem *> lines = m_grid->childItems(); | |
99 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
101 | QList<QGraphicsItem *> labels = m_labels->childItems(); | |
100 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
102 | QList<QGraphicsItem *> shades = m_shades->childItems(); | |
101 | QList<QGraphicsItem *> axis = m_axis->childItems(); |
|
103 | QList<QGraphicsItem *> axis = m_axis->childItems(); | |
102 |
|
104 | |||
103 | Q_ASSERT(labels.size() == ticksList.size()); |
|
105 | Q_ASSERT(labels.size() == ticksList.size()); | |
104 | Q_ASSERT(layout.size() == ticksList.size()); |
|
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 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(axis.at(0)); |
|
110 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(axis.at(0)); | |
109 | lineItem->setLine(m_rect.left(), m_rect.bottom(), m_rect.right(), m_rect.bottom()); |
|
111 | lineItem->setLine(m_rect.left(), m_rect.bottom(), m_rect.right(), m_rect.bottom()); | |
110 |
|
112 | |||
111 | qreal width = m_rect.left(); |
|
113 | qreal width = m_rect.left(); | |
112 | for (int i = 0; i < layout.size(); ++i) { |
|
114 | for (int i = 0; i < layout.size(); ++i) { | |
113 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i)); |
|
115 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i)); | |
114 | lineItem->setLine(layout[i], m_rect.top(), layout[i], m_rect.bottom()); |
|
116 | lineItem->setLine(layout[i], m_rect.top(), layout[i], m_rect.bottom()); | |
115 | QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i)); |
|
117 | QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i)); | |
116 | labelItem->setText(ticksList.at(i)); |
|
118 | labelItem->setText(ticksList.at(i)); | |
117 | const QRectF& rect = labelItem->boundingRect(); |
|
119 | const QRectF& rect = labelItem->boundingRect(); | |
118 | QPointF center = rect.center(); |
|
120 | QPointF center = rect.center(); | |
119 | labelItem->setTransformOriginPoint(center.x(), center.y()); |
|
121 | labelItem->setTransformOriginPoint(center.x(), center.y()); | |
120 |
|
122 | |||
121 | if(i==0){ |
|
123 | if(i==0){ | |
122 | labelItem->setPos(layout[i+1] - (delta)/2 - center.x(), m_rect.bottom() + label_padding); |
|
124 | labelItem->setPos(layout[i+1] - (delta)/2 - center.x(), m_rect.bottom() + label_padding); | |
123 | }else{ |
|
125 | }else{ | |
124 | labelItem->setPos(layout[i] + (delta)/2 - center.x(), m_rect.bottom() + label_padding); |
|
126 | labelItem->setPos(layout[i] + (delta)/2 - center.x(), m_rect.bottom() + label_padding); | |
125 | } |
|
127 | } | |
126 |
|
128 | |||
127 | if(labelItem->pos().x()<=width || labelItem->pos().x()+ rect.width()>m_rect.right()) { |
|
129 | if(labelItem->pos().x()<=width || labelItem->pos().x()+ rect.width()>m_rect.right()) { | |
128 | labelItem->setVisible(false); |
|
130 | labelItem->setVisible(false); | |
129 | } |
|
131 | } | |
130 | else { |
|
132 | else { | |
131 | labelItem->setVisible(true); |
|
133 | labelItem->setVisible(true); | |
132 | width=rect.width()+labelItem->pos().x(); |
|
134 | width=rect.width()+labelItem->pos().x(); | |
133 | } |
|
135 | } | |
134 |
|
136 | |||
135 | m_minWidth+=rect.width(); |
|
137 | m_minWidth+=rect.width(); | |
136 | m_minHeight=qMax(rect.height()+label_padding,m_minHeight); |
|
138 | m_minHeight=qMax(rect.height()+label_padding,m_minHeight); | |
137 |
|
139 | |||
138 | if ((i+1)%2 && i>1) { |
|
140 | if ((i+1)%2 && i>1) { | |
139 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2-1)); |
|
141 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2-1)); | |
140 | rectItem->setRect(layout[i-1],m_rect.top(),layout[i]-layout[i-1],m_rect.height()); |
|
142 | rectItem->setRect(layout[i-1],m_rect.top(),layout[i]-layout[i-1],m_rect.height()); | |
141 | } |
|
143 | } | |
142 | lineItem = static_cast<QGraphicsLineItem*>(axis.at(i+1)); |
|
144 | lineItem = static_cast<QGraphicsLineItem*>(axis.at(i+1)); | |
143 | lineItem->setLine(layout[i],m_rect.bottom(),layout[i],m_rect.bottom()+5); |
|
145 | lineItem->setLine(layout[i],m_rect.bottom(),layout[i],m_rect.bottom()+5); | |
144 | } |
|
146 | } | |
145 | } |
|
147 | } | |
146 |
|
148 | |||
147 | void ChartCategoriesAxisX::handleAxisUpdated() |
|
149 | void ChartCategoriesAxisX::handleAxisUpdated() | |
148 | { |
|
150 | { | |
149 | if(m_categoriesAxis->categories()!=m_categories) |
|
151 | if(m_categoriesAxis->categories()!=m_categories) | |
150 | { |
|
152 | { | |
151 | m_categories=m_categoriesAxis->categories(); |
|
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 | ChartAxis::handleAxisUpdated(); |
|
156 | ChartAxis::handleAxisUpdated(); | |
155 | } |
|
157 | } | |
156 |
|
158 | |||
157 | QTCOMMERCIALCHART_END_NAMESPACE |
|
159 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,159 +1,160 | |||||
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 "chartcategoriesaxisy_p.h" |
|
21 | #include "chartcategoriesaxisy_p.h" | |
22 | #include "chartpresenter_p.h" |
|
22 | #include "chartpresenter_p.h" | |
23 | #include "qbarcategoriesaxis_p.h" |
|
23 | #include "qbarcategoriesaxis_p.h" | |
24 | #include <qmath.h> |
|
24 | #include <qmath.h> | |
25 |
|
25 | |||
26 | static int label_padding = 5; |
|
26 | static int label_padding = 5; | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | ChartCategoriesAxisY::ChartCategoriesAxisY(QBarCategoriesAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter), |
|
30 | ChartCategoriesAxisY::ChartCategoriesAxisY(QBarCategoriesAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter), | |
31 | m_categoriesAxis(axis) |
|
31 | m_categoriesAxis(axis) | |
32 | { |
|
32 | { | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | ChartCategoriesAxisY::~ChartCategoriesAxisY() |
|
35 | ChartCategoriesAxisY::~ChartCategoriesAxisY() | |
36 | { |
|
36 | { | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | QVector<qreal> ChartCategoriesAxisY::calculateLayout() const |
|
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 | QVector<qreal> points; |
|
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 | qreal offset = - m_min - 0.5; |
|
49 | qreal offset = - m_min - 0.5; | |
48 |
|
50 | |||
49 | if(offset<=0) { |
|
51 | if(offset<=0) { | |
50 | offset = int(offset * m_rect.height()/(m_max - m_min))%int(delta) + delta; |
|
52 | offset = int(offset * m_rect.height()/(m_max - m_min))%int(delta) + delta; | |
51 | } |
|
53 | } | |
52 | else { |
|
54 | else { | |
53 | offset = int(offset * m_rect.height()/(m_max - m_min))%int(delta); |
|
55 | offset = int(offset * m_rect.height()/(m_max - m_min))%int(delta); | |
54 | } |
|
56 | } | |
55 |
|
57 | |||
56 | points[0] = m_rect.bottom(); |
|
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 | int y = m_rect.bottom() - i * delta - offset; |
|
62 | int y = m_rect.bottom() - i * delta - offset; | |
61 | points[i+1] = y; |
|
63 | points[i+1] = y; | |
62 | } |
|
64 | } | |
63 | return points; |
|
65 | return points; | |
64 | } |
|
66 | } | |
65 |
|
67 | |||
66 | QStringList ChartCategoriesAxisY::createCategoryLabels(const QVector<qreal>& layout) const |
|
68 | QStringList ChartCategoriesAxisY::createCategoryLabels(const QVector<qreal>& layout) const | |
67 | { |
|
69 | { | |
68 | QStringList result; |
|
70 | QStringList result; | |
69 | qreal d = (m_max - m_min)/m_rect.height(); |
|
71 | qreal d = (m_max - m_min)/m_rect.height(); | |
70 | for (int i = 0;i < layout.count()-1; ++i) { |
|
72 | for (int i = 0;i < layout.count()-1; ++i) { | |
71 | qreal x = qFloor(((m_rect.height()- (layout[i+1] + layout[i])/2 + m_rect.top())*d + m_min+0.5)); |
|
73 | qreal x = qFloor(((m_rect.height()- (layout[i+1] + layout[i])/2 + m_rect.top())*d + m_min+0.5)); | |
72 | if ((x < m_categoriesAxis->categories().count()) && (x >= 0)) { |
|
74 | if ((x < m_categoriesAxis->categories().count()) && (x >= 0)) { | |
73 | result << m_categoriesAxis->categories().at(x); |
|
75 | result << m_categoriesAxis->categories().at(x); | |
74 | } |
|
76 | } | |
75 | else { |
|
77 | else { | |
76 | // No label for x coordinate |
|
78 | // No label for x coordinate | |
77 | result << ""; |
|
79 | result << ""; | |
78 | } |
|
80 | } | |
79 | } |
|
81 | } | |
80 | result << ""; |
|
82 | result << ""; | |
81 | return result; |
|
83 | return result; | |
82 | } |
|
84 | } | |
83 |
|
85 | |||
84 | void ChartCategoriesAxisY::updateGeometry() |
|
86 | void ChartCategoriesAxisY::updateGeometry() | |
85 | { |
|
87 | { | |
86 | const QVector<qreal>& layout = ChartAxis::layout(); |
|
88 | const QVector<qreal>& layout = ChartAxis::layout(); | |
87 |
|
89 | |||
88 | m_minWidth = 0; |
|
90 | m_minWidth = 0; | |
89 | m_minHeight = 0; |
|
91 | m_minHeight = 0; | |
90 |
|
92 | |||
91 | if(layout.isEmpty()) return; |
|
93 | if(layout.isEmpty()) return; | |
92 |
|
94 | |||
93 | QStringList ticksList = createCategoryLabels(layout); |
|
95 | QStringList ticksList = createCategoryLabels(layout); | |
94 |
|
96 | |||
95 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
97 | QList<QGraphicsItem *> lines = m_grid->childItems(); | |
96 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
98 | QList<QGraphicsItem *> labels = m_labels->childItems(); | |
97 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
99 | QList<QGraphicsItem *> shades = m_shades->childItems(); | |
98 | QList<QGraphicsItem *> axis = m_axis->childItems(); |
|
100 | QList<QGraphicsItem *> axis = m_axis->childItems(); | |
99 |
|
101 | |||
100 | Q_ASSERT(labels.size() == ticksList.size()); |
|
102 | Q_ASSERT(labels.size() == ticksList.size()); | |
101 | Q_ASSERT(layout.size() == ticksList.size()); |
|
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 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(axis.at(0)); |
|
107 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(axis.at(0)); | |
106 | lineItem->setLine(m_rect.left() , m_rect.top(), m_rect.left(), m_rect.bottom()); |
|
108 | lineItem->setLine(m_rect.left() , m_rect.top(), m_rect.left(), m_rect.bottom()); | |
107 |
|
109 | |||
108 | qreal height = m_rect.bottom(); |
|
110 | qreal height = m_rect.bottom(); | |
109 | for (int i = 0; i < layout.size(); ++i) { |
|
111 | for (int i = 0; i < layout.size(); ++i) { | |
110 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i)); |
|
112 | QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i)); | |
111 | lineItem->setLine(m_rect.left() , layout[i], m_rect.right(), layout[i]); |
|
113 | lineItem->setLine(m_rect.left() , layout[i], m_rect.right(), layout[i]); | |
112 | QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i)); |
|
114 | QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i)); | |
113 | labelItem->setText(ticksList.at(i)); |
|
115 | labelItem->setText(ticksList.at(i)); | |
114 | const QRectF& rect = labelItem->boundingRect(); |
|
116 | const QRectF& rect = labelItem->boundingRect(); | |
115 | QPointF center = rect.center(); |
|
117 | QPointF center = rect.center(); | |
116 | labelItem->setTransformOriginPoint(center.x(), center.y()); |
|
118 | labelItem->setTransformOriginPoint(center.x(), center.y()); | |
117 |
|
119 | |||
118 | if(i==0) { |
|
120 | if(i==0) { | |
119 | labelItem->setPos(m_rect.left() - rect.width() - label_padding ,layout[i+1] + (delta)/2 - center.y()); |
|
121 | labelItem->setPos(m_rect.left() - rect.width() - label_padding ,layout[i+1] + (delta)/2 - center.y()); | |
120 | } |
|
122 | } | |
121 | else { |
|
123 | else { | |
122 | labelItem->setPos(m_rect.left() - rect.width() - label_padding ,layout[i] - (delta)/2 - center.y()); |
|
124 | labelItem->setPos(m_rect.left() - rect.width() - label_padding ,layout[i] - (delta)/2 - center.y()); | |
123 | } |
|
125 | } | |
124 |
|
126 | |||
125 | if(labelItem->pos().y()+rect.height()>= height || labelItem->pos().y() < m_rect.top()) { |
|
127 | if(labelItem->pos().y()+rect.height()>= height || labelItem->pos().y() < m_rect.top()) { | |
126 | labelItem->setVisible(false); |
|
128 | labelItem->setVisible(false); | |
127 | } |
|
129 | } | |
128 | else { |
|
130 | else { | |
129 | labelItem->setVisible(true); |
|
131 | labelItem->setVisible(true); | |
130 | height=labelItem->pos().y(); |
|
132 | height=labelItem->pos().y(); | |
131 | } |
|
133 | } | |
132 |
|
134 | |||
133 | m_minWidth+=rect.width(); |
|
135 | m_minWidth+=rect.width(); | |
134 | m_minHeight=qMax(rect.height()+label_padding,m_minHeight); |
|
136 | m_minHeight=qMax(rect.height()+label_padding,m_minHeight); | |
135 |
|
137 | |||
136 | if ((i+1)%2 && i>1) { |
|
138 | if ((i+1)%2 && i>1) { | |
137 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2-1)); |
|
139 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2-1)); | |
138 | rectItem->setRect(m_rect.left(),layout[i],m_rect.width(),layout[i-1]-layout[i]); |
|
140 | rectItem->setRect(m_rect.left(),layout[i],m_rect.width(),layout[i-1]-layout[i]); | |
139 | } |
|
141 | } | |
140 | lineItem = static_cast<QGraphicsLineItem*>(axis.at(i+1)); |
|
142 | lineItem = static_cast<QGraphicsLineItem*>(axis.at(i+1)); | |
141 | lineItem->setLine(m_rect.left()-5,layout[i],m_rect.left(),layout[i]); |
|
143 | lineItem->setLine(m_rect.left()-5,layout[i],m_rect.left(),layout[i]); | |
142 | } |
|
144 | } | |
143 | } |
|
145 | } | |
144 |
|
146 | |||
145 | void ChartCategoriesAxisY::handleAxisUpdated() |
|
147 | void ChartCategoriesAxisY::handleAxisUpdated() | |
146 | { |
|
148 | { | |
147 |
|
149 | |||
148 | if(m_categoriesAxis->categories()!=m_categories) |
|
150 | if(m_categoriesAxis->categories()!=m_categories) | |
149 | { |
|
151 | { | |
150 | m_categories=m_categoriesAxis->categories(); |
|
152 | m_categories=m_categoriesAxis->categories(); | |
151 |
if(ChartAxis::layout().count()==m_categories |
|
153 | if(ChartAxis::layout().count()==m_categoriesAxis->d_ptr->count()+2) { | |
152 |
|
||||
153 | updateGeometry(); |
|
154 | updateGeometry(); | |
154 | } |
|
155 | } | |
155 | } |
|
156 | } | |
156 | ChartAxis::handleAxisUpdated(); |
|
157 | ChartAxis::handleAxisUpdated(); | |
157 | } |
|
158 | } | |
158 |
|
159 | |||
159 | QTCOMMERCIALCHART_END_NAMESPACE |
|
160 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,64 +1,63 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef CHARTCATEGORIESAXISY_H |
|
30 | #ifndef CHARTCATEGORIESAXISY_H | |
31 | #define CHARTCATEGORIESAXISY_H |
|
31 | #define CHARTCATEGORIESAXISY_H | |
32 |
|
32 | |||
33 | #include "chartaxis_p.h" |
|
33 | #include "chartaxis_p.h" | |
34 |
|
34 | |||
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QAbstractAxis; |
|
37 | class QAbstractAxis; | |
38 | class QBarCategoriesAxis; |
|
38 | class QBarCategoriesAxis; | |
39 | class ChartPresenter; |
|
39 | class ChartPresenter; | |
40 |
|
40 | |||
41 | class ChartCategoriesAxisY : public ChartAxis |
|
41 | class ChartCategoriesAxisY : public ChartAxis | |
42 | { |
|
42 | { | |
43 | public: |
|
43 | public: | |
44 | ChartCategoriesAxisY(QBarCategoriesAxis *axis, ChartPresenter *presenter); |
|
44 | ChartCategoriesAxisY(QBarCategoriesAxis *axis, ChartPresenter *presenter); | |
45 | ~ChartCategoriesAxisY(); |
|
45 | ~ChartCategoriesAxisY(); | |
46 |
|
46 | |||
47 | AxisType axisType() const { return Y_AXIS;} |
|
47 | AxisType axisType() const { return Y_AXIS;} | |
48 |
|
48 | |||
49 | protected: |
|
49 | protected: | |
50 | QVector<qreal> calculateLayout() const; |
|
50 | QVector<qreal> calculateLayout() const; | |
51 | void updateGeometry(); |
|
51 | void updateGeometry(); | |
52 | private: |
|
52 | private: | |
53 | QStringList createCategoryLabels(const QVector<qreal>& layout) const; |
|
53 | QStringList createCategoryLabels(const QVector<qreal>& layout) const; | |
54 | Q_SLOTS |
|
54 | Q_SLOTS | |
55 | void handleAxisUpdated(); |
|
55 | void handleAxisUpdated(); | |
56 | private: |
|
56 | private: | |
57 | QStringList m_categories; |
|
57 | QStringList m_categories; | |
58 | QVector<int> m_labelIndex; |
|
|||
59 | QBarCategoriesAxis *m_categoriesAxis; |
|
58 | QBarCategoriesAxis *m_categoriesAxis; | |
60 | }; |
|
59 | }; | |
61 |
|
60 | |||
62 | QTCOMMERCIALCHART_END_NAMESPACE |
|
61 | QTCOMMERCIALCHART_END_NAMESPACE | |
63 |
|
62 | |||
64 | #endif /* CHARTCATEGORIESAXISY_H */ |
|
63 | #endif /* CHARTCATEGORIESAXISY_H */ |
@@ -1,439 +1,432 | |||||
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 "qbarcategoriesaxis.h" |
|
21 | #include "qbarcategoriesaxis.h" | |
22 | #include "qbarcategoriesaxis_p.h" |
|
22 | #include "qbarcategoriesaxis_p.h" | |
23 | #include "chartcategoriesaxisx_p.h" |
|
23 | #include "chartcategoriesaxisx_p.h" | |
24 | #include "chartcategoriesaxisy_p.h" |
|
24 | #include "chartcategoriesaxisy_p.h" | |
25 | #include "domain_p.h" |
|
25 | #include "domain_p.h" | |
|
26 | #include "chartdataset_p.h" | |||
26 | #include <qmath.h> |
|
27 | #include <qmath.h> | |
27 | #include <QDebug> |
|
|||
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 | /*! |
|
30 | /*! | |
31 | \class QBarCategoriesAxis |
|
31 | \class QBarCategoriesAxis | |
32 | \brief The QBarCategoriesAxis class is used for manipulating chart's axis. |
|
32 | \brief The QBarCategoriesAxis class is used for manipulating chart's axis. | |
33 | \mainclass |
|
33 | \mainclass | |
34 |
|
34 | |||
35 | BarCategoriesAxis can be setup to show axis line with tick marks, grid lines and shades. |
|
35 | BarCategoriesAxis can be setup to show axis line with tick marks, grid lines and shades. | |
36 | Categories are drawn between ticks. Note that you can use this also with lineseries too. |
|
36 | Categories are drawn between ticks. Note that you can use this also with lineseries too. | |
37 | See the \l {Line and BarChart Example} {Line and BarChart Example} to learn how to do that. |
|
37 | See the \l {Line and BarChart Example} {Line and BarChart Example} to learn how to do that. | |
38 | */ |
|
38 | */ | |
39 |
|
39 | |||
40 | /*! |
|
40 | /*! | |
41 | \qmlclass BarCategoriesAxis QBarCategoriesAxis |
|
41 | \qmlclass BarCategoriesAxis QBarCategoriesAxis | |
42 | \brief The Axis element is used for manipulating chart's axes. |
|
42 | \brief The Axis element is used for manipulating chart's axes. | |
43 |
|
43 | |||
44 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
44 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
45 | Categories are drawn between ticks. Note that you can use this also with lineseries too. |
|
45 | Categories are drawn between ticks. Note that you can use this also with lineseries too. | |
46 |
|
46 | |||
47 | To access BarCategoriesAxis you can use ChartView API. For example: |
|
47 | To access BarCategoriesAxis you can use ChartView API. For example: | |
48 | \code |
|
48 | \code | |
49 | ChartView { |
|
49 | ChartView { | |
50 | BarCategoriesAxis { |
|
50 | BarCategoriesAxis { | |
51 | id: categoryAxis |
|
51 | id: categoryAxis | |
52 | categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun" ] |
|
52 | categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun" ] | |
53 | } |
|
53 | } | |
54 | // Add a few series... |
|
54 | // Add a few series... | |
55 | } |
|
55 | } | |
56 | \endcode |
|
56 | \endcode | |
57 | */ |
|
57 | */ | |
58 |
|
58 | |||
59 | /*! |
|
59 | /*! | |
60 | \property QBarCategoriesAxis::categories |
|
60 | \property QBarCategoriesAxis::categories | |
61 | Defines the categories of axis |
|
61 | Defines the categories of axis | |
62 | */ |
|
62 | */ | |
63 | /*! |
|
63 | /*! | |
64 | \qmlproperty QStringList BarCategoriesAxis::categories |
|
64 | \qmlproperty QStringList BarCategoriesAxis::categories | |
65 | Defines the categories of axis |
|
65 | Defines the categories of axis | |
66 | */ |
|
66 | */ | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | \property QBarCategoriesAxis::min |
|
69 | \property QBarCategoriesAxis::min | |
70 | Defines the minimum value on the axis. |
|
70 | Defines the minimum value on the axis. | |
71 | */ |
|
71 | */ | |
72 | /*! |
|
72 | /*! | |
73 | \qmlproperty QString BarCategoriesAxis::min |
|
73 | \qmlproperty QString BarCategoriesAxis::min | |
74 | Defines the minimum value on the axis. |
|
74 | Defines the minimum value on the axis. | |
75 | */ |
|
75 | */ | |
76 |
|
76 | |||
77 | /*! |
|
77 | /*! | |
78 | \property QBarCategoriesAxis::max |
|
78 | \property QBarCategoriesAxis::max | |
79 | Defines the maximum value on the axis. |
|
79 | Defines the maximum value on the axis. | |
80 | */ |
|
80 | */ | |
81 | /*! |
|
81 | /*! | |
82 | \qmlproperty QString BarCategoriesAxis::max |
|
82 | \qmlproperty QString BarCategoriesAxis::max | |
83 | Defines the maximum value on the axis. |
|
83 | Defines the maximum value on the axis. | |
84 | */ |
|
84 | */ | |
85 |
|
85 | |||
86 |
|
86 | |||
87 | /*! |
|
87 | /*! | |
88 | \fn void QBarCategoriesAxis::categoriesChanged() |
|
88 | \fn void QBarCategoriesAxis::categoriesChanged() | |
89 | Axis emits signal when the categories of the axis has changed. |
|
89 | Axis emits signal when the categories of the axis has changed. | |
90 | */ |
|
90 | */ | |
91 | /*! |
|
91 | /*! | |
92 | \fn void QBarCategoriesAxis::minChanged(const QString &min) |
|
92 | \fn void QBarCategoriesAxis::minChanged(const QString &min) | |
93 | Axis emits signal when \a min of axis has changed. |
|
93 | Axis emits signal when \a min of axis has changed. | |
94 | */ |
|
94 | */ | |
95 | /*! |
|
95 | /*! | |
96 | \qmlsignal BarCategoriesAxis::onMinChanged(const QString &min) |
|
96 | \qmlsignal BarCategoriesAxis::onMinChanged(const QString &min) | |
97 | Axis emits signal when \a min of axis has changed. |
|
97 | Axis emits signal when \a min of axis has changed. | |
98 | */ |
|
98 | */ | |
99 |
|
99 | |||
100 | /*! |
|
100 | /*! | |
101 | \fn void QBarCategoriesAxis::maxChanged(const QString &max) |
|
101 | \fn void QBarCategoriesAxis::maxChanged(const QString &max) | |
102 | Axis emits signal when \a max of axis has changed. |
|
102 | Axis emits signal when \a max of axis has changed. | |
103 | */ |
|
103 | */ | |
104 | /*! |
|
104 | /*! | |
105 | \qmlsignal BarCategoriesAxis::onMaxChanged(const QString &max) |
|
105 | \qmlsignal BarCategoriesAxis::onMaxChanged(const QString &max) | |
106 | Axis emits signal when \a max of axis has changed. |
|
106 | Axis emits signal when \a max of axis has changed. | |
107 | */ |
|
107 | */ | |
108 |
|
108 | |||
109 | /*! |
|
109 | /*! | |
110 | \fn void QBarCategoriesAxis::rangeChanged(const QString &min, const QString &max) |
|
110 | \fn void QBarCategoriesAxis::rangeChanged(const QString &min, const QString &max) | |
111 | Axis emits signal when \a min or \a max of axis has changed. |
|
111 | Axis emits signal when \a min or \a max of axis has changed. | |
112 | */ |
|
112 | */ | |
113 |
|
113 | |||
114 | /*! |
|
114 | /*! | |
115 | Constructs an axis object which is a child of \a parent. |
|
115 | Constructs an axis object which is a child of \a parent. | |
116 | */ |
|
116 | */ | |
117 | QBarCategoriesAxis::QBarCategoriesAxis(QObject *parent): |
|
117 | QBarCategoriesAxis::QBarCategoriesAxis(QObject *parent): | |
118 | QAbstractAxis(*new QBarCategoriesAxisPrivate(this),parent) |
|
118 | QAbstractAxis(*new QBarCategoriesAxisPrivate(this),parent) | |
119 | { |
|
119 | { | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
122 | /*! |
|
122 | /*! | |
123 | Destroys the object |
|
123 | Destroys the object | |
124 | */ |
|
124 | */ | |
125 | QBarCategoriesAxis::~QBarCategoriesAxis() |
|
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 | /*! | |
130 | \internal |
|
134 | \internal | |
131 | */ |
|
135 | */ | |
132 | QBarCategoriesAxis::QBarCategoriesAxis(QBarCategoriesAxisPrivate &d,QObject *parent):QAbstractAxis(d,parent) |
|
136 | QBarCategoriesAxis::QBarCategoriesAxis(QBarCategoriesAxisPrivate &d,QObject *parent):QAbstractAxis(d,parent) | |
133 | { |
|
137 | { | |
134 |
|
138 | |||
135 | } |
|
139 | } | |
136 |
|
140 | |||
137 | /*! |
|
141 | /*! | |
138 | Appends \a categories to axis |
|
142 | Appends \a categories to axis | |
139 | */ |
|
143 | */ | |
140 | void QBarCategoriesAxis::append(const QStringList &categories) |
|
144 | void QBarCategoriesAxis::append(const QStringList &categories) | |
141 | { |
|
145 | { | |
142 | if(categories.isEmpty()) return; |
|
146 | if(categories.isEmpty()) return; | |
143 |
|
147 | |||
144 | Q_D(QBarCategoriesAxis); |
|
148 | Q_D(QBarCategoriesAxis); | |
145 | if (d->m_categories.isEmpty()) { |
|
149 | if (d->m_categories.isEmpty()) { | |
146 | d->m_categories.append(categories); |
|
150 | d->m_categories.append(categories); | |
147 | setRange(categories.first(),categories.last()); |
|
151 | setRange(categories.first(),categories.last()); | |
148 | }else{ |
|
152 | }else{ | |
149 | d->m_categories.append(categories); |
|
153 | d->m_categories.append(categories); | |
150 | } |
|
154 | } | |
151 | emit d->updated(); |
|
155 | emit d->updated(); | |
152 | emit categoriesChanged(); |
|
156 | emit categoriesChanged(); | |
153 | } |
|
157 | } | |
154 |
|
158 | |||
155 | /*! |
|
159 | /*! | |
156 | Appends \a category to axis |
|
160 | Appends \a category to axis | |
157 | */ |
|
161 | */ | |
158 | void QBarCategoriesAxis::append(const QString &category) |
|
162 | void QBarCategoriesAxis::append(const QString &category) | |
159 | { |
|
163 | { | |
160 | Q_D(QBarCategoriesAxis); |
|
164 | Q_D(QBarCategoriesAxis); | |
161 | if (d->m_categories.isEmpty()) { |
|
165 | if (d->m_categories.isEmpty()) { | |
162 | d->m_categories.append(category); |
|
166 | d->m_categories.append(category); | |
163 | setRange(category,category); |
|
167 | setRange(category,category); | |
164 | }else{ |
|
168 | }else{ | |
165 | d->m_categories.append(category); |
|
169 | d->m_categories.append(category); | |
166 | } |
|
170 | } | |
167 | emit d->updated(); |
|
171 | emit d->updated(); | |
168 | emit categoriesChanged(); |
|
172 | emit categoriesChanged(); | |
169 | } |
|
173 | } | |
170 |
|
174 | |||
171 | /*! |
|
175 | /*! | |
172 | Removes \a category from axis |
|
176 | Removes \a category from axis | |
173 | */ |
|
177 | */ | |
174 | void QBarCategoriesAxis::remove(const QString &category) |
|
178 | void QBarCategoriesAxis::remove(const QString &category) | |
175 | { |
|
179 | { | |
176 | Q_D(QBarCategoriesAxis); |
|
180 | Q_D(QBarCategoriesAxis); | |
177 | if (d->m_categories.contains(category)) { |
|
181 | if (d->m_categories.contains(category)) { | |
178 | d->m_categories.removeAt(d->m_categories.indexOf(category)); |
|
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 | emit d->updated(); |
|
187 | emit d->updated(); | |
181 | emit categoriesChanged(); |
|
188 | emit categoriesChanged(); | |
182 | } |
|
189 | } | |
183 | } |
|
190 | } | |
184 |
|
191 | |||
185 | /*! |
|
192 | /*! | |
186 | Inserts \a category to axis at \a index |
|
193 | Inserts \a category to axis at \a index | |
187 | */ |
|
194 | */ | |
188 | void QBarCategoriesAxis::insert(int index, const QString &category) |
|
195 | void QBarCategoriesAxis::insert(int index, const QString &category) | |
189 | { |
|
196 | { | |
190 | Q_D(QBarCategoriesAxis); |
|
197 | Q_D(QBarCategoriesAxis); | |
191 | if (d->m_categories.isEmpty()) { |
|
198 | if (d->m_categories.isEmpty()) { | |
192 | d->m_categories.insert(index,category); |
|
199 | d->m_categories.insert(index,category); | |
193 | setRange(category,category); |
|
200 | setRange(category,category); | |
194 | }else{ |
|
201 | }else{ | |
195 | d->m_categories.insert(index,category); |
|
202 | d->m_categories.insert(index,category); | |
196 | } |
|
203 | } | |
197 | emit d->updated(); |
|
204 | emit d->updated(); | |
198 | emit categoriesChanged(); |
|
205 | emit categoriesChanged(); | |
199 | } |
|
206 | } | |
200 |
|
207 | |||
201 | /*! |
|
208 | /*! | |
202 | Removes all categories. |
|
209 | Removes all categories. | |
203 | */ |
|
210 | */ | |
204 | void QBarCategoriesAxis::clear() |
|
211 | void QBarCategoriesAxis::clear() | |
205 | { |
|
212 | { | |
206 | Q_D(QBarCategoriesAxis); |
|
213 | Q_D(QBarCategoriesAxis); | |
207 | d->m_categories.clear(); |
|
214 | d->m_categories.clear(); | |
208 | setRange(QString::null,QString::null); |
|
215 | setRange(QString::null,QString::null); | |
209 | emit d->updated(); |
|
216 | emit d->updated(); | |
210 | emit categoriesChanged(); |
|
217 | emit categoriesChanged(); | |
211 | } |
|
218 | } | |
212 |
|
219 | |||
213 | void QBarCategoriesAxis::setCategories(const QStringList &categories) |
|
220 | void QBarCategoriesAxis::setCategories(const QStringList &categories) | |
214 | { |
|
221 | { | |
215 | Q_D(QBarCategoriesAxis); |
|
222 | Q_D(QBarCategoriesAxis); | |
216 | if(d->m_categories!=categories){ |
|
223 | if(d->m_categories!=categories){ | |
217 | d->m_categories = categories; |
|
224 | d->m_categories = categories; | |
218 | setRange(categories.first(),categories.last()); |
|
225 | setRange(categories.first(),categories.last()); | |
219 | emit d->updated(); |
|
226 | emit d->updated(); | |
220 | emit categoriesChanged(); |
|
227 | emit categoriesChanged(); | |
221 | } |
|
228 | } | |
222 | } |
|
229 | } | |
223 |
|
230 | |||
224 | QStringList QBarCategoriesAxis::categories() |
|
231 | QStringList QBarCategoriesAxis::categories() | |
225 | { |
|
232 | { | |
226 | Q_D(QBarCategoriesAxis); |
|
233 | Q_D(QBarCategoriesAxis); | |
227 | return d->m_categories; |
|
234 | return d->m_categories; | |
228 | } |
|
235 | } | |
229 |
|
236 | |||
230 | /*! |
|
237 | /*! | |
231 | Returns number of categories. |
|
238 | Returns number of categories. | |
232 | */ |
|
239 | */ | |
233 | int QBarCategoriesAxis::count() const |
|
240 | int QBarCategoriesAxis::count() const | |
234 | { |
|
241 | { | |
235 | Q_D(const QBarCategoriesAxis); |
|
242 | Q_D(const QBarCategoriesAxis); | |
236 | return d->m_categories.count(); |
|
243 | return d->m_categories.count(); | |
237 | } |
|
244 | } | |
238 |
|
245 | |||
239 | /*! |
|
246 | /*! | |
240 | Returns category at \a index. Index must be valid. |
|
247 | Returns category at \a index. Index must be valid. | |
241 | */ |
|
248 | */ | |
242 | QString QBarCategoriesAxis::at(int index) const |
|
249 | QString QBarCategoriesAxis::at(int index) const | |
243 | { |
|
250 | { | |
244 | Q_D(const QBarCategoriesAxis); |
|
251 | Q_D(const QBarCategoriesAxis); | |
245 | return d->m_categories.at(index); |
|
252 | return d->m_categories.at(index); | |
246 | } |
|
253 | } | |
247 |
|
254 | |||
248 | /*! |
|
255 | /*! | |
249 | Sets minimum category to \a min. |
|
256 | Sets minimum category to \a min. | |
250 | */ |
|
257 | */ | |
251 | void QBarCategoriesAxis::setMin(const QString& min) |
|
258 | void QBarCategoriesAxis::setMin(const QString& min) | |
252 | { |
|
259 | { | |
253 | Q_D(QBarCategoriesAxis); |
|
260 | Q_D(QBarCategoriesAxis); | |
254 | if (d->m_minCategory!=min && d->m_categories.contains(min)) { |
|
261 | setRange(min,d->m_maxCategory); | |
255 | d->m_minCategory = min; |
|
|||
256 | d->emitUpdated(); |
|
|||
257 | emit minChanged(min); |
|
|||
258 | } |
|
|||
259 |
|
||||
260 | } |
|
262 | } | |
261 |
|
263 | |||
262 | /*! |
|
264 | /*! | |
263 | Returns minimum category. |
|
265 | Returns minimum category. | |
264 | */ |
|
266 | */ | |
265 | QString QBarCategoriesAxis::min() const |
|
267 | QString QBarCategoriesAxis::min() const | |
266 | { |
|
268 | { | |
267 | Q_D(const QBarCategoriesAxis); |
|
269 | Q_D(const QBarCategoriesAxis); | |
268 | return d->m_minCategory; |
|
270 | return d->m_minCategory; | |
269 | } |
|
271 | } | |
270 |
|
272 | |||
271 | /*! |
|
273 | /*! | |
272 | Sets maximum category to \a max. |
|
274 | Sets maximum category to \a max. | |
273 | */ |
|
275 | */ | |
274 | void QBarCategoriesAxis::setMax(const QString& max) |
|
276 | void QBarCategoriesAxis::setMax(const QString& max) | |
275 | { |
|
277 | { | |
276 | Q_D(QBarCategoriesAxis); |
|
278 | Q_D(QBarCategoriesAxis); | |
277 | if (d->m_maxCategory!=max && d->m_categories.contains(max)) { |
|
279 | setRange(d->m_minCategory,max); | |
278 | d->m_maxCategory = max; |
|
|||
279 | d->emitUpdated(); |
|
|||
280 | emit maxChanged(max); |
|
|||
281 | } |
|
|||
282 |
|
||||
283 | } |
|
280 | } | |
284 |
|
281 | |||
285 | /*! |
|
282 | /*! | |
286 | Returns maximum category |
|
283 | Returns maximum category | |
287 | */ |
|
284 | */ | |
288 | QString QBarCategoriesAxis::max() const |
|
285 | QString QBarCategoriesAxis::max() const | |
289 | { |
|
286 | { | |
290 | Q_D(const QBarCategoriesAxis); |
|
287 | Q_D(const QBarCategoriesAxis); | |
291 | return d->m_maxCategory; |
|
288 | return d->m_maxCategory; | |
292 | } |
|
289 | } | |
293 |
|
290 | |||
294 | /*! |
|
291 | /*! | |
295 | Sets range from \a minCategory to \a maxCategory |
|
292 | Sets range from \a minCategory to \a maxCategory | |
296 | */ |
|
293 | */ | |
297 | void QBarCategoriesAxis::setRange(const QString& minCategory, const QString& maxCategory) |
|
294 | void QBarCategoriesAxis::setRange(const QString& minCategory, const QString& maxCategory) | |
298 | { |
|
295 | { | |
299 | setMin(minCategory); |
|
296 | Q_D(QBarCategoriesAxis); | |
300 | setMax(maxCategory); |
|
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 | /*! | |
304 | Returns the type of the axis |
|
324 | Returns the type of the axis | |
305 | */ |
|
325 | */ | |
306 | QAbstractAxis::AxisType QBarCategoriesAxis::type() const |
|
326 | QAbstractAxis::AxisType QBarCategoriesAxis::type() const | |
307 | { |
|
327 | { | |
308 | return AxisTypeCategories; |
|
328 | return AxisTypeCategories; | |
309 | } |
|
329 | } | |
310 |
|
330 | |||
311 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
331 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
312 |
|
332 | |||
313 | QBarCategoriesAxisPrivate::QBarCategoriesAxisPrivate(QBarCategoriesAxis* q): |
|
333 | QBarCategoriesAxisPrivate::QBarCategoriesAxisPrivate(QBarCategoriesAxis* q): | |
314 | QAbstractAxisPrivate(q), |
|
334 | QAbstractAxisPrivate(q), | |
315 | m_min(0.0), |
|
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 | } | |
320 |
|
341 | |||
321 | QBarCategoriesAxisPrivate::~QBarCategoriesAxisPrivate() |
|
342 | QBarCategoriesAxisPrivate::~QBarCategoriesAxisPrivate() | |
322 | { |
|
343 | { | |
323 |
|
344 | |||
324 | } |
|
345 | } | |
325 |
|
346 | |||
326 | void QBarCategoriesAxisPrivate::setMin(const QVariant &min) |
|
347 | void QBarCategoriesAxisPrivate::setMin(const QVariant &min) | |
327 | { |
|
348 | { | |
328 | setRange(min,m_maxCategory); |
|
349 | setRange(min,m_maxCategory); | |
329 | } |
|
350 | } | |
330 |
|
351 | |||
331 | void QBarCategoriesAxisPrivate::setMax(const QVariant &max) |
|
352 | void QBarCategoriesAxisPrivate::setMax(const QVariant &max) | |
332 | { |
|
353 | { | |
333 | setRange(m_minCategory,max); |
|
354 | setRange(m_minCategory,max); | |
334 | } |
|
355 | } | |
335 |
|
356 | |||
336 | void QBarCategoriesAxisPrivate::setRange(const QVariant &min, const QVariant &max) |
|
357 | void QBarCategoriesAxisPrivate::setRange(const QVariant &min, const QVariant &max) | |
337 | { |
|
358 | { | |
338 | Q_Q(QBarCategoriesAxis); |
|
359 | Q_Q(QBarCategoriesAxis); | |
339 | QString value1 = min.toString(); |
|
360 | QString value1 = min.toString(); | |
340 | QString value2 = max.toString(); |
|
361 | QString value2 = max.toString(); | |
341 | q->setRange(value1,value2); |
|
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 | void QBarCategoriesAxisPrivate::handleDomainUpdated() |
|
365 | void QBarCategoriesAxisPrivate::handleDomainUpdated() | |
357 | { |
|
366 | { | |
|
367 | Q_Q(QBarCategoriesAxis); | |||
358 | Domain* domain = qobject_cast<Domain*>(sender()); |
|
368 | Domain* domain = qobject_cast<Domain*>(sender()); | |
359 |
|
369 | |||
360 | if(m_orientation==Qt::Horizontal){ |
|
370 | if(m_orientation==Qt::Horizontal) { | |
361 | m_min = domain->minX(); |
|
371 | m_min = domain->minX(); | |
362 | m_max = domain->maxX(); |
|
372 | m_max = domain->maxX(); | |
363 | }else if(m_orientation==Qt::Vertical){ |
|
373 | } | |
|
374 | else if(m_orientation==Qt::Vertical) { | |||
364 | m_min = domain->minY(); |
|
375 | m_min = domain->minY(); | |
365 | m_max = domain->maxY(); |
|
376 | m_max = domain->maxY(); | |
366 | } |
|
377 | } | |
367 |
|
378 | |||
368 | // Q_Q(QBarCategoriesAxis); |
|
379 | bool changed = false; | |
369 |
|
||||
370 | // TODO: causes crash in some situations. added to known issues |
|
|||
371 | /* |
|
|||
372 | int minIndex = qFloor(min); |
|
|||
373 | int maxIndex = qFloor(max); |
|
|||
374 |
|
380 | |||
375 | if (minIndex < 0) { |
|
381 | int min = m_min + 0.5; | |
376 | minIndex = 0; |
|
382 | if(min>=0 && min<m_categories.count()) { | |
377 | } |
|
383 | QString minCategory = m_categories.at(min); | |
378 | if (maxIndex > m_categories.count()-1){ |
|
384 | if(m_minCategory!=minCategory && !minCategory.isEmpty()) { | |
379 | maxIndex = m_categories.count()-1; |
|
385 | m_minCategory=minCategory; | |
380 | if (maxIndex<0) { |
|
386 | changed=true; | |
381 | maxIndex = 0; |
|
387 | emit q->minChanged(minCategory); | |
382 | } |
|
388 | } | |
383 | } |
|
389 | } | |
384 |
|
390 | int max = m_max - 0.5; | ||
385 | bool changed = false; |
|
391 | if(max>=0 && max<m_categories.count()) { | |
386 |
|
|
392 | QString maxCategory = m_categories.at(max); | |
387 | m_minCategory = m_categories.at(minIndex); |
|
393 | if(m_maxCategory!=maxCategory && !maxCategory.isEmpty()) { | |
388 | emit q->minChanged(m_minCategory); |
|
394 | m_maxCategory=maxCategory; | |
389 | changed = true; |
|
395 | emit q->maxChanged(maxCategory); | |
390 | } |
|
396 | } | |
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; |
|
|||
396 | } |
|
397 | } | |
397 |
|
398 | |||
398 | if (changed) { |
|
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 | ChartAxis* QBarCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) |
|
404 | ChartAxis* QBarCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) | |
405 | { |
|
405 | { | |
406 | Q_Q(QBarCategoriesAxis); |
|
406 | Q_Q(QBarCategoriesAxis); | |
407 | if(m_orientation == Qt::Vertical){ |
|
407 | if(m_orientation == Qt::Vertical){ | |
408 | return new ChartCategoriesAxisY(q,presenter); |
|
408 | return new ChartCategoriesAxisY(q,presenter); | |
409 | }else{ |
|
409 | }else{ | |
410 | return new ChartCategoriesAxisX(q,presenter); |
|
410 | return new ChartCategoriesAxisX(q,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 | void QBarCategoriesAxisPrivate::intializeDomain(Domain* domain) |
|
414 | void QBarCategoriesAxisPrivate::intializeDomain(Domain* domain) | |
422 | { |
|
415 | { | |
423 | Q_UNUSED(domain); |
|
416 | Q_UNUSED(domain); | |
424 | // TODO: this causes crash now. added to known issues. |
|
417 | // TODO: this causes crash now. added to known issues. | |
425 | /* |
|
418 | /* | |
426 | if (qFuzzyCompare(m_max, m_min)) { |
|
419 | if (qFuzzyCompare(m_max, m_min)) { | |
427 | if(m_orientation==Qt::Vertical){ |
|
420 | if(m_orientation==Qt::Vertical){ | |
428 | handleAxisRangeChanged(domain->minY(),domain->maxY(),domain->tickXCount()); |
|
421 | handleAxisRangeChanged(domain->minY(),domain->maxY(),domain->tickXCount()); | |
429 | }else{ |
|
422 | }else{ | |
430 | handleAxisRangeChanged(domain->minX(),domain->maxX(),domain->tickYCount()); |
|
423 | handleAxisRangeChanged(domain->minX(),domain->maxX(),domain->tickYCount()); | |
431 | } |
|
424 | } | |
432 | } |
|
425 | } | |
433 | */ |
|
426 | */ | |
434 | } |
|
427 | } | |
435 |
|
428 | |||
436 | #include "moc_qbarcategoriesaxis.cpp" |
|
429 | #include "moc_qbarcategoriesaxis.cpp" | |
437 | #include "moc_qbarcategoriesaxis_p.cpp" |
|
430 | #include "moc_qbarcategoriesaxis_p.cpp" | |
438 |
|
431 | |||
439 | QTCOMMERCIALCHART_END_NAMESPACE |
|
432 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,76 +1,78 | |||||
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 QBARCATEGORIESAXIS_H |
|
21 | #ifndef QBARCATEGORIESAXIS_H | |
22 | #define QBARCATEGORIESAXIS_H |
|
22 | #define QBARCATEGORIESAXIS_H | |
23 |
|
23 | |||
24 | #include "qabstractaxis.h" |
|
24 | #include "qabstractaxis.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | class QBarCategoriesAxisPrivate; |
|
28 | class QBarCategoriesAxisPrivate; | |
29 |
|
29 | |||
30 | class QTCOMMERCIALCHART_EXPORT QBarCategoriesAxis : public QAbstractAxis |
|
30 | class QTCOMMERCIALCHART_EXPORT QBarCategoriesAxis : public QAbstractAxis | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 | Q_PROPERTY(QStringList categories READ categories WRITE setCategories NOTIFY categoriesChanged) |
|
33 | Q_PROPERTY(QStringList categories READ categories WRITE setCategories NOTIFY categoriesChanged) | |
34 | Q_PROPERTY(QString min READ min WRITE setMin NOTIFY minChanged) |
|
34 | Q_PROPERTY(QString min READ min WRITE setMin NOTIFY minChanged) | |
35 | Q_PROPERTY(QString max READ max WRITE setMax NOTIFY maxChanged) |
|
35 | Q_PROPERTY(QString max READ max WRITE setMax NOTIFY maxChanged) | |
36 |
|
36 | |||
37 | public: |
|
37 | public: | |
38 | explicit QBarCategoriesAxis(QObject *parent = 0); |
|
38 | explicit QBarCategoriesAxis(QObject *parent = 0); | |
39 | ~QBarCategoriesAxis(); |
|
39 | ~QBarCategoriesAxis(); | |
40 |
|
40 | |||
41 | protected: |
|
41 | protected: | |
42 | QBarCategoriesAxis(QBarCategoriesAxisPrivate &d,QObject *parent = 0); |
|
42 | QBarCategoriesAxis(QBarCategoriesAxisPrivate &d,QObject *parent = 0); | |
43 |
|
43 | |||
44 | public: |
|
44 | public: | |
45 | AxisType type() const; |
|
45 | AxisType type() const; | |
46 | void append(const QStringList &categories); |
|
46 | void append(const QStringList &categories); | |
47 | void append(const QString &category); |
|
47 | void append(const QString &category); | |
48 | void remove(const QString &category); |
|
48 | void remove(const QString &category); | |
49 | void insert(int index, const QString &category); |
|
49 | void insert(int index, const QString &category); | |
50 | void clear(); |
|
50 | void clear(); | |
51 | void setCategories(const QStringList &categories); |
|
51 | void setCategories(const QStringList &categories); | |
52 | QStringList categories(); |
|
52 | QStringList categories(); | |
53 | int count() const; |
|
53 | int count() const; | |
54 | QString at(int index) const; |
|
54 | QString at(int index) const; | |
55 |
|
55 | |||
56 | //range handling |
|
56 | //range handling | |
57 | void setMin(const QString& minCategory); |
|
57 | void setMin(const QString& minCategory); | |
58 | QString min() const; |
|
58 | QString min() const; | |
59 | void setMax(const QString& maxCategory); |
|
59 | void setMax(const QString& maxCategory); | |
60 | QString max() const; |
|
60 | QString max() const; | |
61 | void setRange(const QString& minCategory, const QString& maxCategory); |
|
61 | void setRange(const QString& minCategory, const QString& maxCategory); | |
62 |
|
62 | |||
63 | Q_SIGNALS: |
|
63 | Q_SIGNALS: | |
64 | void categoriesChanged(); |
|
64 | void categoriesChanged(); | |
65 | void minChanged(const QString &min); |
|
65 | void minChanged(const QString &min); | |
66 | void maxChanged(const QString &max); |
|
66 | void maxChanged(const QString &max); | |
67 | void rangeChanged(const QString &min, const QString &max); |
|
67 | void rangeChanged(const QString &min, const QString &max); | |
68 |
|
68 | |||
69 | private: |
|
69 | private: | |
70 | Q_DECLARE_PRIVATE(QBarCategoriesAxis) |
|
70 | Q_DECLARE_PRIVATE(QBarCategoriesAxis) | |
71 | Q_DISABLE_COPY(QBarCategoriesAxis) |
|
71 | Q_DISABLE_COPY(QBarCategoriesAxis) | |
|
72 | friend class ChartCategoriesAxisX; | |||
|
73 | friend class ChartCategoriesAxisY; | |||
72 | }; |
|
74 | }; | |
73 |
|
75 | |||
74 | QTCOMMERCIALCHART_END_NAMESPACE |
|
76 | QTCOMMERCIALCHART_END_NAMESPACE | |
75 |
|
77 | |||
76 | #endif // QCATEGORIESAXIS_H |
|
78 | #endif // QCATEGORIESAXIS_H |
@@ -1,74 +1,76 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef QBARCATEGORIESAXIS_P_H |
|
30 | #ifndef QBARCATEGORIESAXIS_P_H | |
31 | #define QBARCATEGORIESAXIS_P_H |
|
31 | #define QBARCATEGORIESAXIS_P_H | |
32 |
|
32 | |||
33 | #include "qbarcategoriesaxis.h" |
|
33 | #include "qbarcategoriesaxis.h" | |
34 | #include "qabstractaxis_p.h" |
|
34 | #include "qabstractaxis_p.h" | |
35 |
|
35 | |||
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
37 |
|
37 | |||
38 | class Domain; |
|
38 | class Domain; | |
39 |
|
39 | |||
40 | class QBarCategoriesAxisPrivate : public QAbstractAxisPrivate |
|
40 | class QBarCategoriesAxisPrivate : public QAbstractAxisPrivate | |
41 | { |
|
41 | { | |
42 | Q_OBJECT |
|
42 | Q_OBJECT | |
43 |
|
43 | |||
44 | public: |
|
44 | public: | |
45 | QBarCategoriesAxisPrivate(QBarCategoriesAxis *q); |
|
45 | QBarCategoriesAxisPrivate(QBarCategoriesAxis *q); | |
46 | ~QBarCategoriesAxisPrivate(); |
|
46 | ~QBarCategoriesAxisPrivate(); | |
47 |
|
47 | |||
48 | public: |
|
48 | public: | |
49 | ChartAxis* createGraphics(ChartPresenter* presenter); |
|
49 | ChartAxis* createGraphics(ChartPresenter* presenter); | |
50 | void intializeDomain(Domain* domain); |
|
50 | void intializeDomain(Domain* domain); | |
51 | void handleDomainUpdated(); |
|
51 | void handleDomainUpdated(); | |
52 | qreal min(); |
|
52 | qreal min() { return m_min;}; | |
53 | qreal max(); |
|
53 | qreal max() { return m_max;}; | |
|
54 | int count() const { return m_count; }; | |||
54 |
|
55 | |||
55 | private: |
|
56 | private: | |
56 | //range handling |
|
57 | //range handling | |
57 | void setMin(const QVariant &min); |
|
58 | void setMin(const QVariant &min); | |
58 | void setMax(const QVariant &max); |
|
59 | void setMax(const QVariant &max); | |
59 | void setRange(const QVariant &min, const QVariant &max); |
|
60 | void setRange(const QVariant &min, const QVariant &max); | |
60 |
|
61 | |||
61 | private: |
|
62 | private: | |
62 | QStringList m_categories; |
|
63 | QStringList m_categories; | |
63 | QString m_minCategory; |
|
64 | QString m_minCategory; | |
64 | QString m_maxCategory; |
|
65 | QString m_maxCategory; | |
65 | qreal m_min; |
|
66 | qreal m_min; | |
66 | qreal m_max; |
|
67 | qreal m_max; | |
|
68 | int m_count; | |||
67 |
|
69 | |||
68 | private: |
|
70 | private: | |
69 | Q_DECLARE_PUBLIC(QBarCategoriesAxis) |
|
71 | Q_DECLARE_PUBLIC(QBarCategoriesAxis); | |
70 | }; |
|
72 | }; | |
71 |
|
73 | |||
72 | QTCOMMERCIALCHART_END_NAMESPACE |
|
74 | QTCOMMERCIALCHART_END_NAMESPACE | |
73 |
|
75 | |||
74 | #endif // QBARCATEGORIESAXIS_P_H |
|
76 | #endif // QBARCATEGORIESAXIS_P_H |
@@ -1,69 +1,70 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef QVALUESAXIS_P_H |
|
30 | #ifndef QVALUESAXIS_P_H | |
31 | #define QVALUESAXIS_P_H |
|
31 | #define QVALUESAXIS_P_H | |
32 |
|
32 | |||
33 | #include "qdatetimeaxis.h" |
|
33 | #include "qdatetimeaxis.h" | |
34 | #include "qabstractaxis_p.h" |
|
34 | #include "qabstractaxis_p.h" | |
35 | #include <QDateTime> |
|
35 | #include <QDateTime> | |
36 |
|
36 | |||
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class QDateTimeAxisPrivate : public QAbstractAxisPrivate |
|
39 | class QDateTimeAxisPrivate : public QAbstractAxisPrivate | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | public: |
|
42 | public: | |
43 | QDateTimeAxisPrivate(QDateTimeAxis *q); |
|
43 | QDateTimeAxisPrivate(QDateTimeAxis *q); | |
44 | ~QDateTimeAxisPrivate(); |
|
44 | ~QDateTimeAxisPrivate(); | |
45 |
|
45 | |||
46 | public: |
|
46 | public: | |
47 | ChartAxis* createGraphics(ChartPresenter* presenter); |
|
47 | ChartAxis* createGraphics(ChartPresenter* presenter); | |
48 | void intializeDomain(Domain* domain); |
|
48 | void intializeDomain(Domain* domain); | |
49 | void handleDomainUpdated(); |
|
49 | void handleDomainUpdated(); | |
50 | qreal min(){ return m_min.toMSecsSinceEpoch(); } |
|
50 | qreal min(){ return m_min.toMSecsSinceEpoch(); } | |
51 | qreal max(){ return m_max.toMSecsSinceEpoch(); } |
|
51 | qreal max(){ return m_max.toMSecsSinceEpoch(); } | |
|
52 | int count() const { /*TODO:*/ return 0;}; | |||
52 |
|
53 | |||
53 | protected: |
|
54 | protected: | |
54 | void setMin(const QVariant &min); |
|
55 | void setMin(const QVariant &min); | |
55 | void setMax(const QVariant &max); |
|
56 | void setMax(const QVariant &max); | |
56 | void setRange(const QVariant &min, const QVariant &max); |
|
57 | void setRange(const QVariant &min, const QVariant &max); | |
57 | int ticksCount() const; |
|
58 | int ticksCount() const; | |
58 |
|
59 | |||
59 | protected: |
|
60 | protected: | |
60 | QDateTime m_min; |
|
61 | QDateTime m_min; | |
61 | QDateTime m_max; |
|
62 | QDateTime m_max; | |
62 | int m_tickCount; |
|
63 | int m_tickCount; | |
63 | QString m_format; |
|
64 | QString m_format; | |
64 | Q_DECLARE_PUBLIC(QDateTimeAxis) |
|
65 | Q_DECLARE_PUBLIC(QDateTimeAxis) | |
65 | }; |
|
66 | }; | |
66 |
|
67 | |||
67 | QTCOMMERCIALCHART_END_NAMESPACE |
|
68 | QTCOMMERCIALCHART_END_NAMESPACE | |
68 |
|
69 | |||
69 | #endif // QVALUESAXIS_P_H |
|
70 | #endif // QVALUESAXIS_P_H |
@@ -1,210 +1,212 | |||||
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 | |||
80 | if (!d->m_intervals.contains(intervalLabel)) |
|
80 | if (!d->m_intervals.contains(intervalLabel)) | |
81 | { |
|
81 | { | |
82 | if(d->m_intervals.isEmpty()){ |
|
82 | if(d->m_intervals.isEmpty()){ | |
83 | Range range(d->m_categoryMinimum,interval); |
|
83 | Range range(d->m_categoryMinimum,interval); | |
84 | d->m_intervalsMap.insert(intervalLabel, range); |
|
84 | d->m_intervalsMap.insert(intervalLabel, range); | |
85 | d->m_intervals.append(intervalLabel); |
|
85 | d->m_intervals.append(intervalLabel); | |
86 | }else if (interval > intervalMax(d->m_intervals.last())){ |
|
86 | }else if (interval > intervalMax(d->m_intervals.last())){ | |
87 | Range range = d->m_intervalsMap.value(d->m_intervals.last()); |
|
87 | Range range = d->m_intervalsMap.value(d->m_intervals.last()); | |
88 | d->m_intervalsMap.insert(intervalLabel, Range(range.second,interval)); |
|
88 | d->m_intervalsMap.insert(intervalLabel, Range(range.second,interval)); | |
89 | d->m_intervals.append(intervalLabel); |
|
89 | d->m_intervals.append(intervalLabel); | |
90 | } |
|
90 | } | |
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_D(QIntervalsAxis); |
|
123 | Q_D(QIntervalsAxis); | |
124 | int labelIndex = d->m_intervals.indexOf(intervalLabel); |
|
124 | int labelIndex = d->m_intervals.indexOf(intervalLabel); | |
125 |
|
125 | |||
126 | // check if such label exists |
|
126 | // check if such label exists | |
127 | if (labelIndex != -1) { |
|
127 | if (labelIndex != -1) { | |
128 | d->m_intervals.removeAt(labelIndex); |
|
128 | d->m_intervals.removeAt(labelIndex); | |
129 | d->m_intervalsMap.remove(intervalLabel); |
|
129 | d->m_intervalsMap.remove(intervalLabel); | |
130 |
|
130 | |||
131 | // the range of the interval that follows (if exists) needs to be updated |
|
131 | // the range of the interval that follows (if exists) needs to be updated | |
132 | if (labelIndex < d->m_intervals.count()) { |
|
132 | if (labelIndex < d->m_intervals.count()) { | |
133 | QString label = d->m_intervals.at(labelIndex); |
|
133 | QString label = d->m_intervals.at(labelIndex); | |
134 | Range range = d->m_intervalsMap.value(label); |
|
134 | Range range = d->m_intervalsMap.value(label); | |
135 |
|
135 | |||
136 | // set the range |
|
136 | // set the range | |
137 | if (labelIndex == 0) { |
|
137 | if (labelIndex == 0) { | |
138 | range.first = d->m_categoryMinimum; |
|
138 | range.first = d->m_categoryMinimum; | |
139 | d->m_intervalsMap.insert(label, range); |
|
139 | d->m_intervalsMap.insert(label, range); | |
140 | } else { |
|
140 | } else { | |
141 | range.first = d->m_intervalsMap.value(d->m_intervals.at(labelIndex - 1)).second; |
|
141 | range.first = d->m_intervalsMap.value(d->m_intervals.at(labelIndex - 1)).second; | |
142 | d->m_intervalsMap.insert(label, range); |
|
142 | d->m_intervalsMap.insert(label, range); | |
143 | } |
|
143 | } | |
144 | } |
|
144 | } | |
145 | } |
|
145 | } | |
146 | } |
|
146 | } | |
147 |
|
147 | |||
148 | QStringList QIntervalsAxis::intervalsLabels() |
|
148 | QStringList QIntervalsAxis::intervalsLabels() | |
149 | { |
|
149 | { | |
150 | Q_D(QIntervalsAxis); |
|
150 | Q_D(QIntervalsAxis); | |
151 | return d->m_intervals; |
|
151 | return d->m_intervals; | |
152 | } |
|
152 | } | |
153 |
|
153 | |||
154 | /*! |
|
154 | /*! | |
155 | Returns number of categories. |
|
155 | Returns number of categories. | |
156 | */ |
|
156 | */ | |
157 | int QIntervalsAxis::count() const |
|
157 | int QIntervalsAxis::count() const | |
158 | { |
|
158 | { | |
159 | Q_D(const QIntervalsAxis); |
|
159 | Q_D(const QIntervalsAxis); | |
160 | return d->m_intervals.count(); |
|
160 | return d->m_intervals.count(); | |
161 | } |
|
161 | } | |
162 |
|
162 | |||
163 | /*! |
|
163 | /*! | |
164 | Returns the type of the axis |
|
164 | Returns the type of the axis | |
165 | */ |
|
165 | */ | |
166 | QAbstractAxis::AxisType QIntervalsAxis::type() const |
|
166 | QAbstractAxis::AxisType QIntervalsAxis::type() const | |
167 | { |
|
167 | { | |
168 | return QAbstractAxis::AxisTypeIntervals; |
|
168 | return QAbstractAxis::AxisTypeIntervals; | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
171 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
172 |
|
172 | |||
173 | QIntervalsAxisPrivate::QIntervalsAxisPrivate(QIntervalsAxis* q): |
|
173 | QIntervalsAxisPrivate::QIntervalsAxisPrivate(QIntervalsAxis* q): | |
174 | QValuesAxisPrivate(q), |
|
174 | QValuesAxisPrivate(q), | |
175 | m_categoryMinimum(0) |
|
175 | m_categoryMinimum(0) | |
176 | { |
|
176 | { | |
177 |
|
177 | |||
178 | } |
|
178 | } | |
179 |
|
179 | |||
180 | QIntervalsAxisPrivate::~QIntervalsAxisPrivate() |
|
180 | QIntervalsAxisPrivate::~QIntervalsAxisPrivate() | |
181 | { |
|
181 | { | |
182 |
|
182 | |||
183 | } |
|
183 | } | |
184 |
|
184 | |||
185 | int QIntervalsAxisPrivate::ticksCount() const |
|
185 | int QIntervalsAxisPrivate::ticksCount() const | |
186 | { |
|
186 | { | |
187 | return m_intervals.count() + 1; |
|
187 | return m_intervals.count() + 1; | |
188 | } |
|
188 | } | |
189 |
|
189 | |||
190 | void QIntervalsAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) |
|
190 | void QIntervalsAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |
191 | { |
|
191 | { | |
192 | Q_UNUSED(count); |
|
192 | Q_UNUSED(count); | |
193 | m_min = min; |
|
193 | Q_UNUSED(min); | |
194 | m_max = max; |
|
194 | Q_UNUSED(max); | |
|
195 | //m_min = min; | |||
|
196 | //m_max = max; | |||
195 | } |
|
197 | } | |
196 |
|
198 | |||
197 | ChartAxis* QIntervalsAxisPrivate::createGraphics(ChartPresenter* presenter) |
|
199 | ChartAxis* QIntervalsAxisPrivate::createGraphics(ChartPresenter* presenter) | |
198 | { |
|
200 | { | |
199 | Q_Q(QIntervalsAxis); |
|
201 | Q_Q(QIntervalsAxis); | |
200 | if(m_orientation == Qt::Vertical){ |
|
202 | if(m_orientation == Qt::Vertical){ | |
201 | return new ChartIntervalAxisY(q,presenter); |
|
203 | return new ChartIntervalAxisY(q,presenter); | |
202 | }else{ |
|
204 | }else{ | |
203 | return new ChartIntervalAxisX(q,presenter); |
|
205 | return new ChartIntervalAxisX(q,presenter); | |
204 | } |
|
206 | } | |
205 | } |
|
207 | } | |
206 |
|
208 | |||
207 | #include "moc_qintervalsaxis.cpp" |
|
209 | #include "moc_qintervalsaxis.cpp" | |
208 | #include "moc_qintervalsaxis_p.cpp" |
|
210 | #include "moc_qintervalsaxis_p.cpp" | |
209 |
|
211 | |||
210 | QTCOMMERCIALCHART_END_NAMESPACE |
|
212 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,651 +1,653 | |||||
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 "qabstractaxis.h" |
|
21 | #include "qabstractaxis.h" | |
22 | #include "qabstractaxis_p.h" |
|
22 | #include "qabstractaxis_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QAbstractAxis |
|
27 | \class QAbstractAxis | |
28 | \brief The QAbstractAxis class is used for manipulating chart's axis. |
|
28 | \brief The QAbstractAxis class is used for manipulating chart's axis. | |
29 | \mainclass |
|
29 | \mainclass | |
30 |
|
30 | |||
31 | There is only one x Axis visible at the time, however there can be multiple y axes. |
|
31 | There is only one x Axis visible at the time, however there can be multiple y axes. | |
32 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
32 | Each chart series can be bound to exactly one Y axis and the shared common X axis. | |
33 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
33 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
34 | */ |
|
34 | */ | |
35 |
|
35 | |||
36 | /*! |
|
36 | /*! | |
37 | \qmlclass AbstractAxis QAbstractAxis |
|
37 | \qmlclass AbstractAxis QAbstractAxis | |
38 | \brief The Axis element is used for manipulating chart's axes |
|
38 | \brief The Axis element is used for manipulating chart's axes | |
39 |
|
39 | |||
40 | There is only one x Axis visible at the time, however there can be multiple y axes on a ChartView. |
|
40 | There is only one x Axis visible at the time, however there can be multiple y axes on a ChartView. | |
41 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
41 | Each chart series can be bound to exactly one Y axis and the shared common X axis. | |
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 | ChartView { |
|
46 | ChartView { | |
47 | axisX.min: 0 |
|
47 | axisX.min: 0 | |
48 | axisX.max: 3 |
|
48 | axisX.max: 3 | |
49 | axisX.ticksCount: 4 |
|
49 | axisX.ticksCount: 4 | |
50 | axisY.min: 0 |
|
50 | axisY.min: 0 | |
51 | axisY.max: 4 |
|
51 | axisY.max: 4 | |
52 | // Add a few series... |
|
52 | // Add a few series... | |
53 | } |
|
53 | } | |
54 | \endcode |
|
54 | \endcode | |
55 | */ |
|
55 | */ | |
56 |
|
56 | |||
57 | /*! |
|
57 | /*! | |
58 | \enum QAbstractAxis::AxisType |
|
58 | \enum QAbstractAxis::AxisType | |
59 |
|
59 | |||
60 | The type of the series object. |
|
60 | The type of the series object. | |
61 |
|
61 | |||
62 | \value AxisTypeNoAxis |
|
62 | \value AxisTypeNoAxis | |
63 | \value AxisTypeValues |
|
63 | \value AxisTypeValues | |
64 | \value AxisTypeCategories |
|
64 | \value AxisTypeCategories | |
65 | */ |
|
65 | */ | |
66 |
|
66 | |||
67 | /*! |
|
67 | /*! | |
68 | *\fn void QAbstractAxis::type() const |
|
68 | *\fn void QAbstractAxis::type() const | |
69 | Returns the type of the axis |
|
69 | Returns the type of the axis | |
70 | */ |
|
70 | */ | |
71 |
|
71 | |||
72 | /*! |
|
72 | /*! | |
73 | \property QAbstractAxis::arrowVisible |
|
73 | \property QAbstractAxis::arrowVisible | |
74 | The visibility of the axis arrow |
|
74 | The visibility of the axis arrow | |
75 | */ |
|
75 | */ | |
76 | /*! |
|
76 | /*! | |
77 | \qmlproperty bool AbstractAxis::arrrowVisible |
|
77 | \qmlproperty bool AbstractAxis::arrrowVisible | |
78 | The visibility of the axis arrow |
|
78 | The visibility of the axis arrow | |
79 | */ |
|
79 | */ | |
80 |
|
80 | |||
81 | /*! |
|
81 | /*! | |
82 | \property QAbstractAxis::labelsVisible |
|
82 | \property QAbstractAxis::labelsVisible | |
83 | Defines if axis labels are visible. |
|
83 | Defines if axis labels are visible. | |
84 | */ |
|
84 | */ | |
85 | /*! |
|
85 | /*! | |
86 | \qmlproperty bool AbstractAxis::labelsVisible |
|
86 | \qmlproperty bool AbstractAxis::labelsVisible | |
87 | Defines if axis labels are visible. |
|
87 | Defines if axis labels are visible. | |
88 | */ |
|
88 | */ | |
89 |
|
89 | |||
90 | /*! |
|
90 | /*! | |
91 | \property QAbstractAxis::visible |
|
91 | \property QAbstractAxis::visible | |
92 | The visibility of the axis. |
|
92 | The visibility of the axis. | |
93 | */ |
|
93 | */ | |
94 | /*! |
|
94 | /*! | |
95 | \qmlproperty bool AbstractAxis::visible |
|
95 | \qmlproperty bool AbstractAxis::visible | |
96 | The visibility of the axis. |
|
96 | The visibility of the axis. | |
97 | */ |
|
97 | */ | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | \property QAbstractAxis::gridVisible |
|
100 | \property QAbstractAxis::gridVisible | |
101 | The visibility of the grid lines. |
|
101 | The visibility of the grid lines. | |
102 | */ |
|
102 | */ | |
103 | /*! |
|
103 | /*! | |
104 | \qmlproperty bool AbstractAxis::gridVisible |
|
104 | \qmlproperty bool AbstractAxis::gridVisible | |
105 | The visibility of the grid lines. |
|
105 | The visibility of the grid lines. | |
106 | */ |
|
106 | */ | |
107 |
|
107 | |||
108 | /*! |
|
108 | /*! | |
109 | \property QAbstractAxis::color |
|
109 | \property QAbstractAxis::color | |
110 | The color of the axis and ticks. |
|
110 | The color of the axis and ticks. | |
111 | */ |
|
111 | */ | |
112 | /*! |
|
112 | /*! | |
113 | \qmlproperty color AbstractAxis::color |
|
113 | \qmlproperty color AbstractAxis::color | |
114 | The color of the axis and ticks. |
|
114 | The color of the axis and ticks. | |
115 | */ |
|
115 | */ | |
116 |
|
116 | |||
117 | /*! |
|
117 | /*! | |
118 | \property QAbstractAxis::labelsFont |
|
118 | \property QAbstractAxis::labelsFont | |
119 | The font of the axis labels. |
|
119 | The font of the axis labels. | |
120 | */ |
|
120 | */ | |
121 |
|
121 | |||
122 | /*! |
|
122 | /*! | |
123 | \qmlproperty Font AbstractAxis::labelsFont |
|
123 | \qmlproperty Font AbstractAxis::labelsFont | |
124 | The font of the axis labels. |
|
124 | The font of the axis labels. | |
125 |
|
125 | |||
126 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
126 | See the \l {Font} {QML Font Element} for detailed documentation. | |
127 | */ |
|
127 | */ | |
128 |
|
128 | |||
129 | /*! |
|
129 | /*! | |
130 | \property QAbstractAxis::labelsColor |
|
130 | \property QAbstractAxis::labelsColor | |
131 | The color of the axis labels. |
|
131 | The color of the axis labels. | |
132 | */ |
|
132 | */ | |
133 | /*! |
|
133 | /*! | |
134 | \qmlproperty color AbstractAxis::labelsColor |
|
134 | \qmlproperty color AbstractAxis::labelsColor | |
135 | The color of the axis labels. |
|
135 | The color of the axis labels. | |
136 | */ |
|
136 | */ | |
137 |
|
137 | |||
138 | /*! |
|
138 | /*! | |
139 | \property QAbstractAxis::labelsAngle |
|
139 | \property QAbstractAxis::labelsAngle | |
140 | The angle of the axis labels in degrees. |
|
140 | The angle of the axis labels in degrees. | |
141 | */ |
|
141 | */ | |
142 | /*! |
|
142 | /*! | |
143 | \qmlproperty int AbstractAxis::labelsAngle |
|
143 | \qmlproperty int AbstractAxis::labelsAngle | |
144 | The angle of the axis labels in degrees. |
|
144 | The angle of the axis labels in degrees. | |
145 | */ |
|
145 | */ | |
146 |
|
146 | |||
147 | /*! |
|
147 | /*! | |
148 | \property QAbstractAxis::shadesVisible |
|
148 | \property QAbstractAxis::shadesVisible | |
149 | The visibility of the axis shades. |
|
149 | The visibility of the axis shades. | |
150 | */ |
|
150 | */ | |
151 | /*! |
|
151 | /*! | |
152 | \qmlproperty bool AbstractAxis::shadesVisible |
|
152 | \qmlproperty bool AbstractAxis::shadesVisible | |
153 | The visibility of the axis shades. |
|
153 | The visibility of the axis shades. | |
154 | */ |
|
154 | */ | |
155 |
|
155 | |||
156 | /*! |
|
156 | /*! | |
157 | \property QAbstractAxis::shadesColor |
|
157 | \property QAbstractAxis::shadesColor | |
158 | The fill (brush) color of the axis shades. |
|
158 | The fill (brush) color of the axis shades. | |
159 | */ |
|
159 | */ | |
160 | /*! |
|
160 | /*! | |
161 | \qmlproperty color AbstractAxis::shadesColor |
|
161 | \qmlproperty color AbstractAxis::shadesColor | |
162 | The fill (brush) color of the axis shades. |
|
162 | The fill (brush) color of the axis shades. | |
163 | */ |
|
163 | */ | |
164 |
|
164 | |||
165 | /*! |
|
165 | /*! | |
166 | \property QAbstractAxis::shadesBorderColor |
|
166 | \property QAbstractAxis::shadesBorderColor | |
167 | The border (pen) color of the axis shades. |
|
167 | The border (pen) color of the axis shades. | |
168 | */ |
|
168 | */ | |
169 | /*! |
|
169 | /*! | |
170 | \qmlproperty color AbstractAxis::shadesBorderColor |
|
170 | \qmlproperty color AbstractAxis::shadesBorderColor | |
171 | The border (pen) color of the axis shades. |
|
171 | The border (pen) color of the axis shades. | |
172 | */ |
|
172 | */ | |
173 |
|
173 | |||
174 | /*! |
|
174 | /*! | |
175 | \fn void QAbstractAxis::visibleChanged(bool visible) |
|
175 | \fn void QAbstractAxis::visibleChanged(bool visible) | |
176 | Visiblity of the axis has changed to \a visible. |
|
176 | Visiblity of the axis has changed to \a visible. | |
177 | */ |
|
177 | */ | |
178 | /*! |
|
178 | /*! | |
179 | \qmlsignal AbstractAxis::onVisibleChanged(bool visible) |
|
179 | \qmlsignal AbstractAxis::onVisibleChanged(bool visible) | |
180 | Visiblity of the axis has changed to \a visible. |
|
180 | Visiblity of the axis has changed to \a visible. | |
181 | */ |
|
181 | */ | |
182 |
|
182 | |||
183 | /*! |
|
183 | /*! | |
184 | \fn void QAbstractAxis::arrowVisibleChanged(bool visible) |
|
184 | \fn void QAbstractAxis::arrowVisibleChanged(bool visible) | |
185 | Visiblity of the axis arrow has changed to \a visible. |
|
185 | Visiblity of the axis arrow has changed to \a visible. | |
186 | */ |
|
186 | */ | |
187 | /*! |
|
187 | /*! | |
188 | \qmlsignal AbstractAxis::onArrowVisibleChanged(bool visible) |
|
188 | \qmlsignal AbstractAxis::onArrowVisibleChanged(bool visible) | |
189 | Visiblity of the axis arrow has changed to \a visible. |
|
189 | Visiblity of the axis arrow has changed to \a visible. | |
190 | */ |
|
190 | */ | |
191 |
|
191 | |||
192 | /*! |
|
192 | /*! | |
193 | \fn void QAbstractAxis::labelsVisibleChanged(bool visible) |
|
193 | \fn void QAbstractAxis::labelsVisibleChanged(bool visible) | |
194 | Visiblity of the labels of the axis has changed to \a visible. |
|
194 | Visiblity of the labels of the axis has changed to \a visible. | |
195 | */ |
|
195 | */ | |
196 | /*! |
|
196 | /*! | |
197 | \qmlsignal AbstractAxis::onLabelsVisibleChanged(bool visible) |
|
197 | \qmlsignal AbstractAxis::onLabelsVisibleChanged(bool visible) | |
198 | Visiblity of the labels of the axis has changed to \a visible. |
|
198 | Visiblity of the labels of the axis has changed to \a visible. | |
199 | */ |
|
199 | */ | |
200 |
|
200 | |||
201 | /*! |
|
201 | /*! | |
202 | \fn void QAbstractAxis::gridVisibleChanged(bool visible) |
|
202 | \fn void QAbstractAxis::gridVisibleChanged(bool visible) | |
203 | Visiblity of the grid lines of the axis has changed to \a visible. |
|
203 | Visiblity of the grid lines of the axis has changed to \a visible. | |
204 | */ |
|
204 | */ | |
205 | /*! |
|
205 | /*! | |
206 | \qmlsignal AbstractAxis::onGridVisibleChanged(bool visible) |
|
206 | \qmlsignal AbstractAxis::onGridVisibleChanged(bool visible) | |
207 | Visiblity of the grid lines of the axis has changed to \a visible. |
|
207 | Visiblity of the grid lines of the axis has changed to \a visible. | |
208 | */ |
|
208 | */ | |
209 |
|
209 | |||
210 | /*! |
|
210 | /*! | |
211 | \fn void QAbstractAxis::colorChanged(QColor color) |
|
211 | \fn void QAbstractAxis::colorChanged(QColor color) | |
212 | Emitted if the \a color of the axis is changed. |
|
212 | Emitted if the \a color of the axis is changed. | |
213 | */ |
|
213 | */ | |
214 | /*! |
|
214 | /*! | |
215 | \qmlsignal AbstractAxis::onColorChanged(QColor color) |
|
215 | \qmlsignal AbstractAxis::onColorChanged(QColor color) | |
216 | Emitted if the \a color of the axis is changed. |
|
216 | Emitted if the \a color of the axis is changed. | |
217 | */ |
|
217 | */ | |
218 |
|
218 | |||
219 | /*! |
|
219 | /*! | |
220 | \fn void QAbstractAxis::labelsColorChanged(QColor color) |
|
220 | \fn void QAbstractAxis::labelsColorChanged(QColor color) | |
221 | Emitted if the \a color of the axis labels is changed. |
|
221 | Emitted if the \a color of the axis labels is changed. | |
222 | */ |
|
222 | */ | |
223 | /*! |
|
223 | /*! | |
224 | \qmlsignal AbstractAxis::onLabelsColorChanged(QColor color) |
|
224 | \qmlsignal AbstractAxis::onLabelsColorChanged(QColor color) | |
225 | Emitted if the \a color of the axis labels is changed. |
|
225 | Emitted if the \a color of the axis labels is changed. | |
226 | */ |
|
226 | */ | |
227 |
|
227 | |||
228 | /*! |
|
228 | /*! | |
229 | \fn void QAbstractAxis::shadesVisibleChanged(bool) |
|
229 | \fn void QAbstractAxis::shadesVisibleChanged(bool) | |
230 | Emitted if the visibility of the axis shades is changed to \a visible. |
|
230 | Emitted if the visibility of the axis shades is changed to \a visible. | |
231 | */ |
|
231 | */ | |
232 | /*! |
|
232 | /*! | |
233 | \qmlsignal AbstractAxis::onShadesVisibleChanged(bool visible) |
|
233 | \qmlsignal AbstractAxis::onShadesVisibleChanged(bool visible) | |
234 | Emitted if the visibility of the axis shades is changed to \a visible. |
|
234 | Emitted if the visibility of the axis shades is changed to \a visible. | |
235 | */ |
|
235 | */ | |
236 |
|
236 | |||
237 | /*! |
|
237 | /*! | |
238 | \fn void QAbstractAxis::shadesColorChanged(QColor color) |
|
238 | \fn void QAbstractAxis::shadesColorChanged(QColor color) | |
239 | Emitted if the \a color of the axis shades is changed. |
|
239 | Emitted if the \a color of the axis shades is changed. | |
240 | */ |
|
240 | */ | |
241 | /*! |
|
241 | /*! | |
242 | \qmlsignal AbstractAxis::onShadesColorChanged(QColor color) |
|
242 | \qmlsignal AbstractAxis::onShadesColorChanged(QColor color) | |
243 | Emitted if the \a color of the axis shades is changed. |
|
243 | Emitted if the \a color of the axis shades is changed. | |
244 | */ |
|
244 | */ | |
245 |
|
245 | |||
246 | /*! |
|
246 | /*! | |
247 | \fn void QAbstractAxis::shadesBorderColorChanged(QColor) |
|
247 | \fn void QAbstractAxis::shadesBorderColorChanged(QColor) | |
248 | Emitted if the border \a color of the axis shades is changed. |
|
248 | Emitted if the border \a color of the axis shades is changed. | |
249 | */ |
|
249 | */ | |
250 | /*! |
|
250 | /*! | |
251 | \qmlsignal AbstractAxis::onBorderColorChanged(QColor color) |
|
251 | \qmlsignal AbstractAxis::onBorderColorChanged(QColor color) | |
252 | Emitted if the border \a color of the axis shades is changed. |
|
252 | Emitted if the border \a color of the axis shades is changed. | |
253 | */ |
|
253 | */ | |
254 |
|
254 | |||
255 | /*! |
|
255 | /*! | |
256 | \internal |
|
256 | \internal | |
257 | Constructs new axis object which is a child of \a parent. Ownership is taken by |
|
257 | Constructs new axis object which is a child of \a parent. Ownership is taken by | |
258 | QChart when axis added. |
|
258 | QChart when axis added. | |
259 | */ |
|
259 | */ | |
260 |
|
260 | |||
261 | QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) : |
|
261 | QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) : | |
262 | QObject(parent), |
|
262 | QObject(parent), | |
263 | d_ptr(&d) |
|
263 | d_ptr(&d) | |
264 | { |
|
264 | { | |
265 | } |
|
265 | } | |
266 |
|
266 | |||
267 | /*! |
|
267 | /*! | |
268 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. |
|
268 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. | |
269 | */ |
|
269 | */ | |
270 |
|
270 | |||
271 | QAbstractAxis::~QAbstractAxis() |
|
271 | QAbstractAxis::~QAbstractAxis() | |
272 | { |
|
272 | { | |
|
273 | if(d_ptr->m_dataset) qFatal("Still binded axis detected !"); | |||
273 | } |
|
274 | } | |
274 |
|
275 | |||
275 | /*! |
|
276 | /*! | |
276 | Sets \a pen used to draw axis line and ticks. |
|
277 | Sets \a pen used to draw axis line and ticks. | |
277 | */ |
|
278 | */ | |
278 | void QAbstractAxis::setAxisPen(const QPen &pen) |
|
279 | void QAbstractAxis::setAxisPen(const QPen &pen) | |
279 | { |
|
280 | { | |
280 | if (d_ptr->m_axisPen!=pen) { |
|
281 | if (d_ptr->m_axisPen!=pen) { | |
281 | d_ptr->m_axisPen = pen; |
|
282 | d_ptr->m_axisPen = pen; | |
282 | d_ptr->emitUpdated(); |
|
283 | d_ptr->emitUpdated(); | |
283 | } |
|
284 | } | |
284 | } |
|
285 | } | |
285 |
|
286 | |||
286 | /*! |
|
287 | /*! | |
287 | Returns pen used to draw axis and ticks. |
|
288 | Returns pen used to draw axis and ticks. | |
288 | */ |
|
289 | */ | |
289 | QPen QAbstractAxis::axisPen() const |
|
290 | QPen QAbstractAxis::axisPen() const | |
290 | { |
|
291 | { | |
291 | return d_ptr->m_axisPen; |
|
292 | return d_ptr->m_axisPen; | |
292 | } |
|
293 | } | |
293 |
|
294 | |||
294 | void QAbstractAxis::setAxisPenColor(QColor color) |
|
295 | void QAbstractAxis::setAxisPenColor(QColor color) | |
295 | { |
|
296 | { | |
296 | QPen p = d_ptr->m_axisPen; |
|
297 | QPen p = d_ptr->m_axisPen; | |
297 | if (p.color() != color) { |
|
298 | if (p.color() != color) { | |
298 | p.setColor(color); |
|
299 | p.setColor(color); | |
299 | setAxisPen(p); |
|
300 | setAxisPen(p); | |
300 | emit colorChanged(color); |
|
301 | emit colorChanged(color); | |
301 | } |
|
302 | } | |
302 | } |
|
303 | } | |
303 |
|
304 | |||
304 | QColor QAbstractAxis::axisPenColor() const |
|
305 | QColor QAbstractAxis::axisPenColor() const | |
305 | { |
|
306 | { | |
306 | return d_ptr->m_axisPen.color(); |
|
307 | return d_ptr->m_axisPen.color(); | |
307 | } |
|
308 | } | |
308 |
|
309 | |||
309 | /*! |
|
310 | /*! | |
310 | Sets if axis and ticks are \a visible. |
|
311 | Sets if axis and ticks are \a visible. | |
311 | */ |
|
312 | */ | |
312 | void QAbstractAxis::setArrowVisible(bool visible) |
|
313 | void QAbstractAxis::setArrowVisible(bool visible) | |
313 | { |
|
314 | { | |
314 | if (d_ptr->m_arrowVisible != visible) { |
|
315 | if (d_ptr->m_arrowVisible != visible) { | |
315 | d_ptr->m_arrowVisible = visible; |
|
316 | d_ptr->m_arrowVisible = visible; | |
316 | d_ptr->emitUpdated(); |
|
317 | d_ptr->emitUpdated(); | |
317 | emit arrowVisibleChanged(visible); |
|
318 | emit arrowVisibleChanged(visible); | |
318 | } |
|
319 | } | |
319 | } |
|
320 | } | |
320 |
|
321 | |||
321 | bool QAbstractAxis::isArrowVisible() const |
|
322 | bool QAbstractAxis::isArrowVisible() const | |
322 | { |
|
323 | { | |
323 | return d_ptr->m_arrowVisible; |
|
324 | return d_ptr->m_arrowVisible; | |
324 | } |
|
325 | } | |
325 |
|
326 | |||
326 | void QAbstractAxis::setGridLineVisible(bool visible) |
|
327 | void QAbstractAxis::setGridLineVisible(bool visible) | |
327 | { |
|
328 | { | |
328 | if (d_ptr->m_gridLineVisible != visible) { |
|
329 | if (d_ptr->m_gridLineVisible != visible) { | |
329 | d_ptr->m_gridLineVisible = visible; |
|
330 | d_ptr->m_gridLineVisible = visible; | |
330 | d_ptr->emitUpdated(); |
|
331 | d_ptr->emitUpdated(); | |
331 | emit gridVisibleChanged(visible); |
|
332 | emit gridVisibleChanged(visible); | |
332 | } |
|
333 | } | |
333 | } |
|
334 | } | |
334 |
|
335 | |||
335 | bool QAbstractAxis::isGridLineVisible() const |
|
336 | bool QAbstractAxis::isGridLineVisible() const | |
336 | { |
|
337 | { | |
337 | return d_ptr->m_gridLineVisible; |
|
338 | return d_ptr->m_gridLineVisible; | |
338 | } |
|
339 | } | |
339 |
|
340 | |||
340 | /*! |
|
341 | /*! | |
341 | Sets \a pen used to draw grid line. |
|
342 | Sets \a pen used to draw grid line. | |
342 | */ |
|
343 | */ | |
343 | void QAbstractAxis::setGridLinePen(const QPen &pen) |
|
344 | void QAbstractAxis::setGridLinePen(const QPen &pen) | |
344 | { |
|
345 | { | |
345 | if (d_ptr->m_gridLinePen != pen) { |
|
346 | if (d_ptr->m_gridLinePen != pen) { | |
346 | d_ptr->m_gridLinePen = pen; |
|
347 | d_ptr->m_gridLinePen = pen; | |
347 | d_ptr->emitUpdated(); |
|
348 | d_ptr->emitUpdated(); | |
348 | } |
|
349 | } | |
349 | } |
|
350 | } | |
350 |
|
351 | |||
351 | /*! |
|
352 | /*! | |
352 | Returns pen used to draw grid. |
|
353 | Returns pen used to draw grid. | |
353 | */ |
|
354 | */ | |
354 | QPen QAbstractAxis::gridLinePen() const |
|
355 | QPen QAbstractAxis::gridLinePen() const | |
355 | { |
|
356 | { | |
356 | return d_ptr->m_gridLinePen; |
|
357 | return d_ptr->m_gridLinePen; | |
357 | } |
|
358 | } | |
358 |
|
359 | |||
359 | void QAbstractAxis::setLabelsVisible(bool visible) |
|
360 | void QAbstractAxis::setLabelsVisible(bool visible) | |
360 | { |
|
361 | { | |
361 | if (d_ptr->m_labelsVisible != visible) { |
|
362 | if (d_ptr->m_labelsVisible != visible) { | |
362 | d_ptr->m_labelsVisible = visible; |
|
363 | d_ptr->m_labelsVisible = visible; | |
363 | d_ptr->emitUpdated(); |
|
364 | d_ptr->emitUpdated(); | |
364 | emit labelsVisibleChanged(visible); |
|
365 | emit labelsVisibleChanged(visible); | |
365 | } |
|
366 | } | |
366 | } |
|
367 | } | |
367 |
|
368 | |||
368 | bool QAbstractAxis::labelsVisible() const |
|
369 | bool QAbstractAxis::labelsVisible() const | |
369 | { |
|
370 | { | |
370 | return d_ptr->m_labelsVisible; |
|
371 | return d_ptr->m_labelsVisible; | |
371 | } |
|
372 | } | |
372 |
|
373 | |||
373 | /*! |
|
374 | /*! | |
374 | Sets \a pen used to draw labels. |
|
375 | Sets \a pen used to draw labels. | |
375 | */ |
|
376 | */ | |
376 | void QAbstractAxis::setLabelsPen(const QPen &pen) |
|
377 | void QAbstractAxis::setLabelsPen(const QPen &pen) | |
377 | { |
|
378 | { | |
378 | if (d_ptr->m_labelsPen != pen) { |
|
379 | if (d_ptr->m_labelsPen != pen) { | |
379 | d_ptr->m_labelsPen = pen; |
|
380 | d_ptr->m_labelsPen = pen; | |
380 | d_ptr->emitUpdated(); |
|
381 | d_ptr->emitUpdated(); | |
381 | } |
|
382 | } | |
382 | } |
|
383 | } | |
383 |
|
384 | |||
384 | /*! |
|
385 | /*! | |
385 | Returns the pen used to labels. |
|
386 | Returns the pen used to labels. | |
386 | */ |
|
387 | */ | |
387 | QPen QAbstractAxis::labelsPen() const |
|
388 | QPen QAbstractAxis::labelsPen() const | |
388 | { |
|
389 | { | |
389 | return d_ptr->m_labelsPen; |
|
390 | return d_ptr->m_labelsPen; | |
390 | } |
|
391 | } | |
391 |
|
392 | |||
392 | /*! |
|
393 | /*! | |
393 | Sets \a brush used to draw labels. |
|
394 | Sets \a brush used to draw labels. | |
394 | */ |
|
395 | */ | |
395 | void QAbstractAxis::setLabelsBrush(const QBrush &brush) |
|
396 | void QAbstractAxis::setLabelsBrush(const QBrush &brush) | |
396 | { |
|
397 | { | |
397 | if (d_ptr->m_labelsBrush != brush) { |
|
398 | if (d_ptr->m_labelsBrush != brush) { | |
398 | d_ptr->m_labelsBrush = brush; |
|
399 | d_ptr->m_labelsBrush = brush; | |
399 | d_ptr->emitUpdated(); |
|
400 | d_ptr->emitUpdated(); | |
400 | } |
|
401 | } | |
401 | } |
|
402 | } | |
402 |
|
403 | |||
403 | /*! |
|
404 | /*! | |
404 | Returns brush used to draw labels. |
|
405 | Returns brush used to draw labels. | |
405 | */ |
|
406 | */ | |
406 | QBrush QAbstractAxis::labelsBrush() const |
|
407 | QBrush QAbstractAxis::labelsBrush() const | |
407 | { |
|
408 | { | |
408 | return d_ptr->m_labelsBrush; |
|
409 | return d_ptr->m_labelsBrush; | |
409 | } |
|
410 | } | |
410 |
|
411 | |||
411 | /*! |
|
412 | /*! | |
412 | Sets \a font used to draw labels. |
|
413 | Sets \a font used to draw labels. | |
413 | */ |
|
414 | */ | |
414 | void QAbstractAxis::setLabelsFont(const QFont &font) |
|
415 | void QAbstractAxis::setLabelsFont(const QFont &font) | |
415 | { |
|
416 | { | |
416 | if (d_ptr->m_labelsFont != font) { |
|
417 | if (d_ptr->m_labelsFont != font) { | |
417 | d_ptr->m_labelsFont = font; |
|
418 | d_ptr->m_labelsFont = font; | |
418 | d_ptr->emitUpdated(); |
|
419 | d_ptr->emitUpdated(); | |
419 | } |
|
420 | } | |
420 | } |
|
421 | } | |
421 |
|
422 | |||
422 | /*! |
|
423 | /*! | |
423 | Returns font used to draw labels. |
|
424 | Returns font used to draw labels. | |
424 | */ |
|
425 | */ | |
425 | QFont QAbstractAxis::labelsFont() const |
|
426 | QFont QAbstractAxis::labelsFont() const | |
426 | { |
|
427 | { | |
427 | return d_ptr->m_labelsFont; |
|
428 | return d_ptr->m_labelsFont; | |
428 | } |
|
429 | } | |
429 |
|
430 | |||
430 | void QAbstractAxis::setLabelsAngle(int angle) |
|
431 | void QAbstractAxis::setLabelsAngle(int angle) | |
431 | { |
|
432 | { | |
432 | if (d_ptr->m_labelsAngle != angle) { |
|
433 | if (d_ptr->m_labelsAngle != angle) { | |
433 | d_ptr->m_labelsAngle = angle; |
|
434 | d_ptr->m_labelsAngle = angle; | |
434 | d_ptr->emitUpdated(); |
|
435 | d_ptr->emitUpdated(); | |
435 | } |
|
436 | } | |
436 | } |
|
437 | } | |
437 |
|
438 | |||
438 | int QAbstractAxis::labelsAngle() const |
|
439 | int QAbstractAxis::labelsAngle() const | |
439 | { |
|
440 | { | |
440 | return d_ptr->m_labelsAngle; |
|
441 | return d_ptr->m_labelsAngle; | |
441 | } |
|
442 | } | |
442 |
|
443 | |||
443 | void QAbstractAxis::setLabelsColor(QColor color) |
|
444 | void QAbstractAxis::setLabelsColor(QColor color) | |
444 | { |
|
445 | { | |
445 | QBrush b = d_ptr->m_labelsBrush; |
|
446 | QBrush b = d_ptr->m_labelsBrush; | |
446 | if (b.color() != color) { |
|
447 | if (b.color() != color) { | |
447 | b.setColor(color); |
|
448 | b.setColor(color); | |
448 | setLabelsBrush(b); |
|
449 | setLabelsBrush(b); | |
449 | emit labelsColorChanged(color); |
|
450 | emit labelsColorChanged(color); | |
450 | } |
|
451 | } | |
451 | } |
|
452 | } | |
452 |
|
453 | |||
453 | QColor QAbstractAxis::labelsColor() const |
|
454 | QColor QAbstractAxis::labelsColor() const | |
454 | { |
|
455 | { | |
455 | return d_ptr->m_labelsBrush.color(); |
|
456 | return d_ptr->m_labelsBrush.color(); | |
456 | } |
|
457 | } | |
457 |
|
458 | |||
458 | void QAbstractAxis::setShadesVisible(bool visible) |
|
459 | void QAbstractAxis::setShadesVisible(bool visible) | |
459 | { |
|
460 | { | |
460 | if (d_ptr->m_shadesVisible != visible) { |
|
461 | if (d_ptr->m_shadesVisible != visible) { | |
461 | d_ptr->m_shadesVisible = visible; |
|
462 | d_ptr->m_shadesVisible = visible; | |
462 | d_ptr->emitUpdated(); |
|
463 | d_ptr->emitUpdated(); | |
463 | emit shadesVisibleChanged(visible); |
|
464 | emit shadesVisibleChanged(visible); | |
464 | } |
|
465 | } | |
465 | } |
|
466 | } | |
466 |
|
467 | |||
467 | bool QAbstractAxis::shadesVisible() const |
|
468 | bool QAbstractAxis::shadesVisible() const | |
468 | { |
|
469 | { | |
469 | return d_ptr->m_shadesVisible; |
|
470 | return d_ptr->m_shadesVisible; | |
470 | } |
|
471 | } | |
471 |
|
472 | |||
472 | /*! |
|
473 | /*! | |
473 | Sets \a pen used to draw shades. |
|
474 | Sets \a pen used to draw shades. | |
474 | */ |
|
475 | */ | |
475 | void QAbstractAxis::setShadesPen(const QPen &pen) |
|
476 | void QAbstractAxis::setShadesPen(const QPen &pen) | |
476 | { |
|
477 | { | |
477 | if (d_ptr->m_shadesPen != pen) { |
|
478 | if (d_ptr->m_shadesPen != pen) { | |
478 | d_ptr->m_shadesPen = pen; |
|
479 | d_ptr->m_shadesPen = pen; | |
479 | d_ptr->emitUpdated(); |
|
480 | d_ptr->emitUpdated(); | |
480 | } |
|
481 | } | |
481 | } |
|
482 | } | |
482 |
|
483 | |||
483 | /*! |
|
484 | /*! | |
484 | Returns pen used to draw shades. |
|
485 | Returns pen used to draw shades. | |
485 | */ |
|
486 | */ | |
486 | QPen QAbstractAxis::shadesPen() const |
|
487 | QPen QAbstractAxis::shadesPen() const | |
487 | { |
|
488 | { | |
488 | return d_ptr->m_shadesPen; |
|
489 | return d_ptr->m_shadesPen; | |
489 | } |
|
490 | } | |
490 |
|
491 | |||
491 | /*! |
|
492 | /*! | |
492 | Sets \a brush used to draw shades. |
|
493 | Sets \a brush used to draw shades. | |
493 | */ |
|
494 | */ | |
494 | void QAbstractAxis::setShadesBrush(const QBrush &brush) |
|
495 | void QAbstractAxis::setShadesBrush(const QBrush &brush) | |
495 | { |
|
496 | { | |
496 | if (d_ptr->m_shadesBrush != brush) { |
|
497 | if (d_ptr->m_shadesBrush != brush) { | |
497 | d_ptr->m_shadesBrush = brush; |
|
498 | d_ptr->m_shadesBrush = brush; | |
498 | d_ptr->emitUpdated(); |
|
499 | d_ptr->emitUpdated(); | |
499 | emit shadesColorChanged(brush.color()); |
|
500 | emit shadesColorChanged(brush.color()); | |
500 | } |
|
501 | } | |
501 | } |
|
502 | } | |
502 |
|
503 | |||
503 | /*! |
|
504 | /*! | |
504 | Returns brush used to draw shades. |
|
505 | Returns brush used to draw shades. | |
505 | */ |
|
506 | */ | |
506 | QBrush QAbstractAxis::shadesBrush() const |
|
507 | QBrush QAbstractAxis::shadesBrush() const | |
507 | { |
|
508 | { | |
508 | return d_ptr->m_shadesBrush; |
|
509 | return d_ptr->m_shadesBrush; | |
509 | } |
|
510 | } | |
510 |
|
511 | |||
511 | void QAbstractAxis::setShadesColor(QColor color) |
|
512 | void QAbstractAxis::setShadesColor(QColor color) | |
512 | { |
|
513 | { | |
513 | QBrush b = d_ptr->m_shadesBrush; |
|
514 | QBrush b = d_ptr->m_shadesBrush; | |
514 | b.setColor(color); |
|
515 | b.setColor(color); | |
515 | setShadesBrush(b); |
|
516 | setShadesBrush(b); | |
516 | } |
|
517 | } | |
517 |
|
518 | |||
518 | QColor QAbstractAxis::shadesColor() const |
|
519 | QColor QAbstractAxis::shadesColor() const | |
519 | { |
|
520 | { | |
520 | return d_ptr->m_shadesBrush.color(); |
|
521 | return d_ptr->m_shadesBrush.color(); | |
521 | } |
|
522 | } | |
522 |
|
523 | |||
523 | void QAbstractAxis::setShadesBorderColor(QColor color) |
|
524 | void QAbstractAxis::setShadesBorderColor(QColor color) | |
524 | { |
|
525 | { | |
525 | QPen p = d_ptr->m_shadesPen; |
|
526 | QPen p = d_ptr->m_shadesPen; | |
526 | p.setColor(color); |
|
527 | p.setColor(color); | |
527 | setShadesPen(p); |
|
528 | setShadesPen(p); | |
528 | } |
|
529 | } | |
529 |
|
530 | |||
530 | QColor QAbstractAxis::shadesBorderColor() const |
|
531 | QColor QAbstractAxis::shadesBorderColor() const | |
531 | { |
|
532 | { | |
532 | return d_ptr->m_shadesPen.color(); |
|
533 | return d_ptr->m_shadesPen.color(); | |
533 | } |
|
534 | } | |
534 |
|
535 | |||
535 |
|
536 | |||
536 | bool QAbstractAxis::isVisible() const |
|
537 | bool QAbstractAxis::isVisible() const | |
537 | { |
|
538 | { | |
538 | return d_ptr->m_visible; |
|
539 | return d_ptr->m_visible; | |
539 | } |
|
540 | } | |
540 |
|
541 | |||
541 | /*! |
|
542 | /*! | |
542 | Sets axis, shades, labels and grid lines to be visible. |
|
543 | Sets axis, shades, labels and grid lines to be visible. | |
543 | */ |
|
544 | */ | |
544 | void QAbstractAxis::setVisible(bool visible) |
|
545 | void QAbstractAxis::setVisible(bool visible) | |
545 | { |
|
546 | { | |
546 | if(d_ptr->m_visible!=visible){ |
|
547 | if(d_ptr->m_visible!=visible){ | |
547 | d_ptr->m_visible=visible; |
|
548 | d_ptr->m_visible=visible; | |
548 | d_ptr->emitUpdated(); |
|
549 | d_ptr->emitUpdated(); | |
549 | emit visibleChanged(visible); |
|
550 | emit visibleChanged(visible); | |
550 | } |
|
551 | } | |
551 | } |
|
552 | } | |
552 |
|
553 | |||
553 |
|
554 | |||
554 | /*! |
|
555 | /*! | |
555 | Sets axis, shades, labels and grid lines to be visible. |
|
556 | Sets axis, shades, labels and grid lines to be visible. | |
556 | */ |
|
557 | */ | |
557 | void QAbstractAxis::show() |
|
558 | void QAbstractAxis::show() | |
558 | { |
|
559 | { | |
559 | setVisible(true); |
|
560 | setVisible(true); | |
560 | } |
|
561 | } | |
561 |
|
562 | |||
562 | /*! |
|
563 | /*! | |
563 | Sets axis, shades, labels and grid lines to not be visible. |
|
564 | Sets axis, shades, labels and grid lines to not be visible. | |
564 | */ |
|
565 | */ | |
565 | void QAbstractAxis::hide() |
|
566 | void QAbstractAxis::hide() | |
566 | { |
|
567 | { | |
567 | setVisible(false); |
|
568 | setVisible(false); | |
568 | } |
|
569 | } | |
569 |
|
570 | |||
570 | /*! |
|
571 | /*! | |
571 | Sets the minimum value shown on the axis. |
|
572 | Sets the minimum value shown on the axis. | |
572 | Depending on the actual axis type the \a min paramter is converted to appropriate type. |
|
573 | Depending on the actual axis type the \a min paramter is converted to appropriate type. | |
573 | If the conversion is impossible then the function call does nothing |
|
574 | If the conversion is impossible then the function call does nothing | |
574 | */ |
|
575 | */ | |
575 | void QAbstractAxis::setMin(const QVariant &min) |
|
576 | void QAbstractAxis::setMin(const QVariant &min) | |
576 | { |
|
577 | { | |
577 | d_ptr->setMin(min); |
|
578 | d_ptr->setMin(min); | |
578 | } |
|
579 | } | |
579 |
|
580 | |||
580 | /*! |
|
581 | /*! | |
581 | Sets the maximum value shown on the axis. |
|
582 | Sets the maximum value shown on the axis. | |
582 | Depending on the actual axis type the \a max paramter is converted to appropriate type. |
|
583 | Depending on the actual axis type the \a max paramter is converted to appropriate type. | |
583 | If the conversion is impossible then the function call does nothing |
|
584 | If the conversion is impossible then the function call does nothing | |
584 | */ |
|
585 | */ | |
585 | void QAbstractAxis::setMax(const QVariant &max) |
|
586 | void QAbstractAxis::setMax(const QVariant &max) | |
586 | { |
|
587 | { | |
587 | d_ptr->setMax(max); |
|
588 | d_ptr->setMax(max); | |
588 | } |
|
589 | } | |
589 |
|
590 | |||
590 | /*! |
|
591 | /*! | |
591 | Sets the range shown on the axis. |
|
592 | Sets the range shown on the axis. | |
592 | Depending on the actual axis type the \a min and \a max paramters are converted to appropriate types. |
|
593 | Depending on the actual axis type the \a min and \a max paramters are converted to appropriate types. | |
593 | If the conversion is impossible then the function call does nothing. |
|
594 | If the conversion is impossible then the function call does nothing. | |
594 | */ |
|
595 | */ | |
595 | void QAbstractAxis::setRange(const QVariant &min, const QVariant &max) |
|
596 | void QAbstractAxis::setRange(const QVariant &min, const QVariant &max) | |
596 | { |
|
597 | { | |
597 | d_ptr->setRange(min,max); |
|
598 | d_ptr->setRange(min,max); | |
598 | } |
|
599 | } | |
599 |
|
600 | |||
600 |
|
601 | |||
601 | Qt::Orientation QAbstractAxis::orientation() |
|
602 | Qt::Orientation QAbstractAxis::orientation() | |
602 | { |
|
603 | { | |
603 | return d_ptr->m_orientation; |
|
604 | return d_ptr->m_orientation; | |
604 | } |
|
605 | } | |
605 |
|
606 | |||
606 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
607 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
607 |
|
608 | |||
608 | QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q): |
|
609 | QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q): | |
609 | q_ptr(q), |
|
610 | q_ptr(q), | |
610 | m_orientation(Qt::Orientation(0)), |
|
611 | m_orientation(Qt::Orientation(0)), | |
|
612 | m_dataset(0), | |||
611 | m_visible(false), |
|
613 | m_visible(false), | |
612 | m_arrowVisible(true), |
|
614 | m_arrowVisible(true), | |
613 | m_gridLineVisible(true), |
|
615 | m_gridLineVisible(true), | |
614 | m_labelsVisible(true), |
|
616 | m_labelsVisible(true), | |
615 | m_labelsAngle(0), |
|
617 | m_labelsAngle(0), | |
616 | m_shadesVisible(false), |
|
618 | m_shadesVisible(false), | |
617 | m_shadesBrush(Qt::SolidPattern), |
|
619 | m_shadesBrush(Qt::SolidPattern), | |
618 | m_shadesOpacity(1.0), |
|
620 | m_shadesOpacity(1.0), | |
619 | m_dirty(false) |
|
621 | m_dirty(false) | |
620 | { |
|
622 | { | |
621 |
|
623 | |||
622 | } |
|
624 | } | |
623 |
|
625 | |||
624 | QAbstractAxisPrivate::~QAbstractAxisPrivate() |
|
626 | QAbstractAxisPrivate::~QAbstractAxisPrivate() | |
625 | { |
|
627 | { | |
626 |
|
628 | |||
627 | } |
|
629 | } | |
628 |
|
630 | |||
629 | void QAbstractAxisPrivate::emitUpdated() |
|
631 | void QAbstractAxisPrivate::emitUpdated() | |
630 | { |
|
632 | { | |
631 | if(!m_dirty){ |
|
633 | if(!m_dirty){ | |
632 | m_dirty=true; |
|
634 | m_dirty=true; | |
633 | emit updated(); |
|
635 | emit updated(); | |
634 | } |
|
636 | } | |
635 | } |
|
637 | } | |
636 |
|
638 | |||
637 | void QAbstractAxisPrivate::setDirty(bool dirty) |
|
639 | void QAbstractAxisPrivate::setDirty(bool dirty) | |
638 | { |
|
640 | { | |
639 | m_dirty=dirty; |
|
641 | m_dirty=dirty; | |
640 | } |
|
642 | } | |
641 |
|
643 | |||
642 | void QAbstractAxisPrivate::setOrientation(Qt::Orientation orientation) |
|
644 | void QAbstractAxisPrivate::setOrientation(Qt::Orientation orientation) | |
643 | { |
|
645 | { | |
644 | m_orientation=orientation; |
|
646 | m_orientation=orientation; | |
645 | } |
|
647 | } | |
646 |
|
648 | |||
647 |
|
649 | |||
648 | #include "moc_qabstractaxis.cpp" |
|
650 | #include "moc_qabstractaxis.cpp" | |
649 | #include "moc_qabstractaxis_p.cpp" |
|
651 | #include "moc_qabstractaxis_p.cpp" | |
650 |
|
652 | |||
651 | QTCOMMERCIALCHART_END_NAMESPACE |
|
653 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,105 +1,110 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef QABSTRACTAXIS_P_H |
|
30 | #ifndef QABSTRACTAXIS_P_H | |
31 | #define QABSTRACTAXIS_P_H |
|
31 | #define QABSTRACTAXIS_P_H | |
32 |
|
32 | |||
33 | #include "qabstractaxis.h" |
|
33 | #include "qabstractaxis.h" | |
34 |
|
34 | |||
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class ChartPresenter; |
|
37 | class ChartPresenter; | |
38 | class ChartAxis; |
|
38 | class ChartAxis; | |
39 | class Domain; |
|
39 | class Domain; | |
|
40 | class ChartDataSet; | |||
40 |
|
41 | |||
41 | class QTCOMMERCIALCHART_AUTOTEST_EXPORT QAbstractAxisPrivate : public QObject |
|
42 | class QTCOMMERCIALCHART_AUTOTEST_EXPORT QAbstractAxisPrivate : public QObject | |
42 | { |
|
43 | { | |
43 | Q_OBJECT |
|
44 | Q_OBJECT | |
44 | public: |
|
45 | public: | |
45 | QAbstractAxisPrivate(QAbstractAxis *q); |
|
46 | QAbstractAxisPrivate(QAbstractAxis *q); | |
46 | ~QAbstractAxisPrivate(); |
|
47 | ~QAbstractAxisPrivate(); | |
47 |
|
48 | |||
48 | public: |
|
49 | public: | |
49 |
|
50 | |||
50 | virtual ChartAxis* createGraphics(ChartPresenter* presenter) = 0; |
|
51 | virtual ChartAxis* createGraphics(ChartPresenter* presenter) = 0; | |
51 | virtual void intializeDomain(Domain* domain) = 0; |
|
52 | virtual void intializeDomain(Domain* domain) = 0; | |
52 |
|
53 | |||
53 | void emitUpdated(); |
|
54 | void emitUpdated(); | |
54 | void setDirty(bool dirty); |
|
55 | void setDirty(bool dirty); | |
55 | bool isDirty(){ return m_dirty; }; |
|
56 | bool isDirty(){ return m_dirty; }; | |
56 | void setOrientation(Qt::Orientation orientation); |
|
57 | void setOrientation(Qt::Orientation orientation); | |
57 | Qt::Orientation orientation() const { return m_orientation; } |
|
58 | Qt::Orientation orientation() const { return m_orientation; } | |
58 |
|
59 | |||
59 | virtual void setMin(const QVariant &min) = 0; |
|
60 | virtual void setMin(const QVariant &min) = 0; | |
60 | virtual qreal min() = 0; |
|
61 | virtual qreal min() = 0; | |
61 |
|
62 | |||
62 | virtual void setMax(const QVariant &max) = 0; |
|
63 | virtual void setMax(const QVariant &max) = 0; | |
63 | virtual qreal max() = 0; |
|
64 | virtual qreal max() = 0; | |
64 |
|
65 | |||
|
66 | virtual int count() const = 0; | |||
|
67 | ||||
65 | virtual void setRange(const QVariant &min, const QVariant &max) = 0; |
|
68 | virtual void setRange(const QVariant &min, const QVariant &max) = 0; | |
66 |
|
69 | |||
67 | public Q_SLOTS: |
|
70 | public Q_SLOTS: | |
68 | virtual void handleDomainUpdated() = 0; |
|
71 | virtual void handleDomainUpdated() = 0; | |
69 |
|
72 | |||
70 | Q_SIGNALS: |
|
73 | Q_SIGNALS: | |
71 | void updated(); |
|
74 | void updated(); | |
72 |
|
75 | |||
73 | protected: |
|
76 | protected: | |
74 | QAbstractAxis *q_ptr; |
|
77 | QAbstractAxis *q_ptr; | |
75 | Qt::Orientation m_orientation; |
|
78 | Qt::Orientation m_orientation; | |
|
79 | ChartDataSet *m_dataset; | |||
76 |
|
80 | |||
77 | private: |
|
81 | private: | |
78 | bool m_visible; |
|
82 | bool m_visible; | |
79 |
|
83 | |||
80 | bool m_arrowVisible; |
|
84 | bool m_arrowVisible; | |
81 | QPen m_axisPen; |
|
85 | QPen m_axisPen; | |
82 | QBrush m_axisBrush; |
|
86 | QBrush m_axisBrush; | |
83 |
|
87 | |||
84 | bool m_gridLineVisible; |
|
88 | bool m_gridLineVisible; | |
85 | QPen m_gridLinePen; |
|
89 | QPen m_gridLinePen; | |
86 |
|
90 | |||
87 | bool m_labelsVisible; |
|
91 | bool m_labelsVisible; | |
88 | QPen m_labelsPen; |
|
92 | QPen m_labelsPen; | |
89 | QBrush m_labelsBrush; |
|
93 | QBrush m_labelsBrush; | |
90 | QFont m_labelsFont; |
|
94 | QFont m_labelsFont; | |
91 | int m_labelsAngle; |
|
95 | int m_labelsAngle; | |
92 |
|
96 | |||
93 | bool m_shadesVisible; |
|
97 | bool m_shadesVisible; | |
94 | QPen m_shadesPen; |
|
98 | QPen m_shadesPen; | |
95 | QBrush m_shadesBrush; |
|
99 | QBrush m_shadesBrush; | |
96 | qreal m_shadesOpacity; |
|
100 | qreal m_shadesOpacity; | |
97 |
|
101 | |||
98 | bool m_dirty; |
|
102 | bool m_dirty; | |
99 |
|
103 | |||
100 | friend class QAbstractAxis; |
|
104 | friend class QAbstractAxis; | |
|
105 | friend class ChartDataSet; | |||
101 | }; |
|
106 | }; | |
102 |
|
107 | |||
103 | QTCOMMERCIALCHART_END_NAMESPACE |
|
108 | QTCOMMERCIALCHART_END_NAMESPACE | |
104 |
|
109 | |||
105 | #endif |
|
110 | #endif |
@@ -1,367 +1,373 | |||||
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 "qvaluesaxis.h" |
|
21 | #include "qvaluesaxis.h" | |
22 | #include "qvaluesaxis_p.h" |
|
22 | #include "qvaluesaxis_p.h" | |
23 | #include "chartvaluesaxisx_p.h" |
|
23 | #include "chartvaluesaxisx_p.h" | |
24 | #include "chartvaluesaxisy_p.h" |
|
24 | #include "chartvaluesaxisy_p.h" | |
25 | #include "domain_p.h" |
|
25 | #include "domain_p.h" | |
26 |
#include |
|
26 | #include "chartdataset_p.h" | |
27 |
#include < |
|
27 | #include <qmath.h> | |
|
28 | ||||
28 |
|
29 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 | /*! |
|
31 | /*! | |
31 | \class QValuesAxis |
|
32 | \class QValuesAxis | |
32 | \brief The QValuesAxis class is used for manipulating chart's axis. |
|
33 | \brief The QValuesAxis class is used for manipulating chart's axis. | |
33 | \mainclass |
|
34 | \mainclass | |
34 |
|
35 | |||
35 | ValuesAxis can be setup to show axis line with tick marks, grid lines and shades. |
|
36 | ValuesAxis can be setup to show axis line with tick marks, grid lines and shades. | |
36 | Values of axis are drawn to position of ticks |
|
37 | Values of axis are drawn to position of ticks | |
37 | */ |
|
38 | */ | |
38 |
|
39 | |||
39 | /*! |
|
40 | /*! | |
40 | \qmlclass ValuesAxis QValuesAxis |
|
41 | \qmlclass ValuesAxis QValuesAxis | |
41 | \brief The ValuesAxis element is used for manipulating chart's axes |
|
42 | \brief The ValuesAxis element is used for manipulating chart's axes | |
42 |
|
43 | |||
43 | ValueAxis can be setup to show axis line with tick marks, grid lines and shades. |
|
44 | ValueAxis can be setup to show axis line with tick marks, grid lines and shades. | |
44 | Values of axis are drawn to position of ticks |
|
45 | Values of axis are drawn to position of ticks | |
45 |
|
46 | |||
46 | To access Axes you can use ChartView API. For example: |
|
47 | To access Axes you can use ChartView API. For example: | |
47 | \code |
|
48 | \code | |
48 | ChartView { |
|
49 | ChartView { | |
49 | ValuesAxis { |
|
50 | ValuesAxis { | |
50 | id: xAxis |
|
51 | id: xAxis | |
51 | min: 0 |
|
52 | min: 0 | |
52 | max: 10 |
|
53 | max: 10 | |
53 | } |
|
54 | } | |
54 | // Add a few series... |
|
55 | // Add a few series... | |
55 | } |
|
56 | } | |
56 | \endcode |
|
57 | \endcode | |
57 | */ |
|
58 | */ | |
58 |
|
59 | |||
59 | /*! |
|
60 | /*! | |
60 | \property QValuesAxis::min |
|
61 | \property QValuesAxis::min | |
61 | Defines the minimum value on the axis. |
|
62 | Defines the minimum value on the axis. | |
62 | */ |
|
63 | */ | |
63 | /*! |
|
64 | /*! | |
64 | \qmlproperty real ValuesAxis::min |
|
65 | \qmlproperty real ValuesAxis::min | |
65 | Defines the minimum value on the axis. |
|
66 | Defines the minimum value on the axis. | |
66 | */ |
|
67 | */ | |
67 |
|
68 | |||
68 | /*! |
|
69 | /*! | |
69 | \property QValuesAxis::max |
|
70 | \property QValuesAxis::max | |
70 | Defines the maximum value on the axis. |
|
71 | Defines the maximum value on the axis. | |
71 | */ |
|
72 | */ | |
72 | /*! |
|
73 | /*! | |
73 | \qmlproperty real ValuesAxis::max |
|
74 | \qmlproperty real ValuesAxis::max | |
74 | Defines the maximum value on the axis. |
|
75 | Defines the maximum value on the axis. | |
75 | */ |
|
76 | */ | |
76 |
|
77 | |||
77 | /*! |
|
78 | /*! | |
78 | \fn void QValuesAxis::minChanged(qreal min) |
|
79 | \fn void QValuesAxis::minChanged(qreal min) | |
79 | Axis emits signal when \a min of axis has changed. |
|
80 | Axis emits signal when \a min of axis has changed. | |
80 | */ |
|
81 | */ | |
81 | /*! |
|
82 | /*! | |
82 | \qmlsignal ValuesAxis::onMinChanged(real min) |
|
83 | \qmlsignal ValuesAxis::onMinChanged(real min) | |
83 | Axis emits signal when \a min of axis has changed. |
|
84 | Axis emits signal when \a min of axis has changed. | |
84 | */ |
|
85 | */ | |
85 |
|
86 | |||
86 | /*! |
|
87 | /*! | |
87 | \fn void QValuesAxis::maxChanged(qreal max) |
|
88 | \fn void QValuesAxis::maxChanged(qreal max) | |
88 | Axis emits signal when \a max of axis has changed. |
|
89 | Axis emits signal when \a max of axis has changed. | |
89 | */ |
|
90 | */ | |
90 | /*! |
|
91 | /*! | |
91 | \qmlsignal ValuesAxis::onMaxChanged(real max) |
|
92 | \qmlsignal ValuesAxis::onMaxChanged(real max) | |
92 | Axis emits signal when \a max of axis has changed. |
|
93 | Axis emits signal when \a max of axis has changed. | |
93 | */ |
|
94 | */ | |
94 |
|
95 | |||
95 | /*! |
|
96 | /*! | |
96 | \fn void QValuesAxis::rangeChanged(qreal min, qreal max) |
|
97 | \fn void QValuesAxis::rangeChanged(qreal min, qreal max) | |
97 | Axis emits signal when \a min or \a max of axis has changed. |
|
98 | Axis emits signal when \a min or \a max of axis has changed. | |
98 | */ |
|
99 | */ | |
99 |
|
100 | |||
100 | /*! |
|
101 | /*! | |
101 | \property QValuesAxis::ticksCount |
|
102 | \property QValuesAxis::ticksCount | |
102 | The number of tick marks for the axis. |
|
103 | The number of tick marks for the axis. | |
103 | */ |
|
104 | */ | |
104 |
|
105 | |||
105 | /*! |
|
106 | /*! | |
106 | \qmlproperty int ValuesAxis::ticksCount |
|
107 | \qmlproperty int ValuesAxis::ticksCount | |
107 | The number of tick marks for the axis. |
|
108 | The number of tick marks for the axis. | |
108 | */ |
|
109 | */ | |
109 |
|
110 | |||
110 | /*! |
|
111 | /*! | |
111 | \property QValuesAxis::niceNumbersEnabled |
|
112 | \property QValuesAxis::niceNumbersEnabled | |
112 | Whether the nice numbers algorithm is enabled or not for the axis. |
|
113 | Whether the nice numbers algorithm is enabled or not for the axis. | |
113 | */ |
|
114 | */ | |
114 |
|
115 | |||
115 | /*! |
|
116 | /*! | |
116 | \qmlproperty bool ValuesAxis::niceNumbersEnabled |
|
117 | \qmlproperty bool ValuesAxis::niceNumbersEnabled | |
117 | Whether the nice numbers algorithm is enabled or not for the axis. |
|
118 | Whether the nice numbers algorithm is enabled or not for the axis. | |
118 | */ |
|
119 | */ | |
119 |
|
120 | |||
120 | /*! |
|
121 | /*! | |
121 | Constructs an axis object which is a child of \a parent. |
|
122 | Constructs an axis object which is a child of \a parent. | |
122 | */ |
|
123 | */ | |
123 | QValuesAxis::QValuesAxis(QObject *parent) : |
|
124 | QValuesAxis::QValuesAxis(QObject *parent) : | |
124 | QAbstractAxis(*new QValuesAxisPrivate(this),parent) |
|
125 | QAbstractAxis(*new QValuesAxisPrivate(this),parent) | |
125 | { |
|
126 | { | |
126 |
|
127 | |||
127 | } |
|
128 | } | |
128 |
|
129 | |||
129 | /*! |
|
130 | /*! | |
130 | \internal |
|
131 | \internal | |
131 | */ |
|
132 | */ | |
132 | QValuesAxis::QValuesAxis(QValuesAxisPrivate &d,QObject *parent) : QAbstractAxis(d,parent) |
|
133 | QValuesAxis::QValuesAxis(QValuesAxisPrivate &d,QObject *parent) : QAbstractAxis(d,parent) | |
133 | { |
|
134 | { | |
134 |
|
135 | |||
135 | } |
|
136 | } | |
136 |
|
137 | |||
137 | /*! |
|
138 | /*! | |
138 | Destroys the object |
|
139 | Destroys the object | |
139 | */ |
|
140 | */ | |
140 | QValuesAxis::~QValuesAxis() |
|
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 | void QValuesAxis::setMin(qreal min) |
|
149 | void QValuesAxis::setMin(qreal min) | |
146 | { |
|
150 | { | |
147 | Q_D(QValuesAxis); |
|
151 | Q_D(QValuesAxis); | |
148 | setRange(min,d->m_max); |
|
152 | setRange(min,d->m_max); | |
149 | } |
|
153 | } | |
150 |
|
154 | |||
151 | qreal QValuesAxis::min() const |
|
155 | qreal QValuesAxis::min() const | |
152 | { |
|
156 | { | |
153 | Q_D(const QValuesAxis); |
|
157 | Q_D(const QValuesAxis); | |
154 | return d->m_min; |
|
158 | return d->m_min; | |
155 | } |
|
159 | } | |
156 |
|
160 | |||
157 | void QValuesAxis::setMax(qreal max) |
|
161 | void QValuesAxis::setMax(qreal max) | |
158 | { |
|
162 | { | |
159 | Q_D(QValuesAxis); |
|
163 | Q_D(QValuesAxis); | |
160 | setRange(d->m_min,max); |
|
164 | setRange(d->m_min,max); | |
161 | } |
|
165 | } | |
162 |
|
166 | |||
163 | qreal QValuesAxis::max() const |
|
167 | qreal QValuesAxis::max() const | |
164 | { |
|
168 | { | |
165 | Q_D(const QValuesAxis); |
|
169 | Q_D(const QValuesAxis); | |
166 | return d->m_max; |
|
170 | return d->m_max; | |
167 | } |
|
171 | } | |
168 |
|
172 | |||
169 | /*! |
|
173 | /*! | |
170 | Sets range from \a min to \a max on the axis. |
|
174 | Sets range from \a min to \a max on the axis. | |
171 | */ |
|
175 | */ | |
172 | void QValuesAxis::setRange(qreal min, qreal max) |
|
176 | void QValuesAxis::setRange(qreal min, qreal max) | |
173 | { |
|
177 | { | |
|
178 | if(max<min) return; | |||
|
179 | ||||
174 | Q_D(QValuesAxis); |
|
180 | Q_D(QValuesAxis); | |
175 | bool changed = false; |
|
181 | bool changed = false; | |
176 |
|
182 | |||
177 | if (!qFuzzyIsNull(d->m_min - min)) { |
|
183 | if (!qFuzzyIsNull(d->m_min - min)) { | |
178 | d->m_min = min; |
|
184 | d->m_min = min; | |
179 | changed = true; |
|
185 | changed = true; | |
180 | emit minChanged(min); |
|
186 | emit minChanged(min); | |
181 | } |
|
187 | } | |
182 |
|
188 | |||
183 | if (!qFuzzyIsNull(d->m_max - max)) { |
|
189 | if (!qFuzzyIsNull(d->m_max - max)) { | |
184 | d->m_max = max; |
|
190 | d->m_max = max; | |
185 | changed = true; |
|
191 | changed = true; | |
186 | emit maxChanged(max); |
|
192 | emit maxChanged(max); | |
187 | } |
|
193 | } | |
188 |
|
194 | |||
189 | if(d->m_niceNumbers) d->looseNiceNumbers(d->m_min, d->m_max, d->m_tickCount); |
|
195 | if(d->m_niceNumbers) d->looseNiceNumbers(d->m_min, d->m_max, d->m_tickCount); | |
190 |
|
196 | |||
191 | if (changed) { |
|
197 | if (changed) { | |
192 | emit rangeChanged(d->m_min,d->m_max); |
|
198 | emit rangeChanged(d->m_min,d->m_max); | |
193 | d->emitUpdated(); |
|
199 | d->emitUpdated(); | |
194 | } |
|
200 | } | |
195 | } |
|
201 | } | |
196 |
|
202 | |||
197 | /*! |
|
203 | /*! | |
198 | Sets \a count for ticks on the axis. |
|
204 | Sets \a count for ticks on the axis. | |
199 | */ |
|
205 | */ | |
200 | void QValuesAxis::setTicksCount(int count) |
|
206 | void QValuesAxis::setTicksCount(int count) | |
201 | { |
|
207 | { | |
202 | Q_D(QValuesAxis); |
|
208 | Q_D(QValuesAxis); | |
203 | if (d->m_tickCount != count && count >=2) { |
|
209 | if (d->m_tickCount != count && count >=2) { | |
204 | d->m_tickCount = count; |
|
210 | d->m_tickCount = count; | |
205 | d->emitUpdated(); |
|
211 | d->emitUpdated(); | |
206 | } |
|
212 | } | |
207 | } |
|
213 | } | |
208 |
|
214 | |||
209 | /*! |
|
215 | /*! | |
210 | \fn int QValuesAxis::ticksCount() const |
|
216 | \fn int QValuesAxis::ticksCount() const | |
211 | Return number of ticks on the axis |
|
217 | Return number of ticks on the axis | |
212 | */ |
|
218 | */ | |
213 | int QValuesAxis::ticksCount() const |
|
219 | int QValuesAxis::ticksCount() const | |
214 | { |
|
220 | { | |
215 | Q_D(const QValuesAxis); |
|
221 | Q_D(const QValuesAxis); | |
216 | return d->m_tickCount; |
|
222 | return d->m_tickCount; | |
217 | } |
|
223 | } | |
218 |
|
224 | |||
219 | void QValuesAxis::setNiceNumbersEnabled(bool enable) |
|
225 | void QValuesAxis::setNiceNumbersEnabled(bool enable) | |
220 | { |
|
226 | { | |
221 | Q_D(QValuesAxis); |
|
227 | Q_D(QValuesAxis); | |
222 | if (d->m_niceNumbers != enable){ |
|
228 | if (d->m_niceNumbers != enable){ | |
223 | d->m_niceNumbers = enable; |
|
229 | d->m_niceNumbers = enable; | |
224 | if(enable && !qFuzzyIsNull(d->m_max - d->m_min)) setRange(d->min(),d->max()); |
|
230 | if(enable && !qFuzzyIsNull(d->m_max - d->m_min)) setRange(d->min(),d->max()); | |
225 | } |
|
231 | } | |
226 | } |
|
232 | } | |
227 |
|
233 | |||
228 | bool QValuesAxis::niceNumbersEnabled() const |
|
234 | bool QValuesAxis::niceNumbersEnabled() const | |
229 | { |
|
235 | { | |
230 | Q_D(const QValuesAxis); |
|
236 | Q_D(const QValuesAxis); | |
231 | return d->m_niceNumbers; |
|
237 | return d->m_niceNumbers; | |
232 | } |
|
238 | } | |
233 |
|
239 | |||
234 | /*! |
|
240 | /*! | |
235 | Returns the type of the axis |
|
241 | Returns the type of the axis | |
236 | */ |
|
242 | */ | |
237 | QAbstractAxis::AxisType QValuesAxis::type() const |
|
243 | QAbstractAxis::AxisType QValuesAxis::type() const | |
238 | { |
|
244 | { | |
239 | return AxisTypeValues; |
|
245 | return AxisTypeValues; | |
240 | } |
|
246 | } | |
241 |
|
247 | |||
242 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
248 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
243 |
|
249 | |||
244 | QValuesAxisPrivate::QValuesAxisPrivate(QValuesAxis* q): |
|
250 | QValuesAxisPrivate::QValuesAxisPrivate(QValuesAxis* q): | |
245 | QAbstractAxisPrivate(q), |
|
251 | QAbstractAxisPrivate(q), | |
246 | m_min(0), |
|
252 | m_min(0), | |
247 | m_max(0), |
|
253 | m_max(0), | |
248 | m_tickCount(5), |
|
254 | m_tickCount(5), | |
249 | m_niceNumbers(false) |
|
255 | m_niceNumbers(false) | |
250 | { |
|
256 | { | |
251 |
|
257 | |||
252 | } |
|
258 | } | |
253 |
|
259 | |||
254 | QValuesAxisPrivate::~QValuesAxisPrivate() |
|
260 | QValuesAxisPrivate::~QValuesAxisPrivate() | |
255 | { |
|
261 | { | |
256 |
|
262 | |||
257 | } |
|
263 | } | |
258 |
|
264 | |||
259 | void QValuesAxisPrivate::handleDomainUpdated() |
|
265 | void QValuesAxisPrivate::handleDomainUpdated() | |
260 | { |
|
266 | { | |
261 | Q_Q(QValuesAxis); |
|
267 | Q_Q(QValuesAxis); | |
262 | Domain* domain = qobject_cast<Domain*>(sender()); |
|
268 | Domain* domain = qobject_cast<Domain*>(sender()); | |
263 | Q_ASSERT(domain); |
|
269 | Q_ASSERT(domain); | |
264 |
|
270 | |||
265 | if(orientation()==Qt::Horizontal){ |
|
271 | if(orientation()==Qt::Horizontal){ | |
266 | q->setRange(domain->minX(),domain->maxX()); |
|
272 | q->setRange(domain->minX(),domain->maxX()); | |
267 | }else if(orientation()==Qt::Vertical){ |
|
273 | }else if(orientation()==Qt::Vertical){ | |
268 | q->setRange(domain->minY(),domain->maxY()); |
|
274 | q->setRange(domain->minY(),domain->maxY()); | |
269 | } |
|
275 | } | |
270 | } |
|
276 | } | |
271 |
|
277 | |||
272 |
|
278 | |||
273 | void QValuesAxisPrivate::setMin(const QVariant &min) |
|
279 | void QValuesAxisPrivate::setMin(const QVariant &min) | |
274 | { |
|
280 | { | |
275 | Q_Q(QValuesAxis); |
|
281 | Q_Q(QValuesAxis); | |
276 | bool ok; |
|
282 | bool ok; | |
277 | qreal value = min.toReal(&ok); |
|
283 | qreal value = min.toReal(&ok); | |
278 | if(ok) q->setMin(value); |
|
284 | if(ok) q->setMin(value); | |
279 | } |
|
285 | } | |
280 |
|
286 | |||
281 | void QValuesAxisPrivate::setMax(const QVariant &max) |
|
287 | void QValuesAxisPrivate::setMax(const QVariant &max) | |
282 | { |
|
288 | { | |
283 |
|
289 | |||
284 | Q_Q(QValuesAxis); |
|
290 | Q_Q(QValuesAxis); | |
285 | bool ok; |
|
291 | bool ok; | |
286 | qreal value = max.toReal(&ok); |
|
292 | qreal value = max.toReal(&ok); | |
287 | if(ok) q->setMax(value); |
|
293 | if(ok) q->setMax(value); | |
288 | } |
|
294 | } | |
289 |
|
295 | |||
290 | void QValuesAxisPrivate::setRange(const QVariant &min, const QVariant &max) |
|
296 | void QValuesAxisPrivate::setRange(const QVariant &min, const QVariant &max) | |
291 | { |
|
297 | { | |
292 | Q_Q(QValuesAxis); |
|
298 | Q_Q(QValuesAxis); | |
293 | bool ok1; |
|
299 | bool ok1; | |
294 | bool ok2; |
|
300 | bool ok2; | |
295 | qreal value1 = min.toReal(&ok1); |
|
301 | qreal value1 = min.toReal(&ok1); | |
296 | qreal value2 = max.toReal(&ok2); |
|
302 | qreal value2 = max.toReal(&ok2); | |
297 | if(ok1&&ok2) q->setRange(value1,value2); |
|
303 | if(ok1&&ok2) q->setRange(value1,value2); | |
298 | } |
|
304 | } | |
299 |
|
305 | |||
300 | ChartAxis* QValuesAxisPrivate::createGraphics(ChartPresenter* presenter) |
|
306 | ChartAxis* QValuesAxisPrivate::createGraphics(ChartPresenter* presenter) | |
301 | { |
|
307 | { | |
302 | Q_Q(QValuesAxis); |
|
308 | Q_Q(QValuesAxis); | |
303 | if(m_orientation == Qt::Vertical){ |
|
309 | if(m_orientation == Qt::Vertical){ | |
304 | return new ChartValuesAxisY(q,presenter); |
|
310 | return new ChartValuesAxisY(q,presenter); | |
305 | }else{ |
|
311 | }else{ | |
306 | return new ChartValuesAxisX(q,presenter); |
|
312 | return new ChartValuesAxisX(q,presenter); | |
307 | } |
|
313 | } | |
308 |
|
314 | |||
309 | } |
|
315 | } | |
310 |
|
316 | |||
311 | void QValuesAxisPrivate::intializeDomain(Domain* domain) |
|
317 | void QValuesAxisPrivate::intializeDomain(Domain* domain) | |
312 | { |
|
318 | { | |
313 | Q_Q(QValuesAxis); |
|
319 | Q_Q(QValuesAxis); | |
314 | if(qFuzzyCompare(m_max,m_min)) { |
|
320 | if(qFuzzyCompare(m_max,m_min)) { | |
315 | if(m_orientation==Qt::Vertical){ |
|
321 | if(m_orientation==Qt::Vertical){ | |
316 | q->setRange(domain->minY(),domain->maxY()); |
|
322 | q->setRange(domain->minY(),domain->maxY()); | |
317 | }else{ |
|
323 | }else{ | |
318 | q->setRange(domain->minX(), domain->maxX()); |
|
324 | q->setRange(domain->minX(), domain->maxX()); | |
319 | } |
|
325 | } | |
320 | } else { |
|
326 | } else { | |
321 | if(m_orientation==Qt::Vertical){ |
|
327 | if(m_orientation==Qt::Vertical){ | |
322 | domain->setRangeY(m_min, m_max); |
|
328 | domain->setRangeY(m_min, m_max); | |
323 | }else{ |
|
329 | }else{ | |
324 | domain->setRangeX(m_min, m_max); |
|
330 | domain->setRangeX(m_min, m_max); | |
325 | } |
|
331 | } | |
326 | } |
|
332 | } | |
327 | } |
|
333 | } | |
328 |
|
334 | |||
329 | //algorithm defined by Paul S.Heckbert GraphicalGems I |
|
335 | //algorithm defined by Paul S.Heckbert GraphicalGems I | |
330 |
|
336 | |||
331 | void QValuesAxisPrivate::looseNiceNumbers(qreal &min, qreal &max, int &ticksCount) const |
|
337 | void QValuesAxisPrivate::looseNiceNumbers(qreal &min, qreal &max, int &ticksCount) const | |
332 | { |
|
338 | { | |
333 | qreal range = niceNumber(max-min,true); //range with ceiling |
|
339 | qreal range = niceNumber(max-min,true); //range with ceiling | |
334 | qreal step = niceNumber(range/(ticksCount-1),false); |
|
340 | qreal step = niceNumber(range/(ticksCount-1),false); | |
335 |
min = |
|
341 | min = qFloor(min/step); | |
336 |
max = |
|
342 | max = qCeil(max/step); | |
337 | ticksCount = int(max-min) +1; |
|
343 | ticksCount = int(max-min) +1; | |
338 | min*=step; |
|
344 | min*=step; | |
339 | max*=step; |
|
345 | max*=step; | |
340 | } |
|
346 | } | |
341 |
|
347 | |||
342 | //nice numbers can be expressed as form of 1*10^n, 2* 10^n or 5*10^n |
|
348 | //nice numbers can be expressed as form of 1*10^n, 2* 10^n or 5*10^n | |
343 |
|
349 | |||
344 | qreal QValuesAxisPrivate::niceNumber(qreal x,bool ceiling) const |
|
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 | qreal q = x/z;//q<10 && q>=1; |
|
353 | qreal q = x/z;//q<10 && q>=1; | |
348 |
|
354 | |||
349 | if(ceiling) { |
|
355 | if(ceiling) { | |
350 | if(q <= 1.0) q=1; |
|
356 | if(q <= 1.0) q=1; | |
351 | else if(q <= 2.0) q=2; |
|
357 | else if(q <= 2.0) q=2; | |
352 | else if(q <= 5.0) q=5; |
|
358 | else if(q <= 5.0) q=5; | |
353 | else q=10; |
|
359 | else q=10; | |
354 | } |
|
360 | } | |
355 | else { |
|
361 | else { | |
356 | if(q < 1.5) q=1; |
|
362 | if(q < 1.5) q=1; | |
357 | else if(q < 3.0) q=2; |
|
363 | else if(q < 3.0) q=2; | |
358 | else if(q < 7.0) q=5; |
|
364 | else if(q < 7.0) q=5; | |
359 | else q=10; |
|
365 | else q=10; | |
360 | } |
|
366 | } | |
361 | return q*z; |
|
367 | return q*z; | |
362 | } |
|
368 | } | |
363 |
|
369 | |||
364 | #include "moc_qvaluesaxis.cpp" |
|
370 | #include "moc_qvaluesaxis.cpp" | |
365 | #include "moc_qvaluesaxis_p.cpp" |
|
371 | #include "moc_qvaluesaxis_p.cpp" | |
366 |
|
372 | |||
367 | QTCOMMERCIALCHART_END_NAMESPACE |
|
373 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,72 +1,72 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef QVALUESAXIS_P_H |
|
30 | #ifndef QVALUESAXIS_P_H | |
31 | #define QVALUESAXIS_P_H |
|
31 | #define QVALUESAXIS_P_H | |
32 |
|
32 | |||
33 | #include "qvaluesaxis.h" |
|
33 | #include "qvaluesaxis.h" | |
34 | #include "qabstractaxis_p.h" |
|
34 | #include "qabstractaxis_p.h" | |
35 |
|
35 | |||
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
37 |
|
37 | |||
38 | class QValuesAxisPrivate : public QAbstractAxisPrivate |
|
38 | class QValuesAxisPrivate : public QAbstractAxisPrivate | |
39 | { |
|
39 | { | |
40 | Q_OBJECT |
|
40 | Q_OBJECT | |
41 | public: |
|
41 | public: | |
42 | QValuesAxisPrivate(QValuesAxis *q); |
|
42 | QValuesAxisPrivate(QValuesAxis *q); | |
43 | ~QValuesAxisPrivate(); |
|
43 | ~QValuesAxisPrivate(); | |
44 |
|
44 | |||
45 | public: |
|
45 | public: | |
46 | ChartAxis* createGraphics(ChartPresenter* presenter); |
|
46 | ChartAxis* createGraphics(ChartPresenter* presenter); | |
47 | void intializeDomain(Domain* domain); |
|
47 | void intializeDomain(Domain* domain); | |
48 | void handleDomainUpdated(); |
|
48 | void handleDomainUpdated(); | |
49 | qreal min(){ return m_min; }; |
|
49 | qreal min(){ return m_min; }; | |
50 | qreal max(){ return m_max; }; |
|
50 | qreal max(){ return m_max; }; | |
|
51 | int count() const { return m_tickCount;} | |||
51 |
|
52 | |||
52 | protected: |
|
53 | protected: | |
53 | void setMin(const QVariant &min); |
|
54 | void setMin(const QVariant &min); | |
54 | void setMax(const QVariant &max); |
|
55 | void setMax(const QVariant &max); | |
55 | void setRange(const QVariant &min, const QVariant &max); |
|
56 | void setRange(const QVariant &min, const QVariant &max); | |
56 | int ticksCount() const; |
|
|||
57 |
|
57 | |||
58 | private: |
|
58 | private: | |
59 | void looseNiceNumbers(qreal &min, qreal &max, int &ticksCount) const; |
|
59 | void looseNiceNumbers(qreal &min, qreal &max, int &ticksCount) const; | |
60 | qreal niceNumber(qreal x,bool ceiling) const; |
|
60 | qreal niceNumber(qreal x,bool ceiling) const; | |
61 |
|
61 | |||
62 | protected: |
|
62 | private: | |
63 | qreal m_min; |
|
63 | qreal m_min; | |
64 | qreal m_max; |
|
64 | qreal m_max; | |
65 | int m_tickCount; |
|
65 | int m_tickCount; | |
66 | bool m_niceNumbers; |
|
66 | bool m_niceNumbers; | |
67 | Q_DECLARE_PUBLIC(QValuesAxis) |
|
67 | Q_DECLARE_PUBLIC(QValuesAxis) | |
68 | }; |
|
68 | }; | |
69 |
|
69 | |||
70 | QTCOMMERCIALCHART_END_NAMESPACE |
|
70 | QTCOMMERCIALCHART_END_NAMESPACE | |
71 |
|
71 | |||
72 | #endif // QVALUESAXIS_P_H |
|
72 | #endif // QVALUESAXIS_P_H |
@@ -1,786 +1,783 | |||||
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 "qabstractbarseries.h" |
|
21 | #include "qabstractbarseries.h" | |
22 | #include "qabstractbarseries_p.h" |
|
22 | #include "qabstractbarseries_p.h" | |
23 | #include "qbarset.h" |
|
23 | #include "qbarset.h" | |
24 | #include "qbarset_p.h" |
|
24 | #include "qbarset_p.h" | |
25 | #include "domain_p.h" |
|
25 | #include "domain_p.h" | |
26 | #include "legendmarker_p.h" |
|
26 | #include "legendmarker_p.h" | |
27 | #include "chartdataset_p.h" |
|
27 | #include "chartdataset_p.h" | |
28 | #include "charttheme_p.h" |
|
28 | #include "charttheme_p.h" | |
29 | #include "chartanimator_p.h" |
|
29 | #include "chartanimator_p.h" | |
30 | #include "qvaluesaxis.h" |
|
30 | #include "qvaluesaxis.h" | |
31 | #include "qbarcategoriesaxis.h" |
|
31 | #include "qbarcategoriesaxis.h" | |
32 |
|
32 | |||
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
34 |
|
34 | |||
35 | /*! |
|
35 | /*! | |
36 | \class QAbstractBarSeries |
|
36 | \class QAbstractBarSeries | |
37 | \brief Series for creating a bar chart |
|
37 | \brief Series for creating a bar chart | |
38 | \mainclass |
|
38 | \mainclass | |
39 |
|
39 | |||
40 | QAbstractBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars to |
|
40 | QAbstractBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars to | |
41 | the position defined by data. Single bar is defined by QPointF, where x value is the x-coordinate of the bar |
|
41 | the position defined by data. Single bar is defined by QPointF, where x value is the x-coordinate of the bar | |
42 | and y-value is the height of the bar. The category names are ignored with this series and x-axis |
|
42 | and y-value is the height of the bar. The category names are ignored with this series and x-axis | |
43 | shows the x-values. |
|
43 | shows the x-values. | |
44 |
|
44 | |||
45 | See the \l {BarChart Example} {bar chart example} to learn how to create a simple bar chart. |
|
45 | See the \l {BarChart Example} {bar chart example} to learn how to create a simple bar chart. | |
46 | \image examples_barchart.png |
|
46 | \image examples_barchart.png | |
47 |
|
47 | |||
48 | \sa QBarSet, QStackedBarSeries, QPercentBarSeries |
|
48 | \sa QBarSet, QStackedBarSeries, QPercentBarSeries | |
49 | */ |
|
49 | */ | |
50 | /*! |
|
50 | /*! | |
51 | \qmlclass AbstractBarSeries QAbstractBarSeries |
|
51 | \qmlclass AbstractBarSeries QAbstractBarSeries | |
52 | \inherits QAbstractSeries |
|
52 | \inherits QAbstractSeries | |
53 |
|
53 | |||
54 | The following QML shows how to create a simple bar chart: |
|
54 | The following QML shows how to create a simple bar chart: | |
55 | \snippet ../demos/qmlchart/qml/qmlchart/View6.qml 1 |
|
55 | \snippet ../demos/qmlchart/qml/qmlchart/View6.qml 1 | |
56 |
|
56 | |||
57 | \beginfloatleft |
|
57 | \beginfloatleft | |
58 | \image demos_qmlchart6.png |
|
58 | \image demos_qmlchart6.png | |
59 | \endfloat |
|
59 | \endfloat | |
60 | \clearfloat |
|
60 | \clearfloat | |
61 | */ |
|
61 | */ | |
62 |
|
62 | |||
63 | /*! |
|
63 | /*! | |
64 | \property QAbstractBarSeries::barWidth |
|
64 | \property QAbstractBarSeries::barWidth | |
65 | The width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars |
|
65 | The width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars | |
66 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen |
|
66 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen | |
67 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. |
|
67 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. | |
68 | Note that with QBarSeries this value means the width of one group of bars instead of just one bar. |
|
68 | Note that with QBarSeries this value means the width of one group of bars instead of just one bar. | |
69 | \sa QBarSeries |
|
69 | \sa QBarSeries | |
70 | */ |
|
70 | */ | |
71 | /*! |
|
71 | /*! | |
72 | \qmlproperty real AbstractBarSeries::barWidth |
|
72 | \qmlproperty real AbstractBarSeries::barWidth | |
73 | The width of the bars of the series. The unit of width is the unit of x-axis. The minimum width for bars |
|
73 | The width of the bars of the series. The unit of width is the unit of x-axis. The minimum width for bars | |
74 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen |
|
74 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen | |
75 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. |
|
75 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. | |
76 | Note that with QBarSeries this value means the width of one group of bars instead of just one bar. |
|
76 | Note that with QBarSeries this value means the width of one group of bars instead of just one bar. | |
77 | */ |
|
77 | */ | |
78 |
|
78 | |||
79 | /*! |
|
79 | /*! | |
80 | \property QAbstractBarSeries::count |
|
80 | \property QAbstractBarSeries::count | |
81 | Holds the number of sets in series. |
|
81 | Holds the number of sets in series. | |
82 | */ |
|
82 | */ | |
83 | /*! |
|
83 | /*! | |
84 | \qmlproperty int AbstractBarSeries::count |
|
84 | \qmlproperty int AbstractBarSeries::count | |
85 | Holds the number of sets in series. |
|
85 | Holds the number of sets in series. | |
86 | */ |
|
86 | */ | |
87 |
|
87 | |||
88 | /*! |
|
88 | /*! | |
89 | \property QAbstractBarSeries::labelsVisible |
|
89 | \property QAbstractBarSeries::labelsVisible | |
90 | Defines the visibility of the labels in series |
|
90 | Defines the visibility of the labels in series | |
91 | */ |
|
91 | */ | |
92 | /*! |
|
92 | /*! | |
93 | \qmlproperty bool AbstractBarSeries::labelsVisible |
|
93 | \qmlproperty bool AbstractBarSeries::labelsVisible | |
94 | Defines the visibility of the labels in series |
|
94 | Defines the visibility of the labels in series | |
95 | */ |
|
95 | */ | |
96 |
|
96 | |||
97 | /*! |
|
97 | /*! | |
98 | \fn void QAbstractBarSeries::clicked(int index, QBarSet *barset) |
|
98 | \fn void QAbstractBarSeries::clicked(int index, QBarSet *barset) | |
99 | The signal is emitted if the user clicks with a mouse on top of QBarSet \a barset. |
|
99 | The signal is emitted if the user clicks with a mouse on top of QBarSet \a barset. | |
100 | Clicked bar inside set is indexed by \a index |
|
100 | Clicked bar inside set is indexed by \a index | |
101 | */ |
|
101 | */ | |
102 | /*! |
|
102 | /*! | |
103 | \qmlsignal AbstractBarSeries::onClicked(int index, BarSet barset) |
|
103 | \qmlsignal AbstractBarSeries::onClicked(int index, BarSet barset) | |
104 | The signal is emitted if the user clicks with a mouse on top of BarSet. |
|
104 | The signal is emitted if the user clicks with a mouse on top of BarSet. | |
105 | Clicked bar inside set is indexed by \a index |
|
105 | Clicked bar inside set is indexed by \a index | |
106 | */ |
|
106 | */ | |
107 |
|
107 | |||
108 | /*! |
|
108 | /*! | |
109 | \fn void QAbstractBarSeries::hovered(bool status, QBarSet* barset) |
|
109 | \fn void QAbstractBarSeries::hovered(bool status, QBarSet* barset) | |
110 |
|
110 | |||
111 | The signal is emitted if mouse is hovered on top of series. |
|
111 | The signal is emitted if mouse is hovered on top of series. | |
112 | Parameter \a barset is the pointer of barset, where hover happened. |
|
112 | Parameter \a barset is the pointer of barset, where hover happened. | |
113 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. |
|
113 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. | |
114 | */ |
|
114 | */ | |
115 | /*! |
|
115 | /*! | |
116 | \qmlsignal AbstractBarSeries::onHovered(bool status, BarSet barset) |
|
116 | \qmlsignal AbstractBarSeries::onHovered(bool status, BarSet barset) | |
117 |
|
117 | |||
118 | The signal is emitted if mouse is hovered on top of series. |
|
118 | The signal is emitted if mouse is hovered on top of series. | |
119 | Parameter \a barset is the pointer of barset, where hover happened. |
|
119 | Parameter \a barset is the pointer of barset, where hover happened. | |
120 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. |
|
120 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. | |
121 | */ |
|
121 | */ | |
122 |
|
122 | |||
123 | /*! |
|
123 | /*! | |
124 | \fn void QAbstractBarSeries::countChanged() |
|
124 | \fn void QAbstractBarSeries::countChanged() | |
125 | This signal is emitted when barset count has been changed, for example by append or remove. |
|
125 | This signal is emitted when barset count has been changed, for example by append or remove. | |
126 | */ |
|
126 | */ | |
127 | /*! |
|
127 | /*! | |
128 | \qmlsignal AbstractBarSeries::onCountChanged() |
|
128 | \qmlsignal AbstractBarSeries::onCountChanged() | |
129 | This signal is emitted when barset count has been changed, for example by append or remove. |
|
129 | This signal is emitted when barset count has been changed, for example by append or remove. | |
130 | */ |
|
130 | */ | |
131 |
|
131 | |||
132 | /*! |
|
132 | /*! | |
133 | \fn void QAbstractBarSeries::labelsVisibleChanged() |
|
133 | \fn void QAbstractBarSeries::labelsVisibleChanged() | |
134 | This signal is emitted when labels visibility have changed. |
|
134 | This signal is emitted when labels visibility have changed. | |
135 | \sa isLabelsVisible(), setLabelsVisible() |
|
135 | \sa isLabelsVisible(), setLabelsVisible() | |
136 | */ |
|
136 | */ | |
137 |
|
137 | |||
138 | /*! |
|
138 | /*! | |
139 | \fn void QAbstractBarSeries::barsetsAdded(QList<QBarSet*> sets) |
|
139 | \fn void QAbstractBarSeries::barsetsAdded(QList<QBarSet*> sets) | |
140 | This signal is emitted when \a sets have been added to the series. |
|
140 | This signal is emitted when \a sets have been added to the series. | |
141 | \sa append(), insert() |
|
141 | \sa append(), insert() | |
142 | */ |
|
142 | */ | |
143 | /*! |
|
143 | /*! | |
144 | \qmlsignal AbstractBarSeries::onAdded(BarSet barset) |
|
144 | \qmlsignal AbstractBarSeries::onAdded(BarSet barset) | |
145 | Emitted when \a barset has been added to the series. |
|
145 | Emitted when \a barset has been added to the series. | |
146 | */ |
|
146 | */ | |
147 |
|
147 | |||
148 | /*! |
|
148 | /*! | |
149 | \fn void QAbstractBarSeries::barsetsRemoved(QList<QBarSet*> sets) |
|
149 | \fn void QAbstractBarSeries::barsetsRemoved(QList<QBarSet*> sets) | |
150 | This signal is emitted when \a sets have been removed from the series. |
|
150 | This signal is emitted when \a sets have been removed from the series. | |
151 | \sa remove() |
|
151 | \sa remove() | |
152 | */ |
|
152 | */ | |
153 | /*! |
|
153 | /*! | |
154 | \qmlsignal AbstractBarSeries::onRemoved(BarSet barset) |
|
154 | \qmlsignal AbstractBarSeries::onRemoved(BarSet barset) | |
155 | Emitted when \a barset has been removed from the series. |
|
155 | Emitted when \a barset has been removed from the series. | |
156 | */ |
|
156 | */ | |
157 |
|
157 | |||
158 | /*! |
|
158 | /*! | |
159 | \qmlmethod BarSet AbstractBarSeries::at(int index) |
|
159 | \qmlmethod BarSet AbstractBarSeries::at(int index) | |
160 | Returns bar set at \a index. Returns null if the index is not valid. |
|
160 | Returns bar set at \a index. Returns null if the index is not valid. | |
161 | */ |
|
161 | */ | |
162 |
|
162 | |||
163 | /*! |
|
163 | /*! | |
164 | \qmlmethod BarSet AbstractBarSeries::append(string label, VariantList values) |
|
164 | \qmlmethod BarSet AbstractBarSeries::append(string label, VariantList values) | |
165 | Adds a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints. |
|
165 | Adds a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints. | |
166 | For example: |
|
166 | For example: | |
167 | \code |
|
167 | \code | |
168 | myBarSeries.append("set 1", [0, 0.2, 0.2, 0.5, 0.4, 1.5, 0.9]); |
|
168 | myBarSeries.append("set 1", [0, 0.2, 0.2, 0.5, 0.4, 1.5, 0.9]); | |
169 | myBarSeries.append("set 2", [Qt.point(0, 1), Qt.point(2, 2.5), Qt.point(3.5, 2.2)]); |
|
169 | myBarSeries.append("set 2", [Qt.point(0, 1), Qt.point(2, 2.5), Qt.point(3.5, 2.2)]); | |
170 | \endcode |
|
170 | \endcode | |
171 | */ |
|
171 | */ | |
172 |
|
172 | |||
173 | /*! |
|
173 | /*! | |
174 | \qmlmethod BarSet AbstractBarSeries::insert(int index, string label, VariantList values) |
|
174 | \qmlmethod BarSet AbstractBarSeries::insert(int index, string label, VariantList values) | |
175 | Inserts a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints. |
|
175 | Inserts a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints. | |
176 | If index is zero or smaller, the new barset is prepended. If the index is count or bigger, the new barset is |
|
176 | If index is zero or smaller, the new barset is prepended. If the index is count or bigger, the new barset is | |
177 | appended. |
|
177 | appended. | |
178 | \sa AbstractBarSeries::append() |
|
178 | \sa AbstractBarSeries::append() | |
179 | */ |
|
179 | */ | |
180 |
|
180 | |||
181 | /*! |
|
181 | /*! | |
182 | \qmlmethod bool AbstractBarSeries::remove(BarSet barset) |
|
182 | \qmlmethod bool AbstractBarSeries::remove(BarSet barset) | |
183 | Removes the barset from the series. Returns true if successfull, false otherwise. |
|
183 | Removes the barset from the series. Returns true if successfull, false otherwise. | |
184 | */ |
|
184 | */ | |
185 |
|
185 | |||
186 | /*! |
|
186 | /*! | |
187 | \qmlmethod AbstractBarSeries::clear() |
|
187 | \qmlmethod AbstractBarSeries::clear() | |
188 | Removes all barsets from the series. |
|
188 | Removes all barsets from the series. | |
189 | */ |
|
189 | */ | |
190 |
|
190 | |||
191 | /*! |
|
191 | /*! | |
192 | This is depreciated constructor. |
|
192 | This is depreciated constructor. | |
193 | */ |
|
193 | */ | |
194 | QAbstractBarSeries::QAbstractBarSeries(QObject *parent) : |
|
194 | QAbstractBarSeries::QAbstractBarSeries(QObject *parent) : | |
195 | QAbstractSeries(*(QAbstractBarSeriesPrivate*)(0),parent) |
|
195 | QAbstractSeries(*(QAbstractBarSeriesPrivate*)(0),parent) | |
196 | { |
|
196 | { | |
197 | } |
|
197 | } | |
198 |
|
198 | |||
199 | /*! |
|
199 | /*! | |
200 | Destructs abstractbarseries and owned barsets. |
|
200 | Destructs abstractbarseries and owned barsets. | |
201 | */ |
|
201 | */ | |
202 | QAbstractBarSeries::~QAbstractBarSeries() |
|
202 | QAbstractBarSeries::~QAbstractBarSeries() | |
203 | { |
|
203 | { | |
204 | Q_D(QAbstractBarSeries); |
|
204 | ||
205 | if(d->m_dataset){ |
|
|||
206 | d->m_dataset->removeSeries(this); |
|
|||
207 | } |
|
|||
208 | } |
|
205 | } | |
209 |
|
206 | |||
210 | /*! |
|
207 | /*! | |
211 | \internal |
|
208 | \internal | |
212 | */ |
|
209 | */ | |
213 | QAbstractBarSeries::QAbstractBarSeries(QAbstractBarSeriesPrivate &d, QObject *parent) : |
|
210 | QAbstractBarSeries::QAbstractBarSeries(QAbstractBarSeriesPrivate &d, QObject *parent) : | |
214 | QAbstractSeries(d,parent) |
|
211 | QAbstractSeries(d,parent) | |
215 | { |
|
212 | { | |
216 | } |
|
213 | } | |
217 |
|
214 | |||
218 | /*! |
|
215 | /*! | |
219 | Sets the width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars |
|
216 | Sets the width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars | |
220 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen |
|
217 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen | |
221 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. |
|
218 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. | |
222 | Note that with \link QBarSeries \endlink this value means the width of one group of bars instead of just one bar. |
|
219 | Note that with \link QBarSeries \endlink this value means the width of one group of bars instead of just one bar. | |
223 | */ |
|
220 | */ | |
224 | void QAbstractBarSeries::setBarWidth(qreal width) |
|
221 | void QAbstractBarSeries::setBarWidth(qreal width) | |
225 | { |
|
222 | { | |
226 | Q_D(QAbstractBarSeries); |
|
223 | Q_D(QAbstractBarSeries); | |
227 | d->setBarWidth(width); |
|
224 | d->setBarWidth(width); | |
228 | } |
|
225 | } | |
229 |
|
226 | |||
230 | /*! |
|
227 | /*! | |
231 | Returns the width of the bars of the series. |
|
228 | Returns the width of the bars of the series. | |
232 | \sa setBarWidth() |
|
229 | \sa setBarWidth() | |
233 | */ |
|
230 | */ | |
234 | qreal QAbstractBarSeries::barWidth() const |
|
231 | qreal QAbstractBarSeries::barWidth() const | |
235 | { |
|
232 | { | |
236 | Q_D(const QAbstractBarSeries); |
|
233 | Q_D(const QAbstractBarSeries); | |
237 | return d->barWidth(); |
|
234 | return d->barWidth(); | |
238 | } |
|
235 | } | |
239 |
|
236 | |||
240 | /*! |
|
237 | /*! | |
241 | Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. |
|
238 | Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. | |
242 | Returns true, if appending succeeded. |
|
239 | Returns true, if appending succeeded. | |
243 | */ |
|
240 | */ | |
244 | bool QAbstractBarSeries::append(QBarSet *set) |
|
241 | bool QAbstractBarSeries::append(QBarSet *set) | |
245 | { |
|
242 | { | |
246 | Q_D(QAbstractBarSeries); |
|
243 | Q_D(QAbstractBarSeries); | |
247 | bool success = d->append(set); |
|
244 | bool success = d->append(set); | |
248 | if (success) { |
|
245 | if (success) { | |
249 | QList<QBarSet*> sets; |
|
246 | QList<QBarSet*> sets; | |
250 | sets.append(set); |
|
247 | sets.append(set); | |
251 | emit barsetsAdded(sets); |
|
248 | emit barsetsAdded(sets); | |
252 | emit countChanged(); |
|
249 | emit countChanged(); | |
253 | } |
|
250 | } | |
254 | return success; |
|
251 | return success; | |
255 | } |
|
252 | } | |
256 |
|
253 | |||
257 | /*! |
|
254 | /*! | |
258 | Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set. |
|
255 | Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set. | |
259 | Returns true, if set was removed. |
|
256 | Returns true, if set was removed. | |
260 | */ |
|
257 | */ | |
261 | bool QAbstractBarSeries::remove(QBarSet *set) |
|
258 | bool QAbstractBarSeries::remove(QBarSet *set) | |
262 | { |
|
259 | { | |
263 | Q_D(QAbstractBarSeries); |
|
260 | Q_D(QAbstractBarSeries); | |
264 | bool success = d->remove(set); |
|
261 | bool success = d->remove(set); | |
265 | if (success) { |
|
262 | if (success) { | |
266 | QList<QBarSet*> sets; |
|
263 | QList<QBarSet*> sets; | |
267 | sets.append(set); |
|
264 | sets.append(set); | |
268 | emit barsetsRemoved(sets); |
|
265 | emit barsetsRemoved(sets); | |
269 | emit countChanged(); |
|
266 | emit countChanged(); | |
270 | } |
|
267 | } | |
271 | return success; |
|
268 | return success; | |
272 | } |
|
269 | } | |
273 |
|
270 | |||
274 | /*! |
|
271 | /*! | |
275 | Adds a list of barsets to series. Takes ownership of \a sets. |
|
272 | Adds a list of barsets to series. Takes ownership of \a sets. | |
276 | Returns true, if all sets were appended succesfully. If any of the sets is null or is already appended to series, |
|
273 | Returns true, if all sets were appended succesfully. If any of the sets is null or is already appended to series, | |
277 | nothing is appended and function returns false. If any of the sets is in list more than once, nothing is appended |
|
274 | nothing is appended and function returns false. If any of the sets is in list more than once, nothing is appended | |
278 | and function returns false. |
|
275 | and function returns false. | |
279 | */ |
|
276 | */ | |
280 | bool QAbstractBarSeries::append(QList<QBarSet* > sets) |
|
277 | bool QAbstractBarSeries::append(QList<QBarSet* > sets) | |
281 | { |
|
278 | { | |
282 | Q_D(QAbstractBarSeries); |
|
279 | Q_D(QAbstractBarSeries); | |
283 | bool success = d->append(sets); |
|
280 | bool success = d->append(sets); | |
284 | if (success) { |
|
281 | if (success) { | |
285 | emit barsetsAdded(sets); |
|
282 | emit barsetsAdded(sets); | |
286 | emit countChanged(); |
|
283 | emit countChanged(); | |
287 | } |
|
284 | } | |
288 | return success; |
|
285 | return success; | |
289 | } |
|
286 | } | |
290 |
|
287 | |||
291 | /*! |
|
288 | /*! | |
292 | Insert a set of bars to series at \a index postion. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. |
|
289 | Insert a set of bars to series at \a index postion. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. | |
293 | Returns true, if inserting succeeded. |
|
290 | Returns true, if inserting succeeded. | |
294 |
|
291 | |||
295 | */ |
|
292 | */ | |
296 | bool QAbstractBarSeries::insert(int index, QBarSet *set) |
|
293 | bool QAbstractBarSeries::insert(int index, QBarSet *set) | |
297 | { |
|
294 | { | |
298 | Q_D(QAbstractBarSeries); |
|
295 | Q_D(QAbstractBarSeries); | |
299 | bool success = d->insert(index, set); |
|
296 | bool success = d->insert(index, set); | |
300 | if (success) { |
|
297 | if (success) { | |
301 | QList<QBarSet*> sets; |
|
298 | QList<QBarSet*> sets; | |
302 | sets.append(set); |
|
299 | sets.append(set); | |
303 | emit barsetsAdded(sets); |
|
300 | emit barsetsAdded(sets); | |
304 | emit countChanged(); |
|
301 | emit countChanged(); | |
305 | } |
|
302 | } | |
306 | return success; |
|
303 | return success; | |
307 | } |
|
304 | } | |
308 |
|
305 | |||
309 | /*! |
|
306 | /*! | |
310 | Removes all of the bar sets from the series |
|
307 | Removes all of the bar sets from the series | |
311 | */ |
|
308 | */ | |
312 | void QAbstractBarSeries::clear() |
|
309 | void QAbstractBarSeries::clear() | |
313 | { |
|
310 | { | |
314 | Q_D(QAbstractBarSeries); |
|
311 | Q_D(QAbstractBarSeries); | |
315 | QList<QBarSet *> sets = barSets(); |
|
312 | QList<QBarSet *> sets = barSets(); | |
316 | bool success = d->remove(sets); |
|
313 | bool success = d->remove(sets); | |
317 | if (success) { |
|
314 | if (success) { | |
318 | emit barsetsRemoved(sets); |
|
315 | emit barsetsRemoved(sets); | |
319 | emit countChanged(); |
|
316 | emit countChanged(); | |
320 | } |
|
317 | } | |
321 | } |
|
318 | } | |
322 |
|
319 | |||
323 | /*! |
|
320 | /*! | |
324 | Returns number of sets in series. |
|
321 | Returns number of sets in series. | |
325 | */ |
|
322 | */ | |
326 | int QAbstractBarSeries::count() const |
|
323 | int QAbstractBarSeries::count() const | |
327 | { |
|
324 | { | |
328 | Q_D(const QAbstractBarSeries); |
|
325 | Q_D(const QAbstractBarSeries); | |
329 | return d->m_barSets.count(); |
|
326 | return d->m_barSets.count(); | |
330 | } |
|
327 | } | |
331 |
|
328 | |||
332 | /*! |
|
329 | /*! | |
333 | Returns a list of sets in series. Keeps ownership of sets. |
|
330 | Returns a list of sets in series. Keeps ownership of sets. | |
334 | */ |
|
331 | */ | |
335 | QList<QBarSet*> QAbstractBarSeries::barSets() const |
|
332 | QList<QBarSet*> QAbstractBarSeries::barSets() const | |
336 | { |
|
333 | { | |
337 | Q_D(const QAbstractBarSeries); |
|
334 | Q_D(const QAbstractBarSeries); | |
338 | return d->m_barSets; |
|
335 | return d->m_barSets; | |
339 | } |
|
336 | } | |
340 |
|
337 | |||
341 | /*! |
|
338 | /*! | |
342 | Sets the visibility of labels in series to \a visible |
|
339 | Sets the visibility of labels in series to \a visible | |
343 | */ |
|
340 | */ | |
344 | void QAbstractBarSeries::setLabelsVisible(bool visible) |
|
341 | void QAbstractBarSeries::setLabelsVisible(bool visible) | |
345 | { |
|
342 | { | |
346 | Q_D(QAbstractBarSeries); |
|
343 | Q_D(QAbstractBarSeries); | |
347 | if (d->m_labelsVisible != visible) { |
|
344 | if (d->m_labelsVisible != visible) { | |
348 | d->setLabelsVisible(visible); |
|
345 | d->setLabelsVisible(visible); | |
349 | emit labelsVisibleChanged(); |
|
346 | emit labelsVisibleChanged(); | |
350 | } |
|
347 | } | |
351 | } |
|
348 | } | |
352 |
|
349 | |||
353 | /*! |
|
350 | /*! | |
354 | Returns the visibility of labels |
|
351 | Returns the visibility of labels | |
355 | */ |
|
352 | */ | |
356 | bool QAbstractBarSeries::isLabelsVisible() const |
|
353 | bool QAbstractBarSeries::isLabelsVisible() const | |
357 | { |
|
354 | { | |
358 | Q_D(const QAbstractBarSeries); |
|
355 | Q_D(const QAbstractBarSeries); | |
359 | return d->m_labelsVisible; |
|
356 | return d->m_labelsVisible; | |
360 | } |
|
357 | } | |
361 |
|
358 | |||
362 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
359 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
363 |
|
360 | |||
364 | QAbstractBarSeriesPrivate::QAbstractBarSeriesPrivate(QAbstractBarSeries *q) : |
|
361 | QAbstractBarSeriesPrivate::QAbstractBarSeriesPrivate(QAbstractBarSeries *q) : | |
365 | QAbstractSeriesPrivate(q), |
|
362 | QAbstractSeriesPrivate(q), | |
366 | m_barWidth(0.5), // Default value is 50% of category width |
|
363 | m_barWidth(0.5), // Default value is 50% of category width | |
367 | m_labelsVisible(false), |
|
364 | m_labelsVisible(false), | |
368 | m_visible(true) |
|
365 | m_visible(true) | |
369 | { |
|
366 | { | |
370 | } |
|
367 | } | |
371 |
|
368 | |||
372 | int QAbstractBarSeriesPrivate::categoryCount() const |
|
369 | int QAbstractBarSeriesPrivate::categoryCount() const | |
373 | { |
|
370 | { | |
374 | // No categories defined. return count of longest set. |
|
371 | // No categories defined. return count of longest set. | |
375 | int count = 0; |
|
372 | int count = 0; | |
376 | for (int i=0; i<m_barSets.count(); i++) { |
|
373 | for (int i=0; i<m_barSets.count(); i++) { | |
377 | if (m_barSets.at(i)->count() > count) { |
|
374 | if (m_barSets.at(i)->count() > count) { | |
378 | count = m_barSets.at(i)->count(); |
|
375 | count = m_barSets.at(i)->count(); | |
379 | } |
|
376 | } | |
380 | } |
|
377 | } | |
381 |
|
378 | |||
382 | return count; |
|
379 | return count; | |
383 | } |
|
380 | } | |
384 |
|
381 | |||
385 | void QAbstractBarSeriesPrivate::setBarWidth(qreal width) |
|
382 | void QAbstractBarSeriesPrivate::setBarWidth(qreal width) | |
386 | { |
|
383 | { | |
387 | if (width < 0.0) { |
|
384 | if (width < 0.0) { | |
388 | width = 0.0; |
|
385 | width = 0.0; | |
389 | } |
|
386 | } | |
390 | m_barWidth = width; |
|
387 | m_barWidth = width; | |
391 | emit updatedBars(); |
|
388 | emit updatedBars(); | |
392 | } |
|
389 | } | |
393 |
|
390 | |||
394 | qreal QAbstractBarSeriesPrivate::barWidth() const |
|
391 | qreal QAbstractBarSeriesPrivate::barWidth() const | |
395 | { |
|
392 | { | |
396 | return m_barWidth; |
|
393 | return m_barWidth; | |
397 | } |
|
394 | } | |
398 |
|
395 | |||
399 | QBarSet* QAbstractBarSeriesPrivate::barsetAt(int index) |
|
396 | QBarSet* QAbstractBarSeriesPrivate::barsetAt(int index) | |
400 | { |
|
397 | { | |
401 | return m_barSets.at(index); |
|
398 | return m_barSets.at(index); | |
402 | } |
|
399 | } | |
403 |
|
400 | |||
404 | void QAbstractBarSeriesPrivate::setVisible(bool visible) |
|
401 | void QAbstractBarSeriesPrivate::setVisible(bool visible) | |
405 | { |
|
402 | { | |
406 | m_visible = visible; |
|
403 | m_visible = visible; | |
407 | emit updatedBars(); |
|
404 | emit updatedBars(); | |
408 | } |
|
405 | } | |
409 |
|
406 | |||
410 | void QAbstractBarSeriesPrivate::setLabelsVisible(bool visible) |
|
407 | void QAbstractBarSeriesPrivate::setLabelsVisible(bool visible) | |
411 | { |
|
408 | { | |
412 | m_labelsVisible = visible; |
|
409 | m_labelsVisible = visible; | |
413 | emit labelsVisibleChanged(visible); |
|
410 | emit labelsVisibleChanged(visible); | |
414 | } |
|
411 | } | |
415 |
|
412 | |||
416 | qreal QAbstractBarSeriesPrivate::min() |
|
413 | qreal QAbstractBarSeriesPrivate::min() | |
417 | { |
|
414 | { | |
418 | if (m_barSets.count() <= 0) { |
|
415 | if (m_barSets.count() <= 0) { | |
419 | return 0; |
|
416 | return 0; | |
420 | } |
|
417 | } | |
421 | qreal min = INT_MAX; |
|
418 | qreal min = INT_MAX; | |
422 |
|
419 | |||
423 | for (int i = 0; i < m_barSets.count(); i++) { |
|
420 | for (int i = 0; i < m_barSets.count(); i++) { | |
424 | int categoryCount = m_barSets.at(i)->count(); |
|
421 | int categoryCount = m_barSets.at(i)->count(); | |
425 | for (int j = 0; j < categoryCount; j++) { |
|
422 | for (int j = 0; j < categoryCount; j++) { | |
426 | qreal temp = m_barSets.at(i)->at(j); |
|
423 | qreal temp = m_barSets.at(i)->at(j); | |
427 | if (temp < min) |
|
424 | if (temp < min) | |
428 | min = temp; |
|
425 | min = temp; | |
429 | } |
|
426 | } | |
430 | } |
|
427 | } | |
431 | return min; |
|
428 | return min; | |
432 | } |
|
429 | } | |
433 |
|
430 | |||
434 | qreal QAbstractBarSeriesPrivate::max() |
|
431 | qreal QAbstractBarSeriesPrivate::max() | |
435 | { |
|
432 | { | |
436 | if (m_barSets.count() <= 0) { |
|
433 | if (m_barSets.count() <= 0) { | |
437 | return 0; |
|
434 | return 0; | |
438 | } |
|
435 | } | |
439 | qreal max = INT_MIN; |
|
436 | qreal max = INT_MIN; | |
440 |
|
437 | |||
441 | for (int i = 0; i < m_barSets.count(); i++) { |
|
438 | for (int i = 0; i < m_barSets.count(); i++) { | |
442 | int categoryCount = m_barSets.at(i)->count(); |
|
439 | int categoryCount = m_barSets.at(i)->count(); | |
443 | for (int j = 0; j < categoryCount; j++) { |
|
440 | for (int j = 0; j < categoryCount; j++) { | |
444 | qreal temp = m_barSets.at(i)->at(j); |
|
441 | qreal temp = m_barSets.at(i)->at(j); | |
445 | if (temp > max) |
|
442 | if (temp > max) | |
446 | max = temp; |
|
443 | max = temp; | |
447 | } |
|
444 | } | |
448 | } |
|
445 | } | |
449 |
|
446 | |||
450 | return max; |
|
447 | return max; | |
451 | } |
|
448 | } | |
452 |
|
449 | |||
453 | qreal QAbstractBarSeriesPrivate::valueAt(int set, int category) |
|
450 | qreal QAbstractBarSeriesPrivate::valueAt(int set, int category) | |
454 | { |
|
451 | { | |
455 | if ((set < 0) || (set >= m_barSets.count())) { |
|
452 | if ((set < 0) || (set >= m_barSets.count())) { | |
456 | // No set, no value. |
|
453 | // No set, no value. | |
457 | return 0; |
|
454 | return 0; | |
458 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { |
|
455 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { | |
459 | // No category, no value. |
|
456 | // No category, no value. | |
460 | return 0; |
|
457 | return 0; | |
461 | } |
|
458 | } | |
462 |
|
459 | |||
463 | return m_barSets.at(set)->at(category); |
|
460 | return m_barSets.at(set)->at(category); | |
464 | } |
|
461 | } | |
465 |
|
462 | |||
466 | qreal QAbstractBarSeriesPrivate::percentageAt(int set, int category) |
|
463 | qreal QAbstractBarSeriesPrivate::percentageAt(int set, int category) | |
467 | { |
|
464 | { | |
468 | if ((set < 0) || (set >= m_barSets.count())) { |
|
465 | if ((set < 0) || (set >= m_barSets.count())) { | |
469 | // No set, no value. |
|
466 | // No set, no value. | |
470 | return 0; |
|
467 | return 0; | |
471 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { |
|
468 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { | |
472 | // No category, no value. |
|
469 | // No category, no value. | |
473 | return 0; |
|
470 | return 0; | |
474 | } |
|
471 | } | |
475 |
|
472 | |||
476 | qreal value = m_barSets.at(set)->at(category); |
|
473 | qreal value = m_barSets.at(set)->at(category); | |
477 | qreal sum = categorySum(category); |
|
474 | qreal sum = categorySum(category); | |
478 | if ( qFuzzyIsNull(sum) ) { |
|
475 | if ( qFuzzyIsNull(sum) ) { | |
479 | return 0; |
|
476 | return 0; | |
480 | } |
|
477 | } | |
481 |
|
478 | |||
482 | return value / sum; |
|
479 | return value / sum; | |
483 | } |
|
480 | } | |
484 |
|
481 | |||
485 | qreal QAbstractBarSeriesPrivate::categorySum(int category) |
|
482 | qreal QAbstractBarSeriesPrivate::categorySum(int category) | |
486 | { |
|
483 | { | |
487 | qreal sum(0); |
|
484 | qreal sum(0); | |
488 | int count = m_barSets.count(); // Count sets |
|
485 | int count = m_barSets.count(); // Count sets | |
489 | for (int set = 0; set < count; set++) { |
|
486 | for (int set = 0; set < count; set++) { | |
490 | if (category < m_barSets.at(set)->count()) |
|
487 | if (category < m_barSets.at(set)->count()) | |
491 | sum += m_barSets.at(set)->at(category); |
|
488 | sum += m_barSets.at(set)->at(category); | |
492 | } |
|
489 | } | |
493 | return sum; |
|
490 | return sum; | |
494 | } |
|
491 | } | |
495 |
|
492 | |||
496 | qreal QAbstractBarSeriesPrivate::absoluteCategorySum(int category) |
|
493 | qreal QAbstractBarSeriesPrivate::absoluteCategorySum(int category) | |
497 | { |
|
494 | { | |
498 | qreal sum(0); |
|
495 | qreal sum(0); | |
499 | int count = m_barSets.count(); // Count sets |
|
496 | int count = m_barSets.count(); // Count sets | |
500 | for (int set = 0; set < count; set++) { |
|
497 | for (int set = 0; set < count; set++) { | |
501 | if (category < m_barSets.at(set)->count()) |
|
498 | if (category < m_barSets.at(set)->count()) | |
502 | sum += qAbs(m_barSets.at(set)->at(category)); |
|
499 | sum += qAbs(m_barSets.at(set)->at(category)); | |
503 | } |
|
500 | } | |
504 | return sum; |
|
501 | return sum; | |
505 | } |
|
502 | } | |
506 |
|
503 | |||
507 | qreal QAbstractBarSeriesPrivate::maxCategorySum() |
|
504 | qreal QAbstractBarSeriesPrivate::maxCategorySum() | |
508 | { |
|
505 | { | |
509 | qreal max = INT_MIN; |
|
506 | qreal max = INT_MIN; | |
510 | int count = categoryCount(); |
|
507 | int count = categoryCount(); | |
511 | for (int i = 0; i < count; i++) { |
|
508 | for (int i = 0; i < count; i++) { | |
512 | qreal sum = categorySum(i); |
|
509 | qreal sum = categorySum(i); | |
513 | if (sum > max) |
|
510 | if (sum > max) | |
514 | max = sum; |
|
511 | max = sum; | |
515 | } |
|
512 | } | |
516 | return max; |
|
513 | return max; | |
517 | } |
|
514 | } | |
518 |
|
515 | |||
519 | qreal QAbstractBarSeriesPrivate::minX() |
|
516 | qreal QAbstractBarSeriesPrivate::minX() | |
520 | { |
|
517 | { | |
521 | if (m_barSets.count() <= 0) { |
|
518 | if (m_barSets.count() <= 0) { | |
522 | return 0; |
|
519 | return 0; | |
523 | } |
|
520 | } | |
524 | qreal min = INT_MAX; |
|
521 | qreal min = INT_MAX; | |
525 |
|
522 | |||
526 | for (int i = 0; i < m_barSets.count(); i++) { |
|
523 | for (int i = 0; i < m_barSets.count(); i++) { | |
527 | int categoryCount = m_barSets.at(i)->count(); |
|
524 | int categoryCount = m_barSets.at(i)->count(); | |
528 | for (int j = 0; j < categoryCount; j++) { |
|
525 | for (int j = 0; j < categoryCount; j++) { | |
529 | qreal temp = m_barSets.at(i)->d_ptr.data()->m_values.at(j).x(); |
|
526 | qreal temp = m_barSets.at(i)->d_ptr.data()->m_values.at(j).x(); | |
530 | if (temp < min) |
|
527 | if (temp < min) | |
531 | min = temp; |
|
528 | min = temp; | |
532 | } |
|
529 | } | |
533 | } |
|
530 | } | |
534 | return min; |
|
531 | return min; | |
535 | } |
|
532 | } | |
536 |
|
533 | |||
537 | qreal QAbstractBarSeriesPrivate::maxX() |
|
534 | qreal QAbstractBarSeriesPrivate::maxX() | |
538 | { |
|
535 | { | |
539 | if (m_barSets.count() <= 0) { |
|
536 | if (m_barSets.count() <= 0) { | |
540 | return 0; |
|
537 | return 0; | |
541 | } |
|
538 | } | |
542 | qreal max = INT_MIN; |
|
539 | qreal max = INT_MIN; | |
543 |
|
540 | |||
544 | for (int i = 0; i < m_barSets.count(); i++) { |
|
541 | for (int i = 0; i < m_barSets.count(); i++) { | |
545 | int categoryCount = m_barSets.at(i)->count(); |
|
542 | int categoryCount = m_barSets.at(i)->count(); | |
546 | for (int j = 0; j < categoryCount; j++) { |
|
543 | for (int j = 0; j < categoryCount; j++) { | |
547 | qreal temp = m_barSets.at(i)->d_ptr.data()->m_values.at(j).x(); |
|
544 | qreal temp = m_barSets.at(i)->d_ptr.data()->m_values.at(j).x(); | |
548 | if (temp > max) |
|
545 | if (temp > max) | |
549 | max = temp; |
|
546 | max = temp; | |
550 | } |
|
547 | } | |
551 | } |
|
548 | } | |
552 |
|
549 | |||
553 | return max; |
|
550 | return max; | |
554 | } |
|
551 | } | |
555 |
|
552 | |||
556 |
|
553 | |||
557 | void QAbstractBarSeriesPrivate::scaleDomain(Domain& domain) |
|
554 | void QAbstractBarSeriesPrivate::scaleDomain(Domain& domain) | |
558 | { |
|
555 | { | |
559 | qreal minX(domain.minX()); |
|
556 | qreal minX(domain.minX()); | |
560 | qreal minY(domain.minY()); |
|
557 | qreal minY(domain.minY()); | |
561 | qreal maxX(domain.maxX()); |
|
558 | qreal maxX(domain.maxX()); | |
562 | qreal maxY(domain.maxY()); |
|
559 | qreal maxY(domain.maxY()); | |
563 |
|
560 | |||
564 | qreal seriesMinX = this->minX(); |
|
561 | qreal seriesMinX = this->minX(); | |
565 | qreal seriesMaxX = this->maxX(); |
|
562 | qreal seriesMaxX = this->maxX(); | |
566 | qreal y = max(); |
|
563 | qreal y = max(); | |
567 | minX = qMin(minX, seriesMinX - (qreal)0.5); |
|
564 | minX = qMin(minX, seriesMinX - (qreal)0.5); | |
568 | minY = qMin(minY, y); |
|
565 | minY = qMin(minY, y); | |
569 | maxX = qMax(maxX, seriesMaxX + (qreal)0.5); |
|
566 | maxX = qMax(maxX, seriesMaxX + (qreal)0.5); | |
570 | maxY = qMax(maxY, y); |
|
567 | maxY = qMax(maxY, y); | |
571 |
|
568 | |||
572 | domain.setRange(minX,maxX,minY,maxY); |
|
569 | domain.setRange(minX,maxX,minY,maxY); | |
573 | } |
|
570 | } | |
574 |
|
571 | |||
575 | Chart* QAbstractBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
572 | Chart* QAbstractBarSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
576 | { |
|
573 | { | |
577 | Q_UNUSED(presenter); |
|
574 | Q_UNUSED(presenter); | |
578 | qWarning() << "QAbstractBarSeriesPrivate::createGraphics called"; |
|
575 | qWarning() << "QAbstractBarSeriesPrivate::createGraphics called"; | |
579 | return 0; |
|
576 | return 0; | |
580 | } |
|
577 | } | |
581 |
|
578 | |||
582 | QList<LegendMarker*> QAbstractBarSeriesPrivate::createLegendMarker(QLegend* legend) |
|
579 | QList<LegendMarker*> QAbstractBarSeriesPrivate::createLegendMarker(QLegend* legend) | |
583 | { |
|
580 | { | |
584 | Q_Q(QAbstractBarSeries); |
|
581 | Q_Q(QAbstractBarSeries); | |
585 | QList<LegendMarker*> markers; |
|
582 | QList<LegendMarker*> markers; | |
586 | foreach(QBarSet* set, q->barSets()) { |
|
583 | foreach(QBarSet* set, q->barSets()) { | |
587 | BarLegendMarker* marker = new BarLegendMarker(q,set,legend); |
|
584 | BarLegendMarker* marker = new BarLegendMarker(q,set,legend); | |
588 | markers << marker; |
|
585 | markers << marker; | |
589 | } |
|
586 | } | |
590 |
|
587 | |||
591 | return markers; |
|
588 | return markers; | |
592 | } |
|
589 | } | |
593 |
|
590 | |||
594 | bool QAbstractBarSeriesPrivate::append(QBarSet *set) |
|
591 | bool QAbstractBarSeriesPrivate::append(QBarSet *set) | |
595 | { |
|
592 | { | |
596 | Q_Q(QAbstractBarSeries); |
|
593 | Q_Q(QAbstractBarSeries); | |
597 | if ((m_barSets.contains(set)) || (set == 0)) { |
|
594 | if ((m_barSets.contains(set)) || (set == 0)) { | |
598 | // Fail if set is already in list or set is null. |
|
595 | // Fail if set is already in list or set is null. | |
599 | return false; |
|
596 | return false; | |
600 | } |
|
597 | } | |
601 | m_barSets.append(set); |
|
598 | m_barSets.append(set); | |
602 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
599 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); | |
603 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
600 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
604 | emit restructuredBars(); // this notifies barchartitem |
|
601 | emit restructuredBars(); // this notifies barchartitem | |
605 | if (m_dataset) { |
|
602 | if (m_dataset) { | |
606 | m_dataset->updateSeries(q); // this notifies legend |
|
603 | m_dataset->updateSeries(q); // this notifies legend | |
607 | } |
|
604 | } | |
608 | return true; |
|
605 | return true; | |
609 | } |
|
606 | } | |
610 |
|
607 | |||
611 | bool QAbstractBarSeriesPrivate::remove(QBarSet *set) |
|
608 | bool QAbstractBarSeriesPrivate::remove(QBarSet *set) | |
612 | { |
|
609 | { | |
613 | Q_Q(QAbstractBarSeries); |
|
610 | Q_Q(QAbstractBarSeries); | |
614 | if (!m_barSets.contains(set)) { |
|
611 | if (!m_barSets.contains(set)) { | |
615 | // Fail if set is not in list |
|
612 | // Fail if set is not in list | |
616 | return false; |
|
613 | return false; | |
617 | } |
|
614 | } | |
618 | m_barSets.removeOne(set); |
|
615 | m_barSets.removeOne(set); | |
619 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
616 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); | |
620 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
617 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
621 | emit restructuredBars(); // this notifies barchartitem |
|
618 | emit restructuredBars(); // this notifies barchartitem | |
622 | if (m_dataset) { |
|
619 | if (m_dataset) { | |
623 | m_dataset->updateSeries(q); // this notifies legend |
|
620 | m_dataset->updateSeries(q); // this notifies legend | |
624 | } |
|
621 | } | |
625 | return true; |
|
622 | return true; | |
626 | } |
|
623 | } | |
627 |
|
624 | |||
628 | bool QAbstractBarSeriesPrivate::append(QList<QBarSet* > sets) |
|
625 | bool QAbstractBarSeriesPrivate::append(QList<QBarSet* > sets) | |
629 | { |
|
626 | { | |
630 | Q_Q(QAbstractBarSeries); |
|
627 | Q_Q(QAbstractBarSeries); | |
631 | foreach (QBarSet* set, sets) { |
|
628 | foreach (QBarSet* set, sets) { | |
632 | if ((set == 0) || (m_barSets.contains(set))) { |
|
629 | if ((set == 0) || (m_barSets.contains(set))) { | |
633 | // Fail if any of the sets is null or is already appended. |
|
630 | // Fail if any of the sets is null or is already appended. | |
634 | return false; |
|
631 | return false; | |
635 | } |
|
632 | } | |
636 | if (sets.count(set) != 1) { |
|
633 | if (sets.count(set) != 1) { | |
637 | // Also fail if same set is more than once in given list. |
|
634 | // Also fail if same set is more than once in given list. | |
638 | return false; |
|
635 | return false; | |
639 | } |
|
636 | } | |
640 | } |
|
637 | } | |
641 |
|
638 | |||
642 | foreach (QBarSet* set, sets) { |
|
639 | foreach (QBarSet* set, sets) { | |
643 | m_barSets.append(set); |
|
640 | m_barSets.append(set); | |
644 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
641 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); | |
645 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
642 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
646 | } |
|
643 | } | |
647 | emit restructuredBars(); // this notifies barchartitem |
|
644 | emit restructuredBars(); // this notifies barchartitem | |
648 | if (m_dataset) { |
|
645 | if (m_dataset) { | |
649 | m_dataset->updateSeries(q); // this notifies legend |
|
646 | m_dataset->updateSeries(q); // this notifies legend | |
650 | } |
|
647 | } | |
651 | return true; |
|
648 | return true; | |
652 | } |
|
649 | } | |
653 |
|
650 | |||
654 | bool QAbstractBarSeriesPrivate::remove(QList<QBarSet* > sets) |
|
651 | bool QAbstractBarSeriesPrivate::remove(QList<QBarSet* > sets) | |
655 | { |
|
652 | { | |
656 | Q_Q(QAbstractBarSeries); |
|
653 | Q_Q(QAbstractBarSeries); | |
657 | if (sets.count() == 0) { |
|
654 | if (sets.count() == 0) { | |
658 | return false; |
|
655 | return false; | |
659 | } |
|
656 | } | |
660 | foreach (QBarSet* set, sets) { |
|
657 | foreach (QBarSet* set, sets) { | |
661 | if ((set == 0) || (!m_barSets.contains(set))) { |
|
658 | if ((set == 0) || (!m_barSets.contains(set))) { | |
662 | // Fail if any of the sets is null or is not in series |
|
659 | // Fail if any of the sets is null or is not in series | |
663 | return false; |
|
660 | return false; | |
664 | } |
|
661 | } | |
665 | if (sets.count(set) != 1) { |
|
662 | if (sets.count(set) != 1) { | |
666 | // Also fail if same set is more than once in given list. |
|
663 | // Also fail if same set is more than once in given list. | |
667 | return false; |
|
664 | return false; | |
668 | } |
|
665 | } | |
669 | } |
|
666 | } | |
670 |
|
667 | |||
671 | foreach (QBarSet* set, sets) { |
|
668 | foreach (QBarSet* set, sets) { | |
672 | m_barSets.removeOne(set); |
|
669 | m_barSets.removeOne(set); | |
673 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
670 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); | |
674 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
671 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
675 | } |
|
672 | } | |
676 |
|
673 | |||
677 | emit restructuredBars(); // this notifies barchartitem |
|
674 | emit restructuredBars(); // this notifies barchartitem | |
678 | if (m_dataset) { |
|
675 | if (m_dataset) { | |
679 | m_dataset->updateSeries(q); // this notifies legend |
|
676 | m_dataset->updateSeries(q); // this notifies legend | |
680 | } |
|
677 | } | |
681 | return true; |
|
678 | return true; | |
682 | } |
|
679 | } | |
683 |
|
680 | |||
684 | bool QAbstractBarSeriesPrivate::insert(int index, QBarSet *set) |
|
681 | bool QAbstractBarSeriesPrivate::insert(int index, QBarSet *set) | |
685 | { |
|
682 | { | |
686 | Q_Q(QAbstractBarSeries); |
|
683 | Q_Q(QAbstractBarSeries); | |
687 | if ((m_barSets.contains(set)) || (set == 0)) { |
|
684 | if ((m_barSets.contains(set)) || (set == 0)) { | |
688 | // Fail if set is already in list or set is null. |
|
685 | // Fail if set is already in list or set is null. | |
689 | return false; |
|
686 | return false; | |
690 | } |
|
687 | } | |
691 | m_barSets.insert(index, set); |
|
688 | m_barSets.insert(index, set); | |
692 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
689 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); | |
693 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
690 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
694 | emit restructuredBars(); // this notifies barchartitem |
|
691 | emit restructuredBars(); // this notifies barchartitem | |
695 | if (m_dataset) { |
|
692 | if (m_dataset) { | |
696 | m_dataset->updateSeries(q); // this notifies legend |
|
693 | m_dataset->updateSeries(q); // this notifies legend | |
697 | } |
|
694 | } | |
698 | return true; |
|
695 | return true; | |
699 | } |
|
696 | } | |
700 |
|
697 | |||
701 | void QAbstractBarSeriesPrivate::initializeAxis(QAbstractAxis* axis) |
|
698 | void QAbstractBarSeriesPrivate::initializeAxis(QAbstractAxis* axis) | |
702 | { |
|
699 | { | |
703 | Q_Q(QAbstractBarSeries); |
|
700 | Q_Q(QAbstractBarSeries); | |
704 |
|
701 | |||
705 | if(axis->type()==QAbstractAxis::AxisTypeCategories) { |
|
702 | if(axis->type()==QAbstractAxis::AxisTypeCategories) { | |
706 |
|
703 | |||
707 | switch(q->type()) { |
|
704 | switch(q->type()) { | |
708 |
|
705 | |||
709 | case QAbstractSeries::SeriesTypeHorizontalBar: |
|
706 | case QAbstractSeries::SeriesTypeHorizontalBar: | |
710 | case QAbstractSeries::SeriesTypeHorizontalPercentBar: |
|
707 | case QAbstractSeries::SeriesTypeHorizontalPercentBar: | |
711 | case QAbstractSeries::SeriesTypeHorizontalStackedBar: { |
|
708 | case QAbstractSeries::SeriesTypeHorizontalStackedBar: { | |
712 |
|
709 | |||
713 | if(axis->orientation()==Qt::Vertical) |
|
710 | if(axis->orientation()==Qt::Vertical) | |
714 | { |
|
711 | { | |
715 | populateCategories(qobject_cast<QBarCategoriesAxis*>(axis)); |
|
712 | populateCategories(qobject_cast<QBarCategoriesAxis*>(axis)); | |
716 | } |
|
713 | } | |
717 | break; |
|
714 | break; | |
718 | } |
|
715 | } | |
719 | case QAbstractSeries::SeriesTypeBar: |
|
716 | case QAbstractSeries::SeriesTypeBar: | |
720 | case QAbstractSeries::SeriesTypePercentBar: |
|
717 | case QAbstractSeries::SeriesTypePercentBar: | |
721 | case QAbstractSeries::SeriesTypeStackedBar: { |
|
718 | case QAbstractSeries::SeriesTypeStackedBar: { | |
722 |
|
719 | |||
723 | if(axis->orientation()==Qt::Horizontal) |
|
720 | if(axis->orientation()==Qt::Horizontal) | |
724 | { |
|
721 | { | |
725 | populateCategories(qobject_cast<QBarCategoriesAxis*>(axis)); |
|
722 | populateCategories(qobject_cast<QBarCategoriesAxis*>(axis)); | |
726 | } |
|
723 | } | |
727 | break; |
|
724 | break; | |
728 | } |
|
725 | } | |
729 | default: |
|
726 | default: | |
730 | qWarning()<<"Unexpected series type"; |
|
727 | qWarning()<<"Unexpected series type"; | |
731 | break; |
|
728 | break; | |
732 |
|
729 | |||
733 | } |
|
730 | } | |
734 | } |
|
731 | } | |
735 | } |
|
732 | } | |
736 |
|
733 | |||
737 | QAbstractAxis::AxisType QAbstractBarSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const |
|
734 | QAbstractAxis::AxisType QAbstractBarSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const | |
738 | { |
|
735 | { | |
739 | Q_Q(const QAbstractBarSeries); |
|
736 | Q_Q(const QAbstractBarSeries); | |
740 |
|
737 | |||
741 | switch(q->type()) { |
|
738 | switch(q->type()) { | |
742 |
|
739 | |||
743 | case QAbstractSeries::SeriesTypeHorizontalBar: |
|
740 | case QAbstractSeries::SeriesTypeHorizontalBar: | |
744 | case QAbstractSeries::SeriesTypeHorizontalPercentBar: |
|
741 | case QAbstractSeries::SeriesTypeHorizontalPercentBar: | |
745 | case QAbstractSeries::SeriesTypeHorizontalStackedBar: { |
|
742 | case QAbstractSeries::SeriesTypeHorizontalStackedBar: { | |
746 |
|
743 | |||
747 | if(orientation==Qt::Vertical) |
|
744 | if(orientation==Qt::Vertical) | |
748 | { |
|
745 | { | |
749 | return QAbstractAxis::AxisTypeCategories; |
|
746 | return QAbstractAxis::AxisTypeCategories; | |
750 | } |
|
747 | } | |
751 | break; |
|
748 | break; | |
752 | } |
|
749 | } | |
753 | case QAbstractSeries::SeriesTypeBar: |
|
750 | case QAbstractSeries::SeriesTypeBar: | |
754 | case QAbstractSeries::SeriesTypePercentBar: |
|
751 | case QAbstractSeries::SeriesTypePercentBar: | |
755 | case QAbstractSeries::SeriesTypeStackedBar: { |
|
752 | case QAbstractSeries::SeriesTypeStackedBar: { | |
756 |
|
753 | |||
757 | if(orientation==Qt::Horizontal) |
|
754 | if(orientation==Qt::Horizontal) | |
758 | { |
|
755 | { | |
759 | return QAbstractAxis::AxisTypeCategories; |
|
756 | return QAbstractAxis::AxisTypeCategories; | |
760 | } |
|
757 | } | |
761 | break; |
|
758 | break; | |
762 | } |
|
759 | } | |
763 | default: |
|
760 | default: | |
764 | qWarning()<<"Unexpected series type"; |
|
761 | qWarning()<<"Unexpected series type"; | |
765 | break; |
|
762 | break; | |
766 |
|
763 | |||
767 | } |
|
764 | } | |
768 | return QAbstractAxis::AxisTypeValues; |
|
765 | return QAbstractAxis::AxisTypeValues; | |
769 |
|
766 | |||
770 | } |
|
767 | } | |
771 |
|
768 | |||
772 | void QAbstractBarSeriesPrivate::populateCategories(QBarCategoriesAxis* axis) |
|
769 | void QAbstractBarSeriesPrivate::populateCategories(QBarCategoriesAxis* axis) | |
773 | { |
|
770 | { | |
774 | QStringList categories; |
|
771 | QStringList categories; | |
775 | if(axis->categories().isEmpty()) { |
|
772 | if(axis->categories().isEmpty()) { | |
776 | for (int i(1); i < categoryCount()+1; i++) |
|
773 | for (int i(1); i < categoryCount()+1; i++) | |
777 | categories << QString::number(i); |
|
774 | categories << QString::number(i); | |
778 | axis->append(categories); |
|
775 | axis->append(categories); | |
779 | } |
|
776 | } | |
780 | } |
|
777 | } | |
781 |
|
778 | |||
782 | #include "moc_qabstractbarseries.cpp" |
|
779 | #include "moc_qabstractbarseries.cpp" | |
783 | #include "moc_qabstractbarseries_p.cpp" |
|
780 | #include "moc_qabstractbarseries_p.cpp" | |
784 |
|
781 | |||
785 |
|
782 | |||
786 | QTCOMMERCIALCHART_END_NAMESPACE |
|
783 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,117 +1,125 | |||||
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 "qbarseries.h" |
|
21 | #include "qbarseries.h" | |
22 | #include "qbarseries_p.h" |
|
22 | #include "qbarseries_p.h" | |
23 | #include "barchartitem_p.h" |
|
23 | #include "barchartitem_p.h" | |
24 | #include "chartdataset_p.h" |
|
24 | #include "chartdataset_p.h" | |
25 | #include "charttheme_p.h" |
|
25 | #include "charttheme_p.h" | |
26 | #include "chartanimator_p.h" |
|
26 | #include "chartanimator_p.h" | |
27 | #include "baranimation_p.h" |
|
27 | #include "baranimation_p.h" | |
28 | #include "qvaluesaxis.h" |
|
28 | #include "qvaluesaxis.h" | |
29 | #include "qbarcategoriesaxis.h" |
|
29 | #include "qbarcategoriesaxis.h" | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | /*! |
|
33 | /*! | |
34 | \class QBarSeries |
|
34 | \class QBarSeries | |
35 | \brief Series for creating bar chart |
|
35 | \brief Series for creating bar chart | |
36 | \mainclass |
|
36 | \mainclass | |
37 |
|
37 | |||
38 | QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars |
|
38 | QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars | |
39 | as groups, where bars in same category are grouped next to each other. QBarSeries groups the data |
|
39 | as groups, where bars in same category are grouped next to each other. QBarSeries groups the data | |
40 | from sets to categories, which are defined by a QStringList. |
|
40 | from sets to categories, which are defined by a QStringList. | |
41 |
|
41 | |||
42 | See the \l {BarChart Example} {bar chart example} to learn how to create a grouped bar chart. |
|
42 | See the \l {BarChart Example} {bar chart example} to learn how to create a grouped bar chart. | |
43 | \image examples_barchart.png |
|
43 | \image examples_barchart.png | |
44 |
|
44 | |||
45 | \sa QBarSet, QPercentBarSeries, QAbstractBarSeries, QStackedBarSeries |
|
45 | \sa QBarSet, QPercentBarSeries, QAbstractBarSeries, QStackedBarSeries | |
46 | */ |
|
46 | */ | |
47 | /*! |
|
47 | /*! | |
48 | \qmlclass BarSeries QBarSeries |
|
48 | \qmlclass BarSeries QBarSeries | |
49 | \inherits AbstractBarSeries |
|
49 | \inherits AbstractBarSeries | |
50 |
|
50 | |||
51 | The following QML shows how to create a simple grouped bar chart: |
|
51 | The following QML shows how to create a simple grouped bar chart: | |
52 | \snippet ../demos/qmlchart/qml/qmlchart/View6.qml 1 |
|
52 | \snippet ../demos/qmlchart/qml/qmlchart/View6.qml 1 | |
53 | \beginfloatleft |
|
53 | \beginfloatleft | |
54 | \image demos_qmlchart6.png |
|
54 | \image demos_qmlchart6.png | |
55 | \endfloat |
|
55 | \endfloat | |
56 | \clearfloat |
|
56 | \clearfloat | |
57 | */ |
|
57 | */ | |
58 |
|
58 | |||
59 | /*! |
|
59 | /*! | |
60 | Constructs empty QBarSeries. |
|
60 | Constructs empty QBarSeries. | |
61 | QBarSeries is QObject which is a child of a \a parent. |
|
61 | QBarSeries is QObject which is a child of a \a parent. | |
62 | */ |
|
62 | */ | |
63 | QBarSeries::QBarSeries(QObject *parent) |
|
63 | QBarSeries::QBarSeries(QObject *parent) | |
64 | : QAbstractBarSeries(*new QBarSeriesPrivate(this), parent) |
|
64 | : QAbstractBarSeries(*new QBarSeriesPrivate(this), parent) | |
65 | { |
|
65 | { | |
66 | } |
|
66 | } | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | Returns QChartSeries::SeriesTypeBar. |
|
69 | Returns QChartSeries::SeriesTypeBar. | |
70 | */ |
|
70 | */ | |
71 | QAbstractSeries::SeriesType QBarSeries::type() const |
|
71 | QAbstractSeries::SeriesType QBarSeries::type() const | |
72 | { |
|
72 | { | |
73 | return QAbstractSeries::SeriesTypeBar; |
|
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 | QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : QAbstractBarSeriesPrivate(q) |
|
86 | QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : QAbstractBarSeriesPrivate(q) | |
79 | { |
|
87 | { | |
80 |
|
88 | |||
81 | } |
|
89 | } | |
82 |
|
90 | |||
83 | void QBarSeriesPrivate::scaleDomain(Domain& domain) |
|
91 | void QBarSeriesPrivate::scaleDomain(Domain& domain) | |
84 | { |
|
92 | { | |
85 | qreal minX(domain.minX()); |
|
93 | qreal minX(domain.minX()); | |
86 | qreal minY(domain.minY()); |
|
94 | qreal minY(domain.minY()); | |
87 | qreal maxX(domain.maxX()); |
|
95 | qreal maxX(domain.maxX()); | |
88 | qreal maxY(domain.maxY()); |
|
96 | qreal maxY(domain.maxY()); | |
89 |
|
97 | |||
90 | qreal x = categoryCount(); |
|
98 | qreal x = categoryCount(); | |
91 | qreal y = max(); |
|
99 | qreal y = max(); | |
92 | minX = qMin(minX, - (qreal)0.5); |
|
100 | minX = qMin(minX, - (qreal)0.5); | |
93 | minY = qMin(minY, y); |
|
101 | minY = qMin(minY, y); | |
94 | maxX = qMax(maxX, x - (qreal)0.5); |
|
102 | maxX = qMax(maxX, x - (qreal)0.5); | |
95 | maxY = qMax(maxY, y); |
|
103 | maxY = qMax(maxY, y); | |
96 |
|
104 | |||
97 | domain.setRange(minX,maxX,minY,maxY); |
|
105 | domain.setRange(minX,maxX,minY,maxY); | |
98 | } |
|
106 | } | |
99 |
|
107 | |||
100 |
|
108 | |||
101 | Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
109 | Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
102 | { |
|
110 | { | |
103 | Q_Q(QBarSeries); |
|
111 | Q_Q(QBarSeries); | |
104 |
|
112 | |||
105 | BarChartItem* bar = new BarChartItem(q,presenter); |
|
113 | BarChartItem* bar = new BarChartItem(q,presenter); | |
106 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
114 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
107 | bar->setAnimator(presenter->animator()); |
|
115 | bar->setAnimator(presenter->animator()); | |
108 | bar->setAnimation(new BarAnimation(bar)); |
|
116 | bar->setAnimation(new BarAnimation(bar)); | |
109 | } |
|
117 | } | |
110 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
118 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
111 | return bar; |
|
119 | return bar; | |
112 | } |
|
120 | } | |
113 |
|
121 | |||
114 | #include "moc_qbarseries.cpp" |
|
122 | #include "moc_qbarseries.cpp" | |
115 |
|
123 | |||
116 | QTCOMMERCIALCHART_END_NAMESPACE |
|
124 | QTCOMMERCIALCHART_END_NAMESPACE | |
117 |
|
125 |
@@ -1,44 +1,45 | |||||
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 QBARSERIES_H |
|
21 | #ifndef QBARSERIES_H | |
22 | #define QBARSERIES_H |
|
22 | #define QBARSERIES_H | |
23 |
|
23 | |||
24 | #include <qabstractbarseries.h> |
|
24 | #include <qabstractbarseries.h> | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | class QBarSeriesPrivate; |
|
28 | class QBarSeriesPrivate; | |
29 |
|
29 | |||
30 | class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractBarSeries |
|
30 | class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractBarSeries | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 | public: |
|
33 | public: | |
34 | explicit QBarSeries(QObject *parent = 0); |
|
34 | explicit QBarSeries(QObject *parent = 0); | |
|
35 | ~QBarSeries(); | |||
35 | QAbstractSeries::SeriesType type() const; |
|
36 | QAbstractSeries::SeriesType type() const; | |
36 |
|
37 | |||
37 | private: |
|
38 | private: | |
38 | Q_DECLARE_PRIVATE(QBarSeries) |
|
39 | Q_DECLARE_PRIVATE(QBarSeries) | |
39 | Q_DISABLE_COPY(QBarSeries) |
|
40 | Q_DISABLE_COPY(QBarSeries) | |
40 | }; |
|
41 | }; | |
41 |
|
42 | |||
42 | QTCOMMERCIALCHART_END_NAMESPACE |
|
43 | QTCOMMERCIALCHART_END_NAMESPACE | |
43 |
|
44 | |||
44 | #endif // QBARSERIES_H |
|
45 | #endif // QBARSERIES_H |
@@ -1,441 +1,471 | |||||
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 "chartdataset_p.h" |
|
21 | #include "chartdataset_p.h" | |
22 | #include "qchart.h" |
|
22 | #include "qchart.h" | |
23 | #include "qvaluesaxis.h" |
|
23 | #include "qvaluesaxis.h" | |
24 | #include "qbarcategoriesaxis.h" |
|
24 | #include "qbarcategoriesaxis.h" | |
25 | #include "qvaluesaxis_p.h" |
|
25 | #include "qvaluesaxis_p.h" | |
26 | #include "qintervalsaxis.h" |
|
26 | #include "qintervalsaxis.h" | |
27 | #include "qdatetimeaxis.h" |
|
27 | #include "qdatetimeaxis.h" | |
28 | #include "qabstractseries_p.h" |
|
28 | #include "qabstractseries_p.h" | |
29 | #include "qabstractbarseries.h" |
|
29 | #include "qabstractbarseries.h" | |
30 | #include "qstackedbarseries.h" |
|
30 | #include "qstackedbarseries.h" | |
31 | #include "qpercentbarseries.h" |
|
31 | #include "qpercentbarseries.h" | |
32 | #include "qpieseries.h" |
|
32 | #include "qpieseries.h" | |
33 |
|
33 | |||
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
35 |
|
35 | |||
36 | ChartDataSet::ChartDataSet(QChart *parent):QObject(parent) |
|
36 | ChartDataSet::ChartDataSet(QChart *parent):QObject(parent) | |
37 | { |
|
37 | { | |
38 |
|
38 | |||
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | ChartDataSet::~ChartDataSet() |
|
41 | ChartDataSet::~ChartDataSet() | |
42 | { |
|
42 | { | |
43 | removeAllSeries(); |
|
43 | removeAllSeries(); | |
44 | } |
|
44 | } | |
45 |
|
45 | |||
46 | void ChartDataSet::addSeries(QAbstractSeries* series) |
|
46 | void ChartDataSet::addSeries(QAbstractSeries* series) | |
47 | { |
|
47 | { | |
48 | Domain* domain = m_seriesDomainMap.value(series); |
|
48 | Domain* domain = m_seriesDomainMap.value(series); | |
49 |
|
49 | |||
50 | if(domain) { |
|
50 | if(domain) { | |
51 | qWarning() << "Can not add series. Series already on the chart"; |
|
51 | qWarning() << "Can not add series. Series already on the chart"; | |
52 | return; |
|
52 | return; | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | domain = new Domain(series); |
|
55 | domain = new Domain(series); | |
56 | m_seriesDomainMap.insert(series,domain); |
|
56 | m_seriesDomainMap.insert(series,domain); | |
57 | series->d_ptr->scaleDomain(*domain); |
|
57 | series->d_ptr->scaleDomain(*domain); | |
58 |
|
58 | |||
59 | createSeriesIndex(series); |
|
59 | createSeriesIndex(series); | |
60 |
|
60 | |||
61 | series->setParent(this); // take ownership |
|
61 | series->setParent(this); // take ownership | |
62 | series->d_ptr->m_chart = qobject_cast<QChart*>(parent()); |
|
62 | series->d_ptr->m_chart = qobject_cast<QChart*>(parent()); | |
63 | series->d_ptr->m_dataset = this; |
|
63 | series->d_ptr->m_dataset = this; | |
64 |
|
64 | |||
65 | emit seriesAdded(series,domain); |
|
65 | emit seriesAdded(series,domain); | |
66 |
|
66 | |||
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | void ChartDataSet::removeSeries(QAbstractSeries* series) |
|
69 | void ChartDataSet::removeSeries(QAbstractSeries* series) | |
70 | { |
|
70 | { | |
71 |
|
71 | |||
72 | if(!m_seriesDomainMap.contains(series)) { |
|
72 | if(!m_seriesDomainMap.contains(series)) { | |
73 | qWarning()<<"Can not remove series. Series not found on the chart."; |
|
73 | qWarning()<<"Can not remove series. Series not found on the chart."; | |
74 | return; |
|
74 | return; | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | emit seriesRemoved(series); |
|
77 | emit seriesRemoved(series); | |
78 |
|
78 | |||
79 | Domain* domain = m_seriesDomainMap.take(series); |
|
79 | Domain* domain = m_seriesDomainMap.take(series); | |
80 | delete domain; |
|
80 | delete domain; | |
81 | domain = 0; |
|
81 | domain = 0; | |
82 |
|
82 | |||
83 | removeSeriesIndex(series); |
|
83 | removeSeriesIndex(series); | |
84 |
|
84 | |||
85 | series->setParent(0); |
|
85 | series->setParent(0); | |
86 | series->d_ptr->m_chart = 0; |
|
86 | series->d_ptr->m_chart = 0; | |
87 | series->d_ptr->m_dataset = 0; |
|
87 | series->d_ptr->m_dataset = 0; | |
88 |
|
88 | |||
89 | removeAxes(series); |
|
89 | removeAxes(series); | |
90 | } |
|
90 | } | |
91 |
|
91 | |||
92 |
|
92 | |||
93 |
|
93 | |||
94 | void ChartDataSet::createSeriesIndex(QAbstractSeries* series) |
|
94 | void ChartDataSet::createSeriesIndex(QAbstractSeries* series) | |
95 | { |
|
95 | { | |
96 | QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap); |
|
96 | QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap); | |
97 |
|
97 | |||
98 | int key=0; |
|
98 | int key=0; | |
99 | while (i.hasNext()) { |
|
99 | while (i.hasNext()) { | |
100 | i.next(); |
|
100 | i.next(); | |
101 | if(i.key()!=key) { |
|
101 | if(i.key()!=key) { | |
102 | break; |
|
102 | break; | |
103 | } |
|
103 | } | |
104 | key++; |
|
104 | key++; | |
105 | } |
|
105 | } | |
106 |
|
106 | |||
107 | m_indexSeriesMap.insert(key,series); |
|
107 | m_indexSeriesMap.insert(key,series); | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 | void ChartDataSet::removeSeriesIndex(QAbstractSeries* series) |
|
110 | void ChartDataSet::removeSeriesIndex(QAbstractSeries* series) | |
111 | { |
|
111 | { | |
112 | int key = seriesIndex(series); |
|
112 | int key = seriesIndex(series); | |
113 | Q_ASSERT(key!=-1); |
|
113 | Q_ASSERT(key!=-1); | |
114 | m_indexSeriesMap.remove(key); |
|
114 | m_indexSeriesMap.remove(key); | |
115 | } |
|
115 | } | |
116 |
|
116 | |||
117 | void ChartDataSet::createDefaultAxes() |
|
117 | void ChartDataSet::createDefaultAxes() | |
118 | { |
|
118 | { | |
119 |
|
119 | |||
120 | if(m_seriesDomainMap.isEmpty()) return; |
|
120 | if(m_seriesDomainMap.isEmpty()) return; | |
121 |
|
121 | |||
122 | QAbstractAxis::AxisTypes typeX(0); |
|
122 | QAbstractAxis::AxisTypes typeX(0); | |
123 | QAbstractAxis::AxisTypes typeY(0); |
|
123 | QAbstractAxis::AxisTypes typeY(0); | |
124 |
|
124 | |||
125 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
125 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
126 | while (i.hasNext()) { |
|
126 | while (i.hasNext()) { | |
127 | i.next(); |
|
127 | i.next(); | |
128 | removeAxes(i.key()); |
|
128 | removeAxes(i.key()); | |
129 | } |
|
129 | } | |
130 |
|
130 | |||
131 | i.toFront(); |
|
131 | i.toFront(); | |
132 |
|
132 | |||
133 | while (i.hasNext()) { |
|
133 | while (i.hasNext()) { | |
134 | i.next(); |
|
134 | i.next(); | |
135 | QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key()); |
|
135 | QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key()); | |
136 | QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key()); |
|
136 | QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key()); | |
137 | if(axisX) typeX&=axisX->type(); |
|
137 | if(axisX) typeX&=axisX->type(); | |
138 | else typeX|=i.key()->d_ptr->defaultAxisType(Qt::Horizontal); |
|
138 | else typeX|=i.key()->d_ptr->defaultAxisType(Qt::Horizontal); | |
139 | if(axisY) typeY&=axisY->type(); |
|
139 | if(axisY) typeY&=axisY->type(); | |
140 | else typeY|=i.key()->d_ptr->defaultAxisType(Qt::Vertical); |
|
140 | else typeY|=i.key()->d_ptr->defaultAxisType(Qt::Vertical); | |
141 | } |
|
141 | } | |
142 |
|
142 | |||
143 | createAxes(typeX,Qt::Horizontal); |
|
143 | createAxes(typeX,Qt::Horizontal); | |
144 | createAxes(typeY,Qt::Vertical); |
|
144 | createAxes(typeY,Qt::Vertical); | |
145 | } |
|
145 | } | |
146 |
|
146 | |||
147 | void ChartDataSet::createAxes(QAbstractAxis::AxisTypes type,Qt::Orientation orientation) |
|
147 | void ChartDataSet::createAxes(QAbstractAxis::AxisTypes type,Qt::Orientation orientation) | |
148 | { |
|
148 | { | |
149 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
149 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
150 |
|
150 | |||
151 | if(type.testFlag(QAbstractAxis::AxisTypeValues) && type.testFlag(QAbstractAxis::AxisTypeCategories)) |
|
151 | if(type.testFlag(QAbstractAxis::AxisTypeValues) && type.testFlag(QAbstractAxis::AxisTypeCategories)) | |
152 | { |
|
152 | { | |
153 | while (i.hasNext()) { |
|
153 | while (i.hasNext()) { | |
154 | i.next(); |
|
154 | i.next(); | |
155 | QAbstractAxis* axis = createAxis(i.key()->d_ptr->defaultAxisType(orientation),orientation); |
|
155 | QAbstractAxis* axis = createAxis(i.key()->d_ptr->defaultAxisType(orientation),orientation); | |
156 | if(!axis) continue; |
|
156 | if(!axis) continue; | |
157 | initializeAxis(axis,i.key()); |
|
157 | initializeAxis(axis,i.key()); | |
158 | emit axisAdded(axis,i.value()); |
|
158 | emit axisAdded(axis,i.value()); | |
159 | } |
|
159 | } | |
160 |
|
160 | |||
161 | } |
|
161 | } | |
162 | else if(!type.testFlag(QAbstractAxis::AxisTypeNoAxis)) { |
|
162 | else if(!type.testFlag(QAbstractAxis::AxisTypeNoAxis)) { | |
163 | QAbstractAxis* axis = createAxis(QAbstractAxis::AxisType(int(type)),orientation); |
|
163 | QAbstractAxis* axis = createAxis(QAbstractAxis::AxisType(int(type)),orientation); | |
164 | i.toFront(); |
|
164 | i.toFront(); | |
165 | while (i.hasNext()) { |
|
165 | while (i.hasNext()) { | |
166 | i.next(); |
|
166 | i.next(); | |
167 | initializeAxis(axis,i.key()); |
|
167 | initializeAxis(axis,i.key()); | |
168 | } |
|
168 | } | |
169 | emit axisAdded(axis,i.value()); |
|
169 | emit axisAdded(axis,i.value()); | |
170 | } |
|
170 | } | |
171 | } |
|
171 | } | |
172 |
|
172 | |||
173 |
|
173 | |||
174 | QAbstractAxis* ChartDataSet::createAxis(QAbstractAxis::AxisType type,Qt::Orientation orientation) |
|
174 | QAbstractAxis* ChartDataSet::createAxis(QAbstractAxis::AxisType type,Qt::Orientation orientation) | |
175 | { |
|
175 | { | |
176 | QAbstractAxis* axis =0; |
|
176 | QAbstractAxis* axis =0; | |
177 |
|
177 | |||
178 | switch(type) { |
|
178 | switch(type) { | |
179 | case QAbstractAxis::AxisTypeValues: |
|
179 | case QAbstractAxis::AxisTypeValues: | |
180 | axis = new QValuesAxis(this); |
|
180 | axis = new QValuesAxis(this); | |
181 | break; |
|
181 | break; | |
182 | case QAbstractAxis::AxisTypeCategories: |
|
182 | case QAbstractAxis::AxisTypeCategories: | |
183 | axis = new QBarCategoriesAxis(this); |
|
183 | axis = new QBarCategoriesAxis(this); | |
184 | break; |
|
184 | break; | |
185 | case QAbstractAxis::AxisTypeIntervals: |
|
185 | case QAbstractAxis::AxisTypeIntervals: | |
186 | axis = new QIntervalsAxis(this); |
|
186 | axis = new QIntervalsAxis(this); | |
187 | break; |
|
187 | break; | |
188 | case QAbstractAxis::AxisTypeDateTime: |
|
188 | case QAbstractAxis::AxisTypeDateTime: | |
189 | axis = new QDateTimeAxis(this); |
|
189 | axis = new QDateTimeAxis(this); | |
190 | break; |
|
190 | break; | |
191 | default: |
|
191 | default: | |
192 | axis = 0; |
|
192 | axis = 0; | |
193 | break; |
|
193 | break; | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | if(axis) |
|
196 | if(axis) | |
197 | axis->d_ptr->setOrientation(orientation); |
|
197 | axis->d_ptr->setOrientation(orientation); | |
198 |
|
198 | |||
199 | return axis; |
|
199 | return axis; | |
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | void ChartDataSet::initializeAxis(QAbstractAxis* axis,QAbstractSeries* series) |
|
202 | void ChartDataSet::initializeAxis(QAbstractAxis* axis,QAbstractSeries* series) | |
203 | { |
|
203 | { | |
204 | Domain* domain = m_seriesDomainMap.value(series); |
|
204 | Domain* domain = m_seriesDomainMap.value(series); | |
|
205 | axis->d_ptr->m_dataset = this; | |||
205 | axis->d_ptr->intializeDomain(domain); |
|
206 | axis->d_ptr->intializeDomain(domain); | |
206 | series->d_ptr->initializeAxis(axis); |
|
207 | series->d_ptr->initializeAxis(axis); | |
207 | if(axis->orientation()==Qt::Horizontal) { |
|
208 | if(axis->orientation()==Qt::Horizontal) { | |
208 | QObject::connect(axis->d_ptr.data(),SIGNAL(updated()),domain,SLOT(handleAxisUpdated())); |
|
209 | QObject::connect(axis->d_ptr.data(),SIGNAL(updated()),domain,SLOT(handleAxisUpdated())); | |
209 | QObject::connect(domain,SIGNAL(updated()),axis->d_ptr.data(),SLOT(handleDomainUpdated())); |
|
210 | QObject::connect(domain,SIGNAL(updated()),axis->d_ptr.data(),SLOT(handleDomainUpdated())); | |
210 | m_seriesAxisXMap.insert(series,axis); |
|
211 | m_seriesAxisXMap.insert(series,axis); | |
211 | } |
|
212 | } | |
212 | else { |
|
213 | else { | |
213 | QObject::connect(axis->d_ptr.data(),SIGNAL(updated()),domain,SLOT(handleAxisUpdated())); |
|
214 | QObject::connect(axis->d_ptr.data(),SIGNAL(updated()),domain,SLOT(handleAxisUpdated())); | |
214 | QObject::connect(domain,SIGNAL(updated()),axis->d_ptr.data(),SLOT(handleDomainUpdated())); |
|
215 | QObject::connect(domain,SIGNAL(updated()),axis->d_ptr.data(),SLOT(handleDomainUpdated())); | |
215 | m_seriesAxisYMap.insert(series,axis); |
|
216 | m_seriesAxisYMap.insert(series,axis); | |
216 | } |
|
217 | } | |
217 | axis->d_ptr->emitUpdated(); |
|
218 | axis->d_ptr->emitUpdated(); | |
218 | } |
|
219 | } | |
219 |
|
220 | |||
220 | void ChartDataSet::removeAxes(QAbstractSeries* series) |
|
221 | void ChartDataSet::removeAxes(QAbstractSeries* series) | |
221 | { |
|
222 | { | |
222 | QAbstractAxis* axisX = m_seriesAxisXMap.take(series); |
|
223 | QAbstractAxis* axisX = m_seriesAxisXMap.take(series); | |
223 |
|
224 | |||
224 | if(axisX) { |
|
225 | if(axisX) { | |
225 | QList<QAbstractAxis*> axesX = m_seriesAxisXMap.values(); |
|
226 | QList<QAbstractAxis*> axesX = m_seriesAxisXMap.values(); | |
226 | int x = axesX.indexOf(axisX); |
|
227 | int x = axesX.indexOf(axisX); | |
227 |
|
228 | |||
228 | if(x==-1) { |
|
229 | if(x==-1) { | |
229 | emit axisRemoved(axisX); |
|
230 | emit axisRemoved(axisX); | |
|
231 | axisX->d_ptr->m_dataset=0; | |||
230 | axisX->deleteLater(); |
|
232 | axisX->deleteLater(); | |
231 | } |
|
233 | } | |
232 | } |
|
234 | } | |
233 |
|
235 | |||
234 | QAbstractAxis* axisY = m_seriesAxisYMap.take(series); |
|
236 | QAbstractAxis* axisY = m_seriesAxisYMap.take(series); | |
235 |
|
237 | |||
236 | if(axisY) { |
|
238 | if(axisY) { | |
237 | QList<QAbstractAxis*> axesY = m_seriesAxisYMap.values(); |
|
239 | QList<QAbstractAxis*> axesY = m_seriesAxisYMap.values(); | |
238 |
|
240 | |||
239 | int y = axesY.indexOf(axisY); |
|
241 | int y = axesY.indexOf(axisY); | |
240 |
|
242 | |||
241 | if(y==-1) { |
|
243 | if(y==-1) { | |
242 | emit axisRemoved(axisY); |
|
244 | emit axisRemoved(axisY); | |
|
245 | axisY->d_ptr->m_dataset=0; | |||
243 | axisY->deleteLater(); |
|
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 | void ChartDataSet::removeAllSeries() |
|
277 | void ChartDataSet::removeAllSeries() | |
249 | { |
|
278 | { | |
250 | QList<QAbstractSeries*> series = m_seriesDomainMap.keys(); |
|
279 | QList<QAbstractSeries*> series = m_seriesDomainMap.keys(); | |
251 | foreach(QAbstractSeries *s , series) { |
|
280 | foreach(QAbstractSeries *s , series) { | |
252 | removeSeries(s); |
|
281 | removeSeries(s); | |
253 | } |
|
282 | } | |
254 |
|
283 | |||
255 | Q_ASSERT(m_seriesAxisXMap.count()==0); |
|
284 | Q_ASSERT(m_seriesAxisXMap.count()==0); | |
256 | Q_ASSERT(m_seriesAxisXMap.count()==0); |
|
285 | Q_ASSERT(m_seriesAxisXMap.count()==0); | |
257 | Q_ASSERT(m_seriesDomainMap.count()==0); |
|
286 | Q_ASSERT(m_seriesDomainMap.count()==0); | |
258 |
|
287 | |||
259 | qDeleteAll(series); |
|
288 | qDeleteAll(series); | |
260 | } |
|
289 | } | |
261 |
|
290 | |||
262 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) |
|
291 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) | |
263 | { |
|
292 | { | |
264 | //for performance reasons block, signals and scale "full" domain one by one. Gives twice less screen updates |
|
293 | //for performance reasons block, signals and scale "full" domain one by one. Gives twice less screen updates | |
265 |
|
294 | |||
266 |
|
295 | |||
267 | blockAxisSignals(true); |
|
296 | blockAxisSignals(true); | |
268 |
|
297 | |||
269 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
298 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
270 |
|
299 | |||
271 | while (i.hasNext()) { |
|
300 | while (i.hasNext()) { | |
272 | i.next(); |
|
301 | i.next(); | |
273 | i.value()->zoomIn(rect,size); |
|
302 | i.value()->zoomIn(rect,size); | |
274 | } |
|
303 | } | |
275 |
|
304 | |||
276 | blockAxisSignals(false); |
|
305 | blockAxisSignals(false); | |
277 |
|
306 | |||
278 | } |
|
307 | } | |
279 |
|
308 | |||
280 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) |
|
309 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) | |
281 | { |
|
310 | { | |
282 | //for performance reasons block, signals and scale "full" domain one by one. Gives twice less screen updates |
|
311 | //for performance reasons block, signals and scale "full" domain one by one. Gives twice less screen updates | |
283 |
|
312 | |||
284 | blockAxisSignals(true); |
|
313 | blockAxisSignals(true); | |
285 |
|
314 | |||
286 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
315 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
287 |
|
316 | |||
288 | while (i.hasNext()) { |
|
317 | while (i.hasNext()) { | |
289 | i.next(); |
|
318 | i.next(); | |
290 | i.value()->zoomOut(rect,size); |
|
319 | i.value()->zoomOut(rect,size); | |
291 | } |
|
320 | } | |
292 |
|
321 | |||
293 | blockAxisSignals(false); |
|
322 | blockAxisSignals(false); | |
294 | } |
|
323 | } | |
295 |
|
324 | |||
296 | void ChartDataSet::blockAxisSignals(bool enabled) |
|
325 | void ChartDataSet::blockAxisSignals(bool enabled) | |
297 | { |
|
326 | { | |
298 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
327 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
299 | while (i.hasNext()) { |
|
328 | while (i.hasNext()) { | |
300 | i.next(); |
|
329 | i.next(); | |
301 | QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key()); |
|
330 | QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key()); | |
302 | QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key()); |
|
331 | QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key()); | |
303 | if(axisX) axisX->d_ptr->blockSignals(enabled); |
|
332 | if(axisX) axisX->d_ptr->blockSignals(enabled); | |
304 | if(axisY) axisY->d_ptr->blockSignals(enabled); |
|
333 | if(axisY) axisY->d_ptr->blockSignals(enabled); | |
305 | } |
|
334 | } | |
306 | } |
|
335 | } | |
307 |
|
336 | |||
308 | int ChartDataSet::seriesCount(QAbstractSeries::SeriesType type) |
|
337 | int ChartDataSet::seriesCount(QAbstractSeries::SeriesType type) | |
309 | { |
|
338 | { | |
310 | int count=0; |
|
339 | int count=0; | |
311 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
340 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
312 | while (i.hasNext()) { |
|
341 | while (i.hasNext()) { | |
313 | i.next(); |
|
342 | i.next(); | |
314 | if(i.key()->type()==type) count++; |
|
343 | if(i.key()->type()==type) count++; | |
315 | } |
|
344 | } | |
316 | return count; |
|
345 | return count; | |
317 | } |
|
346 | } | |
318 |
|
347 | |||
319 | int ChartDataSet::seriesIndex(QAbstractSeries *series) |
|
348 | int ChartDataSet::seriesIndex(QAbstractSeries *series) | |
320 | { |
|
349 | { | |
321 | QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap); |
|
350 | QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap); | |
322 | while (i.hasNext()) { |
|
351 | while (i.hasNext()) { | |
323 | i.next(); |
|
352 | i.next(); | |
324 | if (i.value() == series) |
|
353 | if (i.value() == series) | |
325 | return i.key(); |
|
354 | return i.key(); | |
326 | } |
|
355 | } | |
327 | return -1; |
|
356 | return -1; | |
328 | } |
|
357 | } | |
329 |
|
358 | |||
330 | QAbstractAxis* ChartDataSet::axisX(QAbstractSeries *series) const |
|
359 | QAbstractAxis* ChartDataSet::axisX(QAbstractSeries *series) const | |
331 | { |
|
360 | { | |
332 | if(series == 0) { |
|
361 | if(series == 0) { | |
333 |
|
362 | |||
334 | QMapIterator<QAbstractSeries*, QAbstractAxis *> i(m_seriesAxisXMap); |
|
363 | QMapIterator<QAbstractSeries*, QAbstractAxis *> i(m_seriesAxisXMap); | |
335 |
|
364 | |||
336 | while (i.hasNext()) { |
|
365 | while (i.hasNext()) { | |
337 | i.next(); |
|
366 | i.next(); | |
338 | if(i.value()->isVisible()) return i.value(); |
|
367 | if(i.value()->isVisible()) return i.value(); | |
339 | } |
|
368 | } | |
340 | return 0; |
|
369 | return 0; | |
341 | } |
|
370 | } | |
342 | return m_seriesAxisXMap.value(series); |
|
371 | return m_seriesAxisXMap.value(series); | |
343 | } |
|
372 | } | |
344 |
|
373 | |||
345 | QAbstractAxis* ChartDataSet::axisY(QAbstractSeries *series) const |
|
374 | QAbstractAxis* ChartDataSet::axisY(QAbstractSeries *series) const | |
346 | { |
|
375 | { | |
347 | if(series == 0) { |
|
376 | if(series == 0) { | |
348 | QMapIterator<QAbstractSeries*, QAbstractAxis *> i(m_seriesAxisYMap); |
|
377 | QMapIterator<QAbstractSeries*, QAbstractAxis *> i(m_seriesAxisYMap); | |
349 |
|
378 | |||
350 | while (i.hasNext()) { |
|
379 | while (i.hasNext()) { | |
351 | i.next(); |
|
380 | i.next(); | |
352 | if(i.value()->isVisible()) return i.value(); |
|
381 | if(i.value()->isVisible()) return i.value(); | |
353 | } |
|
382 | } | |
354 | return 0; |
|
383 | return 0; | |
355 | } |
|
384 | } | |
356 | return m_seriesAxisYMap.value(series); |
|
385 | return m_seriesAxisYMap.value(series); | |
357 | } |
|
386 | } | |
358 |
|
387 | |||
359 | void ChartDataSet::setAxis(QAbstractSeries *series, QAbstractAxis *axis, Qt::Orientation orientation) |
|
388 | void ChartDataSet::setAxis(QAbstractSeries *series, QAbstractAxis *axis, Qt::Orientation orientation) | |
360 | { |
|
389 | { | |
361 | Q_ASSERT(axis); |
|
390 | Q_ASSERT(axis); | |
362 |
|
391 | |||
363 | if(!series) { |
|
392 | if(!series) { | |
364 | qWarning() << "Series not found on the chart."; |
|
393 | qWarning() << "Series not found on the chart."; | |
365 | return; |
|
394 | return; | |
366 | } |
|
395 | } | |
367 |
|
396 | |||
368 | Domain* domain = m_seriesDomainMap.value(series); |
|
397 | Domain* domain = m_seriesDomainMap.value(series); | |
369 |
|
398 | |||
370 | if(!domain) { |
|
399 | if(!domain) { | |
371 | qWarning() << "Series not found on the chart."; |
|
400 | qWarning() << "Series not found on the chart."; | |
372 | return; |
|
401 | return; | |
373 | } |
|
402 | } | |
374 |
|
403 | |||
375 | if(orientation==Qt::Horizontal && axis->orientation()==Qt::Vertical) { |
|
404 | if(orientation==Qt::Horizontal && axis->orientation()==Qt::Vertical) { | |
376 | qWarning()<<"Axis already defined as axis Y"; |
|
405 | qWarning()<<"Axis already defined as axis Y"; | |
377 | return; |
|
406 | return; | |
378 | } |
|
407 | } | |
379 |
|
408 | |||
380 | if(orientation==Qt::Vertical && axis->orientation()==Qt::Horizontal) { |
|
409 | if(orientation==Qt::Vertical && axis->orientation()==Qt::Horizontal) { | |
381 | qWarning()<<"Axis already defined as axis X"; |
|
410 | qWarning()<<"Axis already defined as axis X"; | |
382 | return; |
|
411 | return; | |
383 | } |
|
412 | } | |
384 |
|
413 | |||
385 | axis->d_ptr->setOrientation(orientation); |
|
414 | axis->d_ptr->setOrientation(orientation); | |
386 |
|
415 | |||
387 | QMap<QAbstractSeries*, QAbstractAxis*> *seriesAxisMap; |
|
416 | QMap<QAbstractSeries*, QAbstractAxis*> *seriesAxisMap; | |
388 |
|
417 | |||
389 | if(orientation==Qt::Vertical) { |
|
418 | if(orientation==Qt::Vertical) { | |
390 | seriesAxisMap= &m_seriesAxisYMap; |
|
419 | seriesAxisMap= &m_seriesAxisYMap; | |
391 | }else{ |
|
420 | }else{ | |
392 | seriesAxisMap= &m_seriesAxisXMap; |
|
421 | seriesAxisMap= &m_seriesAxisXMap; | |
393 | } |
|
422 | } | |
394 |
|
423 | |||
395 | QAbstractAxis *oldAxis = seriesAxisMap->take(series); |
|
424 | QAbstractAxis *oldAxis = seriesAxisMap->take(series); | |
396 | QList<QAbstractAxis*> axes = seriesAxisMap->values(); |
|
425 | QList<QAbstractAxis*> axes = seriesAxisMap->values(); | |
397 |
|
426 | |||
398 | if(oldAxis) { |
|
427 | if(oldAxis) { | |
399 | if(axes.indexOf(oldAxis)==-1) { |
|
428 | if(axes.indexOf(oldAxis)==-1) { | |
400 | emit axisRemoved(oldAxis); |
|
429 | emit axisRemoved(oldAxis); | |
|
430 | oldAxis->d_ptr->m_dataset=0; | |||
401 | oldAxis->deleteLater(); |
|
431 | oldAxis->deleteLater(); | |
402 | } |
|
432 | } | |
403 | } |
|
433 | } | |
404 |
|
434 | |||
405 | if(axes.indexOf(axis)==-1) { |
|
435 | if(axes.indexOf(axis)==-1) { | |
406 | initializeAxis(axis,series); |
|
436 | initializeAxis(axis,series); | |
407 | emit axisAdded(axis,domain); |
|
437 | emit axisAdded(axis,domain); | |
408 | }else{ |
|
438 | }else{ | |
409 | initializeAxis(axis,series); |
|
439 | initializeAxis(axis,series); | |
410 | } |
|
440 | } | |
411 | } |
|
441 | } | |
412 |
|
442 | |||
413 | Domain* ChartDataSet::domain(QAbstractSeries *series) const |
|
443 | Domain* ChartDataSet::domain(QAbstractSeries *series) const | |
414 | { |
|
444 | { | |
415 | return m_seriesDomainMap.value(series); |
|
445 | return m_seriesDomainMap.value(series); | |
416 | } |
|
446 | } | |
417 |
|
447 | |||
418 | void ChartDataSet::scrollDomain(qreal dx,qreal dy,const QSizeF& size) |
|
448 | void ChartDataSet::scrollDomain(qreal dx,qreal dy,const QSizeF& size) | |
419 | { |
|
449 | { | |
420 | blockAxisSignals(true); |
|
450 | blockAxisSignals(true); | |
421 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
451 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
422 | while (i.hasNext()) { |
|
452 | while (i.hasNext()) { | |
423 | i.next(); |
|
453 | i.next(); | |
424 | i.value()->move(dx,dy,size); |
|
454 | i.value()->move(dx,dy,size); | |
425 | } |
|
455 | } | |
426 | blockAxisSignals(false); |
|
456 | blockAxisSignals(false); | |
427 | } |
|
457 | } | |
428 |
|
458 | |||
429 | QList<QAbstractSeries*> ChartDataSet::series() const |
|
459 | QList<QAbstractSeries*> ChartDataSet::series() const | |
430 | { |
|
460 | { | |
431 | return m_seriesDomainMap.keys(); |
|
461 | return m_seriesDomainMap.keys(); | |
432 | } |
|
462 | } | |
433 |
|
463 | |||
434 | void ChartDataSet::updateSeries(QAbstractSeries *series) |
|
464 | void ChartDataSet::updateSeries(QAbstractSeries *series) | |
435 | { |
|
465 | { | |
436 | emit seriesUpdated(series); |
|
466 | emit seriesUpdated(series); | |
437 | } |
|
467 | } | |
438 |
|
468 | |||
439 | #include "moc_chartdataset_p.cpp" |
|
469 | #include "moc_chartdataset_p.cpp" | |
440 |
|
470 | |||
441 | QTCOMMERCIALCHART_END_NAMESPACE |
|
471 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,99 +1,100 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef CHARTDATASET_P_H |
|
30 | #ifndef CHARTDATASET_P_H | |
31 | #define CHARTDATASET_P_H |
|
31 | #define CHARTDATASET_P_H | |
32 |
|
32 | |||
33 | #include "qabstractseries.h" |
|
33 | #include "qabstractseries.h" | |
34 | #include "domain_p.h" |
|
34 | #include "domain_p.h" | |
35 | #include "qabstractaxis_p.h" |
|
35 | #include "qabstractaxis_p.h" | |
36 | #include <QVector> |
|
36 | #include <QVector> | |
37 |
|
37 | |||
38 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
38 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
39 |
|
39 | |||
40 | class QAbstractAxis; |
|
40 | class QAbstractAxis; | |
41 |
|
41 | |||
42 | class QTCOMMERCIALCHART_AUTOTEST_EXPORT ChartDataSet : public QObject |
|
42 | class QTCOMMERCIALCHART_AUTOTEST_EXPORT ChartDataSet : public QObject | |
43 | { |
|
43 | { | |
44 | Q_OBJECT |
|
44 | Q_OBJECT | |
45 | public: |
|
45 | public: | |
46 | ChartDataSet(QChart* parent=0); |
|
46 | ChartDataSet(QChart* parent=0); | |
47 | virtual ~ChartDataSet(); |
|
47 | virtual ~ChartDataSet(); | |
48 |
|
48 | |||
49 | void addSeries(QAbstractSeries* series); |
|
49 | void addSeries(QAbstractSeries* series); | |
50 | void removeSeries(QAbstractSeries* series); |
|
50 | void removeSeries(QAbstractSeries* series); | |
51 | void removeAllSeries(); |
|
51 | void removeAllSeries(); | |
52 | void updateSeries(QAbstractSeries* series); |
|
52 | void updateSeries(QAbstractSeries* series); | |
53 |
|
53 | |||
54 | void zoomInDomain(const QRectF& rect, const QSizeF& size); |
|
54 | void zoomInDomain(const QRectF& rect, const QSizeF& size); | |
55 | void zoomOutDomain(const QRectF& rect, const QSizeF& size); |
|
55 | void zoomOutDomain(const QRectF& rect, const QSizeF& size); | |
56 | void scrollDomain(qreal dx,qreal dy,const QSizeF& size); |
|
56 | void scrollDomain(qreal dx,qreal dy,const QSizeF& size); | |
57 |
|
57 | |||
58 | int seriesCount(QAbstractSeries::SeriesType type); |
|
58 | int seriesCount(QAbstractSeries::SeriesType type); | |
59 | int seriesIndex(QAbstractSeries *series); |
|
59 | int seriesIndex(QAbstractSeries *series); | |
60 |
|
60 | |||
61 | QAbstractAxis* axisX(QAbstractSeries *series) const; |
|
61 | QAbstractAxis* axisX(QAbstractSeries *series) const; | |
62 | QAbstractAxis* axisY(QAbstractSeries *series) const; |
|
62 | QAbstractAxis* axisY(QAbstractSeries *series) const; | |
63 |
|
63 | |||
64 | void setAxis(QAbstractSeries *series, QAbstractAxis *axis, Qt::Orientation orientation); |
|
64 | void setAxis(QAbstractSeries *series, QAbstractAxis *axis, Qt::Orientation orientation); | |
65 |
|
65 | |||
66 | QList<QAbstractSeries*> series() const; |
|
66 | QList<QAbstractSeries*> series() const; | |
67 | Domain* domain(QAbstractSeries *series) const; |
|
67 | Domain* domain(QAbstractSeries *series) const; | |
68 |
|
68 | |||
|
69 | void removeAxis(QAbstractAxis* axis); | |||
69 | void createDefaultAxes(); |
|
70 | void createDefaultAxes(); | |
70 |
|
71 | |||
71 | Q_SIGNALS: |
|
72 | Q_SIGNALS: | |
72 | void seriesAdded(QAbstractSeries* series, Domain* domain); |
|
73 | void seriesAdded(QAbstractSeries* series, Domain* domain); | |
73 | void seriesRemoved(QAbstractSeries* series); |
|
74 | void seriesRemoved(QAbstractSeries* series); | |
74 | void seriesUpdated(QAbstractSeries* series); |
|
75 | void seriesUpdated(QAbstractSeries* series); | |
75 | void axisAdded(QAbstractAxis* axis,Domain* domain); |
|
76 | void axisAdded(QAbstractAxis* axis,Domain* domain); | |
76 | void axisRemoved(QAbstractAxis* axis); |
|
77 | void axisRemoved(QAbstractAxis* axis); | |
77 |
|
78 | |||
78 | private: |
|
79 | private: | |
79 | void calculateDomain(QAbstractSeries* series,Domain* domain); |
|
80 | void calculateDomain(QAbstractSeries* series,Domain* domain); | |
80 | void createAxes(QAbstractAxis::AxisTypes type,Qt::Orientation orientation); |
|
81 | void createAxes(QAbstractAxis::AxisTypes type,Qt::Orientation orientation); | |
81 | QAbstractAxis* createAxis(QAbstractAxis::AxisType type,Qt::Orientation orientation); |
|
82 | QAbstractAxis* createAxis(QAbstractAxis::AxisType type,Qt::Orientation orientation); | |
82 | void initializeAxis(QAbstractAxis* axis,QAbstractSeries* series); |
|
83 | void initializeAxis(QAbstractAxis* axis,QAbstractSeries* series); | |
83 | void removeAxes(QAbstractSeries* series); |
|
84 | void removeAxes(QAbstractSeries* series); | |
84 | void blockAxisSignals(bool enabled); |
|
85 | void blockAxisSignals(bool enabled); | |
85 | void createSeriesIndex(QAbstractSeries* series); |
|
86 | void createSeriesIndex(QAbstractSeries* series); | |
86 | void removeSeriesIndex(QAbstractSeries* series); |
|
87 | void removeSeriesIndex(QAbstractSeries* series); | |
87 |
|
88 | |||
88 | private: |
|
89 | private: | |
89 | QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisXMap; |
|
90 | QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisXMap; | |
90 | QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisYMap; |
|
91 | QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisYMap; | |
91 | QMap<QAbstractSeries*, Domain*> m_seriesDomainMap; |
|
92 | QMap<QAbstractSeries*, Domain*> m_seriesDomainMap; | |
92 | QMap<int, QAbstractSeries*> m_indexSeriesMap; |
|
93 | QMap<int, QAbstractSeries*> m_indexSeriesMap; | |
93 | int m_domainIndex; |
|
94 | int m_domainIndex; | |
94 |
|
95 | |||
95 | }; |
|
96 | }; | |
96 |
|
97 | |||
97 | QTCOMMERCIALCHART_END_NAMESPACE |
|
98 | QTCOMMERCIALCHART_END_NAMESPACE | |
98 |
|
99 | |||
99 | #endif /* CHARTENGINE_P_H_ */ |
|
100 | #endif /* CHARTENGINE_P_H_ */ |
@@ -1,29 +1,30 | |||||
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 | qintervalsaxis \ | |
25 | qdatetimeaxis |
|
25 | qdatetimeaxis \ | |
|
26 | qbarcategoriesaxis | |||
26 |
|
27 | |||
27 | test_private:{ |
|
28 | test_private:{ | |
28 | SUBDIRS += domain chartdataset |
|
29 | SUBDIRS += domain chartdataset | |
29 | } |
|
30 | } |
@@ -1,848 +1,847 | |||||
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 |
|
||||
45 | delete m_view; |
|
44 | delete m_view; | |
46 | m_view = 0; |
|
45 | m_view = 0; | |
47 | m_chart = 0; |
|
46 | m_chart = 0; | |
48 | m_axis = 0; |
|
47 | m_axis = 0; | |
49 | } |
|
48 | } | |
50 |
|
49 | |||
51 | void tst_QAbstractAxis::qabstractaxis() |
|
50 | void tst_QAbstractAxis::qabstractaxis() | |
52 | { |
|
51 | { | |
53 | QCOMPARE(m_axis->axisPen(), QPen()); |
|
52 | QCOMPARE(m_axis->axisPen(), QPen()); | |
54 | //TODO QCOMPARE(m_axis->axisPenColor(), QColor()); |
|
53 | //TODO QCOMPARE(m_axis->axisPenColor(), QColor()); | |
55 | QCOMPARE(m_axis->gridLinePen(), QPen()); |
|
54 | QCOMPARE(m_axis->gridLinePen(), QPen()); | |
56 | QCOMPARE(m_axis->isArrowVisible(), true); |
|
55 | QCOMPARE(m_axis->isArrowVisible(), true); | |
57 | QCOMPARE(m_axis->isGridLineVisible(), true); |
|
56 | QCOMPARE(m_axis->isGridLineVisible(), true); | |
58 | QCOMPARE(m_axis->isVisible(), false); |
|
57 | QCOMPARE(m_axis->isVisible(), false); | |
59 | QCOMPARE(m_axis->labelsAngle(), 0); |
|
58 | QCOMPARE(m_axis->labelsAngle(), 0); | |
60 | QCOMPARE(m_axis->labelsBrush(), QBrush()); |
|
59 | QCOMPARE(m_axis->labelsBrush(), QBrush()); | |
61 | //TODO QCOMPARE(m_axis->labelsColor(), QColor()); |
|
60 | //TODO QCOMPARE(m_axis->labelsColor(), QColor()); | |
62 | QCOMPARE(m_axis->labelsFont(), QFont()); |
|
61 | QCOMPARE(m_axis->labelsFont(), QFont()); | |
63 | QCOMPARE(m_axis->labelsPen(), QPen()); |
|
62 | QCOMPARE(m_axis->labelsPen(), QPen()); | |
64 | QCOMPARE(m_axis->labelsVisible(), true); |
|
63 | QCOMPARE(m_axis->labelsVisible(), true); | |
65 | QCOMPARE(m_axis->orientation(), Qt::Orientation(0)); |
|
64 | QCOMPARE(m_axis->orientation(), Qt::Orientation(0)); | |
66 | m_axis->setArrowVisible(false); |
|
65 | m_axis->setArrowVisible(false); | |
67 | m_axis->setAxisPen(QPen()); |
|
66 | m_axis->setAxisPen(QPen()); | |
68 | m_axis->setAxisPenColor(QColor()); |
|
67 | m_axis->setAxisPenColor(QColor()); | |
69 | m_axis->setGridLinePen(QPen()); |
|
68 | m_axis->setGridLinePen(QPen()); | |
70 | m_axis->setGridLineVisible(false); |
|
69 | m_axis->setGridLineVisible(false); | |
71 | m_axis->setLabelsAngle(-1); |
|
70 | m_axis->setLabelsAngle(-1); | |
72 | m_axis->setLabelsBrush(QBrush()); |
|
71 | m_axis->setLabelsBrush(QBrush()); | |
73 | m_axis->setLabelsColor(QColor()); |
|
72 | m_axis->setLabelsColor(QColor()); | |
74 | m_axis->setLabelsFont(QFont()); |
|
73 | m_axis->setLabelsFont(QFont()); | |
75 | m_axis->setLabelsPen(QPen()); |
|
74 | m_axis->setLabelsPen(QPen()); | |
76 | m_axis->setLabelsVisible(false); |
|
75 | m_axis->setLabelsVisible(false); | |
77 | m_axis->setMax(QVariant()); |
|
76 | m_axis->setMax(QVariant()); | |
78 | m_axis->setMin(QVariant()); |
|
77 | m_axis->setMin(QVariant()); | |
79 | m_axis->setRange(QVariant(), QVariant()); |
|
78 | m_axis->setRange(QVariant(), QVariant()); | |
80 | m_axis->setShadesBorderColor(QColor()); |
|
79 | m_axis->setShadesBorderColor(QColor()); | |
81 | m_axis->setShadesBrush(QBrush()); |
|
80 | m_axis->setShadesBrush(QBrush()); | |
82 | m_axis->setShadesColor(QColor()); |
|
81 | m_axis->setShadesColor(QColor()); | |
83 | m_axis->setShadesPen(QPen()); |
|
82 | m_axis->setShadesPen(QPen()); | |
84 | m_axis->setShadesVisible(false); |
|
83 | m_axis->setShadesVisible(false); | |
85 | m_axis->setVisible(false); |
|
84 | m_axis->setVisible(false); | |
86 | //TODO QCOMPARE(m_axis->shadesBorderColor(), QColor()); |
|
85 | //TODO QCOMPARE(m_axis->shadesBorderColor(), QColor()); | |
87 | //TODO QCOMPARE(m_axis->shadesBrush(), QBrush()); |
|
86 | //TODO QCOMPARE(m_axis->shadesBrush(), QBrush()); | |
88 | //TODO QCOMPARE(m_axis->shadesColor(), QColor()); |
|
87 | //TODO QCOMPARE(m_axis->shadesColor(), QColor()); | |
89 | QCOMPARE(m_axis->shadesPen(), QPen()); |
|
88 | QCOMPARE(m_axis->shadesPen(), QPen()); | |
90 | QCOMPARE(m_axis->shadesVisible(), false); |
|
89 | QCOMPARE(m_axis->shadesVisible(), false); | |
91 | m_axis->show(); |
|
90 | m_axis->show(); | |
92 | m_axis->hide(); |
|
91 | m_axis->hide(); | |
93 | } |
|
92 | } | |
94 |
|
93 | |||
95 | void tst_QAbstractAxis::axisPen_data() |
|
94 | void tst_QAbstractAxis::axisPen_data() | |
96 | { |
|
95 | { | |
97 | QTest::addColumn<QPen>("axisPen"); |
|
96 | QTest::addColumn<QPen>("axisPen"); | |
98 | QTest::newRow("null") << QPen(); |
|
97 | QTest::newRow("null") << QPen(); | |
99 | QTest::newRow("blue") << QPen(Qt::blue); |
|
98 | QTest::newRow("blue") << QPen(Qt::blue); | |
100 | QTest::newRow("black") << QPen(Qt::black); |
|
99 | QTest::newRow("black") << QPen(Qt::black); | |
101 | QTest::newRow("red") << QPen(Qt::red); |
|
100 | QTest::newRow("red") << QPen(Qt::red); | |
102 | } |
|
101 | } | |
103 |
|
102 | |||
104 | void tst_QAbstractAxis::axisPen() |
|
103 | void tst_QAbstractAxis::axisPen() | |
105 | { |
|
104 | { | |
106 | QFETCH(QPen, axisPen); |
|
105 | QFETCH(QPen, axisPen); | |
107 |
|
106 | |||
108 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
107 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
109 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
108 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
110 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
109 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
111 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
110 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
112 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
111 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
113 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
112 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
114 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
113 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
115 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
114 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
116 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
115 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
117 |
|
116 | |||
118 | m_axis->setAxisPen(axisPen); |
|
117 | m_axis->setAxisPen(axisPen); | |
119 | QCOMPARE(m_axis->axisPen(), axisPen); |
|
118 | QCOMPARE(m_axis->axisPen(), axisPen); | |
120 |
|
119 | |||
121 | QCOMPARE(spy0.count(), 0); |
|
120 | QCOMPARE(spy0.count(), 0); | |
122 | QCOMPARE(spy1.count(), 0); |
|
121 | QCOMPARE(spy1.count(), 0); | |
123 | QCOMPARE(spy2.count(), 0); |
|
122 | QCOMPARE(spy2.count(), 0); | |
124 | QCOMPARE(spy3.count(), 0); |
|
123 | QCOMPARE(spy3.count(), 0); | |
125 | QCOMPARE(spy4.count(), 0); |
|
124 | QCOMPARE(spy4.count(), 0); | |
126 | QCOMPARE(spy5.count(), 0); |
|
125 | QCOMPARE(spy5.count(), 0); | |
127 | QCOMPARE(spy6.count(), 0); |
|
126 | QCOMPARE(spy6.count(), 0); | |
128 | QCOMPARE(spy7.count(), 0); |
|
127 | QCOMPARE(spy7.count(), 0); | |
129 | QCOMPARE(spy8.count(), 0); |
|
128 | QCOMPARE(spy8.count(), 0); | |
130 |
|
129 | |||
131 | m_chart->setAxisX(m_axis, m_series); |
|
130 | m_chart->setAxisX(m_axis, m_series); | |
132 | m_view->show(); |
|
131 | m_view->show(); | |
133 | QTest::qWaitForWindowShown(m_view); |
|
132 | QTest::qWaitForWindowShown(m_view); | |
134 | //TODO QCOMPARE(m_axis->axisPen(), axisPen); |
|
133 | //TODO QCOMPARE(m_axis->axisPen(), axisPen); | |
135 | } |
|
134 | } | |
136 |
|
135 | |||
137 | void tst_QAbstractAxis::axisPenColor_data() |
|
136 | void tst_QAbstractAxis::axisPenColor_data() | |
138 | { |
|
137 | { | |
139 | } |
|
138 | } | |
140 |
|
139 | |||
141 | void tst_QAbstractAxis::axisPenColor() |
|
140 | void tst_QAbstractAxis::axisPenColor() | |
142 | { |
|
141 | { | |
143 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); |
|
142 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); | |
144 | } |
|
143 | } | |
145 |
|
144 | |||
146 | void tst_QAbstractAxis::gridLinePen_data() |
|
145 | void tst_QAbstractAxis::gridLinePen_data() | |
147 | { |
|
146 | { | |
148 |
|
147 | |||
149 | QTest::addColumn<QPen>("gridLinePen"); |
|
148 | QTest::addColumn<QPen>("gridLinePen"); | |
150 | QTest::newRow("null") << QPen(); |
|
149 | QTest::newRow("null") << QPen(); | |
151 | QTest::newRow("blue") << QPen(Qt::blue); |
|
150 | QTest::newRow("blue") << QPen(Qt::blue); | |
152 | QTest::newRow("black") << QPen(Qt::black); |
|
151 | QTest::newRow("black") << QPen(Qt::black); | |
153 | QTest::newRow("red") << QPen(Qt::red); |
|
152 | QTest::newRow("red") << QPen(Qt::red); | |
154 |
|
153 | |||
155 | } |
|
154 | } | |
156 |
|
155 | |||
157 | void tst_QAbstractAxis::gridLinePen() |
|
156 | void tst_QAbstractAxis::gridLinePen() | |
158 | { |
|
157 | { | |
159 | QFETCH(QPen, gridLinePen); |
|
158 | QFETCH(QPen, gridLinePen); | |
160 |
|
159 | |||
161 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
160 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
162 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
161 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
163 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
162 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
164 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
163 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
165 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
164 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
166 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
165 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
167 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
166 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
168 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
167 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
169 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
168 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
170 |
|
169 | |||
171 | m_axis->setGridLinePen(gridLinePen); |
|
170 | m_axis->setGridLinePen(gridLinePen); | |
172 | QCOMPARE(m_axis->gridLinePen(), gridLinePen); |
|
171 | QCOMPARE(m_axis->gridLinePen(), gridLinePen); | |
173 |
|
172 | |||
174 | QCOMPARE(spy0.count(), 0); |
|
173 | QCOMPARE(spy0.count(), 0); | |
175 | QCOMPARE(spy1.count(), 0); |
|
174 | QCOMPARE(spy1.count(), 0); | |
176 | QCOMPARE(spy2.count(), 0); |
|
175 | QCOMPARE(spy2.count(), 0); | |
177 | QCOMPARE(spy3.count(), 0); |
|
176 | QCOMPARE(spy3.count(), 0); | |
178 | QCOMPARE(spy4.count(), 0); |
|
177 | QCOMPARE(spy4.count(), 0); | |
179 | QCOMPARE(spy5.count(), 0); |
|
178 | QCOMPARE(spy5.count(), 0); | |
180 | QCOMPARE(spy6.count(), 0); |
|
179 | QCOMPARE(spy6.count(), 0); | |
181 | QCOMPARE(spy7.count(), 0); |
|
180 | QCOMPARE(spy7.count(), 0); | |
182 | QCOMPARE(spy8.count(), 0); |
|
181 | QCOMPARE(spy8.count(), 0); | |
183 |
|
182 | |||
184 | m_chart->setAxisX(m_axis, m_series); |
|
183 | m_chart->setAxisX(m_axis, m_series); | |
185 | m_view->show(); |
|
184 | m_view->show(); | |
186 | QTest::qWaitForWindowShown(m_view); |
|
185 | QTest::qWaitForWindowShown(m_view); | |
187 | //TODO QCOMPARE(m_axis->gridLinePen(), gridLinePen); |
|
186 | //TODO QCOMPARE(m_axis->gridLinePen(), gridLinePen); | |
188 | } |
|
187 | } | |
189 |
|
188 | |||
190 | void tst_QAbstractAxis::arrowVisible_data() |
|
189 | void tst_QAbstractAxis::arrowVisible_data() | |
191 | { |
|
190 | { | |
192 | QTest::addColumn<bool>("arrowVisible"); |
|
191 | QTest::addColumn<bool>("arrowVisible"); | |
193 | QTest::newRow("true") << true; |
|
192 | QTest::newRow("true") << true; | |
194 | QTest::newRow("false") << false; |
|
193 | QTest::newRow("false") << false; | |
195 | } |
|
194 | } | |
196 |
|
195 | |||
197 | void tst_QAbstractAxis::arrowVisible() |
|
196 | void tst_QAbstractAxis::arrowVisible() | |
198 | { |
|
197 | { | |
199 | QFETCH(bool, arrowVisible); |
|
198 | QFETCH(bool, arrowVisible); | |
200 |
|
199 | |||
201 | m_axis->setArrowVisible(!arrowVisible); |
|
200 | m_axis->setArrowVisible(!arrowVisible); | |
202 |
|
201 | |||
203 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
202 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
204 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
203 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
205 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
204 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
206 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
205 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
207 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
206 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
208 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
207 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
209 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
208 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
210 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
209 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
211 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
210 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
212 |
|
211 | |||
213 | m_axis->setArrowVisible(arrowVisible); |
|
212 | m_axis->setArrowVisible(arrowVisible); | |
214 | QCOMPARE(m_axis->isArrowVisible(), arrowVisible); |
|
213 | QCOMPARE(m_axis->isArrowVisible(), arrowVisible); | |
215 |
|
214 | |||
216 | QCOMPARE(spy0.count(), 1); |
|
215 | QCOMPARE(spy0.count(), 1); | |
217 | QCOMPARE(spy1.count(), 0); |
|
216 | QCOMPARE(spy1.count(), 0); | |
218 | QCOMPARE(spy2.count(), 0); |
|
217 | QCOMPARE(spy2.count(), 0); | |
219 | QCOMPARE(spy3.count(), 0); |
|
218 | QCOMPARE(spy3.count(), 0); | |
220 | QCOMPARE(spy4.count(), 0); |
|
219 | QCOMPARE(spy4.count(), 0); | |
221 | QCOMPARE(spy5.count(), 0); |
|
220 | QCOMPARE(spy5.count(), 0); | |
222 | QCOMPARE(spy6.count(), 0); |
|
221 | QCOMPARE(spy6.count(), 0); | |
223 | QCOMPARE(spy7.count(), 0); |
|
222 | QCOMPARE(spy7.count(), 0); | |
224 | QCOMPARE(spy8.count(), 0); |
|
223 | QCOMPARE(spy8.count(), 0); | |
225 |
|
224 | |||
226 | m_chart->setAxisX(m_axis, m_series); |
|
225 | m_chart->setAxisX(m_axis, m_series); | |
227 | m_view->show(); |
|
226 | m_view->show(); | |
228 | QTest::qWaitForWindowShown(m_view); |
|
227 | QTest::qWaitForWindowShown(m_view); | |
229 | QCOMPARE(m_axis->isArrowVisible(), arrowVisible); |
|
228 | QCOMPARE(m_axis->isArrowVisible(), arrowVisible); | |
230 | } |
|
229 | } | |
231 |
|
230 | |||
232 | void tst_QAbstractAxis::gridLineVisible_data() |
|
231 | void tst_QAbstractAxis::gridLineVisible_data() | |
233 | { |
|
232 | { | |
234 | QTest::addColumn<bool>("gridLineVisible"); |
|
233 | QTest::addColumn<bool>("gridLineVisible"); | |
235 | QTest::newRow("true") << true; |
|
234 | QTest::newRow("true") << true; | |
236 | QTest::newRow("false") << false; |
|
235 | QTest::newRow("false") << false; | |
237 | } |
|
236 | } | |
238 |
|
237 | |||
239 | void tst_QAbstractAxis::gridLineVisible() |
|
238 | void tst_QAbstractAxis::gridLineVisible() | |
240 | { |
|
239 | { | |
241 | QFETCH(bool, gridLineVisible); |
|
240 | QFETCH(bool, gridLineVisible); | |
242 |
|
241 | |||
243 | m_axis->setGridLineVisible(!gridLineVisible); |
|
242 | m_axis->setGridLineVisible(!gridLineVisible); | |
244 |
|
243 | |||
245 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
244 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
246 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
245 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
247 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
246 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
248 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
247 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
249 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
248 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
250 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
249 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
251 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
250 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
252 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
251 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
253 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
252 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
254 |
|
253 | |||
255 | m_axis->setGridLineVisible(gridLineVisible); |
|
254 | m_axis->setGridLineVisible(gridLineVisible); | |
256 | QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible); |
|
255 | QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible); | |
257 |
|
256 | |||
258 | QCOMPARE(spy0.count(), 0); |
|
257 | QCOMPARE(spy0.count(), 0); | |
259 | QCOMPARE(spy1.count(), 0); |
|
258 | QCOMPARE(spy1.count(), 0); | |
260 | QCOMPARE(spy2.count(), 1); |
|
259 | QCOMPARE(spy2.count(), 1); | |
261 | QCOMPARE(spy3.count(), 0); |
|
260 | QCOMPARE(spy3.count(), 0); | |
262 | QCOMPARE(spy4.count(), 0); |
|
261 | QCOMPARE(spy4.count(), 0); | |
263 | QCOMPARE(spy5.count(), 0); |
|
262 | QCOMPARE(spy5.count(), 0); | |
264 | QCOMPARE(spy6.count(), 0); |
|
263 | QCOMPARE(spy6.count(), 0); | |
265 | QCOMPARE(spy7.count(), 0); |
|
264 | QCOMPARE(spy7.count(), 0); | |
266 | QCOMPARE(spy8.count(), 0); |
|
265 | QCOMPARE(spy8.count(), 0); | |
267 |
|
266 | |||
268 | m_chart->setAxisX(m_axis, m_series); |
|
267 | m_chart->setAxisX(m_axis, m_series); | |
269 | m_view->show(); |
|
268 | m_view->show(); | |
270 | QTest::qWaitForWindowShown(m_view); |
|
269 | QTest::qWaitForWindowShown(m_view); | |
271 | QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible); |
|
270 | QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible); | |
272 |
|
271 | |||
273 | } |
|
272 | } | |
274 |
|
273 | |||
275 | void tst_QAbstractAxis::visible_data() |
|
274 | void tst_QAbstractAxis::visible_data() | |
276 | { |
|
275 | { | |
277 | QTest::addColumn<bool>("visible"); |
|
276 | QTest::addColumn<bool>("visible"); | |
278 | QTest::newRow("true") << true; |
|
277 | QTest::newRow("true") << true; | |
279 | QTest::newRow("false") << false; |
|
278 | QTest::newRow("false") << false; | |
280 | } |
|
279 | } | |
281 |
|
280 | |||
282 | void tst_QAbstractAxis::visible() |
|
281 | void tst_QAbstractAxis::visible() | |
283 | { |
|
282 | { | |
284 | QFETCH(bool, visible); |
|
283 | QFETCH(bool, visible); | |
285 |
|
284 | |||
286 | m_axis->setVisible(!visible); |
|
285 | m_axis->setVisible(!visible); | |
287 |
|
286 | |||
288 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
287 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
289 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
288 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
290 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
289 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
291 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
290 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
292 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
291 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
293 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
292 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
294 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
293 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
295 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
294 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
296 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
295 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
297 |
|
296 | |||
298 | m_axis->setVisible(visible); |
|
297 | m_axis->setVisible(visible); | |
299 | QCOMPARE(m_axis->isVisible(), visible); |
|
298 | QCOMPARE(m_axis->isVisible(), visible); | |
300 |
|
299 | |||
301 | QCOMPARE(spy0.count(), 0); |
|
300 | QCOMPARE(spy0.count(), 0); | |
302 | QCOMPARE(spy1.count(), 0); |
|
301 | QCOMPARE(spy1.count(), 0); | |
303 | QCOMPARE(spy2.count(), 0); |
|
302 | QCOMPARE(spy2.count(), 0); | |
304 | QCOMPARE(spy3.count(), 0); |
|
303 | QCOMPARE(spy3.count(), 0); | |
305 | QCOMPARE(spy4.count(), 0); |
|
304 | QCOMPARE(spy4.count(), 0); | |
306 | QCOMPARE(spy5.count(), 0); |
|
305 | QCOMPARE(spy5.count(), 0); | |
307 | QCOMPARE(spy6.count(), 0); |
|
306 | QCOMPARE(spy6.count(), 0); | |
308 | QCOMPARE(spy7.count(), 0); |
|
307 | QCOMPARE(spy7.count(), 0); | |
309 | QCOMPARE(spy8.count(), 1); |
|
308 | QCOMPARE(spy8.count(), 1); | |
310 |
|
309 | |||
311 | m_chart->setAxisX(m_axis, m_series); |
|
310 | m_chart->setAxisX(m_axis, m_series); | |
312 | m_view->show(); |
|
311 | m_view->show(); | |
313 | QTest::qWaitForWindowShown(m_view); |
|
312 | QTest::qWaitForWindowShown(m_view); | |
314 | QCOMPARE(m_axis->isVisible(), true); |
|
313 | QCOMPARE(m_axis->isVisible(), true); | |
315 | } |
|
314 | } | |
316 |
|
315 | |||
317 | void tst_QAbstractAxis::labelsAngle_data() |
|
316 | void tst_QAbstractAxis::labelsAngle_data() | |
318 | { |
|
317 | { | |
319 | QTest::addColumn<int>("labelsAngle"); |
|
318 | QTest::addColumn<int>("labelsAngle"); | |
320 | QTest::newRow("0") << 0; |
|
319 | QTest::newRow("0") << 0; | |
321 | QTest::newRow("45") << 45; |
|
320 | QTest::newRow("45") << 45; | |
322 | QTest::newRow("90") << 90; |
|
321 | QTest::newRow("90") << 90; | |
323 | } |
|
322 | } | |
324 |
|
323 | |||
325 | void tst_QAbstractAxis::labelsAngle() |
|
324 | void tst_QAbstractAxis::labelsAngle() | |
326 | { |
|
325 | { | |
327 | QFETCH(int, labelsAngle); |
|
326 | QFETCH(int, labelsAngle); | |
328 |
|
327 | |||
329 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
328 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
330 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
329 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
331 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
330 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
332 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
331 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
333 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
332 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
334 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
333 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
335 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
334 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
336 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
335 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
337 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
336 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
338 |
|
337 | |||
339 | m_axis->setLabelsAngle(labelsAngle); |
|
338 | m_axis->setLabelsAngle(labelsAngle); | |
340 | QCOMPARE(m_axis->labelsAngle(), labelsAngle); |
|
339 | QCOMPARE(m_axis->labelsAngle(), labelsAngle); | |
341 |
|
340 | |||
342 | QCOMPARE(spy0.count(), 0); |
|
341 | QCOMPARE(spy0.count(), 0); | |
343 | QCOMPARE(spy1.count(), 0); |
|
342 | QCOMPARE(spy1.count(), 0); | |
344 | QCOMPARE(spy2.count(), 0); |
|
343 | QCOMPARE(spy2.count(), 0); | |
345 | QCOMPARE(spy3.count(), 0); |
|
344 | QCOMPARE(spy3.count(), 0); | |
346 | QCOMPARE(spy4.count(), 0); |
|
345 | QCOMPARE(spy4.count(), 0); | |
347 | QCOMPARE(spy5.count(), 0); |
|
346 | QCOMPARE(spy5.count(), 0); | |
348 | QCOMPARE(spy6.count(), 0); |
|
347 | QCOMPARE(spy6.count(), 0); | |
349 | QCOMPARE(spy7.count(), 0); |
|
348 | QCOMPARE(spy7.count(), 0); | |
350 | QCOMPARE(spy8.count(), 0); |
|
349 | QCOMPARE(spy8.count(), 0); | |
351 |
|
350 | |||
352 | m_chart->setAxisX(m_axis, m_series); |
|
351 | m_chart->setAxisX(m_axis, m_series); | |
353 | m_view->show(); |
|
352 | m_view->show(); | |
354 | QTest::qWaitForWindowShown(m_view); |
|
353 | QTest::qWaitForWindowShown(m_view); | |
355 | QCOMPARE(m_axis->labelsAngle(), labelsAngle); |
|
354 | QCOMPARE(m_axis->labelsAngle(), labelsAngle); | |
356 | } |
|
355 | } | |
357 |
|
356 | |||
358 | void tst_QAbstractAxis::labelsBrush_data() |
|
357 | void tst_QAbstractAxis::labelsBrush_data() | |
359 | { |
|
358 | { | |
360 | QTest::addColumn<QBrush>("labelsBrush"); |
|
359 | QTest::addColumn<QBrush>("labelsBrush"); | |
361 | QTest::newRow("null") << QBrush(); |
|
360 | QTest::newRow("null") << QBrush(); | |
362 | QTest::newRow("blue") << QBrush(Qt::blue); |
|
361 | QTest::newRow("blue") << QBrush(Qt::blue); | |
363 | QTest::newRow("black") << QBrush(Qt::black); |
|
362 | QTest::newRow("black") << QBrush(Qt::black); | |
364 |
|
363 | |||
365 | } |
|
364 | } | |
366 |
|
365 | |||
367 | void tst_QAbstractAxis::labelsBrush() |
|
366 | void tst_QAbstractAxis::labelsBrush() | |
368 | { |
|
367 | { | |
369 |
|
368 | |||
370 | QFETCH(QBrush, labelsBrush); |
|
369 | QFETCH(QBrush, labelsBrush); | |
371 |
|
370 | |||
372 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
371 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
373 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
372 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
374 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
373 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
375 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
374 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
376 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
375 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
377 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
376 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
378 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
377 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
379 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
378 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
380 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
379 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
381 |
|
380 | |||
382 | m_axis->setLabelsBrush(labelsBrush); |
|
381 | m_axis->setLabelsBrush(labelsBrush); | |
383 | QCOMPARE(m_axis->labelsBrush(), labelsBrush); |
|
382 | QCOMPARE(m_axis->labelsBrush(), labelsBrush); | |
384 |
|
383 | |||
385 | QCOMPARE(spy0.count(), 0); |
|
384 | QCOMPARE(spy0.count(), 0); | |
386 | QCOMPARE(spy1.count(), 0); |
|
385 | QCOMPARE(spy1.count(), 0); | |
387 | QCOMPARE(spy2.count(), 0); |
|
386 | QCOMPARE(spy2.count(), 0); | |
388 | QCOMPARE(spy3.count(), 0); |
|
387 | QCOMPARE(spy3.count(), 0); | |
389 | QCOMPARE(spy4.count(), 0); |
|
388 | QCOMPARE(spy4.count(), 0); | |
390 | QCOMPARE(spy5.count(), 0); |
|
389 | QCOMPARE(spy5.count(), 0); | |
391 | //TODO QCOMPARE(spy6.count(), 0); |
|
390 | //TODO QCOMPARE(spy6.count(), 0); | |
392 | QCOMPARE(spy7.count(), 0); |
|
391 | QCOMPARE(spy7.count(), 0); | |
393 | QCOMPARE(spy8.count(), 0); |
|
392 | QCOMPARE(spy8.count(), 0); | |
394 |
|
393 | |||
395 | m_view->show(); |
|
394 | m_view->show(); | |
396 | QTest::qWaitForWindowShown(m_view); |
|
395 | QTest::qWaitForWindowShown(m_view); | |
397 | QCOMPARE(m_axis->labelsBrush(), labelsBrush); |
|
396 | QCOMPARE(m_axis->labelsBrush(), labelsBrush); | |
398 |
|
397 | |||
399 | } |
|
398 | } | |
400 |
|
399 | |||
401 | void tst_QAbstractAxis::labelsColor_data() |
|
400 | void tst_QAbstractAxis::labelsColor_data() | |
402 | { |
|
401 | { | |
403 |
|
402 | |||
404 | } |
|
403 | } | |
405 |
|
404 | |||
406 | void tst_QAbstractAxis::labelsColor() |
|
405 | void tst_QAbstractAxis::labelsColor() | |
407 | { |
|
406 | { | |
408 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); |
|
407 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); | |
409 | } |
|
408 | } | |
410 |
|
409 | |||
411 | void tst_QAbstractAxis::labelsFont_data() |
|
410 | void tst_QAbstractAxis::labelsFont_data() | |
412 | { |
|
411 | { | |
413 | QTest::addColumn<QFont>("labelsFont"); |
|
412 | QTest::addColumn<QFont>("labelsFont"); | |
414 | QTest::newRow("null") << QFont(); |
|
413 | QTest::newRow("null") << QFont(); | |
415 | QTest::newRow("serif") << QFont("SansSerif"); |
|
414 | QTest::newRow("serif") << QFont("SansSerif"); | |
416 | } |
|
415 | } | |
417 |
|
416 | |||
418 | void tst_QAbstractAxis::labelsFont() |
|
417 | void tst_QAbstractAxis::labelsFont() | |
419 | { |
|
418 | { | |
420 |
|
419 | |||
421 | QFETCH(QFont, labelsFont); |
|
420 | QFETCH(QFont, labelsFont); | |
422 |
|
421 | |||
423 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
422 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
424 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
423 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
425 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
424 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
426 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
425 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
427 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
426 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
428 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
427 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
429 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
428 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
430 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
429 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
431 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
430 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
432 |
|
431 | |||
433 | m_axis->setLabelsFont(labelsFont); |
|
432 | m_axis->setLabelsFont(labelsFont); | |
434 | QCOMPARE(m_axis->labelsFont(), labelsFont); |
|
433 | QCOMPARE(m_axis->labelsFont(), labelsFont); | |
435 |
|
434 | |||
436 | QCOMPARE(spy0.count(), 0); |
|
435 | QCOMPARE(spy0.count(), 0); | |
437 | QCOMPARE(spy1.count(), 0); |
|
436 | QCOMPARE(spy1.count(), 0); | |
438 | QCOMPARE(spy2.count(), 0); |
|
437 | QCOMPARE(spy2.count(), 0); | |
439 | QCOMPARE(spy3.count(), 0); |
|
438 | QCOMPARE(spy3.count(), 0); | |
440 | QCOMPARE(spy4.count(), 0); |
|
439 | QCOMPARE(spy4.count(), 0); | |
441 | QCOMPARE(spy5.count(), 0); |
|
440 | QCOMPARE(spy5.count(), 0); | |
442 | QCOMPARE(spy6.count(), 0); |
|
441 | QCOMPARE(spy6.count(), 0); | |
443 | QCOMPARE(spy7.count(), 0); |
|
442 | QCOMPARE(spy7.count(), 0); | |
444 | QCOMPARE(spy8.count(), 0); |
|
443 | QCOMPARE(spy8.count(), 0); | |
445 |
|
444 | |||
446 | m_view->show(); |
|
445 | m_view->show(); | |
447 | QTest::qWaitForWindowShown(m_view); |
|
446 | QTest::qWaitForWindowShown(m_view); | |
448 | QCOMPARE(m_axis->labelsFont(), labelsFont); |
|
447 | QCOMPARE(m_axis->labelsFont(), labelsFont); | |
449 |
|
448 | |||
450 | } |
|
449 | } | |
451 |
|
450 | |||
452 | void tst_QAbstractAxis::labelsPen_data() |
|
451 | void tst_QAbstractAxis::labelsPen_data() | |
453 | { |
|
452 | { | |
454 | QTest::addColumn<QPen>("labelsPen"); |
|
453 | QTest::addColumn<QPen>("labelsPen"); | |
455 | QTest::newRow("null") << QPen(); |
|
454 | QTest::newRow("null") << QPen(); | |
456 | QTest::newRow("blue") << QPen(Qt::blue); |
|
455 | QTest::newRow("blue") << QPen(Qt::blue); | |
457 | QTest::newRow("black") << QPen(Qt::black); |
|
456 | QTest::newRow("black") << QPen(Qt::black); | |
458 | QTest::newRow("red") << QPen(Qt::red); |
|
457 | QTest::newRow("red") << QPen(Qt::red); | |
459 | } |
|
458 | } | |
460 |
|
459 | |||
461 | void tst_QAbstractAxis::labelsPen() |
|
460 | void tst_QAbstractAxis::labelsPen() | |
462 | { |
|
461 | { | |
463 | QFETCH(QPen, labelsPen); |
|
462 | QFETCH(QPen, labelsPen); | |
464 |
|
463 | |||
465 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
464 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
466 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
465 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
467 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
466 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
468 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
467 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
469 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
468 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
470 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
469 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
471 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
470 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
472 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
471 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
473 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
472 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
474 |
|
473 | |||
475 | m_axis->setLabelsPen(labelsPen); |
|
474 | m_axis->setLabelsPen(labelsPen); | |
476 | QCOMPARE(m_axis->labelsPen(), labelsPen); |
|
475 | QCOMPARE(m_axis->labelsPen(), labelsPen); | |
477 |
|
476 | |||
478 | QCOMPARE(spy0.count(), 0); |
|
477 | QCOMPARE(spy0.count(), 0); | |
479 | QCOMPARE(spy1.count(), 0); |
|
478 | QCOMPARE(spy1.count(), 0); | |
480 | QCOMPARE(spy2.count(), 0); |
|
479 | QCOMPARE(spy2.count(), 0); | |
481 | QCOMPARE(spy3.count(), 0); |
|
480 | QCOMPARE(spy3.count(), 0); | |
482 | QCOMPARE(spy4.count(), 0); |
|
481 | QCOMPARE(spy4.count(), 0); | |
483 | QCOMPARE(spy5.count(), 0); |
|
482 | QCOMPARE(spy5.count(), 0); | |
484 | QCOMPARE(spy6.count(), 0); |
|
483 | QCOMPARE(spy6.count(), 0); | |
485 | QCOMPARE(spy7.count(), 0); |
|
484 | QCOMPARE(spy7.count(), 0); | |
486 | QCOMPARE(spy8.count(), 0); |
|
485 | QCOMPARE(spy8.count(), 0); | |
487 |
|
486 | |||
488 | m_chart->setAxisX(m_axis, m_series); |
|
487 | m_chart->setAxisX(m_axis, m_series); | |
489 | m_view->show(); |
|
488 | m_view->show(); | |
490 | QTest::qWaitForWindowShown(m_view); |
|
489 | QTest::qWaitForWindowShown(m_view); | |
491 | //TODO QCOMPARE(m_axis->labelsPen(), labelsPen); |
|
490 | //TODO QCOMPARE(m_axis->labelsPen(), labelsPen); | |
492 | } |
|
491 | } | |
493 |
|
492 | |||
494 | void tst_QAbstractAxis::labelsVisible_data() |
|
493 | void tst_QAbstractAxis::labelsVisible_data() | |
495 | { |
|
494 | { | |
496 | QTest::addColumn<bool>("labelsVisible"); |
|
495 | QTest::addColumn<bool>("labelsVisible"); | |
497 | QTest::newRow("true") << true; |
|
496 | QTest::newRow("true") << true; | |
498 | QTest::newRow("false") << false; |
|
497 | QTest::newRow("false") << false; | |
499 | } |
|
498 | } | |
500 |
|
499 | |||
501 | void tst_QAbstractAxis::labelsVisible() |
|
500 | void tst_QAbstractAxis::labelsVisible() | |
502 | { |
|
501 | { | |
503 | QFETCH(bool, labelsVisible); |
|
502 | QFETCH(bool, labelsVisible); | |
504 |
|
503 | |||
505 | m_axis->setLabelsVisible(!labelsVisible); |
|
504 | m_axis->setLabelsVisible(!labelsVisible); | |
506 |
|
505 | |||
507 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
506 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
508 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
507 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
509 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
508 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
510 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
509 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
511 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
510 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
512 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
511 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
513 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
512 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
514 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
513 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
515 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
514 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
516 |
|
515 | |||
517 | m_axis->setLabelsVisible(labelsVisible); |
|
516 | m_axis->setLabelsVisible(labelsVisible); | |
518 | QCOMPARE(m_axis->labelsVisible(), labelsVisible); |
|
517 | QCOMPARE(m_axis->labelsVisible(), labelsVisible); | |
519 |
|
518 | |||
520 | QCOMPARE(spy0.count(), 0); |
|
519 | QCOMPARE(spy0.count(), 0); | |
521 | QCOMPARE(spy1.count(), 0); |
|
520 | QCOMPARE(spy1.count(), 0); | |
522 | QCOMPARE(spy2.count(), 0); |
|
521 | QCOMPARE(spy2.count(), 0); | |
523 | QCOMPARE(spy3.count(), 0); |
|
522 | QCOMPARE(spy3.count(), 0); | |
524 | QCOMPARE(spy4.count(), 1); |
|
523 | QCOMPARE(spy4.count(), 1); | |
525 | QCOMPARE(spy5.count(), 0); |
|
524 | QCOMPARE(spy5.count(), 0); | |
526 | QCOMPARE(spy6.count(), 0); |
|
525 | QCOMPARE(spy6.count(), 0); | |
527 | QCOMPARE(spy7.count(), 0); |
|
526 | QCOMPARE(spy7.count(), 0); | |
528 | QCOMPARE(spy8.count(), 0); |
|
527 | QCOMPARE(spy8.count(), 0); | |
529 |
|
528 | |||
530 | m_chart->setAxisX(m_axis, m_series); |
|
529 | m_chart->setAxisX(m_axis, m_series); | |
531 | m_view->show(); |
|
530 | m_view->show(); | |
532 | QTest::qWaitForWindowShown(m_view); |
|
531 | QTest::qWaitForWindowShown(m_view); | |
533 | QCOMPARE(m_axis->labelsVisible(), labelsVisible); |
|
532 | QCOMPARE(m_axis->labelsVisible(), labelsVisible); | |
534 | } |
|
533 | } | |
535 |
|
534 | |||
536 | void tst_QAbstractAxis::orientation_data() |
|
535 | void tst_QAbstractAxis::orientation_data() | |
537 | { |
|
536 | { | |
538 | QTest::addColumn<Qt::Orientation>("orientation"); |
|
537 | QTest::addColumn<Qt::Orientation>("orientation"); | |
539 | QTest::newRow("Vertical") << Qt::Vertical; |
|
538 | QTest::newRow("Vertical") << Qt::Vertical; | |
540 | QTest::newRow("Horizontal") << Qt::Horizontal; |
|
539 | QTest::newRow("Horizontal") << Qt::Horizontal; | |
541 | } |
|
540 | } | |
542 |
|
541 | |||
543 | void tst_QAbstractAxis::orientation() |
|
542 | void tst_QAbstractAxis::orientation() | |
544 | { |
|
543 | { | |
545 | QFETCH(Qt::Orientation, orientation); |
|
544 | QFETCH(Qt::Orientation, orientation); | |
546 |
|
545 | |||
547 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
546 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
548 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
547 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
549 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
548 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
550 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
549 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
551 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
550 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
552 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
551 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
553 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
552 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
554 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
553 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
555 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
554 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
556 |
|
555 | |||
557 | if(orientation==Qt::Vertical){ |
|
556 | if(orientation==Qt::Vertical){ | |
558 | m_chart->setAxisY(m_axis,m_series); |
|
557 | m_chart->setAxisY(m_axis,m_series); | |
559 | }else{ |
|
558 | }else{ | |
560 | m_chart->setAxisX(m_axis,m_series); |
|
559 | m_chart->setAxisX(m_axis,m_series); | |
561 | } |
|
560 | } | |
562 | QCOMPARE(m_axis->orientation(), orientation); |
|
561 | QCOMPARE(m_axis->orientation(), orientation); | |
563 |
|
562 | |||
564 | QCOMPARE(spy0.count(), 0); |
|
563 | QCOMPARE(spy0.count(), 0); | |
565 | QCOMPARE(spy1.count(), 0); |
|
564 | QCOMPARE(spy1.count(), 0); | |
566 | QCOMPARE(spy2.count(), 0); |
|
565 | QCOMPARE(spy2.count(), 0); | |
567 | QCOMPARE(spy3.count(), 0); |
|
566 | QCOMPARE(spy3.count(), 0); | |
568 | QCOMPARE(spy4.count(), 0); |
|
567 | QCOMPARE(spy4.count(), 0); | |
569 | QCOMPARE(spy5.count(), 0); |
|
568 | QCOMPARE(spy5.count(), 0); | |
570 | QCOMPARE(spy6.count(), 0); |
|
569 | QCOMPARE(spy6.count(), 0); | |
571 | QCOMPARE(spy7.count(), 0); |
|
570 | QCOMPARE(spy7.count(), 0); | |
572 | QCOMPARE(spy8.count(), 1); |
|
571 | QCOMPARE(spy8.count(), 1); | |
573 |
|
572 | |||
574 | m_view->show(); |
|
573 | m_view->show(); | |
575 | QTest::qWaitForWindowShown(m_view); |
|
574 | QTest::qWaitForWindowShown(m_view); | |
576 | QCOMPARE(m_axis->orientation(), orientation); |
|
575 | QCOMPARE(m_axis->orientation(), orientation); | |
577 | } |
|
576 | } | |
578 |
|
577 | |||
579 | void tst_QAbstractAxis::setMax_data() |
|
578 | void tst_QAbstractAxis::setMax_data() | |
580 | { |
|
579 | { | |
581 | //just check if it does not crash |
|
580 | //just check if it does not crash | |
582 | QTest::addColumn<QVariant>("max"); |
|
581 | QTest::addColumn<QVariant>("max"); | |
583 | QTest::newRow("something") << QVariant("something"); |
|
582 | QTest::newRow("something") << QVariant("something"); | |
584 | QTest::newRow("1.0") << QVariant(1.0); |
|
583 | QTest::newRow("1.0") << QVariant(1.0); | |
585 | } |
|
584 | } | |
586 |
|
585 | |||
587 | void tst_QAbstractAxis::setMax() |
|
586 | void tst_QAbstractAxis::setMax() | |
588 | { |
|
587 | { | |
589 | QFETCH(QVariant, max); |
|
588 | QFETCH(QVariant, max); | |
590 | m_axis->setMax(max); |
|
589 | m_axis->setMax(max); | |
591 | } |
|
590 | } | |
592 |
|
591 | |||
593 | void tst_QAbstractAxis::setMin_data() |
|
592 | void tst_QAbstractAxis::setMin_data() | |
594 | { |
|
593 | { | |
595 | //just check if it does not crash |
|
594 | //just check if it does not crash | |
596 | QTest::addColumn<QVariant>("min"); |
|
595 | QTest::addColumn<QVariant>("min"); | |
597 | QTest::newRow("something") << QVariant("something"); |
|
596 | QTest::newRow("something") << QVariant("something"); | |
598 | QTest::newRow("1.0") << QVariant(1.0); |
|
597 | QTest::newRow("1.0") << QVariant(1.0); | |
599 | } |
|
598 | } | |
600 |
|
599 | |||
601 | // public void setMin(QVariant const& min) |
|
600 | // public void setMin(QVariant const& min) | |
602 | void tst_QAbstractAxis::setMin() |
|
601 | void tst_QAbstractAxis::setMin() | |
603 | { |
|
602 | { | |
604 | QFETCH(QVariant, min); |
|
603 | QFETCH(QVariant, min); | |
605 | m_axis->setMin(min); |
|
604 | m_axis->setMin(min); | |
606 | } |
|
605 | } | |
607 |
|
606 | |||
608 | void tst_QAbstractAxis::setRange_data() |
|
607 | void tst_QAbstractAxis::setRange_data() | |
609 | { |
|
608 | { | |
610 | //just check if it does not crash |
|
609 | //just check if it does not crash | |
611 | QTest::addColumn<QVariant>("min"); |
|
610 | QTest::addColumn<QVariant>("min"); | |
612 | QTest::addColumn<QVariant>("max"); |
|
611 | QTest::addColumn<QVariant>("max"); | |
613 | QTest::newRow("something") << QVariant("something0") << QVariant("something1"); |
|
612 | QTest::newRow("something") << QVariant("something0") << QVariant("something1"); | |
614 | QTest::newRow("-1 1") << QVariant(-1.0) << QVariant(1.0); |
|
613 | QTest::newRow("-1 1") << QVariant(-1.0) << QVariant(1.0); | |
615 | } |
|
614 | } | |
616 |
|
615 | |||
617 | // public void setRange(QVariant const& min, QVariant const& max) |
|
616 | // public void setRange(QVariant const& min, QVariant const& max) | |
618 | void tst_QAbstractAxis::setRange() |
|
617 | void tst_QAbstractAxis::setRange() | |
619 | { |
|
618 | { | |
620 |
|
619 | |||
621 | QFETCH(QVariant, min); |
|
620 | QFETCH(QVariant, min); | |
622 | QFETCH(QVariant, max); |
|
621 | QFETCH(QVariant, max); | |
623 | m_axis->setRange(min,max); |
|
622 | m_axis->setRange(min,max); | |
624 | } |
|
623 | } | |
625 |
|
624 | |||
626 | void tst_QAbstractAxis::shadesBorderColor_data() |
|
625 | void tst_QAbstractAxis::shadesBorderColor_data() | |
627 | { |
|
626 | { | |
628 |
|
627 | |||
629 | } |
|
628 | } | |
630 |
|
629 | |||
631 | void tst_QAbstractAxis::shadesBorderColor() |
|
630 | void tst_QAbstractAxis::shadesBorderColor() | |
632 | { |
|
631 | { | |
633 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); |
|
632 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); | |
634 | } |
|
633 | } | |
635 |
|
634 | |||
636 | void tst_QAbstractAxis::shadesBrush_data() |
|
635 | void tst_QAbstractAxis::shadesBrush_data() | |
637 | { |
|
636 | { | |
638 | QTest::addColumn<QBrush>("shadesBrush"); |
|
637 | QTest::addColumn<QBrush>("shadesBrush"); | |
639 | QTest::newRow("null") << QBrush(); |
|
638 | QTest::newRow("null") << QBrush(); | |
640 | QTest::newRow("blue") << QBrush(Qt::blue); |
|
639 | QTest::newRow("blue") << QBrush(Qt::blue); | |
641 | QTest::newRow("black") << QBrush(Qt::black); |
|
640 | QTest::newRow("black") << QBrush(Qt::black); | |
642 | } |
|
641 | } | |
643 |
|
642 | |||
644 | void tst_QAbstractAxis::shadesBrush() |
|
643 | void tst_QAbstractAxis::shadesBrush() | |
645 | { |
|
644 | { | |
646 | QFETCH(QBrush, shadesBrush); |
|
645 | QFETCH(QBrush, shadesBrush); | |
647 |
|
646 | |||
648 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
647 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
649 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
648 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
650 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
649 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
651 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
650 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
652 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
651 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
653 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
652 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
654 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
653 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
655 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
654 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
656 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
655 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
657 |
|
656 | |||
658 | m_axis->setShadesBrush(shadesBrush); |
|
657 | m_axis->setShadesBrush(shadesBrush); | |
659 | QCOMPARE(m_axis->shadesBrush(), shadesBrush); |
|
658 | QCOMPARE(m_axis->shadesBrush(), shadesBrush); | |
660 |
|
659 | |||
661 | QCOMPARE(spy0.count(), 0); |
|
660 | QCOMPARE(spy0.count(), 0); | |
662 | QCOMPARE(spy1.count(), 0); |
|
661 | QCOMPARE(spy1.count(), 0); | |
663 | QCOMPARE(spy2.count(), 0); |
|
662 | QCOMPARE(spy2.count(), 0); | |
664 | QCOMPARE(spy3.count(), 0); |
|
663 | QCOMPARE(spy3.count(), 0); | |
665 | QCOMPARE(spy4.count(), 0); |
|
664 | QCOMPARE(spy4.count(), 0); | |
666 | QCOMPARE(spy5.count(), 0); |
|
665 | QCOMPARE(spy5.count(), 0); | |
667 | //TODO QCOMPARE(spy6.count(), 0); |
|
666 | //TODO QCOMPARE(spy6.count(), 0); | |
668 | QCOMPARE(spy7.count(), 0); |
|
667 | QCOMPARE(spy7.count(), 0); | |
669 | QCOMPARE(spy8.count(), 0); |
|
668 | QCOMPARE(spy8.count(), 0); | |
670 |
|
669 | |||
671 | m_view->show(); |
|
670 | m_view->show(); | |
672 | QTest::qWaitForWindowShown(m_view); |
|
671 | QTest::qWaitForWindowShown(m_view); | |
673 | QCOMPARE(m_axis->shadesBrush(), shadesBrush); |
|
672 | QCOMPARE(m_axis->shadesBrush(), shadesBrush); | |
674 | } |
|
673 | } | |
675 |
|
674 | |||
676 | void tst_QAbstractAxis::shadesColor_data() |
|
675 | void tst_QAbstractAxis::shadesColor_data() | |
677 | { |
|
676 | { | |
678 | } |
|
677 | } | |
679 |
|
678 | |||
680 | // public QColor shadesColor() const |
|
679 | // public QColor shadesColor() const | |
681 | void tst_QAbstractAxis::shadesColor() |
|
680 | void tst_QAbstractAxis::shadesColor() | |
682 | { |
|
681 | { | |
683 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); |
|
682 | QSKIP("Test is not implemented. This is depreciated function", SkipAll); | |
684 | } |
|
683 | } | |
685 |
|
684 | |||
686 | void tst_QAbstractAxis::shadesPen_data() |
|
685 | void tst_QAbstractAxis::shadesPen_data() | |
687 | { |
|
686 | { | |
688 | QTest::addColumn<QPen>("shadesPen"); |
|
687 | QTest::addColumn<QPen>("shadesPen"); | |
689 | QTest::newRow("null") << QPen(); |
|
688 | QTest::newRow("null") << QPen(); | |
690 | QTest::newRow("blue") << QPen(Qt::blue); |
|
689 | QTest::newRow("blue") << QPen(Qt::blue); | |
691 | QTest::newRow("black") << QPen(Qt::black); |
|
690 | QTest::newRow("black") << QPen(Qt::black); | |
692 | QTest::newRow("red") << QPen(Qt::red); |
|
691 | QTest::newRow("red") << QPen(Qt::red); | |
693 | } |
|
692 | } | |
694 |
|
693 | |||
695 | void tst_QAbstractAxis::shadesPen() |
|
694 | void tst_QAbstractAxis::shadesPen() | |
696 | { |
|
695 | { | |
697 | QFETCH(QPen, shadesPen); |
|
696 | QFETCH(QPen, shadesPen); | |
698 |
|
697 | |||
699 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
698 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
700 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
699 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
701 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
700 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
702 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
701 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
703 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
702 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
704 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
703 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
705 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
704 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
706 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
705 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
707 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
706 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
708 |
|
707 | |||
709 | m_axis->setShadesPen(shadesPen); |
|
708 | m_axis->setShadesPen(shadesPen); | |
710 | QCOMPARE(m_axis->shadesPen(), shadesPen); |
|
709 | QCOMPARE(m_axis->shadesPen(), shadesPen); | |
711 |
|
710 | |||
712 | QCOMPARE(spy0.count(), 0); |
|
711 | QCOMPARE(spy0.count(), 0); | |
713 | QCOMPARE(spy1.count(), 0); |
|
712 | QCOMPARE(spy1.count(), 0); | |
714 | QCOMPARE(spy2.count(), 0); |
|
713 | QCOMPARE(spy2.count(), 0); | |
715 | QCOMPARE(spy3.count(), 0); |
|
714 | QCOMPARE(spy3.count(), 0); | |
716 | QCOMPARE(spy4.count(), 0); |
|
715 | QCOMPARE(spy4.count(), 0); | |
717 | QCOMPARE(spy5.count(), 0); |
|
716 | QCOMPARE(spy5.count(), 0); | |
718 | QCOMPARE(spy6.count(), 0); |
|
717 | QCOMPARE(spy6.count(), 0); | |
719 | QCOMPARE(spy7.count(), 0); |
|
718 | QCOMPARE(spy7.count(), 0); | |
720 | QCOMPARE(spy8.count(), 0); |
|
719 | QCOMPARE(spy8.count(), 0); | |
721 |
|
720 | |||
722 | m_chart->setAxisX(m_axis, m_series); |
|
721 | m_chart->setAxisX(m_axis, m_series); | |
723 | m_view->show(); |
|
722 | m_view->show(); | |
724 | QTest::qWaitForWindowShown(m_view); |
|
723 | QTest::qWaitForWindowShown(m_view); | |
725 | QCOMPARE(m_axis->shadesPen(), shadesPen); |
|
724 | QCOMPARE(m_axis->shadesPen(), shadesPen); | |
726 | } |
|
725 | } | |
727 |
|
726 | |||
728 | void tst_QAbstractAxis::shadesVisible_data() |
|
727 | void tst_QAbstractAxis::shadesVisible_data() | |
729 | { |
|
728 | { | |
730 | QTest::addColumn<bool>("shadesVisible"); |
|
729 | QTest::addColumn<bool>("shadesVisible"); | |
731 | QTest::newRow("true") << true; |
|
730 | QTest::newRow("true") << true; | |
732 | QTest::newRow("false") << false; |
|
731 | QTest::newRow("false") << false; | |
733 | } |
|
732 | } | |
734 |
|
733 | |||
735 | void tst_QAbstractAxis::shadesVisible() |
|
734 | void tst_QAbstractAxis::shadesVisible() | |
736 | { |
|
735 | { | |
737 | QFETCH(bool, shadesVisible); |
|
736 | QFETCH(bool, shadesVisible); | |
738 |
|
737 | |||
739 | m_axis->setShadesVisible(!shadesVisible); |
|
738 | m_axis->setShadesVisible(!shadesVisible); | |
740 |
|
739 | |||
741 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
740 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
742 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
741 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
743 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
742 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
744 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
743 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
745 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
744 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
746 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
745 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
747 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
746 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
748 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
747 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
749 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
748 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
750 |
|
749 | |||
751 | m_axis->setShadesVisible(shadesVisible); |
|
750 | m_axis->setShadesVisible(shadesVisible); | |
752 | QCOMPARE(m_axis->shadesVisible(), shadesVisible); |
|
751 | QCOMPARE(m_axis->shadesVisible(), shadesVisible); | |
753 |
|
752 | |||
754 | QCOMPARE(spy0.count(), 0); |
|
753 | QCOMPARE(spy0.count(), 0); | |
755 | QCOMPARE(spy1.count(), 0); |
|
754 | QCOMPARE(spy1.count(), 0); | |
756 | QCOMPARE(spy2.count(), 0); |
|
755 | QCOMPARE(spy2.count(), 0); | |
757 | QCOMPARE(spy3.count(), 0); |
|
756 | QCOMPARE(spy3.count(), 0); | |
758 | QCOMPARE(spy4.count(), 0); |
|
757 | QCOMPARE(spy4.count(), 0); | |
759 | QCOMPARE(spy5.count(), 0); |
|
758 | QCOMPARE(spy5.count(), 0); | |
760 | QCOMPARE(spy6.count(), 0); |
|
759 | QCOMPARE(spy6.count(), 0); | |
761 | QCOMPARE(spy7.count(), 1); |
|
760 | QCOMPARE(spy7.count(), 1); | |
762 | QCOMPARE(spy8.count(), 0); |
|
761 | QCOMPARE(spy8.count(), 0); | |
763 |
|
762 | |||
764 | m_chart->setAxisX(m_axis, m_series); |
|
763 | m_chart->setAxisX(m_axis, m_series); | |
765 | m_view->show(); |
|
764 | m_view->show(); | |
766 | QTest::qWaitForWindowShown(m_view); |
|
765 | QTest::qWaitForWindowShown(m_view); | |
767 | QCOMPARE(m_axis->shadesVisible(), shadesVisible); |
|
766 | QCOMPARE(m_axis->shadesVisible(), shadesVisible); | |
768 | } |
|
767 | } | |
769 |
|
768 | |||
770 | void tst_QAbstractAxis::show_data() |
|
769 | void tst_QAbstractAxis::show_data() | |
771 | { |
|
770 | { | |
772 |
|
771 | |||
773 | } |
|
772 | } | |
774 |
|
773 | |||
775 | void tst_QAbstractAxis::show() |
|
774 | void tst_QAbstractAxis::show() | |
776 | { |
|
775 | { | |
777 | m_axis->hide(); |
|
776 | m_axis->hide(); | |
778 | QCOMPARE(m_axis->isVisible(), false); |
|
777 | QCOMPARE(m_axis->isVisible(), false); | |
779 |
|
778 | |||
780 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
779 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
781 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
780 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
782 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
781 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
783 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
782 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
784 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
783 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
785 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
784 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
786 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
785 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
787 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
786 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
788 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
787 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
789 |
|
788 | |||
790 | m_axis->show(); |
|
789 | m_axis->show(); | |
791 |
|
790 | |||
792 | QCOMPARE(spy0.count(), 0); |
|
791 | QCOMPARE(spy0.count(), 0); | |
793 | QCOMPARE(spy1.count(), 0); |
|
792 | QCOMPARE(spy1.count(), 0); | |
794 | QCOMPARE(spy2.count(), 0); |
|
793 | QCOMPARE(spy2.count(), 0); | |
795 | QCOMPARE(spy3.count(), 0); |
|
794 | QCOMPARE(spy3.count(), 0); | |
796 | QCOMPARE(spy4.count(), 0); |
|
795 | QCOMPARE(spy4.count(), 0); | |
797 | QCOMPARE(spy5.count(), 0); |
|
796 | QCOMPARE(spy5.count(), 0); | |
798 | QCOMPARE(spy6.count(), 0); |
|
797 | QCOMPARE(spy6.count(), 0); | |
799 | QCOMPARE(spy7.count(), 0); |
|
798 | QCOMPARE(spy7.count(), 0); | |
800 | QCOMPARE(spy8.count(), 1); |
|
799 | QCOMPARE(spy8.count(), 1); | |
801 | QCOMPARE(m_axis->isVisible(), true); |
|
800 | QCOMPARE(m_axis->isVisible(), true); | |
802 | } |
|
801 | } | |
803 |
|
802 | |||
804 | void tst_QAbstractAxis::hide_data() |
|
803 | void tst_QAbstractAxis::hide_data() | |
805 | { |
|
804 | { | |
806 |
|
805 | |||
807 | } |
|
806 | } | |
808 |
|
807 | |||
809 | void tst_QAbstractAxis::hide() |
|
808 | void tst_QAbstractAxis::hide() | |
810 | { |
|
809 | { | |
811 | m_axis->show(); |
|
810 | m_axis->show(); | |
812 | QCOMPARE(m_axis->isVisible(),true); |
|
811 | QCOMPARE(m_axis->isVisible(),true); | |
813 |
|
812 | |||
814 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); |
|
813 | QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool))); | |
815 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); |
|
814 | QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); | |
816 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); |
|
815 | QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); | |
817 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); |
|
816 | QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); | |
818 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); |
|
817 | QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); | |
819 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); |
|
818 | QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); | |
820 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); |
|
819 | QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); | |
821 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); |
|
820 | QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); | |
822 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); |
|
821 | QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); | |
823 |
|
822 | |||
824 | m_axis->hide(); |
|
823 | m_axis->hide(); | |
825 |
|
824 | |||
826 | QCOMPARE(spy0.count(), 0); |
|
825 | QCOMPARE(spy0.count(), 0); | |
827 | QCOMPARE(spy1.count(), 0); |
|
826 | QCOMPARE(spy1.count(), 0); | |
828 | QCOMPARE(spy2.count(), 0); |
|
827 | QCOMPARE(spy2.count(), 0); | |
829 | QCOMPARE(spy3.count(), 0); |
|
828 | QCOMPARE(spy3.count(), 0); | |
830 | QCOMPARE(spy4.count(), 0); |
|
829 | QCOMPARE(spy4.count(), 0); | |
831 | QCOMPARE(spy5.count(), 0); |
|
830 | QCOMPARE(spy5.count(), 0); | |
832 | QCOMPARE(spy6.count(), 0); |
|
831 | QCOMPARE(spy6.count(), 0); | |
833 | QCOMPARE(spy7.count(), 0); |
|
832 | QCOMPARE(spy7.count(), 0); | |
834 | QCOMPARE(spy8.count(), 1); |
|
833 | QCOMPARE(spy8.count(), 1); | |
835 | QCOMPARE(m_axis->isVisible(),false); |
|
834 | QCOMPARE(m_axis->isVisible(),false); | |
836 | } |
|
835 | } | |
837 |
|
836 | |||
838 |
|
837 | |||
839 |
|
838 | |||
840 |
|
839 | |||
841 |
|
840 | |||
842 |
|
841 | |||
843 |
|
842 | |||
844 |
|
843 | |||
845 |
|
844 | |||
846 |
|
845 | |||
847 |
|
846 | |||
848 |
|
847 |
General Comments 0
You need to be logged in to leave comments.
Login now