##// END OF EJS Templates
Removed unneeded includes from declarative plugin
Tero Ahola -
r1831:08849c38dd18
parent child
Show More
@@ -1,54 +1,55
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "declarativeareaseries.h"
22 #include "declarativelineseries.h"
22 23
23 24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 25
25 26 DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) :
26 27 QAreaSeries(parent),
27 28 m_axisX(0),
28 29 m_axisY(0)
29 30 {
30 31 }
31 32
32 33 void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries* series)
33 34 {
34 35 QAreaSeries::setUpperSeries(series);
35 36 }
36 37
37 38 DeclarativeLineSeries* DeclarativeAreaSeries::upperSeries() const
38 39 {
39 40 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::upperSeries());
40 41 }
41 42
42 43 void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries* series)
43 44 {
44 45 QAreaSeries::setLowerSeries(series);
45 46 }
46 47
47 48 DeclarativeLineSeries* DeclarativeAreaSeries::lowerSeries() const
48 49 {
49 50 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::lowerSeries());
50 51 }
51 52
52 53 #include "moc_declarativeareaseries.cpp"
53 54
54 55 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,59 +1,59
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef DECLARATIVEAREASERIES_H
22 22 #define DECLARATIVEAREASERIES_H
23 23
24 24 #include "qareaseries.h"
25 #include "declarativelineseries.h"
26 25
27 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 class DeclarativeLineSeries;
28 28
29 29 class DeclarativeAreaSeries : public QAreaSeries
30 30 {
31 31 Q_OBJECT
32 32 Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries)
33 33 Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries)
34 34 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged)
35 35 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged)
36 36
37 37 public:
38 38 explicit DeclarativeAreaSeries(QObject *parent = 0);
39 39 void setUpperSeries(DeclarativeLineSeries* series);
40 40 DeclarativeLineSeries* upperSeries() const;
41 41 void setLowerSeries(DeclarativeLineSeries* series);
42 42 DeclarativeLineSeries* lowerSeries() const;
43 43 QAbstractAxis *axisX() { return m_axisX; }
44 44 void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); }
45 45 QAbstractAxis *axisY() { return m_axisY; }
46 46 void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); }
47 47
48 48 Q_SIGNALS:
49 49 void axisXChanged(QAbstractAxis *axis);
50 50 void axisYChanged(QAbstractAxis *axis);
51 51
52 52 private:
53 53 QAbstractAxis *m_axisX;
54 54 QAbstractAxis *m_axisY;
55 55 };
56 56
57 57 QTCOMMERCIALCHART_END_NAMESPACE
58 58
59 59 #endif // DECLARATIVEAREASERIES_H
@@ -1,418 +1,418
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "declarativebarseries.h"
22 #include <QBarSet>
23 #include <QVBarModelMapper>
24 #include <QHBarModelMapper>
22 #include "qbarset.h"
23 #include "qvbarmodelmapper.h"
24 #include "qhbarmodelmapper.h"
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 28 DeclarativeBarSet::DeclarativeBarSet(QObject *parent) :
29 29 QBarSet("", parent)
30 30 {
31 31 connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int, int)));
32 32 connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int)));
33 33 }
34 34
35 35 void DeclarativeBarSet::handleCountChanged(int index, int count)
36 36 {
37 37 Q_UNUSED(index)
38 38 Q_UNUSED(count)
39 39 emit countChanged(QBarSet::count());
40 40 }
41 41
42 42 QVariantList DeclarativeBarSet::values()
43 43 {
44 44 QVariantList values;
45 45 for (int i(0); i < count(); i++)
46 46 values.append(QVariant(QBarSet::at(i)));
47 47 return values;
48 48 }
49 49
50 50 void DeclarativeBarSet::setValues(QVariantList values)
51 51 {
52 52 while (count())
53 53 remove(count() - 1);
54 54
55 55 for (int i(0); i < values.count(); i++) {
56 56 if (values.at(i).canConvert(QVariant::Double))
57 57 QBarSet::append(values[i].toDouble());
58 58 }
59 59 }
60 60
61 61 // Declarative bar series ======================================================================================
62 62 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
63 63 QBarSeries(parent),
64 64 m_axisX(0),
65 65 m_axisY(0)
66 66 {
67 67 }
68 68
69 69 void DeclarativeBarSeries::classBegin()
70 70 {
71 71 }
72 72
73 73 void DeclarativeBarSeries::componentComplete()
74 74 {
75 75 foreach(QObject *child, children()) {
76 76 if (qobject_cast<DeclarativeBarSet *>(child)) {
77 77 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
78 78 } else if(qobject_cast<QVBarModelMapper *>(child)) {
79 79 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
80 80 mapper->setSeries(this);
81 81 } else if(qobject_cast<QHBarModelMapper *>(child)) {
82 82 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
83 83 mapper->setSeries(this);
84 84 }
85 85 }
86 86 }
87 87
88 88 QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren()
89 89 {
90 90 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
91 91 }
92 92
93 93 void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
94 94 {
95 95 // Empty implementation; the children are parsed in componentComplete instead
96 96 Q_UNUSED(list);
97 97 Q_UNUSED(element);
98 98 }
99 99
100 100 DeclarativeBarSet *DeclarativeBarSeries::at(int index)
101 101 {
102 102 QList<QBarSet*> setList = barSets();
103 103 if (index >= 0 && index < setList.count())
104 104 return qobject_cast<DeclarativeBarSet *>(setList[index]);
105 105
106 106 return 0;
107 107 }
108 108
109 109 DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values)
110 110 {
111 111 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
112 112 barset->setLabel(label);
113 113 barset->setValues(values);
114 114 if (QBarSeries::insert(index, barset))
115 115 return barset;
116 116 delete barset;
117 117 return 0;
118 118 }
119 119
120 120 // Declarative stacked bar series ==============================================================================
121 121 DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) :
122 122 QStackedBarSeries(parent),
123 123 m_axisX(0),
124 124 m_axisY(0)
125 125 {
126 126 }
127 127
128 128 void DeclarativeStackedBarSeries::classBegin()
129 129 {
130 130 }
131 131
132 132 void DeclarativeStackedBarSeries::componentComplete()
133 133 {
134 134 foreach(QObject *child, children()) {
135 135 if (qobject_cast<DeclarativeBarSet *>(child)) {
136 136 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
137 137 } else if(qobject_cast<QVBarModelMapper *>(child)) {
138 138 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
139 139 mapper->setSeries(this);
140 140 } else if(qobject_cast<QHBarModelMapper *>(child)) {
141 141 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
142 142 mapper->setSeries(this);
143 143 }
144 144 }
145 145 }
146 146
147 147
148 148 QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren()
149 149 {
150 150 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
151 151 }
152 152
153 153 void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
154 154 {
155 155 // Empty implementation; the children are parsed in componentComplete instead
156 156 Q_UNUSED(list);
157 157 Q_UNUSED(element);
158 158 }
159 159
160 160 DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index)
161 161 {
162 162 QList<QBarSet*> setList = barSets();
163 163 if (index >= 0 && index < setList.count())
164 164 return qobject_cast<DeclarativeBarSet *>(setList[index]);
165 165
166 166 return 0;
167 167 }
168 168
169 169 DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values)
170 170 {
171 171 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
172 172 barset->setLabel(label);
173 173 barset->setValues(values);
174 174 if (QStackedBarSeries::insert(index, barset))
175 175 return barset;
176 176 delete barset;
177 177 return 0;
178 178 }
179 179
180 180 // Declarative percent bar series ==============================================================================
181 181 DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) :
182 182 QPercentBarSeries(parent),
183 183 m_axisX(0),
184 184 m_axisY(0)
185 185 {
186 186 }
187 187
188 188 void DeclarativePercentBarSeries::classBegin()
189 189 {
190 190 }
191 191
192 192 void DeclarativePercentBarSeries::componentComplete()
193 193 {
194 194 foreach(QObject *child, children()) {
195 195 if (qobject_cast<DeclarativeBarSet *>(child)) {
196 196 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
197 197 } else if(qobject_cast<QVBarModelMapper *>(child)) {
198 198 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
199 199 mapper->setSeries(this);
200 200 } else if(qobject_cast<QHBarModelMapper *>(child)) {
201 201 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
202 202 mapper->setSeries(this);
203 203 }
204 204 }
205 205 }
206 206
207 207 QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren()
208 208 {
209 209 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
210 210 }
211 211
212 212 void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
213 213 {
214 214 // Empty implementation; the children are parsed in componentComplete instead
215 215 Q_UNUSED(list);
216 216 Q_UNUSED(element);
217 217 }
218 218
219 219 DeclarativeBarSet *DeclarativePercentBarSeries::at(int index)
220 220 {
221 221 QList<QBarSet*> setList = barSets();
222 222 if (index >= 0 && index < setList.count())
223 223 return qobject_cast<DeclarativeBarSet *>(setList[index]);
224 224
225 225 return 0;
226 226 }
227 227
228 228 DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values)
229 229 {
230 230 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
231 231 barset->setLabel(label);
232 232 barset->setValues(values);
233 233 if (QPercentBarSeries::insert(index, barset))
234 234 return barset;
235 235 delete barset;
236 236 return 0;
237 237 }
238 238
239 239 // Declarative horizontal bar series ===========================================================================
240 240 DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QDeclarativeItem *parent) :
241 241 QHorizontalBarSeries(parent),
242 242 m_axisX(0),
243 243 m_axisY(0)
244 244 {
245 245 }
246 246
247 247 void DeclarativeHorizontalBarSeries::classBegin()
248 248 {
249 249 }
250 250
251 251 void DeclarativeHorizontalBarSeries::componentComplete()
252 252 {
253 253 foreach(QObject *child, children()) {
254 254 if (qobject_cast<DeclarativeBarSet *>(child)) {
255 255 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
256 256 } else if(qobject_cast<QVBarModelMapper *>(child)) {
257 257 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
258 258 mapper->setSeries(this);
259 259 } else if(qobject_cast<QHBarModelMapper *>(child)) {
260 260 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
261 261 mapper->setSeries(this);
262 262 }
263 263 }
264 264 }
265 265
266 266 QDeclarativeListProperty<QObject> DeclarativeHorizontalBarSeries::seriesChildren()
267 267 {
268 268 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren);
269 269 }
270 270
271 271 void DeclarativeHorizontalBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
272 272 {
273 273 // Empty implementation; the children are parsed in componentComplete instead
274 274 Q_UNUSED(list);
275 275 Q_UNUSED(element);
276 276 }
277 277
278 278 DeclarativeBarSet *DeclarativeHorizontalBarSeries::at(int index)
279 279 {
280 280 QList<QBarSet*> setList = barSets();
281 281 if (index >= 0 && index < setList.count())
282 282 return qobject_cast<DeclarativeBarSet *>(setList[index]);
283 283
284 284 return 0;
285 285 }
286 286
287 287 DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString label, QVariantList values)
288 288 {
289 289 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
290 290 barset->setLabel(label);
291 291 barset->setValues(values);
292 292 if (QHorizontalBarSeries::insert(index, barset))
293 293 return barset;
294 294 delete barset;
295 295 return 0;
296 296 }
297 297
298 298 // Declarative horizontal stacked bar series ===================================================================
299 299 DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent) :
300 300 QHorizontalStackedBarSeries(parent),
301 301 m_axisX(0),
302 302 m_axisY(0)
303 303 {
304 304 }
305 305
306 306 void DeclarativeHorizontalStackedBarSeries::classBegin()
307 307 {
308 308 }
309 309
310 310 void DeclarativeHorizontalStackedBarSeries::componentComplete()
311 311 {
312 312 foreach(QObject *child, children()) {
313 313 if (qobject_cast<DeclarativeBarSet *>(child)) {
314 314 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
315 315 } else if(qobject_cast<QVBarModelMapper *>(child)) {
316 316 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
317 317 mapper->setSeries(this);
318 318 } else if(qobject_cast<QHBarModelMapper *>(child)) {
319 319 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
320 320 mapper->setSeries(this);
321 321 }
322 322 }
323 323 }
324 324
325 325 QDeclarativeListProperty<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren()
326 326 {
327 327 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren);
328 328 }
329 329
330 330 void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
331 331 {
332 332 // Empty implementation; the children are parsed in componentComplete instead
333 333 Q_UNUSED(list);
334 334 Q_UNUSED(element);
335 335 }
336 336
337 337 DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::at(int index)
338 338 {
339 339 QList<QBarSet*> setList = barSets();
340 340 if (index >= 0 && index < setList.count())
341 341 return qobject_cast<DeclarativeBarSet *>(setList[index]);
342 342
343 343 return 0;
344 344 }
345 345
346 346 DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QString label, QVariantList values)
347 347 {
348 348 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
349 349 barset->setLabel(label);
350 350 barset->setValues(values);
351 351 if (QHorizontalStackedBarSeries::insert(index, barset))
352 352 return barset;
353 353 delete barset;
354 354 return 0;
355 355 }
356 356
357 357 // Declarative horizontal percent bar series ===================================================================
358 358 DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent) :
359 359 QHorizontalPercentBarSeries(parent),
360 360 m_axisX(0),
361 361 m_axisY(0)
362 362 {
363 363 }
364 364
365 365 void DeclarativeHorizontalPercentBarSeries::classBegin()
366 366 {
367 367 }
368 368
369 369 void DeclarativeHorizontalPercentBarSeries::componentComplete()
370 370 {
371 371 foreach(QObject *child, children()) {
372 372 if (qobject_cast<DeclarativeBarSet *>(child)) {
373 373 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
374 374 } else if(qobject_cast<QVBarModelMapper *>(child)) {
375 375 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
376 376 mapper->setSeries(this);
377 377 } else if(qobject_cast<QHBarModelMapper *>(child)) {
378 378 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
379 379 mapper->setSeries(this);
380 380 }
381 381 }
382 382 }
383 383
384 384 QDeclarativeListProperty<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren()
385 385 {
386 386 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren);
387 387 }
388 388
389 389 void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
390 390 {
391 391 // Empty implementation; the children are parsed in componentComplete instead
392 392 Q_UNUSED(list);
393 393 Q_UNUSED(element);
394 394 }
395 395
396 396 DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::at(int index)
397 397 {
398 398 QList<QBarSet*> setList = barSets();
399 399 if (index >= 0 && index < setList.count())
400 400 return qobject_cast<DeclarativeBarSet *>(setList[index]);
401 401
402 402 return 0;
403 403 }
404 404
405 405 DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::insert(int index, QString label, QVariantList values)
406 406 {
407 407 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
408 408 barset->setLabel(label);
409 409 barset->setValues(values);
410 410 if (QHorizontalPercentBarSeries::insert(index, barset))
411 411 return barset;
412 412 delete barset;
413 413 return 0;
414 414 }
415 415
416 416 #include "moc_declarativebarseries.cpp"
417 417
418 418 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,159 +1,158
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef DECLARATIVECHART_H
22 22 #define DECLARATIVECHART_H
23 23
24 24 #include <QtCore/QtGlobal>
25 25 #include <QDeclarativeItem>
26 #include <qchart.h>
26 #include "qchart.h"
27 27
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29
30 30 class DeclarativeChart : public QDeclarativeItem
31 31 // TODO: for QTQUICK2: extend QQuickPainterItem instead
32 32 //class DeclarativeChart : public QQuickPaintedItem, public Chart
33 33 {
34 34 Q_OBJECT
35 35 Q_PROPERTY(Theme theme READ theme WRITE setTheme)
36 36 Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions)
37 37 Q_PROPERTY(QString title READ title WRITE setTitle)
38 38 Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont)
39 39 Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged)
40 40 Q_PROPERTY(QLegend *legend READ legend)
41 41 Q_PROPERTY(int count READ count)
42 42 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
43 43 Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged)
44 44 Q_PROPERTY(qreal topMargin READ topMargin NOTIFY topMarginChanged)
45 45 Q_PROPERTY(qreal bottomMargin READ bottomMargin NOTIFY bottomMarginChanged)
46 46 Q_PROPERTY(qreal leftMargin READ leftMargin NOTIFY leftMarginChanged)
47 47 Q_PROPERTY(qreal rightMargin READ rightMargin NOTIFY rightMarginChanged)
48 48 Q_ENUMS(Animation)
49 49 Q_ENUMS(Theme)
50 50 Q_ENUMS(SeriesType)
51 // Q_ENUMS(AxisType)
52 51
53 52 public:
54 53 // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api
55 54 enum Theme {
56 55 ChartThemeLight = 0,
57 56 ChartThemeBlueCerulean,
58 57 ChartThemeDark,
59 58 ChartThemeBrownSand,
60 59 ChartThemeBlueNcs,
61 60 ChartThemeHighContrast,
62 61 ChartThemeBlueIcy
63 62 };
64 63
65 64 enum Animation {
66 65 NoAnimation = 0x0,
67 66 GridAxisAnimations = 0x1,
68 67 SeriesAnimations =0x2,
69 68 AllAnimations = 0x3
70 69 };
71 70
72 71 enum SeriesType {
73 72 SeriesTypeLine,
74 73 SeriesTypeArea,
75 74 SeriesTypeBar,
76 75 SeriesTypeStackedBar,
77 76 SeriesTypePercentBar,
78 77 SeriesTypePie,
79 78 SeriesTypeScatter,
80 79 SeriesTypeSpline,
81 80 SeriesTypeHorizontalBar,
82 81 SeriesTypeHorizontalStackedBar,
83 82 SeriesTypeHorizontalPercentBar
84 83 };
85 84
86 85 public:
87 86 DeclarativeChart(QDeclarativeItem *parent = 0);
88 87 ~DeclarativeChart();
89 88
90 89 public: // From QDeclarativeItem/QGraphicsItem
91 90 void childEvent(QChildEvent *event);
92 91 void componentComplete();
93 92 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
94 93 void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
95 94
96 95 public:
97 96 void setTheme(DeclarativeChart::Theme theme);
98 97 DeclarativeChart::Theme theme();
99 98 void setAnimationOptions(DeclarativeChart::Animation animations);
100 99 DeclarativeChart::Animation animationOptions();
101 100 void setTitle(QString title);
102 101 QString title();
103 102 QLegend *legend();
104 103 QFont titleFont() const;
105 104 void setTitleFont(const QFont& font);
106 105 void setTitleColor(QColor color);
107 106 QColor titleColor();
108 107 void setBackgroundColor(QColor color);
109 108 QColor backgroundColor();
110 109 int count();
111 110 void setDropShadowEnabled(bool enabled);
112 111 bool dropShadowEnabled();
113 112 qreal topMargin();
114 113 qreal bottomMargin();
115 114 qreal leftMargin();
116 115 qreal rightMargin();
117 116 void createDefaultAxes(QAbstractSeries* series);
118 117
119 118 public:
120 119 Q_INVOKABLE QAbstractSeries *series(int index);
121 120 Q_INVOKABLE QAbstractSeries *series(QString seriesName);
122 121 Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = "");
123 122 Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0);
124 123 Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0);
125 124 Q_INVOKABLE void createDefaultAxes();
126 125 Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0);
127 126 Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0);
128 127
129 128 Q_INVOKABLE void zoom(qreal factor);
130 129 Q_INVOKABLE void scrollLeft(qreal pixels);
131 130 Q_INVOKABLE void scrollRight(qreal pixels);
132 131 Q_INVOKABLE void scrollUp(qreal pixels);
133 132 Q_INVOKABLE void scrollDown(qreal pixels);
134 133
135 134 Q_SIGNALS:
136 135 void axisLabelsChanged();
137 136 void titleColorChanged(QColor color);
138 137 void backgroundColorChanged();
139 138 void dropShadowEnabledChanged(bool enabled);
140 139 void topMarginChanged(qreal margin);
141 140 void bottomMarginChanged(qreal margin);
142 141 void leftMarginChanged(qreal margin);
143 142 void rightMarginChanged(qreal margin);
144 143
145 144 public Q_SLOTS:
146 145 void handleMarginsChanged(QRectF newMargins);
147 146 void handleAxisXSet(QAbstractAxis *axis);
148 147 void handleAxisYSet(QAbstractAxis *axis);
149 148
150 149 private:
151 150 // Extending QChart with DeclarativeChart is not possible because QObject does not support
152 151 // multi inheritance, so we now have a QChart as a member instead
153 152 QChart *m_chart;
154 153 QRectF m_chartMargins;
155 154 };
156 155
157 156 QTCOMMERCIALCHART_END_NAMESPACE
158 157
159 158 #endif // DECLARATIVECHART_H
@@ -1,117 +1,118
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "declarativepieseries.h"
22 #include <QVPieModelMapper>
23 #include <QHPieModelMapper>
22 #include "qpieslice.h"
23 #include "qvpiemodelmapper.h"
24 #include "qhpiemodelmapper.h"
24 25
25 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 27
27 28 DeclarativePieSeries::DeclarativePieSeries(QDeclarativeItem *parent) :
28 29 QPieSeries(parent)
29 30 {
30 31 connect(this, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleAdded(QList<QPieSlice*>)));
31 32 connect(this, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleRemoved(QList<QPieSlice*>)));
32 33 }
33 34
34 35 void DeclarativePieSeries::classBegin()
35 36 {
36 37 }
37 38
38 39 void DeclarativePieSeries::componentComplete()
39 40 {
40 41 foreach(QObject *child, children()) {
41 42 if (qobject_cast<QPieSlice *>(child)) {
42 43 QPieSeries::append(qobject_cast<QPieSlice *>(child));
43 44 } else if(qobject_cast<QVPieModelMapper *>(child)) {
44 45 QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child);
45 46 mapper->setSeries(this);
46 47 } else if(qobject_cast<QHPieModelMapper *>(child)) {
47 48 QHPieModelMapper *mapper = qobject_cast<QHPieModelMapper *>(child);
48 49 mapper->setSeries(this);
49 50 }
50 51 }
51 52 }
52 53
53 54 QDeclarativeListProperty<QObject> DeclarativePieSeries::seriesChildren()
54 55 {
55 56 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativePieSeries::appendSeriesChildren);
56 57 }
57 58
58 59 void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
59 60 {
60 61 // Empty implementation; the children are parsed in componentComplete instead
61 62 Q_UNUSED(list);
62 63 Q_UNUSED(element);
63 64 }
64 65
65 66 QPieSlice *DeclarativePieSeries::at(int index)
66 67 {
67 68 QList<QPieSlice*> sliceList = slices();
68 69 if (index >= 0 && index < sliceList.count())
69 70 return sliceList[index];
70 71
71 72 return 0;
72 73 }
73 74
74 75 QPieSlice* DeclarativePieSeries::find(QString label)
75 76 {
76 77 foreach (QPieSlice *slice, slices()) {
77 78 if (slice->label() == label)
78 79 return slice;
79 80 }
80 81 return 0;
81 82 }
82 83
83 84 QPieSlice* DeclarativePieSeries::append(QString label, qreal value)
84 85 {
85 86 // TODO: parameter order is wrong, switch it:
86 87 QPieSlice *slice = new QPieSlice(this);
87 88 slice->setLabel(label);
88 89 slice->setValue(value);
89 90 QPieSeries::append(slice);
90 91 return slice;
91 92 }
92 93
93 94 bool DeclarativePieSeries::remove(QPieSlice *slice)
94 95 {
95 96 return QPieSeries::remove(slice);
96 97 }
97 98
98 99 void DeclarativePieSeries::clear()
99 100 {
100 101 QPieSeries::clear();
101 102 }
102 103
103 104 void DeclarativePieSeries::handleAdded(QList<QPieSlice*> slices)
104 105 {
105 106 foreach(QPieSlice *slice, slices)
106 107 emit sliceAdded(slice);
107 108 }
108 109
109 110 void DeclarativePieSeries::handleRemoved(QList<QPieSlice*> slices)
110 111 {
111 112 foreach(QPieSlice *slice, slices)
112 113 emit sliceRemoved(slice);
113 114 }
114 115
115 116 #include "moc_declarativepieseries.cpp"
116 117
117 118 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,63 +1,63
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef DECLARATIVEPIESERIES_H
22 22 #define DECLARATIVEPIESERIES_H
23 23
24 #include "qpieslice.h"
25 24 #include "qpieseries.h"
26 25 #include <QDeclarativeItem>
27 26 #include <QDeclarativeParserStatus>
28 27
29 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 class QPieSlice;
30 30
31 31 class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus
32 32 {
33 33 Q_OBJECT
34 34 Q_INTERFACES(QDeclarativeParserStatus)
35 35 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
36 36 Q_CLASSINFO("DefaultProperty", "seriesChildren")
37 37
38 38 public:
39 39 explicit DeclarativePieSeries(QDeclarativeItem *parent = 0);
40 40 QDeclarativeListProperty<QObject> seriesChildren();
41 41 Q_INVOKABLE QPieSlice *at(int index);
42 42 Q_INVOKABLE QPieSlice *find(QString label);
43 43 Q_INVOKABLE QPieSlice *append(QString label, qreal value);
44 44 Q_INVOKABLE bool remove(QPieSlice *slice);
45 45 Q_INVOKABLE void clear();
46 46
47 47 public:
48 48 void classBegin();
49 49 void componentComplete();
50 50
51 51 Q_SIGNALS:
52 52 void sliceAdded(QPieSlice* slice);
53 53 void sliceRemoved(QPieSlice* slice);
54 54
55 55 public Q_SLOTS:
56 56 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
57 57 void handleAdded(QList<QPieSlice*> slices);
58 58 void handleRemoved(QList<QPieSlice*> slices);
59 59 };
60 60
61 61 QTCOMMERCIALCHART_END_NAMESPACE
62 62
63 63 #endif // DECLARATIVEPIESERIES_H
@@ -1,51 +1,52
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "declarativexypoint.h"
22 #include <QDataStream>
22 23
23 24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 25
25 26 /*!
26 27 \qmlclass XYPoint QPointF
27 28 XYPoint is a convenience element for initializing XY-series with static coordinate data. To
28 29 manipulate an XY-series dynamically, use it's data manipulation functions instead.
29 30 \sa LineSeries, AreaSeries, ScatterSeries, SplineSeries
30 31 */
31 32
32 33 /*!
33 34 \qmlproperty real XYPoint::x
34 35 The x-coordinate of the point.
35 36 */
36 37
37 38 /*!
38 39 \qmlproperty real XYPoint::y
39 40 The y-coordinate of the point.
40 41 */
41 42
42 43 DeclarativeXYPoint::DeclarativeXYPoint(QObject *parent) :
43 44 QObject(parent)
44 45 {
45 46 setX(0.0);
46 47 setY(0.0);
47 48 }
48 49
49 50 #include "moc_declarativexypoint.cpp"
50 51
51 52 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,44 +1,43
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef DECLARATIVE_XY_POINT_H
22 22 #define DECLARATIVE_XY_POINT_H
23 23
24 24 #include "qchartglobal.h"
25 25 #include <QObject>
26 26 #include <QPointF>
27 #include <QDataStream>
28 27
29 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 29
31 30 class DeclarativeXYPoint : public QObject, public QPointF
32 31 {
33 32 Q_OBJECT
34 33 // TODO: make the setters change the value, if parented by a series
35 34 Q_PROPERTY(qreal x READ x WRITE setX /*NOTIFY dataXChanged*/)
36 35 Q_PROPERTY(qreal y READ y WRITE setY /*NOTIFY dataYChanged*/)
37 36
38 37 public:
39 38 explicit DeclarativeXYPoint(QObject *parent = 0);
40 39 };
41 40
42 41 QTCOMMERCIALCHART_END_NAMESPACE
43 42
44 43 #endif // DECLARATIVE_XY_POINT_H
@@ -1,103 +1,104
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21
22 22 #include "declarativexyseries.h"
23 #include <QVXYModelMapper>
24 #include <QHXYModelMapper>
23 #include "declarativexypoint.h"
24 #include "qvxymodelmapper.h"
25 #include "qhxymodelmapper.h"
25 26
26 27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 28
28 29 DeclarativeXySeries::DeclarativeXySeries()
29 30 {
30 31 }
31 32
32 33 DeclarativeXySeries::~DeclarativeXySeries()
33 34 {
34 35 }
35 36
36 37 void DeclarativeXySeries::classBegin()
37 38 {
38 39 }
39 40
40 41 void DeclarativeXySeries::componentComplete()
41 42 {
42 43 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
43 44 Q_ASSERT(series);
44 45
45 46 foreach(QObject *child, series->children()) {
46 47 if (qobject_cast<DeclarativeXYPoint *>(child)) {
47 48 DeclarativeXYPoint *point = qobject_cast<DeclarativeXYPoint *>(child);
48 49 series->append(point->x(), point->y());
49 50 } else if(qobject_cast<QVXYModelMapper *>(child)) {
50 51 QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child);
51 52 mapper->setSeries(series);
52 53 } else if(qobject_cast<QHXYModelMapper *>(child)) {
53 54 QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child);
54 55 mapper->setSeries(series);
55 56 }
56 57 }
57 58 }
58 59
59 60 void DeclarativeXySeries::append(qreal x, qreal y)
60 61 {
61 62 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
62 63 Q_ASSERT(series);
63 64 series->append(x, y);
64 65 }
65 66
66 67 void DeclarativeXySeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY)
67 68 {
68 69 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
69 70 Q_ASSERT(series);
70 71 series->replace(oldX, oldY, newX, newY);
71 72 }
72 73
73 74 void DeclarativeXySeries::remove(qreal x, qreal y)
74 75 {
75 76 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
76 77 Q_ASSERT(series);
77 78 series->remove(x, y);
78 79 }
79 80
80 81 void DeclarativeXySeries::insert(int index, qreal x, qreal y)
81 82 {
82 83 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
83 84 Q_ASSERT(series);
84 85 series->insert(index, QPointF(x, y));
85 86 }
86 87
87 88 void DeclarativeXySeries::clear()
88 89 {
89 90 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
90 91 Q_ASSERT(series);
91 92 series->clear();
92 93 }
93 94
94 95 QPointF DeclarativeXySeries::at(int index)
95 96 {
96 97 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
97 98 Q_ASSERT(series);
98 99 if (index >= 0 || index < series->count())
99 100 return series->points().at(index);
100 101 return QPointF(0, 0);
101 102 }
102 103
103 104 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,53 +1,52
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef DECLARATIVE_XY_SERIES_H
22 22 #define DECLARATIVE_XY_SERIES_H
23 23
24 #include "declarativexypoint.h"
25 24 #include <QXYSeries>
26 25
27 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 27
29 28 class QChart;
30 29 class QAbstractSeries;
31 30
32 31 class DeclarativeXySeries
33 32 {
34 33 public:
35 34 explicit DeclarativeXySeries();
36 35 ~DeclarativeXySeries();
37 36
38 37 public:
39 38 void classBegin();
40 39 void componentComplete();
41 40 virtual QXYSeries *xySeries() = 0;
42 41
43 42 void append(qreal x, qreal y);
44 43 void replace(qreal oldX, qreal oldY, qreal newX, qreal newY);
45 44 void remove(qreal x, qreal y);
46 45 void insert(int index, qreal x, qreal y);
47 46 void clear();
48 47 QPointF at(int index);
49 48 };
50 49
51 50 QTCOMMERCIALCHART_END_NAMESPACE
52 51
53 52 #endif // DECLARATIVE_XY_SERIES_H
General Comments 0
You need to be logged in to leave comments. Login now