@@ -1,48 +1,53 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativelineseries.h" |
|
21 | #include "declarativelineseries.h" | |
22 | #include "declarativechart.h" |
|
22 | #include "declarativechart.h" | |
23 | #include "qchart.h" |
|
23 | #include "qchart.h" | |
24 | #include "qlineseries.h" |
|
24 | #include "qlineseries.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) : |
|
28 | DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) : | |
29 | QLineSeries(parent) |
|
29 | QLineSeries(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); | |
36 | } |
|
41 | } | |
37 |
|
42 | |||
38 | void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element) |
|
43 | void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element) | |
39 | { |
|
44 | { | |
40 | QXYSeries *series = qobject_cast<QXYSeries*>(list->object); |
|
45 | QXYSeries *series = qobject_cast<QXYSeries*>(list->object); | |
41 | DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element); |
|
46 | DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element); | |
42 | if (series && point) |
|
47 | if (series && point) | |
43 | series->append(*point); |
|
48 | series->append(*point); | |
44 | } |
|
49 | } | |
45 |
|
50 | |||
46 | #include "moc_declarativelineseries.cpp" |
|
51 | #include "moc_declarativelineseries.cpp" | |
47 |
|
52 | |||
48 | QTCOMMERCIALCHART_END_NAMESPACE |
|
53 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,61 +1,62 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVELINESERIES_H |
|
21 | #ifndef DECLARATIVELINESERIES_H | |
22 | #define DECLARATIVELINESERIES_H |
|
22 | #define DECLARATIVELINESERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "qlineseries.h" |
|
25 | #include "qlineseries.h" | |
26 | #include "declarativexyseries.h" |
|
26 | #include "declarativexyseries.h" | |
27 | #include <QDeclarativeParserStatus> |
|
27 | #include <QDeclarativeParserStatus> | |
28 | #include <QDeclarativeListProperty> |
|
28 | #include <QDeclarativeListProperty> | |
29 | #include <QDeclarativeParserStatus> |
|
29 | #include <QDeclarativeParserStatus> | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus |
|
33 | class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | Q_INTERFACES(QDeclarativeParserStatus) |
|
36 | Q_INTERFACES(QDeclarativeParserStatus) | |
37 | Q_PROPERTY(QColor color READ penColor WRITE setPenColor) |
|
37 | Q_PROPERTY(QColor color READ penColor WRITE setPenColor) | |
38 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
38 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
39 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
39 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
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 | |
46 | void classBegin() { DeclarativeXySeries::classBegin(); } |
|
47 | void classBegin() { DeclarativeXySeries::classBegin(); } | |
47 | void componentComplete() { DeclarativeXySeries::componentComplete(); } |
|
48 | void componentComplete() { DeclarativeXySeries::componentComplete(); } | |
48 |
|
49 | |||
49 | public: // from QLineSeries |
|
50 | public: // from QLineSeries | |
50 | Q_INVOKABLE void append(qreal x, qreal y) { QLineSeries::append(x, y); } |
|
51 | Q_INVOKABLE void append(qreal x, qreal y) { QLineSeries::append(x, y); } | |
51 | Q_INVOKABLE void remove(qreal x, qreal y) { QLineSeries::remove(x, y); } |
|
52 | Q_INVOKABLE void remove(qreal x, qreal y) { QLineSeries::remove(x, y); } | |
52 | Q_INVOKABLE void clear() { QLineSeries::clear(); } |
|
53 | Q_INVOKABLE void clear() { QLineSeries::clear(); } | |
53 | Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } |
|
54 | Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } | |
54 |
|
55 | |||
55 | public Q_SLOTS: |
|
56 | public Q_SLOTS: | |
56 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
57 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
57 | }; |
|
58 | }; | |
58 |
|
59 | |||
59 | QTCOMMERCIALCHART_END_NAMESPACE |
|
60 | QTCOMMERCIALCHART_END_NAMESPACE | |
60 |
|
61 | |||
61 | #endif // DECLARATIVELINESERIES_H |
|
62 | #endif // DECLARATIVELINESERIES_H |
@@ -1,60 +1,65 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativescatterseries.h" |
|
21 | #include "declarativescatterseries.h" | |
22 | #include "declarativechart.h" |
|
22 | #include "declarativechart.h" | |
23 | #include "qchart.h" |
|
23 | #include "qchart.h" | |
24 | #include "qscatterseries.h" |
|
24 | #include "qscatterseries.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : |
|
28 | DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : | |
29 | QScatterSeries(parent) |
|
29 | QScatterSeries(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); | |
36 | } |
|
41 | } | |
37 |
|
42 | |||
38 | void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element) |
|
43 | void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element) | |
39 | { |
|
44 | { | |
40 | QXYSeries *series = qobject_cast<QXYSeries*>(list->object); |
|
45 | QXYSeries *series = qobject_cast<QXYSeries*>(list->object); | |
41 | DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element); |
|
46 | DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element); | |
42 | if (series && point) |
|
47 | if (series && point) | |
43 | series->append(*point); |
|
48 | series->append(*point); | |
44 | } |
|
49 | } | |
45 |
|
50 | |||
46 | QColor DeclarativeScatterSeries::brushColor() |
|
51 | QColor DeclarativeScatterSeries::brushColor() | |
47 | { |
|
52 | { | |
48 | return brush().color(); |
|
53 | return brush().color(); | |
49 | } |
|
54 | } | |
50 |
|
55 | |||
51 | void DeclarativeScatterSeries::setBrushColor(QColor color) |
|
56 | void DeclarativeScatterSeries::setBrushColor(QColor color) | |
52 | { |
|
57 | { | |
53 | QBrush b = brush(); |
|
58 | QBrush b = brush(); | |
54 | b.setColor(color); |
|
59 | b.setColor(color); | |
55 | setBrush(b); |
|
60 | setBrush(b); | |
56 | } |
|
61 | } | |
57 |
|
62 | |||
58 | #include "moc_declarativescatterseries.cpp" |
|
63 | #include "moc_declarativescatterseries.cpp" | |
59 |
|
64 | |||
60 | QTCOMMERCIALCHART_END_NAMESPACE |
|
65 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,63 +1,64 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVESCATTERSERIES_H |
|
21 | #ifndef DECLARATIVESCATTERSERIES_H | |
22 | #define DECLARATIVESCATTERSERIES_H |
|
22 | #define DECLARATIVESCATTERSERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "qscatterseries.h" |
|
25 | #include "qscatterseries.h" | |
26 | #include "declarativexyseries.h" |
|
26 | #include "declarativexyseries.h" | |
27 | #include <QDeclarativeListProperty> |
|
27 | #include <QDeclarativeListProperty> | |
28 | #include <QDeclarativeParserStatus> |
|
28 | #include <QDeclarativeParserStatus> | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries, public QDeclarativeParserStatus |
|
32 | class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries, public QDeclarativeParserStatus | |
33 | { |
|
33 | { | |
34 | Q_OBJECT |
|
34 | Q_OBJECT | |
35 | Q_INTERFACES(QDeclarativeParserStatus) |
|
35 | Q_INTERFACES(QDeclarativeParserStatus) | |
36 | Q_PROPERTY(QColor color READ brushColor WRITE setBrushColor) |
|
36 | Q_PROPERTY(QColor color READ brushColor WRITE setBrushColor) | |
37 | Q_PROPERTY(QColor borderColor READ penColor WRITE setPenColor) |
|
37 | Q_PROPERTY(QColor borderColor READ penColor WRITE setPenColor) | |
38 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
38 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
39 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
39 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
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); | |
46 |
|
47 | |||
47 | public: // from QDeclarativeParserStatus |
|
48 | public: // from QDeclarativeParserStatus | |
48 | void classBegin() { DeclarativeXySeries::classBegin(); } |
|
49 | void classBegin() { DeclarativeXySeries::classBegin(); } | |
49 | void componentComplete() { DeclarativeXySeries::componentComplete(); } |
|
50 | void componentComplete() { DeclarativeXySeries::componentComplete(); } | |
50 |
|
51 | |||
51 | public: // from QScatterSeries |
|
52 | public: // from QScatterSeries | |
52 | Q_INVOKABLE void append(qreal x, qreal y) { QScatterSeries::append(x, y); } |
|
53 | Q_INVOKABLE void append(qreal x, qreal y) { QScatterSeries::append(x, y); } | |
53 | Q_INVOKABLE void remove(qreal x, qreal y) { QScatterSeries::remove(x, y); } |
|
54 | Q_INVOKABLE void remove(qreal x, qreal y) { QScatterSeries::remove(x, y); } | |
54 | Q_INVOKABLE void clear() { QScatterSeries::clear(); } |
|
55 | Q_INVOKABLE void clear() { QScatterSeries::clear(); } | |
55 | Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } |
|
56 | Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } | |
56 |
|
57 | |||
57 | public Q_SLOTS: |
|
58 | public Q_SLOTS: | |
58 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
59 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
59 | }; |
|
60 | }; | |
60 |
|
61 | |||
61 | QTCOMMERCIALCHART_END_NAMESPACE |
|
62 | QTCOMMERCIALCHART_END_NAMESPACE | |
62 |
|
63 | |||
63 | #endif // DECLARATIVESCATTERSERIES_H |
|
64 | #endif // DECLARATIVESCATTERSERIES_H |
@@ -1,48 +1,53 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativesplineseries.h" |
|
21 | #include "declarativesplineseries.h" | |
22 | #include "declarativechart.h" |
|
22 | #include "declarativechart.h" | |
23 | #include <QChart> |
|
23 | #include <QChart> | |
24 | #include "declarativexypoint.h" |
|
24 | #include "declarativexypoint.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : |
|
28 | DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : | |
29 | QSplineSeries(parent) |
|
29 | QSplineSeries(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); | |
36 | } |
|
41 | } | |
37 |
|
42 | |||
38 | void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element) |
|
43 | void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element) | |
39 | { |
|
44 | { | |
40 | QXYSeries *series = qobject_cast<QXYSeries*>(list->object); |
|
45 | QXYSeries *series = qobject_cast<QXYSeries*>(list->object); | |
41 | DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element); |
|
46 | DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element); | |
42 | if (series && point) |
|
47 | if (series && point) | |
43 | series->append(*point); |
|
48 | series->append(*point); | |
44 | } |
|
49 | } | |
45 |
|
50 | |||
46 | #include "moc_declarativesplineseries.cpp" |
|
51 | #include "moc_declarativesplineseries.cpp" | |
47 |
|
52 | |||
48 | QTCOMMERCIALCHART_END_NAMESPACE |
|
53 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,61 +1,62 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVESPLINESERIES_H |
|
21 | #ifndef DECLARATIVESPLINESERIES_H | |
22 | #define DECLARATIVESPLINESERIES_H |
|
22 | #define DECLARATIVESPLINESERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "qsplineseries.h" |
|
25 | #include "qsplineseries.h" | |
26 | #include "declarativexyseries.h" |
|
26 | #include "declarativexyseries.h" | |
27 | #include <QDeclarativeParserStatus> |
|
27 | #include <QDeclarativeParserStatus> | |
28 | #include <QDeclarativeListProperty> |
|
28 | #include <QDeclarativeListProperty> | |
29 | #include <QDeclarativeParserStatus> |
|
29 | #include <QDeclarativeParserStatus> | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus |
|
33 | class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | Q_INTERFACES(QDeclarativeParserStatus) |
|
36 | Q_INTERFACES(QDeclarativeParserStatus) | |
37 | Q_PROPERTY(QColor color READ penColor WRITE setPenColor) |
|
37 | Q_PROPERTY(QColor color READ penColor WRITE setPenColor) | |
38 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
38 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
39 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
39 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
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 | |
46 | void classBegin() { DeclarativeXySeries::classBegin(); } |
|
47 | void classBegin() { DeclarativeXySeries::classBegin(); } | |
47 | void componentComplete() { DeclarativeXySeries::componentComplete(); } |
|
48 | void componentComplete() { DeclarativeXySeries::componentComplete(); } | |
48 |
|
49 | |||
49 | public: // from QSplineSeries |
|
50 | public: // from QSplineSeries | |
50 | Q_INVOKABLE void append(qreal x, qreal y) { QSplineSeries::append(x, y); } |
|
51 | Q_INVOKABLE void append(qreal x, qreal y) { QSplineSeries::append(x, y); } | |
51 | Q_INVOKABLE void remove(qreal x, qreal y) { QSplineSeries::remove(x, y); } |
|
52 | Q_INVOKABLE void remove(qreal x, qreal y) { QSplineSeries::remove(x, y); } | |
52 | Q_INVOKABLE void clear() { QSplineSeries::clear(); } |
|
53 | Q_INVOKABLE void clear() { QSplineSeries::clear(); } | |
53 | Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } |
|
54 | Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } | |
54 |
|
55 | |||
55 | public Q_SLOTS: |
|
56 | public Q_SLOTS: | |
56 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
57 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
57 | }; |
|
58 | }; | |
58 |
|
59 | |||
59 | QTCOMMERCIALCHART_END_NAMESPACE |
|
60 | QTCOMMERCIALCHART_END_NAMESPACE | |
60 |
|
61 | |||
61 | #endif // DECLARATIVESPLINESERIES_H |
|
62 | #endif // DECLARATIVESPLINESERIES_H |
@@ -1,90 +1,94 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | //#include "DeclarativeXySeries.h" |
|
21 | //#include "DeclarativeXySeries.h" | |
22 | #include "declarativexyseries.h" |
|
22 | #include "declarativexyseries.h" | |
23 | #include "declarativechart.h" |
|
23 | #include "declarativechart.h" | |
24 | #include <QXYSeries> |
|
24 | #include <QXYSeries> | |
25 | #include <QVXYModelMapper> |
|
25 | #include <QVXYModelMapper> | |
26 | #include <QHXYModelMapper> |
|
26 | #include <QHXYModelMapper> | |
27 | #include <QDeclarativeListProperty> |
|
27 | #include <QDeclarativeListProperty> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | DeclarativeXySeries::DeclarativeXySeries() |
|
31 | DeclarativeXySeries::DeclarativeXySeries() | |
32 | { |
|
32 | { | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | DeclarativeXySeries::~DeclarativeXySeries() |
|
35 | DeclarativeXySeries::~DeclarativeXySeries() | |
36 | { |
|
36 | { | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | void DeclarativeXySeries::classBegin() |
|
39 | void DeclarativeXySeries::classBegin() | |
40 | { |
|
40 | { | |
41 | } |
|
41 | } | |
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: | |
50 | // series->append(qobject_cast<DeclarativeXyPoint *>(child)); |
|
51 | // series->append(qobject_cast<DeclarativeXyPoint *>(child)); | |
51 | } else if(qobject_cast<QVXYModelMapper *>(child)) { |
|
52 | } else if(qobject_cast<QVXYModelMapper *>(child)) { | |
52 | QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child); |
|
53 | QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child); | |
53 | mapper->setSeries(series); |
|
54 | mapper->setSeries(series); | |
54 | } else if(qobject_cast<QHXYModelMapper *>(child)) { |
|
55 | } else if(qobject_cast<QHXYModelMapper *>(child)) { | |
55 | QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child); |
|
56 | QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child); | |
56 | mapper->setSeries(series); |
|
57 | mapper->setSeries(series); | |
57 | } |
|
58 | } | |
58 | } |
|
59 | } | |
59 | } |
|
60 | } | |
60 |
|
61 | |||
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); | |
74 | } |
|
77 | } | |
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); | |
82 | xyPoint->setX(point.x()); |
|
86 | xyPoint->setX(point.x()); | |
83 | xyPoint->setY(point.y()); |
|
87 | xyPoint->setY(point.y()); | |
84 | return xyPoint; |
|
88 | return xyPoint; | |
85 | } |
|
89 | } | |
86 | return 0; |
|
90 | return 0; | |
87 | } |
|
91 | } | |
88 |
|
92 | |||
89 |
|
93 | |||
90 | QTCOMMERCIALCHART_END_NAMESPACE |
|
94 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,49 +1,51 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVE_XY_SERIES_H |
|
21 | #ifndef DECLARATIVE_XY_SERIES_H | |
22 | #define DECLARATIVE_XY_SERIES_H |
|
22 | #define DECLARATIVE_XY_SERIES_H | |
23 |
|
23 | |||
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 | |||
30 | class QChart; |
|
31 | class QChart; | |
31 | class QAbstractSeries; |
|
32 | class QAbstractSeries; | |
32 |
|
33 | |||
33 | class DeclarativeXySeries |
|
34 | class DeclarativeXySeries | |
34 | { |
|
35 | { | |
35 | public: |
|
36 | public: | |
36 | explicit DeclarativeXySeries(); |
|
37 | explicit DeclarativeXySeries(); | |
37 | ~DeclarativeXySeries(); |
|
38 | ~DeclarativeXySeries(); | |
38 |
|
39 | |||
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); | |
45 | }; |
|
47 | }; | |
46 |
|
48 | |||
47 | QTCOMMERCIALCHART_END_NAMESPACE |
|
49 | QTCOMMERCIALCHART_END_NAMESPACE | |
48 |
|
50 | |||
49 | #endif // DECLARATIVE_XY_SERIES_H |
|
51 | #endif // DECLARATIVE_XY_SERIES_H |
General Comments 0
You need to be logged in to leave comments.
Login now