##// END OF EJS Templates
Fix BoxPlotSeries documentation...
Titta Heikkala -
r2756:82bdb5075bbd
parent child
Show More
@@ -1,455 +1,459
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2014 Digia Plc
3 ** Copyright (C) 2014 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.io
5 ** For any questions to Digia, please use contact form at http://qt.io
6 **
6 **
7 ** This file is part of the Qt Charts module.
7 ** This file is part of the Qt Charts module.
8 **
8 **
9 ** Licensees holding valid commercial license for Qt may use this file in
9 ** Licensees holding valid commercial license for Qt may use this file in
10 ** accordance with the Qt License Agreement provided with the Software
10 ** accordance with the Qt License Agreement provided with the Software
11 ** or, alternatively, in accordance with the terms contained in a written
11 ** or, alternatively, in accordance with the terms contained in a written
12 ** agreement between you and Digia.
12 ** agreement between you and Digia.
13 **
13 **
14 ** If you have questions regarding the use of this file, please use
14 ** If you have questions regarding the use of this file, please use
15 ** contact form at http://qt.io
15 ** contact form at http://qt.io
16 **
16 **
17 ****************************************************************************/
17 ****************************************************************************/
18
18
19 #include "declarativebarseries.h"
19 #include "declarativebarseries.h"
20 #include "declarativeboxplotseries.h"
20 #include "declarativeboxplotseries.h"
21 #include <QtCharts/QBoxSet>
21 #include <QtCharts/QBoxSet>
22 #include <QtCharts/QVBoxPlotModelMapper>
22 #include <QtCharts/QVBoxPlotModelMapper>
23
23
24 QT_CHARTS_BEGIN_NAMESPACE
24 QT_CHARTS_BEGIN_NAMESPACE
25
25
26 /*!
26 /*!
27 \qmltype BoxSet
27 \qmltype BoxSet
28 \instantiates QBoxSet
28 \instantiates QBoxSet
29 \inqmlmodule QtCharts
29 \inqmlmodule QtCharts
30
30
31 \brief Building block for box-and-whiskers chart.
31 \brief Building block for box-and-whiskers chart.
32
32
33 BoxSet represents one box-and-whiskers item. It takes five values to create a graphical
33 BoxSet represents one box-and-whiskers item. It takes five values to create a graphical
34 representation of range and three medians. There are two ways to give the values. The first one
34 representation of range and three medians. There are two ways to give the values. The first one
35 is with constructor or with append method. In these the values have to be given in the following
35 is with constructor or with append method. In these the values have to be given in the following
36 order: lower extreme, lower quartile, median, upper quartile and upper extreme. The second
36 order: lower extreme, lower quartile, median, upper quartile and upper extreme. The second
37 method is to create an empty QBoxSet instance and give the values using value specific methods.
37 method is to create an empty QBoxSet instance and give the values using value specific methods.
38 \sa BoxPlotSeries
38 \sa BoxPlotSeries
39 */
39 */
40 /*!
40 /*!
41 \qmlproperty string BoxSet::values
41 \qmlproperty string BoxSet::values
42 The values on the box-and-whiskers set.
42 The values on the box-and-whiskers set.
43 */
43 */
44 /*!
44 /*!
45 \qmlproperty string BoxSet::label
45 \qmlproperty string BoxSet::label
46 Defines the label of the box-and-whiskers set.
46 Defines the label of the box-and-whiskers set.
47 */
47 */
48 /*!
48 /*!
49 \qmlproperty int BoxSet::count
49 \qmlproperty int BoxSet::count
50 The count of values on the box-and-whiskers set
50 The count of values on the box-and-whiskers set
51 */
51 */
52 /*!
52 /*!
53 \qmlmethod void BoxSet::at(int index)
53 \qmlmethod void BoxSet::at(int index)
54 Returns the value at \a index position.
54 Returns the value at \a index position.
55 */
55 */
56 /*!
56 /*!
57 \qmlmethod void BoxSet::append(qreal value)
57 \qmlmethod void BoxSet::append(qreal value)
58 Appends new value \a value to the end of set.
58 Appends new value \a value to the end of set.
59 */
59 */
60 /*!
60 /*!
61 \qmlmethod void BoxSet::clear()
61 \qmlmethod void BoxSet::clear()
62 Sets all values on the set to 0.
62 Sets all values on the set to 0.
63 */
63 */
64 /*!
64 /*!
65 \qmlmethod void BoxSet::setValue(int index, qreal value)
65 \qmlmethod void BoxSet::setValue(int index, qreal value)
66 Sets a new \a value on the \a index position.
66 Sets a new \a value on the \a index position.
67 */
67 */
68 /*!
68 /*!
69 \qmlsignal BoxSet::onClicked()
69 \qmlsignal BoxSet::onClicked()
70 This signal is emitted when the user clicks with a mouse on top of box-and-whiskers item.
70 This signal is emitted when the user clicks with a mouse on top of box-and-whiskers item.
71 */
71 */
72 /*!
72 /*!
73 \qmlsignal BoxSet::onPressed()
73 \qmlsignal BoxSet::onPressed()
74 This signal is emitted when the user presses with a mouse on top of box-and-whiskers item.
74 This signal is emitted when the user presses with a mouse on top of box-and-whiskers item.
75 */
75 */
76 /*!
76 /*!
77 \qmlsignal BoxSet::onReleased()
77 \qmlsignal BoxSet::onReleased()
78 This signal is emitted when the user releases with a mouse on top of box-and-whiskers item.
78 This signal is emitted when the user releases with a mouse on top of box-and-whiskers item.
79 */
79 */
80 /*!
80 /*!
81 \qmlsignal BoxSet::onDoubleClicked()
81 \qmlsignal BoxSet::onDoubleClicked()
82 This signal is emitted when the user doubleclicks with a mouse on top of box-and-whiskers item.
82 This signal is emitted when the user doubleclicks with a mouse on top of box-and-whiskers item.
83 */
83 */
84 /*!
84 /*!
85 \qmlsignal BoxSet::onHovered(bool status)
85 \qmlsignal BoxSet::onHovered(bool status)
86 The signal is emitted if mouse is hovered on top of box-and-whiskers item.
86 The signal is emitted if mouse is hovered on top of box-and-whiskers item.
87 Parameter \a status is true, if mouse entered on top of the item, and false if mouse left from top of the item.
87 Parameter \a status is true, if mouse entered on top of the item, and false if mouse left from top of the item.
88 */
88 */
89 /*!
89 /*!
90 \qmlsignal BoxSet::onPenChanged()
90 \qmlsignal BoxSet::onPenChanged()
91 This signal is emitted when the pen of the box-and-whiskers item has changed.
91 This signal is emitted when the pen of the box-and-whiskers item has changed.
92 */
92 */
93 /*!
93 /*!
94 \qmlsignal BoxSet::onBrushChanged()
94 \qmlsignal BoxSet::onBrushChanged()
95 This signal is emitted when the brush of the box-and-whiskers item has changed.
95 This signal is emitted when the brush of the box-and-whiskers item has changed.
96 */
96 */
97 /*!
97 /*!
98 \qmlsignal BoxSet::onChangedValues()
98 \qmlsignal BoxSet::onChangedValues()
99 This signal is emitted when multiple values have been changed on the box-and-whiskers item.
99 This signal is emitted when multiple values have been changed on the box-and-whiskers item.
100 */
100 */
101 /*!
101 /*!
102 \qmlsignal BoxSet::onChangedValue(int index)
102 \qmlsignal BoxSet::onChangedValue(int index)
103 This signal is emitted values the value in the box-and-whiskers item has been modified.
103 This signal is emitted values the value in the box-and-whiskers item has been modified.
104 Parameter \a index indicates the position of the modified value.
104 Parameter \a index indicates the position of the modified value.
105 */
105 */
106 /*!
106 /*!
107 \qmlsignal BoxSet::onCleared()
107 \qmlsignal BoxSet::onCleared()
108 This signal is emitted when all the values on the set are cleared to 0.
108 This signal is emitted when all the values on the set are cleared to 0.
109 */
109 */
110
110
111 /*!
111 /*!
112 \qmltype BoxPlotSeries
112 \qmltype BoxPlotSeries
113 \instantiates QBoxPlotSeries
113 \instantiates QBoxPlotSeries
114 \inqmlmodule QtCharts
114 \inqmlmodule QtCharts
115
115
116 \inherits AbstractSeries
116 \inherits AbstractSeries
117
117
118 \brief Series for creating box-and-whiskers chart.
118 \brief Series for creating box-and-whiskers chart.
119
119
120 BoxPlotSeries represents a series of data shown as box-and-whiskers bars. The purpose of this
120 BoxPlotSeries represents a series of data shown as box-and-whiskers bars. The purpose of this
121 class is to act as a container for single box-and-whiskers items. Each item is drawn to own
121 class is to act as a container for single box-and-whiskers items. Each item is drawn to own
122 slot. If chart includes multiple instances of BoxPlotSeries then box-and-whiskers items with the
122 slot. If chart includes multiple instances of BoxPlotSeries then box-and-whiskers items with the
123 same index are drawn to same slot.
123 same index are drawn to same slot.
124
124
125 The following QML shows how to create a simple box-and-whiskers chart:
125 The following QML shows how to create a simple box-and-whiskers chart:
126 \code
126 \code
127 import QtQuick 2.0
127 import QtQuick 2.0
128 import QtCharts 2.0
128 import QtCharts 2.0
129
129
130 ChartView {
130 ChartView {
131 title: "Box Plot series"
131 title: "Box Plot series"
132 width: 400
132 width: 400
133 height: 300
133 height: 300
134 theme: ChartView.ChartThemeBrownSand
134 theme: ChartView.ChartThemeBrownSand
135 legend.alignment: Qt.AlignBottom
135 legend.alignment: Qt.AlignBottom
136
136
137 BoxPlotSeries {
137 BoxPlotSeries {
138 id: plotSeries
138 id: plotSeries
139 name: "Income"
139 name: "Income"
140 BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] }
140 BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] }
141 BoxSet { label: "Feb"; values: [5, 6, 7.5, 8.6, 11.8] }
141 BoxSet { label: "Feb"; values: [5, 6, 7.5, 8.6, 11.8] }
142 BoxSet { label: "Mar"; values: [3.2, 5, 5.7, 8, 9.2] }
142 BoxSet { label: "Mar"; values: [3.2, 5, 5.7, 8, 9.2] }
143 BoxSet { label: "Apr"; values: [3.8, 5, 6.4, 7, 8] }
143 BoxSet { label: "Apr"; values: [3.8, 5, 6.4, 7, 8] }
144 BoxSet { label: "May"; values: [4, 5, 5.2, 6, 7] }
144 BoxSet { label: "May"; values: [4, 5, 5.2, 6, 7] }
145 }
145 }
146 }
146 }
147 \endcode
147 \endcode
148
148
149 \beginfloatleft
149 \beginfloatleft
150 \image examples_qmlboxplot.png
150 \image examples_qmlboxplot.png
151 \endfloat
151 \endfloat
152 \clearfloat
152 \clearfloat
153 */
153 */
154
154
155 /*!
155 /*!
156 \qmlmethod BoxPlotSeries::append(string label, VariantList values)
156 \qmlmethod BoxPlotSeries::append(string label, VariantList values)
157 Appends a new box-and-whiskers set with \a label and \a values to the series.
157 Appends a new box-and-whiskers set with \a label and \a values to the series.
158 */
158 */
159 /*!
159 /*!
160 \qmlmethod BoxPlotSeries::append(BoxSet box)
160 \qmlmethod BoxPlotSeries::append(BoxSet box)
161 Appends the \a box to the series.
161 Appends the \a box to the series.
162 */
162 */
163 /*!
163 /*!
164 \qmlmethod BoxPlotSeries::insert(int index, string label, VariantList values)
164 \qmlmethod BoxPlotSeries::insert(int index, string label, VariantList values)
165 Inserts a new box-and-whiskers set with \a label and \a values at the \a index position.
165 Inserts a new box-and-whiskers set with \a label and \a values at the \a index position.
166 */
166 */
167 /*!
167 /*!
168 \qmlmethod BoxPlotSeries::remove(QBoxSet boxset)
168 \qmlmethod BoxPlotSeries::remove(QBoxSet boxset)
169 Removes the \a boxset from the series.
169 Removes the \a boxset from the series.
170 */
170 */
171 /*!
171 /*!
172 \qmlmethod BoxPlotSeries::clear()
172 \qmlmethod BoxPlotSeries::clear()
173 Removes all boxsets from the series. Deletes removed sets.
173 Removes all boxsets from the series. Deletes removed sets.
174 */
174 */
175 /*!
175 /*!
176 \qmlsignal BoxPlotSeries::onClicked(BoxSet boxset);
176 \qmlsignal BoxPlotSeries::onClicked(BoxSet boxset);
177 Signal is emitted when the user clicks the \a boxset on the chart.
177 Signal is emitted when the user clicks the \a boxset on the chart.
178 */
178 */
179 /*!
179 /*!
180 \qmlsignal BoxPlotSeries::onHovered(bool status, BoxSet boxset);
180 \qmlsignal BoxPlotSeries::onHovered(bool status, BoxSet boxset);
181 Signal is emitted when there is change in hover \a status over \a boxset.
181 Signal is emitted when there is change in hover \a status over \a boxset.
182 */
182 */
183 /*!
183 /*!
184 \qmlsignal BoxPlotSeries::onPressed(BoxSet boxset)
185 This signal is emitted when the user presses the \a boxset on the chart.
186 */
187 /*!
188 \qmlsignal BoxPlotSeries::onReleased(BoxSet boxset)
189 This signal is emitted when the user releases the \a boxset on the chart.
190 */
191 /*!
192 \qmlsignal BoxPlotSeries::onDoubleClicked(BoxSet boxset)
193 This signal is emitted when the user doubleclicks the \a boxset on the chart.
194 */
195 /*!
184 \qmlsignal BoxPlotSeries::onCountChanged();
196 \qmlsignal BoxPlotSeries::onCountChanged();
185 Signal is emitted when there is change in count of box-and-whiskers items in the series.
197 Signal is emitted when there is change in count of box-and-whiskers items in the series.
186 */
198 */
187 /*!
199 /*!
188 \qmlsignal BoxPlotSeries::onBoxsetsAdded()
200 \qmlsignal BoxPlotSeries::onBoxsetsAdded()
189 Signal is emitted when new box-and-whiskers sets are added to the series.
201 Signal is emitted when new box-and-whiskers sets are added to the series.
190 */
202 */
191 /*!
203 /*!
192 \qmlsignal BoxPlotSeries::onBoxsetsRemoved()
204 \qmlsignal BoxPlotSeries::onBoxsetsRemoved()
193 Signal is emitted when new box-and-whiskers sets are removed from the series.
205 Signal is emitted when new box-and-whiskers sets are removed from the series.
194 */
206 */
195 /*!
207 /*!
196 \qmlproperty AbstractAxis BoxPlotSeries::axisX
208 \qmlproperty AbstractAxis BoxPlotSeries::axisX
197 The x axis used for the series. If you leave both axisX and axisXTop undefined, a BarCategoriesAxis is created for
209 The x axis used for the series. If you leave both axisX and axisXTop undefined, a BarCategoriesAxis is created for
198 the series.
210 the series.
199 \sa axisXTop
211 \sa axisXTop
200 */
212 */
201 /*!
213 /*!
202 \qmlproperty AbstractAxis BoxPlotSeries::axisY
214 \qmlproperty AbstractAxis BoxPlotSeries::axisY
203 The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for
215 The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for
204 the series.
216 the series.
205 \sa axisYRight
217 \sa axisYRight
206 */
218 */
207 /*!
219 /*!
208 \qmlproperty AbstractAxis BoxPlotSeries::axisXTop
220 \qmlproperty AbstractAxis BoxPlotSeries::axisXTop
209 The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or
221 The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or
210 axisXTop, but not both.
222 axisXTop, but not both.
211 \sa axisX
223 \sa axisX
212 */
224 */
213 /*!
225 /*!
214 \qmlproperty AbstractAxis BoxPlotSeries::axisYRight
226 \qmlproperty AbstractAxis BoxPlotSeries::axisYRight
215 The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY
227 The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY
216 or axisYRight, but not both.
228 or axisYRight, but not both.
217 \sa axisY
229 \sa axisY
218 */
230 */
219 /*!
231 /*!
220 \qmlproperty bool BoxPlotSeries::boxOutlineVisible
232 \qmlproperty bool BoxPlotSeries::boxOutlineVisible
221 This property configures the visibility of the middle box outline.
233 This property configures the visibility of the middle box outline.
222 */
234 */
223 /*!
235 /*!
224 \qmlproperty qreal BoxPlotSeries::boxWidth
236 \qmlproperty qreal BoxPlotSeries::boxWidth
225 This property configures the width of the box-and-whiskers item. The value signifies the relative
237 This property configures the width of the box-and-whiskers item. The value signifies the relative
226 width of the box-and-whiskers item inside its own slot. The value can between 0.0 and 1.0. Negative values
238 width of the box-and-whiskers item inside its own slot. The value can between 0.0 and 1.0. Negative values
227 are clamped to 0.0 and values over 1.0 are clamped to 1.0.
239 are clamped to 0.0 and values over 1.0 are clamped to 1.0.
228 */
240 */
229 /*!
241 /*!
230 \qmlproperty Pen BoxPlotSeries::pen
242 \qmlproperty Pen BoxPlotSeries::pen
231 This property configures the pen of the box-and-whiskers items.
243 This property configures the pen of the box-and-whiskers items.
232 */
244 */
233 /*!
245 /*!
234 \qmlproperty Brush BoxPlotSeries::brush
246 \qmlproperty Brush BoxPlotSeries::brush
235 This property configures the brush of the box-and-whiskers items.
247 This property configures the brush of the box-and-whiskers items.
236 */
248 */
237 /*!
249 /*!
238 \qmlproperty int BoxPlotSeries::count
250 \qmlproperty int BoxPlotSeries::count
239 The count of sets in series.
251 The count of sets in series.
240 */
252 */
241 /*!
253 /*!
242 \qmlsignal BoxPlotSeries::onBoxOutlineVisibilityChanged()
254 \qmlsignal BoxPlotSeries::onBoxOutlineVisibilityChanged()
243 Signal is emitted when the middle box outline visibility is changed.
255 Signal is emitted when the middle box outline visibility is changed.
244 */
256 */
245 /*!
257 /*!
246 \qmlsignal BoxPlotSeries::onBoxWidthChanged()
258 \qmlsignal BoxPlotSeries::onBoxWidthChanged()
247 Signal is emitted when the width of the box-and-whiskers item is changed.
259 Signal is emitted when the width of the box-and-whiskers item is changed.
248 */
260 */
249 /*!
261 /*!
250 \qmlsignal BoxPlotSeries::onPenChanged()
262 \qmlsignal BoxPlotSeries::onPenChanged()
251 Signal is emitted when the pen for box-and-whiskers items has changed.
263 Signal is emitted when the pen for box-and-whiskers items has changed.
252 */
264 */
253 /*!
265 /*!
254 \qmlsignal BoxPlotSeries::onBrushChanged()
266 \qmlsignal BoxPlotSeries::onBrushChanged()
255 Signal is emitted when the brush for box-and-whiskers items has changed.
267 Signal is emitted when the brush for box-and-whiskers items has changed.
256 */
268 */
257 /*!
269 /*!
258 \qmlsignal BoxPlotSeries::onClicked(BoxSet boxset)
259 Signal is emitted when the user clicks the \a boxset on the chart.
260 */
261 /*!
262 \qmlsignal BoxPlotSeries::onHovered(bool status, BoxSet boxset)
263 Signal is emitted when there is change in hover \a status over \a boxset.
264 */
265 /*!
266 \qmlsignal BoxPlotSeries::onAxisXChanged(AbstractAxis axis)
270 \qmlsignal BoxPlotSeries::onAxisXChanged(AbstractAxis axis)
267 Signal is emitted when there is change in X axis.
271 Signal is emitted when there is change in X axis.
268 */
272 */
269 /*!
273 /*!
270 \qmlsignal BoxPlotSeries::onAxisYChanged(AbstractAxis axis)
274 \qmlsignal BoxPlotSeries::onAxisYChanged(AbstractAxis axis)
271 Signal is emitted when there is change in Y axis.
275 Signal is emitted when there is change in Y axis.
272 */
276 */
273 /*!
277 /*!
274 \qmlsignal BoxPlotSeries::onAxisXTopChanged(AbstractAxis axis)
278 \qmlsignal BoxPlotSeries::onAxisXTopChanged(AbstractAxis axis)
275 Signal is emitted when there is change in top X axis.
279 Signal is emitted when there is change in top X axis.
276 */
280 */
277 /*!
281 /*!
278 \qmlsignal BoxPlotSeries::onAxisYRightChanged(AbstractAxis axis)
282 \qmlsignal BoxPlotSeries::onAxisYRightChanged(AbstractAxis axis)
279 Signal is emitted when there is change in Y right axis.
283 Signal is emitted when there is change in Y right axis.
280 */
284 */
281
285
282
286
283 DeclarativeBoxSet::DeclarativeBoxSet(const QString label, QObject *parent)
287 DeclarativeBoxSet::DeclarativeBoxSet(const QString label, QObject *parent)
284 : QBoxSet(label, parent)
288 : QBoxSet(label, parent)
285 {
289 {
286 connect(this, SIGNAL(valuesChanged()), this, SIGNAL(changedValues()));
290 connect(this, SIGNAL(valuesChanged()), this, SIGNAL(changedValues()));
287 connect(this, SIGNAL(valueChanged(int)), this, SIGNAL(changedValue(int)));
291 connect(this, SIGNAL(valueChanged(int)), this, SIGNAL(changedValue(int)));
288 connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged()));
292 connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged()));
289 }
293 }
290
294
291 QVariantList DeclarativeBoxSet::values()
295 QVariantList DeclarativeBoxSet::values()
292 {
296 {
293 QVariantList values;
297 QVariantList values;
294 for (int i(0); i < 5; i++)
298 for (int i(0); i < 5; i++)
295 values.append(QVariant(QBoxSet::at(i)));
299 values.append(QVariant(QBoxSet::at(i)));
296 return values;
300 return values;
297 }
301 }
298
302
299 void DeclarativeBoxSet::setValues(QVariantList values)
303 void DeclarativeBoxSet::setValues(QVariantList values)
300 {
304 {
301 for (int i(0); i < values.count(); i++) {
305 for (int i(0); i < values.count(); i++) {
302 if (values.at(i).canConvert(QVariant::Double))
306 if (values.at(i).canConvert(QVariant::Double))
303 QBoxSet::append(values[i].toDouble());
307 QBoxSet::append(values[i].toDouble());
304 }
308 }
305 }
309 }
306
310
307 QString DeclarativeBoxSet::brushFilename() const
311 QString DeclarativeBoxSet::brushFilename() const
308 {
312 {
309 return m_brushFilename;
313 return m_brushFilename;
310 }
314 }
311
315
312 void DeclarativeBoxSet::setBrushFilename(const QString &brushFilename)
316 void DeclarativeBoxSet::setBrushFilename(const QString &brushFilename)
313 {
317 {
314 QImage brushImage(brushFilename);
318 QImage brushImage(brushFilename);
315 if (QBoxSet::brush().textureImage() != brushImage) {
319 if (QBoxSet::brush().textureImage() != brushImage) {
316 QBrush brush = QBoxSet::brush();
320 QBrush brush = QBoxSet::brush();
317 brush.setTextureImage(brushImage);
321 brush.setTextureImage(brushImage);
318 QBoxSet::setBrush(brush);
322 QBoxSet::setBrush(brush);
319 m_brushFilename = brushFilename;
323 m_brushFilename = brushFilename;
320 m_brushImage = brushImage;
324 m_brushImage = brushImage;
321 emit brushFilenameChanged(brushFilename);
325 emit brushFilenameChanged(brushFilename);
322 }
326 }
323 }
327 }
324
328
325 void DeclarativeBoxSet::handleBrushChanged()
329 void DeclarativeBoxSet::handleBrushChanged()
326 {
330 {
327 // If the texture image of the brush has changed along the brush
331 // If the texture image of the brush has changed along the brush
328 // the brush file name needs to be cleared.
332 // the brush file name needs to be cleared.
329 if (!m_brushFilename.isEmpty() && QBoxSet::brush().textureImage() != m_brushImage) {
333 if (!m_brushFilename.isEmpty() && QBoxSet::brush().textureImage() != m_brushImage) {
330 m_brushFilename.clear();
334 m_brushFilename.clear();
331 emit brushFilenameChanged(QString(""));
335 emit brushFilenameChanged(QString(""));
332 }
336 }
333 }
337 }
334
338
335 // =====================================================
339 // =====================================================
336
340
337 DeclarativeBoxPlotSeries::DeclarativeBoxPlotSeries(QQuickItem *parent) :
341 DeclarativeBoxPlotSeries::DeclarativeBoxPlotSeries(QQuickItem *parent) :
338 QBoxPlotSeries(parent),
342 QBoxPlotSeries(parent),
339 m_axes(new DeclarativeAxes(this))
343 m_axes(new DeclarativeAxes(this))
340 {
344 {
341 connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*)));
345 connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*)));
342 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
346 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
343 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
347 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
344 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
348 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
345 connect(this, SIGNAL(hovered(bool, QBoxSet*)), this, SLOT(onHovered(bool, QBoxSet*)));
349 connect(this, SIGNAL(hovered(bool, QBoxSet*)), this, SLOT(onHovered(bool, QBoxSet*)));
346 connect(this, SIGNAL(clicked(QBoxSet*)), this, SLOT(onClicked(QBoxSet*)));
350 connect(this, SIGNAL(clicked(QBoxSet*)), this, SLOT(onClicked(QBoxSet*)));
347 connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged()));
351 connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged()));
348 connect(this, SIGNAL(pressed(QBoxSet*)), this, SLOT(onPressed(QBoxSet*)));
352 connect(this, SIGNAL(pressed(QBoxSet*)), this, SLOT(onPressed(QBoxSet*)));
349 connect(this, SIGNAL(released(QBoxSet*)), this, SLOT(onReleased(QBoxSet*)));
353 connect(this, SIGNAL(released(QBoxSet*)), this, SLOT(onReleased(QBoxSet*)));
350 connect(this, SIGNAL(doubleClicked(QBoxSet*)), this, SLOT(onDoubleClicked(QBoxSet*)));
354 connect(this, SIGNAL(doubleClicked(QBoxSet*)), this, SLOT(onDoubleClicked(QBoxSet*)));
351 }
355 }
352
356
353 void DeclarativeBoxPlotSeries::classBegin()
357 void DeclarativeBoxPlotSeries::classBegin()
354 {
358 {
355 }
359 }
356
360
357 void DeclarativeBoxPlotSeries::componentComplete()
361 void DeclarativeBoxPlotSeries::componentComplete()
358 {
362 {
359 foreach (QObject *child, children()) {
363 foreach (QObject *child, children()) {
360 if (qobject_cast<DeclarativeBoxSet *>(child)) {
364 if (qobject_cast<DeclarativeBoxSet *>(child)) {
361 QBoxPlotSeries::append(qobject_cast<DeclarativeBoxSet *>(child));
365 QBoxPlotSeries::append(qobject_cast<DeclarativeBoxSet *>(child));
362 } else if (qobject_cast<QVBoxPlotModelMapper *>(child)) {
366 } else if (qobject_cast<QVBoxPlotModelMapper *>(child)) {
363 QVBoxPlotModelMapper *mapper = qobject_cast<QVBoxPlotModelMapper *>(child);
367 QVBoxPlotModelMapper *mapper = qobject_cast<QVBoxPlotModelMapper *>(child);
364 mapper->setSeries(this);
368 mapper->setSeries(this);
365 }
369 }
366 }
370 }
367 }
371 }
368
372
369 QQmlListProperty<QObject> DeclarativeBoxPlotSeries::seriesChildren()
373 QQmlListProperty<QObject> DeclarativeBoxPlotSeries::seriesChildren()
370 {
374 {
371 return QQmlListProperty<QObject>(this, 0, &DeclarativeBoxPlotSeries::appendSeriesChildren ,0,0,0);
375 return QQmlListProperty<QObject>(this, 0, &DeclarativeBoxPlotSeries::appendSeriesChildren ,0,0,0);
372 }
376 }
373
377
374 void DeclarativeBoxPlotSeries::appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element)
378 void DeclarativeBoxPlotSeries::appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element)
375 {
379 {
376 // Empty implementation; the children are parsed in componentComplete instead
380 // Empty implementation; the children are parsed in componentComplete instead
377 Q_UNUSED(list);
381 Q_UNUSED(list);
378 Q_UNUSED(element);
382 Q_UNUSED(element);
379 }
383 }
380
384
381 DeclarativeBoxSet *DeclarativeBoxPlotSeries::at(int index)
385 DeclarativeBoxSet *DeclarativeBoxPlotSeries::at(int index)
382 {
386 {
383 QList<QBoxSet *> setList = boxSets();
387 QList<QBoxSet *> setList = boxSets();
384 if (index >= 0 && index < setList.count())
388 if (index >= 0 && index < setList.count())
385 return qobject_cast<DeclarativeBoxSet *>(setList[index]);
389 return qobject_cast<DeclarativeBoxSet *>(setList[index]);
386
390
387 return 0;
391 return 0;
388 }
392 }
389
393
390 DeclarativeBoxSet *DeclarativeBoxPlotSeries::insert(int index, const QString label, QVariantList values)
394 DeclarativeBoxSet *DeclarativeBoxPlotSeries::insert(int index, const QString label, QVariantList values)
391 {
395 {
392 DeclarativeBoxSet *barset = new DeclarativeBoxSet(label, this);
396 DeclarativeBoxSet *barset = new DeclarativeBoxSet(label, this);
393 barset->setValues(values);
397 barset->setValues(values);
394 if (QBoxPlotSeries::insert(index, barset))
398 if (QBoxPlotSeries::insert(index, barset))
395 return barset;
399 return barset;
396 delete barset;
400 delete barset;
397 return 0;
401 return 0;
398 }
402 }
399
403
400 void DeclarativeBoxPlotSeries::onHovered(bool status, QBoxSet *boxset)
404 void DeclarativeBoxPlotSeries::onHovered(bool status, QBoxSet *boxset)
401 {
405 {
402 emit hovered(status, qobject_cast<DeclarativeBoxSet *>(boxset));
406 emit hovered(status, qobject_cast<DeclarativeBoxSet *>(boxset));
403 }
407 }
404
408
405 void DeclarativeBoxPlotSeries::onClicked(QBoxSet *boxset)
409 void DeclarativeBoxPlotSeries::onClicked(QBoxSet *boxset)
406 {
410 {
407 emit clicked(qobject_cast<DeclarativeBoxSet *>(boxset));
411 emit clicked(qobject_cast<DeclarativeBoxSet *>(boxset));
408 }
412 }
409
413
410 void DeclarativeBoxPlotSeries::onPressed(QBoxSet *boxset)
414 void DeclarativeBoxPlotSeries::onPressed(QBoxSet *boxset)
411 {
415 {
412 emit pressed(qobject_cast<DeclarativeBoxSet *>(boxset));
416 emit pressed(qobject_cast<DeclarativeBoxSet *>(boxset));
413 }
417 }
414
418
415 void DeclarativeBoxPlotSeries::onReleased(QBoxSet *boxset)
419 void DeclarativeBoxPlotSeries::onReleased(QBoxSet *boxset)
416 {
420 {
417 emit released(qobject_cast<DeclarativeBoxSet *>(boxset));
421 emit released(qobject_cast<DeclarativeBoxSet *>(boxset));
418 }
422 }
419
423
420 void DeclarativeBoxPlotSeries::onDoubleClicked(QBoxSet *boxset)
424 void DeclarativeBoxPlotSeries::onDoubleClicked(QBoxSet *boxset)
421 {
425 {
422 emit doubleClicked(qobject_cast<DeclarativeBoxSet *>(boxset));
426 emit doubleClicked(qobject_cast<DeclarativeBoxSet *>(boxset));
423 }
427 }
424
428
425 QString DeclarativeBoxPlotSeries::brushFilename() const
429 QString DeclarativeBoxPlotSeries::brushFilename() const
426 {
430 {
427 return m_brushFilename;
431 return m_brushFilename;
428 }
432 }
429
433
430 void DeclarativeBoxPlotSeries::setBrushFilename(const QString &brushFilename)
434 void DeclarativeBoxPlotSeries::setBrushFilename(const QString &brushFilename)
431 {
435 {
432 QImage brushImage(brushFilename);
436 QImage brushImage(brushFilename);
433 if (QBoxPlotSeries::brush().textureImage() != brushImage) {
437 if (QBoxPlotSeries::brush().textureImage() != brushImage) {
434 QBrush brush = QBoxPlotSeries::brush();
438 QBrush brush = QBoxPlotSeries::brush();
435 brush.setTextureImage(brushImage);
439 brush.setTextureImage(brushImage);
436 QBoxPlotSeries::setBrush(brush);
440 QBoxPlotSeries::setBrush(brush);
437 m_brushFilename = brushFilename;
441 m_brushFilename = brushFilename;
438 m_brushImage = brushImage;
442 m_brushImage = brushImage;
439 emit brushFilenameChanged(brushFilename);
443 emit brushFilenameChanged(brushFilename);
440 }
444 }
441 }
445 }
442
446
443 void DeclarativeBoxPlotSeries::handleBrushChanged()
447 void DeclarativeBoxPlotSeries::handleBrushChanged()
444 {
448 {
445 // If the texture image of the brush has changed along the brush
449 // If the texture image of the brush has changed along the brush
446 // the brush file name needs to be cleared.
450 // the brush file name needs to be cleared.
447 if (!m_brushFilename.isEmpty() && QBoxPlotSeries::brush().textureImage() != m_brushImage) {
451 if (!m_brushFilename.isEmpty() && QBoxPlotSeries::brush().textureImage() != m_brushImage) {
448 m_brushFilename.clear();
452 m_brushFilename.clear();
449 emit brushFilenameChanged(QString(""));
453 emit brushFilenameChanged(QString(""));
450 }
454 }
451 }
455 }
452
456
453 #include "moc_declarativeboxplotseries.cpp"
457 #include "moc_declarativeboxplotseries.cpp"
454
458
455 QT_CHARTS_END_NAMESPACE
459 QT_CHARTS_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now