@@ -1,688 +1,688 | |||||
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 <QtCharts/QBarSet> |
|
19 | #include <QtCharts/QBarSet> | |
20 | #include <private/qbarset_p.h> |
|
20 | #include <private/qbarset_p.h> | |
21 | #include <private/charthelpers_p.h> |
|
21 | #include <private/charthelpers_p.h> | |
22 | #include <private/qchart_p.h> |
|
22 | #include <private/qchart_p.h> | |
23 |
|
23 | |||
24 | QT_CHARTS_BEGIN_NAMESPACE |
|
24 | QT_CHARTS_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QBarSet |
|
27 | \class QBarSet | |
28 | \inmodule Qt Charts |
|
28 | \inmodule Qt Charts | |
29 | \brief Building block for different bar charts. |
|
29 | \brief Building block for different bar charts. | |
30 |
|
30 | |||
31 | QBarSet represents one set of bars. Set of bars contains one data value for each category. |
|
31 | QBarSet represents one set of bars. Set of bars contains one data value for each category. | |
32 | First value of set is assumed to belong to first category, second to second category and so on. |
|
32 | First value of set is assumed to belong to first category, second to second category and so on. | |
33 | If set has fewer values than there are categories, then the missing values are assumed to be |
|
33 | If set has fewer values than there are categories, then the missing values are assumed to be | |
34 | at the end of set. For missing values in middle of a set, numerical value of zero is used. |
|
34 | at the end of set. For missing values in middle of a set, numerical value of zero is used. | |
35 |
|
35 | |||
36 | \mainclass |
|
36 | \mainclass | |
37 |
|
37 | |||
38 | \sa QAbstractBarSeries, QBarSeries, QStackedBarSeries, QPercentBarSeries |
|
38 | \sa QAbstractBarSeries, QBarSeries, QStackedBarSeries, QPercentBarSeries | |
39 | */ |
|
39 | */ | |
40 | /*! |
|
40 | /*! | |
41 | \qmltype BarSet |
|
41 | \qmltype BarSet | |
42 | \instantiates QBarSet |
|
42 | \instantiates QBarSet | |
43 | \inqmlmodule QtCharts |
|
43 | \inqmlmodule QtCharts | |
44 |
|
44 | |||
45 | \brief Building block for different bar charts. |
|
45 | \brief Building block for different bar charts. | |
46 |
|
46 | |||
47 | BarSet represents one set of bars. Set of bars contains one data value for each category. |
|
47 | BarSet represents one set of bars. Set of bars contains one data value for each category. | |
48 | First value of set is assumed to belong to first category, second to second category and so on. |
|
48 | First value of set is assumed to belong to first category, second to second category and so on. | |
49 | If set has fewer values than there are categories, then the missing values are assumed to be |
|
49 | If set has fewer values than there are categories, then the missing values are assumed to be | |
50 | at the end of set. For missing values in middle of a set, numerical value of zero is used. |
|
50 | at the end of set. For missing values in middle of a set, numerical value of zero is used. | |
51 | \sa AbstractBarSeries, BarSeries, StackedBarSeries, PercentBarSeries |
|
51 | \sa AbstractBarSeries, BarSeries, StackedBarSeries, PercentBarSeries | |
52 | */ |
|
52 | */ | |
53 |
|
53 | |||
54 | /*! |
|
54 | /*! | |
55 | \property QBarSet::label |
|
55 | \property QBarSet::label | |
56 | Defines the label of the bar set. |
|
56 | Defines the label of the bar set. | |
57 | */ |
|
57 | */ | |
58 | /*! |
|
58 | /*! | |
59 | \qmlproperty string BarSet::label |
|
59 | \qmlproperty string BarSet::label | |
60 | Defines the label of the bar set. |
|
60 | Defines the label of the bar set. | |
61 | */ |
|
61 | */ | |
62 |
|
62 | |||
63 | /*! |
|
63 | /*! | |
64 | \property QBarSet::pen |
|
64 | \property QBarSet::pen | |
65 | \brief Defines the pen used by the bar set. |
|
65 | \brief Defines the pen used by the bar set. | |
66 | */ |
|
66 | */ | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | \property QBarSet::brush |
|
69 | \property QBarSet::brush | |
70 | \brief Defines the brush used by the bar set. |
|
70 | \brief Defines the brush used by the bar set. | |
71 | */ |
|
71 | */ | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | \qmlproperty QString BarSet::brushFilename |
|
74 | \qmlproperty QString BarSet::brushFilename | |
75 | The name of the file used as a brush for the set. |
|
75 | The name of the file used as a brush for the set. | |
76 | */ |
|
76 | */ | |
77 |
|
77 | |||
78 | /*! |
|
78 | /*! | |
79 | \property QBarSet::labelBrush |
|
79 | \property QBarSet::labelBrush | |
80 | \brief Defines the brush used by the bar set's label. |
|
80 | \brief Defines the brush used by the bar set's label. | |
81 | */ |
|
81 | */ | |
82 |
|
82 | |||
83 | /*! |
|
83 | /*! | |
84 | \property QBarSet::labelFont |
|
84 | \property QBarSet::labelFont | |
85 | \brief Defines the font used by the bar set's label. |
|
85 | \brief Defines the font used by the bar set's label. | |
86 | */ |
|
86 | */ | |
87 |
|
87 | |||
88 | /*! |
|
88 | /*! | |
89 | \qmlproperty Font BarSet::labelFont |
|
89 | \qmlproperty Font BarSet::labelFont | |
90 | Defines the font used by the bar set's label. |
|
90 | Defines the font used by the bar set's label. | |
91 |
|
91 | |||
92 | See the Qt documentation for more details of Font. |
|
92 | See the Qt documentation for more details of Font. | |
93 | */ |
|
93 | */ | |
94 |
|
94 | |||
95 | /*! |
|
95 | /*! | |
96 | \property QBarSet::color |
|
96 | \property QBarSet::color | |
97 | The fill (brush) color of the bar set. |
|
97 | The fill (brush) color of the bar set. | |
98 | */ |
|
98 | */ | |
99 | /*! |
|
99 | /*! | |
100 | \qmlproperty color BarSet::color |
|
100 | \qmlproperty color BarSet::color | |
101 | The fill (brush) color of the bar set. |
|
101 | The fill (brush) color of the bar set. | |
102 | */ |
|
102 | */ | |
103 |
|
103 | |||
104 | /*! |
|
104 | /*! | |
105 | \property QBarSet::borderColor |
|
105 | \property QBarSet::borderColor | |
106 | The line (pen) color of the bar set. |
|
106 | The line (pen) color of the bar set. | |
107 | */ |
|
107 | */ | |
108 | /*! |
|
108 | /*! | |
109 | \qmlproperty color BarSet::borderColor |
|
109 | \qmlproperty color BarSet::borderColor | |
110 | The line (pen) color of the bar set. |
|
110 | The line (pen) color of the bar set. | |
111 | */ |
|
111 | */ | |
112 |
|
112 | |||
113 | /*! |
|
113 | /*! | |
114 | \qmlproperty real BarSet::borderWidth |
|
114 | \qmlproperty real BarSet::borderWidth | |
115 | The width of the border line. By default the width is 2.0. |
|
115 | The width of the border line. By default the width is 2.0. | |
116 | */ |
|
116 | */ | |
117 |
|
117 | |||
118 | /*! |
|
118 | /*! | |
119 | \property QBarSet::labelColor |
|
119 | \property QBarSet::labelColor | |
120 | The text (label) color of the bar set. |
|
120 | The text (label) color of the bar set. | |
121 | */ |
|
121 | */ | |
122 | /*! |
|
122 | /*! | |
123 | \qmlproperty color BarSet::labelColor |
|
123 | \qmlproperty color BarSet::labelColor | |
124 | The text (label) color of the bar set. |
|
124 | The text (label) color of the bar set. | |
125 | */ |
|
125 | */ | |
126 |
|
126 | |||
127 | /*! |
|
127 | /*! | |
128 | \fn void QBarSet::clicked(int index) |
|
128 | \fn void QBarSet::clicked(int index) | |
129 |
|
129 | |||
130 | The signal is emitted if the user clicks with a mouse on top of bar set. |
|
130 | The signal is emitted if the user clicks with a mouse on top of bar set. | |
131 | Clicked bar inside set is indexed by \a index |
|
131 | Clicked bar inside set is indexed by \a index | |
132 | */ |
|
132 | */ | |
133 |
|
133 | |||
134 | /*! |
|
134 | /*! | |
135 | \fn void QBarSet::pressed(int index) |
|
135 | \fn void QBarSet::pressed(int index) | |
136 |
|
136 | |||
137 | The signal is emitted if the user presses with a mouse on top of bar set. |
|
137 | The signal is emitted if the user presses with a mouse on top of bar set. | |
138 | Pressed bar inside set is indexed by \a index |
|
138 | Pressed bar inside set is indexed by \a index | |
139 | */ |
|
139 | */ | |
140 |
|
140 | |||
141 | /*! |
|
141 | /*! | |
142 | \fn void QBarSet::released(int index) |
|
142 | \fn void QBarSet::released(int index) | |
143 |
|
143 | |||
144 | The signal is emitted if the user releases with a mouse on top of bar set. |
|
144 | The signal is emitted if the user releases with a mouse on top of bar set. | |
145 | Released bar inside set is indexed by \a index |
|
145 | Released bar inside set is indexed by \a index | |
146 | */ |
|
146 | */ | |
147 |
|
147 | |||
148 | /*! |
|
148 | /*! | |
149 | \fn void QBarSet::doubleClicked(int index) |
|
149 | \fn void QBarSet::doubleClicked(int index) | |
150 |
|
150 | |||
151 | The signal is emitted if the user doubleclicks with a mouse on top of bar set. |
|
151 | The signal is emitted if the user doubleclicks with a mouse on top of bar set. | |
152 | Doubleclicked bar inside set is indexed by \a index |
|
152 | Doubleclicked bar inside set is indexed by \a index | |
153 | */ |
|
153 | */ | |
154 |
|
154 | |||
155 | /*! |
|
155 | /*! | |
156 | \fn void QBarSet::hovered(bool status, int index) |
|
156 | \fn void QBarSet::hovered(bool status, int index) | |
157 |
|
157 | |||
158 | The signal is emitted if mouse is hovered on top of bar set. |
|
158 | The signal is emitted if mouse is hovered on top of bar set. | |
159 | Parameter \a status is true, if mouse entered on top of bar set, false if mouse left from top of bar set. |
|
159 | Parameter \a status is true, if mouse entered on top of bar set, false if mouse left from top of bar set. | |
160 | Hovered bar inside the set is indexed by \a index. |
|
160 | Hovered bar inside the set is indexed by \a index. | |
161 | */ |
|
161 | */ | |
162 |
|
162 | |||
163 |
|
163 | |||
164 | /*! |
|
164 | /*! | |
165 | \fn void QBarSet::labelChanged() |
|
165 | \fn void QBarSet::labelChanged() | |
166 | This signal is emitted when the label of the bar set has changed. |
|
166 | This signal is emitted when the label of the bar set has changed. | |
167 | \sa label |
|
167 | \sa label | |
168 | */ |
|
168 | */ | |
169 | /*! |
|
169 | /*! | |
170 | \qmlsignal BarSet::onLabelChanged() |
|
170 | \qmlsignal BarSet::onLabelChanged() | |
171 | This signal is emitted when the label of the bar set has changed. |
|
171 | This signal is emitted when the label of the bar set has changed. | |
172 | */ |
|
172 | */ | |
173 |
|
173 | |||
174 | /*! |
|
174 | /*! | |
175 | \fn void QBarSet::penChanged() |
|
175 | \fn void QBarSet::penChanged() | |
176 | This signal is emitted when the pen of the bar set has changed. |
|
176 | This signal is emitted when the pen of the bar set has changed. | |
177 | \sa pen |
|
177 | \sa pen | |
178 | */ |
|
178 | */ | |
179 |
|
179 | |||
180 | /*! |
|
180 | /*! | |
181 | \fn void QBarSet::brushChanged() |
|
181 | \fn void QBarSet::brushChanged() | |
182 | This signal is emitted when the brush of the bar set has changed. |
|
182 | This signal is emitted when the brush of the bar set has changed. | |
183 | \sa brush |
|
183 | \sa brush | |
184 | */ |
|
184 | */ | |
185 |
|
185 | |||
186 | /*! |
|
186 | /*! | |
187 | \fn void QBarSet::labelBrushChanged() |
|
187 | \fn void QBarSet::labelBrushChanged() | |
188 | This signal is emitted when the brush of the bar set's label has changed. |
|
188 | This signal is emitted when the brush of the bar set's label has changed. | |
189 | \sa labelBrush |
|
189 | \sa labelBrush | |
190 | */ |
|
190 | */ | |
191 |
|
191 | |||
192 | /*! |
|
192 | /*! | |
193 | \fn void QBarSet::labelFontChanged() |
|
193 | \fn void QBarSet::labelFontChanged() | |
194 | This signal is emitted when the font of the bar set's label has changed. |
|
194 | This signal is emitted when the font of the bar set's label has changed. | |
195 | \sa labelBrush |
|
195 | \sa labelBrush | |
196 | */ |
|
196 | */ | |
197 |
|
197 | |||
198 | /*! |
|
198 | /*! | |
199 | \fn void QBarSet::colorChanged(QColor) |
|
199 | \fn void QBarSet::colorChanged(QColor) | |
200 | This signal is emitted when the fill (brush) color of the set has changed to \a color. |
|
200 | This signal is emitted when the fill (brush) color of the set has changed to \a color. | |
201 | */ |
|
201 | */ | |
202 | /*! |
|
202 | /*! | |
203 | \qmlsignal BarSet::onColorChanged(color color) |
|
203 | \qmlsignal BarSet::onColorChanged(color color) | |
204 | This signal is emitted when the fill (brush) color of the set has changed to \a color. |
|
204 | This signal is emitted when the fill (brush) color of the set has changed to \a color. | |
205 | */ |
|
205 | */ | |
206 |
|
206 | |||
207 | /*! |
|
207 | /*! | |
208 | \fn void QBarSet::borderColorChanged(QColor) |
|
208 | \fn void QBarSet::borderColorChanged(QColor) | |
209 | This signal is emitted when the line (pen) color of the set has changed to \a color. |
|
209 | This signal is emitted when the line (pen) color of the set has changed to \a color. | |
210 | */ |
|
210 | */ | |
211 | /*! |
|
211 | /*! | |
212 | \qmlsignal BarSet::onBorderColorChanged(color color) |
|
212 | \qmlsignal BarSet::onBorderColorChanged(color color) | |
213 | This signal is emitted when the line (pen) color of the set has changed to \a color. |
|
213 | This signal is emitted when the line (pen) color of the set has changed to \a color. | |
214 | */ |
|
214 | */ | |
215 |
|
215 | |||
216 | /*! |
|
216 | /*! | |
217 | \fn void QBarSet::labelColorChanged(QColor) |
|
217 | \fn void QBarSet::labelColorChanged(QColor) | |
218 | This signal is emitted when the text (label) color of the set has changed to \a color. |
|
218 | This signal is emitted when the text (label) color of the set has changed to \a color. | |
219 | */ |
|
219 | */ | |
220 | /*! |
|
220 | /*! | |
221 | \qmlsignal BarSet::onLabelColorChanged(color color) |
|
221 | \qmlsignal BarSet::onLabelColorChanged(color color) | |
222 | This signal is emitted when the text (label) color of the set has changed to \a color. |
|
222 | This signal is emitted when the text (label) color of the set has changed to \a color. | |
223 | */ |
|
223 | */ | |
224 |
|
224 | |||
225 | /*! |
|
225 | /*! | |
226 | \fn void QBarSet::valuesAdded(int index, int count) |
|
226 | \fn void QBarSet::valuesAdded(int index, int count) | |
227 | This signal is emitted when new values have been added to the set. |
|
227 | This signal is emitted when new values have been added to the set. | |
228 | Parameter \a index indicates the position of the first inserted value. |
|
228 | Parameter \a index indicates the position of the first inserted value. | |
229 | Parameter \a count is the number of inserted values. |
|
229 | Parameter \a count is the number of inserted values. | |
230 | \sa append(), insert() |
|
230 | \sa append(), insert() | |
231 | */ |
|
231 | */ | |
232 | /*! |
|
232 | /*! | |
233 | \qmlsignal BarSet::onValuesAdded(int index, int count) |
|
233 | \qmlsignal BarSet::onValuesAdded(int index, int count) | |
234 | This signal is emitted when new values have been added to the set. |
|
234 | This signal is emitted when new values have been added to the set. | |
235 | Parameter \a index indicates the position of the first inserted value. |
|
235 | Parameter \a index indicates the position of the first inserted value. | |
236 | Parameter \a count is the number of inserted values. |
|
236 | Parameter \a count is the number of inserted values. | |
237 | */ |
|
237 | */ | |
238 |
|
238 | |||
239 | /*! |
|
239 | /*! | |
240 | \fn void QBarSet::valuesRemoved(int index, int count) |
|
240 | \fn void QBarSet::valuesRemoved(int index, int count) | |
241 | This signal is emitted values have been removed from the set. |
|
241 | This signal is emitted values have been removed from the set. | |
242 | Parameter \a index indicates the position of the first removed value. |
|
242 | Parameter \a index indicates the position of the first removed value. | |
243 | Parameter \a count is the number of removed values. |
|
243 | Parameter \a count is the number of removed values. | |
244 | \sa remove() |
|
244 | \sa remove() | |
245 | */ |
|
245 | */ | |
246 | /*! |
|
246 | /*! | |
247 | \qmlsignal BarSet::onValuesRemoved(int index, int count) |
|
247 | \qmlsignal BarSet::onValuesRemoved(int index, int count) | |
248 | This signal is emitted values have been removed from the set. |
|
248 | This signal is emitted values have been removed from the set. | |
249 | Parameter \a index indicates the position of the first removed value. |
|
249 | Parameter \a index indicates the position of the first removed value. | |
250 | Parameter \a count is the number of removed values. |
|
250 | Parameter \a count is the number of removed values. | |
251 | */ |
|
251 | */ | |
252 |
|
252 | |||
253 | /*! |
|
253 | /*! | |
254 | \fn void QBarSet::valueChanged(int index) |
|
254 | \fn void QBarSet::valueChanged(int index) | |
255 | This signal is emitted values the value in the set has been modified. |
|
255 | This signal is emitted values the value in the set has been modified. | |
256 | Parameter \a index indicates the position of the modified value. |
|
256 | Parameter \a index indicates the position of the modified value. | |
257 | \sa at() |
|
257 | \sa at() | |
258 | */ |
|
258 | */ | |
259 | /*! |
|
259 | /*! | |
260 | \qmlsignal BarSet::onValueChanged(int index) |
|
260 | \qmlsignal BarSet::onValueChanged(int index) | |
261 | This signal is emitted values the value in the set has been modified. |
|
261 | This signal is emitted values the value in the set has been modified. | |
262 | Parameter \a index indicates the position of the modified value. |
|
262 | Parameter \a index indicates the position of the modified value. | |
263 | */ |
|
263 | */ | |
264 |
|
264 | |||
265 | /*! |
|
265 | /*! | |
266 | \qmlproperty int BarSet::count |
|
266 | \qmlproperty int BarSet::count | |
267 | The count of values on the bar set |
|
267 | The count of values on the bar set | |
268 | */ |
|
268 | */ | |
269 |
|
269 | |||
270 | /*! |
|
270 | /*! | |
271 | \qmlproperty QVariantList BarSet::values |
|
271 | \qmlproperty QVariantList BarSet::values | |
272 | The values of the bar set. You can set either a list of reals or a list of points as values. If you set a list of |
|
272 | The values of the bar set. You can set either a list of reals or a list of points as values. If you set a list of | |
273 | reals as values, the values are automatically completed to points by using the index of a value as it's |
|
273 | reals as values, the values are automatically completed to points by using the index of a value as it's | |
274 | x-coordinate. For example the following sets have equal values: |
|
274 | x-coordinate. For example the following sets have equal values: | |
275 | \code |
|
275 | \code | |
276 | myBarSet1.values = [0, 5, 1, 5]; |
|
276 | myBarSet1.values = [0, 5, 1, 5]; | |
277 | myBarSet2.values = [Qt.point(0, 0), Qt.point(1, 5), Qt.point(2, 1), Qt.point(3, 5)]; |
|
277 | myBarSet2.values = [Qt.point(0, 0), Qt.point(1, 5), Qt.point(2, 1), Qt.point(3, 5)]; | |
278 | \endcode |
|
278 | \endcode | |
279 | */ |
|
279 | */ | |
280 |
|
280 | |||
281 | /*! |
|
281 | /*! | |
282 | Constructs QBarSet with a label of \a label and with parent of \a parent. |
|
282 | Constructs QBarSet with a label of \a label and with parent of \a parent. | |
283 | */ |
|
283 | */ | |
284 | QBarSet::QBarSet(const QString label, QObject *parent) |
|
284 | QBarSet::QBarSet(const QString label, QObject *parent) | |
285 | : QObject(parent), |
|
285 | : QObject(parent), | |
286 | d_ptr(new QBarSetPrivate(label, this)) |
|
286 | d_ptr(new QBarSetPrivate(label, this)) | |
287 | { |
|
287 | { | |
288 | } |
|
288 | } | |
289 |
|
289 | |||
290 | /*! |
|
290 | /*! | |
291 | Destroys the bar set. |
|
291 | Destroys the bar set. | |
292 | */ |
|
292 | */ | |
293 | QBarSet::~QBarSet() |
|
293 | QBarSet::~QBarSet() | |
294 | { |
|
294 | { | |
295 | // NOTE: d_ptr destroyed by QObject |
|
295 | // NOTE: d_ptr destroyed by QObject | |
296 | } |
|
296 | } | |
297 |
|
297 | |||
298 | /*! |
|
298 | /*! | |
299 | Sets new \a label for set. |
|
299 | Sets new \a label for set. | |
300 | */ |
|
300 | */ | |
301 | void QBarSet::setLabel(const QString label) |
|
301 | void QBarSet::setLabel(const QString label) | |
302 | { |
|
302 | { | |
303 | d_ptr->m_label = label; |
|
303 | d_ptr->m_label = label; | |
304 | emit labelChanged(); |
|
304 | emit labelChanged(); | |
305 | } |
|
305 | } | |
306 |
|
306 | |||
307 | /*! |
|
307 | /*! | |
308 | Returns label of the set. |
|
308 | Returns label of the set. | |
309 | */ |
|
309 | */ | |
310 | QString QBarSet::label() const |
|
310 | QString QBarSet::label() const | |
311 | { |
|
311 | { | |
312 | return d_ptr->m_label; |
|
312 | return d_ptr->m_label; | |
313 | } |
|
313 | } | |
314 |
|
314 | |||
315 | /*! |
|
315 | /*! | |
316 | Appends new value \a value to the end of set. |
|
316 | Appends new value \a value to the end of set. | |
317 | */ |
|
317 | */ | |
318 | void QBarSet::append(const qreal value) |
|
318 | void QBarSet::append(const qreal value) | |
319 | { |
|
319 | { | |
320 | // Convert to QPointF |
|
320 | // Convert to QPointF | |
321 | int index = d_ptr->m_values.count(); |
|
321 | int index = d_ptr->m_values.count(); | |
322 | d_ptr->append(QPointF(d_ptr->m_values.count(), value)); |
|
322 | d_ptr->append(QPointF(d_ptr->m_values.count(), value)); | |
323 | emit valuesAdded(index, 1); |
|
323 | emit valuesAdded(index, 1); | |
324 | } |
|
324 | } | |
325 |
|
325 | |||
326 | /*! |
|
326 | /*! | |
327 | Appends a list of reals to set. Works like append with single real value. The \a values in list |
|
327 | Appends a list of reals to set. Works like append with single real value. The \a values in list | |
328 | are appended to end of bar set. |
|
328 | are appended to end of bar set. | |
329 | \sa append() |
|
329 | \sa append() | |
330 | */ |
|
330 | */ | |
331 | void QBarSet::append(const QList<qreal> &values) |
|
331 | void QBarSet::append(const QList<qreal> &values) | |
332 | { |
|
332 | { | |
333 | int index = d_ptr->m_values.count(); |
|
333 | int index = d_ptr->m_values.count(); | |
334 | d_ptr->append(values); |
|
334 | d_ptr->append(values); | |
335 | emit valuesAdded(index, values.count()); |
|
335 | emit valuesAdded(index, values.count()); | |
336 | } |
|
336 | } | |
337 |
|
337 | |||
338 | /*! |
|
338 | /*! | |
339 | Convenience operator. Same as append, with real \a value. |
|
339 | Convenience operator. Same as append, with real \a value. | |
340 | \sa append() |
|
340 | \sa append() | |
341 | */ |
|
341 | */ | |
342 | QBarSet &QBarSet::operator << (const qreal &value) |
|
342 | QBarSet &QBarSet::operator << (const qreal &value) | |
343 | { |
|
343 | { | |
344 | append(value); |
|
344 | append(value); | |
345 | return *this; |
|
345 | return *this; | |
346 | } |
|
346 | } | |
347 |
|
347 | |||
348 | /*! |
|
348 | /*! | |
349 | Inserts new \a value on the \a index position. |
|
349 | Inserts new \a value on the \a index position. | |
350 | The value that is currently at this postion is moved to position index + 1 |
|
350 | The value that is currently at this postion is moved to position index + 1 | |
351 | \sa remove() |
|
351 | \sa remove() | |
352 | */ |
|
352 | */ | |
353 | void QBarSet::insert(const int index, const qreal value) |
|
353 | void QBarSet::insert(const int index, const qreal value) | |
354 | { |
|
354 | { | |
355 | d_ptr->insert(index, value); |
|
355 | d_ptr->insert(index, value); | |
356 | emit valuesAdded(index, 1); |
|
356 | emit valuesAdded(index, 1); | |
357 | } |
|
357 | } | |
358 |
|
358 | |||
359 | /*! |
|
359 | /*! | |
360 | Removes \a count number of values from the set starting at \a index. |
|
360 | Removes \a count number of values from the set starting at \a index. | |
361 | \sa insert() |
|
361 | \sa insert() | |
362 | */ |
|
362 | */ | |
363 | void QBarSet::remove(const int index, const int count) |
|
363 | void QBarSet::remove(const int index, const int count) | |
364 | { |
|
364 | { | |
365 | int removedCount = d_ptr->remove(index, count); |
|
365 | int removedCount = d_ptr->remove(index, count); | |
366 | if (removedCount > 0) |
|
366 | if (removedCount > 0) | |
367 | emit valuesRemoved(index, removedCount); |
|
367 | emit valuesRemoved(index, removedCount); | |
368 | return; |
|
368 | return; | |
369 | } |
|
369 | } | |
370 |
|
370 | |||
371 | /*! |
|
371 | /*! | |
372 | Sets a new value \a value to set, indexed by \a index. |
|
372 | Sets a new value \a value to set, indexed by \a index. | |
373 | */ |
|
373 | */ | |
374 | void QBarSet::replace(const int index, const qreal value) |
|
374 | void QBarSet::replace(const int index, const qreal value) | |
375 | { |
|
375 | { | |
376 | if (index >= 0 && index < d_ptr->m_values.count()) { |
|
376 | if (index >= 0 && index < d_ptr->m_values.count()) { | |
377 | d_ptr->replace(index, value); |
|
377 | d_ptr->replace(index, value); | |
378 | emit valueChanged(index); |
|
378 | emit valueChanged(index); | |
379 | } |
|
379 | } | |
380 | } |
|
380 | } | |
381 |
|
381 | |||
382 |
|
382 | |||
383 | /*! |
|
383 | /*! | |
384 | Returns value of set indexed by \a index. |
|
384 | Returns value of set indexed by \a index. | |
385 | If the index is out of bounds 0.0 is returned. |
|
385 | If the index is out of bounds 0.0 is returned. | |
386 | */ |
|
386 | */ | |
387 | qreal QBarSet::at(const int index) const |
|
387 | qreal QBarSet::at(const int index) const | |
388 | { |
|
388 | { | |
389 | if (index < 0 || index >= d_ptr->m_values.count()) |
|
389 | if (index < 0 || index >= d_ptr->m_values.count()) | |
390 | return 0; |
|
390 | return 0; | |
391 | return d_ptr->m_values.at(index).y(); |
|
391 | return d_ptr->m_values.at(index).y(); | |
392 | } |
|
392 | } | |
393 |
|
393 | |||
394 | /*! |
|
394 | /*! | |
395 | Returns value of set indexed by \a index. |
|
395 | Returns value of set indexed by \a index. | |
396 | If the index is out of bounds 0.0 is returned. |
|
396 | If the index is out of bounds 0.0 is returned. | |
397 | */ |
|
397 | */ | |
398 | qreal QBarSet::operator [](const int index) const |
|
398 | qreal QBarSet::operator [](const int index) const | |
399 | { |
|
399 | { | |
400 | return at(index); |
|
400 | return at(index); | |
401 | } |
|
401 | } | |
402 |
|
402 | |||
403 | /*! |
|
403 | /*! | |
404 | Returns count of values in set. |
|
404 | Returns count of values in set. | |
405 | */ |
|
405 | */ | |
406 | int QBarSet::count() const |
|
406 | int QBarSet::count() const | |
407 | { |
|
407 | { | |
408 | return d_ptr->m_values.count(); |
|
408 | return d_ptr->m_values.count(); | |
409 | } |
|
409 | } | |
410 |
|
410 | |||
411 | /*! |
|
411 | /*! | |
412 | Returns sum of all values in the bar set. |
|
412 | Returns sum of all values in the bar set. | |
413 | */ |
|
413 | */ | |
414 | qreal QBarSet::sum() const |
|
414 | qreal QBarSet::sum() const | |
415 | { |
|
415 | { | |
416 | qreal total(0); |
|
416 | qreal total(0); | |
417 | for (int i = 0; i < d_ptr->m_values.count(); i++) |
|
417 | for (int i = 0; i < d_ptr->m_values.count(); i++) | |
418 | total += d_ptr->m_values.at(i).y(); |
|
418 | total += d_ptr->m_values.at(i).y(); | |
419 | return total; |
|
419 | return total; | |
420 | } |
|
420 | } | |
421 |
|
421 | |||
422 | /*! |
|
422 | /*! | |
423 | Sets pen for set. Bars of this set are drawn using \a pen |
|
423 | Sets pen for set. Bars of this set are drawn using \a pen | |
424 | */ |
|
424 | */ | |
425 | void QBarSet::setPen(const QPen &pen) |
|
425 | void QBarSet::setPen(const QPen &pen) | |
426 | { |
|
426 | { | |
427 | if (d_ptr->m_pen != pen) { |
|
427 | if (d_ptr->m_pen != pen) { | |
428 | d_ptr->m_pen = pen; |
|
428 | d_ptr->m_pen = pen; | |
429 | emit d_ptr->updatedBars(); |
|
429 | emit d_ptr->updatedBars(); | |
430 | emit penChanged(); |
|
430 | emit penChanged(); | |
431 | } |
|
431 | } | |
432 | } |
|
432 | } | |
433 |
|
433 | |||
434 | /*! |
|
434 | /*! | |
435 | Returns pen of the set. |
|
435 | Returns pen of the set. | |
436 | */ |
|
436 | */ | |
437 | QPen QBarSet::pen() const |
|
437 | QPen QBarSet::pen() const | |
438 | { |
|
438 | { | |
439 | if (d_ptr->m_pen == QChartPrivate::defaultPen()) |
|
439 | if (d_ptr->m_pen == QChartPrivate::defaultPen()) | |
440 | return QPen(); |
|
440 | return QPen(); | |
441 | else |
|
441 | else | |
442 | return d_ptr->m_pen; |
|
442 | return d_ptr->m_pen; | |
443 | } |
|
443 | } | |
444 |
|
444 | |||
445 | /*! |
|
445 | /*! | |
446 | Sets brush for the set. Bars of this set are drawn using \a brush. |
|
446 | Sets brush for the set. Bars of this set are drawn using \a brush. | |
447 | */ |
|
447 | */ | |
448 | void QBarSet::setBrush(const QBrush &brush) |
|
448 | void QBarSet::setBrush(const QBrush &brush) | |
449 | { |
|
449 | { | |
450 | if (d_ptr->m_brush != brush) { |
|
450 | if (d_ptr->m_brush != brush) { | |
451 | d_ptr->m_brush = brush; |
|
451 | d_ptr->m_brush = brush; | |
452 | emit d_ptr->updatedBars(); |
|
452 | emit d_ptr->updatedBars(); | |
453 | emit brushChanged(); |
|
453 | emit brushChanged(); | |
454 | } |
|
454 | } | |
455 | } |
|
455 | } | |
456 |
|
456 | |||
457 | /*! |
|
457 | /*! | |
458 | Returns brush of the set. |
|
458 | Returns brush of the set. | |
459 | */ |
|
459 | */ | |
460 | QBrush QBarSet::brush() const |
|
460 | QBrush QBarSet::brush() const | |
461 | { |
|
461 | { | |
462 | if (d_ptr->m_brush == QChartPrivate::defaultBrush()) |
|
462 | if (d_ptr->m_brush == QChartPrivate::defaultBrush()) | |
463 | return QBrush(); |
|
463 | return QBrush(); | |
464 | else |
|
464 | else | |
465 | return d_ptr->m_brush; |
|
465 | return d_ptr->m_brush; | |
466 | } |
|
466 | } | |
467 |
|
467 | |||
468 | /*! |
|
468 | /*! | |
469 | Sets \a brush of the values that are drawn on top of this bar set. |
|
469 | Sets \a brush of the values that are drawn on top of this bar set. | |
470 | */ |
|
470 | */ | |
471 | void QBarSet::setLabelBrush(const QBrush &brush) |
|
471 | void QBarSet::setLabelBrush(const QBrush &brush) | |
472 | { |
|
472 | { | |
473 | if (d_ptr->m_labelBrush != brush) { |
|
473 | if (d_ptr->m_labelBrush != brush) { | |
474 | d_ptr->m_labelBrush = brush; |
|
474 | d_ptr->m_labelBrush = brush; | |
475 | emit d_ptr->updatedBars(); |
|
475 | emit d_ptr->updatedBars(); | |
476 | emit labelBrushChanged(); |
|
476 | emit labelBrushChanged(); | |
477 | } |
|
477 | } | |
478 | } |
|
478 | } | |
479 |
|
479 | |||
480 | /*! |
|
480 | /*! | |
481 | Returns brush of the values that are drawn on top of this bar set. |
|
481 | Returns brush of the values that are drawn on top of this bar set. | |
482 | */ |
|
482 | */ | |
483 | QBrush QBarSet::labelBrush() const |
|
483 | QBrush QBarSet::labelBrush() const | |
484 | { |
|
484 | { | |
485 | if (d_ptr->m_labelBrush == QChartPrivate::defaultBrush()) |
|
485 | if (d_ptr->m_labelBrush == QChartPrivate::defaultBrush()) | |
486 | return QBrush(); |
|
486 | return QBrush(); | |
487 | else |
|
487 | else | |
488 | return d_ptr->m_labelBrush; |
|
488 | return d_ptr->m_labelBrush; | |
489 | } |
|
489 | } | |
490 |
|
490 | |||
491 | /*! |
|
491 | /*! | |
492 | Sets the \a font for values that are drawn on top of this bar set. |
|
492 | Sets the \a font for values that are drawn on top of this bar set. | |
493 | */ |
|
493 | */ | |
494 | void QBarSet::setLabelFont(const QFont &font) |
|
494 | void QBarSet::setLabelFont(const QFont &font) | |
495 | { |
|
495 | { | |
496 | if (d_ptr->m_labelFont != font) { |
|
496 | if (d_ptr->m_labelFont != font) { | |
497 | d_ptr->m_labelFont = font; |
|
497 | d_ptr->m_labelFont = font; | |
498 | emit d_ptr->updatedBars(); |
|
498 | emit d_ptr->updatedBars(); | |
499 | emit labelFontChanged(); |
|
499 | emit labelFontChanged(); | |
500 | } |
|
500 | } | |
501 |
|
501 | |||
502 | } |
|
502 | } | |
503 |
|
503 | |||
504 | /*! |
|
504 | /*! | |
505 | Returns the pen for values that are drawn on top of this bar set. |
|
505 | Returns the pen for values that are drawn on top of this bar set. | |
506 | */ |
|
506 | */ | |
507 | QFont QBarSet::labelFont() const |
|
507 | QFont QBarSet::labelFont() const | |
508 | { |
|
508 | { | |
509 | return d_ptr->m_labelFont; |
|
509 | return d_ptr->m_labelFont; | |
510 | } |
|
510 | } | |
511 |
|
511 | |||
512 | /*! |
|
512 | /*! | |
513 | Returns the color of the brush of bar set. |
|
513 | Returns the color of the brush of bar set. | |
514 | */ |
|
514 | */ | |
515 | QColor QBarSet::color() |
|
515 | QColor QBarSet::color() | |
516 | { |
|
516 | { | |
517 | return brush().color(); |
|
517 | return brush().color(); | |
518 | } |
|
518 | } | |
519 |
|
519 | |||
520 | /*! |
|
520 | /*! | |
521 | Sets the \a color of brush for this bar set. |
|
521 | Sets the \a color of brush for this bar set. | |
522 | */ |
|
522 | */ | |
523 | void QBarSet::setColor(QColor color) |
|
523 | void QBarSet::setColor(QColor color) | |
524 | { |
|
524 | { | |
525 | QBrush b = brush(); |
|
525 | QBrush b = brush(); | |
526 | if ((b.color() != color) || (b.style() == Qt::NoBrush)) { |
|
526 | if ((b.color() != color) || (b.style() == Qt::NoBrush)) { | |
527 | b.setColor(color); |
|
527 | b.setColor(color); | |
528 | if (b.style() == Qt::NoBrush) { |
|
528 | if (b.style() == Qt::NoBrush) { | |
529 | // Set tyle to Qt::SolidPattern. (Default is Qt::NoBrush) |
|
529 | // Set tyle to Qt::SolidPattern. (Default is Qt::NoBrush) | |
530 | // This prevents theme to override color defined in QML side: |
|
530 | // This prevents theme to override color defined in QML side: | |
531 | // BarSet { label: "Bob"; color:"red"; values: [1,2,3] } |
|
531 | // BarSet { label: "Bob"; color:"red"; values: [1,2,3] } | |
532 | // The color must be obeyed, since user wanted it. |
|
532 | // The color must be obeyed, since user wanted it. | |
533 | b.setStyle(Qt::SolidPattern); |
|
533 | b.setStyle(Qt::SolidPattern); | |
534 | } |
|
534 | } | |
535 | setBrush(b); |
|
535 | setBrush(b); | |
536 | emit colorChanged(color); |
|
536 | emit colorChanged(color); | |
537 | } |
|
537 | } | |
538 | } |
|
538 | } | |
539 |
|
539 | |||
540 | /*! |
|
540 | /*! | |
541 | Returns the color of pen of this bar set. |
|
541 | Returns the color of pen of this bar set. | |
542 | */ |
|
542 | */ | |
543 | QColor QBarSet::borderColor() |
|
543 | QColor QBarSet::borderColor() | |
544 | { |
|
544 | { | |
545 | return pen().color(); |
|
545 | return pen().color(); | |
546 | } |
|
546 | } | |
547 |
|
547 | |||
548 | /*! |
|
548 | /*! | |
549 | Sets the color of pen for this bar set. |
|
549 | Sets the color of pen for this bar set. | |
550 | */ |
|
550 | */ | |
551 | void QBarSet::setBorderColor(QColor color) |
|
551 | void QBarSet::setBorderColor(QColor color) | |
552 | { |
|
552 | { | |
553 | QPen p = pen(); |
|
553 | QPen p = pen(); | |
554 | if (p.color() != color) { |
|
554 | if (p.color() != color) { | |
555 | p.setColor(color); |
|
555 | p.setColor(color); | |
556 | setPen(p); |
|
556 | setPen(p); | |
557 | emit borderColorChanged(color); |
|
557 | emit borderColorChanged(color); | |
558 | } |
|
558 | } | |
559 | } |
|
559 | } | |
560 |
|
560 | |||
561 | /*! |
|
561 | /*! | |
562 | Returns the color of labels of this bar set. |
|
562 | Returns the color of labels of this bar set. | |
563 | */ |
|
563 | */ | |
564 | QColor QBarSet::labelColor() |
|
564 | QColor QBarSet::labelColor() | |
565 | { |
|
565 | { | |
566 | return labelBrush().color(); |
|
566 | return labelBrush().color(); | |
567 | } |
|
567 | } | |
568 |
|
568 | |||
569 | /*! |
|
569 | /*! | |
570 | Sets the color of labels for this bar set. |
|
570 | Sets the color of labels for this bar set. | |
571 | */ |
|
571 | */ | |
572 | void QBarSet::setLabelColor(QColor color) |
|
572 | void QBarSet::setLabelColor(QColor color) | |
573 | { |
|
573 | { | |
574 | QBrush b = labelBrush(); |
|
574 | QBrush b = labelBrush(); | |
575 | if (b == QBrush()) |
|
575 | if (b == QBrush()) | |
576 | b.setStyle(Qt::SolidPattern); |
|
576 | b.setStyle(Qt::SolidPattern); | |
577 |
|
577 | |||
578 | if (b.color() != color) { |
|
578 | if (d_ptr->m_labelBrush.color() != color) { | |
579 | b.setColor(color); |
|
579 | b.setColor(color); | |
580 | setLabelBrush(b); |
|
580 | setLabelBrush(b); | |
581 | emit labelColorChanged(color); |
|
581 | emit labelColorChanged(color); | |
582 | } |
|
582 | } | |
583 | } |
|
583 | } | |
584 |
|
584 | |||
585 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
585 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
586 |
|
586 | |||
587 | QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent), |
|
587 | QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent), | |
588 | q_ptr(parent), |
|
588 | q_ptr(parent), | |
589 | m_label(label), |
|
589 | m_label(label), | |
590 | m_pen(QChartPrivate::defaultPen()), |
|
590 | m_pen(QChartPrivate::defaultPen()), | |
591 | m_brush(QChartPrivate::defaultBrush()), |
|
591 | m_brush(QChartPrivate::defaultBrush()), | |
592 | m_labelBrush(QChartPrivate::defaultBrush()) |
|
592 | m_labelBrush(QChartPrivate::defaultBrush()) | |
593 | { |
|
593 | { | |
594 | } |
|
594 | } | |
595 |
|
595 | |||
596 | QBarSetPrivate::~QBarSetPrivate() |
|
596 | QBarSetPrivate::~QBarSetPrivate() | |
597 | { |
|
597 | { | |
598 | } |
|
598 | } | |
599 |
|
599 | |||
600 | void QBarSetPrivate::append(QPointF value) |
|
600 | void QBarSetPrivate::append(QPointF value) | |
601 | { |
|
601 | { | |
602 | if (isValidValue(value)) { |
|
602 | if (isValidValue(value)) { | |
603 | m_values.append(value); |
|
603 | m_values.append(value); | |
604 | emit restructuredBars(); |
|
604 | emit restructuredBars(); | |
605 | } |
|
605 | } | |
606 | } |
|
606 | } | |
607 |
|
607 | |||
608 | void QBarSetPrivate::append(QList<QPointF> values) |
|
608 | void QBarSetPrivate::append(QList<QPointF> values) | |
609 | { |
|
609 | { | |
610 | for (int i = 0; i < values.count(); i++) { |
|
610 | for (int i = 0; i < values.count(); i++) { | |
611 | if (isValidValue(values.at(i))) |
|
611 | if (isValidValue(values.at(i))) | |
612 | m_values.append(values.at(i)); |
|
612 | m_values.append(values.at(i)); | |
613 | } |
|
613 | } | |
614 | emit restructuredBars(); |
|
614 | emit restructuredBars(); | |
615 | } |
|
615 | } | |
616 |
|
616 | |||
617 | void QBarSetPrivate::append(QList<qreal> values) |
|
617 | void QBarSetPrivate::append(QList<qreal> values) | |
618 | { |
|
618 | { | |
619 | int index = m_values.count(); |
|
619 | int index = m_values.count(); | |
620 | for (int i = 0; i < values.count(); i++) { |
|
620 | for (int i = 0; i < values.count(); i++) { | |
621 | if (isValidValue(values.at(i))) { |
|
621 | if (isValidValue(values.at(i))) { | |
622 | m_values.append(QPointF(index, values.at(i))); |
|
622 | m_values.append(QPointF(index, values.at(i))); | |
623 | index++; |
|
623 | index++; | |
624 | } |
|
624 | } | |
625 | } |
|
625 | } | |
626 | emit restructuredBars(); |
|
626 | emit restructuredBars(); | |
627 | } |
|
627 | } | |
628 |
|
628 | |||
629 | void QBarSetPrivate::insert(const int index, const qreal value) |
|
629 | void QBarSetPrivate::insert(const int index, const qreal value) | |
630 | { |
|
630 | { | |
631 | m_values.insert(index, QPointF(index, value)); |
|
631 | m_values.insert(index, QPointF(index, value)); | |
632 | emit restructuredBars(); |
|
632 | emit restructuredBars(); | |
633 | } |
|
633 | } | |
634 |
|
634 | |||
635 | void QBarSetPrivate::insert(const int index, const QPointF value) |
|
635 | void QBarSetPrivate::insert(const int index, const QPointF value) | |
636 | { |
|
636 | { | |
637 | m_values.insert(index, value); |
|
637 | m_values.insert(index, value); | |
638 | emit restructuredBars(); |
|
638 | emit restructuredBars(); | |
639 | } |
|
639 | } | |
640 |
|
640 | |||
641 | int QBarSetPrivate::remove(const int index, const int count) |
|
641 | int QBarSetPrivate::remove(const int index, const int count) | |
642 | { |
|
642 | { | |
643 | int removeCount = count; |
|
643 | int removeCount = count; | |
644 |
|
644 | |||
645 | if ((index < 0) || (m_values.count() == 0)) |
|
645 | if ((index < 0) || (m_values.count() == 0)) | |
646 | return 0; // Invalid index or not values in list, remove nothing. |
|
646 | return 0; // Invalid index or not values in list, remove nothing. | |
647 | else if ((index + count) > m_values.count()) |
|
647 | else if ((index + count) > m_values.count()) | |
648 | removeCount = m_values.count() - index; // Trying to remove more items than list has. Limit amount to be removed. |
|
648 | removeCount = m_values.count() - index; // Trying to remove more items than list has. Limit amount to be removed. | |
649 |
|
649 | |||
650 | int c = 0; |
|
650 | int c = 0; | |
651 | while (c < removeCount) { |
|
651 | while (c < removeCount) { | |
652 | m_values.removeAt(index); |
|
652 | m_values.removeAt(index); | |
653 | c++; |
|
653 | c++; | |
654 | } |
|
654 | } | |
655 | emit restructuredBars(); |
|
655 | emit restructuredBars(); | |
656 | return removeCount; |
|
656 | return removeCount; | |
657 | } |
|
657 | } | |
658 |
|
658 | |||
659 | void QBarSetPrivate::replace(const int index, const qreal value) |
|
659 | void QBarSetPrivate::replace(const int index, const qreal value) | |
660 | { |
|
660 | { | |
661 | m_values.replace(index, QPointF(index, value)); |
|
661 | m_values.replace(index, QPointF(index, value)); | |
662 | emit updatedLayout(); |
|
662 | emit updatedLayout(); | |
663 | } |
|
663 | } | |
664 |
|
664 | |||
665 | void QBarSetPrivate::replace(const int index, const QPointF value) |
|
665 | void QBarSetPrivate::replace(const int index, const QPointF value) | |
666 | { |
|
666 | { | |
667 | m_values.replace(index, value); |
|
667 | m_values.replace(index, value); | |
668 | emit updatedLayout(); |
|
668 | emit updatedLayout(); | |
669 | } |
|
669 | } | |
670 |
|
670 | |||
671 | qreal QBarSetPrivate::pos(const int index) |
|
671 | qreal QBarSetPrivate::pos(const int index) | |
672 | { |
|
672 | { | |
673 | if (index < 0 || index >= m_values.count()) |
|
673 | if (index < 0 || index >= m_values.count()) | |
674 | return 0; |
|
674 | return 0; | |
675 | return m_values.at(index).x(); |
|
675 | return m_values.at(index).x(); | |
676 | } |
|
676 | } | |
677 |
|
677 | |||
678 | qreal QBarSetPrivate::value(const int index) |
|
678 | qreal QBarSetPrivate::value(const int index) | |
679 | { |
|
679 | { | |
680 | if (index < 0 || index >= m_values.count()) |
|
680 | if (index < 0 || index >= m_values.count()) | |
681 | return 0; |
|
681 | return 0; | |
682 | return m_values.at(index).y(); |
|
682 | return m_values.at(index).y(); | |
683 | } |
|
683 | } | |
684 |
|
684 | |||
685 | #include "moc_qbarset.cpp" |
|
685 | #include "moc_qbarset.cpp" | |
686 | #include "moc_qbarset_p.cpp" |
|
686 | #include "moc_qbarset_p.cpp" | |
687 |
|
687 | |||
688 | QT_CHARTS_END_NAMESPACE |
|
688 | QT_CHARTS_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now