@@ -1,393 +1,393 | |||||
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 "declarativebarseries.h" |
|
21 | #include "declarativebarseries.h" | |
22 | #include "declarativechart.h" |
|
22 | #include "declarativechart.h" | |
23 | #include <QBarSet> |
|
23 | #include <QBarSet> | |
24 | #include <QVBarModelMapper> |
|
24 | #include <QVBarModelMapper> | |
25 | #include <QHBarModelMapper> |
|
25 | #include <QHBarModelMapper> | |
26 | #include <QAbstractAxis> |
|
26 | #include <QAbstractAxis> | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) : |
|
30 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) : | |
31 | QBarSet("", parent) |
|
31 | QBarSet("", parent) | |
32 | { |
|
32 | { | |
33 | connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int, int))); |
|
33 | connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int, int))); | |
34 | connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int))); |
|
34 | connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int))); | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | void DeclarativeBarSet::handleCountChanged(int index, int count) |
|
37 | void DeclarativeBarSet::handleCountChanged(int index, int count) | |
38 | { |
|
38 | { | |
39 | Q_UNUSED(index) |
|
39 | Q_UNUSED(index) | |
40 | Q_UNUSED(count) |
|
40 | Q_UNUSED(count) | |
41 | emit countChanged(QBarSet::count()); |
|
41 | emit countChanged(QBarSet::count()); | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | QVariantList DeclarativeBarSet::values() |
|
44 | QVariantList DeclarativeBarSet::values() | |
45 | { |
|
45 | { | |
46 | QVariantList values; |
|
46 | QVariantList values; | |
47 | for (int i(0); i < count(); i++) |
|
47 | for (int i(0); i < count(); i++) | |
48 | values.append(QVariant(QBarSet::at(i))); |
|
48 | values.append(QVariant(QBarSet::at(i))); | |
49 | return values; |
|
49 | return values; | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | void DeclarativeBarSet::setValues(QVariantList values) |
|
52 | void DeclarativeBarSet::setValues(QVariantList values) | |
53 | { |
|
53 | { | |
54 | while (count()) |
|
54 | while (count()) | |
55 | remove(count() - 1); |
|
55 | remove(count() - 1); | |
56 |
|
56 | |||
57 | for (int i(0); i < values.count(); i++) { |
|
57 | for (int i(0); i < values.count(); i++) { | |
58 | if (values.at(i).canConvert(QVariant::Double)) |
|
58 | if (values.at(i).canConvert(QVariant::Double)) | |
59 | QBarSet::append(values[i].toDouble()); |
|
59 | QBarSet::append(values[i].toDouble()); | |
60 | } |
|
60 | } | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 | DeclarativeAbstractBarSeries::DeclarativeAbstractBarSeries(QDeclarativeItem *parent) : |
|
63 | DeclarativeAbstractBarSeries::DeclarativeAbstractBarSeries(QDeclarativeItem *parent) : | |
64 | QAbstractBarSeries(parent) |
|
64 | QAbstractBarSeries(parent) | |
65 | { |
|
65 | { | |
66 | connect(this, SIGNAL(barsetsAdded(QList<QBarSet*>)), this, SLOT(handleAdded(QList<QBarSet*>))); |
|
66 | connect(this, SIGNAL(barsetsAdded(QList<QBarSet*>)), this, SLOT(handleAdded(QList<QBarSet*>))); | |
67 | connect(this, SIGNAL(barsetsRemoved(QList<QBarSet*>)), this, SLOT(handleRemoved(QList<QBarSet*>))); |
|
67 | connect(this, SIGNAL(barsetsRemoved(QList<QBarSet*>)), this, SLOT(handleRemoved(QList<QBarSet*>))); | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | void DeclarativeAbstractBarSeries::handleAdded(QList<QBarSet* > barsets) |
|
70 | void DeclarativeAbstractBarSeries::handleAdded(QList<QBarSet* > barsets) | |
71 | { |
|
71 | { | |
72 | foreach(QBarSet *b, barsets) { |
|
72 | foreach(QBarSet *b, barsets) { | |
73 | DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b); |
|
73 | DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b); | |
74 | emit added(barset); |
|
74 | emit added(barset); | |
75 | } |
|
75 | } | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | void DeclarativeAbstractBarSeries::handleRemoved(QList<QBarSet* > barsets) |
|
78 | void DeclarativeAbstractBarSeries::handleRemoved(QList<QBarSet* > barsets) | |
79 | { |
|
79 | { | |
80 | foreach(QBarSet *b, barsets) { |
|
80 | foreach(QBarSet *b, barsets) { | |
81 | DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b); |
|
81 | DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b); | |
82 | emit removed(barset); |
|
82 | emit removed(barset); | |
83 | } |
|
83 | } | |
84 | } |
|
84 | } | |
85 |
|
85 | |||
86 | void DeclarativeAbstractBarSeries::classBegin() |
|
86 | void DeclarativeAbstractBarSeries::classBegin() | |
87 | { |
|
87 | { | |
88 | } |
|
88 | } | |
89 |
|
89 | |||
90 | void DeclarativeAbstractBarSeries::componentComplete() |
|
90 | void DeclarativeAbstractBarSeries::componentComplete() | |
91 | { |
|
91 | { | |
92 | foreach(QObject *child, children()) { |
|
92 | foreach(QObject *child, children()) { | |
93 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
93 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
94 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
94 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
95 | } else if (qobject_cast<QVBarModelMapper *>(child)) { |
|
95 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
96 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
96 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
97 | mapper->setSeries(this); |
|
97 | mapper->setSeries(this); | |
98 | } else if (qobject_cast<QHBarModelMapper *>(child)) { |
|
98 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
99 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
99 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
100 | mapper->setSeries(this); |
|
100 | mapper->setSeries(this); | |
101 | } |
|
101 | } | |
102 | } |
|
102 | } | |
103 | } |
|
103 | } | |
104 |
|
104 | |||
105 | void DeclarativeAbstractBarSeries::setAxisX(QAbstractAxis *axis) |
|
105 | void DeclarativeAbstractBarSeries::setAxisX(QAbstractAxis *axis) | |
106 | { |
|
106 | { | |
107 | chart()->setAxisX(axis, this); |
|
107 | chart()->setAxisX(axis, this); | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 | QAbstractAxis *DeclarativeAbstractBarSeries::axisX() |
|
110 | QAbstractAxis *DeclarativeAbstractBarSeries::axisX() | |
111 | { |
|
111 | { | |
112 | return chart()->axisX(this); |
|
112 | return chart()->axisX(this); | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 | void DeclarativeAbstractBarSeries::setAxisY(QAbstractAxis *axis) |
|
115 | void DeclarativeAbstractBarSeries::setAxisY(QAbstractAxis *axis) | |
116 | { |
|
116 | { | |
117 | chart()->setAxisY(axis, this); |
|
117 | chart()->setAxisY(axis, this); | |
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | QAbstractAxis *DeclarativeAbstractBarSeries::axisY() |
|
120 | QAbstractAxis *DeclarativeAbstractBarSeries::axisY() | |
121 | { |
|
121 | { | |
122 | return chart()->axisY(this); |
|
122 | return chart()->axisY(this); | |
123 | } |
|
123 | } | |
124 |
|
124 | |||
125 | QDeclarativeListProperty<QObject> DeclarativeAbstractBarSeries::seriesChildren() |
|
125 | QDeclarativeListProperty<QObject> DeclarativeAbstractBarSeries::seriesChildren() | |
126 | { |
|
126 | { | |
127 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeAbstractBarSeries::appendSeriesChildren); |
|
127 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeAbstractBarSeries::appendSeriesChildren); | |
128 | } |
|
128 | } | |
129 |
|
129 | |||
130 | void DeclarativeAbstractBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
130 | void DeclarativeAbstractBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
131 | { |
|
131 | { | |
132 | // Empty implementation; the children are parsed in componentComplete instead |
|
132 | // Empty implementation; the children are parsed in componentComplete instead | |
133 | Q_UNUSED(list); |
|
133 | Q_UNUSED(list); | |
134 | Q_UNUSED(element); |
|
134 | Q_UNUSED(element); | |
135 | } |
|
135 | } | |
136 |
|
136 | |||
137 | DeclarativeBarSet *DeclarativeAbstractBarSeries::at(int index) |
|
137 | DeclarativeBarSet *DeclarativeAbstractBarSeries::at(int index) | |
138 | { |
|
138 | { | |
139 | QList<QBarSet*> setList = barSets(); |
|
139 | QList<QBarSet*> setList = barSets(); | |
140 | if (index >= 0 && index < setList.count()) |
|
140 | if (index >= 0 && index < setList.count()) | |
141 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
141 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
142 |
|
142 | |||
143 | return 0; |
|
143 | return 0; | |
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 | DeclarativeBarSet *DeclarativeAbstractBarSeries::insert(int index, QString label, QVariantList values) |
|
146 | DeclarativeBarSet *DeclarativeAbstractBarSeries::insert(int index, QString label, QVariantList values) | |
147 | { |
|
147 | { | |
148 | int insertIndex = index; |
|
148 | int insertIndex = index; | |
149 | if (insertIndex < 0) |
|
149 | if (insertIndex < 0) | |
150 | insertIndex = 0; |
|
150 | insertIndex = 0; | |
151 | else if (insertIndex > count()) |
|
151 | else if (insertIndex > count()) | |
152 | insertIndex = count(); |
|
152 | insertIndex = count(); | |
153 |
|
153 | |||
154 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
154 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
155 | barset->setLabel(label); |
|
155 | barset->setLabel(label); | |
156 | barset->setValues(values); |
|
156 | barset->setValues(values); | |
157 | if (QAbstractBarSeries::insert(insertIndex, barset)) |
|
157 | if (QAbstractBarSeries::insert(insertIndex, barset)) | |
158 | return barset; |
|
158 | return barset; | |
159 | delete barset; |
|
159 | delete barset; | |
160 | return 0; |
|
160 | return 0; | |
161 | } |
|
161 | } | |
162 |
|
162 | |||
163 | DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) : |
|
163 | DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) : | |
164 | QGroupedBarSeries(parent) |
|
164 | QGroupedBarSeries(parent) | |
165 | { |
|
165 | { | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 | void DeclarativeGroupedBarSeries::classBegin() |
|
168 | void DeclarativeGroupedBarSeries::classBegin() | |
169 | { |
|
169 | { | |
170 | } |
|
170 | } | |
171 |
|
171 | |||
172 | void DeclarativeGroupedBarSeries::componentComplete() |
|
172 | void DeclarativeGroupedBarSeries::componentComplete() | |
173 | { |
|
173 | { | |
174 | foreach(QObject *child, children()) { |
|
174 | foreach(QObject *child, children()) { | |
175 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
175 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
176 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
176 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
177 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
177 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
178 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
178 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
179 | mapper->setSeries(this); |
|
179 | mapper->setSeries(this); | |
180 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
180 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
181 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
181 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
182 | mapper->setSeries(this); |
|
182 | mapper->setSeries(this); | |
183 | } |
|
183 | } | |
184 | } |
|
184 | } | |
185 | } |
|
185 | } | |
186 |
|
186 | |||
187 | void DeclarativeGroupedBarSeries::setAxisX(QAbstractAxis *axis) |
|
187 | void DeclarativeGroupedBarSeries::setAxisX(QAbstractAxis *axis) | |
188 | { |
|
188 | { | |
189 | chart()->setAxisX(axis, this); |
|
189 | chart()->setAxisX(axis, this); | |
190 | } |
|
190 | } | |
191 |
|
191 | |||
192 | QAbstractAxis *DeclarativeGroupedBarSeries::axisX() |
|
192 | QAbstractAxis *DeclarativeGroupedBarSeries::axisX() | |
193 | { |
|
193 | { | |
194 | return chart()->axisX(this); |
|
194 | return chart()->axisX(this); | |
195 | } |
|
195 | } | |
196 |
|
196 | |||
197 | void DeclarativeGroupedBarSeries::setAxisY(QAbstractAxis *axis) |
|
197 | void DeclarativeGroupedBarSeries::setAxisY(QAbstractAxis *axis) | |
198 | { |
|
198 | { | |
199 | chart()->setAxisY(axis, this); |
|
199 | chart()->setAxisY(axis, this); | |
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | QAbstractAxis *DeclarativeGroupedBarSeries::axisY() |
|
202 | QAbstractAxis *DeclarativeGroupedBarSeries::axisY() | |
203 | { |
|
203 | { | |
204 | return chart()->axisY(this); |
|
204 | return chart()->axisY(this); | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | QDeclarativeListProperty<QObject> DeclarativeGroupedBarSeries::seriesChildren() |
|
207 | QDeclarativeListProperty<QObject> DeclarativeGroupedBarSeries::seriesChildren() | |
208 | { |
|
208 | { | |
209 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeAbstractBarSeries::appendSeriesChildren); |
|
209 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeAbstractBarSeries::appendSeriesChildren); | |
210 | } |
|
210 | } | |
211 |
|
211 | |||
212 | void DeclarativeGroupedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
212 | void DeclarativeGroupedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
213 | { |
|
213 | { | |
214 | // Empty implementation; the children are parsed in componentComplete instead |
|
214 | // Empty implementation; the children are parsed in componentComplete instead | |
215 | Q_UNUSED(list); |
|
215 | Q_UNUSED(list); | |
216 | Q_UNUSED(element); |
|
216 | Q_UNUSED(element); | |
217 | } |
|
217 | } | |
218 |
|
218 | |||
219 | DeclarativeBarSet *DeclarativeGroupedBarSeries::at(int index) |
|
219 | DeclarativeBarSet *DeclarativeGroupedBarSeries::at(int index) | |
220 | { |
|
220 | { | |
221 | QList<QBarSet*> setList = barSets(); |
|
221 | QList<QBarSet*> setList = barSets(); | |
222 | if (index >= 0 && index < setList.count()) |
|
222 | if (index >= 0 && index < setList.count()) | |
223 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
223 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
224 |
|
224 | |||
225 | return 0; |
|
225 | return 0; | |
226 | } |
|
226 | } | |
227 |
|
227 | |||
228 | DeclarativeBarSet *DeclarativeGroupedBarSeries::insert(int index, QString label, QVariantList values) |
|
228 | DeclarativeBarSet *DeclarativeGroupedBarSeries::insert(int index, QString label, QVariantList values) | |
229 | { |
|
229 | { | |
230 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
230 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
231 | barset->setLabel(label); |
|
231 | barset->setLabel(label); | |
232 | barset->setValues(values); |
|
232 | barset->setValues(values); | |
233 | if (QGroupedBarSeries::insert(index, barset)) |
|
233 | if (QGroupedBarSeries::insert(index, barset)) | |
234 | return barset; |
|
234 | return barset; | |
235 | delete barset; |
|
235 | delete barset; | |
236 | return 0; |
|
236 | return 0; | |
237 | } |
|
237 | } | |
238 |
|
238 | |||
239 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : |
|
239 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : | |
240 | QStackedBarSeries(parent) |
|
240 | QStackedBarSeries(parent) | |
241 | { |
|
241 | { | |
242 | } |
|
242 | } | |
243 |
|
243 | |||
244 | void DeclarativeStackedBarSeries::classBegin() |
|
244 | void DeclarativeStackedBarSeries::classBegin() | |
245 | { |
|
245 | { | |
246 | } |
|
246 | } | |
247 |
|
247 | |||
248 | void DeclarativeStackedBarSeries::componentComplete() |
|
248 | void DeclarativeStackedBarSeries::componentComplete() | |
249 | { |
|
249 | { | |
250 | foreach(QObject *child, children()) { |
|
250 | foreach(QObject *child, children()) { | |
251 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
251 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
252 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
252 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
253 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
253 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
254 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
254 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
255 | mapper->setSeries(this); |
|
255 | mapper->setSeries(this); | |
256 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
256 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
257 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
257 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
258 | mapper->setSeries(this); |
|
258 | mapper->setSeries(this); | |
259 | } |
|
259 | } | |
260 | } |
|
260 | } | |
261 | } |
|
261 | } | |
262 |
|
262 | |||
263 | void DeclarativeStackedBarSeries::setAxisX(QAbstractAxis *axis) |
|
263 | void DeclarativeStackedBarSeries::setAxisX(QAbstractAxis *axis) | |
264 | { |
|
264 | { | |
265 | chart()->setAxisX(axis, this); |
|
265 | chart()->setAxisX(axis, this); | |
266 | } |
|
266 | } | |
267 |
|
267 | |||
268 | QAbstractAxis *DeclarativeStackedBarSeries::axisX() |
|
268 | QAbstractAxis *DeclarativeStackedBarSeries::axisX() | |
269 | { |
|
269 | { | |
270 | return chart()->axisX(this); |
|
270 | return chart()->axisX(this); | |
271 | } |
|
271 | } | |
272 |
|
272 | |||
273 | void DeclarativeStackedBarSeries::setAxisY(QAbstractAxis *axis) |
|
273 | void DeclarativeStackedBarSeries::setAxisY(QAbstractAxis *axis) | |
274 | { |
|
274 | { | |
275 | chart()->setAxisY(axis, this); |
|
275 | chart()->setAxisY(axis, this); | |
276 | } |
|
276 | } | |
277 |
|
277 | |||
278 | QAbstractAxis *DeclarativeStackedBarSeries::axisY() |
|
278 | QAbstractAxis *DeclarativeStackedBarSeries::axisY() | |
279 | { |
|
279 | { | |
280 | return chart()->axisY(this); |
|
280 | return chart()->axisY(this); | |
281 | } |
|
281 | } | |
282 |
|
282 | |||
283 | QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() |
|
283 | QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() | |
284 | { |
|
284 | { | |
285 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeAbstractBarSeries::appendSeriesChildren); |
|
285 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeAbstractBarSeries::appendSeriesChildren); | |
286 | } |
|
286 | } | |
287 |
|
287 | |||
288 | void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
288 | void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
289 | { |
|
289 | { | |
290 | // Empty implementation; the children are parsed in componentComplete instead |
|
290 | // Empty implementation; the children are parsed in componentComplete instead | |
291 | Q_UNUSED(list); |
|
291 | Q_UNUSED(list); | |
292 | Q_UNUSED(element); |
|
292 | Q_UNUSED(element); | |
293 | } |
|
293 | } | |
294 |
|
294 | |||
295 | DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) |
|
295 | DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) | |
296 | { |
|
296 | { | |
297 | QList<QBarSet*> setList = barSets(); |
|
297 | QList<QBarSet*> setList = barSets(); | |
298 | if (index >= 0 && index < setList.count()) |
|
298 | if (index >= 0 && index < setList.count()) | |
299 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
299 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
300 |
|
300 | |||
301 | return 0; |
|
301 | return 0; | |
302 | } |
|
302 | } | |
303 |
|
303 | |||
304 | DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values) |
|
304 | DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values) | |
305 | { |
|
305 | { | |
306 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
306 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
307 | barset->setLabel(label); |
|
307 | barset->setLabel(label); | |
308 | barset->setValues(values); |
|
308 | barset->setValues(values); | |
309 | if (QStackedBarSeries::insert(index, barset)) |
|
309 | if (QStackedBarSeries::insert(index, barset)) | |
310 | return barset; |
|
310 | return barset; | |
311 | delete barset; |
|
311 | delete barset; | |
312 | return 0; |
|
312 | return 0; | |
313 | } |
|
313 | } | |
314 |
|
314 | |||
315 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : |
|
315 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : | |
316 | QPercentBarSeries(parent) |
|
316 | QPercentBarSeries(parent) | |
317 | { |
|
317 | { | |
318 | } |
|
318 | } | |
319 |
|
319 | |||
320 | void DeclarativePercentBarSeries::classBegin() |
|
320 | void DeclarativePercentBarSeries::classBegin() | |
321 | { |
|
321 | { | |
322 | } |
|
322 | } | |
323 |
|
323 | |||
324 | void DeclarativePercentBarSeries::componentComplete() |
|
324 | void DeclarativePercentBarSeries::componentComplete() | |
325 | { |
|
325 | { | |
326 | foreach(QObject *child, children()) { |
|
326 | foreach(QObject *child, children()) { | |
327 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
327 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
328 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
328 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
329 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
329 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
330 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
330 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
331 | mapper->setSeries(this); |
|
331 | mapper->setSeries(this); | |
332 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
332 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
333 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
333 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
334 | mapper->setSeries(this); |
|
334 | mapper->setSeries(this); | |
335 | } |
|
335 | } | |
336 | } |
|
336 | } | |
337 | } |
|
337 | } | |
338 |
|
338 | |||
339 | void DeclarativePercentBarSeries::setAxisX(QAbstractAxis *axis) |
|
339 | void DeclarativePercentBarSeries::setAxisX(QAbstractAxis *axis) | |
340 | { |
|
340 | { | |
341 | chart()->setAxisX(axis, this); |
|
341 | chart()->setAxisX(axis, this); | |
342 | } |
|
342 | } | |
343 |
|
343 | |||
344 | QAbstractAxis *DeclarativePercentBarSeries::axisX() |
|
344 | QAbstractAxis *DeclarativePercentBarSeries::axisX() | |
345 | { |
|
345 | { | |
346 | return chart()->axisX(this); |
|
346 | return chart()->axisX(this); | |
347 | } |
|
347 | } | |
348 |
|
348 | |||
349 | void DeclarativePercentBarSeries::setAxisY(QAbstractAxis *axis) |
|
349 | void DeclarativePercentBarSeries::setAxisY(QAbstractAxis *axis) | |
350 | { |
|
350 | { | |
351 | chart()->setAxisY(axis, this); |
|
351 | chart()->setAxisY(axis, this); | |
352 | } |
|
352 | } | |
353 |
|
353 | |||
354 | QAbstractAxis *DeclarativePercentBarSeries::axisY() |
|
354 | QAbstractAxis *DeclarativePercentBarSeries::axisY() | |
355 | { |
|
355 | { | |
356 | return chart()->axisY(this); |
|
356 | return chart()->axisY(this); | |
357 | } |
|
357 | } | |
358 |
|
358 | |||
359 | QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() |
|
359 | QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() | |
360 | { |
|
360 | { | |
361 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeAbstractBarSeries::appendSeriesChildren); |
|
361 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeAbstractBarSeries::appendSeriesChildren); | |
362 | } |
|
362 | } | |
363 |
|
363 | |||
364 | void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
364 | void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
365 | { |
|
365 | { | |
366 | // Empty implementation; the children are parsed in componentComplete instead |
|
366 | // Empty implementation; the children are parsed in componentComplete instead | |
367 | Q_UNUSED(list); |
|
367 | Q_UNUSED(list); | |
368 | Q_UNUSED(element); |
|
368 | Q_UNUSED(element); | |
369 | } |
|
369 | } | |
370 |
|
370 | |||
371 | DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) |
|
371 | DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) | |
372 | { |
|
372 | { | |
373 | QList<QBarSet*> setList = barSets(); |
|
373 | QList<QBarSet*> setList = barSets(); | |
374 | if (index >= 0 && index < setList.count()) |
|
374 | if (index >= 0 && index < setList.count()) | |
375 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
375 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
376 |
|
376 | |||
377 | return 0; |
|
377 | return 0; | |
378 | } |
|
378 | } | |
379 |
|
379 | |||
380 | DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values) |
|
380 | DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values) | |
381 | { |
|
381 | { | |
382 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
382 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
383 | barset->setLabel(label); |
|
383 | barset->setLabel(label); | |
384 | barset->setValues(values); |
|
384 | barset->setValues(values); | |
385 | if (QPercentBarSeries::insert(index, barset)) |
|
385 | if (QPercentBarSeries::insert(index, barset)) | |
386 | return barset; |
|
386 | return barset; | |
387 | delete barset; |
|
387 | delete barset; | |
388 | return 0; |
|
388 | return 0; | |
389 | } |
|
389 | } | |
390 |
|
390 | |||
391 |
#include "moc_declarative |
|
391 | #include "moc_declarativebarseries.cpp" | |
392 |
|
392 | |||
393 | QTCOMMERCIALCHART_END_NAMESPACE |
|
393 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now