##// END OF EJS Templates
Removed unneeded includes from declarative plugin
Tero Ahola -
r1831:08849c38dd18
parent child
Show More
@@ -1,54 +1,55
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "declarativeareaseries.h"
21 #include "declarativeareaseries.h"
22 #include "declarativelineseries.h"
22
23
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24
25
25 DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) :
26 DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) :
26 QAreaSeries(parent),
27 QAreaSeries(parent),
27 m_axisX(0),
28 m_axisX(0),
28 m_axisY(0)
29 m_axisY(0)
29 {
30 {
30 }
31 }
31
32
32 void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries* series)
33 void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries* series)
33 {
34 {
34 QAreaSeries::setUpperSeries(series);
35 QAreaSeries::setUpperSeries(series);
35 }
36 }
36
37
37 DeclarativeLineSeries* DeclarativeAreaSeries::upperSeries() const
38 DeclarativeLineSeries* DeclarativeAreaSeries::upperSeries() const
38 {
39 {
39 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::upperSeries());
40 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::upperSeries());
40 }
41 }
41
42
42 void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries* series)
43 void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries* series)
43 {
44 {
44 QAreaSeries::setLowerSeries(series);
45 QAreaSeries::setLowerSeries(series);
45 }
46 }
46
47
47 DeclarativeLineSeries* DeclarativeAreaSeries::lowerSeries() const
48 DeclarativeLineSeries* DeclarativeAreaSeries::lowerSeries() const
48 {
49 {
49 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::lowerSeries());
50 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::lowerSeries());
50 }
51 }
51
52
52 #include "moc_declarativeareaseries.cpp"
53 #include "moc_declarativeareaseries.cpp"
53
54
54 QTCOMMERCIALCHART_END_NAMESPACE
55 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,59 +1,59
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef DECLARATIVEAREASERIES_H
21 #ifndef DECLARATIVEAREASERIES_H
22 #define DECLARATIVEAREASERIES_H
22 #define DECLARATIVEAREASERIES_H
23
23
24 #include "qareaseries.h"
24 #include "qareaseries.h"
25 #include "declarativelineseries.h"
26
25
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 class DeclarativeLineSeries;
28
28
29 class DeclarativeAreaSeries : public QAreaSeries
29 class DeclarativeAreaSeries : public QAreaSeries
30 {
30 {
31 Q_OBJECT
31 Q_OBJECT
32 Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries)
32 Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries)
33 Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries)
33 Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries)
34 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged)
34 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged)
35 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged)
35 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged)
36
36
37 public:
37 public:
38 explicit DeclarativeAreaSeries(QObject *parent = 0);
38 explicit DeclarativeAreaSeries(QObject *parent = 0);
39 void setUpperSeries(DeclarativeLineSeries* series);
39 void setUpperSeries(DeclarativeLineSeries* series);
40 DeclarativeLineSeries* upperSeries() const;
40 DeclarativeLineSeries* upperSeries() const;
41 void setLowerSeries(DeclarativeLineSeries* series);
41 void setLowerSeries(DeclarativeLineSeries* series);
42 DeclarativeLineSeries* lowerSeries() const;
42 DeclarativeLineSeries* lowerSeries() const;
43 QAbstractAxis *axisX() { return m_axisX; }
43 QAbstractAxis *axisX() { return m_axisX; }
44 void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); }
44 void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); }
45 QAbstractAxis *axisY() { return m_axisY; }
45 QAbstractAxis *axisY() { return m_axisY; }
46 void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); }
46 void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); }
47
47
48 Q_SIGNALS:
48 Q_SIGNALS:
49 void axisXChanged(QAbstractAxis *axis);
49 void axisXChanged(QAbstractAxis *axis);
50 void axisYChanged(QAbstractAxis *axis);
50 void axisYChanged(QAbstractAxis *axis);
51
51
52 private:
52 private:
53 QAbstractAxis *m_axisX;
53 QAbstractAxis *m_axisX;
54 QAbstractAxis *m_axisY;
54 QAbstractAxis *m_axisY;
55 };
55 };
56
56
57 QTCOMMERCIALCHART_END_NAMESPACE
57 QTCOMMERCIALCHART_END_NAMESPACE
58
58
59 #endif // DECLARATIVEAREASERIES_H
59 #endif // DECLARATIVEAREASERIES_H
@@ -1,418 +1,418
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "declarativebarseries.h"
21 #include "declarativebarseries.h"
22 #include <QBarSet>
22 #include "qbarset.h"
23 #include <QVBarModelMapper>
23 #include "qvbarmodelmapper.h"
24 #include <QHBarModelMapper>
24 #include "qhbarmodelmapper.h"
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 DeclarativeBarSet::DeclarativeBarSet(QObject *parent) :
28 DeclarativeBarSet::DeclarativeBarSet(QObject *parent) :
29 QBarSet("", parent)
29 QBarSet("", parent)
30 {
30 {
31 connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int, int)));
31 connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int, int)));
32 connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int)));
32 connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int)));
33 }
33 }
34
34
35 void DeclarativeBarSet::handleCountChanged(int index, int count)
35 void DeclarativeBarSet::handleCountChanged(int index, int count)
36 {
36 {
37 Q_UNUSED(index)
37 Q_UNUSED(index)
38 Q_UNUSED(count)
38 Q_UNUSED(count)
39 emit countChanged(QBarSet::count());
39 emit countChanged(QBarSet::count());
40 }
40 }
41
41
42 QVariantList DeclarativeBarSet::values()
42 QVariantList DeclarativeBarSet::values()
43 {
43 {
44 QVariantList values;
44 QVariantList values;
45 for (int i(0); i < count(); i++)
45 for (int i(0); i < count(); i++)
46 values.append(QVariant(QBarSet::at(i)));
46 values.append(QVariant(QBarSet::at(i)));
47 return values;
47 return values;
48 }
48 }
49
49
50 void DeclarativeBarSet::setValues(QVariantList values)
50 void DeclarativeBarSet::setValues(QVariantList values)
51 {
51 {
52 while (count())
52 while (count())
53 remove(count() - 1);
53 remove(count() - 1);
54
54
55 for (int i(0); i < values.count(); i++) {
55 for (int i(0); i < values.count(); i++) {
56 if (values.at(i).canConvert(QVariant::Double))
56 if (values.at(i).canConvert(QVariant::Double))
57 QBarSet::append(values[i].toDouble());
57 QBarSet::append(values[i].toDouble());
58 }
58 }
59 }
59 }
60
60
61 // Declarative bar series ======================================================================================
61 // Declarative bar series ======================================================================================
62 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
62 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
63 QBarSeries(parent),
63 QBarSeries(parent),
64 m_axisX(0),
64 m_axisX(0),
65 m_axisY(0)
65 m_axisY(0)
66 {
66 {
67 }
67 }
68
68
69 void DeclarativeBarSeries::classBegin()
69 void DeclarativeBarSeries::classBegin()
70 {
70 {
71 }
71 }
72
72
73 void DeclarativeBarSeries::componentComplete()
73 void DeclarativeBarSeries::componentComplete()
74 {
74 {
75 foreach(QObject *child, children()) {
75 foreach(QObject *child, children()) {
76 if (qobject_cast<DeclarativeBarSet *>(child)) {
76 if (qobject_cast<DeclarativeBarSet *>(child)) {
77 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
77 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
78 } else if(qobject_cast<QVBarModelMapper *>(child)) {
78 } else if(qobject_cast<QVBarModelMapper *>(child)) {
79 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
79 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
80 mapper->setSeries(this);
80 mapper->setSeries(this);
81 } else if(qobject_cast<QHBarModelMapper *>(child)) {
81 } else if(qobject_cast<QHBarModelMapper *>(child)) {
82 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
82 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
83 mapper->setSeries(this);
83 mapper->setSeries(this);
84 }
84 }
85 }
85 }
86 }
86 }
87
87
88 QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren()
88 QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren()
89 {
89 {
90 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
90 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
91 }
91 }
92
92
93 void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
93 void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
94 {
94 {
95 // Empty implementation; the children are parsed in componentComplete instead
95 // Empty implementation; the children are parsed in componentComplete instead
96 Q_UNUSED(list);
96 Q_UNUSED(list);
97 Q_UNUSED(element);
97 Q_UNUSED(element);
98 }
98 }
99
99
100 DeclarativeBarSet *DeclarativeBarSeries::at(int index)
100 DeclarativeBarSet *DeclarativeBarSeries::at(int index)
101 {
101 {
102 QList<QBarSet*> setList = barSets();
102 QList<QBarSet*> setList = barSets();
103 if (index >= 0 && index < setList.count())
103 if (index >= 0 && index < setList.count())
104 return qobject_cast<DeclarativeBarSet *>(setList[index]);
104 return qobject_cast<DeclarativeBarSet *>(setList[index]);
105
105
106 return 0;
106 return 0;
107 }
107 }
108
108
109 DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values)
109 DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values)
110 {
110 {
111 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
111 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
112 barset->setLabel(label);
112 barset->setLabel(label);
113 barset->setValues(values);
113 barset->setValues(values);
114 if (QBarSeries::insert(index, barset))
114 if (QBarSeries::insert(index, barset))
115 return barset;
115 return barset;
116 delete barset;
116 delete barset;
117 return 0;
117 return 0;
118 }
118 }
119
119
120 // Declarative stacked bar series ==============================================================================
120 // Declarative stacked bar series ==============================================================================
121 DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) :
121 DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) :
122 QStackedBarSeries(parent),
122 QStackedBarSeries(parent),
123 m_axisX(0),
123 m_axisX(0),
124 m_axisY(0)
124 m_axisY(0)
125 {
125 {
126 }
126 }
127
127
128 void DeclarativeStackedBarSeries::classBegin()
128 void DeclarativeStackedBarSeries::classBegin()
129 {
129 {
130 }
130 }
131
131
132 void DeclarativeStackedBarSeries::componentComplete()
132 void DeclarativeStackedBarSeries::componentComplete()
133 {
133 {
134 foreach(QObject *child, children()) {
134 foreach(QObject *child, children()) {
135 if (qobject_cast<DeclarativeBarSet *>(child)) {
135 if (qobject_cast<DeclarativeBarSet *>(child)) {
136 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
136 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
137 } else if(qobject_cast<QVBarModelMapper *>(child)) {
137 } else if(qobject_cast<QVBarModelMapper *>(child)) {
138 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
138 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
139 mapper->setSeries(this);
139 mapper->setSeries(this);
140 } else if(qobject_cast<QHBarModelMapper *>(child)) {
140 } else if(qobject_cast<QHBarModelMapper *>(child)) {
141 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
141 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
142 mapper->setSeries(this);
142 mapper->setSeries(this);
143 }
143 }
144 }
144 }
145 }
145 }
146
146
147
147
148 QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren()
148 QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren()
149 {
149 {
150 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
150 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
151 }
151 }
152
152
153 void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
153 void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
154 {
154 {
155 // Empty implementation; the children are parsed in componentComplete instead
155 // Empty implementation; the children are parsed in componentComplete instead
156 Q_UNUSED(list);
156 Q_UNUSED(list);
157 Q_UNUSED(element);
157 Q_UNUSED(element);
158 }
158 }
159
159
160 DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index)
160 DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index)
161 {
161 {
162 QList<QBarSet*> setList = barSets();
162 QList<QBarSet*> setList = barSets();
163 if (index >= 0 && index < setList.count())
163 if (index >= 0 && index < setList.count())
164 return qobject_cast<DeclarativeBarSet *>(setList[index]);
164 return qobject_cast<DeclarativeBarSet *>(setList[index]);
165
165
166 return 0;
166 return 0;
167 }
167 }
168
168
169 DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values)
169 DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values)
170 {
170 {
171 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
171 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
172 barset->setLabel(label);
172 barset->setLabel(label);
173 barset->setValues(values);
173 barset->setValues(values);
174 if (QStackedBarSeries::insert(index, barset))
174 if (QStackedBarSeries::insert(index, barset))
175 return barset;
175 return barset;
176 delete barset;
176 delete barset;
177 return 0;
177 return 0;
178 }
178 }
179
179
180 // Declarative percent bar series ==============================================================================
180 // Declarative percent bar series ==============================================================================
181 DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) :
181 DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) :
182 QPercentBarSeries(parent),
182 QPercentBarSeries(parent),
183 m_axisX(0),
183 m_axisX(0),
184 m_axisY(0)
184 m_axisY(0)
185 {
185 {
186 }
186 }
187
187
188 void DeclarativePercentBarSeries::classBegin()
188 void DeclarativePercentBarSeries::classBegin()
189 {
189 {
190 }
190 }
191
191
192 void DeclarativePercentBarSeries::componentComplete()
192 void DeclarativePercentBarSeries::componentComplete()
193 {
193 {
194 foreach(QObject *child, children()) {
194 foreach(QObject *child, children()) {
195 if (qobject_cast<DeclarativeBarSet *>(child)) {
195 if (qobject_cast<DeclarativeBarSet *>(child)) {
196 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
196 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
197 } else if(qobject_cast<QVBarModelMapper *>(child)) {
197 } else if(qobject_cast<QVBarModelMapper *>(child)) {
198 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
198 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
199 mapper->setSeries(this);
199 mapper->setSeries(this);
200 } else if(qobject_cast<QHBarModelMapper *>(child)) {
200 } else if(qobject_cast<QHBarModelMapper *>(child)) {
201 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
201 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
202 mapper->setSeries(this);
202 mapper->setSeries(this);
203 }
203 }
204 }
204 }
205 }
205 }
206
206
207 QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren()
207 QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren()
208 {
208 {
209 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
209 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
210 }
210 }
211
211
212 void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
212 void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
213 {
213 {
214 // Empty implementation; the children are parsed in componentComplete instead
214 // Empty implementation; the children are parsed in componentComplete instead
215 Q_UNUSED(list);
215 Q_UNUSED(list);
216 Q_UNUSED(element);
216 Q_UNUSED(element);
217 }
217 }
218
218
219 DeclarativeBarSet *DeclarativePercentBarSeries::at(int index)
219 DeclarativeBarSet *DeclarativePercentBarSeries::at(int index)
220 {
220 {
221 QList<QBarSet*> setList = barSets();
221 QList<QBarSet*> setList = barSets();
222 if (index >= 0 && index < setList.count())
222 if (index >= 0 && index < setList.count())
223 return qobject_cast<DeclarativeBarSet *>(setList[index]);
223 return qobject_cast<DeclarativeBarSet *>(setList[index]);
224
224
225 return 0;
225 return 0;
226 }
226 }
227
227
228 DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values)
228 DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values)
229 {
229 {
230 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
230 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
231 barset->setLabel(label);
231 barset->setLabel(label);
232 barset->setValues(values);
232 barset->setValues(values);
233 if (QPercentBarSeries::insert(index, barset))
233 if (QPercentBarSeries::insert(index, barset))
234 return barset;
234 return barset;
235 delete barset;
235 delete barset;
236 return 0;
236 return 0;
237 }
237 }
238
238
239 // Declarative horizontal bar series ===========================================================================
239 // Declarative horizontal bar series ===========================================================================
240 DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QDeclarativeItem *parent) :
240 DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QDeclarativeItem *parent) :
241 QHorizontalBarSeries(parent),
241 QHorizontalBarSeries(parent),
242 m_axisX(0),
242 m_axisX(0),
243 m_axisY(0)
243 m_axisY(0)
244 {
244 {
245 }
245 }
246
246
247 void DeclarativeHorizontalBarSeries::classBegin()
247 void DeclarativeHorizontalBarSeries::classBegin()
248 {
248 {
249 }
249 }
250
250
251 void DeclarativeHorizontalBarSeries::componentComplete()
251 void DeclarativeHorizontalBarSeries::componentComplete()
252 {
252 {
253 foreach(QObject *child, children()) {
253 foreach(QObject *child, children()) {
254 if (qobject_cast<DeclarativeBarSet *>(child)) {
254 if (qobject_cast<DeclarativeBarSet *>(child)) {
255 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
255 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
256 } else if(qobject_cast<QVBarModelMapper *>(child)) {
256 } else if(qobject_cast<QVBarModelMapper *>(child)) {
257 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
257 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
258 mapper->setSeries(this);
258 mapper->setSeries(this);
259 } else if(qobject_cast<QHBarModelMapper *>(child)) {
259 } else if(qobject_cast<QHBarModelMapper *>(child)) {
260 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
260 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
261 mapper->setSeries(this);
261 mapper->setSeries(this);
262 }
262 }
263 }
263 }
264 }
264 }
265
265
266 QDeclarativeListProperty<QObject> DeclarativeHorizontalBarSeries::seriesChildren()
266 QDeclarativeListProperty<QObject> DeclarativeHorizontalBarSeries::seriesChildren()
267 {
267 {
268 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren);
268 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren);
269 }
269 }
270
270
271 void DeclarativeHorizontalBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
271 void DeclarativeHorizontalBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
272 {
272 {
273 // Empty implementation; the children are parsed in componentComplete instead
273 // Empty implementation; the children are parsed in componentComplete instead
274 Q_UNUSED(list);
274 Q_UNUSED(list);
275 Q_UNUSED(element);
275 Q_UNUSED(element);
276 }
276 }
277
277
278 DeclarativeBarSet *DeclarativeHorizontalBarSeries::at(int index)
278 DeclarativeBarSet *DeclarativeHorizontalBarSeries::at(int index)
279 {
279 {
280 QList<QBarSet*> setList = barSets();
280 QList<QBarSet*> setList = barSets();
281 if (index >= 0 && index < setList.count())
281 if (index >= 0 && index < setList.count())
282 return qobject_cast<DeclarativeBarSet *>(setList[index]);
282 return qobject_cast<DeclarativeBarSet *>(setList[index]);
283
283
284 return 0;
284 return 0;
285 }
285 }
286
286
287 DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString label, QVariantList values)
287 DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString label, QVariantList values)
288 {
288 {
289 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
289 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
290 barset->setLabel(label);
290 barset->setLabel(label);
291 barset->setValues(values);
291 barset->setValues(values);
292 if (QHorizontalBarSeries::insert(index, barset))
292 if (QHorizontalBarSeries::insert(index, barset))
293 return barset;
293 return barset;
294 delete barset;
294 delete barset;
295 return 0;
295 return 0;
296 }
296 }
297
297
298 // Declarative horizontal stacked bar series ===================================================================
298 // Declarative horizontal stacked bar series ===================================================================
299 DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent) :
299 DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent) :
300 QHorizontalStackedBarSeries(parent),
300 QHorizontalStackedBarSeries(parent),
301 m_axisX(0),
301 m_axisX(0),
302 m_axisY(0)
302 m_axisY(0)
303 {
303 {
304 }
304 }
305
305
306 void DeclarativeHorizontalStackedBarSeries::classBegin()
306 void DeclarativeHorizontalStackedBarSeries::classBegin()
307 {
307 {
308 }
308 }
309
309
310 void DeclarativeHorizontalStackedBarSeries::componentComplete()
310 void DeclarativeHorizontalStackedBarSeries::componentComplete()
311 {
311 {
312 foreach(QObject *child, children()) {
312 foreach(QObject *child, children()) {
313 if (qobject_cast<DeclarativeBarSet *>(child)) {
313 if (qobject_cast<DeclarativeBarSet *>(child)) {
314 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
314 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
315 } else if(qobject_cast<QVBarModelMapper *>(child)) {
315 } else if(qobject_cast<QVBarModelMapper *>(child)) {
316 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
316 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
317 mapper->setSeries(this);
317 mapper->setSeries(this);
318 } else if(qobject_cast<QHBarModelMapper *>(child)) {
318 } else if(qobject_cast<QHBarModelMapper *>(child)) {
319 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
319 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
320 mapper->setSeries(this);
320 mapper->setSeries(this);
321 }
321 }
322 }
322 }
323 }
323 }
324
324
325 QDeclarativeListProperty<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren()
325 QDeclarativeListProperty<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren()
326 {
326 {
327 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren);
327 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren);
328 }
328 }
329
329
330 void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
330 void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
331 {
331 {
332 // Empty implementation; the children are parsed in componentComplete instead
332 // Empty implementation; the children are parsed in componentComplete instead
333 Q_UNUSED(list);
333 Q_UNUSED(list);
334 Q_UNUSED(element);
334 Q_UNUSED(element);
335 }
335 }
336
336
337 DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::at(int index)
337 DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::at(int index)
338 {
338 {
339 QList<QBarSet*> setList = barSets();
339 QList<QBarSet*> setList = barSets();
340 if (index >= 0 && index < setList.count())
340 if (index >= 0 && index < setList.count())
341 return qobject_cast<DeclarativeBarSet *>(setList[index]);
341 return qobject_cast<DeclarativeBarSet *>(setList[index]);
342
342
343 return 0;
343 return 0;
344 }
344 }
345
345
346 DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QString label, QVariantList values)
346 DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QString label, QVariantList values)
347 {
347 {
348 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
348 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
349 barset->setLabel(label);
349 barset->setLabel(label);
350 barset->setValues(values);
350 barset->setValues(values);
351 if (QHorizontalStackedBarSeries::insert(index, barset))
351 if (QHorizontalStackedBarSeries::insert(index, barset))
352 return barset;
352 return barset;
353 delete barset;
353 delete barset;
354 return 0;
354 return 0;
355 }
355 }
356
356
357 // Declarative horizontal percent bar series ===================================================================
357 // Declarative horizontal percent bar series ===================================================================
358 DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent) :
358 DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent) :
359 QHorizontalPercentBarSeries(parent),
359 QHorizontalPercentBarSeries(parent),
360 m_axisX(0),
360 m_axisX(0),
361 m_axisY(0)
361 m_axisY(0)
362 {
362 {
363 }
363 }
364
364
365 void DeclarativeHorizontalPercentBarSeries::classBegin()
365 void DeclarativeHorizontalPercentBarSeries::classBegin()
366 {
366 {
367 }
367 }
368
368
369 void DeclarativeHorizontalPercentBarSeries::componentComplete()
369 void DeclarativeHorizontalPercentBarSeries::componentComplete()
370 {
370 {
371 foreach(QObject *child, children()) {
371 foreach(QObject *child, children()) {
372 if (qobject_cast<DeclarativeBarSet *>(child)) {
372 if (qobject_cast<DeclarativeBarSet *>(child)) {
373 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
373 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
374 } else if(qobject_cast<QVBarModelMapper *>(child)) {
374 } else if(qobject_cast<QVBarModelMapper *>(child)) {
375 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
375 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
376 mapper->setSeries(this);
376 mapper->setSeries(this);
377 } else if(qobject_cast<QHBarModelMapper *>(child)) {
377 } else if(qobject_cast<QHBarModelMapper *>(child)) {
378 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
378 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
379 mapper->setSeries(this);
379 mapper->setSeries(this);
380 }
380 }
381 }
381 }
382 }
382 }
383
383
384 QDeclarativeListProperty<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren()
384 QDeclarativeListProperty<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren()
385 {
385 {
386 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren);
386 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren);
387 }
387 }
388
388
389 void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
389 void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
390 {
390 {
391 // Empty implementation; the children are parsed in componentComplete instead
391 // Empty implementation; the children are parsed in componentComplete instead
392 Q_UNUSED(list);
392 Q_UNUSED(list);
393 Q_UNUSED(element);
393 Q_UNUSED(element);
394 }
394 }
395
395
396 DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::at(int index)
396 DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::at(int index)
397 {
397 {
398 QList<QBarSet*> setList = barSets();
398 QList<QBarSet*> setList = barSets();
399 if (index >= 0 && index < setList.count())
399 if (index >= 0 && index < setList.count())
400 return qobject_cast<DeclarativeBarSet *>(setList[index]);
400 return qobject_cast<DeclarativeBarSet *>(setList[index]);
401
401
402 return 0;
402 return 0;
403 }
403 }
404
404
405 DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::insert(int index, QString label, QVariantList values)
405 DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::insert(int index, QString label, QVariantList values)
406 {
406 {
407 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
407 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
408 barset->setLabel(label);
408 barset->setLabel(label);
409 barset->setValues(values);
409 barset->setValues(values);
410 if (QHorizontalPercentBarSeries::insert(index, barset))
410 if (QHorizontalPercentBarSeries::insert(index, barset))
411 return barset;
411 return barset;
412 delete barset;
412 delete barset;
413 return 0;
413 return 0;
414 }
414 }
415
415
416 #include "moc_declarativebarseries.cpp"
416 #include "moc_declarativebarseries.cpp"
417
417
418 QTCOMMERCIALCHART_END_NAMESPACE
418 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,159 +1,158
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef DECLARATIVECHART_H
21 #ifndef DECLARATIVECHART_H
22 #define DECLARATIVECHART_H
22 #define DECLARATIVECHART_H
23
23
24 #include <QtCore/QtGlobal>
24 #include <QtCore/QtGlobal>
25 #include <QDeclarativeItem>
25 #include <QDeclarativeItem>
26 #include <qchart.h>
26 #include "qchart.h"
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 class DeclarativeChart : public QDeclarativeItem
30 class DeclarativeChart : public QDeclarativeItem
31 // TODO: for QTQUICK2: extend QQuickPainterItem instead
31 // TODO: for QTQUICK2: extend QQuickPainterItem instead
32 //class DeclarativeChart : public QQuickPaintedItem, public Chart
32 //class DeclarativeChart : public QQuickPaintedItem, public Chart
33 {
33 {
34 Q_OBJECT
34 Q_OBJECT
35 Q_PROPERTY(Theme theme READ theme WRITE setTheme)
35 Q_PROPERTY(Theme theme READ theme WRITE setTheme)
36 Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions)
36 Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions)
37 Q_PROPERTY(QString title READ title WRITE setTitle)
37 Q_PROPERTY(QString title READ title WRITE setTitle)
38 Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont)
38 Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont)
39 Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged)
39 Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged)
40 Q_PROPERTY(QLegend *legend READ legend)
40 Q_PROPERTY(QLegend *legend READ legend)
41 Q_PROPERTY(int count READ count)
41 Q_PROPERTY(int count READ count)
42 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
42 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
43 Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged)
43 Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged)
44 Q_PROPERTY(qreal topMargin READ topMargin NOTIFY topMarginChanged)
44 Q_PROPERTY(qreal topMargin READ topMargin NOTIFY topMarginChanged)
45 Q_PROPERTY(qreal bottomMargin READ bottomMargin NOTIFY bottomMarginChanged)
45 Q_PROPERTY(qreal bottomMargin READ bottomMargin NOTIFY bottomMarginChanged)
46 Q_PROPERTY(qreal leftMargin READ leftMargin NOTIFY leftMarginChanged)
46 Q_PROPERTY(qreal leftMargin READ leftMargin NOTIFY leftMarginChanged)
47 Q_PROPERTY(qreal rightMargin READ rightMargin NOTIFY rightMarginChanged)
47 Q_PROPERTY(qreal rightMargin READ rightMargin NOTIFY rightMarginChanged)
48 Q_ENUMS(Animation)
48 Q_ENUMS(Animation)
49 Q_ENUMS(Theme)
49 Q_ENUMS(Theme)
50 Q_ENUMS(SeriesType)
50 Q_ENUMS(SeriesType)
51 // Q_ENUMS(AxisType)
52
51
53 public:
52 public:
54 // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api
53 // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api
55 enum Theme {
54 enum Theme {
56 ChartThemeLight = 0,
55 ChartThemeLight = 0,
57 ChartThemeBlueCerulean,
56 ChartThemeBlueCerulean,
58 ChartThemeDark,
57 ChartThemeDark,
59 ChartThemeBrownSand,
58 ChartThemeBrownSand,
60 ChartThemeBlueNcs,
59 ChartThemeBlueNcs,
61 ChartThemeHighContrast,
60 ChartThemeHighContrast,
62 ChartThemeBlueIcy
61 ChartThemeBlueIcy
63 };
62 };
64
63
65 enum Animation {
64 enum Animation {
66 NoAnimation = 0x0,
65 NoAnimation = 0x0,
67 GridAxisAnimations = 0x1,
66 GridAxisAnimations = 0x1,
68 SeriesAnimations =0x2,
67 SeriesAnimations =0x2,
69 AllAnimations = 0x3
68 AllAnimations = 0x3
70 };
69 };
71
70
72 enum SeriesType {
71 enum SeriesType {
73 SeriesTypeLine,
72 SeriesTypeLine,
74 SeriesTypeArea,
73 SeriesTypeArea,
75 SeriesTypeBar,
74 SeriesTypeBar,
76 SeriesTypeStackedBar,
75 SeriesTypeStackedBar,
77 SeriesTypePercentBar,
76 SeriesTypePercentBar,
78 SeriesTypePie,
77 SeriesTypePie,
79 SeriesTypeScatter,
78 SeriesTypeScatter,
80 SeriesTypeSpline,
79 SeriesTypeSpline,
81 SeriesTypeHorizontalBar,
80 SeriesTypeHorizontalBar,
82 SeriesTypeHorizontalStackedBar,
81 SeriesTypeHorizontalStackedBar,
83 SeriesTypeHorizontalPercentBar
82 SeriesTypeHorizontalPercentBar
84 };
83 };
85
84
86 public:
85 public:
87 DeclarativeChart(QDeclarativeItem *parent = 0);
86 DeclarativeChart(QDeclarativeItem *parent = 0);
88 ~DeclarativeChart();
87 ~DeclarativeChart();
89
88
90 public: // From QDeclarativeItem/QGraphicsItem
89 public: // From QDeclarativeItem/QGraphicsItem
91 void childEvent(QChildEvent *event);
90 void childEvent(QChildEvent *event);
92 void componentComplete();
91 void componentComplete();
93 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
92 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
94 void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
93 void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
95
94
96 public:
95 public:
97 void setTheme(DeclarativeChart::Theme theme);
96 void setTheme(DeclarativeChart::Theme theme);
98 DeclarativeChart::Theme theme();
97 DeclarativeChart::Theme theme();
99 void setAnimationOptions(DeclarativeChart::Animation animations);
98 void setAnimationOptions(DeclarativeChart::Animation animations);
100 DeclarativeChart::Animation animationOptions();
99 DeclarativeChart::Animation animationOptions();
101 void setTitle(QString title);
100 void setTitle(QString title);
102 QString title();
101 QString title();
103 QLegend *legend();
102 QLegend *legend();
104 QFont titleFont() const;
103 QFont titleFont() const;
105 void setTitleFont(const QFont& font);
104 void setTitleFont(const QFont& font);
106 void setTitleColor(QColor color);
105 void setTitleColor(QColor color);
107 QColor titleColor();
106 QColor titleColor();
108 void setBackgroundColor(QColor color);
107 void setBackgroundColor(QColor color);
109 QColor backgroundColor();
108 QColor backgroundColor();
110 int count();
109 int count();
111 void setDropShadowEnabled(bool enabled);
110 void setDropShadowEnabled(bool enabled);
112 bool dropShadowEnabled();
111 bool dropShadowEnabled();
113 qreal topMargin();
112 qreal topMargin();
114 qreal bottomMargin();
113 qreal bottomMargin();
115 qreal leftMargin();
114 qreal leftMargin();
116 qreal rightMargin();
115 qreal rightMargin();
117 void createDefaultAxes(QAbstractSeries* series);
116 void createDefaultAxes(QAbstractSeries* series);
118
117
119 public:
118 public:
120 Q_INVOKABLE QAbstractSeries *series(int index);
119 Q_INVOKABLE QAbstractSeries *series(int index);
121 Q_INVOKABLE QAbstractSeries *series(QString seriesName);
120 Q_INVOKABLE QAbstractSeries *series(QString seriesName);
122 Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = "");
121 Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = "");
123 Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0);
122 Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0);
124 Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0);
123 Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0);
125 Q_INVOKABLE void createDefaultAxes();
124 Q_INVOKABLE void createDefaultAxes();
126 Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0);
125 Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0);
127 Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0);
126 Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0);
128
127
129 Q_INVOKABLE void zoom(qreal factor);
128 Q_INVOKABLE void zoom(qreal factor);
130 Q_INVOKABLE void scrollLeft(qreal pixels);
129 Q_INVOKABLE void scrollLeft(qreal pixels);
131 Q_INVOKABLE void scrollRight(qreal pixels);
130 Q_INVOKABLE void scrollRight(qreal pixels);
132 Q_INVOKABLE void scrollUp(qreal pixels);
131 Q_INVOKABLE void scrollUp(qreal pixels);
133 Q_INVOKABLE void scrollDown(qreal pixels);
132 Q_INVOKABLE void scrollDown(qreal pixels);
134
133
135 Q_SIGNALS:
134 Q_SIGNALS:
136 void axisLabelsChanged();
135 void axisLabelsChanged();
137 void titleColorChanged(QColor color);
136 void titleColorChanged(QColor color);
138 void backgroundColorChanged();
137 void backgroundColorChanged();
139 void dropShadowEnabledChanged(bool enabled);
138 void dropShadowEnabledChanged(bool enabled);
140 void topMarginChanged(qreal margin);
139 void topMarginChanged(qreal margin);
141 void bottomMarginChanged(qreal margin);
140 void bottomMarginChanged(qreal margin);
142 void leftMarginChanged(qreal margin);
141 void leftMarginChanged(qreal margin);
143 void rightMarginChanged(qreal margin);
142 void rightMarginChanged(qreal margin);
144
143
145 public Q_SLOTS:
144 public Q_SLOTS:
146 void handleMarginsChanged(QRectF newMargins);
145 void handleMarginsChanged(QRectF newMargins);
147 void handleAxisXSet(QAbstractAxis *axis);
146 void handleAxisXSet(QAbstractAxis *axis);
148 void handleAxisYSet(QAbstractAxis *axis);
147 void handleAxisYSet(QAbstractAxis *axis);
149
148
150 private:
149 private:
151 // Extending QChart with DeclarativeChart is not possible because QObject does not support
150 // Extending QChart with DeclarativeChart is not possible because QObject does not support
152 // multi inheritance, so we now have a QChart as a member instead
151 // multi inheritance, so we now have a QChart as a member instead
153 QChart *m_chart;
152 QChart *m_chart;
154 QRectF m_chartMargins;
153 QRectF m_chartMargins;
155 };
154 };
156
155
157 QTCOMMERCIALCHART_END_NAMESPACE
156 QTCOMMERCIALCHART_END_NAMESPACE
158
157
159 #endif // DECLARATIVECHART_H
158 #endif // DECLARATIVECHART_H
@@ -1,117 +1,118
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "declarativepieseries.h"
21 #include "declarativepieseries.h"
22 #include <QVPieModelMapper>
22 #include "qpieslice.h"
23 #include <QHPieModelMapper>
23 #include "qvpiemodelmapper.h"
24 #include "qhpiemodelmapper.h"
24
25
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26
27
27 DeclarativePieSeries::DeclarativePieSeries(QDeclarativeItem *parent) :
28 DeclarativePieSeries::DeclarativePieSeries(QDeclarativeItem *parent) :
28 QPieSeries(parent)
29 QPieSeries(parent)
29 {
30 {
30 connect(this, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleAdded(QList<QPieSlice*>)));
31 connect(this, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleAdded(QList<QPieSlice*>)));
31 connect(this, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleRemoved(QList<QPieSlice*>)));
32 connect(this, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleRemoved(QList<QPieSlice*>)));
32 }
33 }
33
34
34 void DeclarativePieSeries::classBegin()
35 void DeclarativePieSeries::classBegin()
35 {
36 {
36 }
37 }
37
38
38 void DeclarativePieSeries::componentComplete()
39 void DeclarativePieSeries::componentComplete()
39 {
40 {
40 foreach(QObject *child, children()) {
41 foreach(QObject *child, children()) {
41 if (qobject_cast<QPieSlice *>(child)) {
42 if (qobject_cast<QPieSlice *>(child)) {
42 QPieSeries::append(qobject_cast<QPieSlice *>(child));
43 QPieSeries::append(qobject_cast<QPieSlice *>(child));
43 } else if(qobject_cast<QVPieModelMapper *>(child)) {
44 } else if(qobject_cast<QVPieModelMapper *>(child)) {
44 QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child);
45 QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child);
45 mapper->setSeries(this);
46 mapper->setSeries(this);
46 } else if(qobject_cast<QHPieModelMapper *>(child)) {
47 } else if(qobject_cast<QHPieModelMapper *>(child)) {
47 QHPieModelMapper *mapper = qobject_cast<QHPieModelMapper *>(child);
48 QHPieModelMapper *mapper = qobject_cast<QHPieModelMapper *>(child);
48 mapper->setSeries(this);
49 mapper->setSeries(this);
49 }
50 }
50 }
51 }
51 }
52 }
52
53
53 QDeclarativeListProperty<QObject> DeclarativePieSeries::seriesChildren()
54 QDeclarativeListProperty<QObject> DeclarativePieSeries::seriesChildren()
54 {
55 {
55 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativePieSeries::appendSeriesChildren);
56 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativePieSeries::appendSeriesChildren);
56 }
57 }
57
58
58 void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
59 void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
59 {
60 {
60 // Empty implementation; the children are parsed in componentComplete instead
61 // Empty implementation; the children are parsed in componentComplete instead
61 Q_UNUSED(list);
62 Q_UNUSED(list);
62 Q_UNUSED(element);
63 Q_UNUSED(element);
63 }
64 }
64
65
65 QPieSlice *DeclarativePieSeries::at(int index)
66 QPieSlice *DeclarativePieSeries::at(int index)
66 {
67 {
67 QList<QPieSlice*> sliceList = slices();
68 QList<QPieSlice*> sliceList = slices();
68 if (index >= 0 && index < sliceList.count())
69 if (index >= 0 && index < sliceList.count())
69 return sliceList[index];
70 return sliceList[index];
70
71
71 return 0;
72 return 0;
72 }
73 }
73
74
74 QPieSlice* DeclarativePieSeries::find(QString label)
75 QPieSlice* DeclarativePieSeries::find(QString label)
75 {
76 {
76 foreach (QPieSlice *slice, slices()) {
77 foreach (QPieSlice *slice, slices()) {
77 if (slice->label() == label)
78 if (slice->label() == label)
78 return slice;
79 return slice;
79 }
80 }
80 return 0;
81 return 0;
81 }
82 }
82
83
83 QPieSlice* DeclarativePieSeries::append(QString label, qreal value)
84 QPieSlice* DeclarativePieSeries::append(QString label, qreal value)
84 {
85 {
85 // TODO: parameter order is wrong, switch it:
86 // TODO: parameter order is wrong, switch it:
86 QPieSlice *slice = new QPieSlice(this);
87 QPieSlice *slice = new QPieSlice(this);
87 slice->setLabel(label);
88 slice->setLabel(label);
88 slice->setValue(value);
89 slice->setValue(value);
89 QPieSeries::append(slice);
90 QPieSeries::append(slice);
90 return slice;
91 return slice;
91 }
92 }
92
93
93 bool DeclarativePieSeries::remove(QPieSlice *slice)
94 bool DeclarativePieSeries::remove(QPieSlice *slice)
94 {
95 {
95 return QPieSeries::remove(slice);
96 return QPieSeries::remove(slice);
96 }
97 }
97
98
98 void DeclarativePieSeries::clear()
99 void DeclarativePieSeries::clear()
99 {
100 {
100 QPieSeries::clear();
101 QPieSeries::clear();
101 }
102 }
102
103
103 void DeclarativePieSeries::handleAdded(QList<QPieSlice*> slices)
104 void DeclarativePieSeries::handleAdded(QList<QPieSlice*> slices)
104 {
105 {
105 foreach(QPieSlice *slice, slices)
106 foreach(QPieSlice *slice, slices)
106 emit sliceAdded(slice);
107 emit sliceAdded(slice);
107 }
108 }
108
109
109 void DeclarativePieSeries::handleRemoved(QList<QPieSlice*> slices)
110 void DeclarativePieSeries::handleRemoved(QList<QPieSlice*> slices)
110 {
111 {
111 foreach(QPieSlice *slice, slices)
112 foreach(QPieSlice *slice, slices)
112 emit sliceRemoved(slice);
113 emit sliceRemoved(slice);
113 }
114 }
114
115
115 #include "moc_declarativepieseries.cpp"
116 #include "moc_declarativepieseries.cpp"
116
117
117 QTCOMMERCIALCHART_END_NAMESPACE
118 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,63 +1,63
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef DECLARATIVEPIESERIES_H
21 #ifndef DECLARATIVEPIESERIES_H
22 #define DECLARATIVEPIESERIES_H
22 #define DECLARATIVEPIESERIES_H
23
23
24 #include "qpieslice.h"
25 #include "qpieseries.h"
24 #include "qpieseries.h"
26 #include <QDeclarativeItem>
25 #include <QDeclarativeItem>
27 #include <QDeclarativeParserStatus>
26 #include <QDeclarativeParserStatus>
28
27
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 class QPieSlice;
30
30
31 class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus
31 class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus
32 {
32 {
33 Q_OBJECT
33 Q_OBJECT
34 Q_INTERFACES(QDeclarativeParserStatus)
34 Q_INTERFACES(QDeclarativeParserStatus)
35 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
35 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
36 Q_CLASSINFO("DefaultProperty", "seriesChildren")
36 Q_CLASSINFO("DefaultProperty", "seriesChildren")
37
37
38 public:
38 public:
39 explicit DeclarativePieSeries(QDeclarativeItem *parent = 0);
39 explicit DeclarativePieSeries(QDeclarativeItem *parent = 0);
40 QDeclarativeListProperty<QObject> seriesChildren();
40 QDeclarativeListProperty<QObject> seriesChildren();
41 Q_INVOKABLE QPieSlice *at(int index);
41 Q_INVOKABLE QPieSlice *at(int index);
42 Q_INVOKABLE QPieSlice *find(QString label);
42 Q_INVOKABLE QPieSlice *find(QString label);
43 Q_INVOKABLE QPieSlice *append(QString label, qreal value);
43 Q_INVOKABLE QPieSlice *append(QString label, qreal value);
44 Q_INVOKABLE bool remove(QPieSlice *slice);
44 Q_INVOKABLE bool remove(QPieSlice *slice);
45 Q_INVOKABLE void clear();
45 Q_INVOKABLE void clear();
46
46
47 public:
47 public:
48 void classBegin();
48 void classBegin();
49 void componentComplete();
49 void componentComplete();
50
50
51 Q_SIGNALS:
51 Q_SIGNALS:
52 void sliceAdded(QPieSlice* slice);
52 void sliceAdded(QPieSlice* slice);
53 void sliceRemoved(QPieSlice* slice);
53 void sliceRemoved(QPieSlice* slice);
54
54
55 public Q_SLOTS:
55 public Q_SLOTS:
56 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
56 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
57 void handleAdded(QList<QPieSlice*> slices);
57 void handleAdded(QList<QPieSlice*> slices);
58 void handleRemoved(QList<QPieSlice*> slices);
58 void handleRemoved(QList<QPieSlice*> slices);
59 };
59 };
60
60
61 QTCOMMERCIALCHART_END_NAMESPACE
61 QTCOMMERCIALCHART_END_NAMESPACE
62
62
63 #endif // DECLARATIVEPIESERIES_H
63 #endif // DECLARATIVEPIESERIES_H
@@ -1,51 +1,52
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "declarativexypoint.h"
21 #include "declarativexypoint.h"
22 #include <QDataStream>
22
23
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24
25
25 /*!
26 /*!
26 \qmlclass XYPoint QPointF
27 \qmlclass XYPoint QPointF
27 XYPoint is a convenience element for initializing XY-series with static coordinate data. To
28 XYPoint is a convenience element for initializing XY-series with static coordinate data. To
28 manipulate an XY-series dynamically, use it's data manipulation functions instead.
29 manipulate an XY-series dynamically, use it's data manipulation functions instead.
29 \sa LineSeries, AreaSeries, ScatterSeries, SplineSeries
30 \sa LineSeries, AreaSeries, ScatterSeries, SplineSeries
30 */
31 */
31
32
32 /*!
33 /*!
33 \qmlproperty real XYPoint::x
34 \qmlproperty real XYPoint::x
34 The x-coordinate of the point.
35 The x-coordinate of the point.
35 */
36 */
36
37
37 /*!
38 /*!
38 \qmlproperty real XYPoint::y
39 \qmlproperty real XYPoint::y
39 The y-coordinate of the point.
40 The y-coordinate of the point.
40 */
41 */
41
42
42 DeclarativeXYPoint::DeclarativeXYPoint(QObject *parent) :
43 DeclarativeXYPoint::DeclarativeXYPoint(QObject *parent) :
43 QObject(parent)
44 QObject(parent)
44 {
45 {
45 setX(0.0);
46 setX(0.0);
46 setY(0.0);
47 setY(0.0);
47 }
48 }
48
49
49 #include "moc_declarativexypoint.cpp"
50 #include "moc_declarativexypoint.cpp"
50
51
51 QTCOMMERCIALCHART_END_NAMESPACE
52 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,44 +1,43
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef DECLARATIVE_XY_POINT_H
21 #ifndef DECLARATIVE_XY_POINT_H
22 #define DECLARATIVE_XY_POINT_H
22 #define DECLARATIVE_XY_POINT_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include <QObject>
25 #include <QObject>
26 #include <QPointF>
26 #include <QPointF>
27 #include <QDataStream>
28
27
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
29
31 class DeclarativeXYPoint : public QObject, public QPointF
30 class DeclarativeXYPoint : public QObject, public QPointF
32 {
31 {
33 Q_OBJECT
32 Q_OBJECT
34 // TODO: make the setters change the value, if parented by a series
33 // TODO: make the setters change the value, if parented by a series
35 Q_PROPERTY(qreal x READ x WRITE setX /*NOTIFY dataXChanged*/)
34 Q_PROPERTY(qreal x READ x WRITE setX /*NOTIFY dataXChanged*/)
36 Q_PROPERTY(qreal y READ y WRITE setY /*NOTIFY dataYChanged*/)
35 Q_PROPERTY(qreal y READ y WRITE setY /*NOTIFY dataYChanged*/)
37
36
38 public:
37 public:
39 explicit DeclarativeXYPoint(QObject *parent = 0);
38 explicit DeclarativeXYPoint(QObject *parent = 0);
40 };
39 };
41
40
42 QTCOMMERCIALCHART_END_NAMESPACE
41 QTCOMMERCIALCHART_END_NAMESPACE
43
42
44 #endif // DECLARATIVE_XY_POINT_H
43 #endif // DECLARATIVE_XY_POINT_H
@@ -1,103 +1,104
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21
21
22 #include "declarativexyseries.h"
22 #include "declarativexyseries.h"
23 #include <QVXYModelMapper>
23 #include "declarativexypoint.h"
24 #include <QHXYModelMapper>
24 #include "qvxymodelmapper.h"
25 #include "qhxymodelmapper.h"
25
26
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
28
28 DeclarativeXySeries::DeclarativeXySeries()
29 DeclarativeXySeries::DeclarativeXySeries()
29 {
30 {
30 }
31 }
31
32
32 DeclarativeXySeries::~DeclarativeXySeries()
33 DeclarativeXySeries::~DeclarativeXySeries()
33 {
34 {
34 }
35 }
35
36
36 void DeclarativeXySeries::classBegin()
37 void DeclarativeXySeries::classBegin()
37 {
38 {
38 }
39 }
39
40
40 void DeclarativeXySeries::componentComplete()
41 void DeclarativeXySeries::componentComplete()
41 {
42 {
42 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
43 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
43 Q_ASSERT(series);
44 Q_ASSERT(series);
44
45
45 foreach(QObject *child, series->children()) {
46 foreach(QObject *child, series->children()) {
46 if (qobject_cast<DeclarativeXYPoint *>(child)) {
47 if (qobject_cast<DeclarativeXYPoint *>(child)) {
47 DeclarativeXYPoint *point = qobject_cast<DeclarativeXYPoint *>(child);
48 DeclarativeXYPoint *point = qobject_cast<DeclarativeXYPoint *>(child);
48 series->append(point->x(), point->y());
49 series->append(point->x(), point->y());
49 } else if(qobject_cast<QVXYModelMapper *>(child)) {
50 } else if(qobject_cast<QVXYModelMapper *>(child)) {
50 QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child);
51 QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child);
51 mapper->setSeries(series);
52 mapper->setSeries(series);
52 } else if(qobject_cast<QHXYModelMapper *>(child)) {
53 } else if(qobject_cast<QHXYModelMapper *>(child)) {
53 QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child);
54 QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child);
54 mapper->setSeries(series);
55 mapper->setSeries(series);
55 }
56 }
56 }
57 }
57 }
58 }
58
59
59 void DeclarativeXySeries::append(qreal x, qreal y)
60 void DeclarativeXySeries::append(qreal x, qreal y)
60 {
61 {
61 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
62 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
62 Q_ASSERT(series);
63 Q_ASSERT(series);
63 series->append(x, y);
64 series->append(x, y);
64 }
65 }
65
66
66 void DeclarativeXySeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY)
67 void DeclarativeXySeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY)
67 {
68 {
68 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
69 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
69 Q_ASSERT(series);
70 Q_ASSERT(series);
70 series->replace(oldX, oldY, newX, newY);
71 series->replace(oldX, oldY, newX, newY);
71 }
72 }
72
73
73 void DeclarativeXySeries::remove(qreal x, qreal y)
74 void DeclarativeXySeries::remove(qreal x, qreal y)
74 {
75 {
75 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
76 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
76 Q_ASSERT(series);
77 Q_ASSERT(series);
77 series->remove(x, y);
78 series->remove(x, y);
78 }
79 }
79
80
80 void DeclarativeXySeries::insert(int index, qreal x, qreal y)
81 void DeclarativeXySeries::insert(int index, qreal x, qreal y)
81 {
82 {
82 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
83 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
83 Q_ASSERT(series);
84 Q_ASSERT(series);
84 series->insert(index, QPointF(x, y));
85 series->insert(index, QPointF(x, y));
85 }
86 }
86
87
87 void DeclarativeXySeries::clear()
88 void DeclarativeXySeries::clear()
88 {
89 {
89 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
90 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
90 Q_ASSERT(series);
91 Q_ASSERT(series);
91 series->clear();
92 series->clear();
92 }
93 }
93
94
94 QPointF DeclarativeXySeries::at(int index)
95 QPointF DeclarativeXySeries::at(int index)
95 {
96 {
96 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
97 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
97 Q_ASSERT(series);
98 Q_ASSERT(series);
98 if (index >= 0 || index < series->count())
99 if (index >= 0 || index < series->count())
99 return series->points().at(index);
100 return series->points().at(index);
100 return QPointF(0, 0);
101 return QPointF(0, 0);
101 }
102 }
102
103
103 QTCOMMERCIALCHART_END_NAMESPACE
104 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,53 +1,52
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef DECLARATIVE_XY_SERIES_H
21 #ifndef DECLARATIVE_XY_SERIES_H
22 #define DECLARATIVE_XY_SERIES_H
22 #define DECLARATIVE_XY_SERIES_H
23
23
24 #include "declarativexypoint.h"
25 #include <QXYSeries>
24 #include <QXYSeries>
26
25
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
27
29 class QChart;
28 class QChart;
30 class QAbstractSeries;
29 class QAbstractSeries;
31
30
32 class DeclarativeXySeries
31 class DeclarativeXySeries
33 {
32 {
34 public:
33 public:
35 explicit DeclarativeXySeries();
34 explicit DeclarativeXySeries();
36 ~DeclarativeXySeries();
35 ~DeclarativeXySeries();
37
36
38 public:
37 public:
39 void classBegin();
38 void classBegin();
40 void componentComplete();
39 void componentComplete();
41 virtual QXYSeries *xySeries() = 0;
40 virtual QXYSeries *xySeries() = 0;
42
41
43 void append(qreal x, qreal y);
42 void append(qreal x, qreal y);
44 void replace(qreal oldX, qreal oldY, qreal newX, qreal newY);
43 void replace(qreal oldX, qreal oldY, qreal newX, qreal newY);
45 void remove(qreal x, qreal y);
44 void remove(qreal x, qreal y);
46 void insert(int index, qreal x, qreal y);
45 void insert(int index, qreal x, qreal y);
47 void clear();
46 void clear();
48 QPointF at(int index);
47 QPointF at(int index);
49 };
48 };
50
49
51 QTCOMMERCIALCHART_END_NAMESPACE
50 QTCOMMERCIALCHART_END_NAMESPACE
52
51
53 #endif // DECLARATIVE_XY_SERIES_H
52 #endif // DECLARATIVE_XY_SERIES_H
General Comments 0
You need to be logged in to leave comments. Login now