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