@@ -1,510 +1,510 | |||||
1 | /****************************************************************************** |
|
1 | /****************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd. | |
4 | ** Contact: http://www.qt.io/licensing/ |
|
4 | ** Contact: http://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module. |
|
6 | ** This file is part of the Qt Charts module. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:COMM$ |
|
8 | ** $QT_BEGIN_LICENSE:COMM$ | |
9 | ** |
|
9 | ** | |
10 | ** Commercial License Usage |
|
10 | ** Commercial License Usage | |
11 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
11 | ** Licensees holding valid commercial Qt licenses may use this file in | |
12 | ** accordance with the commercial license agreement provided with the |
|
12 | ** accordance with the commercial license agreement provided with the | |
13 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | ** Software or, alternatively, in accordance with the terms contained in | |
14 | ** a written agreement between you and The Qt Company. For licensing terms |
|
14 | ** a written agreement between you and The Qt Company. For licensing terms | |
15 | ** and conditions see http://www.qt.io/terms-conditions. For further |
|
15 | ** and conditions see http://www.qt.io/terms-conditions. For further | |
16 | ** information use the contact form at http://www.qt.io/contact-us. |
|
16 | ** information use the contact form at http://www.qt.io/contact-us. | |
17 | ** |
|
17 | ** | |
18 | ** $QT_END_LICENSE$ |
|
18 | ** $QT_END_LICENSE$ | |
19 | ** |
|
19 | ** | |
20 | ******************************************************************************/ |
|
20 | ******************************************************************************/ | |
21 |
|
21 | |||
22 | #include "declarativebarseries.h" |
|
22 | #include "declarativebarseries.h" | |
23 | #include <QtCharts/QBarSet> |
|
23 | #include <QtCharts/QBarSet> | |
24 | #include <QtCharts/QVBarModelMapper> |
|
24 | #include <QtCharts/QVBarModelMapper> | |
25 | #include <QtCharts/QHBarModelMapper> |
|
25 | #include <QtCharts/QHBarModelMapper> | |
26 |
|
26 | |||
27 | QT_CHARTS_BEGIN_NAMESPACE |
|
27 | QT_CHARTS_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) |
|
29 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) | |
30 | : QBarSet("", parent) |
|
30 | : QBarSet("", parent) | |
31 | { |
|
31 | { | |
32 | connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int,int))); |
|
32 | connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int,int))); | |
33 | connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int,int))); |
|
33 | connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int,int))); | |
34 | connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged())); |
|
34 | connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged())); | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | void DeclarativeBarSet::handleCountChanged(int index, int count) |
|
37 | void DeclarativeBarSet::handleCountChanged(int index, int count) | |
38 | { |
|
38 | { | |
39 | Q_UNUSED(index) |
|
39 | Q_UNUSED(index) | |
40 | Q_UNUSED(count) |
|
40 | Q_UNUSED(count) | |
41 | emit countChanged(QBarSet::count()); |
|
41 | emit countChanged(QBarSet::count()); | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | qreal DeclarativeBarSet::borderWidth() const |
|
44 | qreal DeclarativeBarSet::borderWidth() const | |
45 | { |
|
45 | { | |
46 | return pen().widthF(); |
|
46 | return pen().widthF(); | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | void DeclarativeBarSet::setBorderWidth(qreal width) |
|
49 | void DeclarativeBarSet::setBorderWidth(qreal width) | |
50 | { |
|
50 | { | |
51 | if (width != pen().widthF()) { |
|
51 | if (width != pen().widthF()) { | |
52 | QPen p = pen(); |
|
52 | QPen p = pen(); | |
53 | p.setWidthF(width); |
|
53 | p.setWidthF(width); | |
54 | setPen(p); |
|
54 | setPen(p); | |
55 | emit borderWidthChanged(width); |
|
55 | emit borderWidthChanged(width); | |
56 | } |
|
56 | } | |
57 | } |
|
57 | } | |
58 |
|
58 | |||
59 | QVariantList DeclarativeBarSet::values() |
|
59 | QVariantList DeclarativeBarSet::values() | |
60 | { |
|
60 | { | |
61 | QVariantList values; |
|
61 | QVariantList values; | |
62 | for (int i(0); i < count(); i++) |
|
62 | for (int i(0); i < count(); i++) | |
63 | values.append(QVariant(QBarSet::at(i))); |
|
63 | values.append(QVariant(QBarSet::at(i))); | |
64 | return values; |
|
64 | return values; | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | void DeclarativeBarSet::setValues(QVariantList values) |
|
67 | void DeclarativeBarSet::setValues(QVariantList values) | |
68 | { |
|
68 | { | |
69 | while (count()) |
|
69 | while (count()) | |
70 | remove(count() - 1); |
|
70 | remove(count() - 1); | |
71 |
|
71 | |||
72 | if (values.at(0).canConvert(QVariant::Point)) { |
|
72 | if (values.count() > 0 && values.at(0).canConvert(QVariant::Point)) { | |
73 | // Create list of values for appending if the first item is Qt.point |
|
73 | // Create list of values for appending if the first item is Qt.point | |
74 | int maxValue = 0; |
|
74 | int maxValue = 0; | |
75 | for (int i = 0; i < values.count(); i++) { |
|
75 | for (int i = 0; i < values.count(); i++) { | |
76 | if (values.at(i).canConvert(QVariant::Point) && |
|
76 | if (values.at(i).canConvert(QVariant::Point) && | |
77 | values.at(i).toPoint().x() > maxValue) { |
|
77 | values.at(i).toPoint().x() > maxValue) { | |
78 | maxValue = values.at(i).toPoint().x(); |
|
78 | maxValue = values.at(i).toPoint().x(); | |
79 | } |
|
79 | } | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 | QVector<int> indexValueList; |
|
82 | QVector<int> indexValueList; | |
83 | indexValueList.resize(maxValue + 1); |
|
83 | indexValueList.resize(maxValue + 1); | |
84 |
|
84 | |||
85 | for (int i = 0; i < values.count(); i++) { |
|
85 | for (int i = 0; i < values.count(); i++) { | |
86 | if (values.at(i).canConvert(QVariant::Point)) { |
|
86 | if (values.at(i).canConvert(QVariant::Point)) { | |
87 | indexValueList.replace(values.at(i).toPoint().x(), values.at(i).toPoint().y()); |
|
87 | indexValueList.replace(values.at(i).toPoint().x(), values.at(i).toPoint().y()); | |
88 | } |
|
88 | } | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | for (int i = 0; i < indexValueList.count(); i++) |
|
91 | for (int i = 0; i < indexValueList.count(); i++) | |
92 | QBarSet::append(indexValueList.at(i)); |
|
92 | QBarSet::append(indexValueList.at(i)); | |
93 |
|
93 | |||
94 | } else { |
|
94 | } else { | |
95 | for (int i(0); i < values.count(); i++) { |
|
95 | for (int i(0); i < values.count(); i++) { | |
96 | if (values.at(i).canConvert(QVariant::Double)) |
|
96 | if (values.at(i).canConvert(QVariant::Double)) | |
97 | QBarSet::append(values[i].toDouble()); |
|
97 | QBarSet::append(values[i].toDouble()); | |
98 | } |
|
98 | } | |
99 | } |
|
99 | } | |
100 | } |
|
100 | } | |
101 |
|
101 | |||
102 | QString DeclarativeBarSet::brushFilename() const |
|
102 | QString DeclarativeBarSet::brushFilename() const | |
103 | { |
|
103 | { | |
104 | return m_brushFilename; |
|
104 | return m_brushFilename; | |
105 | } |
|
105 | } | |
106 |
|
106 | |||
107 | void DeclarativeBarSet::setBrushFilename(const QString &brushFilename) |
|
107 | void DeclarativeBarSet::setBrushFilename(const QString &brushFilename) | |
108 | { |
|
108 | { | |
109 | QImage brushImage(brushFilename); |
|
109 | QImage brushImage(brushFilename); | |
110 | if (QBarSet::brush().textureImage() != brushImage) { |
|
110 | if (QBarSet::brush().textureImage() != brushImage) { | |
111 | QBrush brush = QBarSet::brush(); |
|
111 | QBrush brush = QBarSet::brush(); | |
112 | brush.setTextureImage(brushImage); |
|
112 | brush.setTextureImage(brushImage); | |
113 | QBarSet::setBrush(brush); |
|
113 | QBarSet::setBrush(brush); | |
114 | m_brushFilename = brushFilename; |
|
114 | m_brushFilename = brushFilename; | |
115 | m_brushImage = brushImage; |
|
115 | m_brushImage = brushImage; | |
116 | emit brushFilenameChanged(brushFilename); |
|
116 | emit brushFilenameChanged(brushFilename); | |
117 | } |
|
117 | } | |
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | void DeclarativeBarSet::handleBrushChanged() |
|
120 | void DeclarativeBarSet::handleBrushChanged() | |
121 | { |
|
121 | { | |
122 | // If the texture image of the brush has changed along the brush |
|
122 | // If the texture image of the brush has changed along the brush | |
123 | // the brush file name needs to be cleared. |
|
123 | // the brush file name needs to be cleared. | |
124 | if (!m_brushFilename.isEmpty() && QBarSet::brush().textureImage() != m_brushImage) { |
|
124 | if (!m_brushFilename.isEmpty() && QBarSet::brush().textureImage() != m_brushImage) { | |
125 | m_brushFilename.clear(); |
|
125 | m_brushFilename.clear(); | |
126 | emit brushFilenameChanged(QString("")); |
|
126 | emit brushFilenameChanged(QString("")); | |
127 | } |
|
127 | } | |
128 | } |
|
128 | } | |
129 |
|
129 | |||
130 | // Declarative bar series ====================================================================================== |
|
130 | // Declarative bar series ====================================================================================== | |
131 | DeclarativeBarSeries::DeclarativeBarSeries(QQuickItem *parent) : |
|
131 | DeclarativeBarSeries::DeclarativeBarSeries(QQuickItem *parent) : | |
132 | QBarSeries(parent), |
|
132 | QBarSeries(parent), | |
133 | m_axes(new DeclarativeAxes(this)) |
|
133 | m_axes(new DeclarativeAxes(this)) | |
134 | { |
|
134 | { | |
135 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); |
|
135 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
136 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); |
|
136 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
137 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); |
|
137 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
138 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); |
|
138 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
139 | } |
|
139 | } | |
140 |
|
140 | |||
141 | void DeclarativeBarSeries::classBegin() |
|
141 | void DeclarativeBarSeries::classBegin() | |
142 | { |
|
142 | { | |
143 | } |
|
143 | } | |
144 |
|
144 | |||
145 | void DeclarativeBarSeries::componentComplete() |
|
145 | void DeclarativeBarSeries::componentComplete() | |
146 | { |
|
146 | { | |
147 | foreach (QObject *child, children()) { |
|
147 | foreach (QObject *child, children()) { | |
148 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
148 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
149 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
149 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
150 | } else if (qobject_cast<QVBarModelMapper *>(child)) { |
|
150 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
151 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
151 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
152 | mapper->setSeries(this); |
|
152 | mapper->setSeries(this); | |
153 | } else if (qobject_cast<QHBarModelMapper *>(child)) { |
|
153 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
154 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
154 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
155 | mapper->setSeries(this); |
|
155 | mapper->setSeries(this); | |
156 | } |
|
156 | } | |
157 | } |
|
157 | } | |
158 | } |
|
158 | } | |
159 |
|
159 | |||
160 | QQmlListProperty<QObject> DeclarativeBarSeries::seriesChildren() |
|
160 | QQmlListProperty<QObject> DeclarativeBarSeries::seriesChildren() | |
161 | { |
|
161 | { | |
162 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); |
|
162 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); | |
163 | } |
|
163 | } | |
164 |
|
164 | |||
165 | void DeclarativeBarSeries::appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element) |
|
165 | void DeclarativeBarSeries::appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element) | |
166 | { |
|
166 | { | |
167 | // Empty implementation; the children are parsed in componentComplete instead |
|
167 | // Empty implementation; the children are parsed in componentComplete instead | |
168 | Q_UNUSED(list); |
|
168 | Q_UNUSED(list); | |
169 | Q_UNUSED(element); |
|
169 | Q_UNUSED(element); | |
170 | } |
|
170 | } | |
171 |
|
171 | |||
172 | DeclarativeBarSet *DeclarativeBarSeries::at(int index) |
|
172 | DeclarativeBarSet *DeclarativeBarSeries::at(int index) | |
173 | { |
|
173 | { | |
174 | QList<QBarSet *> setList = barSets(); |
|
174 | QList<QBarSet *> setList = barSets(); | |
175 | if (index >= 0 && index < setList.count()) |
|
175 | if (index >= 0 && index < setList.count()) | |
176 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
176 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
177 |
|
177 | |||
178 | return 0; |
|
178 | return 0; | |
179 | } |
|
179 | } | |
180 |
|
180 | |||
181 | DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values) |
|
181 | DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values) | |
182 | { |
|
182 | { | |
183 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
183 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
184 | barset->setLabel(label); |
|
184 | barset->setLabel(label); | |
185 | barset->setValues(values); |
|
185 | barset->setValues(values); | |
186 | if (QBarSeries::insert(index, barset)) |
|
186 | if (QBarSeries::insert(index, barset)) | |
187 | return barset; |
|
187 | return barset; | |
188 | delete barset; |
|
188 | delete barset; | |
189 | return 0; |
|
189 | return 0; | |
190 | } |
|
190 | } | |
191 |
|
191 | |||
192 | // Declarative stacked bar series ============================================================================== |
|
192 | // Declarative stacked bar series ============================================================================== | |
193 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QQuickItem *parent) : |
|
193 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QQuickItem *parent) : | |
194 | QStackedBarSeries(parent), |
|
194 | QStackedBarSeries(parent), | |
195 | m_axes(0) |
|
195 | m_axes(0) | |
196 | { |
|
196 | { | |
197 | m_axes = new DeclarativeAxes(this); |
|
197 | m_axes = new DeclarativeAxes(this); | |
198 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); |
|
198 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
199 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); |
|
199 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
200 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); |
|
200 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
201 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); |
|
201 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
202 | } |
|
202 | } | |
203 |
|
203 | |||
204 | void DeclarativeStackedBarSeries::classBegin() |
|
204 | void DeclarativeStackedBarSeries::classBegin() | |
205 | { |
|
205 | { | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | void DeclarativeStackedBarSeries::componentComplete() |
|
208 | void DeclarativeStackedBarSeries::componentComplete() | |
209 | { |
|
209 | { | |
210 | foreach (QObject *child, children()) { |
|
210 | foreach (QObject *child, children()) { | |
211 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
211 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
212 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
212 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
213 | } else if (qobject_cast<QVBarModelMapper *>(child)) { |
|
213 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
214 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
214 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
215 | mapper->setSeries(this); |
|
215 | mapper->setSeries(this); | |
216 | } else if (qobject_cast<QHBarModelMapper *>(child)) { |
|
216 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
217 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
217 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
218 | mapper->setSeries(this); |
|
218 | mapper->setSeries(this); | |
219 | } |
|
219 | } | |
220 | } |
|
220 | } | |
221 | } |
|
221 | } | |
222 |
|
222 | |||
223 |
|
223 | |||
224 | QQmlListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() |
|
224 | QQmlListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() | |
225 | { |
|
225 | { | |
226 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); |
|
226 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); | |
227 | } |
|
227 | } | |
228 |
|
228 | |||
229 | void DeclarativeStackedBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) |
|
229 | void DeclarativeStackedBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) | |
230 | { |
|
230 | { | |
231 | // Empty implementation; the children are parsed in componentComplete instead |
|
231 | // Empty implementation; the children are parsed in componentComplete instead | |
232 | Q_UNUSED(list); |
|
232 | Q_UNUSED(list); | |
233 | Q_UNUSED(element); |
|
233 | Q_UNUSED(element); | |
234 | } |
|
234 | } | |
235 |
|
235 | |||
236 | DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) |
|
236 | DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) | |
237 | { |
|
237 | { | |
238 | QList<QBarSet *> setList = barSets(); |
|
238 | QList<QBarSet *> setList = barSets(); | |
239 | if (index >= 0 && index < setList.count()) |
|
239 | if (index >= 0 && index < setList.count()) | |
240 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
240 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
241 |
|
241 | |||
242 | return 0; |
|
242 | return 0; | |
243 | } |
|
243 | } | |
244 |
|
244 | |||
245 | DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values) |
|
245 | DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values) | |
246 | { |
|
246 | { | |
247 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
247 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
248 | barset->setLabel(label); |
|
248 | barset->setLabel(label); | |
249 | barset->setValues(values); |
|
249 | barset->setValues(values); | |
250 | if (QStackedBarSeries::insert(index, barset)) |
|
250 | if (QStackedBarSeries::insert(index, barset)) | |
251 | return barset; |
|
251 | return barset; | |
252 | delete barset; |
|
252 | delete barset; | |
253 | return 0; |
|
253 | return 0; | |
254 | } |
|
254 | } | |
255 |
|
255 | |||
256 | // Declarative percent bar series ============================================================================== |
|
256 | // Declarative percent bar series ============================================================================== | |
257 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QQuickItem *parent) : |
|
257 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QQuickItem *parent) : | |
258 | QPercentBarSeries(parent), |
|
258 | QPercentBarSeries(parent), | |
259 | m_axes(0) |
|
259 | m_axes(0) | |
260 | { |
|
260 | { | |
261 | m_axes = new DeclarativeAxes(this); |
|
261 | m_axes = new DeclarativeAxes(this); | |
262 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); |
|
262 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
263 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); |
|
263 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
264 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); |
|
264 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
265 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); |
|
265 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
266 | } |
|
266 | } | |
267 |
|
267 | |||
268 | void DeclarativePercentBarSeries::classBegin() |
|
268 | void DeclarativePercentBarSeries::classBegin() | |
269 | { |
|
269 | { | |
270 | } |
|
270 | } | |
271 |
|
271 | |||
272 | void DeclarativePercentBarSeries::componentComplete() |
|
272 | void DeclarativePercentBarSeries::componentComplete() | |
273 | { |
|
273 | { | |
274 | foreach (QObject *child, children()) { |
|
274 | foreach (QObject *child, children()) { | |
275 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
275 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
276 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
276 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
277 | } else if (qobject_cast<QVBarModelMapper *>(child)) { |
|
277 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
278 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
278 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
279 | mapper->setSeries(this); |
|
279 | mapper->setSeries(this); | |
280 | } else if (qobject_cast<QHBarModelMapper *>(child)) { |
|
280 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
281 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
281 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
282 | mapper->setSeries(this); |
|
282 | mapper->setSeries(this); | |
283 | } |
|
283 | } | |
284 | } |
|
284 | } | |
285 | } |
|
285 | } | |
286 |
|
286 | |||
287 | QQmlListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() |
|
287 | QQmlListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() | |
288 | { |
|
288 | { | |
289 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); |
|
289 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); | |
290 | } |
|
290 | } | |
291 |
|
291 | |||
292 | void DeclarativePercentBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) |
|
292 | void DeclarativePercentBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) | |
293 | { |
|
293 | { | |
294 | // Empty implementation; the children are parsed in componentComplete instead |
|
294 | // Empty implementation; the children are parsed in componentComplete instead | |
295 | Q_UNUSED(list); |
|
295 | Q_UNUSED(list); | |
296 | Q_UNUSED(element); |
|
296 | Q_UNUSED(element); | |
297 | } |
|
297 | } | |
298 |
|
298 | |||
299 | DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) |
|
299 | DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) | |
300 | { |
|
300 | { | |
301 | QList<QBarSet *> setList = barSets(); |
|
301 | QList<QBarSet *> setList = barSets(); | |
302 | if (index >= 0 && index < setList.count()) |
|
302 | if (index >= 0 && index < setList.count()) | |
303 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
303 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
304 |
|
304 | |||
305 | return 0; |
|
305 | return 0; | |
306 | } |
|
306 | } | |
307 |
|
307 | |||
308 | DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values) |
|
308 | DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values) | |
309 | { |
|
309 | { | |
310 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
310 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
311 | barset->setLabel(label); |
|
311 | barset->setLabel(label); | |
312 | barset->setValues(values); |
|
312 | barset->setValues(values); | |
313 | if (QPercentBarSeries::insert(index, barset)) |
|
313 | if (QPercentBarSeries::insert(index, barset)) | |
314 | return barset; |
|
314 | return barset; | |
315 | delete barset; |
|
315 | delete barset; | |
316 | return 0; |
|
316 | return 0; | |
317 | } |
|
317 | } | |
318 |
|
318 | |||
319 | // Declarative horizontal bar series =========================================================================== |
|
319 | // Declarative horizontal bar series =========================================================================== | |
320 | DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QQuickItem *parent) : |
|
320 | DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QQuickItem *parent) : | |
321 | QHorizontalBarSeries(parent), |
|
321 | QHorizontalBarSeries(parent), | |
322 | m_axes(0) |
|
322 | m_axes(0) | |
323 | { |
|
323 | { | |
324 | m_axes = new DeclarativeAxes(this); |
|
324 | m_axes = new DeclarativeAxes(this); | |
325 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); |
|
325 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
326 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); |
|
326 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
327 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); |
|
327 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
328 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); |
|
328 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
329 | } |
|
329 | } | |
330 |
|
330 | |||
331 | void DeclarativeHorizontalBarSeries::classBegin() |
|
331 | void DeclarativeHorizontalBarSeries::classBegin() | |
332 | { |
|
332 | { | |
333 | } |
|
333 | } | |
334 |
|
334 | |||
335 | void DeclarativeHorizontalBarSeries::componentComplete() |
|
335 | void DeclarativeHorizontalBarSeries::componentComplete() | |
336 | { |
|
336 | { | |
337 | foreach (QObject *child, children()) { |
|
337 | foreach (QObject *child, children()) { | |
338 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
338 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
339 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
339 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
340 | } else if (qobject_cast<QVBarModelMapper *>(child)) { |
|
340 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
341 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
341 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
342 | mapper->setSeries(this); |
|
342 | mapper->setSeries(this); | |
343 | } else if (qobject_cast<QHBarModelMapper *>(child)) { |
|
343 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
344 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
344 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
345 | mapper->setSeries(this); |
|
345 | mapper->setSeries(this); | |
346 | } |
|
346 | } | |
347 | } |
|
347 | } | |
348 | } |
|
348 | } | |
349 |
|
349 | |||
350 | QQmlListProperty<QObject> DeclarativeHorizontalBarSeries::seriesChildren() |
|
350 | QQmlListProperty<QObject> DeclarativeHorizontalBarSeries::seriesChildren() | |
351 | { |
|
351 | { | |
352 | return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren ,0,0,0); |
|
352 | return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren ,0,0,0); | |
353 | } |
|
353 | } | |
354 |
|
354 | |||
355 | void DeclarativeHorizontalBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) |
|
355 | void DeclarativeHorizontalBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) | |
356 | { |
|
356 | { | |
357 | // Empty implementation; the children are parsed in componentComplete instead |
|
357 | // Empty implementation; the children are parsed in componentComplete instead | |
358 | Q_UNUSED(list); |
|
358 | Q_UNUSED(list); | |
359 | Q_UNUSED(element); |
|
359 | Q_UNUSED(element); | |
360 | } |
|
360 | } | |
361 |
|
361 | |||
362 | DeclarativeBarSet *DeclarativeHorizontalBarSeries::at(int index) |
|
362 | DeclarativeBarSet *DeclarativeHorizontalBarSeries::at(int index) | |
363 | { |
|
363 | { | |
364 | QList<QBarSet *> setList = barSets(); |
|
364 | QList<QBarSet *> setList = barSets(); | |
365 | if (index >= 0 && index < setList.count()) |
|
365 | if (index >= 0 && index < setList.count()) | |
366 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
366 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
367 |
|
367 | |||
368 | return 0; |
|
368 | return 0; | |
369 | } |
|
369 | } | |
370 |
|
370 | |||
371 | DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString label, QVariantList values) |
|
371 | DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString label, QVariantList values) | |
372 | { |
|
372 | { | |
373 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
373 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
374 | barset->setLabel(label); |
|
374 | barset->setLabel(label); | |
375 | barset->setValues(values); |
|
375 | barset->setValues(values); | |
376 | if (QHorizontalBarSeries::insert(index, barset)) |
|
376 | if (QHorizontalBarSeries::insert(index, barset)) | |
377 | return barset; |
|
377 | return barset; | |
378 | delete barset; |
|
378 | delete barset; | |
379 | return 0; |
|
379 | return 0; | |
380 | } |
|
380 | } | |
381 |
|
381 | |||
382 | // Declarative horizontal stacked bar series =================================================================== |
|
382 | // Declarative horizontal stacked bar series =================================================================== | |
383 | DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QQuickItem *parent) : |
|
383 | DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QQuickItem *parent) : | |
384 | QHorizontalStackedBarSeries(parent), |
|
384 | QHorizontalStackedBarSeries(parent), | |
385 | m_axes(0) |
|
385 | m_axes(0) | |
386 | { |
|
386 | { | |
387 | m_axes = new DeclarativeAxes(this); |
|
387 | m_axes = new DeclarativeAxes(this); | |
388 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); |
|
388 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
389 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); |
|
389 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
390 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); |
|
390 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
391 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); |
|
391 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
392 | } |
|
392 | } | |
393 |
|
393 | |||
394 | void DeclarativeHorizontalStackedBarSeries::classBegin() |
|
394 | void DeclarativeHorizontalStackedBarSeries::classBegin() | |
395 | { |
|
395 | { | |
396 | } |
|
396 | } | |
397 |
|
397 | |||
398 | void DeclarativeHorizontalStackedBarSeries::componentComplete() |
|
398 | void DeclarativeHorizontalStackedBarSeries::componentComplete() | |
399 | { |
|
399 | { | |
400 | foreach (QObject *child, children()) { |
|
400 | foreach (QObject *child, children()) { | |
401 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
401 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
402 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
402 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
403 | } else if (qobject_cast<QVBarModelMapper *>(child)) { |
|
403 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
404 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
404 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
405 | mapper->setSeries(this); |
|
405 | mapper->setSeries(this); | |
406 | } else if (qobject_cast<QHBarModelMapper *>(child)) { |
|
406 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
407 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
407 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
408 | mapper->setSeries(this); |
|
408 | mapper->setSeries(this); | |
409 | } |
|
409 | } | |
410 | } |
|
410 | } | |
411 | } |
|
411 | } | |
412 |
|
412 | |||
413 | QQmlListProperty<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren() |
|
413 | QQmlListProperty<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren() | |
414 | { |
|
414 | { | |
415 | return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren ,0,0,0); |
|
415 | return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren ,0,0,0); | |
416 | } |
|
416 | } | |
417 |
|
417 | |||
418 | void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) |
|
418 | void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) | |
419 | { |
|
419 | { | |
420 | // Empty implementation; the children are parsed in componentComplete instead |
|
420 | // Empty implementation; the children are parsed in componentComplete instead | |
421 | Q_UNUSED(list); |
|
421 | Q_UNUSED(list); | |
422 | Q_UNUSED(element); |
|
422 | Q_UNUSED(element); | |
423 | } |
|
423 | } | |
424 |
|
424 | |||
425 | DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::at(int index) |
|
425 | DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::at(int index) | |
426 | { |
|
426 | { | |
427 | QList<QBarSet *> setList = barSets(); |
|
427 | QList<QBarSet *> setList = barSets(); | |
428 | if (index >= 0 && index < setList.count()) |
|
428 | if (index >= 0 && index < setList.count()) | |
429 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
429 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
430 |
|
430 | |||
431 | return 0; |
|
431 | return 0; | |
432 | } |
|
432 | } | |
433 |
|
433 | |||
434 | DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QString label, QVariantList values) |
|
434 | DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QString label, QVariantList values) | |
435 | { |
|
435 | { | |
436 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
436 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
437 | barset->setLabel(label); |
|
437 | barset->setLabel(label); | |
438 | barset->setValues(values); |
|
438 | barset->setValues(values); | |
439 | if (QHorizontalStackedBarSeries::insert(index, barset)) |
|
439 | if (QHorizontalStackedBarSeries::insert(index, barset)) | |
440 | return barset; |
|
440 | return barset; | |
441 | delete barset; |
|
441 | delete barset; | |
442 | return 0; |
|
442 | return 0; | |
443 | } |
|
443 | } | |
444 |
|
444 | |||
445 | // Declarative horizontal percent bar series =================================================================== |
|
445 | // Declarative horizontal percent bar series =================================================================== | |
446 | DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QQuickItem *parent) : |
|
446 | DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QQuickItem *parent) : | |
447 | QHorizontalPercentBarSeries(parent), |
|
447 | QHorizontalPercentBarSeries(parent), | |
448 | m_axes(0) |
|
448 | m_axes(0) | |
449 | { |
|
449 | { | |
450 | m_axes = new DeclarativeAxes(this); |
|
450 | m_axes = new DeclarativeAxes(this); | |
451 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); |
|
451 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
452 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); |
|
452 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
453 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); |
|
453 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
454 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); |
|
454 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
455 | } |
|
455 | } | |
456 |
|
456 | |||
457 | void DeclarativeHorizontalPercentBarSeries::classBegin() |
|
457 | void DeclarativeHorizontalPercentBarSeries::classBegin() | |
458 | { |
|
458 | { | |
459 | } |
|
459 | } | |
460 |
|
460 | |||
461 | void DeclarativeHorizontalPercentBarSeries::componentComplete() |
|
461 | void DeclarativeHorizontalPercentBarSeries::componentComplete() | |
462 | { |
|
462 | { | |
463 | foreach (QObject *child, children()) { |
|
463 | foreach (QObject *child, children()) { | |
464 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
464 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
465 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
465 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
466 | } else if (qobject_cast<QVBarModelMapper *>(child)) { |
|
466 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
467 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
467 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
468 | mapper->setSeries(this); |
|
468 | mapper->setSeries(this); | |
469 | } else if (qobject_cast<QHBarModelMapper *>(child)) { |
|
469 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
470 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
470 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
471 | mapper->setSeries(this); |
|
471 | mapper->setSeries(this); | |
472 | } |
|
472 | } | |
473 | } |
|
473 | } | |
474 | } |
|
474 | } | |
475 |
|
475 | |||
476 | QQmlListProperty<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren() |
|
476 | QQmlListProperty<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren() | |
477 | { |
|
477 | { | |
478 | return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren ,0,0,0); |
|
478 | return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren ,0,0,0); | |
479 | } |
|
479 | } | |
480 |
|
480 | |||
481 | void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) |
|
481 | void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) | |
482 | { |
|
482 | { | |
483 | // Empty implementation; the children are parsed in componentComplete instead |
|
483 | // Empty implementation; the children are parsed in componentComplete instead | |
484 | Q_UNUSED(list); |
|
484 | Q_UNUSED(list); | |
485 | Q_UNUSED(element); |
|
485 | Q_UNUSED(element); | |
486 | } |
|
486 | } | |
487 |
|
487 | |||
488 | DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::at(int index) |
|
488 | DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::at(int index) | |
489 | { |
|
489 | { | |
490 | QList<QBarSet *> setList = barSets(); |
|
490 | QList<QBarSet *> setList = barSets(); | |
491 | if (index >= 0 && index < setList.count()) |
|
491 | if (index >= 0 && index < setList.count()) | |
492 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
492 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
493 |
|
493 | |||
494 | return 0; |
|
494 | return 0; | |
495 | } |
|
495 | } | |
496 |
|
496 | |||
497 | DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::insert(int index, QString label, QVariantList values) |
|
497 | DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::insert(int index, QString label, QVariantList values) | |
498 | { |
|
498 | { | |
499 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
499 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
500 | barset->setLabel(label); |
|
500 | barset->setLabel(label); | |
501 | barset->setValues(values); |
|
501 | barset->setValues(values); | |
502 | if (QHorizontalPercentBarSeries::insert(index, barset)) |
|
502 | if (QHorizontalPercentBarSeries::insert(index, barset)) | |
503 | return barset; |
|
503 | return barset; | |
504 | delete barset; |
|
504 | delete barset; | |
505 | return 0; |
|
505 | return 0; | |
506 | } |
|
506 | } | |
507 |
|
507 | |||
508 | #include "moc_declarativebarseries.cpp" |
|
508 | #include "moc_declarativebarseries.cpp" | |
509 |
|
509 | |||
510 | QT_CHARTS_END_NAMESPACE |
|
510 | QT_CHARTS_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now