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