##// END OF EJS Templates
Clears the qml plugin code from legacy code
Michal Klocek -
r1608:f0863591c53c
parent child
Show More
@@ -1,160 +1,155
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 import QtCommercial.Chart 1.0
23 23 import QmlCustomModel 1.0
24 24
25 25 Rectangle {
26 26 anchors.fill: parent
27 27
28 28 //![1]
29 29 ChartView {
30 30 id: chartView
31 31 title: "Top-5 car brand shares in Finland"
32 32 anchors.fill: parent
33 33 animationOptions: ChartView.SeriesAnimations
34
34 35 CategoriesAxis {
35 36 id: categoryAxis
36 37 categories: ["2007", "2008", "2009", "2010", "2011", "2012" ]
37 38 }
38 39 // ...
39 40 //![1]
40 41
41 42 //![2]
42 43 CustomModel {
43 44 id: customModel
44 45 verticalHeaders: ["Manufacturer", "Volkswagen", "Toyota", "Ford", "Skoda", "Volvo", "Others"]
45 46 CustomModelElement { values: [0, "Manufacturer", 0, 1, 2, 3, 4] }
46 47 CustomModelElement { values: [1, "Volkswagen", 10.3, 12.0, 12.8, 13.0, 13.8] }
47 48 CustomModelElement { values: [2, "Toyota", 13.8, 13.5, 16.2, 13.7, 10.7] }
48 49 CustomModelElement { values: [3, "Ford", 6.4, 7.1, 8.9, 8.2, 8.6] }
49 50 CustomModelElement { values: [4, "Skoda", 4.7, 5.8, 6.9, 8.3, 8.2] }
50 51 CustomModelElement { values: [5, "Volvo", 7.1, 6.7, 6.5, 6.3, 7.0] }
51 52 CustomModelElement { values: [6, "Others", 57.7, 54.9, 48.7, 50.5, 51.7] }
52 53 }
53 54 //![2]
54 55
55 56 //![5]
56 57 BarSeries {
57 58 name: "Others"
58 59 barWidth: 0.9
59 60 visible: false
60 axisX: categoryAxis
61 61 HBarModelMapper {
62 62 model: customModel
63 63 firstBarSetRow: 6
64 64 lastBarSetRow: 6
65 65 firstColumn: 2
66 66 }
67 67 }
68 68 //![5]
69 69
70 70 //![4]
71 71 LineSeries {
72 72 name: "Volkswagen"
73 axisX: categoryAxis
74 73 visible: false
75 74 HXYModelMapper {
76 75 model: customModel
77 76 xRow: 0
78 77 yRow: 1
79 78 firstColumn: 2
80 79 }
81 80 }
82 81 //![4]
83 82
84 83 LineSeries {
85 84 name: "Toyota"
86 axisX: categoryAxis
87 85 visible: false
88 86 HXYModelMapper {
89 87 model: customModel
90 88 xRow: 0
91 89 yRow: 2
92 90 firstColumn: 2
93 91 }
94 92 }
95 93
96 94 LineSeries {
97 95 name: "Ford"
98 axisX: categoryAxis
99 96 visible: false
100 97 HXYModelMapper {
101 98 model: customModel
102 99 xRow: 0
103 100 yRow: 3
104 101 firstColumn: 2
105 102 }
106 103 }
107 104
108 105 LineSeries {
109 106 name: "Skoda"
110 axisX: categoryAxis
111 107 visible: false
112 108 HXYModelMapper {
113 109 model: customModel
114 110 xRow: 0
115 111 yRow: 4
116 112 firstColumn: 2
117 113 }
118 114 }
119 115
120 116 LineSeries {
121 117 name: "Volvo"
122 axisX: categoryAxis
123 118 visible: false
124 119 HXYModelMapper {
125 120 model: customModel
126 121 xRow: 0
127 122 yRow: 5
128 123 firstColumn: 2
129 124 }
130 125 }
131 126
132 127 //![3]
133 128 PieSeries {
134 129 id: pieSeries
135 130 size: 0.4
136 131 horizontalPosition: 0.7
137 132 verticalPosition: 0.4
138 133 onClicked: {
139 134 // Show the selection by exploding the slice
140 135 slice.exploded = !slice.exploded;
141 136
142 137 // Update the line series to show the yearly data for this slice
143 138 for (var i = 0; i < chartView.count; i++) {
144 139 if (chartView.series(i).name == slice.label) {
145 140 chartView.series(i).visible = slice.exploded;
146 141 }
147 142 }
148 143 }
149 144 }
150 145 //![3]
151 146
152 147 VPieModelMapper {
153 148 series: pieSeries
154 149 model: customModel
155 150 labelsColumn: 1
156 151 valuesColumn: 2
157 152 firstRow: 1
158 153 }
159 154 }
160 155 }
@@ -1,75 +1,56
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 "declarativeareaseries.h"
22 22 #include "declarativechart.h"
23 23 #include "qchart.h"
24 24 #include "qxymodelmapper.h"
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 28 DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) :
29 29 QAreaSeries(parent)
30 30 {
31 31 }
32 32
33 void DeclarativeAreaSeries::setAxisX(QAbstractAxis *axis)
34 {
35 chart()->setAxisX(axis,this);
36 }
37
38 QAbstractAxis *DeclarativeAreaSeries::axisX()
39 {
40 return chart()->axisX(this);
41 }
42
43 void DeclarativeAreaSeries::setAxisY(QAbstractAxis *axis)
44 {
45 chart()->setAxisY(axis,this);
46 }
47
48 QAbstractAxis *DeclarativeAreaSeries::axisY()
49 {
50 return chart()->axisY(this);
51 }
52 33
53 34 void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries* series)
54 35 {
55 36 QAreaSeries::setUpperSeries(series);
56 37 }
57 38
58 39 DeclarativeLineSeries* DeclarativeAreaSeries::upperSeries() const
59 40 {
60 41 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::upperSeries());
61 42 }
62 43
63 44 void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries* series)
64 45 {
65 46 QAreaSeries::setLowerSeries(series);
66 47 }
67 48
68 49 DeclarativeLineSeries* DeclarativeAreaSeries::lowerSeries() const
69 50 {
70 51 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::lowerSeries());
71 52 }
72 53
73 54 #include "moc_declarativeareaseries.cpp"
74 55
75 56 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,53 +1,47
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 DECLARATIVEAREASERIES_H
22 22 #define DECLARATIVEAREASERIES_H
23 23
24 24 #include "qchartglobal.h"
25 25 #include "qareaseries.h"
26 26 #include "declarativelineseries.h"
27 27 #include "qabstractaxis.h"
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30
31 31 class DeclarativeAreaSeries : public QAreaSeries
32 32 {
33 33 Q_OBJECT
34 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX)
35 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY)
36 34 Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries)
37 35 Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries)
38 36
39 37 public:
40 void setAxisX(QAbstractAxis *axis);
41 QAbstractAxis *axisX();
42 void setAxisY(QAbstractAxis *axis);
43 QAbstractAxis *axisY();
44 38 explicit DeclarativeAreaSeries(QObject *parent = 0);
45 39 void setUpperSeries(DeclarativeLineSeries* series);
46 40 DeclarativeLineSeries* upperSeries() const;
47 41 void setLowerSeries(DeclarativeLineSeries* series);
48 42 DeclarativeLineSeries* lowerSeries() const;
49 43 };
50 44
51 45 QTCOMMERCIALCHART_END_NAMESPACE
52 46
53 47 #endif // DECLARATIVEAREASERIES_H
@@ -1,145 +1,141
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 DECLARATIVEBARSERIES_H
22 22 #define DECLARATIVEBARSERIES_H
23 23
24 24 #include "qchartglobal.h"
25 25 #include "qabstractbarseries.h"
26 26 #include "qbarseries.h"
27 27 #include "qstackedbarseries.h"
28 28 #include "qpercentbarseries.h"
29 29 #include "qbarset.h"
30 30 #include "qabstractaxis.h"
31 31 #include <QDeclarativeItem>
32 32 #include <QDeclarativeParserStatus>
33 33
34 34 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 35
36 36 class QChart;
37 37
38 38 class DeclarativeBarSet : public QBarSet
39 39 {
40 40 Q_OBJECT
41 41 Q_PROPERTY(QVariantList values READ values WRITE setValues)
42 42 Q_PROPERTY(int count READ count NOTIFY countChanged)
43 43
44 44 public:
45 45 explicit DeclarativeBarSet(QObject *parent = 0);
46 46 QVariantList values();
47 47 void setValues(QVariantList values);
48 48
49 49 public: // From QBarSet
50 50 Q_INVOKABLE void append(qreal value) { QBarSet::append(value); }
51 51 Q_INVOKABLE void remove(const int index, const int count = 1) { QBarSet::remove(index, count); }
52 52 Q_INVOKABLE void replace(int index, qreal value) { QBarSet::replace(index, value); }
53 53 Q_INVOKABLE qreal at(int index) { return QBarSet::at(index); }
54 54
55 55 Q_SIGNALS:
56 56 void countChanged(int count);
57 57
58 58 private Q_SLOTS:
59 59 void handleCountChanged(int index, int count);
60 60 };
61 61
62 62 class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus
63 63 {
64 64 Q_OBJECT
65 65 Q_INTERFACES(QDeclarativeParserStatus)
66 66 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
67 67 Q_CLASSINFO("DefaultProperty", "seriesChildren")
68 68
69 69 public:
70 70 explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0);
71 void setAxisX(QAbstractAxis *axis);
72 QAbstractAxis *axisX();
73 void setAxisY(QAbstractAxis *axis);
74 QAbstractAxis *axisY();
75 71 QDeclarativeListProperty<QObject> seriesChildren();
76 72 Q_INVOKABLE DeclarativeBarSet *at(int index);
77 73 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
78 74 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
79 75 Q_INVOKABLE bool remove(QBarSet *barset) { return QBarSeries::remove(barset); }
80 76 Q_INVOKABLE void clear() { return QBarSeries::clear(); }
81 77
82 78 public: // from QDeclarativeParserStatus
83 79 void classBegin();
84 80 void componentComplete();
85 81
86 82 public Q_SLOTS:
87 83 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
88 84
89 85 private:
90 86 QAbstractAxis* m_axisX;
91 87 QAbstractAxis* m_axisY;
92 88 };
93 89
94 90 class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus
95 91 {
96 92 Q_OBJECT
97 93 Q_INTERFACES(QDeclarativeParserStatus)
98 94 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
99 95 Q_CLASSINFO("DefaultProperty", "seriesChildren")
100 96
101 97 public:
102 98 explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0);
103 99 QDeclarativeListProperty<QObject> seriesChildren();
104 100 Q_INVOKABLE DeclarativeBarSet *at(int index);
105 101 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
106 102 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
107 103 Q_INVOKABLE bool remove(QBarSet *barset) { return QStackedBarSeries::remove(barset); }
108 104 Q_INVOKABLE void clear() { return QStackedBarSeries::clear(); }
109 105
110 106 public: // from QDeclarativeParserStatus
111 107 void classBegin();
112 108 void componentComplete();
113 109
114 110 public Q_SLOTS:
115 111 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
116 112
117 113 };
118 114
119 115 class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus
120 116 {
121 117 Q_OBJECT
122 118 Q_INTERFACES(QDeclarativeParserStatus)
123 119 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
124 120 Q_CLASSINFO("DefaultProperty", "seriesChildren")
125 121
126 122 public:
127 123 explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0);
128 124 QDeclarativeListProperty<QObject> seriesChildren();
129 125 Q_INVOKABLE DeclarativeBarSet *at(int index);
130 126 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
131 127 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
132 128 Q_INVOKABLE bool remove(QBarSet *barset) { return QPercentBarSeries::remove(barset); }
133 129 Q_INVOKABLE void clear() { return QPercentBarSeries::clear(); }
134 130
135 131 public: // from QDeclarativeParserStatus
136 132 void classBegin();
137 133 void componentComplete();
138 134
139 135 public Q_SLOTS:
140 136 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
141 137 };
142 138
143 139 QTCOMMERCIALCHART_END_NAMESPACE
144 140
145 141 #endif // DECLARATIVEBARSERIES_H
@@ -1,80 +1,60
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 "declarativelineseries.h"
22 22 #include "declarativechart.h"
23 23 #include "qchart.h"
24 24 #include "qlineseries.h"
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 28 DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) :
29 29 QLineSeries(parent)
30 30 {
31 31 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
32 32 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
33 33 }
34 34
35 35 QXYSeries *DeclarativeLineSeries::xySeries()
36 36 {
37 37 return this;
38 38 }
39 39
40 void DeclarativeLineSeries::setAxisX(QAbstractAxis *axis)
41 {
42 chart()->setAxisX(axis,this);
43 }
44
45 QAbstractAxis *DeclarativeLineSeries::axisX()
46 {
47 return chart()->axisX(this);
48 }
49
50 void DeclarativeLineSeries::setAxisY(QAbstractAxis *axis)
51 {
52 chart()->setAxisY(axis,this);
53 }
54
55 QAbstractAxis *DeclarativeLineSeries::axisY()
56 {
57 return chart()->axisY(this);
58 }
59
60 40 void DeclarativeLineSeries::handleCountChanged(int index)
61 41 {
62 42 Q_UNUSED(index)
63 43 emit countChanged(points().count());
64 44 }
65 45
66 46 QDeclarativeListProperty<QObject> DeclarativeLineSeries::declarativeChildren()
67 47 {
68 48 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
69 49 }
70 50
71 51 void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
72 52 {
73 53 Q_UNUSED(list)
74 54 Q_UNUSED(element)
75 55 // Empty implementation, childs are parsed in componentComplete
76 56 }
77 57
78 58 #include "moc_declarativelineseries.cpp"
79 59
80 60 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,75 +1,69
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 "qchartglobal.h"
25 25 #include "qlineseries.h"
26 26 #include "declarativexyseries.h"
27 27 #include "qabstractaxis.h"
28 28 #include <QDeclarativeParserStatus>
29 29 #include <QDeclarativeListProperty>
30 30 #include <QDeclarativeParserStatus>
31 31
32 32 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33 33
34 34 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
35 35 {
36 36 Q_OBJECT
37 37 Q_INTERFACES(QDeclarativeParserStatus)
38 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX)
39 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY)
40 38 Q_PROPERTY(int count READ count NOTIFY countChanged)
41 39 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
42 40 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
43 41
44 42 public:
45 43 explicit DeclarativeLineSeries(QObject *parent = 0);
46 44 QXYSeries *xySeries();
47 void setAxisX(QAbstractAxis *axis);
48 QAbstractAxis *axisX();
49 void setAxisY(QAbstractAxis *axis);
50 QAbstractAxis *axisY();
51 45 QDeclarativeListProperty<QObject> declarativeChildren();
52 46
53 47 public: // from QDeclarativeParserStatus
54 48 void classBegin() { DeclarativeXySeries::classBegin(); }
55 49 void componentComplete() { DeclarativeXySeries::componentComplete(); }
56 50
57 51 public:
58 52 Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); }
59 53 Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); }
60 54 Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); }
61 55 Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); }
62 56 Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); }
63 57 Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); }
64 58
65 59 Q_SIGNALS:
66 60 void countChanged(int count);
67 61
68 62 public Q_SLOTS:
69 63 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
70 64 void handleCountChanged(int index);
71 65 };
72 66
73 67 QTCOMMERCIALCHART_END_NAMESPACE
74 68
75 69 #endif // DECLARATIVELINESERIES_H
@@ -1,80 +1,60
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 "declarativescatterseries.h"
22 22 #include "declarativechart.h"
23 23 #include "qchart.h"
24 24 #include "qscatterseries.h"
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 28 DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) :
29 29 QScatterSeries(parent)
30 30 {
31 31 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
32 32 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
33 33 }
34 34
35 35 QXYSeries *DeclarativeScatterSeries::xySeries()
36 36 {
37 37 return this;
38 38 }
39 39
40 void DeclarativeScatterSeries::setAxisX(QAbstractAxis *axis)
41 {
42 chart()->setAxisX(axis,this);
43 }
44
45 QAbstractAxis *DeclarativeScatterSeries::axisX()
46 {
47 return chart()->axisX(this);
48 }
49
50 void DeclarativeScatterSeries::setAxisY(QAbstractAxis *axis)
51 {
52 chart()->setAxisY(axis,this);
53 }
54
55 QAbstractAxis *DeclarativeScatterSeries::axisY()
56 {
57 return chart()->axisY(this);
58 }
59
60 40 void DeclarativeScatterSeries::handleCountChanged(int index)
61 41 {
62 42 Q_UNUSED(index)
63 43 emit countChanged(QScatterSeries::count());
64 44 }
65 45
66 46 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren()
67 47 {
68 48 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
69 49 }
70 50
71 51 void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
72 52 {
73 53 Q_UNUSED(list)
74 54 Q_UNUSED(element)
75 55 // Empty implementation, childs are parsed in componentComplete
76 56 }
77 57
78 58 #include "moc_declarativescatterseries.cpp"
79 59
80 60 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,74 +1,68
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 "qchartglobal.h"
25 25 #include "qscatterseries.h"
26 26 #include "declarativexyseries.h"
27 27 #include "qabstractaxis.h"
28 28 #include <QDeclarativeListProperty>
29 29 #include <QDeclarativeParserStatus>
30 30
31 31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 32
33 33 class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
34 34 {
35 35 Q_OBJECT
36 36 Q_INTERFACES(QDeclarativeParserStatus)
37 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX)
38 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY)
39 37 Q_PROPERTY(int count READ count NOTIFY countChanged)
40 38 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
41 39 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
42 40
43 41 public:
44 42 explicit DeclarativeScatterSeries(QObject *parent = 0);
45 43 QXYSeries *xySeries();
46 void setAxisX(QAbstractAxis *axis);
47 QAbstractAxis *axisX();
48 void setAxisY(QAbstractAxis *axis);
49 QAbstractAxis *axisY();
50 44 QDeclarativeListProperty<QObject> declarativeChildren();
51 45
52 46 public: // from QDeclarativeParserStatus
53 47 void classBegin() { DeclarativeXySeries::classBegin(); }
54 48 void componentComplete() { DeclarativeXySeries::componentComplete(); }
55 49
56 50 public:
57 51 Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); }
58 52 Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); }
59 53 Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); }
60 54 Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); }
61 55 Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); }
62 56 Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); }
63 57
64 58 Q_SIGNALS:
65 59 void countChanged(int count);
66 60
67 61 public Q_SLOTS:
68 62 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
69 63 void handleCountChanged(int index);
70 64 };
71 65
72 66 QTCOMMERCIALCHART_END_NAMESPACE
73 67
74 68 #endif // DECLARATIVESCATTERSERIES_H
@@ -1,80 +1,60
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 "declarativesplineseries.h"
22 22 #include "declarativechart.h"
23 23 #include <QChart>
24 24 #include "declarativexypoint.h"
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 28 DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) :
29 29 QSplineSeries(parent)
30 30 {
31 31 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
32 32 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
33 33 }
34 34
35 35 QXYSeries *DeclarativeSplineSeries::xySeries()
36 36 {
37 37 return this;
38 38 }
39 39
40 void DeclarativeSplineSeries::setAxisX(QAbstractAxis *axis)
41 {
42 chart()->setAxisX(axis,this);
43 }
44
45 QAbstractAxis *DeclarativeSplineSeries::axisX()
46 {
47 return chart()->axisX(this);
48 }
49
50 void DeclarativeSplineSeries::setAxisY(QAbstractAxis *axis)
51 {
52 chart()->setAxisY(axis,this);
53 }
54
55 QAbstractAxis *DeclarativeSplineSeries::axisY()
56 {
57 return chart()->axisY(this);
58 }
59
60 40 void DeclarativeSplineSeries::handleCountChanged(int index)
61 41 {
62 42 Q_UNUSED(index)
63 43 emit countChanged(points().count());
64 44 }
65 45
66 46 QDeclarativeListProperty<QObject> DeclarativeSplineSeries::declarativeChildren()
67 47 {
68 48 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
69 49 }
70 50
71 51 void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
72 52 {
73 53 Q_UNUSED(list)
74 54 Q_UNUSED(element)
75 55 // Empty implementation, childs are parsed in componentComplete
76 56 }
77 57
78 58 #include "moc_declarativesplineseries.cpp"
79 59
80 60 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,75 +1,69
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 "qchartglobal.h"
25 25 #include "qsplineseries.h"
26 26 #include "declarativexyseries.h"
27 27 #include "qabstractaxis.h"
28 28 #include <QDeclarativeParserStatus>
29 29 #include <QDeclarativeListProperty>
30 30 #include <QDeclarativeParserStatus>
31 31
32 32 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33 33
34 34 class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
35 35 {
36 36 Q_OBJECT
37 37 Q_INTERFACES(QDeclarativeParserStatus)
38 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX)
39 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY)
40 38 Q_PROPERTY(int count READ count NOTIFY countChanged)
41 39 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
42 40 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
43 41
44 42 public:
45 43 explicit DeclarativeSplineSeries(QObject *parent = 0);
46 44 QXYSeries *xySeries();
47 void setAxisX(QAbstractAxis *axis);
48 QAbstractAxis *axisX();
49 void setAxisY(QAbstractAxis *axis);
50 QAbstractAxis *axisY();
51 45 QDeclarativeListProperty<QObject> declarativeChildren();
52 46
53 47 public: // from QDeclarativeParserStatus
54 48 void classBegin() { DeclarativeXySeries::classBegin(); }
55 49 void componentComplete() { DeclarativeXySeries::componentComplete(); }
56 50
57 51 public:
58 52 Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); }
59 53 Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); }
60 54 Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); }
61 55 Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); }
62 56 Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); }
63 57 Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); }
64 58
65 59 Q_SIGNALS:
66 60 void countChanged(int count);
67 61
68 62 public Q_SLOTS:
69 63 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
70 64 void handleCountChanged(int index);
71 65 };
72 66
73 67 QTCOMMERCIALCHART_END_NAMESPACE
74 68
75 69 #endif // DECLARATIVESPLINESERIES_H
General Comments 0
You need to be logged in to leave comments. Login now