@@ -1,121 +1,123 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 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 "qlineseries.h" |
|
24 | #include "qlineseries.h" | |
25 | #include "declarativexyseries.h" |
|
25 | #include "declarativexyseries.h" | |
26 | #include "declarativeaxes.h" |
|
26 | #include "declarativeaxes.h" | |
27 | #include "shared_defines.h" |
|
27 | #include "shared_defines.h" | |
28 |
|
28 | |||
29 | #ifdef CHARTS_FOR_QUICK2 |
|
29 | #ifdef CHARTS_FOR_QUICK2 | |
30 | #include <QtQml/QQmlListProperty> |
|
30 | #include <QtQml/QQmlListProperty> | |
31 | #include <QtQml/QQmlParserStatus> |
|
31 | #include <QtQml/QQmlParserStatus> | |
32 | #else |
|
32 | #else | |
33 | #include <QtDeclarative/QDeclarativeListProperty> |
|
33 | #include <QtDeclarative/QDeclarativeListProperty> | |
34 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
34 | #include <QtDeclarative/QDeclarativeParserStatus> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, public QDECLARATIVE_PARSER_STATUS |
|
39 | class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, public QDECLARATIVE_PARSER_STATUS | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | #ifdef CHARTS_FOR_QUICK2 |
|
42 | #ifdef CHARTS_FOR_QUICK2 | |
43 | Q_INTERFACES(QQmlParserStatus) |
|
43 | Q_INTERFACES(QQmlParserStatus) | |
44 | #else |
|
44 | #else | |
45 | Q_INTERFACES(QDeclarativeParserStatus) |
|
45 | Q_INTERFACES(QDeclarativeParserStatus) | |
46 | #endif |
|
46 | #endif | |
47 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
47 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
48 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
48 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
49 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
49 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
50 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) |
|
50 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) | |
51 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) |
|
51 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) | |
52 | Q_PROPERTY(QAbstractAxis *axisAngular READ axisAngular WRITE setAxisAngular NOTIFY axisAngularChanged REVISION 3) |
|
52 | Q_PROPERTY(QAbstractAxis *axisAngular READ axisAngular WRITE setAxisAngular NOTIFY axisAngularChanged REVISION 3) | |
53 | Q_PROPERTY(QAbstractAxis *axisRadial READ axisRadial WRITE setAxisRadial NOTIFY axisRadialChanged REVISION 3) |
|
53 | Q_PROPERTY(QAbstractAxis *axisRadial READ axisRadial WRITE setAxisRadial NOTIFY axisRadialChanged REVISION 3) | |
54 | Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) |
|
54 | Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) | |
55 | Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) |
|
55 | Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) | |
56 | Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1) |
|
56 | Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1) | |
57 | #ifdef CHARTS_FOR_QUICK2 |
|
57 | #ifdef CHARTS_FOR_QUICK2 | |
58 | Q_PROPERTY(QQmlListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
58 | Q_PROPERTY(QQmlListProperty<QObject> declarativeChildren READ declarativeChildren) | |
59 | #else |
|
59 | #else | |
60 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
60 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
61 | #endif |
|
61 | #endif | |
62 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
62 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
63 |
|
63 | |||
64 | public: |
|
64 | public: | |
65 | explicit DeclarativeLineSeries(QObject *parent = 0); |
|
65 | explicit DeclarativeLineSeries(QObject *parent = 0); | |
66 | QXYSeries *xySeries() { return this; } |
|
66 | QXYSeries *xySeries() { return this; } | |
67 | QAbstractAxis *axisX() { return m_axes->axisX(); } |
|
67 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
68 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } |
|
68 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
69 | QAbstractAxis *axisY() { return m_axes->axisY(); } |
|
69 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
70 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } |
|
70 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
71 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } |
|
71 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } | |
72 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } |
|
72 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } | |
73 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } |
|
73 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } | |
74 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } |
|
74 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } | |
75 | Q_REVISION(3) QAbstractAxis *axisAngular() { return m_axes->axisX(); } |
|
75 | Q_REVISION(3) QAbstractAxis *axisAngular() { return m_axes->axisX(); } | |
76 | Q_REVISION(3) void setAxisAngular(QAbstractAxis *axis) { m_axes->setAxisX(axis); } |
|
76 | Q_REVISION(3) void setAxisAngular(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
77 | Q_REVISION(3) QAbstractAxis *axisRadial() { return m_axes->axisY(); } |
|
77 | Q_REVISION(3) QAbstractAxis *axisRadial() { return m_axes->axisY(); } | |
78 | Q_REVISION(3) void setAxisRadial(QAbstractAxis *axis) { m_axes->setAxisY(axis); } |
|
78 | Q_REVISION(3) void setAxisRadial(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
79 | qreal width() const; |
|
79 | qreal width() const; | |
80 | void setWidth(qreal width); |
|
80 | void setWidth(qreal width); | |
81 | Qt::PenStyle style() const; |
|
81 | Qt::PenStyle style() const; | |
82 | void setStyle(Qt::PenStyle style); |
|
82 | void setStyle(Qt::PenStyle style); | |
83 | Qt::PenCapStyle capStyle() const; |
|
83 | Qt::PenCapStyle capStyle() const; | |
84 | void setCapStyle(Qt::PenCapStyle capStyle); |
|
84 | void setCapStyle(Qt::PenCapStyle capStyle); | |
85 | QDECLARATIVE_LIST_PROPERTY<QObject> declarativeChildren(); |
|
85 | QDECLARATIVE_LIST_PROPERTY<QObject> declarativeChildren(); | |
86 |
|
86 | |||
87 | public: // from QDeclarativeParserStatus |
|
87 | public: // from QDeclarativeParserStatus | |
88 | void classBegin() { DeclarativeXySeries::classBegin(); } |
|
88 | void classBegin() { DeclarativeXySeries::classBegin(); } | |
89 | void componentComplete() { DeclarativeXySeries::componentComplete(); } |
|
89 | void componentComplete() { DeclarativeXySeries::componentComplete(); } | |
90 |
|
90 | |||
91 | public: |
|
91 | public: | |
92 | Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } |
|
92 | Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } | |
93 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } |
|
93 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } | |
|
94 | Q_REVISION(3) Q_INVOKABLE void replace(int index, qreal newX, qreal newY) { DeclarativeXySeries::replace(index, newX, newY); } | |||
94 | Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } |
|
95 | Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } | |
|
96 | Q_REVISION(3) Q_INVOKABLE void remove(int index) { DeclarativeXySeries::remove(index); } | |||
95 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } |
|
97 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } | |
96 | Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } |
|
98 | Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } | |
97 | Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } |
|
99 | Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } | |
98 |
|
100 | |||
99 | Q_SIGNALS: |
|
101 | Q_SIGNALS: | |
100 | void countChanged(int count); |
|
102 | void countChanged(int count); | |
101 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
103 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
102 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
104 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
103 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); |
|
105 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); | |
104 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); |
|
106 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); | |
105 | Q_REVISION(3) void axisAngularChanged(QAbstractAxis *axis); |
|
107 | Q_REVISION(3) void axisAngularChanged(QAbstractAxis *axis); | |
106 | Q_REVISION(3) void axisRadialChanged(QAbstractAxis *axis); |
|
108 | Q_REVISION(3) void axisRadialChanged(QAbstractAxis *axis); | |
107 | Q_REVISION(1) void widthChanged(qreal width); |
|
109 | Q_REVISION(1) void widthChanged(qreal width); | |
108 | Q_REVISION(1) void styleChanged(Qt::PenStyle style); |
|
110 | Q_REVISION(1) void styleChanged(Qt::PenStyle style); | |
109 | Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); |
|
111 | Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); | |
110 |
|
112 | |||
111 | public Q_SLOTS: |
|
113 | public Q_SLOTS: | |
112 | static void appendDeclarativeChildren(QDECLARATIVE_LIST_PROPERTY<QObject> *list, QObject *element); |
|
114 | static void appendDeclarativeChildren(QDECLARATIVE_LIST_PROPERTY<QObject> *list, QObject *element); | |
113 | void handleCountChanged(int index); |
|
115 | void handleCountChanged(int index); | |
114 |
|
116 | |||
115 | public: |
|
117 | public: | |
116 | DeclarativeAxes *m_axes; |
|
118 | DeclarativeAxes *m_axes; | |
117 | }; |
|
119 | }; | |
118 |
|
120 | |||
119 | QTCOMMERCIALCHART_END_NAMESPACE |
|
121 | QTCOMMERCIALCHART_END_NAMESPACE | |
120 |
|
122 | |||
121 | #endif // DECLARATIVELINESERIES_H |
|
123 | #endif // DECLARATIVELINESERIES_H |
@@ -1,113 +1,115 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 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 "qscatterseries.h" |
|
24 | #include "qscatterseries.h" | |
25 | #include "declarativexyseries.h" |
|
25 | #include "declarativexyseries.h" | |
26 | #include "declarativeaxes.h" |
|
26 | #include "declarativeaxes.h" | |
27 | #include "shared_defines.h" |
|
27 | #include "shared_defines.h" | |
28 |
|
28 | |||
29 | #ifdef CHARTS_FOR_QUICK2 |
|
29 | #ifdef CHARTS_FOR_QUICK2 | |
30 | #include <QtQml/QQmlListProperty> |
|
30 | #include <QtQml/QQmlListProperty> | |
31 | #include <QtQml/QQmlParserStatus> |
|
31 | #include <QtQml/QQmlParserStatus> | |
32 | #else |
|
32 | #else | |
33 | #include <QtDeclarative/QDeclarativeListProperty> |
|
33 | #include <QtDeclarative/QDeclarativeListProperty> | |
34 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
34 | #include <QtDeclarative/QDeclarativeParserStatus> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries, public QDECLARATIVE_PARSER_STATUS |
|
39 | class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries, public QDECLARATIVE_PARSER_STATUS | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | #ifdef CHARTS_FOR_QUICK2 |
|
42 | #ifdef CHARTS_FOR_QUICK2 | |
43 | Q_INTERFACES(QQmlParserStatus) |
|
43 | Q_INTERFACES(QQmlParserStatus) | |
44 | #else |
|
44 | #else | |
45 | Q_INTERFACES(QDeclarativeParserStatus) |
|
45 | Q_INTERFACES(QDeclarativeParserStatus) | |
46 | #endif |
|
46 | #endif | |
47 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
47 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
48 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
48 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
49 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
49 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
50 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) |
|
50 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) | |
51 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) |
|
51 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) | |
52 | Q_PROPERTY(QAbstractAxis *axisAngular READ axisAngular WRITE setAxisAngular NOTIFY axisAngularChanged REVISION 3) |
|
52 | Q_PROPERTY(QAbstractAxis *axisAngular READ axisAngular WRITE setAxisAngular NOTIFY axisAngularChanged REVISION 3) | |
53 | Q_PROPERTY(QAbstractAxis *axisRadial READ axisRadial WRITE setAxisRadial NOTIFY axisRadialChanged REVISION 3) |
|
53 | Q_PROPERTY(QAbstractAxis *axisRadial READ axisRadial WRITE setAxisRadial NOTIFY axisRadialChanged REVISION 3) | |
54 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) |
|
54 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) | |
55 | #ifdef CHARTS_FOR_QUICK2 |
|
55 | #ifdef CHARTS_FOR_QUICK2 | |
56 | Q_PROPERTY(QQmlListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
56 | Q_PROPERTY(QQmlListProperty<QObject> declarativeChildren READ declarativeChildren) | |
57 | #else |
|
57 | #else | |
58 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
58 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
59 | #endif |
|
59 | #endif | |
60 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
60 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
61 |
|
61 | |||
62 | public: |
|
62 | public: | |
63 | explicit DeclarativeScatterSeries(QObject *parent = 0); |
|
63 | explicit DeclarativeScatterSeries(QObject *parent = 0); | |
64 | QXYSeries *xySeries() { return this; } |
|
64 | QXYSeries *xySeries() { return this; } | |
65 | QAbstractAxis *axisX() { return m_axes->axisX(); } |
|
65 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
66 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } |
|
66 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
67 | QAbstractAxis *axisY() { return m_axes->axisY(); } |
|
67 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
68 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } |
|
68 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
69 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } |
|
69 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } | |
70 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } |
|
70 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } | |
71 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } |
|
71 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } | |
72 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } |
|
72 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } | |
73 | Q_REVISION(3) QAbstractAxis *axisAngular() { return m_axes->axisX(); } |
|
73 | Q_REVISION(3) QAbstractAxis *axisAngular() { return m_axes->axisX(); } | |
74 | Q_REVISION(3) void setAxisAngular(QAbstractAxis *axis) { m_axes->setAxisX(axis); } |
|
74 | Q_REVISION(3) void setAxisAngular(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
75 | Q_REVISION(3) QAbstractAxis *axisRadial() { return m_axes->axisY(); } |
|
75 | Q_REVISION(3) QAbstractAxis *axisRadial() { return m_axes->axisY(); } | |
76 | Q_REVISION(3) void setAxisRadial(QAbstractAxis *axis) { m_axes->setAxisY(axis); } |
|
76 | Q_REVISION(3) void setAxisRadial(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
77 | qreal borderWidth() const; |
|
77 | qreal borderWidth() const; | |
78 | void setBorderWidth(qreal borderWidth); |
|
78 | void setBorderWidth(qreal borderWidth); | |
79 | QDECLARATIVE_LIST_PROPERTY<QObject> declarativeChildren(); |
|
79 | QDECLARATIVE_LIST_PROPERTY<QObject> declarativeChildren(); | |
80 |
|
80 | |||
81 | public: // from QDeclarativeParserStatus |
|
81 | public: // from QDeclarativeParserStatus | |
82 | void classBegin() { DeclarativeXySeries::classBegin(); } |
|
82 | void classBegin() { DeclarativeXySeries::classBegin(); } | |
83 | void componentComplete() { DeclarativeXySeries::componentComplete(); } |
|
83 | void componentComplete() { DeclarativeXySeries::componentComplete(); } | |
84 |
|
84 | |||
85 | public: |
|
85 | public: | |
86 | Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } |
|
86 | Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } | |
87 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } |
|
87 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } | |
|
88 | Q_REVISION(3) Q_INVOKABLE void replace(int index, qreal newX, qreal newY) { DeclarativeXySeries::replace(index, newX, newY); } | |||
88 | Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } |
|
89 | Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } | |
|
90 | Q_REVISION(3) Q_INVOKABLE void remove(int index) { DeclarativeXySeries::remove(index); } | |||
89 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } |
|
91 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } | |
90 | Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } |
|
92 | Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } | |
91 | Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } |
|
93 | Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } | |
92 |
|
94 | |||
93 | Q_SIGNALS: |
|
95 | Q_SIGNALS: | |
94 | void countChanged(int count); |
|
96 | void countChanged(int count); | |
95 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
97 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
96 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
98 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
97 | Q_REVISION(1) void borderWidthChanged(qreal width); |
|
99 | Q_REVISION(1) void borderWidthChanged(qreal width); | |
98 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); |
|
100 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); | |
99 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); |
|
101 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); | |
100 | Q_REVISION(3) void axisAngularChanged(QAbstractAxis *axis); |
|
102 | Q_REVISION(3) void axisAngularChanged(QAbstractAxis *axis); | |
101 | Q_REVISION(3) void axisRadialChanged(QAbstractAxis *axis); |
|
103 | Q_REVISION(3) void axisRadialChanged(QAbstractAxis *axis); | |
102 |
|
104 | |||
103 | public Q_SLOTS: |
|
105 | public Q_SLOTS: | |
104 | static void appendDeclarativeChildren(QDECLARATIVE_LIST_PROPERTY<QObject> *list, QObject *element); |
|
106 | static void appendDeclarativeChildren(QDECLARATIVE_LIST_PROPERTY<QObject> *list, QObject *element); | |
105 | void handleCountChanged(int index); |
|
107 | void handleCountChanged(int index); | |
106 |
|
108 | |||
107 | public: |
|
109 | public: | |
108 | DeclarativeAxes *m_axes; |
|
110 | DeclarativeAxes *m_axes; | |
109 | }; |
|
111 | }; | |
110 |
|
112 | |||
111 | QTCOMMERCIALCHART_END_NAMESPACE |
|
113 | QTCOMMERCIALCHART_END_NAMESPACE | |
112 |
|
114 | |||
113 | #endif // DECLARATIVESCATTERSERIES_H |
|
115 | #endif // DECLARATIVESCATTERSERIES_H |
@@ -1,121 +1,123 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 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 "qsplineseries.h" |
|
24 | #include "qsplineseries.h" | |
25 | #include "declarativexyseries.h" |
|
25 | #include "declarativexyseries.h" | |
26 | #include "declarativeaxes.h" |
|
26 | #include "declarativeaxes.h" | |
27 | #include "shared_defines.h" |
|
27 | #include "shared_defines.h" | |
28 |
|
28 | |||
29 | #ifdef CHARTS_FOR_QUICK2 |
|
29 | #ifdef CHARTS_FOR_QUICK2 | |
30 | #include <QtQml/QQmlListProperty> |
|
30 | #include <QtQml/QQmlListProperty> | |
31 | #include <QtQml/QQmlParserStatus> |
|
31 | #include <QtQml/QQmlParserStatus> | |
32 | #else |
|
32 | #else | |
33 | #include <QtDeclarative/QDeclarativeListProperty> |
|
33 | #include <QtDeclarative/QDeclarativeListProperty> | |
34 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
34 | #include <QtDeclarative/QDeclarativeParserStatus> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries, public QDECLARATIVE_PARSER_STATUS |
|
39 | class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries, public QDECLARATIVE_PARSER_STATUS | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | #ifdef CHARTS_FOR_QUICK2 |
|
42 | #ifdef CHARTS_FOR_QUICK2 | |
43 | Q_INTERFACES(QQmlParserStatus) |
|
43 | Q_INTERFACES(QQmlParserStatus) | |
44 | #else |
|
44 | #else | |
45 | Q_INTERFACES(QDeclarativeParserStatus) |
|
45 | Q_INTERFACES(QDeclarativeParserStatus) | |
46 | #endif |
|
46 | #endif | |
47 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
47 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
48 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
48 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
49 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
49 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
50 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) |
|
50 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) | |
51 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) |
|
51 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) | |
52 | Q_PROPERTY(QAbstractAxis *axisAngular READ axisAngular WRITE setAxisAngular NOTIFY axisAngularChanged REVISION 3) |
|
52 | Q_PROPERTY(QAbstractAxis *axisAngular READ axisAngular WRITE setAxisAngular NOTIFY axisAngularChanged REVISION 3) | |
53 | Q_PROPERTY(QAbstractAxis *axisRadial READ axisRadial WRITE setAxisRadial NOTIFY axisRadialChanged REVISION 3) |
|
53 | Q_PROPERTY(QAbstractAxis *axisRadial READ axisRadial WRITE setAxisRadial NOTIFY axisRadialChanged REVISION 3) | |
54 | Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) |
|
54 | Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) | |
55 | Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) |
|
55 | Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) | |
56 | Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1) |
|
56 | Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1) | |
57 | #ifdef CHARTS_FOR_QUICK2 |
|
57 | #ifdef CHARTS_FOR_QUICK2 | |
58 | Q_PROPERTY(QQmlListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
58 | Q_PROPERTY(QQmlListProperty<QObject> declarativeChildren READ declarativeChildren) | |
59 | #else |
|
59 | #else | |
60 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
60 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
61 | #endif |
|
61 | #endif | |
62 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
62 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
63 |
|
63 | |||
64 | public: |
|
64 | public: | |
65 | explicit DeclarativeSplineSeries(QObject *parent = 0); |
|
65 | explicit DeclarativeSplineSeries(QObject *parent = 0); | |
66 | QXYSeries *xySeries() { return this; } |
|
66 | QXYSeries *xySeries() { return this; } | |
67 | QAbstractAxis *axisX() { return m_axes->axisX(); } |
|
67 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
68 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } |
|
68 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
69 | QAbstractAxis *axisY() { return m_axes->axisY(); } |
|
69 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
70 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } |
|
70 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
71 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } |
|
71 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } | |
72 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } |
|
72 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } | |
73 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } |
|
73 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } | |
74 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } |
|
74 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } | |
75 | Q_REVISION(3) QAbstractAxis *axisAngular() { return m_axes->axisX(); } |
|
75 | Q_REVISION(3) QAbstractAxis *axisAngular() { return m_axes->axisX(); } | |
76 | Q_REVISION(3) void setAxisAngular(QAbstractAxis *axis) { m_axes->setAxisX(axis); } |
|
76 | Q_REVISION(3) void setAxisAngular(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
77 | Q_REVISION(3) QAbstractAxis *axisRadial() { return m_axes->axisY(); } |
|
77 | Q_REVISION(3) QAbstractAxis *axisRadial() { return m_axes->axisY(); } | |
78 | Q_REVISION(3) void setAxisRadial(QAbstractAxis *axis) { m_axes->setAxisY(axis); } |
|
78 | Q_REVISION(3) void setAxisRadial(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
79 | qreal width() const; |
|
79 | qreal width() const; | |
80 | void setWidth(qreal width); |
|
80 | void setWidth(qreal width); | |
81 | Qt::PenStyle style() const; |
|
81 | Qt::PenStyle style() const; | |
82 | void setStyle(Qt::PenStyle style); |
|
82 | void setStyle(Qt::PenStyle style); | |
83 | Qt::PenCapStyle capStyle() const; |
|
83 | Qt::PenCapStyle capStyle() const; | |
84 | void setCapStyle(Qt::PenCapStyle capStyle); |
|
84 | void setCapStyle(Qt::PenCapStyle capStyle); | |
85 | QDECLARATIVE_LIST_PROPERTY<QObject> declarativeChildren(); |
|
85 | QDECLARATIVE_LIST_PROPERTY<QObject> declarativeChildren(); | |
86 |
|
86 | |||
87 | public: // from QDeclarativeParserStatus |
|
87 | public: // from QDeclarativeParserStatus | |
88 | void classBegin() { DeclarativeXySeries::classBegin(); } |
|
88 | void classBegin() { DeclarativeXySeries::classBegin(); } | |
89 | void componentComplete() { DeclarativeXySeries::componentComplete(); } |
|
89 | void componentComplete() { DeclarativeXySeries::componentComplete(); } | |
90 |
|
90 | |||
91 | public: |
|
91 | public: | |
92 | Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } |
|
92 | Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } | |
93 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } |
|
93 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } | |
|
94 | Q_REVISION(3) Q_INVOKABLE void replace(int index, qreal newX, qreal newY) { DeclarativeXySeries::replace(index, newX, newY); } | |||
94 | Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } |
|
95 | Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } | |
|
96 | Q_REVISION(3) Q_INVOKABLE void remove(int index) { DeclarativeXySeries::remove(index); } | |||
95 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } |
|
97 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } | |
96 | Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } |
|
98 | Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } | |
97 | Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } |
|
99 | Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } | |
98 |
|
100 | |||
99 | Q_SIGNALS: |
|
101 | Q_SIGNALS: | |
100 | void countChanged(int count); |
|
102 | void countChanged(int count); | |
101 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
103 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
102 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
104 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
103 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); |
|
105 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); | |
104 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); |
|
106 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); | |
105 | Q_REVISION(3) void axisAngularChanged(QAbstractAxis *axis); |
|
107 | Q_REVISION(3) void axisAngularChanged(QAbstractAxis *axis); | |
106 | Q_REVISION(3) void axisRadialChanged(QAbstractAxis *axis); |
|
108 | Q_REVISION(3) void axisRadialChanged(QAbstractAxis *axis); | |
107 | Q_REVISION(1) void widthChanged(qreal width); |
|
109 | Q_REVISION(1) void widthChanged(qreal width); | |
108 | Q_REVISION(1) void styleChanged(Qt::PenStyle style); |
|
110 | Q_REVISION(1) void styleChanged(Qt::PenStyle style); | |
109 | Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); |
|
111 | Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); | |
110 |
|
112 | |||
111 | public Q_SLOTS: |
|
113 | public Q_SLOTS: | |
112 | static void appendDeclarativeChildren(QDECLARATIVE_LIST_PROPERTY<QObject> *list, QObject *element); |
|
114 | static void appendDeclarativeChildren(QDECLARATIVE_LIST_PROPERTY<QObject> *list, QObject *element); | |
113 | void handleCountChanged(int index); |
|
115 | void handleCountChanged(int index); | |
114 |
|
116 | |||
115 | public: |
|
117 | public: | |
116 | DeclarativeAxes *m_axes; |
|
118 | DeclarativeAxes *m_axes; | |
117 | }; |
|
119 | }; | |
118 |
|
120 | |||
119 | QTCOMMERCIALCHART_END_NAMESPACE |
|
121 | QTCOMMERCIALCHART_END_NAMESPACE | |
120 |
|
122 | |||
121 | #endif // DECLARATIVESPLINESERIES_H |
|
123 | #endif // DECLARATIVESPLINESERIES_H |
@@ -1,104 +1,118 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 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 |
|
21 | |||
22 | #include "declarativexyseries.h" |
|
22 | #include "declarativexyseries.h" | |
23 | #include "declarativexypoint.h" |
|
23 | #include "declarativexypoint.h" | |
24 | #include "qvxymodelmapper.h" |
|
24 | #include "qvxymodelmapper.h" | |
25 | #include "qhxymodelmapper.h" |
|
25 | #include "qhxymodelmapper.h" | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | DeclarativeXySeries::DeclarativeXySeries() |
|
29 | DeclarativeXySeries::DeclarativeXySeries() | |
30 | { |
|
30 | { | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | DeclarativeXySeries::~DeclarativeXySeries() |
|
33 | DeclarativeXySeries::~DeclarativeXySeries() | |
34 | { |
|
34 | { | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | void DeclarativeXySeries::classBegin() |
|
37 | void DeclarativeXySeries::classBegin() | |
38 | { |
|
38 | { | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | void DeclarativeXySeries::componentComplete() |
|
41 | void DeclarativeXySeries::componentComplete() | |
42 | { |
|
42 | { | |
43 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
43 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
44 | Q_ASSERT(series); |
|
44 | Q_ASSERT(series); | |
45 |
|
45 | |||
46 | foreach (QObject *child, series->children()) { |
|
46 | foreach (QObject *child, series->children()) { | |
47 | if (qobject_cast<DeclarativeXYPoint *>(child)) { |
|
47 | if (qobject_cast<DeclarativeXYPoint *>(child)) { | |
48 | DeclarativeXYPoint *point = qobject_cast<DeclarativeXYPoint *>(child); |
|
48 | DeclarativeXYPoint *point = qobject_cast<DeclarativeXYPoint *>(child); | |
49 | series->append(point->x(), point->y()); |
|
49 | series->append(point->x(), point->y()); | |
50 | } else if (qobject_cast<QVXYModelMapper *>(child)) { |
|
50 | } else if (qobject_cast<QVXYModelMapper *>(child)) { | |
51 | QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child); |
|
51 | QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child); | |
52 | mapper->setSeries(series); |
|
52 | mapper->setSeries(series); | |
53 | } else if (qobject_cast<QHXYModelMapper *>(child)) { |
|
53 | } else if (qobject_cast<QHXYModelMapper *>(child)) { | |
54 | QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child); |
|
54 | QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child); | |
55 | mapper->setSeries(series); |
|
55 | mapper->setSeries(series); | |
56 | } |
|
56 | } | |
57 | } |
|
57 | } | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | void DeclarativeXySeries::append(qreal x, qreal y) |
|
60 | void DeclarativeXySeries::append(qreal x, qreal y) | |
61 | { |
|
61 | { | |
62 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
62 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
63 | Q_ASSERT(series); |
|
63 | Q_ASSERT(series); | |
64 | series->append(x, y); |
|
64 | series->append(x, y); | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | void DeclarativeXySeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY) |
|
67 | void DeclarativeXySeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY) | |
68 | { |
|
68 | { | |
69 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
69 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
70 | Q_ASSERT(series); |
|
70 | Q_ASSERT(series); | |
71 | series->replace(oldX, oldY, newX, newY); |
|
71 | series->replace(oldX, oldY, newX, newY); | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
|
74 | void DeclarativeXySeries::replace(int index, qreal newX, qreal newY) | |||
|
75 | { | |||
|
76 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |||
|
77 | Q_ASSERT(series); | |||
|
78 | series->replace(index, newX, newY); | |||
|
79 | } | |||
|
80 | ||||
74 | void DeclarativeXySeries::remove(qreal x, qreal y) |
|
81 | void DeclarativeXySeries::remove(qreal x, qreal y) | |
75 | { |
|
82 | { | |
76 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
83 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
77 | Q_ASSERT(series); |
|
84 | Q_ASSERT(series); | |
78 | series->remove(x, y); |
|
85 | series->remove(x, y); | |
79 | } |
|
86 | } | |
80 |
|
87 | |||
|
88 | void DeclarativeXySeries::remove(int index) | |||
|
89 | { | |||
|
90 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |||
|
91 | Q_ASSERT(series); | |||
|
92 | series->remove(index); | |||
|
93 | } | |||
|
94 | ||||
81 | void DeclarativeXySeries::insert(int index, qreal x, qreal y) |
|
95 | void DeclarativeXySeries::insert(int index, qreal x, qreal y) | |
82 | { |
|
96 | { | |
83 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
97 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
84 | Q_ASSERT(series); |
|
98 | Q_ASSERT(series); | |
85 | series->insert(index, QPointF(x, y)); |
|
99 | series->insert(index, QPointF(x, y)); | |
86 | } |
|
100 | } | |
87 |
|
101 | |||
88 | void DeclarativeXySeries::clear() |
|
102 | void DeclarativeXySeries::clear() | |
89 | { |
|
103 | { | |
90 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
104 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
91 | Q_ASSERT(series); |
|
105 | Q_ASSERT(series); | |
92 | series->clear(); |
|
106 | series->clear(); | |
93 | } |
|
107 | } | |
94 |
|
108 | |||
95 | QPointF DeclarativeXySeries::at(int index) |
|
109 | QPointF DeclarativeXySeries::at(int index) | |
96 | { |
|
110 | { | |
97 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
111 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
98 | Q_ASSERT(series); |
|
112 | Q_ASSERT(series); | |
99 | if (index >= 0 || index < series->count()) |
|
113 | if (index >= 0 || index < series->count()) | |
100 | return series->points().at(index); |
|
114 | return series->points().at(index); | |
101 | return QPointF(0, 0); |
|
115 | return QPointF(0, 0); | |
102 | } |
|
116 | } | |
103 |
|
117 | |||
104 | QTCOMMERCIALCHART_END_NAMESPACE |
|
118 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,52 +1,54 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 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 <QXYSeries> |
|
24 | #include <QXYSeries> | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | class QChart; |
|
28 | class QChart; | |
29 | class QAbstractSeries; |
|
29 | class QAbstractSeries; | |
30 |
|
30 | |||
31 | class DeclarativeXySeries |
|
31 | class DeclarativeXySeries | |
32 | { |
|
32 | { | |
33 | public: |
|
33 | public: | |
34 | explicit DeclarativeXySeries(); |
|
34 | explicit DeclarativeXySeries(); | |
35 | ~DeclarativeXySeries(); |
|
35 | ~DeclarativeXySeries(); | |
36 |
|
36 | |||
37 | public: |
|
37 | public: | |
38 | void classBegin(); |
|
38 | void classBegin(); | |
39 | void componentComplete(); |
|
39 | void componentComplete(); | |
40 | virtual QXYSeries *xySeries() = 0; |
|
40 | virtual QXYSeries *xySeries() = 0; | |
41 |
|
41 | |||
42 | void append(qreal x, qreal y); |
|
42 | void append(qreal x, qreal y); | |
43 | void replace(qreal oldX, qreal oldY, qreal newX, qreal newY); |
|
43 | void replace(qreal oldX, qreal oldY, qreal newX, qreal newY); | |
|
44 | void replace(int index, qreal newX, qreal newY); | |||
44 | void remove(qreal x, qreal y); |
|
45 | void remove(qreal x, qreal y); | |
|
46 | void remove(int index); | |||
45 | void insert(int index, qreal x, qreal y); |
|
47 | void insert(int index, qreal x, qreal y); | |
46 | void clear(); |
|
48 | void clear(); | |
47 | QPointF at(int index); |
|
49 | QPointF at(int index); | |
48 | }; |
|
50 | }; | |
49 |
|
51 | |||
50 | QTCOMMERCIALCHART_END_NAMESPACE |
|
52 | QTCOMMERCIALCHART_END_NAMESPACE | |
51 |
|
53 | |||
52 | #endif // DECLARATIVE_XY_SERIES_H |
|
54 | #endif // DECLARATIVE_XY_SERIES_H |
@@ -1,559 +1,576 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 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 "qxyseries.h" |
|
21 | #include "qxyseries.h" | |
22 | #include "qxyseries_p.h" |
|
22 | #include "qxyseries_p.h" | |
23 | #include "abstractdomain_p.h" |
|
23 | #include "abstractdomain_p.h" | |
24 | #include "qvalueaxis.h" |
|
24 | #include "qvalueaxis.h" | |
25 | #include "xychart_p.h" |
|
25 | #include "xychart_p.h" | |
26 | #include "qxylegendmarker.h" |
|
26 | #include "qxylegendmarker.h" | |
27 | #include "charthelpers_p.h" |
|
27 | #include "charthelpers_p.h" | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | /*! |
|
31 | /*! | |
32 | \class QXYSeries |
|
32 | \class QXYSeries | |
33 | \brief The QXYSeries class is a base class for line, spline and scatter series. |
|
33 | \brief The QXYSeries class is a base class for line, spline and scatter series. | |
34 | */ |
|
34 | */ | |
35 | /*! |
|
35 | /*! | |
36 | \qmlclass XYSeries |
|
36 | \qmlclass XYSeries | |
37 | \inherits AbstractSeries |
|
37 | \inherits AbstractSeries | |
38 | The XYSeries class is a base class for line, spline and scatter series. |
|
38 | The XYSeries class is a base class for line, spline and scatter series. | |
39 |
|
39 | |||
40 | The class cannot be instantiated directly. |
|
40 | The class cannot be instantiated directly. | |
41 | */ |
|
41 | */ | |
42 |
|
42 | |||
43 | /*! |
|
43 | /*! | |
44 | \qmlproperty AbstractAxis XYSeries::axisX |
|
44 | \qmlproperty AbstractAxis XYSeries::axisX | |
45 | The x axis used for the series. If you leave both axisX and axisXTop undefined, a ValueAxis is created for |
|
45 | The x axis used for the series. If you leave both axisX and axisXTop undefined, a ValueAxis is created for | |
46 | the series. |
|
46 | the series. | |
47 | \sa axisXTop |
|
47 | \sa axisXTop | |
48 | */ |
|
48 | */ | |
49 |
|
49 | |||
50 | /*! |
|
50 | /*! | |
51 | \qmlproperty AbstractAxis XYSeries::axisY |
|
51 | \qmlproperty AbstractAxis XYSeries::axisY | |
52 | The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for |
|
52 | The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for | |
53 | the series. |
|
53 | the series. | |
54 | \sa axisYRight |
|
54 | \sa axisYRight | |
55 | */ |
|
55 | */ | |
56 |
|
56 | |||
57 | /*! |
|
57 | /*! | |
58 | \qmlproperty AbstractAxis XYSeries::axisXTop |
|
58 | \qmlproperty AbstractAxis XYSeries::axisXTop | |
59 | The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or |
|
59 | The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or | |
60 | axisXTop, but not both. |
|
60 | axisXTop, but not both. | |
61 | \sa axisX |
|
61 | \sa axisX | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | /*! |
|
64 | /*! | |
65 | \qmlproperty AbstractAxis XYSeries::axisYRight |
|
65 | \qmlproperty AbstractAxis XYSeries::axisYRight | |
66 | The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY |
|
66 | The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY | |
67 | or axisYRight, but not both. |
|
67 | or axisYRight, but not both. | |
68 | \sa axisY |
|
68 | \sa axisY | |
69 | */ |
|
69 | */ | |
70 |
|
70 | |||
71 | /*! |
|
71 | /*! | |
72 | \qmlproperty AbstractAxis XYSeries::axisAngular |
|
72 | \qmlproperty AbstractAxis XYSeries::axisAngular | |
73 | The angular axis used for the series, drawn around the polar chart view. |
|
73 | The angular axis used for the series, drawn around the polar chart view. | |
74 | \sa axisX |
|
74 | \sa axisX | |
75 | */ |
|
75 | */ | |
76 |
|
76 | |||
77 | /*! |
|
77 | /*! | |
78 | \qmlproperty AbstractAxis XYSeries::axisRadial |
|
78 | \qmlproperty AbstractAxis XYSeries::axisRadial | |
79 | The radial axis used for the series, drawn inside the polar chart view. |
|
79 | The radial axis used for the series, drawn inside the polar chart view. | |
80 | \sa axisY |
|
80 | \sa axisY | |
81 | */ |
|
81 | */ | |
82 |
|
82 | |||
83 | /*! |
|
83 | /*! | |
84 | \property QXYSeries::pointsVisible |
|
84 | \property QXYSeries::pointsVisible | |
85 | Controls if the data points are visible and should be drawn. |
|
85 | Controls if the data points are visible and should be drawn. | |
86 | */ |
|
86 | */ | |
87 | /*! |
|
87 | /*! | |
88 | \qmlproperty bool XYSeries::pointsVisible |
|
88 | \qmlproperty bool XYSeries::pointsVisible | |
89 | Controls if the data points are visible and should be drawn. |
|
89 | Controls if the data points are visible and should be drawn. | |
90 | */ |
|
90 | */ | |
91 |
|
91 | |||
92 | /*! |
|
92 | /*! | |
93 | \fn QPen QXYSeries::pen() const |
|
93 | \fn QPen QXYSeries::pen() const | |
94 | \brief Returns pen used to draw points for series. |
|
94 | \brief Returns pen used to draw points for series. | |
95 | \sa setPen() |
|
95 | \sa setPen() | |
96 | */ |
|
96 | */ | |
97 |
|
97 | |||
98 | /*! |
|
98 | /*! | |
99 | \fn QBrush QXYSeries::brush() const |
|
99 | \fn QBrush QXYSeries::brush() const | |
100 | \brief Returns brush used to draw points for series. |
|
100 | \brief Returns brush used to draw points for series. | |
101 | \sa setBrush() |
|
101 | \sa setBrush() | |
102 | */ |
|
102 | */ | |
103 |
|
103 | |||
104 | /*! |
|
104 | /*! | |
105 | \property QXYSeries::color |
|
105 | \property QXYSeries::color | |
106 | The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and |
|
106 | The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and | |
107 | fill (brush) color in case of QScatterSeries or QAreaSeries. |
|
107 | fill (brush) color in case of QScatterSeries or QAreaSeries. | |
108 | \sa QXYSeries::pen(), QXYSeries::brush() |
|
108 | \sa QXYSeries::pen(), QXYSeries::brush() | |
109 | */ |
|
109 | */ | |
110 | /*! |
|
110 | /*! | |
111 | \qmlproperty color XYSeries::color |
|
111 | \qmlproperty color XYSeries::color | |
112 | The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and |
|
112 | The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and | |
113 | fill (brush) color in case of ScatterSeries or AreaSeries. |
|
113 | fill (brush) color in case of ScatterSeries or AreaSeries. | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | /*! |
|
116 | /*! | |
117 | \fn void QXYSeries::clicked(const QPointF& point) |
|
117 | \fn void QXYSeries::clicked(const QPointF& point) | |
118 | \brief Signal is emitted when user clicks the \a point on chart. |
|
118 | \brief Signal is emitted when user clicks the \a point on chart. | |
119 | */ |
|
119 | */ | |
120 | /*! |
|
120 | /*! | |
121 | \qmlsignal XYSeries::onClicked(QPointF point) |
|
121 | \qmlsignal XYSeries::onClicked(QPointF point) | |
122 | Signal is emitted when user clicks the \a point on chart. For example: |
|
122 | Signal is emitted when user clicks the \a point on chart. For example: | |
123 | \code |
|
123 | \code | |
124 | LineSeries { |
|
124 | LineSeries { | |
125 | XYPoint { x: 0; y: 0 } |
|
125 | XYPoint { x: 0; y: 0 } | |
126 | XYPoint { x: 1.1; y: 2.1 } |
|
126 | XYPoint { x: 1.1; y: 2.1 } | |
127 | onClicked: console.log("onClicked: " + point.x + ", " + point.y); |
|
127 | onClicked: console.log("onClicked: " + point.x + ", " + point.y); | |
128 | } |
|
128 | } | |
129 | \endcode |
|
129 | \endcode | |
130 | */ |
|
130 | */ | |
131 |
|
131 | |||
132 | /*! |
|
132 | /*! | |
133 | \fn void QXYSeries::hovered(const QPointF &point, bool state) |
|
133 | \fn void QXYSeries::hovered(const QPointF &point, bool state) | |
134 | This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) |
|
134 | This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) | |
135 | of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from |
|
135 | of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from | |
136 | the series. |
|
136 | the series. | |
137 | */ |
|
137 | */ | |
138 | /*! |
|
138 | /*! | |
139 | \qmlsignal XYSeries::onHovered(point point, bool state) |
|
139 | \qmlsignal XYSeries::onHovered(point point, bool state) | |
140 | This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) |
|
140 | This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) | |
141 | of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from |
|
141 | of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from | |
142 | the series. |
|
142 | the series. | |
143 | */ |
|
143 | */ | |
144 |
|
144 | |||
145 | /*! |
|
145 | /*! | |
146 | \fn void QXYSeries::pointReplaced(int index) |
|
146 | \fn void QXYSeries::pointReplaced(int index) | |
147 | Signal is emitted when a point has been replaced at \a index. |
|
147 | Signal is emitted when a point has been replaced at \a index. | |
148 | \sa replace() |
|
148 | \sa replace() | |
149 | */ |
|
149 | */ | |
150 | /*! |
|
150 | /*! | |
151 | \qmlsignal XYSeries::onPointReplaced(int index) |
|
151 | \qmlsignal XYSeries::onPointReplaced(int index) | |
152 | Signal is emitted when a point has been replaced at \a index. |
|
152 | Signal is emitted when a point has been replaced at \a index. | |
153 | */ |
|
153 | */ | |
154 |
|
154 | |||
155 | /*! |
|
155 | /*! | |
156 | \fn void QXYSeries::pointsReplaced() |
|
156 | \fn void QXYSeries::pointsReplaced() | |
157 | Signal is emitted when all points have been replaced with other points. |
|
157 | Signal is emitted when all points have been replaced with other points. | |
158 | \sa replace() |
|
158 | \sa replace() | |
159 | */ |
|
159 | */ | |
160 | /*! |
|
160 | /*! | |
161 | \qmlsignal XYSeries::onPointsReplaced() |
|
161 | \qmlsignal XYSeries::onPointsReplaced() | |
162 | */ |
|
162 | */ | |
163 |
|
163 | |||
164 | /*! |
|
164 | /*! | |
165 | \fn void QXYSeries::pointAdded(int index) |
|
165 | \fn void QXYSeries::pointAdded(int index) | |
166 | Signal is emitted when a point has been added at \a index. |
|
166 | Signal is emitted when a point has been added at \a index. | |
167 | \sa append(), insert() |
|
167 | \sa append(), insert() | |
168 | */ |
|
168 | */ | |
169 | /*! |
|
169 | /*! | |
170 | \qmlsignal XYSeries::onPointAdded(int index) |
|
170 | \qmlsignal XYSeries::onPointAdded(int index) | |
171 | Signal is emitted when a point has been added at \a index. |
|
171 | Signal is emitted when a point has been added at \a index. | |
172 | */ |
|
172 | */ | |
173 |
|
173 | |||
174 | /*! |
|
174 | /*! | |
175 | \fn void QXYSeries::pointRemoved(int index) |
|
175 | \fn void QXYSeries::pointRemoved(int index) | |
176 | Signal is emitted when a point has been removed from \a index. |
|
176 | Signal is emitted when a point has been removed from \a index. | |
177 | \sa remove() |
|
177 | \sa remove() | |
178 | */ |
|
178 | */ | |
179 | /*! |
|
179 | /*! | |
180 | \qmlsignal XYSeries::onPointRemoved(int index) |
|
180 | \qmlsignal XYSeries::onPointRemoved(int index) | |
181 | Signal is emitted when a point has been removed from \a index. |
|
181 | Signal is emitted when a point has been removed from \a index. | |
182 | */ |
|
182 | */ | |
183 |
|
183 | |||
184 | /*! |
|
184 | /*! | |
185 | \fn void QXYSeries::colorChanged(QColor color) |
|
185 | \fn void QXYSeries::colorChanged(QColor color) | |
186 | \brief Signal is emitted when the line (pen) color has changed to \a color. |
|
186 | \brief Signal is emitted when the line (pen) color has changed to \a color. | |
187 | */ |
|
187 | */ | |
188 | /*! |
|
188 | /*! | |
189 | \qmlsignal XYSeries::onColorChanged(color color) |
|
189 | \qmlsignal XYSeries::onColorChanged(color color) | |
190 | Signal is emitted when the line (pen) color has changed to \a color. |
|
190 | Signal is emitted when the line (pen) color has changed to \a color. | |
191 | */ |
|
191 | */ | |
192 |
|
192 | |||
193 | /*! |
|
193 | /*! | |
194 | \fn void QXYSeriesPrivate::updated() |
|
194 | \fn void QXYSeriesPrivate::updated() | |
195 | \brief \internal |
|
195 | \brief \internal | |
196 | */ |
|
196 | */ | |
197 |
|
197 | |||
198 | /*! |
|
198 | /*! | |
199 | \qmlmethod XYSeries::append(real x, real y) |
|
199 | \qmlmethod XYSeries::append(real x, real y) | |
200 | Append point (\a x, \a y) to the series |
|
200 | Append point (\a x, \a y) to the series | |
201 | */ |
|
201 | */ | |
202 |
|
202 | |||
203 | /*! |
|
203 | /*! | |
204 | \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY) |
|
204 | \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY) | |
205 | Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not |
|
205 | Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not | |
206 | exist. |
|
206 | exist. | |
207 | */ |
|
207 | */ | |
208 |
|
208 | |||
209 | /*! |
|
209 | /*! | |
210 | \qmlmethod XYSeries::remove(real x, real y) |
|
210 | \qmlmethod XYSeries::remove(real x, real y) | |
211 | Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist. |
|
211 | Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist. | |
212 | */ |
|
212 | */ | |
213 |
|
213 | |||
214 | /*! |
|
214 | /*! | |
215 | \qmlmethod XYSeries::insert(int index, real x, real y) |
|
215 | \qmlmethod XYSeries::insert(int index, real x, real y) | |
216 | Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of |
|
216 | Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of | |
217 | points. If index is the same as or bigger than count, the point is appended to the list of points. |
|
217 | points. If index is the same as or bigger than count, the point is appended to the list of points. | |
218 | */ |
|
218 | */ | |
219 |
|
219 | |||
220 | /*! |
|
220 | /*! | |
221 | \qmlmethod QPointF XYSeries::at(int index) |
|
221 | \qmlmethod QPointF XYSeries::at(int index) | |
222 | Returns point at \a index. Returns (0, 0) if the index is not valid. |
|
222 | Returns point at \a index. Returns (0, 0) if the index is not valid. | |
223 | */ |
|
223 | */ | |
224 |
|
224 | |||
225 | /*! |
|
225 | /*! | |
226 | \internal |
|
226 | \internal | |
227 |
|
227 | |||
228 | Constructs empty series object which is a child of \a parent. |
|
228 | Constructs empty series object which is a child of \a parent. | |
229 | When series object is added to QChart instance ownerships is transferred. |
|
229 | When series object is added to QChart instance ownerships is transferred. | |
230 | */ |
|
230 | */ | |
231 | QXYSeries::QXYSeries(QXYSeriesPrivate &d, QObject *parent) |
|
231 | QXYSeries::QXYSeries(QXYSeriesPrivate &d, QObject *parent) | |
232 | : QAbstractSeries(d, parent) |
|
232 | : QAbstractSeries(d, parent) | |
233 | { |
|
233 | { | |
234 | } |
|
234 | } | |
235 |
|
235 | |||
236 | /*! |
|
236 | /*! | |
237 | Destroys the object. Series added to QChart instances are owned by those, |
|
237 | Destroys the object. Series added to QChart instances are owned by those, | |
238 | and are destroyed when QChart instances are destroyed. |
|
238 | and are destroyed when QChart instances are destroyed. | |
239 | */ |
|
239 | */ | |
240 | QXYSeries::~QXYSeries() |
|
240 | QXYSeries::~QXYSeries() | |
241 | { |
|
241 | { | |
242 | } |
|
242 | } | |
243 |
|
243 | |||
244 | /*! |
|
244 | /*! | |
245 | Adds data point (\a x, \a y) to the series. |
|
245 | Adds data point (\a x, \a y) to the series. | |
246 | */ |
|
246 | */ | |
247 | void QXYSeries::append(qreal x, qreal y) |
|
247 | void QXYSeries::append(qreal x, qreal y) | |
248 | { |
|
248 | { | |
249 | append(QPointF(x, y)); |
|
249 | append(QPointF(x, y)); | |
250 | } |
|
250 | } | |
251 |
|
251 | |||
252 | /*! |
|
252 | /*! | |
253 | This is an overloaded function. |
|
253 | This is an overloaded function. | |
254 | Adds data \a point to the series. |
|
254 | Adds data \a point to the series. | |
255 | */ |
|
255 | */ | |
256 | void QXYSeries::append(const QPointF &point) |
|
256 | void QXYSeries::append(const QPointF &point) | |
257 | { |
|
257 | { | |
258 | Q_D(QXYSeries); |
|
258 | Q_D(QXYSeries); | |
259 |
|
259 | |||
260 | if (isValidValue(point)) { |
|
260 | if (isValidValue(point)) { | |
261 | d->m_points << point; |
|
261 | d->m_points << point; | |
262 | emit pointAdded(d->m_points.count() - 1); |
|
262 | emit pointAdded(d->m_points.count() - 1); | |
263 | } |
|
263 | } | |
264 | } |
|
264 | } | |
265 |
|
265 | |||
266 | /*! |
|
266 | /*! | |
267 | This is an overloaded function. |
|
267 | This is an overloaded function. | |
268 | Adds list of data \a points to the series. |
|
268 | Adds list of data \a points to the series. | |
269 | */ |
|
269 | */ | |
270 | void QXYSeries::append(const QList<QPointF> &points) |
|
270 | void QXYSeries::append(const QList<QPointF> &points) | |
271 | { |
|
271 | { | |
272 | foreach (const QPointF &point , points) |
|
272 | foreach (const QPointF &point , points) | |
273 | append(point); |
|
273 | append(point); | |
274 | } |
|
274 | } | |
275 |
|
275 | |||
276 | /*! |
|
276 | /*! | |
277 | Replaces data point (\a oldX, \a oldY) with data point (\a newX, \a newY). |
|
277 | Replaces data point (\a oldX, \a oldY) with data point (\a newX, \a newY). | |
278 | \sa QXYSeries::pointReplaced() |
|
278 | \sa QXYSeries::pointReplaced() | |
279 | */ |
|
279 | */ | |
280 | void QXYSeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY) |
|
280 | void QXYSeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY) | |
281 | { |
|
281 | { | |
282 | replace(QPointF(oldX, oldY), QPointF(newX, newY)); |
|
282 | replace(QPointF(oldX, oldY), QPointF(newX, newY)); | |
283 | } |
|
283 | } | |
284 |
|
284 | |||
285 | /*! |
|
285 | /*! | |
286 | Replaces \a oldPoint with \a newPoint. |
|
286 | Replaces \a oldPoint with \a newPoint. | |
287 | \sa QXYSeries::pointReplaced() |
|
287 | \sa QXYSeries::pointReplaced() | |
288 | */ |
|
288 | */ | |
289 | void QXYSeries::replace(const QPointF &oldPoint, const QPointF &newPoint) |
|
289 | void QXYSeries::replace(const QPointF &oldPoint, const QPointF &newPoint) | |
290 | { |
|
290 | { | |
291 | Q_D(QXYSeries); |
|
291 | Q_D(QXYSeries); | |
292 | int index = d->m_points.indexOf(oldPoint); |
|
292 | int index = d->m_points.indexOf(oldPoint); | |
293 | if (index == -1) |
|
293 | if (index == -1) | |
294 | return; |
|
294 | return; | |
|
295 | replace(index, newPoint); | |||
|
296 | } | |||
|
297 | ||||
|
298 | void QXYSeries::replace(int index, qreal newX, qreal newY) | |||
|
299 | { | |||
|
300 | replace(index, QPointF(newX, newY)); | |||
|
301 | } | |||
|
302 | ||||
|
303 | void QXYSeries::replace(int index, const QPointF &newPoint) | |||
|
304 | { | |||
|
305 | Q_D(QXYSeries); | |||
295 | if (isValidValue(newPoint)) { |
|
306 | if (isValidValue(newPoint)) { | |
296 | d->m_points[index] = newPoint; |
|
307 | d->m_points[index] = newPoint; | |
297 | emit pointReplaced(index); |
|
308 | emit pointReplaced(index); | |
298 | } |
|
309 | } | |
299 | } |
|
310 | } | |
300 |
|
311 | |||
301 | /*! |
|
312 | /*! | |
302 | Replaces the current points with \a points. |
|
313 | Replaces the current points with \a points. | |
303 | \note This is much faster than replacing data points one by one, |
|
314 | \note This is much faster than replacing data points one by one, | |
304 | or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced() |
|
315 | or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced() | |
305 | when the points have been replaced. |
|
316 | when the points have been replaced. | |
306 | \sa QXYSeries::pointsReplaced() |
|
317 | \sa QXYSeries::pointsReplaced() | |
307 | */ |
|
318 | */ | |
308 | void QXYSeries::replace(QList<QPointF> points) |
|
319 | void QXYSeries::replace(QList<QPointF> points) | |
309 | { |
|
320 | { | |
310 | Q_D(QXYSeries); |
|
321 | Q_D(QXYSeries); | |
311 | d->m_points = points.toVector(); |
|
322 | d->m_points = points.toVector(); | |
312 | emit pointsReplaced(); |
|
323 | emit pointsReplaced(); | |
313 | } |
|
324 | } | |
314 |
|
325 | |||
315 | /*! |
|
326 | /*! | |
316 | Removes the point (\a x, \a y) from the series. |
|
327 | Removes the point (\a x, \a y) from the series. | |
317 | */ |
|
328 | */ | |
318 | void QXYSeries::remove(qreal x, qreal y) |
|
329 | void QXYSeries::remove(qreal x, qreal y) | |
319 | { |
|
330 | { | |
320 | remove(QPointF(x, y)); |
|
331 | remove(QPointF(x, y)); | |
321 | } |
|
332 | } | |
322 |
|
333 | |||
323 | /*! |
|
334 | /*! | |
324 | Removes the \a point from the series. |
|
335 | Removes the \a point from the series. | |
325 | */ |
|
336 | */ | |
326 | void QXYSeries::remove(const QPointF &point) |
|
337 | void QXYSeries::remove(const QPointF &point) | |
327 | { |
|
338 | { | |
328 | Q_D(QXYSeries); |
|
339 | Q_D(QXYSeries); | |
329 | int index = d->m_points.indexOf(point); |
|
340 | int index = d->m_points.indexOf(point); | |
330 | if (index == -1) |
|
341 | if (index == -1) | |
331 | return; |
|
342 | return; | |
|
343 | remove(index); | |||
|
344 | } | |||
|
345 | ||||
|
346 | void QXYSeries::remove(int index) | |||
|
347 | { | |||
|
348 | Q_D(QXYSeries); | |||
332 | d->m_points.remove(index); |
|
349 | d->m_points.remove(index); | |
333 | emit pointRemoved(index); |
|
350 | emit pointRemoved(index); | |
334 | } |
|
351 | } | |
335 |
|
352 | |||
336 | /*! |
|
353 | /*! | |
337 | Inserts a \a point in the series at \a index position. |
|
354 | Inserts a \a point in the series at \a index position. | |
338 | */ |
|
355 | */ | |
339 | void QXYSeries::insert(int index, const QPointF &point) |
|
356 | void QXYSeries::insert(int index, const QPointF &point) | |
340 | { |
|
357 | { | |
341 | Q_D(QXYSeries); |
|
358 | Q_D(QXYSeries); | |
342 | if (isValidValue(point)) { |
|
359 | if (isValidValue(point)) { | |
343 | d->m_points.insert(index, point); |
|
360 | d->m_points.insert(index, point); | |
344 | emit pointAdded(index); |
|
361 | emit pointAdded(index); | |
345 | } |
|
362 | } | |
346 | } |
|
363 | } | |
347 |
|
364 | |||
348 | /*! |
|
365 | /*! | |
349 | Removes all points from the series. |
|
366 | Removes all points from the series. | |
350 | */ |
|
367 | */ | |
351 | void QXYSeries::clear() |
|
368 | void QXYSeries::clear() | |
352 | { |
|
369 | { | |
353 | Q_D(QXYSeries); |
|
370 | Q_D(QXYSeries); | |
354 | for (int i = d->m_points.size() - 1; i >= 0; i--) |
|
371 | for (int i = d->m_points.size() - 1; i >= 0; i--) | |
355 | remove(d->m_points.at(i)); |
|
372 | remove(d->m_points.at(i)); | |
356 | } |
|
373 | } | |
357 |
|
374 | |||
358 | /*! |
|
375 | /*! | |
359 | Returns list of points in the series. |
|
376 | Returns list of points in the series. | |
360 | */ |
|
377 | */ | |
361 | QList<QPointF> QXYSeries::points() const |
|
378 | QList<QPointF> QXYSeries::points() const | |
362 | { |
|
379 | { | |
363 | Q_D(const QXYSeries); |
|
380 | Q_D(const QXYSeries); | |
364 | return d->m_points.toList(); |
|
381 | return d->m_points.toList(); | |
365 | } |
|
382 | } | |
366 |
|
383 | |||
367 | /*! |
|
384 | /*! | |
368 | Returns point at \a index in internal points vector. |
|
385 | Returns point at \a index in internal points vector. | |
369 | */ |
|
386 | */ | |
370 | const QPointF &QXYSeries::at(int index) const |
|
387 | const QPointF &QXYSeries::at(int index) const | |
371 | { |
|
388 | { | |
372 | Q_D(const QXYSeries); |
|
389 | Q_D(const QXYSeries); | |
373 | return d->m_points.at(index); |
|
390 | return d->m_points.at(index); | |
374 | } |
|
391 | } | |
375 |
|
392 | |||
376 | /*! |
|
393 | /*! | |
377 | Returns number of data points within series. |
|
394 | Returns number of data points within series. | |
378 | */ |
|
395 | */ | |
379 | int QXYSeries::count() const |
|
396 | int QXYSeries::count() const | |
380 | { |
|
397 | { | |
381 | Q_D(const QXYSeries); |
|
398 | Q_D(const QXYSeries); | |
382 | return d->m_points.count(); |
|
399 | return d->m_points.count(); | |
383 | } |
|
400 | } | |
384 |
|
401 | |||
385 |
|
402 | |||
386 | /*! |
|
403 | /*! | |
387 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the |
|
404 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the | |
388 | pen from chart theme is used. |
|
405 | pen from chart theme is used. | |
389 | \sa QChart::setTheme() |
|
406 | \sa QChart::setTheme() | |
390 | */ |
|
407 | */ | |
391 | void QXYSeries::setPen(const QPen &pen) |
|
408 | void QXYSeries::setPen(const QPen &pen) | |
392 | { |
|
409 | { | |
393 | Q_D(QXYSeries); |
|
410 | Q_D(QXYSeries); | |
394 | if (d->m_pen != pen) { |
|
411 | if (d->m_pen != pen) { | |
395 | bool emitColorChanged = d->m_pen.color() != pen.color(); |
|
412 | bool emitColorChanged = d->m_pen.color() != pen.color(); | |
396 | d->m_pen = pen; |
|
413 | d->m_pen = pen; | |
397 | emit d->updated(); |
|
414 | emit d->updated(); | |
398 | if (emitColorChanged) |
|
415 | if (emitColorChanged) | |
399 | emit colorChanged(pen.color()); |
|
416 | emit colorChanged(pen.color()); | |
400 | } |
|
417 | } | |
401 | } |
|
418 | } | |
402 |
|
419 | |||
403 | QPen QXYSeries::pen() const |
|
420 | QPen QXYSeries::pen() const | |
404 | { |
|
421 | { | |
405 | Q_D(const QXYSeries); |
|
422 | Q_D(const QXYSeries); | |
406 | return d->m_pen; |
|
423 | return d->m_pen; | |
407 | } |
|
424 | } | |
408 |
|
425 | |||
409 | /*! |
|
426 | /*! | |
410 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush |
|
427 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush | |
411 | from chart theme setting is used. |
|
428 | from chart theme setting is used. | |
412 | \sa QChart::setTheme() |
|
429 | \sa QChart::setTheme() | |
413 | */ |
|
430 | */ | |
414 | void QXYSeries::setBrush(const QBrush &brush) |
|
431 | void QXYSeries::setBrush(const QBrush &brush) | |
415 | { |
|
432 | { | |
416 | Q_D(QXYSeries); |
|
433 | Q_D(QXYSeries); | |
417 | if (d->m_brush != brush) { |
|
434 | if (d->m_brush != brush) { | |
418 | d->m_brush = brush; |
|
435 | d->m_brush = brush; | |
419 | emit d->updated(); |
|
436 | emit d->updated(); | |
420 | } |
|
437 | } | |
421 | } |
|
438 | } | |
422 |
|
439 | |||
423 | QBrush QXYSeries::brush() const |
|
440 | QBrush QXYSeries::brush() const | |
424 | { |
|
441 | { | |
425 | Q_D(const QXYSeries); |
|
442 | Q_D(const QXYSeries); | |
426 | return d->m_brush; |
|
443 | return d->m_brush; | |
427 | } |
|
444 | } | |
428 |
|
445 | |||
429 | void QXYSeries::setColor(const QColor &color) |
|
446 | void QXYSeries::setColor(const QColor &color) | |
430 | { |
|
447 | { | |
431 | QPen p = pen(); |
|
448 | QPen p = pen(); | |
432 | if (p.color() != color) { |
|
449 | if (p.color() != color) { | |
433 | p.setColor(color); |
|
450 | p.setColor(color); | |
434 | setPen(p); |
|
451 | setPen(p); | |
435 | } |
|
452 | } | |
436 | } |
|
453 | } | |
437 |
|
454 | |||
438 | QColor QXYSeries::color() const |
|
455 | QColor QXYSeries::color() const | |
439 | { |
|
456 | { | |
440 | return pen().color(); |
|
457 | return pen().color(); | |
441 | } |
|
458 | } | |
442 |
|
459 | |||
443 | void QXYSeries::setPointsVisible(bool visible) |
|
460 | void QXYSeries::setPointsVisible(bool visible) | |
444 | { |
|
461 | { | |
445 | Q_D(QXYSeries); |
|
462 | Q_D(QXYSeries); | |
446 | if (d->m_pointsVisible != visible) { |
|
463 | if (d->m_pointsVisible != visible) { | |
447 | d->m_pointsVisible = visible; |
|
464 | d->m_pointsVisible = visible; | |
448 | emit d->updated(); |
|
465 | emit d->updated(); | |
449 | } |
|
466 | } | |
450 | } |
|
467 | } | |
451 |
|
468 | |||
452 | bool QXYSeries::pointsVisible() const |
|
469 | bool QXYSeries::pointsVisible() const | |
453 | { |
|
470 | { | |
454 | Q_D(const QXYSeries); |
|
471 | Q_D(const QXYSeries); | |
455 | return d->m_pointsVisible; |
|
472 | return d->m_pointsVisible; | |
456 | } |
|
473 | } | |
457 |
|
474 | |||
458 |
|
475 | |||
459 | /*! |
|
476 | /*! | |
460 | Stream operator for adding a data \a point to the series. |
|
477 | Stream operator for adding a data \a point to the series. | |
461 | \sa append() |
|
478 | \sa append() | |
462 | */ |
|
479 | */ | |
463 | QXYSeries &QXYSeries::operator<< (const QPointF &point) |
|
480 | QXYSeries &QXYSeries::operator<< (const QPointF &point) | |
464 | { |
|
481 | { | |
465 | append(point); |
|
482 | append(point); | |
466 | return *this; |
|
483 | return *this; | |
467 | } |
|
484 | } | |
468 |
|
485 | |||
469 |
|
486 | |||
470 | /*! |
|
487 | /*! | |
471 | Stream operator for adding a list of \a points to the series. |
|
488 | Stream operator for adding a list of \a points to the series. | |
472 | \sa append() |
|
489 | \sa append() | |
473 | */ |
|
490 | */ | |
474 |
|
491 | |||
475 | QXYSeries &QXYSeries::operator<< (const QList<QPointF>& points) |
|
492 | QXYSeries &QXYSeries::operator<< (const QList<QPointF>& points) | |
476 | { |
|
493 | { | |
477 | append(points); |
|
494 | append(points); | |
478 | return *this; |
|
495 | return *this; | |
479 | } |
|
496 | } | |
480 |
|
497 | |||
481 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
498 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
482 |
|
499 | |||
483 |
|
500 | |||
484 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) |
|
501 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) | |
485 | : QAbstractSeriesPrivate(q), |
|
502 | : QAbstractSeriesPrivate(q), | |
486 | m_pointsVisible(false) |
|
503 | m_pointsVisible(false) | |
487 | { |
|
504 | { | |
488 | } |
|
505 | } | |
489 |
|
506 | |||
490 | void QXYSeriesPrivate::initializeDomain() |
|
507 | void QXYSeriesPrivate::initializeDomain() | |
491 | { |
|
508 | { | |
492 | qreal minX(0); |
|
509 | qreal minX(0); | |
493 | qreal minY(0); |
|
510 | qreal minY(0); | |
494 | qreal maxX(1); |
|
511 | qreal maxX(1); | |
495 | qreal maxY(1); |
|
512 | qreal maxY(1); | |
496 |
|
513 | |||
497 | Q_Q(QXYSeries); |
|
514 | Q_Q(QXYSeries); | |
498 |
|
515 | |||
499 | const QList<QPointF>& points = q->points(); |
|
516 | const QList<QPointF>& points = q->points(); | |
500 |
|
517 | |||
501 | if (!points.isEmpty()) { |
|
518 | if (!points.isEmpty()) { | |
502 | minX = points[0].x(); |
|
519 | minX = points[0].x(); | |
503 | minY = points[0].y(); |
|
520 | minY = points[0].y(); | |
504 | maxX = minX; |
|
521 | maxX = minX; | |
505 | maxY = minY; |
|
522 | maxY = minY; | |
506 |
|
523 | |||
507 | for (int i = 0; i < points.count(); i++) { |
|
524 | for (int i = 0; i < points.count(); i++) { | |
508 | qreal x = points[i].x(); |
|
525 | qreal x = points[i].x(); | |
509 | qreal y = points[i].y(); |
|
526 | qreal y = points[i].y(); | |
510 | minX = qMin(minX, x); |
|
527 | minX = qMin(minX, x); | |
511 | minY = qMin(minY, y); |
|
528 | minY = qMin(minY, y); | |
512 | maxX = qMax(maxX, x); |
|
529 | maxX = qMax(maxX, x); | |
513 | maxY = qMax(maxY, y); |
|
530 | maxY = qMax(maxY, y); | |
514 | } |
|
531 | } | |
515 | } |
|
532 | } | |
516 |
|
533 | |||
517 | domain()->setRange(minX, maxX, minY, maxY); |
|
534 | domain()->setRange(minX, maxX, minY, maxY); | |
518 | } |
|
535 | } | |
519 |
|
536 | |||
520 | QList<QLegendMarker*> QXYSeriesPrivate::createLegendMarkers(QLegend* legend) |
|
537 | QList<QLegendMarker*> QXYSeriesPrivate::createLegendMarkers(QLegend* legend) | |
521 | { |
|
538 | { | |
522 | Q_Q(QXYSeries); |
|
539 | Q_Q(QXYSeries); | |
523 | QList<QLegendMarker*> list; |
|
540 | QList<QLegendMarker*> list; | |
524 | return list << new QXYLegendMarker(q,legend); |
|
541 | return list << new QXYLegendMarker(q,legend); | |
525 | } |
|
542 | } | |
526 |
|
543 | |||
527 | void QXYSeriesPrivate::initializeAxes() |
|
544 | void QXYSeriesPrivate::initializeAxes() | |
528 | { |
|
545 | { | |
529 |
|
546 | |||
530 | } |
|
547 | } | |
531 |
|
548 | |||
532 | QAbstractAxis::AxisType QXYSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const |
|
549 | QAbstractAxis::AxisType QXYSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const | |
533 | { |
|
550 | { | |
534 | Q_UNUSED(orientation); |
|
551 | Q_UNUSED(orientation); | |
535 | return QAbstractAxis::AxisTypeValue; |
|
552 | return QAbstractAxis::AxisTypeValue; | |
536 | } |
|
553 | } | |
537 |
|
554 | |||
538 | QAbstractAxis* QXYSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const |
|
555 | QAbstractAxis* QXYSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const | |
539 | { |
|
556 | { | |
540 | Q_UNUSED(orientation); |
|
557 | Q_UNUSED(orientation); | |
541 | return 0; |
|
558 | return 0; | |
542 | } |
|
559 | } | |
543 |
|
560 | |||
544 | void QXYSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options) |
|
561 | void QXYSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options) | |
545 | { |
|
562 | { | |
546 | XYChart *item = static_cast<XYChart *>(m_item.data()); |
|
563 | XYChart *item = static_cast<XYChart *>(m_item.data()); | |
547 | Q_ASSERT(item); |
|
564 | Q_ASSERT(item); | |
548 | if (options.testFlag(QChart::SeriesAnimations)) { |
|
565 | if (options.testFlag(QChart::SeriesAnimations)) { | |
549 | item->setAnimation(new XYAnimation(item)); |
|
566 | item->setAnimation(new XYAnimation(item)); | |
550 | }else{ |
|
567 | }else{ | |
551 | item->setAnimation(0); |
|
568 | item->setAnimation(0); | |
552 | } |
|
569 | } | |
553 | QAbstractSeriesPrivate::initializeAnimations(options); |
|
570 | QAbstractSeriesPrivate::initializeAnimations(options); | |
554 | } |
|
571 | } | |
555 |
|
572 | |||
556 | #include "moc_qxyseries.cpp" |
|
573 | #include "moc_qxyseries.cpp" | |
557 | #include "moc_qxyseries_p.cpp" |
|
574 | #include "moc_qxyseries_p.cpp" | |
558 |
|
575 | |||
559 | QTCOMMERCIALCHART_END_NAMESPACE |
|
576 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,97 +1,100 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 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 QXYSERIES_H |
|
21 | #ifndef QXYSERIES_H | |
22 | #define QXYSERIES_H |
|
22 | #define QXYSERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qabstractseries.h> |
|
25 | #include <qabstractseries.h> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 | #include <QBrush> |
|
27 | #include <QBrush> | |
28 |
|
28 | |||
29 | class QModelIndex; |
|
29 | class QModelIndex; | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | class QXYSeriesPrivate; |
|
33 | class QXYSeriesPrivate; | |
34 | class QXYModelMapper; |
|
34 | class QXYModelMapper; | |
35 |
|
35 | |||
36 | class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries |
|
36 | class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries | |
37 | { |
|
37 | { | |
38 | Q_OBJECT |
|
38 | Q_OBJECT | |
39 | Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible) |
|
39 | Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible) | |
40 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
|
40 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |
41 |
|
41 | |||
42 | protected: |
|
42 | protected: | |
43 | explicit QXYSeries(QXYSeriesPrivate &d, QObject *parent = 0); |
|
43 | explicit QXYSeries(QXYSeriesPrivate &d, QObject *parent = 0); | |
44 |
|
44 | |||
45 | public: |
|
45 | public: | |
46 | ~QXYSeries(); |
|
46 | ~QXYSeries(); | |
47 | void append(qreal x, qreal y); |
|
47 | void append(qreal x, qreal y); | |
48 | void append(const QPointF &point); |
|
48 | void append(const QPointF &point); | |
49 | void append(const QList<QPointF> &points); |
|
49 | void append(const QList<QPointF> &points); | |
50 | void replace(qreal oldX, qreal oldY, qreal newX, qreal newY); |
|
50 | void replace(qreal oldX, qreal oldY, qreal newX, qreal newY); | |
51 | void replace(const QPointF &oldPoint, const QPointF &newPoint); |
|
51 | void replace(const QPointF &oldPoint, const QPointF &newPoint); | |
|
52 | void replace(int index, qreal newX, qreal newY); | |||
|
53 | void replace(int index, const QPointF &newPoint); | |||
52 | void remove(qreal x, qreal y); |
|
54 | void remove(qreal x, qreal y); | |
53 | void remove(const QPointF &point); |
|
55 | void remove(const QPointF &point); | |
|
56 | void remove(int index); | |||
54 | void insert(int index, const QPointF &point); |
|
57 | void insert(int index, const QPointF &point); | |
55 | void clear(); |
|
58 | void clear(); | |
56 |
|
59 | |||
57 | int count() const; |
|
60 | int count() const; | |
58 | QList<QPointF> points() const; |
|
61 | QList<QPointF> points() const; | |
59 | const QPointF &at(int index) const; |
|
62 | const QPointF &at(int index) const; | |
60 |
|
63 | |||
61 | QXYSeries &operator << (const QPointF &point); |
|
64 | QXYSeries &operator << (const QPointF &point); | |
62 | QXYSeries &operator << (const QList<QPointF> &points); |
|
65 | QXYSeries &operator << (const QList<QPointF> &points); | |
63 |
|
66 | |||
64 | virtual void setPen(const QPen &pen); |
|
67 | virtual void setPen(const QPen &pen); | |
65 | QPen pen() const; |
|
68 | QPen pen() const; | |
66 |
|
69 | |||
67 | virtual void setBrush(const QBrush &brush); |
|
70 | virtual void setBrush(const QBrush &brush); | |
68 | QBrush brush() const; |
|
71 | QBrush brush() const; | |
69 |
|
72 | |||
70 | virtual void setColor(const QColor &color); |
|
73 | virtual void setColor(const QColor &color); | |
71 | virtual QColor color() const; |
|
74 | virtual QColor color() const; | |
72 |
|
75 | |||
73 | void setPointsVisible(bool visible = true); |
|
76 | void setPointsVisible(bool visible = true); | |
74 | bool pointsVisible() const; |
|
77 | bool pointsVisible() const; | |
75 |
|
78 | |||
76 | void replace(QList<QPointF> points); |
|
79 | void replace(QList<QPointF> points); | |
77 |
|
80 | |||
78 | Q_SIGNALS: |
|
81 | Q_SIGNALS: | |
79 | void clicked(const QPointF &point); |
|
82 | void clicked(const QPointF &point); | |
80 | void hovered(const QPointF &point, bool state); |
|
83 | void hovered(const QPointF &point, bool state); | |
81 | void pointReplaced(int index); |
|
84 | void pointReplaced(int index); | |
82 | void pointRemoved(int index); |
|
85 | void pointRemoved(int index); | |
83 | void pointAdded(int index); |
|
86 | void pointAdded(int index); | |
84 | void colorChanged(QColor color); |
|
87 | void colorChanged(QColor color); | |
85 | void pointsReplaced(); |
|
88 | void pointsReplaced(); | |
86 |
|
89 | |||
87 | private: |
|
90 | private: | |
88 | Q_DECLARE_PRIVATE(QXYSeries) |
|
91 | Q_DECLARE_PRIVATE(QXYSeries) | |
89 | Q_DISABLE_COPY(QXYSeries) |
|
92 | Q_DISABLE_COPY(QXYSeries) | |
90 | friend class QXYLegendMarkerPrivate; |
|
93 | friend class QXYLegendMarkerPrivate; | |
91 | friend class XYLegendMarker; |
|
94 | friend class XYLegendMarker; | |
92 | friend class XYChart; |
|
95 | friend class XYChart; | |
93 | }; |
|
96 | }; | |
94 |
|
97 | |||
95 | QTCOMMERCIALCHART_END_NAMESPACE |
|
98 | QTCOMMERCIALCHART_END_NAMESPACE | |
96 |
|
99 | |||
97 | #endif // QXYSERIES_H |
|
100 | #endif // QXYSERIES_H |
@@ -1,520 +1,543 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 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 "tst_qxyseries.h" |
|
21 | #include "tst_qxyseries.h" | |
22 |
|
22 | |||
23 | Q_DECLARE_METATYPE(QList<QPointF>) |
|
23 | Q_DECLARE_METATYPE(QList<QPointF>) | |
24 |
|
24 | |||
25 | void tst_QXYSeries::initTestCase() |
|
25 | void tst_QXYSeries::initTestCase() | |
26 | { |
|
26 | { | |
27 | } |
|
27 | } | |
28 |
|
28 | |||
29 | void tst_QXYSeries::cleanupTestCase() |
|
29 | void tst_QXYSeries::cleanupTestCase() | |
30 | { |
|
30 | { | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | void tst_QXYSeries::init() |
|
33 | void tst_QXYSeries::init() | |
34 | { |
|
34 | { | |
35 | m_view = new QChartView(newQChartOrQPolarChart()); |
|
35 | m_view = new QChartView(newQChartOrQPolarChart()); | |
36 | m_chart = m_view->chart(); |
|
36 | m_chart = m_view->chart(); | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | void tst_QXYSeries::cleanup() |
|
39 | void tst_QXYSeries::cleanup() | |
40 | { |
|
40 | { | |
41 | delete m_view; |
|
41 | delete m_view; | |
42 | m_view = 0; |
|
42 | m_view = 0; | |
43 | m_chart = 0; |
|
43 | m_chart = 0; | |
44 | m_series = 0; |
|
44 | m_series = 0; | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | void tst_QXYSeries::seriesName() |
|
47 | void tst_QXYSeries::seriesName() | |
48 | { |
|
48 | { | |
49 | QSignalSpy nameSpy(m_series, SIGNAL(nameChanged())); |
|
49 | QSignalSpy nameSpy(m_series, SIGNAL(nameChanged())); | |
50 | QCOMPARE(m_series->name(), QString()); |
|
50 | QCOMPARE(m_series->name(), QString()); | |
51 | m_series->setName("seriesname"); |
|
51 | m_series->setName("seriesname"); | |
52 | QCOMPARE(m_series->name(), QString("seriesname")); |
|
52 | QCOMPARE(m_series->name(), QString("seriesname")); | |
53 | TRY_COMPARE(nameSpy.count(), 1); |
|
53 | TRY_COMPARE(nameSpy.count(), 1); | |
54 | } |
|
54 | } | |
55 |
|
55 | |||
56 | void tst_QXYSeries::seriesVisible() |
|
56 | void tst_QXYSeries::seriesVisible() | |
57 | { |
|
57 | { | |
58 | QSignalSpy visibleSpy(m_series, SIGNAL(visibleChanged())); |
|
58 | QSignalSpy visibleSpy(m_series, SIGNAL(visibleChanged())); | |
59 | QCOMPARE(m_series->isVisible(), true); |
|
59 | QCOMPARE(m_series->isVisible(), true); | |
60 | m_series->setVisible(false); |
|
60 | m_series->setVisible(false); | |
61 | QCOMPARE(m_series->isVisible(), false); |
|
61 | QCOMPARE(m_series->isVisible(), false); | |
62 | m_series->setVisible(true); |
|
62 | m_series->setVisible(true); | |
63 | TRY_COMPARE(visibleSpy.count(), 2); |
|
63 | TRY_COMPARE(visibleSpy.count(), 2); | |
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 | void tst_QXYSeries::seriesOpacity() |
|
66 | void tst_QXYSeries::seriesOpacity() | |
67 | { |
|
67 | { | |
68 | QSignalSpy opacitySpy(m_series, SIGNAL(opacityChanged())); |
|
68 | QSignalSpy opacitySpy(m_series, SIGNAL(opacityChanged())); | |
69 | QCOMPARE(m_series->opacity(), 1.0); |
|
69 | QCOMPARE(m_series->opacity(), 1.0); | |
70 |
|
70 | |||
71 | m_series->setOpacity(0.5); |
|
71 | m_series->setOpacity(0.5); | |
72 | QCOMPARE(m_series->opacity(), 0.5); |
|
72 | QCOMPARE(m_series->opacity(), 0.5); | |
73 | QCOMPARE(opacitySpy.count(), 1); |
|
73 | QCOMPARE(opacitySpy.count(), 1); | |
74 |
|
74 | |||
75 | m_series->setOpacity(0.0); |
|
75 | m_series->setOpacity(0.0); | |
76 | QCOMPARE(m_series->opacity(), 0.0); |
|
76 | QCOMPARE(m_series->opacity(), 0.0); | |
77 | QCOMPARE(opacitySpy.count(), 2); |
|
77 | QCOMPARE(opacitySpy.count(), 2); | |
78 |
|
78 | |||
79 | m_series->setOpacity(1.0); |
|
79 | m_series->setOpacity(1.0); | |
80 | QCOMPARE(m_series->opacity(), 1.0); |
|
80 | QCOMPARE(m_series->opacity(), 1.0); | |
81 | QCOMPARE(opacitySpy.count(), 3); |
|
81 | QCOMPARE(opacitySpy.count(), 3); | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 | void tst_QXYSeries::append_data() |
|
84 | void tst_QXYSeries::append_data() | |
85 | { |
|
85 | { | |
86 | QTest::addColumn< QList<QPointF> >("points"); |
|
86 | QTest::addColumn< QList<QPointF> >("points"); | |
87 | QTest::addColumn< QList<QPointF> >("otherPoints"); |
|
87 | QTest::addColumn< QList<QPointF> >("otherPoints"); | |
88 | QTest::newRow("0,0 1,1 2,2 3,3") |
|
88 | QTest::newRow("0,0 1,1 2,2 3,3") | |
89 | << (QList<QPointF>() << QPointF(0,0) << QPointF(1,1) << QPointF(2,2) << QPointF(3,3)) |
|
89 | << (QList<QPointF>() << QPointF(0,0) << QPointF(1,1) << QPointF(2,2) << QPointF(3,3)) | |
90 | << (QList<QPointF>() << QPointF(4,4) << QPointF(5,5) << QPointF(6,6) << QPointF(7,7)); |
|
90 | << (QList<QPointF>() << QPointF(4,4) << QPointF(5,5) << QPointF(6,6) << QPointF(7,7)); | |
91 | QTest::newRow("0,0 -1,-1 -2,-2 -3,-3") |
|
91 | QTest::newRow("0,0 -1,-1 -2,-2 -3,-3") | |
92 | << (QList<QPointF>() << QPointF(0,0) << QPointF(-1,-1) << QPointF(-2,-2) << QPointF(-3,-3)) |
|
92 | << (QList<QPointF>() << QPointF(0,0) << QPointF(-1,-1) << QPointF(-2,-2) << QPointF(-3,-3)) | |
93 | << (QList<QPointF>() << QPointF(-4,-4) << QPointF(-5,-5) << QPointF(-6,-6) << QPointF(-7,-7)); |
|
93 | << (QList<QPointF>() << QPointF(-4,-4) << QPointF(-5,-5) << QPointF(-6,-6) << QPointF(-7,-7)); | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 |
|
96 | |||
97 | void tst_QXYSeries::append_raw_data() |
|
97 | void tst_QXYSeries::append_raw_data() | |
98 | { |
|
98 | { | |
99 | append_data(); |
|
99 | append_data(); | |
100 | } |
|
100 | } | |
101 |
|
101 | |||
102 | void tst_QXYSeries::append_raw() |
|
102 | void tst_QXYSeries::append_raw() | |
103 | { |
|
103 | { | |
104 | QFETCH(QList<QPointF>, points); |
|
104 | QFETCH(QList<QPointF>, points); | |
105 | QFETCH(QList<QPointF>, otherPoints); |
|
105 | QFETCH(QList<QPointF>, otherPoints); | |
106 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF))); |
|
106 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF))); | |
107 | QSignalSpy addedSpy(m_series, SIGNAL(pointAdded(int))); |
|
107 | QSignalSpy addedSpy(m_series, SIGNAL(pointAdded(int))); | |
108 | m_series->append(points); |
|
108 | m_series->append(points); | |
109 | TRY_COMPARE(spy0.count(), 0); |
|
109 | TRY_COMPARE(spy0.count(), 0); | |
110 | TRY_COMPARE(addedSpy.count(), points.count()); |
|
110 | TRY_COMPARE(addedSpy.count(), points.count()); | |
111 | QCOMPARE(m_series->points(), points); |
|
111 | QCOMPARE(m_series->points(), points); | |
112 |
|
112 | |||
113 | // Process events between appends |
|
113 | // Process events between appends | |
114 | foreach (const QPointF &point, otherPoints) { |
|
114 | foreach (const QPointF &point, otherPoints) { | |
115 | m_series->append(point); |
|
115 | m_series->append(point); | |
116 | QApplication::processEvents(); |
|
116 | QApplication::processEvents(); | |
117 | } |
|
117 | } | |
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | void tst_QXYSeries::chart_append_data() |
|
120 | void tst_QXYSeries::chart_append_data() | |
121 | { |
|
121 | { | |
122 | append_data(); |
|
122 | append_data(); | |
123 | } |
|
123 | } | |
124 |
|
124 | |||
125 | void tst_QXYSeries::chart_append() |
|
125 | void tst_QXYSeries::chart_append() | |
126 | { |
|
126 | { | |
127 | append_raw(); |
|
127 | append_raw(); | |
128 | m_chart->addSeries(m_series); |
|
128 | m_chart->addSeries(m_series); | |
129 | m_view->show(); |
|
129 | m_view->show(); | |
130 | QTest::qWaitForWindowShown(m_view); |
|
130 | QTest::qWaitForWindowShown(m_view); | |
131 | } |
|
131 | } | |
132 |
|
132 | |||
133 | void tst_QXYSeries::append_chart_data() |
|
133 | void tst_QXYSeries::append_chart_data() | |
134 | { |
|
134 | { | |
135 | append_data(); |
|
135 | append_data(); | |
136 | } |
|
136 | } | |
137 |
|
137 | |||
138 | void tst_QXYSeries::append_chart() |
|
138 | void tst_QXYSeries::append_chart() | |
139 | { |
|
139 | { | |
140 | m_view->show(); |
|
140 | m_view->show(); | |
141 | m_chart->addSeries(m_series); |
|
141 | m_chart->addSeries(m_series); | |
142 | QTest::qWaitForWindowShown(m_view); |
|
142 | QTest::qWaitForWindowShown(m_view); | |
143 | append_raw(); |
|
143 | append_raw(); | |
144 |
|
144 | |||
145 | } |
|
145 | } | |
146 |
|
146 | |||
147 | void tst_QXYSeries::append_chart_animation_data() |
|
147 | void tst_QXYSeries::append_chart_animation_data() | |
148 | { |
|
148 | { | |
149 | append_data(); |
|
149 | append_data(); | |
150 | } |
|
150 | } | |
151 |
|
151 | |||
152 | void tst_QXYSeries::append_chart_animation() |
|
152 | void tst_QXYSeries::append_chart_animation() | |
153 | { |
|
153 | { | |
154 | m_chart->setAnimationOptions(QChart::AllAnimations); |
|
154 | m_chart->setAnimationOptions(QChart::AllAnimations); | |
155 | append_chart(); |
|
155 | append_chart(); | |
156 | } |
|
156 | } | |
157 |
|
157 | |||
158 | void tst_QXYSeries::count_data() |
|
158 | void tst_QXYSeries::count_data() | |
159 | { |
|
159 | { | |
160 | QTest::addColumn<int>("count"); |
|
160 | QTest::addColumn<int>("count"); | |
161 | QTest::newRow("0") << 0; |
|
161 | QTest::newRow("0") << 0; | |
162 | QTest::newRow("5") << 5; |
|
162 | QTest::newRow("5") << 5; | |
163 | QTest::newRow("10") << 5; |
|
163 | QTest::newRow("10") << 5; | |
164 | } |
|
164 | } | |
165 |
|
165 | |||
166 | void tst_QXYSeries::count_raw_data() |
|
166 | void tst_QXYSeries::count_raw_data() | |
167 | { |
|
167 | { | |
168 | count_data(); |
|
168 | count_data(); | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | void tst_QXYSeries::count_raw() |
|
171 | void tst_QXYSeries::count_raw() | |
172 | { |
|
172 | { | |
173 | QFETCH(int, count); |
|
173 | QFETCH(int, count); | |
174 |
|
174 | |||
175 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF))); |
|
175 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF))); | |
176 |
|
176 | |||
177 | for(int i=0 ; i< count; ++i) |
|
177 | for(int i=0 ; i< count; ++i) | |
178 | m_series->append(i,i); |
|
178 | m_series->append(i,i); | |
179 |
|
179 | |||
180 | TRY_COMPARE(spy0.count(), 0); |
|
180 | TRY_COMPARE(spy0.count(), 0); | |
181 | QCOMPARE(m_series->count(), count); |
|
181 | QCOMPARE(m_series->count(), count); | |
182 | } |
|
182 | } | |
183 |
|
183 | |||
184 | void tst_QXYSeries::remove_raw_data() |
|
184 | void tst_QXYSeries::remove_raw_data() | |
185 | { |
|
185 | { | |
186 | append_data(); |
|
186 | append_data(); | |
187 | } |
|
187 | } | |
188 |
|
188 | |||
189 | void tst_QXYSeries::remove_raw() |
|
189 | void tst_QXYSeries::remove_raw() | |
190 | { |
|
190 | { | |
191 | QFETCH(QList<QPointF>, points); |
|
191 | QFETCH(QList<QPointF>, points); | |
192 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF))); |
|
192 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF))); | |
193 | m_series->append(points); |
|
193 | m_series->append(points); | |
194 | TRY_COMPARE(spy0.count(), 0); |
|
194 | TRY_COMPARE(spy0.count(), 0); | |
195 | QCOMPARE(m_series->points(), points); |
|
195 | QCOMPARE(m_series->points(), points); | |
196 |
|
196 | |||
197 | foreach (const QPointF& point,points) |
|
197 | foreach (const QPointF& point,points) | |
198 | m_series->remove(point); |
|
198 | m_series->remove(point); | |
199 |
|
199 | |||
200 | QCOMPARE(m_series->points().count(), 0); |
|
200 | QCOMPARE(m_series->points().count(), 0); | |
201 | TRY_COMPARE(spy0.count(), 0); |
|
201 | TRY_COMPARE(spy0.count(), 0); | |
202 |
|
202 | |||
203 | m_series->append(points); |
|
203 | m_series->append(points); | |
204 | QCOMPARE(m_series->points(), points); |
|
204 | QCOMPARE(m_series->points(), points); | |
205 |
|
205 | |||
206 | //reverse order |
|
206 | //reverse order | |
207 | for(int i = points.count()-1 ; i>=0; i--){ |
|
207 | for(int i = points.count()-1 ; i>=0; i--){ | |
208 | m_series->remove(points[i]); |
|
208 | m_series->remove(points[i]); | |
209 | } |
|
209 | } | |
210 | QCOMPARE(m_series->points().count(), 0); |
|
210 | QCOMPARE(m_series->points().count(), 0); | |
211 |
|
211 | |||
212 | QApplication::processEvents(); |
|
212 | QApplication::processEvents(); | |
213 |
|
213 | |||
214 | // Process events between removes |
|
214 | // Process events between removes | |
215 | m_series->append(points); |
|
215 | m_series->append(points); | |
216 | QCOMPARE(m_series->points(), points); |
|
216 | QCOMPARE(m_series->points(), points); | |
217 | foreach (const QPointF &point, points) { |
|
217 | foreach (const QPointF &point, points) { | |
218 | m_series->remove(point); |
|
218 | m_series->remove(point); | |
219 | QApplication::processEvents(); |
|
219 | QApplication::processEvents(); | |
220 | } |
|
220 | } | |
221 |
|
221 | |||
222 | // Actual meaningful delay between removes, but still shorter than animation duration |
|
222 | // Actual meaningful delay between removes, but still shorter than animation duration | |
223 | // (simulate e.g. spamming a hypothetical "remove last point"-button) |
|
223 | // (simulate e.g. spamming a hypothetical "remove last point"-button) | |
224 | QList<QPointF> bunchOfPoints; |
|
224 | QList<QPointF> bunchOfPoints; | |
225 | for (int i = 0; i < 10; i++) |
|
225 | for (int i = 0; i < 10; i++) | |
226 | bunchOfPoints.append(QPointF(i, (qreal) rand() / (qreal) RAND_MAX)); |
|
226 | bunchOfPoints.append(QPointF(i, (qreal) rand() / (qreal) RAND_MAX)); | |
227 | m_series->replace(bunchOfPoints); |
|
227 | m_series->replace(bunchOfPoints); | |
228 | QCOMPARE(m_series->points(), bunchOfPoints); |
|
228 | QCOMPARE(m_series->points(), bunchOfPoints); | |
229 | QTest::qWait(1500); // Wait for append animations to be over |
|
229 | QTest::qWait(1500); // Wait for append animations to be over | |
230 | for (int i = bunchOfPoints.count() - 1; i >= 0; i--) { |
|
230 | for (int i = bunchOfPoints.count() - 1; i >= 0; i--) { | |
231 | m_series->remove(bunchOfPoints.at(i)); |
|
231 | m_series->remove(bunchOfPoints.at(i)); | |
232 | QTest::qWait(50); |
|
232 | QTest::qWait(50); | |
233 | } |
|
233 | } | |
|
234 | QCOMPARE(m_series->points().count(), 0); | |||
|
235 | ||||
|
236 | // Removal using index | |||
|
237 | for (int i = 0; i < 10; i++) | |||
|
238 | bunchOfPoints.append(QPointF(i, (qreal) rand() / (qreal) RAND_MAX)); | |||
|
239 | m_series->replace(bunchOfPoints); | |||
|
240 | m_series->remove(5); | |||
|
241 | m_series->remove(0); | |||
|
242 | QCOMPARE(m_series->points().count(), (bunchOfPoints.count() - 2)); | |||
|
243 | for (int i = bunchOfPoints.count() - 3; i >= 0; i--) { | |||
|
244 | m_series->remove(i); | |||
|
245 | QCOMPARE(m_series->points().count(), i); | |||
|
246 | } | |||
|
247 | QCOMPARE(m_series->points().count(), 0); | |||
234 | } |
|
248 | } | |
235 |
|
249 | |||
236 | void tst_QXYSeries::remove_chart_data() |
|
250 | void tst_QXYSeries::remove_chart_data() | |
237 | { |
|
251 | { | |
238 | append_data(); |
|
252 | append_data(); | |
239 | } |
|
253 | } | |
240 |
|
254 | |||
241 | void tst_QXYSeries::remove_chart() |
|
255 | void tst_QXYSeries::remove_chart() | |
242 | { |
|
256 | { | |
243 | m_view->show(); |
|
257 | m_view->show(); | |
244 | m_chart->addSeries(m_series); |
|
258 | m_chart->addSeries(m_series); | |
245 | QTest::qWaitForWindowShown(m_view); |
|
259 | QTest::qWaitForWindowShown(m_view); | |
246 | remove_raw(); |
|
260 | remove_raw(); | |
247 | } |
|
261 | } | |
248 |
|
262 | |||
249 | void tst_QXYSeries::remove_chart_animation_data() |
|
263 | void tst_QXYSeries::remove_chart_animation_data() | |
250 | { |
|
264 | { | |
251 | append_data(); |
|
265 | append_data(); | |
252 | } |
|
266 | } | |
253 |
|
267 | |||
254 | void tst_QXYSeries::remove_chart_animation() |
|
268 | void tst_QXYSeries::remove_chart_animation() | |
255 | { |
|
269 | { | |
256 | m_chart->setAnimationOptions(QChart::AllAnimations); |
|
270 | m_chart->setAnimationOptions(QChart::AllAnimations); | |
257 | remove_chart(); |
|
271 | remove_chart(); | |
258 | } |
|
272 | } | |
259 |
|
273 | |||
260 |
|
274 | |||
261 | void tst_QXYSeries::clear_raw_data() |
|
275 | void tst_QXYSeries::clear_raw_data() | |
262 | { |
|
276 | { | |
263 | append_data(); |
|
277 | append_data(); | |
264 | } |
|
278 | } | |
265 |
|
279 | |||
266 | void tst_QXYSeries::clear_raw() |
|
280 | void tst_QXYSeries::clear_raw() | |
267 | { |
|
281 | { | |
268 | QFETCH(QList<QPointF>, points); |
|
282 | QFETCH(QList<QPointF>, points); | |
269 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF))); |
|
283 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF))); | |
270 | m_series->append(points); |
|
284 | m_series->append(points); | |
271 | TRY_COMPARE(spy0.count(), 0); |
|
285 | TRY_COMPARE(spy0.count(), 0); | |
272 | QCOMPARE(m_series->points(), points); |
|
286 | QCOMPARE(m_series->points(), points); | |
273 | m_series->clear(); |
|
287 | m_series->clear(); | |
274 | TRY_COMPARE(spy0.count(), 0); |
|
288 | TRY_COMPARE(spy0.count(), 0); | |
275 | QCOMPARE(m_series->points().count(), 0); |
|
289 | QCOMPARE(m_series->points().count(), 0); | |
276 |
|
290 | |||
277 | QApplication::processEvents(); |
|
291 | QApplication::processEvents(); | |
278 | } |
|
292 | } | |
279 |
|
293 | |||
280 | void tst_QXYSeries::clear_chart_data() |
|
294 | void tst_QXYSeries::clear_chart_data() | |
281 | { |
|
295 | { | |
282 | append_data(); |
|
296 | append_data(); | |
283 | } |
|
297 | } | |
284 |
|
298 | |||
285 | void tst_QXYSeries::clear_chart() |
|
299 | void tst_QXYSeries::clear_chart() | |
286 | { |
|
300 | { | |
287 | m_view->show(); |
|
301 | m_view->show(); | |
288 | m_chart->addSeries(m_series); |
|
302 | m_chart->addSeries(m_series); | |
289 | QTest::qWaitForWindowShown(m_view); |
|
303 | QTest::qWaitForWindowShown(m_view); | |
290 | clear_raw(); |
|
304 | clear_raw(); | |
291 | } |
|
305 | } | |
292 |
|
306 | |||
293 | void tst_QXYSeries::clear_chart_animation_data() |
|
307 | void tst_QXYSeries::clear_chart_animation_data() | |
294 | { |
|
308 | { | |
295 | append_data(); |
|
309 | append_data(); | |
296 | } |
|
310 | } | |
297 |
|
311 | |||
298 | void tst_QXYSeries::clear_chart_animation() |
|
312 | void tst_QXYSeries::clear_chart_animation() | |
299 | { |
|
313 | { | |
300 | m_chart->setAnimationOptions(QChart::AllAnimations); |
|
314 | m_chart->setAnimationOptions(QChart::AllAnimations); | |
301 | clear_chart(); |
|
315 | clear_chart(); | |
302 | } |
|
316 | } | |
303 |
|
317 | |||
304 | void tst_QXYSeries::replace_raw_data() |
|
318 | void tst_QXYSeries::replace_raw_data() | |
305 | { |
|
319 | { | |
306 | append_data(); |
|
320 | append_data(); | |
307 | } |
|
321 | } | |
308 |
|
322 | |||
309 | void tst_QXYSeries::replace_raw() |
|
323 | void tst_QXYSeries::replace_raw() | |
310 | { |
|
324 | { | |
311 | QFETCH(QList<QPointF>, points); |
|
325 | QFETCH(QList<QPointF>, points); | |
312 | QFETCH(QList<QPointF>, otherPoints); |
|
326 | QFETCH(QList<QPointF>, otherPoints); | |
313 | QSignalSpy pointReplacedSpy(m_series, SIGNAL(pointReplaced(int))); |
|
327 | QSignalSpy pointReplacedSpy(m_series, SIGNAL(pointReplaced(int))); | |
314 | QSignalSpy pointsReplacedSpy(m_series, SIGNAL(pointsReplaced())); |
|
328 | QSignalSpy pointsReplacedSpy(m_series, SIGNAL(pointsReplaced())); | |
315 | m_series->append(points); |
|
329 | m_series->append(points); | |
316 | TRY_COMPARE(pointReplacedSpy.count(), 0); |
|
330 | TRY_COMPARE(pointReplacedSpy.count(), 0); | |
317 | TRY_COMPARE(pointsReplacedSpy.count(), 0); |
|
331 | TRY_COMPARE(pointsReplacedSpy.count(), 0); | |
318 | QCOMPARE(m_series->points(), points); |
|
332 | QCOMPARE(m_series->points(), points); | |
319 |
|
333 | |||
320 | foreach (const QPointF& point, points) |
|
334 | foreach (const QPointF& point, points) | |
321 | m_series->replace(point.x(),point.y(),point.x(),0); |
|
335 | m_series->replace(point.x(),point.y(),point.x(),0); | |
322 | TRY_COMPARE(pointReplacedSpy.count(), points.count()); |
|
336 | TRY_COMPARE(pointReplacedSpy.count(), points.count()); | |
323 | TRY_COMPARE(pointsReplacedSpy.count(), 0); |
|
337 | TRY_COMPARE(pointsReplacedSpy.count(), 0); | |
324 |
|
338 | |||
325 | // Replace a point that does not exist |
|
339 | // Replace a point that does not exist | |
326 | m_series->replace(-123, 999, 0, 0); |
|
340 | m_series->replace(-123, 999, 0, 0); | |
327 | TRY_COMPARE(pointReplacedSpy.count(), points.count()); |
|
341 | TRY_COMPARE(pointReplacedSpy.count(), points.count()); | |
328 | TRY_COMPARE(pointsReplacedSpy.count(), 0); |
|
342 | TRY_COMPARE(pointsReplacedSpy.count(), 0); | |
329 |
|
343 | |||
330 | QList<QPointF> newPoints = m_series->points(); |
|
344 | QList<QPointF> newPoints = m_series->points(); | |
331 | QCOMPARE(newPoints.count(), points.count()); |
|
345 | QCOMPARE(newPoints.count(), points.count()); | |
332 | for(int i =0 ; i<points.count() ; ++i) { |
|
346 | for(int i =0 ; i<points.count() ; ++i) { | |
333 | QCOMPARE(points[i].x(), newPoints[i].x()); |
|
347 | QCOMPARE(points[i].x(), newPoints[i].x()); | |
334 | QCOMPARE(newPoints[i].y(), 0.0); |
|
348 | QCOMPARE(newPoints[i].y(), 0.0); | |
335 | } |
|
349 | } | |
336 |
|
350 | |||
337 | // Replace all points |
|
351 | // Replace all points | |
338 | QList<QPointF> allPoints; |
|
352 | QList<QPointF> allPoints; | |
339 | for (int i = 0; i < 10; i++) |
|
353 | for (int i = 0; i < 10; i++) | |
340 | allPoints.append(QPointF(i, (qreal) rand() / (qreal) RAND_MAX)); |
|
354 | allPoints.append(QPointF(i, (qreal) rand() / (qreal) RAND_MAX)); | |
341 | m_series->replace(allPoints); |
|
355 | m_series->replace(allPoints); | |
342 | TRY_COMPARE(pointReplacedSpy.count(), points.count()); |
|
356 | TRY_COMPARE(pointReplacedSpy.count(), points.count()); | |
343 | TRY_COMPARE(pointsReplacedSpy.count(), 1); |
|
357 | TRY_COMPARE(pointsReplacedSpy.count(), 1); | |
344 |
|
358 | |||
345 | m_series->replace(points); |
|
359 | m_series->replace(points); | |
346 | QApplication::processEvents(); |
|
360 | QApplication::processEvents(); | |
347 |
|
361 | |||
348 | // Process events between replaces |
|
362 | // Process events between replaces | |
349 | for (int i = 0; i < points.count(); ++i) { |
|
363 | for (int i = 0; i < points.count(); ++i) { | |
350 | m_series->replace(points.at(i), otherPoints.at(i)); |
|
364 | m_series->replace(points.at(i), otherPoints.at(i)); | |
351 | QApplication::processEvents(); |
|
365 | QApplication::processEvents(); | |
352 | } |
|
366 | } | |
353 |
|
367 | |||
354 | newPoints = m_series->points(); |
|
368 | newPoints = m_series->points(); | |
355 | QCOMPARE(newPoints.count(), points.count()); |
|
369 | QCOMPARE(newPoints.count(), points.count()); | |
356 | for (int i = 0; i < points.count(); ++i) { |
|
370 | for (int i = 0; i < points.count(); ++i) { | |
357 | QCOMPARE(otherPoints.at(i).x(), newPoints.at(i).x()); |
|
371 | QCOMPARE(otherPoints.at(i).x(), newPoints.at(i).x()); | |
358 | QCOMPARE(otherPoints.at(i).y(), newPoints.at(i).y()); |
|
372 | QCOMPARE(otherPoints.at(i).y(), newPoints.at(i).y()); | |
359 | } |
|
373 | } | |
360 |
|
374 | |||
361 | // Append followed by a replace shouldn't crash |
|
375 | // Append followed by a replace shouldn't crash | |
362 | m_series->clear(); |
|
376 | m_series->clear(); | |
363 | m_series->append(QPointF(22,22)); |
|
377 | m_series->append(QPointF(22,22)); | |
364 | m_series->append(QPointF(23,23)); |
|
378 | m_series->append(QPointF(23,23)); | |
365 | QApplication::processEvents(); |
|
379 | QApplication::processEvents(); | |
366 | m_series->replace(QPointF(23,23), otherPoints.at(1)); |
|
380 | m_series->replace(QPointF(23,23), otherPoints.at(1)); | |
367 | QCOMPARE(m_series->points().at(1).x(), otherPoints.at(1).x()); |
|
381 | QCOMPARE(m_series->points().at(1).x(), otherPoints.at(1).x()); | |
368 | QCOMPARE(m_series->points().at(1).y(), otherPoints.at(1).y()); |
|
382 | QCOMPARE(m_series->points().at(1).y(), otherPoints.at(1).y()); | |
|
383 | ||||
|
384 | // Replace using index | |||
|
385 | m_series->append(otherPoints); | |||
|
386 | m_series->replace(0, QPointF(333, 333)); | |||
|
387 | m_series->replace(3, 444, 444); | |||
|
388 | m_series->replace(m_series->count() - 1, QPointF(555, 555)); | |||
|
389 | QCOMPARE(m_series->points().at(0), QPointF(333, 333)); | |||
|
390 | QCOMPARE(m_series->points().at(3), QPointF(444, 444)); | |||
|
391 | QCOMPARE(m_series->points().at(m_series->count() - 1), QPointF(555, 555)); | |||
369 | } |
|
392 | } | |
370 |
|
393 | |||
371 |
|
394 | |||
372 | void tst_QXYSeries::replace_chart_data() |
|
395 | void tst_QXYSeries::replace_chart_data() | |
373 | { |
|
396 | { | |
374 | append_data(); |
|
397 | append_data(); | |
375 | } |
|
398 | } | |
376 |
|
399 | |||
377 | void tst_QXYSeries::replace_chart() |
|
400 | void tst_QXYSeries::replace_chart() | |
378 | { |
|
401 | { | |
379 | m_view->show(); |
|
402 | m_view->show(); | |
380 | m_chart->addSeries(m_series); |
|
403 | m_chart->addSeries(m_series); | |
381 | QTest::qWaitForWindowShown(m_view); |
|
404 | QTest::qWaitForWindowShown(m_view); | |
382 | replace_raw(); |
|
405 | replace_raw(); | |
383 | } |
|
406 | } | |
384 |
|
407 | |||
385 | void tst_QXYSeries::replace_chart_animation_data() |
|
408 | void tst_QXYSeries::replace_chart_animation_data() | |
386 | { |
|
409 | { | |
387 | append_data(); |
|
410 | append_data(); | |
388 | } |
|
411 | } | |
389 |
|
412 | |||
390 | void tst_QXYSeries::replace_chart_animation() |
|
413 | void tst_QXYSeries::replace_chart_animation() | |
391 | { |
|
414 | { | |
392 | m_chart->setAnimationOptions(QChart::AllAnimations); |
|
415 | m_chart->setAnimationOptions(QChart::AllAnimations); | |
393 | replace_chart(); |
|
416 | replace_chart(); | |
394 | } |
|
417 | } | |
395 |
|
418 | |||
396 | void tst_QXYSeries::insert_data() |
|
419 | void tst_QXYSeries::insert_data() | |
397 | { |
|
420 | { | |
398 | append_data(); |
|
421 | append_data(); | |
399 | } |
|
422 | } | |
400 |
|
423 | |||
401 | void tst_QXYSeries::insert() |
|
424 | void tst_QXYSeries::insert() | |
402 | { |
|
425 | { | |
403 | QFETCH(QList<QPointF>, points); |
|
426 | QFETCH(QList<QPointF>, points); | |
404 | m_series->append(points); |
|
427 | m_series->append(points); | |
405 |
|
428 | |||
406 | QSignalSpy addedSpy(m_series, SIGNAL(pointAdded(int))); |
|
429 | QSignalSpy addedSpy(m_series, SIGNAL(pointAdded(int))); | |
407 |
|
430 | |||
408 | m_series->insert(0, QPointF(5, 5)); |
|
431 | m_series->insert(0, QPointF(5, 5)); | |
409 | TRY_COMPARE(addedSpy.count(), 1); |
|
432 | TRY_COMPARE(addedSpy.count(), 1); | |
410 | QCOMPARE(m_series->points().count(), points.count() + 1); |
|
433 | QCOMPARE(m_series->points().count(), points.count() + 1); | |
411 |
|
434 | |||
412 | m_series->insert(m_series->count(), QPointF(6, 6)); |
|
435 | m_series->insert(m_series->count(), QPointF(6, 6)); | |
413 | TRY_COMPARE(addedSpy.count(), 2); |
|
436 | TRY_COMPARE(addedSpy.count(), 2); | |
414 | QCOMPARE(m_series->points().count(), points.count() + 2); |
|
437 | QCOMPARE(m_series->points().count(), points.count() + 2); | |
415 | } |
|
438 | } | |
416 |
|
439 | |||
417 | void tst_QXYSeries::oper_data() |
|
440 | void tst_QXYSeries::oper_data() | |
418 | { |
|
441 | { | |
419 | append_data(); |
|
442 | append_data(); | |
420 | } |
|
443 | } | |
421 |
|
444 | |||
422 | void tst_QXYSeries::oper() |
|
445 | void tst_QXYSeries::oper() | |
423 | { |
|
446 | { | |
424 | QFETCH(QList<QPointF>, points); |
|
447 | QFETCH(QList<QPointF>, points); | |
425 |
|
448 | |||
426 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF))); |
|
449 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF))); | |
427 |
|
450 | |||
428 | foreach (const QPointF& point,points) |
|
451 | foreach (const QPointF& point,points) | |
429 | { |
|
452 | { | |
430 | *m_series<<point; |
|
453 | *m_series<<point; | |
431 | } |
|
454 | } | |
432 |
|
455 | |||
433 | QCOMPARE(m_series->points(), points); |
|
456 | QCOMPARE(m_series->points(), points); | |
434 | TRY_COMPARE(spy0.count(), 0); |
|
457 | TRY_COMPARE(spy0.count(), 0); | |
435 | } |
|
458 | } | |
436 |
|
459 | |||
437 |
|
460 | |||
438 | void tst_QXYSeries::pen_data() |
|
461 | void tst_QXYSeries::pen_data() | |
439 | { |
|
462 | { | |
440 | QTest::addColumn<QPen>("pen"); |
|
463 | QTest::addColumn<QPen>("pen"); | |
441 | QTest::newRow("null") << QPen(); |
|
464 | QTest::newRow("null") << QPen(); | |
442 | QTest::newRow("blue") << QPen(Qt::blue); |
|
465 | QTest::newRow("blue") << QPen(Qt::blue); | |
443 | QTest::newRow("black") << QPen(Qt::black); |
|
466 | QTest::newRow("black") << QPen(Qt::black); | |
444 | QTest::newRow("red") << QPen(Qt::red); |
|
467 | QTest::newRow("red") << QPen(Qt::red); | |
445 | } |
|
468 | } | |
446 |
|
469 | |||
447 | void tst_QXYSeries::pen() |
|
470 | void tst_QXYSeries::pen() | |
448 | { |
|
471 | { | |
449 | QFETCH(QPen, pen); |
|
472 | QFETCH(QPen, pen); | |
450 |
|
473 | |||
451 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF))); |
|
474 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF))); | |
452 | m_series->setPen(pen); |
|
475 | m_series->setPen(pen); | |
453 |
|
476 | |||
454 | TRY_COMPARE(spy0.count(), 0); |
|
477 | TRY_COMPARE(spy0.count(), 0); | |
455 | QCOMPARE(m_series->pen(), pen); |
|
478 | QCOMPARE(m_series->pen(), pen); | |
456 |
|
479 | |||
457 | m_chart->addSeries(m_series); |
|
480 | m_chart->addSeries(m_series); | |
458 |
|
481 | |||
459 | if (pen != QPen()) |
|
482 | if (pen != QPen()) | |
460 | QCOMPARE(m_series->pen(), pen); |
|
483 | QCOMPARE(m_series->pen(), pen); | |
461 |
|
484 | |||
462 | m_chart->setTheme(QChart::ChartThemeDark); |
|
485 | m_chart->setTheme(QChart::ChartThemeDark); | |
463 |
|
486 | |||
464 | // setting a theme will overwrite all customizations |
|
487 | // setting a theme will overwrite all customizations | |
465 | if (pen != QPen()) |
|
488 | if (pen != QPen()) | |
466 | QVERIFY(m_series->pen() != pen); |
|
489 | QVERIFY(m_series->pen() != pen); | |
467 | } |
|
490 | } | |
468 |
|
491 | |||
469 | void tst_QXYSeries::pointsVisible_data() |
|
492 | void tst_QXYSeries::pointsVisible_data() | |
470 | { |
|
493 | { | |
471 | QTest::addColumn<bool>("pointsVisible"); |
|
494 | QTest::addColumn<bool>("pointsVisible"); | |
472 | QTest::newRow("true") << true; |
|
495 | QTest::newRow("true") << true; | |
473 | QTest::newRow("false") << false; |
|
496 | QTest::newRow("false") << false; | |
474 | } |
|
497 | } | |
475 |
|
498 | |||
476 | void tst_QXYSeries::pointsVisible_raw_data() |
|
499 | void tst_QXYSeries::pointsVisible_raw_data() | |
477 | { |
|
500 | { | |
478 | pointsVisible_data(); |
|
501 | pointsVisible_data(); | |
479 | } |
|
502 | } | |
480 |
|
503 | |||
481 | void tst_QXYSeries::pointsVisible_raw() |
|
504 | void tst_QXYSeries::pointsVisible_raw() | |
482 | { |
|
505 | { | |
483 | QFETCH(bool, pointsVisible); |
|
506 | QFETCH(bool, pointsVisible); | |
484 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF))); |
|
507 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF))); | |
485 | m_series->setPointsVisible(pointsVisible); |
|
508 | m_series->setPointsVisible(pointsVisible); | |
486 | TRY_COMPARE(spy0.count(), 0); |
|
509 | TRY_COMPARE(spy0.count(), 0); | |
487 | QCOMPARE(m_series->pointsVisible(), pointsVisible); |
|
510 | QCOMPARE(m_series->pointsVisible(), pointsVisible); | |
488 | } |
|
511 | } | |
489 |
|
512 | |||
490 | void tst_QXYSeries::changedSignals() |
|
513 | void tst_QXYSeries::changedSignals() | |
491 | { |
|
514 | { | |
492 | QSignalSpy visibleSpy(m_series, SIGNAL(visibleChanged())); |
|
515 | QSignalSpy visibleSpy(m_series, SIGNAL(visibleChanged())); | |
493 | QSignalSpy nameSpy(m_series, SIGNAL(nameChanged())); |
|
516 | QSignalSpy nameSpy(m_series, SIGNAL(nameChanged())); | |
494 | QSignalSpy colorSpy(m_series, SIGNAL(colorChanged(QColor))); |
|
517 | QSignalSpy colorSpy(m_series, SIGNAL(colorChanged(QColor))); | |
495 |
|
518 | |||
496 | // Visibility |
|
519 | // Visibility | |
497 | m_series->setVisible(false); |
|
520 | m_series->setVisible(false); | |
498 | m_series->setVisible(false); |
|
521 | m_series->setVisible(false); | |
499 | TRY_COMPARE(visibleSpy.count(), 1); |
|
522 | TRY_COMPARE(visibleSpy.count(), 1); | |
500 | m_series->setVisible(true); |
|
523 | m_series->setVisible(true); | |
501 | TRY_COMPARE(visibleSpy.count(), 2); |
|
524 | TRY_COMPARE(visibleSpy.count(), 2); | |
502 |
|
525 | |||
503 | // Color |
|
526 | // Color | |
504 | m_series->setColor(QColor("aliceblue")); |
|
527 | m_series->setColor(QColor("aliceblue")); | |
505 | TRY_COMPARE(colorSpy.count(), 1); |
|
528 | TRY_COMPARE(colorSpy.count(), 1); | |
506 |
|
529 | |||
507 | // Pen and Brush |
|
530 | // Pen and Brush | |
508 | QPen p = m_series->pen(); |
|
531 | QPen p = m_series->pen(); | |
509 | p.setColor("aquamarine"); |
|
532 | p.setColor("aquamarine"); | |
510 | m_series->setPen(p); |
|
533 | m_series->setPen(p); | |
511 | QBrush b = m_series->brush(); |
|
534 | QBrush b = m_series->brush(); | |
512 | b.setColor("beige"); |
|
535 | b.setColor("beige"); | |
513 | m_series->setBrush(b); |
|
536 | m_series->setBrush(b); | |
514 | TRY_COMPARE(colorSpy.count(), 2); |
|
537 | TRY_COMPARE(colorSpy.count(), 2); | |
515 |
|
538 | |||
516 | // Verify all the signals again, to make sure no extra signals were emitted |
|
539 | // Verify all the signals again, to make sure no extra signals were emitted | |
517 | TRY_COMPARE(visibleSpy.count(), 2); |
|
540 | TRY_COMPARE(visibleSpy.count(), 2); | |
518 | TRY_COMPARE(nameSpy.count(), 0); |
|
541 | TRY_COMPARE(nameSpy.count(), 0); | |
519 | TRY_COMPARE(colorSpy.count(), 2); |
|
542 | TRY_COMPARE(colorSpy.count(), 2); | |
520 | } |
|
543 | } |
@@ -1,97 +1,97 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 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 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 |
|
22 | |||
23 |
|
23 | |||
24 | Flow { |
|
24 | Flow { | |
25 | id: flow |
|
25 | id: flow | |
26 | spacing: 5 |
|
26 | spacing: 5 | |
27 | flow: Flow.TopToBottom |
|
27 | flow: Flow.TopToBottom | |
28 | property variant series |
|
28 | property variant series | |
29 |
|
29 | |||
30 | Button { |
|
30 | Button { | |
31 | text: "visible" |
|
31 | text: "visible" | |
32 | onClicked: series.visible = !series.visible; |
|
32 | onClicked: series.visible = !series.visible; | |
33 | } |
|
33 | } | |
34 | Button { |
|
34 | Button { | |
35 | text: "opacity +" |
|
35 | text: "opacity +" | |
36 | onClicked: series.opacity += 0.1; |
|
36 | onClicked: series.opacity += 0.1; | |
37 | } |
|
37 | } | |
38 | Button { |
|
38 | Button { | |
39 | text: "opacity -" |
|
39 | text: "opacity -" | |
40 | onClicked: series.opacity -= 0.1; |
|
40 | onClicked: series.opacity -= 0.1; | |
41 | } |
|
41 | } | |
42 | Button { |
|
42 | Button { | |
43 | text: "color" |
|
43 | text: "color" | |
44 | onClicked: series.color = main.nextColor(); |
|
44 | onClicked: series.color = main.nextColor(); | |
45 | } |
|
45 | } | |
46 | Button { |
|
46 | Button { | |
47 | text: series != undefined ? "width + (" + series.width + ")" : "" |
|
47 | text: series != undefined ? "width + (" + series.width + ")" : "" | |
48 | onClicked: series.width += 0.5; |
|
48 | onClicked: series.width += 0.5; | |
49 | } |
|
49 | } | |
50 | Button { |
|
50 | Button { | |
51 | text: series != undefined ? "width - (" + series.width + ")" : "" |
|
51 | text: series != undefined ? "width - (" + series.width + ")" : "" | |
52 | onClicked: series.width -= 0.5; |
|
52 | onClicked: series.width -= 0.5; | |
53 | } |
|
53 | } | |
54 | Button { |
|
54 | Button { | |
55 | text: series != undefined ? "style + (" + series.style + ")" : "" |
|
55 | text: series != undefined ? "style + (" + series.style + ")" : "" | |
56 | onClicked: series.style++; |
|
56 | onClicked: series.style++; | |
57 | } |
|
57 | } | |
58 | Button { |
|
58 | Button { | |
59 | text: series != undefined ? "style - (" + series.style + ")" : "" |
|
59 | text: series != undefined ? "style - (" + series.style + ")" : "" | |
60 | onClicked: series.style--; |
|
60 | onClicked: series.style--; | |
61 | } |
|
61 | } | |
62 | Button { |
|
62 | Button { | |
63 | text: series != undefined ? "cap style + (" + series.capStyle + ")" : "" |
|
63 | text: series != undefined ? "cap style + (" + series.capStyle + ")" : "" | |
64 | onClicked: series.capStyle++; |
|
64 | onClicked: series.capStyle++; | |
65 | } |
|
65 | } | |
66 | Button { |
|
66 | Button { | |
67 | text: series != undefined ? "cap style - (" +series.capStyle + ")" : "" |
|
67 | text: series != undefined ? "cap style - (" +series.capStyle + ")" : "" | |
68 | onClicked: series.capStyle--; |
|
68 | onClicked: series.capStyle--; | |
69 | } |
|
69 | } | |
70 | Button { |
|
70 | Button { | |
71 | text: "points visible" |
|
71 | text: "points visible" | |
72 | onClicked: series.pointsVisible = !series.pointsVisible; |
|
72 | onClicked: series.pointsVisible = !series.pointsVisible; | |
73 | } |
|
73 | } | |
74 | Button { |
|
74 | Button { | |
75 | text: "append point" |
|
75 | text: "append point" | |
76 | onClicked: series.append(series.count - 1, series.count - 1); |
|
76 | onClicked: series.append(series.count - 1, series.count - 1); | |
77 | } |
|
77 | } | |
78 | Button { |
|
78 | Button { | |
79 | text: "replace point" |
|
79 | text: "replace point" | |
80 | onClicked: { |
|
80 | onClicked: { | |
81 | var xyPoint = series.at(series.count - 1); |
|
81 | var xyPoint = series.at(series.count - 1); | |
82 |
series.replace( |
|
82 | series.replace(series.count - 1, xyPoint.x, xyPoint.y + 0.1); | |
83 | } |
|
83 | } | |
84 | } |
|
84 | } | |
85 | Button { |
|
85 | Button { | |
86 | text: "remove point" |
|
86 | text: "remove point" | |
87 |
onClicked: series.remove(series. |
|
87 | onClicked: series.remove(series.count - 1); | |
88 | } |
|
88 | } | |
89 | Button { |
|
89 | Button { | |
90 | text: "insert point" |
|
90 | text: "insert point" | |
91 | onClicked: series.insert(series.count - 2, series.count - 2, series.count - 2); |
|
91 | onClicked: series.insert(series.count - 2, series.count - 2, series.count - 2); | |
92 | } |
|
92 | } | |
93 | Button { |
|
93 | Button { | |
94 | text: "clear" |
|
94 | text: "clear" | |
95 | onClicked: series.clear(); |
|
95 | onClicked: series.clear(); | |
96 | } |
|
96 | } | |
97 | } |
|
97 | } |
@@ -1,92 +1,92 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 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 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 |
|
22 | |||
23 | Flow { |
|
23 | Flow { | |
24 | id: flow |
|
24 | id: flow | |
25 | spacing: 5 |
|
25 | spacing: 5 | |
26 | flow: Flow.TopToBottom |
|
26 | flow: Flow.TopToBottom | |
27 | property variant series |
|
27 | property variant series | |
28 |
|
28 | |||
29 | Button { |
|
29 | Button { | |
30 | text: "visible" |
|
30 | text: "visible" | |
31 | onClicked: series.visible = !series.visible; |
|
31 | onClicked: series.visible = !series.visible; | |
32 | } |
|
32 | } | |
33 | Button { |
|
33 | Button { | |
34 | text: "opacity +" |
|
34 | text: "opacity +" | |
35 | onClicked: series.opacity += 0.1; |
|
35 | onClicked: series.opacity += 0.1; | |
36 | } |
|
36 | } | |
37 | Button { |
|
37 | Button { | |
38 | text: "opacity -" |
|
38 | text: "opacity -" | |
39 | onClicked: series.opacity -= 0.1; |
|
39 | onClicked: series.opacity -= 0.1; | |
40 | } |
|
40 | } | |
41 | Button { |
|
41 | Button { | |
42 | text: "color" |
|
42 | text: "color" | |
43 | onClicked: series.color = main.nextColor(); |
|
43 | onClicked: series.color = main.nextColor(); | |
44 | } |
|
44 | } | |
45 | Button { |
|
45 | Button { | |
46 | text: "borderColor" |
|
46 | text: "borderColor" | |
47 | onClicked: series.borderColor = main.nextColor(); |
|
47 | onClicked: series.borderColor = main.nextColor(); | |
48 | } |
|
48 | } | |
49 | Button { |
|
49 | Button { | |
50 | text: series != undefined ? "borderWidth + (" + series.borderWidth + ")" : "" |
|
50 | text: series != undefined ? "borderWidth + (" + series.borderWidth + ")" : "" | |
51 | onClicked: series.borderWidth += 0.5; |
|
51 | onClicked: series.borderWidth += 0.5; | |
52 | } |
|
52 | } | |
53 | Button { |
|
53 | Button { | |
54 | text: series != undefined ? "borderWidth - (" + series.borderWidth + ")" : "" |
|
54 | text: series != undefined ? "borderWidth - (" + series.borderWidth + ")" : "" | |
55 | onClicked: series.borderWidth -= 0.5; |
|
55 | onClicked: series.borderWidth -= 0.5; | |
56 | } |
|
56 | } | |
57 | Button { |
|
57 | Button { | |
58 | text: "markerSize +" |
|
58 | text: "markerSize +" | |
59 | onClicked: series.markerSize += 1.0; |
|
59 | onClicked: series.markerSize += 1.0; | |
60 | } |
|
60 | } | |
61 | Button { |
|
61 | Button { | |
62 | text: "markerSize -" |
|
62 | text: "markerSize -" | |
63 | onClicked: series.markerSize -= 1.0; |
|
63 | onClicked: series.markerSize -= 1.0; | |
64 | } |
|
64 | } | |
65 | Button { |
|
65 | Button { | |
66 | text: "markerShape" |
|
66 | text: "markerShape" | |
67 | onClicked: series.markerShape = ((series.markerShape + 1) % 2); |
|
67 | onClicked: series.markerShape = ((series.markerShape + 1) % 2); | |
68 | } |
|
68 | } | |
69 | Button { |
|
69 | Button { | |
70 | text: "append point" |
|
70 | text: "append point" | |
71 | onClicked: series.append(series.count - 1, series.count - 1); |
|
71 | onClicked: series.append(series.count - 1, series.count - 1); | |
72 | } |
|
72 | } | |
73 | Button { |
|
73 | Button { | |
74 | text: "replace point" |
|
74 | text: "replace point" | |
75 | onClicked: { |
|
75 | onClicked: { | |
76 | var xyPoint = series.at(series.count - 1); |
|
76 | var xyPoint = series.at(series.count - 1); | |
77 |
series.replace( |
|
77 | series.replace(series.count - 1, xyPoint.x, xyPoint.y + 0.1); | |
78 | } |
|
78 | } | |
79 | } |
|
79 | } | |
80 | Button { |
|
80 | Button { | |
81 | text: "remove point" |
|
81 | text: "remove point" | |
82 |
onClicked: series.remove(series. |
|
82 | onClicked: series.remove(series.count - 1); | |
83 | } |
|
83 | } | |
84 | Button { |
|
84 | Button { | |
85 | text: "insert point" |
|
85 | text: "insert point" | |
86 | onClicked: series.insert(series.count - 2, series.count - 2, series.count - 2); |
|
86 | onClicked: series.insert(series.count - 2, series.count - 2, series.count - 2); | |
87 | } |
|
87 | } | |
88 | Button { |
|
88 | Button { | |
89 | text: "clear" |
|
89 | text: "clear" | |
90 | onClicked: series.clear(); |
|
90 | onClicked: series.clear(); | |
91 | } |
|
91 | } | |
92 | } |
|
92 | } |
@@ -1,97 +1,97 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 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 | import QtQuick 2.0 |
|
21 | import QtQuick 2.0 | |
22 |
|
22 | |||
23 |
|
23 | |||
24 | Flow { |
|
24 | Flow { | |
25 | id: flow |
|
25 | id: flow | |
26 | spacing: 5 |
|
26 | spacing: 5 | |
27 | flow: Flow.TopToBottom |
|
27 | flow: Flow.TopToBottom | |
28 | property variant series |
|
28 | property variant series | |
29 |
|
29 | |||
30 | Button { |
|
30 | Button { | |
31 | text: "visible" |
|
31 | text: "visible" | |
32 | onClicked: series.visible = !series.visible; |
|
32 | onClicked: series.visible = !series.visible; | |
33 | } |
|
33 | } | |
34 | Button { |
|
34 | Button { | |
35 | text: "opacity +" |
|
35 | text: "opacity +" | |
36 | onClicked: series.opacity += 0.1; |
|
36 | onClicked: series.opacity += 0.1; | |
37 | } |
|
37 | } | |
38 | Button { |
|
38 | Button { | |
39 | text: "opacity -" |
|
39 | text: "opacity -" | |
40 | onClicked: series.opacity -= 0.1; |
|
40 | onClicked: series.opacity -= 0.1; | |
41 | } |
|
41 | } | |
42 | Button { |
|
42 | Button { | |
43 | text: "color" |
|
43 | text: "color" | |
44 | onClicked: series.color = main.nextColor(); |
|
44 | onClicked: series.color = main.nextColor(); | |
45 | } |
|
45 | } | |
46 | Button { |
|
46 | Button { | |
47 | text: series != undefined ? "width + (" + series.width + ")" : "" |
|
47 | text: series != undefined ? "width + (" + series.width + ")" : "" | |
48 | onClicked: series.width += 0.5; |
|
48 | onClicked: series.width += 0.5; | |
49 | } |
|
49 | } | |
50 | Button { |
|
50 | Button { | |
51 | text: series != undefined ? "width - (" + series.width + ")" : "" |
|
51 | text: series != undefined ? "width - (" + series.width + ")" : "" | |
52 | onClicked: series.width -= 0.5; |
|
52 | onClicked: series.width -= 0.5; | |
53 | } |
|
53 | } | |
54 | Button { |
|
54 | Button { | |
55 | text: series != undefined ? "style + (" + series.style + ")" : "" |
|
55 | text: series != undefined ? "style + (" + series.style + ")" : "" | |
56 | onClicked: series.style++; |
|
56 | onClicked: series.style++; | |
57 | } |
|
57 | } | |
58 | Button { |
|
58 | Button { | |
59 | text: series != undefined ? "style - (" + series.style + ")" : "" |
|
59 | text: series != undefined ? "style - (" + series.style + ")" : "" | |
60 | onClicked: series.style--; |
|
60 | onClicked: series.style--; | |
61 | } |
|
61 | } | |
62 | Button { |
|
62 | Button { | |
63 | text: series != undefined ? "cap style + (" + series.capStyle + ")" : "" |
|
63 | text: series != undefined ? "cap style + (" + series.capStyle + ")" : "" | |
64 | onClicked: series.capStyle++; |
|
64 | onClicked: series.capStyle++; | |
65 | } |
|
65 | } | |
66 | Button { |
|
66 | Button { | |
67 | text: series != undefined ? "cap style - (" +series.capStyle + ")" : "" |
|
67 | text: series != undefined ? "cap style - (" +series.capStyle + ")" : "" | |
68 | onClicked: series.capStyle--; |
|
68 | onClicked: series.capStyle--; | |
69 | } |
|
69 | } | |
70 | Button { |
|
70 | Button { | |
71 | text: "points visible" |
|
71 | text: "points visible" | |
72 | onClicked: series.pointsVisible = !series.pointsVisible; |
|
72 | onClicked: series.pointsVisible = !series.pointsVisible; | |
73 | } |
|
73 | } | |
74 | Button { |
|
74 | Button { | |
75 | text: "append point" |
|
75 | text: "append point" | |
76 | onClicked: series.append(series.count - 1, series.count - 1); |
|
76 | onClicked: series.append(series.count - 1, series.count - 1); | |
77 | } |
|
77 | } | |
78 | Button { |
|
78 | Button { | |
79 | text: "replace point" |
|
79 | text: "replace point" | |
80 | onClicked: { |
|
80 | onClicked: { | |
81 | var xyPoint = series.at(series.count - 1); |
|
81 | var xyPoint = series.at(series.count - 1); | |
82 |
series.replace( |
|
82 | series.replace(series.count - 1, xyPoint.x, xyPoint.y + 0.1); | |
83 | } |
|
83 | } | |
84 | } |
|
84 | } | |
85 | Button { |
|
85 | Button { | |
86 | text: "remove point" |
|
86 | text: "remove point" | |
87 |
onClicked: series.remove(series. |
|
87 | onClicked: series.remove(series.count - 1); | |
88 | } |
|
88 | } | |
89 | Button { |
|
89 | Button { | |
90 | text: "insert point" |
|
90 | text: "insert point" | |
91 | onClicked: series.insert(series.count - 2, series.count - 2, series.count - 2); |
|
91 | onClicked: series.insert(series.count - 2, series.count - 2, series.count - 2); | |
92 | } |
|
92 | } | |
93 | Button { |
|
93 | Button { | |
94 | text: "clear" |
|
94 | text: "clear" | |
95 | onClicked: series.clear(); |
|
95 | onClicked: series.clear(); | |
96 | } |
|
96 | } | |
97 | } |
|
97 | } |
@@ -1,92 +1,92 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 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 | import QtQuick 2.0 |
|
21 | import QtQuick 2.0 | |
22 |
|
22 | |||
23 | Flow { |
|
23 | Flow { | |
24 | id: flow |
|
24 | id: flow | |
25 | spacing: 5 |
|
25 | spacing: 5 | |
26 | flow: Flow.TopToBottom |
|
26 | flow: Flow.TopToBottom | |
27 | property variant series |
|
27 | property variant series | |
28 |
|
28 | |||
29 | Button { |
|
29 | Button { | |
30 | text: "visible" |
|
30 | text: "visible" | |
31 | onClicked: series.visible = !series.visible; |
|
31 | onClicked: series.visible = !series.visible; | |
32 | } |
|
32 | } | |
33 | Button { |
|
33 | Button { | |
34 | text: "opacity +" |
|
34 | text: "opacity +" | |
35 | onClicked: series.opacity += 0.1; |
|
35 | onClicked: series.opacity += 0.1; | |
36 | } |
|
36 | } | |
37 | Button { |
|
37 | Button { | |
38 | text: "opacity -" |
|
38 | text: "opacity -" | |
39 | onClicked: series.opacity -= 0.1; |
|
39 | onClicked: series.opacity -= 0.1; | |
40 | } |
|
40 | } | |
41 | Button { |
|
41 | Button { | |
42 | text: "color" |
|
42 | text: "color" | |
43 | onClicked: series.color = main.nextColor(); |
|
43 | onClicked: series.color = main.nextColor(); | |
44 | } |
|
44 | } | |
45 | Button { |
|
45 | Button { | |
46 | text: "borderColor" |
|
46 | text: "borderColor" | |
47 | onClicked: series.borderColor = main.nextColor(); |
|
47 | onClicked: series.borderColor = main.nextColor(); | |
48 | } |
|
48 | } | |
49 | Button { |
|
49 | Button { | |
50 | text: series != undefined ? "borderWidth + (" + series.borderWidth + ")" : "" |
|
50 | text: series != undefined ? "borderWidth + (" + series.borderWidth + ")" : "" | |
51 | onClicked: series.borderWidth += 0.5; |
|
51 | onClicked: series.borderWidth += 0.5; | |
52 | } |
|
52 | } | |
53 | Button { |
|
53 | Button { | |
54 | text: series != undefined ? "borderWidth - (" + series.borderWidth + ")" : "" |
|
54 | text: series != undefined ? "borderWidth - (" + series.borderWidth + ")" : "" | |
55 | onClicked: series.borderWidth -= 0.5; |
|
55 | onClicked: series.borderWidth -= 0.5; | |
56 | } |
|
56 | } | |
57 | Button { |
|
57 | Button { | |
58 | text: "markerSize +" |
|
58 | text: "markerSize +" | |
59 | onClicked: series.markerSize += 1.0; |
|
59 | onClicked: series.markerSize += 1.0; | |
60 | } |
|
60 | } | |
61 | Button { |
|
61 | Button { | |
62 | text: "markerSize -" |
|
62 | text: "markerSize -" | |
63 | onClicked: series.markerSize -= 1.0; |
|
63 | onClicked: series.markerSize -= 1.0; | |
64 | } |
|
64 | } | |
65 | Button { |
|
65 | Button { | |
66 | text: "markerShape" |
|
66 | text: "markerShape" | |
67 | onClicked: series.markerShape = ((series.markerShape + 1) % 2); |
|
67 | onClicked: series.markerShape = ((series.markerShape + 1) % 2); | |
68 | } |
|
68 | } | |
69 | Button { |
|
69 | Button { | |
70 | text: "append point" |
|
70 | text: "append point" | |
71 | onClicked: series.append(series.count - 1, series.count - 1); |
|
71 | onClicked: series.append(series.count - 1, series.count - 1); | |
72 | } |
|
72 | } | |
73 | Button { |
|
73 | Button { | |
74 | text: "replace point" |
|
74 | text: "replace point" | |
75 | onClicked: { |
|
75 | onClicked: { | |
76 | var xyPoint = series.at(series.count - 1); |
|
76 | var xyPoint = series.at(series.count - 1); | |
77 |
series.replace( |
|
77 | series.replace(series.count - 1, xyPoint.x, xyPoint.y + 0.1); | |
78 | } |
|
78 | } | |
79 | } |
|
79 | } | |
80 | Button { |
|
80 | Button { | |
81 | text: "remove point" |
|
81 | text: "remove point" | |
82 |
onClicked: series.remove(series. |
|
82 | onClicked: series.remove(series.count - 1); | |
83 | } |
|
83 | } | |
84 | Button { |
|
84 | Button { | |
85 | text: "insert point" |
|
85 | text: "insert point" | |
86 | onClicked: series.insert(series.count - 2, series.count - 2, series.count - 2); |
|
86 | onClicked: series.insert(series.count - 2, series.count - 2, series.count - 2); | |
87 | } |
|
87 | } | |
88 | Button { |
|
88 | Button { | |
89 | text: "clear" |
|
89 | text: "clear" | |
90 | onClicked: series.clear(); |
|
90 | onClicked: series.clear(); | |
91 | } |
|
91 | } | |
92 | } |
|
92 | } |
General Comments 0
You need to be logged in to leave comments.
Login now