##// END OF EJS Templates
Changed include to small letter first becasue it didn't build on Linux
Marek Rosa -
r736:2fbb02cafb8b
parent child
Show More
@@ -1,85 +1,86
1 #include "DeclarativeXySeries.h"
1 //#include "DeclarativeXySeries.h"
2 #include "declarativexyseries.h"
2 3 #include "declarativechart.h"
3 4 #include "qchart.h"
4 5 #include "qxyseries.h"
5 6 #include "qareaseries.h"
6 7 #include "qsplineseries.h"
7 8 #include "qscatterseries.h"
8 9
9 10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 11
11 12 DeclarativeXySeries::DeclarativeXySeries(QSeries::QSeriesType type, QDeclarativeItem *parent) :
12 13 QDeclarativeItem(parent),
13 14 m_seriesType(type),
14 15 m_chart(0),
15 16 m_series(0)
16 17 {
17 18 setFlag(QGraphicsItem::ItemHasNoContents, false);
18 19 }
19 20
20 21 DeclarativeXySeries::~DeclarativeXySeries()
21 22 {
22 23 }
23 24
24 25 void DeclarativeXySeries::componentComplete()
25 26 {
26 27 Q_ASSERT(!m_series);
27 28 DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent());
28 29
29 30 if (declarativeChart) {
30 31 m_chart = qobject_cast<QChart *>(declarativeChart->m_chart);
31 32 Q_ASSERT(m_chart);
32 33
33 34 switch (m_seriesType) {
34 35 case QSeries::SeriesTypeLine:
35 36 qDebug() << "creating line series for chart: " << m_chart;
36 37 m_series = new QLineSeries();
37 38 break;
38 39 case QSeries::SeriesTypeArea:
39 40 qDebug() << "TODO: creating area series for chart: " << m_chart;
40 41 // m_series = new QAreaSeries();
41 42 break;
42 43 case QSeries::SeriesTypeSpline:
43 44 qDebug() << "creating spline series for chart: " << m_chart;
44 45 m_series = new QSplineSeries();
45 46 break;
46 47 case QSeries::SeriesTypeScatter:
47 48 qDebug() << "creating scatter series for chart: " << m_chart;
48 49 m_series = new QScatterSeries();
49 50 break;
50 51 default:
51 52 Q_ASSERT(false);
52 53 }
53 54
54 55 for (int i(0); i < m_points.count(); i++) {
55 56 DeclarativeXyPoint *element = m_points.at(i);
56 57 m_series->add(element->x(), element->y());
57 58 }
58 59 m_chart->addSeries(m_series);
59 60 }
60 61 }
61 62
62 63 QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeXySeries::points()
63 64 {
64 65 return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeXySeries::appendPoints);
65 66 }
66 67
67 68 void DeclarativeXySeries::appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list,
68 69 DeclarativeXyPoint *element)
69 70 {
70 71 DeclarativeXySeries *series = qobject_cast<DeclarativeXySeries *>(list->object);
71 72 qDebug() << "appendPoints: " << series;
72 73 qDebug() << "appendPoints: " << element;
73 74 qDebug() << "appendPoints: " << element->x();
74 75 qDebug() << "appendPoints: " << element->y();
75 76 qDebug() << "appendPoints: " << series->m_series;
76 77 if (series) {
77 78 series->m_points.append(element);
78 79 if (series->m_series)
79 80 series->m_series->add(element->x(), element->y());
80 81 }
81 82 }
82 83
83 84 #include "moc_declarativexyseries.cpp"
84 85
85 86 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now