@@ -116,12 +116,23 void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject | |||||
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 | { | |
@@ -161,12 +172,23 void DeclarativeGroupedBarSeries::appendSeriesChildren(QDeclarativeListProperty< | |||||
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 | { | |
@@ -206,12 +228,23 void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty< | |||||
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 | { | |
@@ -251,12 +284,23 void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty< | |||||
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 |
@@ -66,6 +66,10 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(); | |
@@ -92,6 +96,10 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(); | |
@@ -112,6 +120,10 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(); | |
@@ -132,6 +144,10 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(); |
@@ -93,12 +93,9 QPieSlice* DeclarativePieSeries::append(QString label, qreal value) | |||||
93 | return slice; |
|
93 | return slice; | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 |
bool DeclarativePieSeries::remove( |
|
96 | bool DeclarativePieSeries::remove(QPieSlice *slice) | |
97 | { |
|
97 | { | |
98 | QPieSlice *slice = at(index); |
|
|||
99 | if (slice) |
|
|||
100 |
|
|
98 | return QPieSeries::remove(slice); | |
101 | return false; |
|
|||
102 | } |
|
99 | } | |
103 |
|
100 | |||
104 | void DeclarativePieSeries::clear() |
|
101 | void DeclarativePieSeries::clear() |
@@ -45,7 +45,7 public: | |||||
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( |
|
48 | Q_INVOKABLE bool remove(QPieSlice *slice); | |
49 | Q_INVOKABLE void clear(); |
|
49 | Q_INVOKABLE void clear(); | |
50 |
|
50 | |||
51 | public: |
|
51 | public: |
@@ -44,8 +44,26 Flow { | |||||
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" |
General Comments 0
You need to be logged in to leave comments.
Login now