@@ -30,6 +30,11 DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) : | |||
|
30 | 30 | { |
|
31 | 31 | } |
|
32 | 32 | |
|
33 | QXYSeries *DeclarativeLineSeries::xySeries() | |
|
34 | { | |
|
35 | return this; | |
|
36 | } | |
|
37 | ||
|
33 | 38 | QDeclarativeListProperty<QObject> DeclarativeLineSeries::declarativeChildren() |
|
34 | 39 | { |
|
35 | 40 | return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren); |
@@ -40,6 +40,7 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, pu | |||
|
40 | 40 | |
|
41 | 41 | public: |
|
42 | 42 | explicit DeclarativeLineSeries(QObject *parent = 0); |
|
43 | QXYSeries *xySeries(); | |
|
43 | 44 | QDeclarativeListProperty<QObject> declarativeChildren(); |
|
44 | 45 | |
|
45 | 46 | public: // from QDeclarativeParserStatus |
@@ -30,6 +30,11 DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : | |||
|
30 | 30 | { |
|
31 | 31 | } |
|
32 | 32 | |
|
33 | QXYSeries *DeclarativeScatterSeries::xySeries() | |
|
34 | { | |
|
35 | return this; | |
|
36 | } | |
|
37 | ||
|
33 | 38 | QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren() |
|
34 | 39 | { |
|
35 | 40 | return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren); |
@@ -40,6 +40,7 class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeri | |||
|
40 | 40 | |
|
41 | 41 | public: |
|
42 | 42 | explicit DeclarativeScatterSeries(QObject *parent = 0); |
|
43 | QXYSeries *xySeries(); | |
|
43 | 44 | QDeclarativeListProperty<QObject> declarativeChildren(); |
|
44 | 45 | QColor brushColor(); |
|
45 | 46 | void setBrushColor(QColor color); |
@@ -30,6 +30,11 DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : | |||
|
30 | 30 | { |
|
31 | 31 | } |
|
32 | 32 | |
|
33 | QXYSeries *DeclarativeSplineSeries::xySeries() | |
|
34 | { | |
|
35 | return this; | |
|
36 | } | |
|
37 | ||
|
33 | 38 | QDeclarativeListProperty<QObject> DeclarativeSplineSeries::declarativeChildren() |
|
34 | 39 | { |
|
35 | 40 | return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren); |
@@ -40,6 +40,7 class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries | |||
|
40 | 40 | |
|
41 | 41 | public: |
|
42 | 42 | explicit DeclarativeSplineSeries(QObject *parent = 0); |
|
43 | QXYSeries *xySeries(); | |
|
43 | 44 | QDeclarativeListProperty<QObject> declarativeChildren(); |
|
44 | 45 | |
|
45 | 46 | public: // from QDeclarativeParserStatus |
@@ -42,8 +42,9 void DeclarativeXySeries::classBegin() | |||
|
42 | 42 | |
|
43 | 43 | void DeclarativeXySeries::componentComplete() |
|
44 | 44 | { |
|
45 | // All the inherited objects must be of type QXYSeries, so it is safe to cast | |
|
46 | QXYSeries *series = reinterpret_cast<QXYSeries *>(this); | |
|
45 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
|
46 | Q_ASSERT(series); | |
|
47 | ||
|
47 | 48 | foreach(QObject *child, series->children()) { |
|
48 | 49 | if (qobject_cast<DeclarativeXyPoint *>(child)) { |
|
49 | 50 | // TODO: |
@@ -61,13 +62,15 void DeclarativeXySeries::componentComplete() | |||
|
61 | 62 | QColor DeclarativeXySeries::penColor() |
|
62 | 63 | { |
|
63 | 64 | // All the inherited objects must be of type QXYSeries, so it is safe to cast |
|
64 |
QXYSeries *series = |
|
|
65 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
|
66 | Q_ASSERT(series); | |
|
65 | 67 | return series->pen().color(); |
|
66 | 68 | } |
|
67 | 69 | |
|
68 | 70 | void DeclarativeXySeries::setPenColor(QColor color) |
|
69 | 71 | { |
|
70 |
QXYSeries *series = |
|
|
72 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
|
73 | Q_ASSERT(series); | |
|
71 | 74 | QPen pen = series->pen(); |
|
72 | 75 | pen.setColor(color); |
|
73 | 76 | series->setPen(pen); |
@@ -75,7 +78,8 void DeclarativeXySeries::setPenColor(QColor color) | |||
|
75 | 78 | |
|
76 | 79 | DeclarativeXyPoint *DeclarativeXySeries::at(int index) |
|
77 | 80 | { |
|
78 |
QXYSeries *series = |
|
|
81 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
|
82 | Q_ASSERT(series); | |
|
79 | 83 | if (index < series->count()) { |
|
80 | 84 | QPointF point = series->points().at(index); |
|
81 | 85 | DeclarativeXyPoint *xyPoint = new DeclarativeXyPoint(series); |
@@ -24,6 +24,7 | |||
|
24 | 24 | #include "qchartglobal.h" |
|
25 | 25 | #include "declarativexypoint.h" |
|
26 | 26 | #include <QColor> |
|
27 | #include <QXYSeries> | |
|
27 | 28 | |
|
28 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 30 | |
@@ -39,6 +40,7 public: | |||
|
39 | 40 | public: |
|
40 | 41 | void classBegin(); |
|
41 | 42 | void componentComplete(); |
|
43 | virtual QXYSeries *xySeries() = 0; | |
|
42 | 44 | QColor penColor(); |
|
43 | 45 | void setPenColor(QColor color); |
|
44 | 46 | DeclarativeXyPoint *at(int index); |
General Comments 0
You need to be logged in to leave comments.
Login now