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