@@ -1,116 +1,116 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2014 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and Digia. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | |
|
20 | 20 | #include "declarativexyseries.h" |
|
21 | 21 | #include "declarativexypoint.h" |
|
22 | 22 | #include <QtCharts/QVXYModelMapper> |
|
23 | 23 | #include <QtCharts/QHXYModelMapper> |
|
24 | 24 | |
|
25 | 25 | QT_CHARTS_BEGIN_NAMESPACE |
|
26 | 26 | |
|
27 | 27 | DeclarativeXySeries::DeclarativeXySeries() |
|
28 | 28 | { |
|
29 | 29 | } |
|
30 | 30 | |
|
31 | 31 | DeclarativeXySeries::~DeclarativeXySeries() |
|
32 | 32 | { |
|
33 | 33 | } |
|
34 | 34 | |
|
35 | 35 | void DeclarativeXySeries::classBegin() |
|
36 | 36 | { |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | void DeclarativeXySeries::componentComplete() |
|
40 | 40 | { |
|
41 | 41 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
42 | 42 | Q_ASSERT(series); |
|
43 | 43 | |
|
44 | 44 | foreach (QObject *child, series->children()) { |
|
45 | 45 | if (qobject_cast<DeclarativeXYPoint *>(child)) { |
|
46 | 46 | DeclarativeXYPoint *point = qobject_cast<DeclarativeXYPoint *>(child); |
|
47 | 47 | series->append(point->x(), point->y()); |
|
48 | 48 | } else if (qobject_cast<QVXYModelMapper *>(child)) { |
|
49 | 49 | QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child); |
|
50 | 50 | mapper->setSeries(series); |
|
51 | 51 | } else if (qobject_cast<QHXYModelMapper *>(child)) { |
|
52 | 52 | QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child); |
|
53 | 53 | mapper->setSeries(series); |
|
54 | 54 | } |
|
55 | 55 | } |
|
56 | 56 | } |
|
57 | 57 | |
|
58 | 58 | void DeclarativeXySeries::append(qreal x, qreal y) |
|
59 | 59 | { |
|
60 | 60 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
61 | 61 | Q_ASSERT(series); |
|
62 | 62 | series->append(x, y); |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | void DeclarativeXySeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY) |
|
66 | 66 | { |
|
67 | 67 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
68 | 68 | Q_ASSERT(series); |
|
69 | 69 | series->replace(oldX, oldY, newX, newY); |
|
70 | 70 | } |
|
71 | 71 | |
|
72 | 72 | void DeclarativeXySeries::replace(int index, qreal newX, qreal newY) |
|
73 | 73 | { |
|
74 | 74 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
75 | 75 | Q_ASSERT(series); |
|
76 | 76 | series->replace(index, newX, newY); |
|
77 | 77 | } |
|
78 | 78 | |
|
79 | 79 | void DeclarativeXySeries::remove(qreal x, qreal y) |
|
80 | 80 | { |
|
81 | 81 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
82 | 82 | Q_ASSERT(series); |
|
83 | 83 | series->remove(x, y); |
|
84 | 84 | } |
|
85 | 85 | |
|
86 | 86 | void DeclarativeXySeries::remove(int index) |
|
87 | 87 | { |
|
88 | 88 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
89 | 89 | Q_ASSERT(series); |
|
90 | 90 | series->remove(index); |
|
91 | 91 | } |
|
92 | 92 | |
|
93 | 93 | void DeclarativeXySeries::insert(int index, qreal x, qreal y) |
|
94 | 94 | { |
|
95 | 95 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
96 | 96 | Q_ASSERT(series); |
|
97 | 97 | series->insert(index, QPointF(x, y)); |
|
98 | 98 | } |
|
99 | 99 | |
|
100 | 100 | void DeclarativeXySeries::clear() |
|
101 | 101 | { |
|
102 | 102 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
103 | 103 | Q_ASSERT(series); |
|
104 | 104 | series->clear(); |
|
105 | 105 | } |
|
106 | 106 | |
|
107 | 107 | QPointF DeclarativeXySeries::at(int index) |
|
108 | 108 | { |
|
109 | 109 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
110 | 110 | Q_ASSERT(series); |
|
111 |
if (index >= 0 |
|
|
111 | if (index >= 0 && index < series->count()) | |
|
112 | 112 | return series->points().at(index); |
|
113 | 113 | return QPointF(0, 0); |
|
114 | 114 | } |
|
115 | 115 | |
|
116 | 116 | QT_CHARTS_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now