@@ -1,639 +1,639 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qbarset.h" |
|
21 | #include "qbarset.h" | |
22 | #include "qbarset_p.h" |
|
22 | #include "qbarset_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QBarSet |
|
27 | \class QBarSet | |
28 | \brief part of QtCommercial chart API. |
|
28 | \brief part of QtCommercial chart API. | |
29 |
|
29 | |||
30 | QBarSet represents one set of bars. Set of bars contains one data value for each category. |
|
30 | QBarSet represents one set of bars. Set of bars contains one data value for each category. | |
31 | First value of set is assumed to belong to first category, second to second category and so on. |
|
31 | First value of set is assumed to belong to first category, second to second category and so on. | |
32 | If set has fewer values than there are categories, then the missing values are assumed to be |
|
32 | If set has fewer values than there are categories, then the missing values are assumed to be | |
33 | at the end of set. For missing values in middle of a set, numerical value of zero is used. |
|
33 | at the end of set. For missing values in middle of a set, numerical value of zero is used. | |
34 |
|
34 | |||
35 | \mainclass |
|
35 | \mainclass | |
36 |
|
36 | |||
37 | \sa QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries |
|
37 | \sa QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries | |
38 | */ |
|
38 | */ | |
39 | /*! |
|
39 | /*! | |
40 | \qmlclass BarSet QBarSet |
|
40 | \qmlclass BarSet QBarSet | |
41 |
|
41 | |||
42 | BarSet represents one set of bars. Set of bars contains one data value for each category. |
|
42 | BarSet represents one set of bars. Set of bars contains one data value for each category. | |
43 | First value of set is assumed to belong to first category, second to second category and so on. |
|
43 | First value of set is assumed to belong to first category, second to second category and so on. | |
44 | If set has fewer values than there are categories, then the missing values are assumed to be |
|
44 | If set has fewer values than there are categories, then the missing values are assumed to be | |
45 | at the end of set. For missing values in middle of a set, numerical value of zero is used. |
|
45 | at the end of set. For missing values in middle of a set, numerical value of zero is used. | |
46 | \sa BarSeries, GroupedBarSeries, StackedBarSeries, PercentBarSeries |
|
46 | \sa BarSeries, GroupedBarSeries, StackedBarSeries, PercentBarSeries | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \property QBarSet::label |
|
50 | \property QBarSet::label | |
51 | Defines the label of the barSet. |
|
51 | Defines the label of the barSet. | |
52 | */ |
|
52 | */ | |
53 | /*! |
|
53 | /*! | |
54 | \qmlproperty string BarSet::label |
|
54 | \qmlproperty string BarSet::label | |
55 | Defines the label of the barSet. |
|
55 | Defines the label of the barSet. | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \property QBarSet::pen |
|
59 | \property QBarSet::pen | |
60 | \brief Defines the pen used by the barSet. |
|
60 | \brief Defines the pen used by the barSet. | |
61 | */ |
|
61 | */ | |
62 |
|
62 | |||
63 | /*! |
|
63 | /*! | |
64 | \property QBarSet::brush |
|
64 | \property QBarSet::brush | |
65 | \brief Defines the brush used by the barSet. |
|
65 | \brief Defines the brush used by the barSet. | |
66 | */ |
|
66 | */ | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | \property QBarSet::labelBrush |
|
69 | \property QBarSet::labelBrush | |
70 | \brief Defines the brush used by the barSet's label. |
|
70 | \brief Defines the brush used by the barSet's label. | |
71 | */ |
|
71 | */ | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | \property QBarSet::labelFont |
|
74 | \property QBarSet::labelFont | |
75 | \brief Defines the font used by the barSet's label. |
|
75 | \brief Defines the font used by the barSet's label. | |
76 | */ |
|
76 | */ | |
77 |
|
77 | |||
78 | /*! |
|
78 | /*! | |
79 | \property QBarSet::color |
|
79 | \property QBarSet::color | |
80 | The fill (brush) color of the bar set. |
|
80 | The fill (brush) color of the bar set. | |
81 | */ |
|
81 | */ | |
82 | /*! |
|
82 | /*! | |
83 | \qmlproperty color BarSet::color |
|
83 | \qmlproperty color BarSet::color | |
84 | The fill (brush) color of the bar set. |
|
84 | The fill (brush) color of the bar set. | |
85 | */ |
|
85 | */ | |
86 |
|
86 | |||
87 | /*! |
|
87 | /*! | |
88 | \property QBarSet::borderColor |
|
88 | \property QBarSet::borderColor | |
89 | The line (pen) color of the bar set. |
|
89 | The line (pen) color of the bar set. | |
90 | */ |
|
90 | */ | |
91 | /*! |
|
91 | /*! | |
92 | \qmlproperty color BarSet::borderColor |
|
92 | \qmlproperty color BarSet::borderColor | |
93 | The line (pen) color of the bar set. |
|
93 | The line (pen) color of the bar set. | |
94 | */ |
|
94 | */ | |
95 |
|
95 | |||
96 | /*! |
|
96 | /*! | |
97 | \property QBarSet::labelColor |
|
97 | \property QBarSet::labelColor | |
98 | The text (label) color of the bar set. |
|
98 | The text (label) color of the bar set. | |
99 | */ |
|
99 | */ | |
100 | /*! |
|
100 | /*! | |
101 | \qmlproperty color BarSet::labelColor |
|
101 | \qmlproperty color BarSet::labelColor | |
102 | The text (label) color of the bar set. |
|
102 | The text (label) color of the bar set. | |
103 | */ |
|
103 | */ | |
104 |
|
104 | |||
105 | /*! |
|
105 | /*! | |
106 | \fn void QBarSet::clicked(int index) |
|
106 | \fn void QBarSet::clicked(int index) | |
107 |
|
107 | |||
108 | The signal is emitted if the user clicks with a mouse on top of barset. |
|
108 | The signal is emitted if the user clicks with a mouse on top of barset. | |
109 | Clicked bar inside set is indexed by \a index |
|
109 | Clicked bar inside set is indexed by \a index | |
110 | */ |
|
110 | */ | |
111 |
|
111 | |||
112 | /*! |
|
112 | /*! | |
113 | \fn void QBarSet::hovered(bool status) |
|
113 | \fn void QBarSet::hovered(bool status) | |
114 |
|
114 | |||
115 | The signal is emitted if mouse is hovered on top of barset. |
|
115 | The signal is emitted if mouse is hovered on top of barset. | |
116 | Parameter \a status is true, if mouse entered on top of barset, false if mouse left from top of barset. |
|
116 | Parameter \a status is true, if mouse entered on top of barset, false if mouse left from top of barset. | |
117 | */ |
|
117 | */ | |
118 |
|
118 | |||
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | \fn void QBarSet::labelChanged() |
|
121 | \fn void QBarSet::labelChanged() | |
122 | This signal is emitted when the label of the barSet has changed. |
|
122 | This signal is emitted when the label of the barSet has changed. | |
123 | \sa label |
|
123 | \sa label | |
124 | */ |
|
124 | */ | |
125 |
|
125 | |||
126 | /*! |
|
126 | /*! | |
127 | \fn void QBarSet::penChanged() |
|
127 | \fn void QBarSet::penChanged() | |
128 | This signal is emitted when the pen of the barSet has changed. |
|
128 | This signal is emitted when the pen of the barSet has changed. | |
129 | \sa pen |
|
129 | \sa pen | |
130 | */ |
|
130 | */ | |
131 |
|
131 | |||
132 | /*! |
|
132 | /*! | |
133 | \fn void QBarSet::brushChanged() |
|
133 | \fn void QBarSet::brushChanged() | |
134 | This signal is emitted when the brush of the barSet has changed. |
|
134 | This signal is emitted when the brush of the barSet has changed. | |
135 | \sa brush |
|
135 | \sa brush | |
136 | */ |
|
136 | */ | |
137 |
|
137 | |||
138 | /*! |
|
138 | /*! | |
139 | \fn void QBarSet::labelBrushChanged() |
|
139 | \fn void QBarSet::labelBrushChanged() | |
140 | This signal is emitted when the brush of the barSet's label has changed. |
|
140 | This signal is emitted when the brush of the barSet's label has changed. | |
141 | \sa labelBrush |
|
141 | \sa labelBrush | |
142 | */ |
|
142 | */ | |
143 |
|
143 | |||
144 | /*! |
|
144 | /*! | |
145 | \fn void QBarSet::labelFontChanged() |
|
145 | \fn void QBarSet::labelFontChanged() | |
146 | This signal is emitted when the font of the barSet's label has changed. |
|
146 | This signal is emitted when the font of the barSet's label has changed. | |
147 | \sa labelBrush |
|
147 | \sa labelBrush | |
148 | */ |
|
148 | */ | |
149 |
|
149 | |||
150 | /*! |
|
150 | /*! | |
151 | \fn void QBarSet::colorChanged(QColor) |
|
151 | \fn void QBarSet::colorChanged(QColor) | |
152 | This signal is emitted when the fill (brush) color of the set has changed to \a color. |
|
152 | This signal is emitted when the fill (brush) color of the set has changed to \a color. | |
153 | */ |
|
153 | */ | |
154 | /*! |
|
154 | /*! | |
155 | \qmlsignal BarSet::onColorChanged(color color) |
|
155 | \qmlsignal BarSet::onColorChanged(color color) | |
156 | This signal is emitted when the fill (brush) color of the set has changed to \a color. |
|
156 | This signal is emitted when the fill (brush) color of the set has changed to \a color. | |
157 | */ |
|
157 | */ | |
158 |
|
158 | |||
159 | /*! |
|
159 | /*! | |
160 | \fn void QBarSet::borderColorChanged(QColor) |
|
160 | \fn void QBarSet::borderColorChanged(QColor) | |
161 | This signal is emitted when the line (pen) color of the set has changed to \a color. |
|
161 | This signal is emitted when the line (pen) color of the set has changed to \a color. | |
162 | */ |
|
162 | */ | |
163 | /*! |
|
163 | /*! | |
164 | \qmlsignal BarSet::onBorderColorChanged(color color) |
|
164 | \qmlsignal BarSet::onBorderColorChanged(color color) | |
165 | This signal is emitted when the line (pen) color of the set has changed to \a color. |
|
165 | This signal is emitted when the line (pen) color of the set has changed to \a color. | |
166 | */ |
|
166 | */ | |
167 |
|
167 | |||
168 | /*! |
|
168 | /*! | |
169 | \fn void QBarSet::labelColorChanged(QColor) |
|
169 | \fn void QBarSet::labelColorChanged(QColor) | |
170 | This signal is emitted when the text (label) color of the set has changed to \a color. |
|
170 | This signal is emitted when the text (label) color of the set has changed to \a color. | |
171 | */ |
|
171 | */ | |
172 | /*! |
|
172 | /*! | |
173 | \qmlsignal BarSet::onLabelColorChanged(color color) |
|
173 | \qmlsignal BarSet::onLabelColorChanged(color color) | |
174 | This signal is emitted when the text (label) color of the set has changed to \a color. |
|
174 | This signal is emitted when the text (label) color of the set has changed to \a color. | |
175 | */ |
|
175 | */ | |
176 |
|
176 | |||
177 | /*! |
|
177 | /*! | |
178 | \fn void QBarSet::valuesAdded(int index, int count) |
|
178 | \fn void QBarSet::valuesAdded(int index, int count) | |
179 | This signal is emitted when new values have been added to the set. |
|
179 | This signal is emitted when new values have been added to the set. | |
180 | Parameter \a index indicates the position of the first inserted value. |
|
180 | Parameter \a index indicates the position of the first inserted value. | |
181 | Parameter \a count is the number of iserted values. |
|
181 | Parameter \a count is the number of iserted values. | |
182 | \sa append(), insert() |
|
182 | \sa append(), insert() | |
183 | */ |
|
183 | */ | |
184 | /*! |
|
184 | /*! | |
185 | \qmlsignal BarSet::onValuesAdded(int index, int count) |
|
185 | \qmlsignal BarSet::onValuesAdded(int index, int count) | |
186 | This signal is emitted when new values have been added to the set. |
|
186 | This signal is emitted when new values have been added to the set. | |
187 | Parameter \a index indicates the position of the first inserted value. |
|
187 | Parameter \a index indicates the position of the first inserted value. | |
188 | Parameter \a count is the number of iserted values. |
|
188 | Parameter \a count is the number of iserted values. | |
189 | */ |
|
189 | */ | |
190 |
|
190 | |||
191 | /*! |
|
191 | /*! | |
192 | \fn void QBarSet::valuesRemoved(int index, int count) |
|
192 | \fn void QBarSet::valuesRemoved(int index, int count) | |
193 | This signal is emitted values have been removed from the set. |
|
193 | This signal is emitted values have been removed from the set. | |
194 | Parameter \a index indicates the position of the first removed value. |
|
194 | Parameter \a index indicates the position of the first removed value. | |
195 | Parameter \a count is the number of removed values. |
|
195 | Parameter \a count is the number of removed values. | |
196 | \sa remove() |
|
196 | \sa remove() | |
197 | */ |
|
197 | */ | |
198 | /*! |
|
198 | /*! | |
199 | \qmlsignal BarSet::onValuesRemoved(int index, int count) |
|
199 | \qmlsignal BarSet::onValuesRemoved(int index, int count) | |
200 | This signal is emitted values have been removed from the set. |
|
200 | This signal is emitted values have been removed from the set. | |
201 | Parameter \a index indicates the position of the first removed value. |
|
201 | Parameter \a index indicates the position of the first removed value. | |
202 | Parameter \a count is the number of removed values. |
|
202 | Parameter \a count is the number of removed values. | |
203 | */ |
|
203 | */ | |
204 |
|
204 | |||
205 | /*! |
|
205 | /*! | |
206 | \fn void QBarSet::valueChanged(int index) |
|
206 | \fn void QBarSet::valueChanged(int index) | |
207 | This signal is emitted values the value in the set has been modified. |
|
207 | This signal is emitted values the value in the set has been modified. | |
208 | Parameter \a index indicates the position of the modified value. |
|
208 | Parameter \a index indicates the position of the modified value. | |
209 | \sa at() |
|
209 | \sa at() | |
210 | */ |
|
210 | */ | |
211 | /*! |
|
211 | /*! | |
212 | \qmlsignal BarSet::onValueChanged(int index) |
|
212 | \qmlsignal BarSet::onValueChanged(int index) | |
213 | This signal is emitted values the value in the set has been modified. |
|
213 | This signal is emitted values the value in the set has been modified. | |
214 | Parameter \a index indicates the position of the modified value. |
|
214 | Parameter \a index indicates the position of the modified value. | |
215 | */ |
|
215 | */ | |
216 |
|
216 | |||
217 | /*! |
|
217 | /*! | |
218 | Constructs QBarSet with a label of \a label and with parent of \a parent |
|
218 | Constructs QBarSet with a label of \a label and with parent of \a parent | |
219 | */ |
|
219 | */ | |
220 | QBarSet::QBarSet(const QString label, QObject *parent) |
|
220 | QBarSet::QBarSet(const QString label, QObject *parent) | |
221 | : QObject(parent) |
|
221 | : QObject(parent) | |
222 | ,d_ptr(new QBarSetPrivate(label,this)) |
|
222 | ,d_ptr(new QBarSetPrivate(label,this)) | |
223 | { |
|
223 | { | |
224 | } |
|
224 | } | |
225 |
|
225 | |||
226 | /*! |
|
226 | /*! | |
227 | Destroys the barset |
|
227 | Destroys the barset | |
228 | */ |
|
228 | */ | |
229 | QBarSet::~QBarSet() |
|
229 | QBarSet::~QBarSet() | |
230 | { |
|
230 | { | |
231 | // NOTE: d_ptr destroyed by QObject |
|
231 | // NOTE: d_ptr destroyed by QObject | |
232 | } |
|
232 | } | |
233 |
|
233 | |||
234 | /*! |
|
234 | /*! | |
235 | Sets new \a label for set. |
|
235 | Sets new \a label for set. | |
236 | */ |
|
236 | */ | |
237 | void QBarSet::setLabel(const QString label) |
|
237 | void QBarSet::setLabel(const QString label) | |
238 | { |
|
238 | { | |
239 | d_ptr->m_label = label; |
|
239 | d_ptr->m_label = label; | |
240 | emit labelChanged(); |
|
240 | emit labelChanged(); | |
241 | } |
|
241 | } | |
242 |
|
242 | |||
243 | /*! |
|
243 | /*! | |
244 | Returns label of the set. |
|
244 | Returns label of the set. | |
245 | */ |
|
245 | */ | |
246 | QString QBarSet::label() const |
|
246 | QString QBarSet::label() const | |
247 | { |
|
247 | { | |
248 | return d_ptr->m_label; |
|
248 | return d_ptr->m_label; | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | /*! |
|
251 | /*! | |
252 | Appends a point to set. Parameter \a value x coordinate defines the |
|
252 | Appends a point to set. Parameter \a value x coordinate defines the | |
253 | position in x-axis and y coordinate defines the height of bar. |
|
253 | position in x-axis and y coordinate defines the height of bar. | |
254 | Depending on presentation (QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries) |
|
254 | Depending on presentation (QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries) | |
255 | the x values are used or ignored. |
|
255 | the x values are used or ignored. | |
256 | */ |
|
256 | */ | |
257 | void QBarSet::append(const QPointF value) |
|
257 | void QBarSet::append(const QPointF value) | |
258 | { |
|
258 | { | |
259 | int index = d_ptr->m_values.count(); |
|
259 | int index = d_ptr->m_values.count(); | |
260 | d_ptr->append(value); |
|
260 | d_ptr->append(value); | |
261 | emit valuesAdded(index, 1); |
|
261 | emit valuesAdded(index, 1); | |
262 | } |
|
262 | } | |
263 |
|
263 | |||
264 | /*! |
|
264 | /*! | |
265 | Appends a list of \a values to set. Works like append with single point. |
|
265 | Appends a list of \a values to set. Works like append with single point. | |
266 | \sa append() |
|
266 | \sa append() | |
267 | */ |
|
267 | */ | |
268 | void QBarSet::append(const QList<QPointF> values) |
|
268 | void QBarSet::append(const QList<QPointF> &values) | |
269 | { |
|
269 | { | |
270 | int index = d_ptr->m_values.count(); |
|
270 | int index = d_ptr->m_values.count(); | |
271 | d_ptr->append(values); |
|
271 | d_ptr->append(values); | |
272 | emit valuesAdded(index, values.count()); |
|
272 | emit valuesAdded(index, values.count()); | |
273 | } |
|
273 | } | |
274 |
|
274 | |||
275 | /*! |
|
275 | /*! | |
276 | Appends new value \a value to the end of set. Internally the value is converted to QPointF, |
|
276 | Appends new value \a value to the end of set. Internally the value is converted to QPointF, | |
277 | with x coordinate being the index of appended value and y coordinate is the value. |
|
277 | with x coordinate being the index of appended value and y coordinate is the value. | |
278 | */ |
|
278 | */ | |
279 | void QBarSet::append(const qreal value) |
|
279 | void QBarSet::append(const qreal value) | |
280 | { |
|
280 | { | |
281 | // Convert to QPointF and use other append(QPointF) method. |
|
281 | // Convert to QPointF and use other append(QPointF) method. | |
282 | append(QPointF(d_ptr->m_values.count(), value)); |
|
282 | append(QPointF(d_ptr->m_values.count(), value)); | |
283 | } |
|
283 | } | |
284 |
|
284 | |||
285 | /*! |
|
285 | /*! | |
286 | Appends a list of reals to set. Works like append with single real value. The \a values in list |
|
286 | Appends a list of reals to set. Works like append with single real value. The \a values in list | |
287 | are converted to QPointF, where x coordinate is the index of point and y coordinate is the value. |
|
287 | are converted to QPointF, where x coordinate is the index of point and y coordinate is the value. | |
288 | \sa append() |
|
288 | \sa append() | |
289 | */ |
|
289 | */ | |
290 | void QBarSet::append(const QList<qreal> values) |
|
290 | void QBarSet::append(const QList<qreal> &values) | |
291 | { |
|
291 | { | |
292 | int index = d_ptr->m_values.count(); |
|
292 | int index = d_ptr->m_values.count(); | |
293 | d_ptr->append(values); |
|
293 | d_ptr->append(values); | |
294 | emit valuesAdded(index, values.count()); |
|
294 | emit valuesAdded(index, values.count()); | |
295 | } |
|
295 | } | |
296 |
|
296 | |||
297 | /*! |
|
297 | /*! | |
298 | Convinience operator. Same as append, with real \a value. |
|
298 | Convinience operator. Same as append, with real \a value. | |
299 | \sa append() |
|
299 | \sa append() | |
300 | */ |
|
300 | */ | |
301 | QBarSet& QBarSet::operator << (const qreal &value) |
|
301 | QBarSet& QBarSet::operator << (const qreal &value) | |
302 | { |
|
302 | { | |
303 | append(value); |
|
303 | append(value); | |
304 | return *this; |
|
304 | return *this; | |
305 | } |
|
305 | } | |
306 |
|
306 | |||
307 | /*! |
|
307 | /*! | |
308 | Convinience operator. Same as append, with QPointF \a value. |
|
308 | Convinience operator. Same as append, with QPointF \a value. | |
309 | \sa append() |
|
309 | \sa append() | |
310 | */ |
|
310 | */ | |
311 | QBarSet& QBarSet::operator << (const QPointF &value) |
|
311 | QBarSet& QBarSet::operator << (const QPointF &value) | |
312 | { |
|
312 | { | |
313 | append(value); |
|
313 | append(value); | |
314 | return *this; |
|
314 | return *this; | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | /*! |
|
317 | /*! | |
318 | Inserts new \a value on the \a index position. |
|
318 | Inserts new \a value on the \a index position. | |
319 | The value that is currently at this postion is moved to postion index + 1 |
|
319 | The value that is currently at this postion is moved to postion index + 1 | |
320 | \sa remove() |
|
320 | \sa remove() | |
321 | */ |
|
321 | */ | |
322 | void QBarSet::insert(const int index, const qreal value) |
|
322 | void QBarSet::insert(const int index, const qreal value) | |
323 | { |
|
323 | { | |
324 | d_ptr->insert(index, value); |
|
324 | d_ptr->insert(index, value); | |
325 | emit valuesAdded(index,1); |
|
325 | emit valuesAdded(index,1); | |
326 | } |
|
326 | } | |
327 |
|
327 | |||
328 | /*! |
|
328 | /*! | |
329 | Inserts new \a value on the \a index position. |
|
329 | Inserts new \a value on the \a index position. | |
330 | The value that is currently at this postion is moved to postion index + 1 |
|
330 | The value that is currently at this postion is moved to postion index + 1 | |
331 | \sa remove() |
|
331 | \sa remove() | |
332 | */ |
|
332 | */ | |
333 | void QBarSet::insert(const int index, const QPointF value) |
|
333 | void QBarSet::insert(const int index, const QPointF value) | |
334 | { |
|
334 | { | |
335 | d_ptr->insert(index,value); |
|
335 | d_ptr->insert(index,value); | |
336 | emit valuesAdded(index,1); |
|
336 | emit valuesAdded(index,1); | |
337 | } |
|
337 | } | |
338 |
|
338 | |||
339 | /*! |
|
339 | /*! | |
340 | Removes \a count number of values from the set starting at \a index. |
|
340 | Removes \a count number of values from the set starting at \a index. | |
341 | Returns true if remove operation was succesfull. |
|
341 | Returns true if remove operation was succesfull. | |
342 | \sa insert() |
|
342 | \sa insert() | |
343 | */ |
|
343 | */ | |
344 | bool QBarSet::remove(const int index, const int count) |
|
344 | bool QBarSet::remove(const int index, const int count) | |
345 | { |
|
345 | { | |
346 | bool success = d_ptr->remove(index,count); |
|
346 | bool success = d_ptr->remove(index,count); | |
347 | if (success) { |
|
347 | if (success) { | |
348 | emit valuesRemoved(index,count); |
|
348 | emit valuesRemoved(index,count); | |
349 | } |
|
349 | } | |
350 | return success; |
|
350 | return success; | |
351 | } |
|
351 | } | |
352 |
|
352 | |||
353 | /*! |
|
353 | /*! | |
354 | Sets a new value \a value to set, indexed by \a index |
|
354 | Sets a new value \a value to set, indexed by \a index | |
355 | */ |
|
355 | */ | |
356 | void QBarSet::replace(const int index, const qreal value) |
|
356 | void QBarSet::replace(const int index, const qreal value) | |
357 | { |
|
357 | { | |
358 | d_ptr->replace(index,value); |
|
358 | d_ptr->replace(index,value); | |
359 | emit valueChanged(index); |
|
359 | emit valueChanged(index); | |
360 | } |
|
360 | } | |
361 |
|
361 | |||
362 | /*! |
|
362 | /*! | |
363 | Sets a new value \a value to set, indexed by \a index |
|
363 | Sets a new value \a value to set, indexed by \a index | |
364 | */ |
|
364 | */ | |
365 | void QBarSet::replace(const int index, const QPointF value) |
|
365 | void QBarSet::replace(const int index, const QPointF value) | |
366 | { |
|
366 | { | |
367 | d_ptr->replace(index,value); |
|
367 | d_ptr->replace(index,value); | |
368 | emit valueChanged(index); |
|
368 | emit valueChanged(index); | |
369 | } |
|
369 | } | |
370 |
|
370 | |||
371 | /*! |
|
371 | /*! | |
372 | Returns value of set indexed by \a index. Note that all appended values are stored internally as QPointF. |
|
372 | Returns value of set indexed by \a index. Note that all appended values are stored internally as QPointF. | |
373 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value |
|
373 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value | |
374 | of the QPointF (if appended with QPointF append). |
|
374 | of the QPointF (if appended with QPointF append). | |
375 | If the index is out of bounds QPointF(0, 0.0) is returned. |
|
375 | If the index is out of bounds QPointF(0, 0.0) is returned. | |
376 | */ |
|
376 | */ | |
377 | QPointF QBarSet::at(const int index) const |
|
377 | QPointF QBarSet::at(const int index) const | |
378 | { |
|
378 | { | |
379 | if (index < 0 || index >= d_ptr->m_values.count()) { |
|
379 | if (index < 0 || index >= d_ptr->m_values.count()) { | |
380 | return QPointF(index, 0.0); |
|
380 | return QPointF(index, 0.0); | |
381 | } |
|
381 | } | |
382 |
|
382 | |||
383 | return d_ptr->m_values.at(index); |
|
383 | return d_ptr->m_values.at(index); | |
384 | } |
|
384 | } | |
385 |
|
385 | |||
386 | /*! |
|
386 | /*! | |
387 | Returns value of set indexed by \a index. ote that all appended values are stored internally as QPointF. |
|
387 | Returns value of set indexed by \a index. ote that all appended values are stored internally as QPointF. | |
388 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value |
|
388 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value | |
389 | of the QPointF (if appended with QPointF append). |
|
389 | of the QPointF (if appended with QPointF append). | |
390 | */ |
|
390 | */ | |
391 | QPointF QBarSet::operator [](const int index) const |
|
391 | QPointF QBarSet::operator [](const int index) const | |
392 | { |
|
392 | { | |
393 | return d_ptr->m_values.at(index); |
|
393 | return d_ptr->m_values.at(index); | |
394 | } |
|
394 | } | |
395 |
|
395 | |||
396 | /*! |
|
396 | /*! | |
397 | Returns count of values in set. |
|
397 | Returns count of values in set. | |
398 | */ |
|
398 | */ | |
399 | int QBarSet::count() const |
|
399 | int QBarSet::count() const | |
400 | { |
|
400 | { | |
401 | return d_ptr->m_values.count(); |
|
401 | return d_ptr->m_values.count(); | |
402 | } |
|
402 | } | |
403 |
|
403 | |||
404 | /*! |
|
404 | /*! | |
405 | Returns sum of all values in barset. The sum is sum of y coordinates in the QPointF representation. |
|
405 | Returns sum of all values in barset. The sum is sum of y coordinates in the QPointF representation. | |
406 | */ |
|
406 | */ | |
407 | qreal QBarSet::sum() const |
|
407 | qreal QBarSet::sum() const | |
408 | { |
|
408 | { | |
409 | qreal total(0); |
|
409 | qreal total(0); | |
410 | for (int i=0; i < d_ptr->m_values.count(); i++) { |
|
410 | for (int i=0; i < d_ptr->m_values.count(); i++) { | |
411 | //total += d_ptr->m_values.at(i); |
|
411 | //total += d_ptr->m_values.at(i); | |
412 | total += d_ptr->m_values.at(i).y(); |
|
412 | total += d_ptr->m_values.at(i).y(); | |
413 | } |
|
413 | } | |
414 | return total; |
|
414 | return total; | |
415 | } |
|
415 | } | |
416 |
|
416 | |||
417 | /*! |
|
417 | /*! | |
418 | Sets pen for set. Bars of this set are drawn using \a pen |
|
418 | Sets pen for set. Bars of this set are drawn using \a pen | |
419 | */ |
|
419 | */ | |
420 | void QBarSet::setPen(const QPen &pen) |
|
420 | void QBarSet::setPen(const QPen &pen) | |
421 | { |
|
421 | { | |
422 | if(d_ptr->m_pen!=pen){ |
|
422 | if(d_ptr->m_pen!=pen){ | |
423 | d_ptr->m_pen = pen; |
|
423 | d_ptr->m_pen = pen; | |
424 | emit d_ptr->updatedBars(); |
|
424 | emit d_ptr->updatedBars(); | |
425 | emit penChanged(); |
|
425 | emit penChanged(); | |
426 | } |
|
426 | } | |
427 | } |
|
427 | } | |
428 |
|
428 | |||
429 | /*! |
|
429 | /*! | |
430 | Returns pen of the set. |
|
430 | Returns pen of the set. | |
431 | */ |
|
431 | */ | |
432 | QPen QBarSet::pen() const |
|
432 | QPen QBarSet::pen() const | |
433 | { |
|
433 | { | |
434 | return d_ptr->m_pen; |
|
434 | return d_ptr->m_pen; | |
435 | } |
|
435 | } | |
436 |
|
436 | |||
437 | /*! |
|
437 | /*! | |
438 | Sets brush for the set. Bars of this set are drawn using \a brush |
|
438 | Sets brush for the set. Bars of this set are drawn using \a brush | |
439 | */ |
|
439 | */ | |
440 | void QBarSet::setBrush(const QBrush &brush) |
|
440 | void QBarSet::setBrush(const QBrush &brush) | |
441 | { |
|
441 | { | |
442 | if(d_ptr->m_brush!=brush){ |
|
442 | if(d_ptr->m_brush!=brush){ | |
443 | d_ptr->m_brush = brush; |
|
443 | d_ptr->m_brush = brush; | |
444 | emit d_ptr->updatedBars(); |
|
444 | emit d_ptr->updatedBars(); | |
445 | emit brushChanged(); |
|
445 | emit brushChanged(); | |
446 | } |
|
446 | } | |
447 | } |
|
447 | } | |
448 |
|
448 | |||
449 | /*! |
|
449 | /*! | |
450 | Returns brush of the set. |
|
450 | Returns brush of the set. | |
451 | */ |
|
451 | */ | |
452 | QBrush QBarSet::brush() const |
|
452 | QBrush QBarSet::brush() const | |
453 | { |
|
453 | { | |
454 | return d_ptr->m_brush; |
|
454 | return d_ptr->m_brush; | |
455 | } |
|
455 | } | |
456 |
|
456 | |||
457 | /*! |
|
457 | /*! | |
458 | Sets \a brush of the values that are drawn on top of this barset |
|
458 | Sets \a brush of the values that are drawn on top of this barset | |
459 | */ |
|
459 | */ | |
460 | void QBarSet::setLabelBrush(const QBrush &brush) |
|
460 | void QBarSet::setLabelBrush(const QBrush &brush) | |
461 | { |
|
461 | { | |
462 | if(d_ptr->m_labelBrush!=brush){ |
|
462 | if(d_ptr->m_labelBrush!=brush){ | |
463 | d_ptr->m_labelBrush = brush; |
|
463 | d_ptr->m_labelBrush = brush; | |
464 | emit d_ptr->updatedBars(); |
|
464 | emit d_ptr->updatedBars(); | |
465 | emit labelBrushChanged(); |
|
465 | emit labelBrushChanged(); | |
466 | } |
|
466 | } | |
467 | } |
|
467 | } | |
468 |
|
468 | |||
469 | /*! |
|
469 | /*! | |
470 | Returns brush of the values that are drawn on top of this barset |
|
470 | Returns brush of the values that are drawn on top of this barset | |
471 | */ |
|
471 | */ | |
472 | QBrush QBarSet::labelBrush() const |
|
472 | QBrush QBarSet::labelBrush() const | |
473 | { |
|
473 | { | |
474 | return d_ptr->m_labelBrush; |
|
474 | return d_ptr->m_labelBrush; | |
475 | } |
|
475 | } | |
476 |
|
476 | |||
477 | /*! |
|
477 | /*! | |
478 | Sets the \a font for values that are drawn on top of this barset |
|
478 | Sets the \a font for values that are drawn on top of this barset | |
479 | */ |
|
479 | */ | |
480 | void QBarSet::setLabelFont(const QFont &font) |
|
480 | void QBarSet::setLabelFont(const QFont &font) | |
481 | { |
|
481 | { | |
482 | if(d_ptr->m_labelFont!=font) { |
|
482 | if(d_ptr->m_labelFont!=font) { | |
483 | d_ptr->m_labelFont = font; |
|
483 | d_ptr->m_labelFont = font; | |
484 | emit d_ptr->updatedBars(); |
|
484 | emit d_ptr->updatedBars(); | |
485 | emit labelFontChanged(); |
|
485 | emit labelFontChanged(); | |
486 | } |
|
486 | } | |
487 |
|
487 | |||
488 | } |
|
488 | } | |
489 |
|
489 | |||
490 | /*! |
|
490 | /*! | |
491 | Returns the pen for values that are drawn on top of this barset |
|
491 | Returns the pen for values that are drawn on top of this barset | |
492 | */ |
|
492 | */ | |
493 | QFont QBarSet::labelFont() const |
|
493 | QFont QBarSet::labelFont() const | |
494 | { |
|
494 | { | |
495 | return d_ptr->m_labelFont; |
|
495 | return d_ptr->m_labelFont; | |
496 | } |
|
496 | } | |
497 |
|
497 | |||
498 | /*! |
|
498 | /*! | |
499 | Returns the color of the brush of barset. |
|
499 | Returns the color of the brush of barset. | |
500 | */ |
|
500 | */ | |
501 | QColor QBarSet::color() |
|
501 | QColor QBarSet::color() | |
502 | { |
|
502 | { | |
503 | return brush().color(); |
|
503 | return brush().color(); | |
504 | } |
|
504 | } | |
505 |
|
505 | |||
506 | /*! |
|
506 | /*! | |
507 | Sets the \a color of brush for this barset |
|
507 | Sets the \a color of brush for this barset | |
508 | */ |
|
508 | */ | |
509 | void QBarSet::setColor(QColor color) |
|
509 | void QBarSet::setColor(QColor color) | |
510 | { |
|
510 | { | |
511 | QBrush b = brush(); |
|
511 | QBrush b = brush(); | |
512 | if (b.color() != color) { |
|
512 | if (b.color() != color) { | |
513 | b.setColor(color); |
|
513 | b.setColor(color); | |
514 | setBrush(b); |
|
514 | setBrush(b); | |
515 | emit colorChanged(color); |
|
515 | emit colorChanged(color); | |
516 | } |
|
516 | } | |
517 | } |
|
517 | } | |
518 |
|
518 | |||
519 | /*! |
|
519 | /*! | |
520 | Returns the color of pen of this barset |
|
520 | Returns the color of pen of this barset | |
521 | */ |
|
521 | */ | |
522 | QColor QBarSet::borderColor() |
|
522 | QColor QBarSet::borderColor() | |
523 | { |
|
523 | { | |
524 | return pen().color(); |
|
524 | return pen().color(); | |
525 | } |
|
525 | } | |
526 |
|
526 | |||
527 | /*! |
|
527 | /*! | |
528 | Sets the color of pen for this barset |
|
528 | Sets the color of pen for this barset | |
529 | */ |
|
529 | */ | |
530 | void QBarSet::setBorderColor(QColor color) |
|
530 | void QBarSet::setBorderColor(QColor color) | |
531 | { |
|
531 | { | |
532 | QPen p = pen(); |
|
532 | QPen p = pen(); | |
533 | if (p.color() != color) { |
|
533 | if (p.color() != color) { | |
534 | p.setColor(color); |
|
534 | p.setColor(color); | |
535 | setPen(p); |
|
535 | setPen(p); | |
536 | emit borderColorChanged(color); |
|
536 | emit borderColorChanged(color); | |
537 | } |
|
537 | } | |
538 | } |
|
538 | } | |
539 |
|
539 | |||
540 | /*! |
|
540 | /*! | |
541 | Returns the color of labels of this barset |
|
541 | Returns the color of labels of this barset | |
542 | */ |
|
542 | */ | |
543 | QColor QBarSet::labelColor() |
|
543 | QColor QBarSet::labelColor() | |
544 | { |
|
544 | { | |
545 | return labelBrush().color(); |
|
545 | return labelBrush().color(); | |
546 | } |
|
546 | } | |
547 |
|
547 | |||
548 | /*! |
|
548 | /*! | |
549 | Sets the color of labels for this barset |
|
549 | Sets the color of labels for this barset | |
550 | */ |
|
550 | */ | |
551 | void QBarSet::setLabelColor(QColor color) |
|
551 | void QBarSet::setLabelColor(QColor color) | |
552 | { |
|
552 | { | |
553 | QBrush b = labelBrush(); |
|
553 | QBrush b = labelBrush(); | |
554 | if (b.color() != color) { |
|
554 | if (b.color() != color) { | |
555 | b.setColor(color); |
|
555 | b.setColor(color); | |
556 | setLabelBrush(b); |
|
556 | setLabelBrush(b); | |
557 | emit labelColorChanged(color); |
|
557 | emit labelColorChanged(color); | |
558 | } |
|
558 | } | |
559 | } |
|
559 | } | |
560 |
|
560 | |||
561 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
561 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
562 |
|
562 | |||
563 | QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent), |
|
563 | QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent), | |
564 | q_ptr(parent), |
|
564 | q_ptr(parent), | |
565 | m_label(label) |
|
565 | m_label(label) | |
566 | { |
|
566 | { | |
567 | } |
|
567 | } | |
568 |
|
568 | |||
569 | QBarSetPrivate::~QBarSetPrivate() |
|
569 | QBarSetPrivate::~QBarSetPrivate() | |
570 | { |
|
570 | { | |
571 | } |
|
571 | } | |
572 |
|
572 | |||
573 | void QBarSetPrivate::append(QPointF value) |
|
573 | void QBarSetPrivate::append(QPointF value) | |
574 | { |
|
574 | { | |
575 | m_values.append(value); |
|
575 | m_values.append(value); | |
576 | emit restructuredBars(); |
|
576 | emit restructuredBars(); | |
577 | } |
|
577 | } | |
578 |
|
578 | |||
579 | void QBarSetPrivate::append(QList<QPointF> values) |
|
579 | void QBarSetPrivate::append(QList<QPointF> values) | |
580 | { |
|
580 | { | |
581 | for (int i=0; i<values.count(); i++) { |
|
581 | for (int i=0; i<values.count(); i++) { | |
582 | m_values.append(values.at(i)); |
|
582 | m_values.append(values.at(i)); | |
583 | } |
|
583 | } | |
584 | emit restructuredBars(); |
|
584 | emit restructuredBars(); | |
585 | } |
|
585 | } | |
586 |
|
586 | |||
587 | void QBarSetPrivate::append(QList<qreal> values) |
|
587 | void QBarSetPrivate::append(QList<qreal> values) | |
588 | { |
|
588 | { | |
589 | int index = m_values.count(); |
|
589 | int index = m_values.count(); | |
590 | for (int i=0; i<values.count(); i++) { |
|
590 | for (int i=0; i<values.count(); i++) { | |
591 | m_values.append(QPointF(index,values.at(i))); |
|
591 | m_values.append(QPointF(index,values.at(i))); | |
592 | index++; |
|
592 | index++; | |
593 | } |
|
593 | } | |
594 | emit restructuredBars(); |
|
594 | emit restructuredBars(); | |
595 | } |
|
595 | } | |
596 |
|
596 | |||
597 | void QBarSetPrivate::insert(const int index, const qreal value) |
|
597 | void QBarSetPrivate::insert(const int index, const qreal value) | |
598 | { |
|
598 | { | |
599 | m_values.insert(index, QPointF(index, value)); |
|
599 | m_values.insert(index, QPointF(index, value)); | |
600 | emit restructuredBars(); |
|
600 | emit restructuredBars(); | |
601 | } |
|
601 | } | |
602 |
|
602 | |||
603 | void QBarSetPrivate::insert(const int index, const QPointF value) |
|
603 | void QBarSetPrivate::insert(const int index, const QPointF value) | |
604 | { |
|
604 | { | |
605 | m_values.insert(index, value); |
|
605 | m_values.insert(index, value); | |
606 | emit restructuredBars(); |
|
606 | emit restructuredBars(); | |
607 | } |
|
607 | } | |
608 |
|
608 | |||
609 | bool QBarSetPrivate::remove(const int index, const int count) |
|
609 | bool QBarSetPrivate::remove(const int index, const int count) | |
610 | { |
|
610 | { | |
611 | if ((index + count) > m_values.count()) { |
|
611 | if ((index + count) > m_values.count()) { | |
612 | // cant remove more values than there are |
|
612 | // cant remove more values than there are | |
613 | return false; |
|
613 | return false; | |
614 | } |
|
614 | } | |
615 | int c = count; |
|
615 | int c = count; | |
616 | while (c > 0) { |
|
616 | while (c > 0) { | |
617 | m_values.removeAt(index); |
|
617 | m_values.removeAt(index); | |
618 | c--; |
|
618 | c--; | |
619 | } |
|
619 | } | |
620 | emit restructuredBars(); |
|
620 | emit restructuredBars(); | |
621 | return true; |
|
621 | return true; | |
622 | } |
|
622 | } | |
623 |
|
623 | |||
624 | void QBarSetPrivate::replace(const int index, const qreal value) |
|
624 | void QBarSetPrivate::replace(const int index, const qreal value) | |
625 | { |
|
625 | { | |
626 | m_values.replace(index,QPointF(index,value)); |
|
626 | m_values.replace(index,QPointF(index,value)); | |
627 | emit updatedBars(); |
|
627 | emit updatedBars(); | |
628 | } |
|
628 | } | |
629 |
|
629 | |||
630 | void QBarSetPrivate::replace(const int index, const QPointF value) |
|
630 | void QBarSetPrivate::replace(const int index, const QPointF value) | |
631 | { |
|
631 | { | |
632 | m_values.replace(index,value); |
|
632 | m_values.replace(index,value); | |
633 | emit updatedBars(); |
|
633 | emit updatedBars(); | |
634 | } |
|
634 | } | |
635 |
|
635 | |||
636 | #include "moc_qbarset.cpp" |
|
636 | #include "moc_qbarset.cpp" | |
637 | #include "moc_qbarset_p.cpp" |
|
637 | #include "moc_qbarset_p.cpp" | |
638 |
|
638 | |||
639 | QTCOMMERCIALCHART_END_NAMESPACE |
|
639 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,117 +1,117 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QBARSET_H |
|
21 | #ifndef QBARSET_H | |
22 | #define QBARSET_H |
|
22 | #define QBARSET_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <QPen> |
|
25 | #include <QPen> | |
26 | #include <QBrush> |
|
26 | #include <QBrush> | |
27 | #include <QFont> |
|
27 | #include <QFont> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 | class QBarSetPrivate; |
|
30 | class QBarSetPrivate; | |
31 |
|
31 | |||
32 | class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject |
|
32 | class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject | |
33 | { |
|
33 | { | |
34 | Q_OBJECT |
|
34 | Q_OBJECT | |
35 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) |
|
35 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) | |
36 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) |
|
36 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) | |
37 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) |
|
37 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) | |
38 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) |
|
38 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) | |
39 | Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged) |
|
39 | Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged) | |
40 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
|
40 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |
41 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) |
|
41 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) | |
42 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) |
|
42 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) | |
43 |
|
43 | |||
44 | public: |
|
44 | public: | |
45 | explicit QBarSet(const QString label, QObject *parent = 0); |
|
45 | explicit QBarSet(const QString label, QObject *parent = 0); | |
46 | virtual ~QBarSet(); |
|
46 | virtual ~QBarSet(); | |
47 |
|
47 | |||
48 | void setLabel(const QString label); |
|
48 | void setLabel(const QString label); | |
49 | QString label() const; |
|
49 | QString label() const; | |
50 |
|
50 | |||
51 | void append(const QPointF value); |
|
51 | void append(const QPointF value); | |
52 | void append(const QList<QPointF> values); |
|
52 | void append(const QList<QPointF> &values); | |
53 | void append(const qreal value); |
|
53 | void append(const qreal value); | |
54 | void append(const QList<qreal> values); |
|
54 | void append(const QList<qreal> &values); | |
55 |
|
55 | |||
56 | QBarSet& operator << (const qreal &value); |
|
56 | QBarSet& operator << (const qreal &value); | |
57 | QBarSet& operator << (const QPointF &value); |
|
57 | QBarSet& operator << (const QPointF &value); | |
58 |
|
58 | |||
59 | void insert(const int index, const qreal value); |
|
59 | void insert(const int index, const qreal value); | |
60 | void insert(const int index, const QPointF value); |
|
60 | void insert(const int index, const QPointF value); | |
61 | bool remove(const int index, const int count = 1); |
|
61 | bool remove(const int index, const int count = 1); | |
62 | void replace(const int index, const qreal value); |
|
62 | void replace(const int index, const qreal value); | |
63 | void replace(const int index, const QPointF value); |
|
63 | void replace(const int index, const QPointF value); | |
64 | QPointF at(const int index) const; |
|
64 | QPointF at(const int index) const; | |
65 | QPointF operator [] (const int index) const; |
|
65 | QPointF operator [] (const int index) const; | |
66 | int count() const; |
|
66 | int count() const; | |
67 | qreal sum() const; |
|
67 | qreal sum() const; | |
68 |
|
68 | |||
69 | void setPen(const QPen &pen); |
|
69 | void setPen(const QPen &pen); | |
70 | QPen pen() const; |
|
70 | QPen pen() const; | |
71 |
|
71 | |||
72 | void setBrush(const QBrush &brush); |
|
72 | void setBrush(const QBrush &brush); | |
73 | QBrush brush() const; |
|
73 | QBrush brush() const; | |
74 |
|
74 | |||
75 | void setLabelBrush(const QBrush &brush); |
|
75 | void setLabelBrush(const QBrush &brush); | |
76 | QBrush labelBrush() const; |
|
76 | QBrush labelBrush() const; | |
77 |
|
77 | |||
78 | void setLabelFont(const QFont &font); |
|
78 | void setLabelFont(const QFont &font); | |
79 | QFont labelFont() const; |
|
79 | QFont labelFont() const; | |
80 |
|
80 | |||
81 | QColor color(); |
|
81 | QColor color(); | |
82 | void setColor(QColor color); |
|
82 | void setColor(QColor color); | |
83 |
|
83 | |||
84 | QColor borderColor(); |
|
84 | QColor borderColor(); | |
85 | void setBorderColor(QColor color); |
|
85 | void setBorderColor(QColor color); | |
86 |
|
86 | |||
87 | QColor labelColor(); |
|
87 | QColor labelColor(); | |
88 | void setLabelColor(QColor color); |
|
88 | void setLabelColor(QColor color); | |
89 |
|
89 | |||
90 | Q_SIGNALS: |
|
90 | Q_SIGNALS: | |
91 | void clicked(int index); |
|
91 | void clicked(int index); | |
92 | void hovered(bool status); |
|
92 | void hovered(bool status); | |
93 | void penChanged(); |
|
93 | void penChanged(); | |
94 | void brushChanged(); |
|
94 | void brushChanged(); | |
95 | void labelChanged(); |
|
95 | void labelChanged(); | |
96 | void labelBrushChanged(); |
|
96 | void labelBrushChanged(); | |
97 | void labelFontChanged(); |
|
97 | void labelFontChanged(); | |
98 | void colorChanged(QColor color); |
|
98 | void colorChanged(QColor color); | |
99 | void borderColorChanged(QColor color); |
|
99 | void borderColorChanged(QColor color); | |
100 | void labelColorChanged(QColor color); |
|
100 | void labelColorChanged(QColor color); | |
101 |
|
101 | |||
102 | void valuesAdded(int index, int count); |
|
102 | void valuesAdded(int index, int count); | |
103 | void valuesRemoved(int index, int count); |
|
103 | void valuesRemoved(int index, int count); | |
104 | void valueChanged(int index); |
|
104 | void valueChanged(int index); | |
105 |
|
105 | |||
106 | private: |
|
106 | private: | |
107 | QScopedPointer<QBarSetPrivate> d_ptr; |
|
107 | QScopedPointer<QBarSetPrivate> d_ptr; | |
108 | Q_DISABLE_COPY(QBarSet) |
|
108 | Q_DISABLE_COPY(QBarSet) | |
109 | friend class QBarSeries; |
|
109 | friend class QBarSeries; | |
110 | friend class BarLegendMarker; |
|
110 | friend class BarLegendMarker; | |
111 | friend class BarChartItem; |
|
111 | friend class BarChartItem; | |
112 | friend class QBarSeriesPrivate; |
|
112 | friend class QBarSeriesPrivate; | |
113 | }; |
|
113 | }; | |
114 |
|
114 | |||
115 | QTCOMMERCIALCHART_END_NAMESPACE |
|
115 | QTCOMMERCIALCHART_END_NAMESPACE | |
116 |
|
116 | |||
117 | #endif // QBARSET_H |
|
117 | #endif // QBARSET_H |
General Comments 0
You need to be logged in to leave comments.
Login now