@@ -58,6 +58,7 void DeclarativeBarSet::setValues(QVariantList values) | |||
|
58 | 58 | } |
|
59 | 59 | } |
|
60 | 60 | |
|
61 | // Declarative bar series ====================================================================================== | |
|
61 | 62 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : |
|
62 | 63 | QBarSeries(parent) |
|
63 | 64 | { |
@@ -114,6 +115,7 DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVaria | |||
|
114 | 115 | return 0; |
|
115 | 116 | } |
|
116 | 117 | |
|
118 | // Declarative stacked bar series ============================================================================== | |
|
117 | 119 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : |
|
118 | 120 | QStackedBarSeries(parent) |
|
119 | 121 | { |
@@ -171,6 +173,7 DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, | |||
|
171 | 173 | return 0; |
|
172 | 174 | } |
|
173 | 175 | |
|
176 | // Declarative percent bar series ============================================================================== | |
|
174 | 177 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : |
|
175 | 178 | QPercentBarSeries(parent) |
|
176 | 179 | { |
@@ -227,6 +230,177 DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, | |||
|
227 | 230 | return 0; |
|
228 | 231 | } |
|
229 | 232 | |
|
233 | // Declarative horizontal bar series =========================================================================== | |
|
234 | DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QDeclarativeItem *parent) : | |
|
235 | QHorizontalBarSeries(parent) | |
|
236 | { | |
|
237 | } | |
|
238 | ||
|
239 | void DeclarativeHorizontalBarSeries::classBegin() | |
|
240 | { | |
|
241 | } | |
|
242 | ||
|
243 | void DeclarativeHorizontalBarSeries::componentComplete() | |
|
244 | { | |
|
245 | foreach(QObject *child, children()) { | |
|
246 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
|
247 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
|
248 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
|
249 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
|
250 | mapper->setSeries(this); | |
|
251 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
|
252 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
|
253 | mapper->setSeries(this); | |
|
254 | } | |
|
255 | } | |
|
256 | } | |
|
257 | ||
|
258 | QDeclarativeListProperty<QObject> DeclarativeHorizontalBarSeries::seriesChildren() | |
|
259 | { | |
|
260 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren); | |
|
261 | } | |
|
262 | ||
|
263 | void DeclarativeHorizontalBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
|
264 | { | |
|
265 | // Empty implementation; the children are parsed in componentComplete instead | |
|
266 | Q_UNUSED(list); | |
|
267 | Q_UNUSED(element); | |
|
268 | } | |
|
269 | ||
|
270 | DeclarativeBarSet *DeclarativeHorizontalBarSeries::at(int index) | |
|
271 | { | |
|
272 | QList<QBarSet*> setList = barSets(); | |
|
273 | if (index >= 0 && index < setList.count()) | |
|
274 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
|
275 | ||
|
276 | return 0; | |
|
277 | } | |
|
278 | ||
|
279 | DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString label, QVariantList values) | |
|
280 | { | |
|
281 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
|
282 | barset->setLabel(label); | |
|
283 | barset->setValues(values); | |
|
284 | if (QHorizontalBarSeries::insert(index, barset)) | |
|
285 | return barset; | |
|
286 | delete barset; | |
|
287 | return 0; | |
|
288 | } | |
|
289 | ||
|
290 | // Declarative horizontal stacked bar series =================================================================== | |
|
291 | DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent) : | |
|
292 | QHorizontalStackedBarSeries(parent) | |
|
293 | { | |
|
294 | } | |
|
295 | ||
|
296 | void DeclarativeHorizontalStackedBarSeries::classBegin() | |
|
297 | { | |
|
298 | } | |
|
299 | ||
|
300 | void DeclarativeHorizontalStackedBarSeries::componentComplete() | |
|
301 | { | |
|
302 | foreach(QObject *child, children()) { | |
|
303 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
|
304 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
|
305 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
|
306 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
|
307 | mapper->setSeries(this); | |
|
308 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
|
309 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
|
310 | mapper->setSeries(this); | |
|
311 | } | |
|
312 | } | |
|
313 | } | |
|
314 | ||
|
315 | QDeclarativeListProperty<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren() | |
|
316 | { | |
|
317 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren); | |
|
318 | } | |
|
319 | ||
|
320 | void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
|
321 | { | |
|
322 | // Empty implementation; the children are parsed in componentComplete instead | |
|
323 | Q_UNUSED(list); | |
|
324 | Q_UNUSED(element); | |
|
325 | } | |
|
326 | ||
|
327 | DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::at(int index) | |
|
328 | { | |
|
329 | QList<QBarSet*> setList = barSets(); | |
|
330 | if (index >= 0 && index < setList.count()) | |
|
331 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
|
332 | ||
|
333 | return 0; | |
|
334 | } | |
|
335 | ||
|
336 | DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QString label, QVariantList values) | |
|
337 | { | |
|
338 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
|
339 | barset->setLabel(label); | |
|
340 | barset->setValues(values); | |
|
341 | if (QHorizontalStackedBarSeries::insert(index, barset)) | |
|
342 | return barset; | |
|
343 | delete barset; | |
|
344 | return 0; | |
|
345 | } | |
|
346 | ||
|
347 | // Declarative horizontal percent bar series =================================================================== | |
|
348 | DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent) : | |
|
349 | QHorizontalPercentBarSeries(parent) | |
|
350 | { | |
|
351 | } | |
|
352 | ||
|
353 | void DeclarativeHorizontalPercentBarSeries::classBegin() | |
|
354 | { | |
|
355 | } | |
|
356 | ||
|
357 | void DeclarativeHorizontalPercentBarSeries::componentComplete() | |
|
358 | { | |
|
359 | foreach(QObject *child, children()) { | |
|
360 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
|
361 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
|
362 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
|
363 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
|
364 | mapper->setSeries(this); | |
|
365 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
|
366 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
|
367 | mapper->setSeries(this); | |
|
368 | } | |
|
369 | } | |
|
370 | } | |
|
371 | ||
|
372 | QDeclarativeListProperty<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren() | |
|
373 | { | |
|
374 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren); | |
|
375 | } | |
|
376 | ||
|
377 | void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
|
378 | { | |
|
379 | // Empty implementation; the children are parsed in componentComplete instead | |
|
380 | Q_UNUSED(list); | |
|
381 | Q_UNUSED(element); | |
|
382 | } | |
|
383 | ||
|
384 | DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::at(int index) | |
|
385 | { | |
|
386 | QList<QBarSet*> setList = barSets(); | |
|
387 | if (index >= 0 && index < setList.count()) | |
|
388 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
|
389 | ||
|
390 | return 0; | |
|
391 | } | |
|
392 | ||
|
393 | DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::insert(int index, QString label, QVariantList values) | |
|
394 | { | |
|
395 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
|
396 | barset->setLabel(label); | |
|
397 | barset->setValues(values); | |
|
398 | if (QHorizontalPercentBarSeries::insert(index, barset)) | |
|
399 | return barset; | |
|
400 | delete barset; | |
|
401 | return 0; | |
|
402 | } | |
|
403 | ||
|
230 | 404 | #include "moc_declarativebarseries.cpp" |
|
231 | 405 | |
|
232 | 406 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -24,6 +24,9 | |||
|
24 | 24 | #include "qbarseries.h" |
|
25 | 25 | #include "qstackedbarseries.h" |
|
26 | 26 | #include "qpercentbarseries.h" |
|
27 | #include "qhorizontalbarseries.h" | |
|
28 | #include "qhorizontalstackedbarseries.h" | |
|
29 | #include "qhorizontalpercentbarseries.h" | |
|
27 | 30 | #include "qbarset.h" |
|
28 | 31 | #include <QDeclarativeItem> |
|
29 | 32 | #include <QDeclarativeParserStatus> |
@@ -133,6 +136,78 public Q_SLOTS: | |||
|
133 | 136 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
134 | 137 | }; |
|
135 | 138 | |
|
139 | class DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QDeclarativeParserStatus | |
|
140 | { | |
|
141 | Q_OBJECT | |
|
142 | Q_INTERFACES(QDeclarativeParserStatus) | |
|
143 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
|
144 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
|
145 | ||
|
146 | public: | |
|
147 | explicit DeclarativeHorizontalBarSeries(QDeclarativeItem *parent = 0); | |
|
148 | QDeclarativeListProperty<QObject> seriesChildren(); | |
|
149 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
|
150 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
|
151 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
|
152 | Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalBarSeries::remove(barset); } | |
|
153 | Q_INVOKABLE void clear() { return QHorizontalBarSeries::clear(); } | |
|
154 | ||
|
155 | public: // from QDeclarativeParserStatus | |
|
156 | void classBegin(); | |
|
157 | void componentComplete(); | |
|
158 | ||
|
159 | public Q_SLOTS: | |
|
160 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
|
161 | }; | |
|
162 | ||
|
163 | class DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries, public QDeclarativeParserStatus | |
|
164 | { | |
|
165 | Q_OBJECT | |
|
166 | Q_INTERFACES(QDeclarativeParserStatus) | |
|
167 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
|
168 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
|
169 | ||
|
170 | public: | |
|
171 | explicit DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent = 0); | |
|
172 | QDeclarativeListProperty<QObject> seriesChildren(); | |
|
173 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
|
174 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
|
175 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
|
176 | Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalStackedBarSeries::remove(barset); } | |
|
177 | Q_INVOKABLE void clear() { return QHorizontalStackedBarSeries::clear(); } | |
|
178 | ||
|
179 | public: // from QDeclarativeParserStatus | |
|
180 | void classBegin(); | |
|
181 | void componentComplete(); | |
|
182 | ||
|
183 | public Q_SLOTS: | |
|
184 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
|
185 | }; | |
|
186 | ||
|
187 | class DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries, public QDeclarativeParserStatus | |
|
188 | { | |
|
189 | Q_OBJECT | |
|
190 | Q_INTERFACES(QDeclarativeParserStatus) | |
|
191 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
|
192 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
|
193 | ||
|
194 | public: | |
|
195 | explicit DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent = 0); | |
|
196 | QDeclarativeListProperty<QObject> seriesChildren(); | |
|
197 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
|
198 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
|
199 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
|
200 | Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalPercentBarSeries::remove(barset); } | |
|
201 | Q_INVOKABLE void clear() { return QHorizontalPercentBarSeries::clear(); } | |
|
202 | ||
|
203 | public: // from QDeclarativeParserStatus | |
|
204 | void classBegin(); | |
|
205 | void componentComplete(); | |
|
206 | ||
|
207 | public Q_SLOTS: | |
|
208 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
|
209 | }; | |
|
210 | ||
|
136 | 211 | QTCOMMERCIALCHART_END_NAMESPACE |
|
137 | 212 | |
|
138 | 213 | #endif // DECLARATIVEBARSERIES_H |
General Comments 0
You need to be logged in to leave comments.
Login now