##// END OF EJS Templates
Implemented BarSeries::append, insert, remove and clear to QML API
Tero Ahola -
r1511:ed36c132b8e6
parent child
Show More
@@ -1,262 +1,306
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
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 DeclarativeBarSet::DeclarativeBarSet(QObject *parent) :
29 DeclarativeBarSet::DeclarativeBarSet(QObject *parent) :
30 QBarSet("", parent)
30 QBarSet("", parent)
31 {
31 {
32 connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int, int)));
32 connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int, int)));
33 connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int)));
33 connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int)));
34 }
34 }
35
35
36 void DeclarativeBarSet::handleCountChanged(int index, int count)
36 void DeclarativeBarSet::handleCountChanged(int index, int count)
37 {
37 {
38 Q_UNUSED(index)
38 Q_UNUSED(index)
39 Q_UNUSED(count)
39 Q_UNUSED(count)
40 emit countChanged(QBarSet::count());
40 emit countChanged(QBarSet::count());
41 }
41 }
42
42
43 QVariantList DeclarativeBarSet::values()
43 QVariantList DeclarativeBarSet::values()
44 {
44 {
45 QVariantList values;
45 QVariantList values;
46 for (int i(0); i < count(); i++)
46 for (int i(0); i < count(); i++)
47 values.append(QVariant(at(i)));
47 values.append(QVariant(at(i)));
48 return values;
48 return values;
49 }
49 }
50
50
51 void DeclarativeBarSet::setValues(QVariantList values)
51 void DeclarativeBarSet::setValues(QVariantList values)
52 {
52 {
53 while (count())
53 while (count())
54 remove(count() - 1);
54 remove(count() - 1);
55
55
56 for (int i(0); i < values.count(); i++) {
56 for (int i(0); i < values.count(); i++) {
57 if (values.at(i).canConvert(QVariant::Double))
57 if (values.at(i).canConvert(QVariant::Double))
58 append(values[i].toDouble());
58 append(values[i].toDouble());
59 }
59 }
60 }
60 }
61
61
62 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
62 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
63 QBarSeries(parent)
63 QBarSeries(parent)
64 {
64 {
65 connect(this, SIGNAL(barsetsAdded(QList<QBarSet*>)), this, SLOT(handleAdded(QList<QBarSet*>)));
65 connect(this, SIGNAL(barsetsAdded(QList<QBarSet*>)), this, SLOT(handleAdded(QList<QBarSet*>)));
66 connect(this, SIGNAL(barsetsRemoved(QList<QBarSet*>)), this, SLOT(handleRemoved(QList<QBarSet*>)));
66 connect(this, SIGNAL(barsetsRemoved(QList<QBarSet*>)), this, SLOT(handleRemoved(QList<QBarSet*>)));
67 }
67 }
68
68
69 void DeclarativeBarSeries::handleAdded(QList<QBarSet* > barsets)
69 void DeclarativeBarSeries::handleAdded(QList<QBarSet* > barsets)
70 {
70 {
71 foreach(QBarSet *b, barsets) {
71 foreach(QBarSet *b, barsets) {
72 DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b);
72 DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b);
73 emit added(barset);
73 emit added(barset);
74 }
74 }
75 }
75 }
76
76
77 void DeclarativeBarSeries::handleRemoved(QList<QBarSet* > barsets)
77 void DeclarativeBarSeries::handleRemoved(QList<QBarSet* > barsets)
78 {
78 {
79 foreach(QBarSet *b, barsets) {
79 foreach(QBarSet *b, barsets) {
80 DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b);
80 DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b);
81 emit removed(barset);
81 emit removed(barset);
82 }
82 }
83 }
83 }
84
84
85 void DeclarativeBarSeries::classBegin()
85 void DeclarativeBarSeries::classBegin()
86 {
86 {
87 }
87 }
88
88
89 void DeclarativeBarSeries::componentComplete()
89 void DeclarativeBarSeries::componentComplete()
90 {
90 {
91 foreach(QObject *child, children()) {
91 foreach(QObject *child, children()) {
92 if (qobject_cast<DeclarativeBarSet *>(child)) {
92 if (qobject_cast<DeclarativeBarSet *>(child)) {
93 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
93 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
94 } else if(qobject_cast<QVBarModelMapper *>(child)) {
94 } else if(qobject_cast<QVBarModelMapper *>(child)) {
95 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
95 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
96 mapper->setSeries(this);
96 mapper->setSeries(this);
97 } else if(qobject_cast<QHBarModelMapper *>(child)) {
97 } else if(qobject_cast<QHBarModelMapper *>(child)) {
98 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
98 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
99 mapper->setSeries(this);
99 mapper->setSeries(this);
100 }
100 }
101 }
101 }
102 }
102 }
103
103
104 QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren()
104 QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren()
105 {
105 {
106 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
106 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
107 }
107 }
108
108
109 void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
109 void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
110 {
110 {
111 // Empty implementation; the children are parsed in componentComplete instead
111 // Empty implementation; the children are parsed in componentComplete instead
112 Q_UNUSED(list);
112 Q_UNUSED(list);
113 Q_UNUSED(element);
113 Q_UNUSED(element);
114 }
114 }
115
115
116 DeclarativeBarSet *DeclarativeBarSeries::at(int index)
116 DeclarativeBarSet *DeclarativeBarSeries::at(int index)
117 {
117 {
118 QList<QBarSet*> setList = barSets();
118 QList<QBarSet*> setList = barSets();
119 if (index < setList.count())
119 if (index >= 0 && index < setList.count())
120 return qobject_cast<DeclarativeBarSet *>(setList[index]);
120 return qobject_cast<DeclarativeBarSet *>(setList[index]);
121
121
122 return 0;
122 return 0;
123 }
123 }
124
124
125 DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values)
126 {
127 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
128 barset->setLabel(label);
129 barset->setValues(values);
130 if (QBarSeries::insert(index, barset))
131 return barset;
132 delete barset;
133 return 0;
134 }
135
125 DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) :
136 DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) :
126 QGroupedBarSeries(parent)
137 QGroupedBarSeries(parent)
127 {
138 {
128 }
139 }
129
140
130 void DeclarativeGroupedBarSeries::classBegin()
141 void DeclarativeGroupedBarSeries::classBegin()
131 {
142 {
132 }
143 }
133
144
134 void DeclarativeGroupedBarSeries::componentComplete()
145 void DeclarativeGroupedBarSeries::componentComplete()
135 {
146 {
136 foreach(QObject *child, children()) {
147 foreach(QObject *child, children()) {
137 if (qobject_cast<DeclarativeBarSet *>(child)) {
148 if (qobject_cast<DeclarativeBarSet *>(child)) {
138 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
149 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
139 } else if(qobject_cast<QVBarModelMapper *>(child)) {
150 } else if(qobject_cast<QVBarModelMapper *>(child)) {
140 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
151 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
141 mapper->setSeries(this);
152 mapper->setSeries(this);
142 } else if(qobject_cast<QHBarModelMapper *>(child)) {
153 } else if(qobject_cast<QHBarModelMapper *>(child)) {
143 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
154 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
144 mapper->setSeries(this);
155 mapper->setSeries(this);
145 }
156 }
146 }
157 }
147 }
158 }
148
159
149 QDeclarativeListProperty<QObject> DeclarativeGroupedBarSeries::seriesChildren()
160 QDeclarativeListProperty<QObject> DeclarativeGroupedBarSeries::seriesChildren()
150 {
161 {
151 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
162 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
152 }
163 }
153
164
154 void DeclarativeGroupedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
165 void DeclarativeGroupedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
155 {
166 {
156 // Empty implementation; the children are parsed in componentComplete instead
167 // Empty implementation; the children are parsed in componentComplete instead
157 Q_UNUSED(list);
168 Q_UNUSED(list);
158 Q_UNUSED(element);
169 Q_UNUSED(element);
159 }
170 }
160
171
161 DeclarativeBarSet *DeclarativeGroupedBarSeries::at(int index)
172 DeclarativeBarSet *DeclarativeGroupedBarSeries::at(int index)
162 {
173 {
163 QList<QBarSet*> setList = barSets();
174 QList<QBarSet*> setList = barSets();
164 if (index < setList.count())
175 if (index >= 0 && index < setList.count())
165 return qobject_cast<DeclarativeBarSet *>(setList[index]);
176 return qobject_cast<DeclarativeBarSet *>(setList[index]);
166
177
167 return 0;
178 return 0;
168 }
179 }
169
180
181 DeclarativeBarSet *DeclarativeGroupedBarSeries::insert(int index, QString label, QVariantList values)
182 {
183 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
184 barset->setLabel(label);
185 barset->setValues(values);
186 if (QGroupedBarSeries::insert(index, barset))
187 return barset;
188 delete barset;
189 return 0;
190 }
191
170 DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) :
192 DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) :
171 QStackedBarSeries(parent)
193 QStackedBarSeries(parent)
172 {
194 {
173 }
195 }
174
196
175 void DeclarativeStackedBarSeries::classBegin()
197 void DeclarativeStackedBarSeries::classBegin()
176 {
198 {
177 }
199 }
178
200
179 void DeclarativeStackedBarSeries::componentComplete()
201 void DeclarativeStackedBarSeries::componentComplete()
180 {
202 {
181 foreach(QObject *child, children()) {
203 foreach(QObject *child, children()) {
182 if (qobject_cast<DeclarativeBarSet *>(child)) {
204 if (qobject_cast<DeclarativeBarSet *>(child)) {
183 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
205 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
184 } else if(qobject_cast<QVBarModelMapper *>(child)) {
206 } else if(qobject_cast<QVBarModelMapper *>(child)) {
185 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
207 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
186 mapper->setSeries(this);
208 mapper->setSeries(this);
187 } else if(qobject_cast<QHBarModelMapper *>(child)) {
209 } else if(qobject_cast<QHBarModelMapper *>(child)) {
188 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
210 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
189 mapper->setSeries(this);
211 mapper->setSeries(this);
190 }
212 }
191 }
213 }
192 }
214 }
193
215
194 QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren()
216 QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren()
195 {
217 {
196 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
218 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
197 }
219 }
198
220
199 void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
221 void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
200 {
222 {
201 // Empty implementation; the children are parsed in componentComplete instead
223 // Empty implementation; the children are parsed in componentComplete instead
202 Q_UNUSED(list);
224 Q_UNUSED(list);
203 Q_UNUSED(element);
225 Q_UNUSED(element);
204 }
226 }
205
227
206 DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index)
228 DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index)
207 {
229 {
208 QList<QBarSet*> setList = barSets();
230 QList<QBarSet*> setList = barSets();
209 if (index < setList.count())
231 if (index >= 0 && index < setList.count())
210 return qobject_cast<DeclarativeBarSet *>(setList[index]);
232 return qobject_cast<DeclarativeBarSet *>(setList[index]);
211
233
212 return 0;
234 return 0;
213 }
235 }
214
236
237 DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values)
238 {
239 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
240 barset->setLabel(label);
241 barset->setValues(values);
242 if (QStackedBarSeries::insert(index, barset))
243 return barset;
244 delete barset;
245 return 0;
246 }
247
215 DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) :
248 DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) :
216 QPercentBarSeries(parent)
249 QPercentBarSeries(parent)
217 {
250 {
218 }
251 }
219
252
220 void DeclarativePercentBarSeries::classBegin()
253 void DeclarativePercentBarSeries::classBegin()
221 {
254 {
222 }
255 }
223
256
224 void DeclarativePercentBarSeries::componentComplete()
257 void DeclarativePercentBarSeries::componentComplete()
225 {
258 {
226 foreach(QObject *child, children()) {
259 foreach(QObject *child, children()) {
227 if (qobject_cast<DeclarativeBarSet *>(child)) {
260 if (qobject_cast<DeclarativeBarSet *>(child)) {
228 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
261 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
229 } else if(qobject_cast<QVBarModelMapper *>(child)) {
262 } else if(qobject_cast<QVBarModelMapper *>(child)) {
230 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
263 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
231 mapper->setSeries(this);
264 mapper->setSeries(this);
232 } else if(qobject_cast<QHBarModelMapper *>(child)) {
265 } else if(qobject_cast<QHBarModelMapper *>(child)) {
233 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
266 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
234 mapper->setSeries(this);
267 mapper->setSeries(this);
235 }
268 }
236 }
269 }
237 }
270 }
238
271
239 QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren()
272 QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren()
240 {
273 {
241 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
274 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
242 }
275 }
243
276
244 void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
277 void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
245 {
278 {
246 // Empty implementation; the children are parsed in componentComplete instead
279 // Empty implementation; the children are parsed in componentComplete instead
247 Q_UNUSED(list);
280 Q_UNUSED(list);
248 Q_UNUSED(element);
281 Q_UNUSED(element);
249 }
282 }
250
283
251 DeclarativeBarSet *DeclarativePercentBarSeries::at(int index)
284 DeclarativeBarSet *DeclarativePercentBarSeries::at(int index)
252 {
285 {
253 QList<QBarSet*> setList = barSets();
286 QList<QBarSet*> setList = barSets();
254 if (index < setList.count())
287 if (index >= 0 && index < setList.count())
255 return qobject_cast<DeclarativeBarSet *>(setList[index]);
288 return qobject_cast<DeclarativeBarSet *>(setList[index]);
256
289
257 return 0;
290 return 0;
258 }
291 }
259
292
293 DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values)
294 {
295 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
296 barset->setLabel(label);
297 barset->setValues(values);
298 if (QPercentBarSeries::insert(index, barset))
299 return barset;
300 delete barset;
301 return 0;
302 }
303
260 #include "moc_declarativebarseries.cpp"
304 #include "moc_declarativebarseries.cpp"
261
305
262 QTCOMMERCIALCHART_END_NAMESPACE
306 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,146 +1,162
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 DECLARATIVEBARSERIES_H
21 #ifndef DECLARATIVEBARSERIES_H
22 #define DECLARATIVEBARSERIES_H
22 #define DECLARATIVEBARSERIES_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include <QGroupedBarSeries>
25 #include <QGroupedBarSeries>
26 #include <QStackedBarSeries>
26 #include <QStackedBarSeries>
27 #include <QPercentBarSeries>
27 #include <QPercentBarSeries>
28 #include <QBarSet>
28 #include <QBarSet>
29 #include <QDeclarativeItem>
29 #include <QDeclarativeItem>
30 #include <QDeclarativeParserStatus>
30 #include <QDeclarativeParserStatus>
31
31
32 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33
33
34 class QChart;
34 class QChart;
35
35
36 class DeclarativeBarSet : public QBarSet
36 class DeclarativeBarSet : public QBarSet
37 {
37 {
38 Q_OBJECT
38 Q_OBJECT
39 Q_PROPERTY(QVariantList values READ values WRITE setValues)
39 Q_PROPERTY(QVariantList values READ values WRITE setValues)
40 Q_PROPERTY(int count READ count NOTIFY countChanged)
40 Q_PROPERTY(int count READ count NOTIFY countChanged)
41
41
42 public:
42 public:
43 explicit DeclarativeBarSet(QObject *parent = 0);
43 explicit DeclarativeBarSet(QObject *parent = 0);
44 QVariantList values();
44 QVariantList values();
45 void setValues(QVariantList values);
45 void setValues(QVariantList values);
46
46
47 public: // From QBarSet
47 public: // From QBarSet
48 Q_INVOKABLE void append(qreal value) { QBarSet::append(value); }
48 Q_INVOKABLE void append(qreal value) { QBarSet::append(value); }
49 Q_INVOKABLE void append(qreal x, qreal y) { QBarSet::append(QPointF(x, y)); }
49 Q_INVOKABLE void append(qreal x, qreal y) { QBarSet::append(QPointF(x, y)); }
50
50
51 Q_SIGNALS:
51 Q_SIGNALS:
52 void countChanged(int count);
52 void countChanged(int count);
53
53
54 private Q_SLOTS:
54 private Q_SLOTS:
55 void handleCountChanged(int index, int count);
55 void handleCountChanged(int index, int count);
56 };
56 };
57
57
58 class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus
58 class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus
59 {
59 {
60 Q_OBJECT
60 Q_OBJECT
61 Q_INTERFACES(QDeclarativeParserStatus)
61 Q_INTERFACES(QDeclarativeParserStatus)
62 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
62 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
63 Q_CLASSINFO("DefaultProperty", "seriesChildren")
63 Q_CLASSINFO("DefaultProperty", "seriesChildren")
64
64
65 public:
65 public:
66 explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0);
66 explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0);
67 QDeclarativeListProperty<QObject> seriesChildren();
67 QDeclarativeListProperty<QObject> seriesChildren();
68 Q_INVOKABLE DeclarativeBarSet *at(int index);
68 Q_INVOKABLE DeclarativeBarSet *at(int index);
69 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
70 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
71 Q_INVOKABLE bool remove(QBarSet *barset) { return QBarSeries::remove(barset); }
72 Q_INVOKABLE void clear() { return QBarSeries::clear(); }
69
73
70 public: // from QDeclarativeParserStatus
74 public: // from QDeclarativeParserStatus
71 void classBegin();
75 void classBegin();
72 void componentComplete();
76 void componentComplete();
73
77
74 Q_SIGNALS:
78 Q_SIGNALS:
75 void added(DeclarativeBarSet *barset);
79 void added(DeclarativeBarSet *barset);
76 void removed(DeclarativeBarSet *barset);
80 void removed(DeclarativeBarSet *barset);
77
81
78 public Q_SLOTS:
82 public Q_SLOTS:
79 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
83 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
80 void handleAdded(QList<QBarSet* > barsets);
84 void handleAdded(QList<QBarSet* > barsets);
81 void handleRemoved(QList<QBarSet* > barsets);
85 void handleRemoved(QList<QBarSet* > barsets);
82 };
86 };
83
87
84 class DeclarativeGroupedBarSeries : public QGroupedBarSeries, public QDeclarativeParserStatus
88 class DeclarativeGroupedBarSeries : public QGroupedBarSeries, public QDeclarativeParserStatus
85 {
89 {
86 Q_OBJECT
90 Q_OBJECT
87 Q_INTERFACES(QDeclarativeParserStatus)
91 Q_INTERFACES(QDeclarativeParserStatus)
88 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
92 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
89 Q_CLASSINFO("DefaultProperty", "seriesChildren")
93 Q_CLASSINFO("DefaultProperty", "seriesChildren")
90
94
91 public:
95 public:
92 explicit DeclarativeGroupedBarSeries(QDeclarativeItem *parent = 0);
96 explicit DeclarativeGroupedBarSeries(QDeclarativeItem *parent = 0);
93 QDeclarativeListProperty<QObject> seriesChildren();
97 QDeclarativeListProperty<QObject> seriesChildren();
94 Q_INVOKABLE DeclarativeBarSet *at(int index);
98 Q_INVOKABLE DeclarativeBarSet *at(int index);
99 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
100 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
101 Q_INVOKABLE bool remove(QBarSet *barset) { return QGroupedBarSeries::remove(barset); }
102 Q_INVOKABLE void clear() { return QGroupedBarSeries::clear(); }
95
103
96 public: // from QDeclarativeParserStatus
104 public: // from QDeclarativeParserStatus
97 void classBegin();
105 void classBegin();
98 void componentComplete();
106 void componentComplete();
99
107
100 public Q_SLOTS:
108 public Q_SLOTS:
101 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
109 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
102 };
110 };
103
111
104 class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus
112 class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus
105 {
113 {
106 Q_OBJECT
114 Q_OBJECT
107 Q_INTERFACES(QDeclarativeParserStatus)
115 Q_INTERFACES(QDeclarativeParserStatus)
108 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
116 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
109 Q_CLASSINFO("DefaultProperty", "seriesChildren")
117 Q_CLASSINFO("DefaultProperty", "seriesChildren")
110
118
111 public:
119 public:
112 explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0);
120 explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0);
113 QDeclarativeListProperty<QObject> seriesChildren();
121 QDeclarativeListProperty<QObject> seriesChildren();
114 Q_INVOKABLE DeclarativeBarSet *at(int index);
122 Q_INVOKABLE DeclarativeBarSet *at(int index);
123 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
124 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
125 Q_INVOKABLE bool remove(QBarSet *barset) { return QStackedBarSeries::remove(barset); }
126 Q_INVOKABLE void clear() { return QStackedBarSeries::clear(); }
115
127
116 public: // from QDeclarativeParserStatus
128 public: // from QDeclarativeParserStatus
117 void classBegin();
129 void classBegin();
118 void componentComplete();
130 void componentComplete();
119
131
120 public Q_SLOTS:
132 public Q_SLOTS:
121 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
133 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
122 };
134 };
123
135
124 class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus
136 class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus
125 {
137 {
126 Q_OBJECT
138 Q_OBJECT
127 Q_INTERFACES(QDeclarativeParserStatus)
139 Q_INTERFACES(QDeclarativeParserStatus)
128 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
140 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
129 Q_CLASSINFO("DefaultProperty", "seriesChildren")
141 Q_CLASSINFO("DefaultProperty", "seriesChildren")
130
142
131 public:
143 public:
132 explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0);
144 explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0);
133 QDeclarativeListProperty<QObject> seriesChildren();
145 QDeclarativeListProperty<QObject> seriesChildren();
134 Q_INVOKABLE DeclarativeBarSet *at(int index);
146 Q_INVOKABLE DeclarativeBarSet *at(int index);
147 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
148 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
149 Q_INVOKABLE bool remove(QBarSet *barset) { return QPercentBarSeries::remove(barset); }
150 Q_INVOKABLE void clear() { return QPercentBarSeries::clear(); }
135
151
136 public: // from QDeclarativeParserStatus
152 public: // from QDeclarativeParserStatus
137 void classBegin();
153 void classBegin();
138 void componentComplete();
154 void componentComplete();
139
155
140 public Q_SLOTS:
156 public Q_SLOTS:
141 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
157 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
142 };
158 };
143
159
144 QTCOMMERCIALCHART_END_NAMESPACE
160 QTCOMMERCIALCHART_END_NAMESPACE
145
161
146 #endif // DECLARATIVEBARSERIES_H
162 #endif // DECLARATIVEBARSERIES_H
@@ -1,123 +1,120
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 "declarativepieseries.h"
21 #include "declarativepieseries.h"
22 #include "declarativechart.h"
22 #include "declarativechart.h"
23 #include "qchart.h"
23 #include "qchart.h"
24 #include <qdeclarativelist.h>
24 #include <qdeclarativelist.h>
25 #include <QVPieModelMapper>
25 #include <QVPieModelMapper>
26 #include <QHPieModelMapper>
26 #include <QHPieModelMapper>
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 DeclarativePieSeries::DeclarativePieSeries(QObject *parent) :
30 DeclarativePieSeries::DeclarativePieSeries(QObject *parent) :
31 QPieSeries(parent)
31 QPieSeries(parent)
32 {
32 {
33 connect(this, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleAdded(QList<QPieSlice*>)));
33 connect(this, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleAdded(QList<QPieSlice*>)));
34 connect(this, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleRemoved(QList<QPieSlice*>)));
34 connect(this, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleRemoved(QList<QPieSlice*>)));
35 }
35 }
36
36
37 void DeclarativePieSeries::classBegin()
37 void DeclarativePieSeries::classBegin()
38 {
38 {
39 }
39 }
40
40
41 void DeclarativePieSeries::componentComplete()
41 void DeclarativePieSeries::componentComplete()
42 {
42 {
43 foreach(QObject *child, children()) {
43 foreach(QObject *child, children()) {
44 if (qobject_cast<QPieSlice *>(child)) {
44 if (qobject_cast<QPieSlice *>(child)) {
45 QPieSeries::append(qobject_cast<QPieSlice *>(child));
45 QPieSeries::append(qobject_cast<QPieSlice *>(child));
46 } else if(qobject_cast<QVPieModelMapper *>(child)) {
46 } else if(qobject_cast<QVPieModelMapper *>(child)) {
47 QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child);
47 QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child);
48 mapper->setSeries(this);
48 mapper->setSeries(this);
49 } else if(qobject_cast<QHPieModelMapper *>(child)) {
49 } else if(qobject_cast<QHPieModelMapper *>(child)) {
50 QHPieModelMapper *mapper = qobject_cast<QHPieModelMapper *>(child);
50 QHPieModelMapper *mapper = qobject_cast<QHPieModelMapper *>(child);
51 mapper->setSeries(this);
51 mapper->setSeries(this);
52 }
52 }
53 }
53 }
54 }
54 }
55
55
56 QDeclarativeListProperty<QObject> DeclarativePieSeries::seriesChildren()
56 QDeclarativeListProperty<QObject> DeclarativePieSeries::seriesChildren()
57 {
57 {
58 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativePieSeries::appendSeriesChildren);
58 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativePieSeries::appendSeriesChildren);
59 }
59 }
60
60
61 void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
61 void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
62 {
62 {
63 // Empty implementation; the children are parsed in componentComplete instead
63 // Empty implementation; the children are parsed in componentComplete instead
64 Q_UNUSED(list);
64 Q_UNUSED(list);
65 Q_UNUSED(element);
65 Q_UNUSED(element);
66 }
66 }
67
67
68 QPieSlice *DeclarativePieSeries::at(int index)
68 QPieSlice *DeclarativePieSeries::at(int index)
69 {
69 {
70 QList<QPieSlice*> sliceList = slices();
70 QList<QPieSlice*> sliceList = slices();
71 if (index >= 0 && index < sliceList.count())
71 if (index >= 0 && index < sliceList.count())
72 return sliceList[index];
72 return sliceList[index];
73
73
74 return 0;
74 return 0;
75 }
75 }
76
76
77 QPieSlice* DeclarativePieSeries::find(QString label)
77 QPieSlice* DeclarativePieSeries::find(QString label)
78 {
78 {
79 foreach (QPieSlice *slice, slices()) {
79 foreach (QPieSlice *slice, slices()) {
80 if (slice->label() == label)
80 if (slice->label() == label)
81 return slice;
81 return slice;
82 }
82 }
83 return 0;
83 return 0;
84 }
84 }
85
85
86 QPieSlice* DeclarativePieSeries::append(QString label, qreal value)
86 QPieSlice* DeclarativePieSeries::append(QString label, qreal value)
87 {
87 {
88 // TODO: parameter order is wrong, switch it:
88 // TODO: parameter order is wrong, switch it:
89 QPieSlice *slice = new QPieSlice(this);
89 QPieSlice *slice = new QPieSlice(this);
90 slice->setLabel(label);
90 slice->setLabel(label);
91 slice->setValue(value);
91 slice->setValue(value);
92 QPieSeries::append(slice);
92 QPieSeries::append(slice);
93 return slice;
93 return slice;
94 }
94 }
95
95
96 bool DeclarativePieSeries::remove(int index)
96 bool DeclarativePieSeries::remove(QPieSlice *slice)
97 {
97 {
98 QPieSlice *slice = at(index);
98 return QPieSeries::remove(slice);
99 if (slice)
100 return QPieSeries::remove(slice);
101 return false;
102 }
99 }
103
100
104 void DeclarativePieSeries::clear()
101 void DeclarativePieSeries::clear()
105 {
102 {
106 QPieSeries::clear();
103 QPieSeries::clear();
107 }
104 }
108
105
109 void DeclarativePieSeries::handleAdded(QList<QPieSlice*> slices)
106 void DeclarativePieSeries::handleAdded(QList<QPieSlice*> slices)
110 {
107 {
111 foreach(QPieSlice *slice, slices)
108 foreach(QPieSlice *slice, slices)
112 emit sliceAdded(slice);
109 emit sliceAdded(slice);
113 }
110 }
114
111
115 void DeclarativePieSeries::handleRemoved(QList<QPieSlice*> slices)
112 void DeclarativePieSeries::handleRemoved(QList<QPieSlice*> slices)
116 {
113 {
117 foreach(QPieSlice *slice, slices)
114 foreach(QPieSlice *slice, slices)
118 emit sliceRemoved(slice);
115 emit sliceRemoved(slice);
119 }
116 }
120
117
121 #include "moc_declarativepieseries.cpp"
118 #include "moc_declarativepieseries.cpp"
122
119
123 QTCOMMERCIALCHART_END_NAMESPACE
120 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,67 +1,67
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 DECLARATIVEPIESERIES_H
21 #ifndef DECLARATIVEPIESERIES_H
22 #define DECLARATIVEPIESERIES_H
22 #define DECLARATIVEPIESERIES_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include <QPieSlice>
25 #include <QPieSlice>
26 #include <QPieSeries>
26 #include <QPieSeries>
27 #include <QDeclarativeParserStatus>
27 #include <QDeclarativeParserStatus>
28 #include <QDeclarativeListProperty>
28 #include <QDeclarativeListProperty>
29 #include <QAbstractItemModel>
29 #include <QAbstractItemModel>
30
30
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32
32
33 class QChart;
33 class QChart;
34
34
35 class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus
35 class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus
36 {
36 {
37 Q_OBJECT
37 Q_OBJECT
38 Q_INTERFACES(QDeclarativeParserStatus)
38 Q_INTERFACES(QDeclarativeParserStatus)
39 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
39 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
40 Q_CLASSINFO("DefaultProperty", "seriesChildren")
40 Q_CLASSINFO("DefaultProperty", "seriesChildren")
41
41
42 public:
42 public:
43 explicit DeclarativePieSeries(QObject *parent = 0);
43 explicit DeclarativePieSeries(QObject *parent = 0);
44 QDeclarativeListProperty<QObject> seriesChildren();
44 QDeclarativeListProperty<QObject> seriesChildren();
45 Q_INVOKABLE QPieSlice *at(int index);
45 Q_INVOKABLE QPieSlice *at(int index);
46 Q_INVOKABLE QPieSlice *find(QString label);
46 Q_INVOKABLE QPieSlice *find(QString label);
47 Q_INVOKABLE QPieSlice *append(QString label, qreal value);
47 Q_INVOKABLE QPieSlice *append(QString label, qreal value);
48 Q_INVOKABLE bool remove(int index);
48 Q_INVOKABLE bool remove(QPieSlice *slice);
49 Q_INVOKABLE void clear();
49 Q_INVOKABLE void clear();
50
50
51 public:
51 public:
52 void classBegin();
52 void classBegin();
53 void componentComplete();
53 void componentComplete();
54
54
55 Q_SIGNALS:
55 Q_SIGNALS:
56 void sliceAdded(QPieSlice* slice);
56 void sliceAdded(QPieSlice* slice);
57 void sliceRemoved(QPieSlice* slice);
57 void sliceRemoved(QPieSlice* slice);
58
58
59 public Q_SLOTS:
59 public Q_SLOTS:
60 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
60 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
61 void handleAdded(QList<QPieSlice*> slices);
61 void handleAdded(QList<QPieSlice*> slices);
62 void handleRemoved(QList<QPieSlice*> slices);
62 void handleRemoved(QList<QPieSlice*> slices);
63 };
63 };
64
64
65 QTCOMMERCIALCHART_END_NAMESPACE
65 QTCOMMERCIALCHART_END_NAMESPACE
66
66
67 #endif // DECLARATIVEPIESERIES_H
67 #endif // DECLARATIVEPIESERIES_H
@@ -1,70 +1,88
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 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 Flow {
24 Flow {
25 id: flow
25 id: flow
26 spacing: 5
26 spacing: 5
27 flow: Flow.TopToBottom
27 flow: Flow.TopToBottom
28 property variant series
28 property variant series
29
29
30 Button {
30 Button {
31 text: "visible"
31 text: "visible"
32 onClicked: series.visible = !series.visible;
32 onClicked: series.visible = !series.visible;
33 }
33 }
34 Button {
34 Button {
35 text: "labels visible"
35 text: "labels visible"
36 onClicked: series.labelsVisible = !series.labelsVisible;
36 onClicked: series.labelsVisible = !series.labelsVisible;
37 }
37 }
38 Button {
38 Button {
39 text: "bar width +"
39 text: "bar width +"
40 onClicked: series.barWidth += 0.1;
40 onClicked: series.barWidth += 0.1;
41 }
41 }
42 Button {
42 Button {
43 text: "bar width -"
43 text: "bar width -"
44 onClicked: series.barWidth -= 0.1;
44 onClicked: series.barWidth -= 0.1;
45 }
45 }
46 Button {
46 Button {
47 text: "append set"
48 onClicked: {
49 var count = series.count;
50 series.append("set" + count, [0, 0.1 * count, 0.2 * count, 0.3 * count, 0.4 * count, 0.5 * count, 0.6 * count]);
51 }
52 }
53 Button {
54 text: "insert set"
55 onClicked: {
56 var count = series.count;
57 series.insert(count - 1, "set" + count, [0, 0.1 * count, 0.2 * count, 0.3 * count, 0.4 * count, 0.5 * count, 0.6 * count]);
58 }
59 }
60 Button {
47 text: "remove set"
61 text: "remove set"
48 onClicked: series.remove(series.count - 1);
62 onClicked: series.remove(series.at(series.count - 1));
63 }
64 Button {
65 text: "clear sets"
66 onClicked: series.clear();
49 }
67 }
50 Button {
68 Button {
51 text: "set 1 color"
69 text: "set 1 color"
52 onClicked: series.at(0).color = main.nextColor();
70 onClicked: series.at(0).color = main.nextColor();
53 }
71 }
54 Button {
72 Button {
55 text: "set 1 border color"
73 text: "set 1 border color"
56 onClicked: series.at(0).borderColor = main.nextColor();
74 onClicked: series.at(0).borderColor = main.nextColor();
57 }
75 }
58 Button {
76 Button {
59 text: "set 1 label color"
77 text: "set 1 label color"
60 onClicked: series.at(0).labelColor = main.nextColor();
78 onClicked: series.at(0).labelColor = main.nextColor();
61 }
79 }
62 Button {
80 Button {
63 text: "set 1 font size +"
81 text: "set 1 font size +"
64 onClicked: series.at(0).labelFont.pixelSize += 1;
82 onClicked: series.at(0).labelFont.pixelSize += 1;
65 }
83 }
66 Button {
84 Button {
67 text: "set 1 font size -"
85 text: "set 1 font size -"
68 onClicked: series.at(0).labelFont.pixelSize -= 1;
86 onClicked: series.at(0).labelFont.pixelSize -= 1;
69 }
87 }
70 }
88 }
@@ -1,130 +1,130
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 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 Flow {
24 Flow {
25 id: flow
25 id: flow
26 spacing: 5
26 spacing: 5
27 flow: Flow.TopToBottom
27 flow: Flow.TopToBottom
28 property variant series
28 property variant series
29
29
30 Button {
30 Button {
31 text: "visible"
31 text: "visible"
32 onClicked: series.visible = !series.visible;
32 onClicked: series.visible = !series.visible;
33 }
33 }
34 Button {
34 Button {
35 text: "series hpos +"
35 text: "series hpos +"
36 onClicked: series.horizontalPosition += 0.1;
36 onClicked: series.horizontalPosition += 0.1;
37 }
37 }
38 Button {
38 Button {
39 text: "series hpos -"
39 text: "series hpos -"
40 onClicked: series.horizontalPosition -= 0.1;
40 onClicked: series.horizontalPosition -= 0.1;
41 }
41 }
42 Button {
42 Button {
43 text: "series vpos +"
43 text: "series vpos +"
44 onClicked: series.verticalPosition += 0.1;
44 onClicked: series.verticalPosition += 0.1;
45 }
45 }
46 Button {
46 Button {
47 text: "series vpos -"
47 text: "series vpos -"
48 onClicked: series.verticalPosition -= 0.1;
48 onClicked: series.verticalPosition -= 0.1;
49 }
49 }
50 Button {
50 Button {
51 text: "series size +"
51 text: "series size +"
52 onClicked: series.size += 0.1;
52 onClicked: series.size += 0.1;
53 }
53 }
54 Button {
54 Button {
55 text: "series size -"
55 text: "series size -"
56 onClicked: series.size -= 0.1;
56 onClicked: series.size -= 0.1;
57 }
57 }
58 Button {
58 Button {
59 text: "series start angle +"
59 text: "series start angle +"
60 onClicked: series.startAngle += 1.1;
60 onClicked: series.startAngle += 1.1;
61 }
61 }
62 Button {
62 Button {
63 text: "series start angle -"
63 text: "series start angle -"
64 onClicked: series.startAngle -= 1.1;
64 onClicked: series.startAngle -= 1.1;
65 }
65 }
66 Button {
66 Button {
67 text: "series end angle +"
67 text: "series end angle +"
68 onClicked: series.endAngle += 1.1;
68 onClicked: series.endAngle += 1.1;
69 }
69 }
70 Button {
70 Button {
71 text: "series end angle -"
71 text: "series end angle -"
72 onClicked: series.endAngle -= 1.1;
72 onClicked: series.endAngle -= 1.1;
73 }
73 }
74 Button {
74 Button {
75 text: "remove slice"
75 text: "remove slice"
76 onClicked: series.remove(series.count - 1);
76 onClicked: series.remove(series.at(series.count - 1));
77 }
77 }
78 Button {
78 Button {
79 text: "slice color"
79 text: "slice color"
80 onClicked: series.at(0).color = main.nextColor();
80 onClicked: series.at(0).color = main.nextColor();
81 }
81 }
82 Button {
82 Button {
83 text: "slice border color"
83 text: "slice border color"
84 onClicked: series.at(0).borderColor = main.nextColor();
84 onClicked: series.at(0).borderColor = main.nextColor();
85 }
85 }
86 Button {
86 Button {
87 text: "slice border width +"
87 text: "slice border width +"
88 onClicked: series.at(0).borderWidth++;
88 onClicked: series.at(0).borderWidth++;
89 }
89 }
90 Button {
90 Button {
91 text: "slice border width -"
91 text: "slice border width -"
92 onClicked: series.at(0).borderWidth--;
92 onClicked: series.at(0).borderWidth--;
93 }
93 }
94 Button {
94 Button {
95 text: "slice label visible"
95 text: "slice label visible"
96 onClicked: series.at(0).labelVisible = !series.at(0).labelVisible;
96 onClicked: series.at(0).labelVisible = !series.at(0).labelVisible;
97 }
97 }
98 Button {
98 Button {
99 text: "slice label position inside"
99 text: "slice label position inside"
100 onClicked: series.at(0).labelPosition = PieSlice.LabelInside;
100 onClicked: series.at(0).labelPosition = PieSlice.LabelInside;
101 }
101 }
102 Button {
102 Button {
103 text: "slice label position outside"
103 text: "slice label position outside"
104 onClicked: series.at(0).labelPosition = PieSlice.LabelOutside;
104 onClicked: series.at(0).labelPosition = PieSlice.LabelOutside;
105 }
105 }
106 Button {
106 Button {
107 text: "slice label arm len +"
107 text: "slice label arm len +"
108 onClicked: series.at(0).labelArmLengthFactor += 0.1;
108 onClicked: series.at(0).labelArmLengthFactor += 0.1;
109 }
109 }
110 Button {
110 Button {
111 text: "slice label arm len -"
111 text: "slice label arm len -"
112 onClicked: series.at(0).labelArmLengthFactor -= 0.1;
112 onClicked: series.at(0).labelArmLengthFactor -= 0.1;
113 }
113 }
114 Button {
114 Button {
115 text: "slice label color"
115 text: "slice label color"
116 onClicked: series.at(0).labelColor = main.nextColor();
116 onClicked: series.at(0).labelColor = main.nextColor();
117 }
117 }
118 Button {
118 Button {
119 text: "slice exploded"
119 text: "slice exploded"
120 onClicked: series.at(0).exploded = !series.at(0).exploded;
120 onClicked: series.at(0).exploded = !series.at(0).exploded;
121 }
121 }
122 Button {
122 Button {
123 text: "slice explode dist +"
123 text: "slice explode dist +"
124 onClicked: series.at(0).explodeDistanceFactor += 0.1;
124 onClicked: series.at(0).explodeDistanceFactor += 0.1;
125 }
125 }
126 Button {
126 Button {
127 text: "slice explode dist -"
127 text: "slice explode dist -"
128 onClicked: series.at(0).explodeDistanceFactor -= 0.1;
128 onClicked: series.at(0).explodeDistanceFactor -= 0.1;
129 }
129 }
130 }
130 }
General Comments 0
You need to be logged in to leave comments. Login now