@@ -1,601 +1,604 | |||||
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 "qabstractaxis.h" |
|
21 | #include "qabstractaxis.h" | |
22 | #include "qabstractaxis_p.h" |
|
22 | #include "qabstractaxis_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QAbstractAxis |
|
27 | \class QAbstractAxis | |
28 | \brief The QAbstractAxis class is used for manipulating chart's axis. |
|
28 | \brief The QAbstractAxis class is used for manipulating chart's axis. | |
29 | \mainclass |
|
29 | \mainclass | |
30 |
|
30 | |||
31 | There is only one x Axis, however there can be multiple y axes. |
|
31 | There is only one x Axis, however there can be multiple y axes. | |
32 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
32 | Each chart series can be bound to exactly one Y axis and the shared common X axis. | |
33 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
33 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
34 | */ |
|
34 | */ | |
35 |
|
35 | |||
36 | /*! |
|
36 | /*! | |
37 | \qmlclass Axis QAbstractAxis |
|
37 | \qmlclass Axis QAbstractAxis | |
38 | \brief The Axis element is used for manipulating chart's axes |
|
38 | \brief The Axis element is used for manipulating chart's axes | |
39 |
|
39 | |||
40 | There is only one x Axis, however there can be multiple y axes on a ChartView. |
|
40 | There is only one x Axis, however there can be multiple y axes on a ChartView. | |
41 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
41 | Each chart series can be bound to exactly one Y axis and the shared common X axis. | |
42 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
42 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
43 |
|
43 | |||
44 | To access Axes you can use ChartView API. For example: |
|
44 | To access Axes you can use ChartView API. For example: | |
45 | \code |
|
45 | \code | |
46 | ChartView { |
|
46 | ChartView { | |
47 | axisX.min: 0 |
|
47 | axisX.min: 0 | |
48 | axisX.max: 3 |
|
48 | axisX.max: 3 | |
49 | axisX.ticksCount: 4 |
|
49 | axisX.ticksCount: 4 | |
50 | axisY.min: 0 |
|
50 | axisY.min: 0 | |
51 | axisY.max: 4 |
|
51 | axisY.max: 4 | |
52 | // Add a few series... |
|
52 | // Add a few series... | |
53 | } |
|
53 | } | |
54 | \endcode |
|
54 | \endcode | |
55 | */ |
|
55 | */ | |
56 |
|
56 | |||
57 | /*! |
|
57 | /*! | |
58 | \enum QAbstractAxis::AxisType |
|
58 | \enum QAbstractAxis::AxisType | |
59 |
|
59 | |||
60 | The type of the series object. |
|
60 | The type of the series object. | |
61 |
|
61 | |||
62 | \value AxisTypeValues |
|
62 | \value AxisTypeValues | |
63 | \value AxisTypeCategories |
|
63 | \value AxisTypeCategories | |
64 | */ |
|
64 | */ | |
65 |
|
65 | |||
66 | /*! |
|
66 | /*! | |
67 | \property QAbstractAxis::type |
|
67 | \property QAbstractAxis::type | |
68 | The type of the axis. |
|
68 | The type of the axis. | |
69 | */ |
|
69 | */ | |
70 |
|
70 | |||
71 | /*! |
|
71 | /*! | |
72 | \property QAbstractAxis::labelsVisible |
|
72 | \property QAbstractAxis::labelsVisible | |
73 | Defines if axis labels are visible. |
|
73 | Defines if axis labels are visible. | |
74 | */ |
|
74 | */ | |
75 | /*! |
|
75 | /*! | |
76 | \qmlproperty bool Axis::labelsVisible |
|
76 | \qmlproperty bool Axis::labelsVisible | |
77 | Defines if axis labels are visible. |
|
77 | Defines if axis labels are visible. | |
78 | */ |
|
78 | */ | |
79 |
|
79 | |||
80 | /*! |
|
80 | /*! | |
81 | \property QAbstractAxis::min |
|
81 | \property QAbstractAxis::min | |
82 | Defines the minimum value on the axis. |
|
82 | Defines the minimum value on the axis. | |
83 | */ |
|
83 | */ | |
84 | /*! |
|
84 | /*! | |
85 | \qmlproperty real Axis::min |
|
85 | \qmlproperty real Axis::min | |
86 | Defines the minimum value on the axis. |
|
86 | Defines the minimum value on the axis. | |
87 | */ |
|
87 | */ | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | \property QAbstractAxis::max |
|
90 | \property QAbstractAxis::max | |
91 | Defines the maximum value on the axis. |
|
91 | Defines the maximum value on the axis. | |
92 | */ |
|
92 | */ | |
93 | /*! |
|
93 | /*! | |
94 | \qmlproperty real Axis::max |
|
94 | \qmlproperty real Axis::max | |
95 | Defines the maximum value on the axis. |
|
95 | Defines the maximum value on the axis. | |
96 | */ |
|
96 | */ | |
97 |
|
97 | |||
98 | /*! |
|
98 | /*! | |
99 | \property QAbstractAxis::visible |
|
99 | \property QAbstractAxis::visible | |
100 | The visibility of the axis. |
|
100 | The visibility of the axis. | |
101 | */ |
|
101 | */ | |
102 | /*! |
|
102 | /*! | |
103 | \qmlproperty bool Axis::visible |
|
103 | \qmlproperty bool Axis::visible | |
104 | The visibility of the axis. |
|
104 | The visibility of the axis. | |
105 | */ |
|
105 | */ | |
106 |
|
106 | |||
107 | /*! |
|
107 | /*! | |
108 | \property QAbstractAxis::gridVisible |
|
108 | \property QAbstractAxis::gridVisible | |
109 | The visibility of the grid lines. |
|
109 | The visibility of the grid lines. | |
110 | */ |
|
110 | */ | |
111 | /*! |
|
111 | /*! | |
112 | \qmlproperty bool Axis::gridVisible |
|
112 | \qmlproperty bool Axis::gridVisible | |
113 | The visibility of the grid lines. |
|
113 | The visibility of the grid lines. | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | /*! |
|
116 | /*! | |
117 | \property QAbstractAxis::color |
|
117 | \property QAbstractAxis::color | |
118 | The color of the axis and ticks. |
|
118 | The color of the axis and ticks. | |
119 | */ |
|
119 | */ | |
120 | /*! |
|
120 | /*! | |
121 | \qmlproperty color Axis::color |
|
121 | \qmlproperty color Axis::color | |
122 | The color of the axis and ticks. |
|
122 | The color of the axis and ticks. | |
123 | */ |
|
123 | */ | |
124 |
|
124 | |||
125 | /*! |
|
125 | /*! | |
126 | \property QAxis::labelsFont |
|
126 | \property QAxis::labelsFont | |
127 | The font of the axis labels. |
|
127 | The font of the axis labels. | |
128 | */ |
|
128 | */ | |
129 | /*! |
|
129 | /*! | |
130 | \qmlproperty Font Axis::labelsFont |
|
130 | \qmlproperty Font Axis::labelsFont | |
131 | The font of the axis labels. |
|
131 | The font of the axis labels. | |
132 |
|
132 | |||
133 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
133 | See the \l {Font} {QML Font Element} for detailed documentation. | |
134 | */ |
|
134 | */ | |
135 |
|
135 | |||
136 | /*! |
|
136 | /*! | |
137 | \property QAbstractAxis::labelsColor |
|
137 | \property QAbstractAxis::labelsColor | |
138 | The color of the axis labels. |
|
138 | The color of the axis labels. | |
139 | */ |
|
139 | */ | |
140 | /*! |
|
140 | /*! | |
141 | \qmlproperty color Axis::labelsColor |
|
141 | \qmlproperty color Axis::labelsColor | |
142 | The color of the axis labels. |
|
142 | The color of the axis labels. | |
143 | */ |
|
143 | */ | |
144 |
|
144 | |||
145 | /*! |
|
145 | /*! | |
146 | \property QAbstractAxis::labelsAngle |
|
146 | \property QAbstractAxis::labelsAngle | |
147 | The angle of the axis labels in degrees. |
|
147 | The angle of the axis labels in degrees. | |
148 | */ |
|
148 | */ | |
149 | /*! |
|
149 | /*! | |
150 | \qmlproperty int Axis::labelsAngle |
|
150 | \qmlproperty int Axis::labelsAngle | |
151 | The angle of the axis labels in degrees. |
|
151 | The angle of the axis labels in degrees. | |
152 | */ |
|
152 | */ | |
153 |
|
153 | |||
154 | /*! |
|
154 | /*! | |
155 | \property QAbstractAxis::shadesVisible |
|
155 | \property QAbstractAxis::shadesVisible | |
156 | The visibility of the axis shades. |
|
156 | The visibility of the axis shades. | |
157 | */ |
|
157 | */ | |
158 | /*! |
|
158 | /*! | |
159 | \qmlproperty bool Axis::shadesVisible |
|
159 | \qmlproperty bool Axis::shadesVisible | |
160 | The visibility of the axis shades. |
|
160 | The visibility of the axis shades. | |
161 | */ |
|
161 | */ | |
162 |
|
162 | |||
163 | /*! |
|
163 | /*! | |
164 | \property QAbstractAxis::shadesColor |
|
164 | \property QAbstractAxis::shadesColor | |
165 | The fill (brush) color of the axis shades. |
|
165 | The fill (brush) color of the axis shades. | |
166 | */ |
|
166 | */ | |
167 | /*! |
|
167 | /*! | |
168 | \qmlproperty color Axis::shadesColor |
|
168 | \qmlproperty color Axis::shadesColor | |
169 | The fill (brush) color of the axis shades. |
|
169 | The fill (brush) color of the axis shades. | |
170 | */ |
|
170 | */ | |
171 |
|
171 | |||
172 | /*! |
|
172 | /*! | |
173 | \property QAbstractAxis::shadesBorderColor |
|
173 | \property QAbstractAxis::shadesBorderColor | |
174 | The border (pen) color of the axis shades. |
|
174 | The border (pen) color of the axis shades. | |
175 | */ |
|
175 | */ | |
176 | /*! |
|
176 | /*! | |
177 | \qmlproperty color Axis::shadesBorderColor |
|
177 | \qmlproperty color Axis::shadesBorderColor | |
178 | The border (pen) color of the axis shades. |
|
178 | The border (pen) color of the axis shades. | |
179 | */ |
|
179 | */ | |
180 |
|
180 | |||
181 | /*! |
|
181 | /*! | |
182 | \property QAbstractAxis::ticksCount |
|
182 | \property QAbstractAxis::ticksCount | |
183 | The number of tick marks for the axis. |
|
183 | The number of tick marks for the axis. | |
184 | */ |
|
184 | */ | |
185 | /*! |
|
185 | /*! | |
186 | \qmlproperty int Axis::ticksCount |
|
186 | \qmlproperty int Axis::ticksCount | |
187 | The number of tick marks for the axis. |
|
187 | The number of tick marks for the axis. | |
188 | */ |
|
188 | */ | |
189 |
|
189 | |||
190 | /*! |
|
190 | /*! | |
191 | \property QAbstractAxis::niceNumbersEnabled |
|
191 | \property QAbstractAxis::niceNumbersEnabled | |
192 | Whether the nice numbers algorithm is enabled or not for the axis. |
|
192 | Whether the nice numbers algorithm is enabled or not for the axis. | |
193 | */ |
|
193 | */ | |
194 | /*! |
|
194 | /*! | |
195 | \qmlproperty bool Axis::niceNumbersEnabled |
|
195 | \qmlproperty bool Axis::niceNumbersEnabled | |
196 | Whether the nice numbers algorithm is enabled or not for the axis. |
|
196 | Whether the nice numbers algorithm is enabled or not for the axis. | |
197 | */ |
|
197 | */ | |
198 |
|
198 | |||
199 | /*! |
|
199 | /*! | |
200 | \fn void QAbstractAxis::visibleChanged(bool) |
|
200 | \fn void QAbstractAxis::visibleChanged(bool) | |
201 | Visiblity of the axis has changed to \a visible. |
|
201 | Visiblity of the axis has changed to \a visible. | |
202 | */ |
|
202 | */ | |
203 |
|
203 | |||
204 | /*! |
|
204 | /*! | |
205 | \fn void QAbstractAxis::labelsVisibleChanged(bool) |
|
205 | \fn void QAbstractAxis::labelsVisibleChanged(bool) | |
206 | Visiblity of the labels of the axis has changed to \a visible. |
|
206 | Visiblity of the labels of the axis has changed to \a visible. | |
207 | */ |
|
207 | */ | |
208 |
|
208 | |||
209 | /*! |
|
209 | /*! | |
210 | \fn void QAbstractAxis::gridVisibleChanged(bool) |
|
210 | \fn void QAbstractAxis::gridVisibleChanged(bool) | |
211 | Visiblity of the grid lines of the axis has changed to \a visible. |
|
211 | Visiblity of the grid lines of the axis has changed to \a visible. | |
212 | */ |
|
212 | */ | |
213 |
|
213 | |||
214 | /*! |
|
214 | /*! | |
215 | \fn void QAbstractAxis::minChanged(qreal min) |
|
215 | \fn void QAbstractAxis::minChanged(qreal min) | |
216 | Axis emits signal when \a min of axis has changed. |
|
216 | Axis emits signal when \a min of axis has changed. | |
217 | */ |
|
217 | */ | |
218 |
|
218 | |||
219 | /*! |
|
219 | /*! | |
220 | \fn void QAbstractAxis::maxChanged(qreal max) |
|
220 | \fn void QAbstractAxis::maxChanged(qreal max) | |
221 | Axis emits signal when \a max of axis has changed. |
|
221 | Axis emits signal when \a max of axis has changed. | |
222 | */ |
|
222 | */ | |
223 |
|
223 | |||
224 | /*! |
|
224 | /*! | |
225 | \fn void QAbstractAxis::rangeChanged(qreal min, qreal max) |
|
225 | \fn void QAbstractAxis::rangeChanged(qreal min, qreal max) | |
226 | Axis emits signal when \a min or \a max of axis has changed. |
|
226 | Axis emits signal when \a min or \a max of axis has changed. | |
227 | */ |
|
227 | */ | |
228 |
|
228 | |||
229 | /*! |
|
229 | /*! | |
230 | \fn QChartAxisCategories* QAbstractAxis::categories() |
|
230 | \fn QChartAxisCategories* QAbstractAxis::categories() | |
231 | Returns pointer to the list of categories which correspond to the values on the axis. |
|
231 | Returns pointer to the list of categories which correspond to the values on the axis. | |
232 | */ |
|
232 | */ | |
233 |
|
233 | |||
234 | /*! |
|
234 | /*! | |
235 | \fn void QAbstractAxis::colorChanged(QColor) |
|
235 | \fn void QAbstractAxis::colorChanged(QColor) | |
236 | Emitted if the \a color of the axis is changed. |
|
236 | Emitted if the \a color of the axis is changed. | |
237 | */ |
|
237 | */ | |
238 |
|
238 | |||
239 | /*! |
|
239 | /*! | |
240 | \fn void QAbstractAxis::labelsColorChanged(QColor) |
|
240 | \fn void QAbstractAxis::labelsColorChanged(QColor) | |
241 | Emitted if the \a color of the axis labels is changed. |
|
241 | Emitted if the \a color of the axis labels is changed. | |
242 | */ |
|
242 | */ | |
243 |
|
243 | |||
244 | /*! |
|
244 | /*! | |
245 | \fn void QAbstractAxis::shadesVisibleChanged(bool) |
|
245 | \fn void QAbstractAxis::shadesVisibleChanged(bool) | |
246 | Emitted if the visibility of the axis shades is changed to \a visible. |
|
246 | Emitted if the visibility of the axis shades is changed to \a visible. | |
247 | */ |
|
247 | */ | |
248 |
|
248 | |||
249 | /*! |
|
249 | /*! | |
250 | \fn void QAbstractAxis::shadesColorChanged(QColor) |
|
250 | \fn void QAbstractAxis::shadesColorChanged(QColor) | |
251 | Emitted if the \a color of the axis shades is changed. |
|
251 | Emitted if the \a color of the axis shades is changed. | |
252 | */ |
|
252 | */ | |
253 |
|
253 | |||
254 | /*! |
|
254 | /*! | |
255 | \fn void QAbstractAxis::shadesBorderColorChanged(QColor) |
|
255 | \fn void QAbstractAxis::shadesBorderColorChanged(QColor) | |
256 | Emitted if the border \a color of the axis shades is changed. |
|
256 | Emitted if the border \a color of the axis shades is changed. | |
257 | */ |
|
257 | */ | |
258 |
|
258 | |||
259 | /*! |
|
259 | /*! | |
260 | Constructs new axis object which is a child of \a parent. Ownership is taken by |
|
260 | Constructs new axis object which is a child of \a parent. Ownership is taken by | |
261 | QChart when axis added. |
|
261 | QChart when axis added. | |
262 | */ |
|
262 | */ | |
263 |
|
263 | |||
264 | QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) : |
|
264 | QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) : | |
265 | QObject(parent), |
|
265 | QObject(parent), | |
266 | d_ptr(&d) |
|
266 | d_ptr(&d) | |
267 | { |
|
267 | { | |
268 | } |
|
268 | } | |
269 |
|
269 | |||
270 | /*! |
|
270 | /*! | |
271 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. |
|
271 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. | |
272 | */ |
|
272 | */ | |
273 |
|
273 | |||
274 | QAbstractAxis::~QAbstractAxis() |
|
274 | QAbstractAxis::~QAbstractAxis() | |
275 | { |
|
275 | { | |
276 | } |
|
276 | } | |
277 |
|
277 | |||
278 | /*! |
|
278 | /*! | |
279 | Sets \a pen used to draw axis line and ticks. |
|
279 | Sets \a pen used to draw axis line and ticks. | |
280 | */ |
|
280 | */ | |
281 | void QAbstractAxis::setAxisPen(const QPen &pen) |
|
281 | void QAbstractAxis::setAxisPen(const QPen &pen) | |
282 | { |
|
282 | { | |
283 | if (d_ptr->m_axisPen!=pen) { |
|
283 | if (d_ptr->m_axisPen!=pen) { | |
284 | d_ptr->m_axisPen = pen; |
|
284 | d_ptr->m_axisPen = pen; | |
285 | emit d_ptr->updated(); |
|
285 | emit d_ptr->updated(); | |
286 | } |
|
286 | } | |
287 | } |
|
287 | } | |
288 |
|
288 | |||
289 | /*! |
|
289 | /*! | |
290 | Returns pen used to draw axis and ticks. |
|
290 | Returns pen used to draw axis and ticks. | |
291 | */ |
|
291 | */ | |
292 | QPen QAbstractAxis::axisPen() const |
|
292 | QPen QAbstractAxis::axisPen() const | |
293 | { |
|
293 | { | |
294 | return d_ptr->m_axisPen; |
|
294 | return d_ptr->m_axisPen; | |
295 | } |
|
295 | } | |
296 |
|
296 | |||
297 | void QAbstractAxis::setAxisPenColor(QColor color) |
|
297 | void QAbstractAxis::setAxisPenColor(QColor color) | |
298 | { |
|
298 | { | |
299 | QPen p = d_ptr->m_axisPen; |
|
299 | QPen p = d_ptr->m_axisPen; | |
300 | if (p.color() != color) { |
|
300 | if (p.color() != color) { | |
301 | p.setColor(color); |
|
301 | p.setColor(color); | |
302 | setAxisPen(p); |
|
302 | setAxisPen(p); | |
303 | emit colorChanged(color); |
|
303 | emit colorChanged(color); | |
304 | } |
|
304 | } | |
305 | } |
|
305 | } | |
306 |
|
306 | |||
307 | QColor QAbstractAxis::axisPenColor() const |
|
307 | QColor QAbstractAxis::axisPenColor() const | |
308 | { |
|
308 | { | |
309 | return d_ptr->m_axisPen.color(); |
|
309 | return d_ptr->m_axisPen.color(); | |
310 | } |
|
310 | } | |
311 |
|
311 | |||
312 | /*! |
|
312 | /*! | |
313 | Sets if axis and ticks are \a visible. |
|
313 | Sets if axis and ticks are \a visible. | |
314 | */ |
|
314 | */ | |
315 | void QAbstractAxis::setAxisVisible(bool visible) |
|
315 | void QAbstractAxis::setAxisVisible(bool visible) | |
316 | { |
|
316 | { | |
317 | if (d_ptr->m_axisVisible != visible) { |
|
317 | if (d_ptr->m_axisVisible != visible) { | |
318 | d_ptr->m_axisVisible = visible; |
|
318 | d_ptr->m_axisVisible = visible; | |
319 | emit d_ptr->updated(); |
|
319 | emit d_ptr->updated(); | |
320 | emit visibleChanged(visible); |
|
320 | emit visibleChanged(visible); | |
321 | } |
|
321 | } | |
322 | } |
|
322 | } | |
323 |
|
323 | |||
324 | bool QAbstractAxis::isAxisVisible() const |
|
324 | bool QAbstractAxis::isAxisVisible() const | |
325 | { |
|
325 | { | |
326 | return d_ptr->m_axisVisible; |
|
326 | return d_ptr->m_axisVisible; | |
327 | } |
|
327 | } | |
328 |
|
328 | |||
329 | void QAbstractAxis::setGridLineVisible(bool visible) |
|
329 | void QAbstractAxis::setGridLineVisible(bool visible) | |
330 | { |
|
330 | { | |
331 | if (d_ptr->m_gridLineVisible != visible) { |
|
331 | if (d_ptr->m_gridLineVisible != visible) { | |
332 | d_ptr->m_gridLineVisible = visible; |
|
332 | d_ptr->m_gridLineVisible = visible; | |
333 | emit d_ptr->updated(); |
|
333 | emit d_ptr->updated(); | |
334 | emit gridVisibleChanged(visible); |
|
334 | emit gridVisibleChanged(visible); | |
335 | } |
|
335 | } | |
336 | } |
|
336 | } | |
337 |
|
337 | |||
338 | bool QAbstractAxis::isGridLineVisible() const |
|
338 | bool QAbstractAxis::isGridLineVisible() const | |
339 | { |
|
339 | { | |
340 | return d_ptr->m_gridLineVisible; |
|
340 | return d_ptr->m_gridLineVisible; | |
341 | } |
|
341 | } | |
342 |
|
342 | |||
343 | /*! |
|
343 | /*! | |
344 | Sets \a pen used to draw grid line. |
|
344 | Sets \a pen used to draw grid line. | |
345 | */ |
|
345 | */ | |
346 | void QAbstractAxis::setGridLinePen(const QPen &pen) |
|
346 | void QAbstractAxis::setGridLinePen(const QPen &pen) | |
347 | { |
|
347 | { | |
348 | if (d_ptr->m_gridLinePen != pen) { |
|
348 | if (d_ptr->m_gridLinePen != pen) { | |
349 | d_ptr->m_gridLinePen = pen; |
|
349 | d_ptr->m_gridLinePen = pen; | |
350 | emit d_ptr->updated(); |
|
350 | emit d_ptr->updated(); | |
351 | } |
|
351 | } | |
352 | } |
|
352 | } | |
353 |
|
353 | |||
354 | /*! |
|
354 | /*! | |
355 | Returns pen used to draw grid. |
|
355 | Returns pen used to draw grid. | |
356 | */ |
|
356 | */ | |
357 | QPen QAbstractAxis::gridLinePen() const |
|
357 | QPen QAbstractAxis::gridLinePen() const | |
358 | { |
|
358 | { | |
359 | return d_ptr->m_gridLinePen; |
|
359 | return d_ptr->m_gridLinePen; | |
360 | } |
|
360 | } | |
361 |
|
361 | |||
362 | void QAbstractAxis::setLabelsVisible(bool visible) |
|
362 | void QAbstractAxis::setLabelsVisible(bool visible) | |
363 | { |
|
363 | { | |
364 | if (d_ptr->m_labelsVisible != visible) { |
|
364 | if (d_ptr->m_labelsVisible != visible) { | |
365 | d_ptr->m_labelsVisible = visible; |
|
365 | d_ptr->m_labelsVisible = visible; | |
366 | emit d_ptr->updated(); |
|
366 | emit d_ptr->updated(); | |
367 | emit labelsVisibleChanged(visible); |
|
367 | emit labelsVisibleChanged(visible); | |
368 | } |
|
368 | } | |
369 | } |
|
369 | } | |
370 |
|
370 | |||
371 | bool QAbstractAxis::labelsVisible() const |
|
371 | bool QAbstractAxis::labelsVisible() const | |
372 | { |
|
372 | { | |
373 | return d_ptr->m_labelsVisible; |
|
373 | return d_ptr->m_labelsVisible; | |
374 | } |
|
374 | } | |
375 |
|
375 | |||
376 | /*! |
|
376 | /*! | |
377 | Sets \a pen used to draw labels. |
|
377 | Sets \a pen used to draw labels. | |
378 | */ |
|
378 | */ | |
379 | void QAbstractAxis::setLabelsPen(const QPen &pen) |
|
379 | void QAbstractAxis::setLabelsPen(const QPen &pen) | |
380 | { |
|
380 | { | |
381 | if (d_ptr->m_labelsPen != pen) { |
|
381 | if (d_ptr->m_labelsPen != pen) { | |
382 | d_ptr->m_labelsPen = pen; |
|
382 | d_ptr->m_labelsPen = pen; | |
383 | emit d_ptr->updated(); |
|
383 | emit d_ptr->updated(); | |
384 | } |
|
384 | } | |
385 | } |
|
385 | } | |
386 |
|
386 | |||
387 | /*! |
|
387 | /*! | |
388 | Returns the pen used to labels. |
|
388 | Returns the pen used to labels. | |
389 | */ |
|
389 | */ | |
390 | QPen QAbstractAxis::labelsPen() const |
|
390 | QPen QAbstractAxis::labelsPen() const | |
391 | { |
|
391 | { | |
392 | return d_ptr->m_labelsPen; |
|
392 | return d_ptr->m_labelsPen; | |
393 | } |
|
393 | } | |
394 |
|
394 | |||
395 | /*! |
|
395 | /*! | |
396 | Sets \a brush used to draw labels. |
|
396 | Sets \a brush used to draw labels. | |
397 | */ |
|
397 | */ | |
398 | void QAbstractAxis::setLabelsBrush(const QBrush &brush) |
|
398 | void QAbstractAxis::setLabelsBrush(const QBrush &brush) | |
399 | { |
|
399 | { | |
400 | if (d_ptr->m_labelsBrush != brush) { |
|
400 | if (d_ptr->m_labelsBrush != brush) { | |
401 | d_ptr->m_labelsBrush = brush; |
|
401 | d_ptr->m_labelsBrush = brush; | |
402 | emit d_ptr->updated(); |
|
402 | emit d_ptr->updated(); | |
403 | } |
|
403 | } | |
404 | } |
|
404 | } | |
405 |
|
405 | |||
406 | /*! |
|
406 | /*! | |
407 | Returns brush used to draw labels. |
|
407 | Returns brush used to draw labels. | |
408 | */ |
|
408 | */ | |
409 | QBrush QAbstractAxis::labelsBrush() const |
|
409 | QBrush QAbstractAxis::labelsBrush() const | |
410 | { |
|
410 | { | |
411 | return d_ptr->m_labelsBrush; |
|
411 | return d_ptr->m_labelsBrush; | |
412 | } |
|
412 | } | |
413 |
|
413 | |||
414 | /*! |
|
414 | /*! | |
415 | Sets \a font used to draw labels. |
|
415 | Sets \a font used to draw labels. | |
416 | */ |
|
416 | */ | |
417 | void QAbstractAxis::setLabelsFont(const QFont &font) |
|
417 | void QAbstractAxis::setLabelsFont(const QFont &font) | |
418 | { |
|
418 | { | |
419 | if (d_ptr->m_labelsFont != font) { |
|
419 | if (d_ptr->m_labelsFont != font) { | |
420 | d_ptr->m_labelsFont = font; |
|
420 | d_ptr->m_labelsFont = font; | |
421 | emit d_ptr->updated(); |
|
421 | emit d_ptr->updated(); | |
422 | } |
|
422 | } | |
423 | } |
|
423 | } | |
424 |
|
424 | |||
425 | /*! |
|
425 | /*! | |
426 | Returns font used to draw labels. |
|
426 | Returns font used to draw labels. | |
427 | */ |
|
427 | */ | |
428 | QFont QAbstractAxis::labelsFont() const |
|
428 | QFont QAbstractAxis::labelsFont() const | |
429 | { |
|
429 | { | |
430 | return d_ptr->m_labelsFont; |
|
430 | return d_ptr->m_labelsFont; | |
431 | } |
|
431 | } | |
432 |
|
432 | |||
433 | void QAbstractAxis::setLabelsAngle(int angle) |
|
433 | void QAbstractAxis::setLabelsAngle(int angle) | |
434 | { |
|
434 | { | |
435 | if (d_ptr->m_labelsAngle != angle) { |
|
435 | if (d_ptr->m_labelsAngle != angle) { | |
436 | d_ptr->m_labelsAngle = angle; |
|
436 | d_ptr->m_labelsAngle = angle; | |
437 | emit d_ptr->updated(); |
|
437 | emit d_ptr->updated(); | |
438 | } |
|
438 | } | |
439 | } |
|
439 | } | |
440 |
|
440 | |||
441 | int QAbstractAxis::labelsAngle() const |
|
441 | int QAbstractAxis::labelsAngle() const | |
442 | { |
|
442 | { | |
443 | return d_ptr->m_labelsAngle; |
|
443 | return d_ptr->m_labelsAngle; | |
444 | } |
|
444 | } | |
445 |
|
445 | |||
446 | void QAbstractAxis::setLabelsColor(QColor color) |
|
446 | void QAbstractAxis::setLabelsColor(QColor color) | |
447 | { |
|
447 | { | |
448 | QBrush b = d_ptr->m_labelsBrush; |
|
448 | QBrush b = d_ptr->m_labelsBrush; | |
449 | if (b.color() != color) { |
|
449 | if (b.color() != color) { | |
450 | b.setColor(color); |
|
450 | b.setColor(color); | |
451 | setLabelsBrush(b); |
|
451 | setLabelsBrush(b); | |
452 | emit labelsColorChanged(color); |
|
452 | emit labelsColorChanged(color); | |
453 | } |
|
453 | } | |
454 | } |
|
454 | } | |
455 |
|
455 | |||
456 | QColor QAbstractAxis::labelsColor() const |
|
456 | QColor QAbstractAxis::labelsColor() const | |
457 | { |
|
457 | { | |
458 | return d_ptr->m_labelsBrush.color(); |
|
458 | return d_ptr->m_labelsBrush.color(); | |
459 | } |
|
459 | } | |
460 |
|
460 | |||
461 | void QAbstractAxis::setShadesVisible(bool visible) |
|
461 | void QAbstractAxis::setShadesVisible(bool visible) | |
462 | { |
|
462 | { | |
463 | if (d_ptr->m_shadesVisible != visible) { |
|
463 | if (d_ptr->m_shadesVisible != visible) { | |
464 | d_ptr->m_shadesVisible = visible; |
|
464 | d_ptr->m_shadesVisible = visible; | |
465 | emit d_ptr->updated(); |
|
465 | emit d_ptr->updated(); | |
466 | emit shadesVisibleChanged(visible); |
|
466 | emit shadesVisibleChanged(visible); | |
467 | } |
|
467 | } | |
468 | } |
|
468 | } | |
469 |
|
469 | |||
470 | bool QAbstractAxis::shadesVisible() const |
|
470 | bool QAbstractAxis::shadesVisible() const | |
471 | { |
|
471 | { | |
472 | return d_ptr->m_shadesVisible; |
|
472 | return d_ptr->m_shadesVisible; | |
473 | } |
|
473 | } | |
474 |
|
474 | |||
475 | /*! |
|
475 | /*! | |
476 | Sets \a pen used to draw shades. |
|
476 | Sets \a pen used to draw shades. | |
477 | */ |
|
477 | */ | |
478 | void QAbstractAxis::setShadesPen(const QPen &pen) |
|
478 | void QAbstractAxis::setShadesPen(const QPen &pen) | |
479 | { |
|
479 | { | |
480 | if (d_ptr->m_shadesPen != pen) { |
|
480 | if (d_ptr->m_shadesPen != pen) { | |
481 | d_ptr->m_shadesPen = pen; |
|
481 | d_ptr->m_shadesPen = pen; | |
482 | emit d_ptr->updated(); |
|
482 | emit d_ptr->updated(); | |
483 | } |
|
483 | } | |
484 | } |
|
484 | } | |
485 |
|
485 | |||
486 | /*! |
|
486 | /*! | |
487 | Returns pen used to draw shades. |
|
487 | Returns pen used to draw shades. | |
488 | */ |
|
488 | */ | |
489 | QPen QAbstractAxis::shadesPen() const |
|
489 | QPen QAbstractAxis::shadesPen() const | |
490 | { |
|
490 | { | |
491 | return d_ptr->m_shadesPen; |
|
491 | return d_ptr->m_shadesPen; | |
492 | } |
|
492 | } | |
493 |
|
493 | |||
494 | /*! |
|
494 | /*! | |
495 | Sets \a brush used to draw shades. |
|
495 | Sets \a brush used to draw shades. | |
496 | */ |
|
496 | */ | |
497 | void QAbstractAxis::setShadesBrush(const QBrush &brush) |
|
497 | void QAbstractAxis::setShadesBrush(const QBrush &brush) | |
498 | { |
|
498 | { | |
499 | if (d_ptr->m_shadesBrush != brush) { |
|
499 | if (d_ptr->m_shadesBrush != brush) { | |
500 | d_ptr->m_shadesBrush = brush; |
|
500 | d_ptr->m_shadesBrush = brush; | |
501 | emit d_ptr->updated(); |
|
501 | emit d_ptr->updated(); | |
502 | emit shadesColorChanged(brush.color()); |
|
502 | emit shadesColorChanged(brush.color()); | |
503 | } |
|
503 | } | |
504 | } |
|
504 | } | |
505 |
|
505 | |||
506 | /*! |
|
506 | /*! | |
507 | Returns brush used to draw shades. |
|
507 | Returns brush used to draw shades. | |
508 | */ |
|
508 | */ | |
509 | QBrush QAbstractAxis::shadesBrush() const |
|
509 | QBrush QAbstractAxis::shadesBrush() const | |
510 | { |
|
510 | { | |
511 | return d_ptr->m_shadesBrush; |
|
511 | return d_ptr->m_shadesBrush; | |
512 | } |
|
512 | } | |
513 |
|
513 | |||
514 | void QAbstractAxis::setShadesColor(QColor color) |
|
514 | void QAbstractAxis::setShadesColor(QColor color) | |
515 | { |
|
515 | { | |
516 | QBrush b = d_ptr->m_shadesBrush; |
|
516 | QBrush b = d_ptr->m_shadesBrush; | |
517 | b.setColor(color); |
|
517 | b.setColor(color); | |
518 | setShadesBrush(b); |
|
518 | setShadesBrush(b); | |
519 | } |
|
519 | } | |
520 |
|
520 | |||
521 | QColor QAbstractAxis::shadesColor() const |
|
521 | QColor QAbstractAxis::shadesColor() const | |
522 | { |
|
522 | { | |
523 | return d_ptr->m_shadesBrush.color(); |
|
523 | return d_ptr->m_shadesBrush.color(); | |
524 | } |
|
524 | } | |
525 |
|
525 | |||
526 | void QAbstractAxis::setShadesBorderColor(QColor color) |
|
526 | void QAbstractAxis::setShadesBorderColor(QColor color) | |
527 | { |
|
527 | { | |
528 | QPen p = d_ptr->m_shadesPen; |
|
528 | QPen p = d_ptr->m_shadesPen; | |
529 | p.setColor(color); |
|
529 | p.setColor(color); | |
530 | setShadesPen(p); |
|
530 | setShadesPen(p); | |
531 | } |
|
531 | } | |
532 |
|
532 | |||
533 | QColor QAbstractAxis::shadesBorderColor() const |
|
533 | QColor QAbstractAxis::shadesBorderColor() const | |
534 | { |
|
534 | { | |
535 | return d_ptr->m_shadesPen.color(); |
|
535 | return d_ptr->m_shadesPen.color(); | |
536 | } |
|
536 | } | |
537 |
|
537 | |||
538 |
|
538 | |||
539 | /*! |
|
539 | /*! | |
540 | Sets axis, shades, labels and grid lines to be visible. |
|
540 | Sets axis, shades, labels and grid lines to be visible. | |
541 | */ |
|
541 | */ | |
542 | void QAbstractAxis::show() |
|
542 | void QAbstractAxis::show() | |
543 | { |
|
543 | { | |
544 | d_ptr->m_axisVisible=true; |
|
544 | d_ptr->m_axisVisible=true; | |
545 | d_ptr->m_gridLineVisible=true; |
|
545 | d_ptr->m_gridLineVisible=true; | |
546 | d_ptr->m_labelsVisible=true; |
|
546 | d_ptr->m_labelsVisible=true; | |
547 | d_ptr->m_shadesVisible=true; |
|
547 | d_ptr->m_shadesVisible=true; | |
548 | emit d_ptr->updated(); |
|
548 | emit d_ptr->updated(); | |
549 | } |
|
549 | } | |
550 |
|
550 | |||
551 | /*! |
|
551 | /*! | |
552 | Sets axis, shades, labels and grid lines to not be visible. |
|
552 | Sets axis, shades, labels and grid lines to not be visible. | |
553 | */ |
|
553 | */ | |
554 | void QAbstractAxis::hide() |
|
554 | void QAbstractAxis::hide() | |
555 | { |
|
555 | { | |
556 | d_ptr->m_axisVisible = false; |
|
556 | d_ptr->m_axisVisible = false; | |
557 | d_ptr->m_gridLineVisible = false; |
|
557 | d_ptr->m_gridLineVisible = false; | |
558 | d_ptr->m_labelsVisible = false; |
|
558 | d_ptr->m_labelsVisible = false; | |
559 | d_ptr->m_shadesVisible = false; |
|
559 | d_ptr->m_shadesVisible = false; | |
560 | emit d_ptr->updated(); |
|
560 | emit d_ptr->updated(); | |
561 | } |
|
561 | } | |
562 |
|
562 | |||
563 |
|
563 | |||
564 |
void QAbstractAxis::setMin(const |
|
564 | void QAbstractAxis::setMin(const qreal min) | |
565 | { |
|
565 | { | |
566 | d_ptr->setMin(min); |
|
566 | d_ptr->setMin(min); | |
567 | } |
|
567 | } | |
568 |
void QAbstractAxis::setMax(const |
|
568 | void QAbstractAxis::setMax(const qreal max) | |
569 | { |
|
569 | { | |
570 | d_ptr->setMax(max); |
|
570 | d_ptr->setMax(max); | |
571 | } |
|
571 | } | |
572 |
void QAbstractAxis::setRange(const |
|
572 | void QAbstractAxis::setRange(const qreal min, const qreal max) | |
573 | { |
|
573 | { | |
574 | d_ptr->setRange(min,max); |
|
574 | d_ptr->setRange(min,max); | |
575 | } |
|
575 | } | |
576 |
|
576 | |||
577 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
577 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
578 |
|
578 | |||
579 | QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q): |
|
579 | QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q): | |
580 | q_ptr(q), |
|
580 | q_ptr(q), | |
581 | m_axisVisible(true), |
|
581 | m_axisVisible(true), | |
582 | m_gridLineVisible(true), |
|
582 | m_gridLineVisible(true), | |
583 | m_labelsVisible(true), |
|
583 | m_labelsVisible(true), | |
584 | m_labelsAngle(0), |
|
584 | m_labelsAngle(0), | |
585 | m_shadesVisible(false), |
|
585 | m_shadesVisible(false), | |
586 | m_shadesBrush(Qt::SolidPattern), |
|
586 | m_shadesBrush(Qt::SolidPattern), | |
587 | m_shadesOpacity(1.0), |
|
587 | m_shadesOpacity(1.0), | |
588 | m_orientation(Qt::Orientation(0)) |
|
588 | m_orientation(Qt::Orientation(0)), | |
|
589 | m_min(0), | |||
|
590 | m_max(0), | |||
|
591 | m_ticksCount(5) | |||
589 | { |
|
592 | { | |
590 |
|
593 | |||
591 | } |
|
594 | } | |
592 |
|
595 | |||
593 | QAbstractAxisPrivate::~QAbstractAxisPrivate() |
|
596 | QAbstractAxisPrivate::~QAbstractAxisPrivate() | |
594 | { |
|
597 | { | |
595 |
|
598 | |||
596 | } |
|
599 | } | |
597 |
|
600 | |||
598 | #include "moc_qabstractaxis.cpp" |
|
601 | #include "moc_qabstractaxis.cpp" | |
599 | #include "moc_qabstractaxis_p.cpp" |
|
602 | #include "moc_qabstractaxis_p.cpp" | |
600 |
|
603 | |||
601 | QTCOMMERCIALCHART_END_NAMESPACE |
|
604 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,130 +1,130 | |||||
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 QABSTRACTAXIS_H |
|
21 | #ifndef QABSTRACTAXIS_H | |
22 | #define QABSTRACTAXIS_H |
|
22 | #define QABSTRACTAXIS_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <QPen> |
|
25 | #include <QPen> | |
26 | #include <QFont> |
|
26 | #include <QFont> | |
27 | #include <QVariant> |
|
27 | #include <QVariant> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class QAbstractAxisPrivate; |
|
31 | class QAbstractAxisPrivate; | |
32 |
|
32 | |||
33 | class QTCOMMERCIALCHART_EXPORT QAbstractAxis : public QObject |
|
33 | class QTCOMMERCIALCHART_EXPORT QAbstractAxis : public QObject | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 |
|
36 | |||
37 | Q_PROPERTY(bool visible READ isAxisVisible WRITE setAxisVisible NOTIFY visibleChanged) |
|
37 | Q_PROPERTY(bool visible READ isAxisVisible WRITE setAxisVisible NOTIFY visibleChanged) | |
38 | Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged) |
|
38 | Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged) | |
39 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) |
|
39 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) | |
40 | Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle) |
|
40 | Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle) | |
41 | Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont) |
|
41 | Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont) | |
42 | Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) |
|
42 | Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) | |
43 | Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged) |
|
43 | Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged) | |
44 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) |
|
44 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) | |
45 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) |
|
45 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) | |
46 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) |
|
46 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) | |
47 |
|
47 | |||
48 | public: |
|
48 | public: | |
49 |
|
49 | |||
50 | enum AxisType { |
|
50 | enum AxisType { | |
51 | AxisTypeValues, |
|
51 | AxisTypeValues, | |
52 | AxisTypeCategories |
|
52 | AxisTypeCategories | |
53 | }; |
|
53 | }; | |
54 |
|
54 | |||
55 | protected: |
|
55 | protected: | |
56 | explicit QAbstractAxis(QAbstractAxisPrivate &d,QObject *parent = 0); |
|
56 | explicit QAbstractAxis(QAbstractAxisPrivate &d,QObject *parent = 0); | |
57 |
|
57 | |||
58 | public: |
|
58 | public: | |
59 | ~QAbstractAxis(); |
|
59 | ~QAbstractAxis(); | |
60 |
|
60 | |||
61 | virtual AxisType type() const = 0; |
|
61 | virtual AxisType type() const = 0; | |
62 |
|
62 | |||
63 | //axis handling |
|
63 | //axis handling | |
64 | bool isAxisVisible() const; |
|
64 | bool isAxisVisible() const; | |
65 | void setAxisVisible(bool visible = true); |
|
65 | void setAxisVisible(bool visible = true); | |
66 | void setAxisPen(const QPen &pen); |
|
66 | void setAxisPen(const QPen &pen); | |
67 | QPen axisPen() const; |
|
67 | QPen axisPen() const; | |
68 | void setAxisPenColor(QColor color); |
|
68 | void setAxisPenColor(QColor color); | |
69 | QColor axisPenColor() const; |
|
69 | QColor axisPenColor() const; | |
70 |
|
70 | |||
71 | //grid handling |
|
71 | //grid handling | |
72 | bool isGridLineVisible() const; |
|
72 | bool isGridLineVisible() const; | |
73 | void setGridLineVisible(bool visible = true); |
|
73 | void setGridLineVisible(bool visible = true); | |
74 | void setGridLinePen(const QPen &pen); |
|
74 | void setGridLinePen(const QPen &pen); | |
75 | QPen gridLinePen() const; |
|
75 | QPen gridLinePen() const; | |
76 |
|
76 | |||
77 | //labels handling |
|
77 | //labels handling | |
78 | bool labelsVisible() const; |
|
78 | bool labelsVisible() const; | |
79 | void setLabelsVisible(bool visible = true); |
|
79 | void setLabelsVisible(bool visible = true); | |
80 | void setLabelsPen(const QPen &pen); |
|
80 | void setLabelsPen(const QPen &pen); | |
81 | QPen labelsPen() const; |
|
81 | QPen labelsPen() const; | |
82 | void setLabelsBrush(const QBrush &brush); |
|
82 | void setLabelsBrush(const QBrush &brush); | |
83 | QBrush labelsBrush() const; |
|
83 | QBrush labelsBrush() const; | |
84 | void setLabelsFont(const QFont &font); |
|
84 | void setLabelsFont(const QFont &font); | |
85 | QFont labelsFont() const; |
|
85 | QFont labelsFont() const; | |
86 | void setLabelsAngle(int angle); |
|
86 | void setLabelsAngle(int angle); | |
87 | int labelsAngle() const; |
|
87 | int labelsAngle() const; | |
88 | void setLabelsColor(QColor color); |
|
88 | void setLabelsColor(QColor color); | |
89 | QColor labelsColor() const; |
|
89 | QColor labelsColor() const; | |
90 |
|
90 | |||
91 | //shades handling |
|
91 | //shades handling | |
92 | bool shadesVisible() const; |
|
92 | bool shadesVisible() const; | |
93 | void setShadesVisible(bool visible = true); |
|
93 | void setShadesVisible(bool visible = true); | |
94 | void setShadesPen(const QPen &pen); |
|
94 | void setShadesPen(const QPen &pen); | |
95 | QPen shadesPen() const; |
|
95 | QPen shadesPen() const; | |
96 | void setShadesBrush(const QBrush &brush); |
|
96 | void setShadesBrush(const QBrush &brush); | |
97 | QBrush shadesBrush() const; |
|
97 | QBrush shadesBrush() const; | |
98 | void setShadesColor(QColor color); |
|
98 | void setShadesColor(QColor color); | |
99 | QColor shadesColor() const; |
|
99 | QColor shadesColor() const; | |
100 | void setShadesBorderColor(QColor color); |
|
100 | void setShadesBorderColor(QColor color); | |
101 | QColor shadesBorderColor() const; |
|
101 | QColor shadesBorderColor() const; | |
102 |
|
102 | |||
103 | //range handling |
|
103 | //range handling | |
104 |
void setMin(const |
|
104 | void setMin(const qreal min); | |
105 |
void setMax(const |
|
105 | void setMax(const qreal max); | |
106 |
void setRange(const |
|
106 | void setRange(const qreal min, const qreal max); | |
107 |
|
107 | |||
108 | void show(); |
|
108 | void show(); | |
109 | void hide(); |
|
109 | void hide(); | |
110 |
|
110 | |||
111 | Q_SIGNALS: |
|
111 | Q_SIGNALS: | |
112 | void visibleChanged(bool visible); |
|
112 | void visibleChanged(bool visible); | |
113 | void labelsVisibleChanged(bool visible); |
|
113 | void labelsVisibleChanged(bool visible); | |
114 | void gridVisibleChanged(bool visible); |
|
114 | void gridVisibleChanged(bool visible); | |
115 | void colorChanged(QColor color); |
|
115 | void colorChanged(QColor color); | |
116 | void labelsColorChanged(QColor color); |
|
116 | void labelsColorChanged(QColor color); | |
117 | void shadesVisibleChanged(bool visible); |
|
117 | void shadesVisibleChanged(bool visible); | |
118 | void shadesColorChanged(QColor color); |
|
118 | void shadesColorChanged(QColor color); | |
119 | void shadesBorderColorChanged(QColor color); |
|
119 | void shadesBorderColorChanged(QColor color); | |
120 |
|
120 | |||
121 | protected: |
|
121 | protected: | |
122 | QScopedPointer<QAbstractAxisPrivate> d_ptr; |
|
122 | QScopedPointer<QAbstractAxisPrivate> d_ptr; | |
123 | Q_DISABLE_COPY(QAbstractAxis); |
|
123 | Q_DISABLE_COPY(QAbstractAxis); | |
124 | friend class ChartDataSet; |
|
124 | friend class ChartDataSet; | |
125 | friend class ChartAxis; |
|
125 | friend class ChartAxis; | |
126 | friend class ChartPresenter; |
|
126 | friend class ChartPresenter; | |
127 | }; |
|
127 | }; | |
128 |
|
128 | |||
129 | QTCOMMERCIALCHART_END_NAMESPACE |
|
129 | QTCOMMERCIALCHART_END_NAMESPACE | |
130 | #endif |
|
130 | #endif |
@@ -1,87 +1,92 | |||||
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 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef QABSTRACTAXIS_P_H |
|
30 | #ifndef QABSTRACTAXIS_P_H | |
31 | #define QABSTRACTAXIS_P_H |
|
31 | #define QABSTRACTAXIS_P_H | |
32 |
|
32 | |||
33 | #include "qabstractaxis.h" |
|
33 | #include "qabstractaxis.h" | |
34 |
|
34 | |||
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class ChartPresenter; |
|
37 | class ChartPresenter; | |
38 | class ChartAxis; |
|
38 | class ChartAxis; | |
39 |
|
39 | |||
40 | class QAbstractAxisPrivate : public QObject |
|
40 | class QAbstractAxisPrivate : public QObject | |
41 | { |
|
41 | { | |
42 | Q_OBJECT |
|
42 | Q_OBJECT | |
43 | public: |
|
43 | public: | |
44 | QAbstractAxisPrivate(QAbstractAxis *q); |
|
44 | QAbstractAxisPrivate(QAbstractAxis *q); | |
45 | ~QAbstractAxisPrivate(); |
|
45 | ~QAbstractAxisPrivate(); | |
46 |
|
46 | |||
47 | Q_SIGNALS: |
|
47 | Q_SIGNALS: | |
48 | void updated(); |
|
48 | void updated(); | |
49 |
|
49 | |||
50 | public: |
|
50 | public: | |
51 | virtual ChartAxis* createGraphics(ChartPresenter* presenter) = 0; |
|
51 | virtual ChartAxis* createGraphics(ChartPresenter* presenter) = 0; | |
52 |
|
52 | |||
53 | protected: |
|
53 | protected: | |
54 |
virtual void setMin(const |
|
54 | virtual void setMin(const qreal min) = 0; | |
55 |
virtual void setMax(const |
|
55 | virtual void setMax(const qreal max) = 0; | |
56 |
virtual void setRange(const |
|
56 | virtual void setRange(const qreal min, const qreal max) = 0; | |
57 | virtual int ticksCount() const = 0; |
|
57 | virtual int ticksCount() const = 0; | |
58 |
|
58 | |||
59 | public: |
|
59 | public: | |
60 | QAbstractAxis *q_ptr; |
|
60 | QAbstractAxis *q_ptr; | |
61 |
|
61 | |||
62 | bool m_axisVisible; |
|
62 | bool m_axisVisible; | |
63 | QPen m_axisPen; |
|
63 | QPen m_axisPen; | |
64 | QBrush m_axisBrush; |
|
64 | QBrush m_axisBrush; | |
65 |
|
65 | |||
66 | bool m_gridLineVisible; |
|
66 | bool m_gridLineVisible; | |
67 | QPen m_gridLinePen; |
|
67 | QPen m_gridLinePen; | |
68 |
|
68 | |||
69 | bool m_labelsVisible; |
|
69 | bool m_labelsVisible; | |
70 | QPen m_labelsPen; |
|
70 | QPen m_labelsPen; | |
71 | QBrush m_labelsBrush; |
|
71 | QBrush m_labelsBrush; | |
72 | QFont m_labelsFont; |
|
72 | QFont m_labelsFont; | |
73 | int m_labelsAngle; |
|
73 | int m_labelsAngle; | |
74 |
|
74 | |||
75 | bool m_shadesVisible; |
|
75 | bool m_shadesVisible; | |
76 | QPen m_shadesPen; |
|
76 | QPen m_shadesPen; | |
77 | QBrush m_shadesBrush; |
|
77 | QBrush m_shadesBrush; | |
78 | qreal m_shadesOpacity; |
|
78 | qreal m_shadesOpacity; | |
79 |
|
79 | |||
80 | Qt::Orientation m_orientation; |
|
80 | Qt::Orientation m_orientation; | |
81 |
|
81 | |||
|
82 | // range | |||
|
83 | qreal m_min; | |||
|
84 | qreal m_max; | |||
|
85 | int m_ticksCount; | |||
|
86 | ||||
82 | friend class QAbstractAxis; |
|
87 | friend class QAbstractAxis; | |
83 | }; |
|
88 | }; | |
84 |
|
89 | |||
85 | QTCOMMERCIALCHART_END_NAMESPACE |
|
90 | QTCOMMERCIALCHART_END_NAMESPACE | |
86 |
|
91 | |||
87 | #endif |
|
92 | #endif |
@@ -1,222 +1,270 | |||||
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 "qcategoriesaxis.h" |
|
21 | #include "qcategoriesaxis.h" | |
22 | #include "qcategoriesaxis_p.h" |
|
22 | #include "qcategoriesaxis_p.h" | |
23 | #include "chartcategoriesaxisx_p.h" |
|
23 | #include "chartcategoriesaxisx_p.h" | |
24 | #include "chartcategoriesaxisy_p.h" |
|
24 | #include "chartcategoriesaxisy_p.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | QCategoriesAxis::QCategoriesAxis(QObject *parent): |
|
28 | QCategoriesAxis::QCategoriesAxis(QObject *parent): | |
29 | QAbstractAxis(*new QCategoriesAxisPrivate(this),parent) |
|
29 | QAbstractAxis(*new QCategoriesAxisPrivate(this),parent) | |
30 | { |
|
30 | { | |
31 |
|
31 | |||
32 | } |
|
32 | } | |
33 |
|
33 | |||
34 | QCategoriesAxis::~QCategoriesAxis() |
|
34 | QCategoriesAxis::~QCategoriesAxis() | |
35 | { |
|
35 | { | |
36 |
|
36 | |||
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | QCategoriesAxis::QCategoriesAxis(QCategoriesAxisPrivate &d,QObject *parent):QAbstractAxis(d,parent) |
|
39 | QCategoriesAxis::QCategoriesAxis(QCategoriesAxisPrivate &d,QObject *parent):QAbstractAxis(d,parent) | |
40 | { |
|
40 | { | |
41 |
|
41 | |||
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | /*! |
|
44 | /*! | |
45 | Appends \a categories to axis |
|
45 | Appends \a categories to axis | |
46 | */ |
|
46 | */ | |
47 | void QCategoriesAxis::append(const QStringList &categories) |
|
47 | void QCategoriesAxis::append(const QStringList &categories) | |
48 | { |
|
48 | { | |
49 | Q_D(QCategoriesAxis); |
|
49 | Q_D(QCategoriesAxis); | |
50 | d->m_categories.append(categories); |
|
50 | d->m_categories.append(categories); | |
51 | emit categoriesChanged(); |
|
51 | emit categoriesChanged(); | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | /*! |
|
54 | /*! | |
55 | Appends \a category to axis |
|
55 | Appends \a category to axis | |
56 | */ |
|
56 | */ | |
57 | void QCategoriesAxis::append(const QString &category) |
|
57 | void QCategoriesAxis::append(const QString &category) | |
58 | { |
|
58 | { | |
59 | Q_D(QCategoriesAxis); |
|
59 | Q_D(QCategoriesAxis); | |
60 | d->m_categories.append(category); |
|
60 | d->m_categories.append(category); | |
61 | emit categoriesChanged(); |
|
61 | emit categoriesChanged(); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | /*! |
|
64 | /*! | |
65 | Removes \a category from axis |
|
65 | Removes \a category from axis | |
66 | */ |
|
66 | */ | |
67 | void QCategoriesAxis::remove(const QString &category) |
|
67 | void QCategoriesAxis::remove(const QString &category) | |
68 | { |
|
68 | { | |
69 | Q_D(QCategoriesAxis); |
|
69 | Q_D(QCategoriesAxis); | |
70 | if (d->m_categories.contains(category)) { |
|
70 | if (d->m_categories.contains(category)) { | |
71 | d->m_categories.removeAt(d->m_categories.indexOf(category)); |
|
71 | d->m_categories.removeAt(d->m_categories.indexOf(category)); | |
72 | emit categoriesChanged(); |
|
72 | emit categoriesChanged(); | |
73 | } |
|
73 | } | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | /*! |
|
76 | /*! | |
77 | Inserts \a category to axis at \a index |
|
77 | Inserts \a category to axis at \a index | |
78 | */ |
|
78 | */ | |
79 | void QCategoriesAxis::insert(int index, const QString &category) |
|
79 | void QCategoriesAxis::insert(int index, const QString &category) | |
80 | { |
|
80 | { | |
81 | Q_D(QCategoriesAxis); |
|
81 | Q_D(QCategoriesAxis); | |
82 | d->m_categories.insert(index,category); |
|
82 | d->m_categories.insert(index,category); | |
83 | emit categoriesChanged(); |
|
83 | emit categoriesChanged(); | |
84 | } |
|
84 | } | |
85 |
|
85 | |||
86 | /*! |
|
86 | /*! | |
87 | Removes all categories. |
|
87 | Removes all categories. | |
88 | */ |
|
88 | */ | |
89 | void QCategoriesAxis::clear() |
|
89 | void QCategoriesAxis::clear() | |
90 | { |
|
90 | { | |
91 | Q_D(QCategoriesAxis); |
|
91 | Q_D(QCategoriesAxis); | |
92 | d->m_categories.clear(); |
|
92 | d->m_categories.clear(); | |
93 | emit categoriesChanged(); |
|
93 | emit categoriesChanged(); | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | void QCategoriesAxis::setCategories(const QStringList &categories) |
|
96 | void QCategoriesAxis::setCategories(const QStringList &categories) | |
97 | { |
|
97 | { | |
98 | Q_D(QCategoriesAxis); |
|
98 | Q_D(QCategoriesAxis); | |
99 | d->m_categories = categories; |
|
99 | d->m_categories = categories; | |
100 | emit categoriesChanged(); |
|
100 | emit categoriesChanged(); | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | QStringList QCategoriesAxis::categories() |
|
103 | QStringList QCategoriesAxis::categories() | |
104 | { |
|
104 | { | |
105 | Q_D(QCategoriesAxis); |
|
105 | Q_D(QCategoriesAxis); | |
106 | return d->m_categories; |
|
106 | return d->m_categories; | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | /*! |
|
109 | /*! | |
110 | Returns number of categories. |
|
110 | Returns number of categories. | |
111 | */ |
|
111 | */ | |
112 | int QCategoriesAxis::count() const |
|
112 | int QCategoriesAxis::count() const | |
113 | { |
|
113 | { | |
114 | Q_D(const QCategoriesAxis); |
|
114 | Q_D(const QCategoriesAxis); | |
115 | return d->m_categories.count(); |
|
115 | return d->m_categories.count(); | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | /*! |
|
118 | /*! | |
119 | Returns category at \a index. Index must be valid. |
|
119 | Returns category at \a index. Index must be valid. | |
120 | */ |
|
120 | */ | |
121 | QString QCategoriesAxis::at(int index) const |
|
121 | QString QCategoriesAxis::at(int index) const | |
122 | { |
|
122 | { | |
123 | Q_D(const QCategoriesAxis); |
|
123 | Q_D(const QCategoriesAxis); | |
124 | return d->m_categories.at(index); |
|
124 | return d->m_categories.at(index); | |
125 | } |
|
125 | } | |
126 |
|
126 | |||
127 | /*! |
|
127 | /*! | |
128 | Sets minimum category to \a minCategory. |
|
128 | Sets minimum category to \a minCategory. | |
129 | */ |
|
129 | */ | |
130 | void QCategoriesAxis::setMin(const QString& minCategory) |
|
130 | void QCategoriesAxis::setMin(const QString& minCategory) | |
131 | { |
|
131 | { | |
132 | Q_D(QCategoriesAxis); |
|
132 | Q_D(QCategoriesAxis); | |
133 | int minIndex = d->m_categories.indexOf(minCategory); |
|
133 | d->setMinCategory(minCategory); | |
134 | if (minIndex == -1) |
|
|||
135 | return; |
|
|||
136 | // else |
|
|||
137 | // QAbstractAxis::setMin(minIndex); |
|
|||
138 | } |
|
134 | } | |
139 |
|
135 | |||
140 | /*! |
|
136 | /*! | |
141 | Sets maximum category to \a maxCategory. |
|
137 | Sets maximum category to \a maxCategory. | |
142 | */ |
|
138 | */ | |
143 | void QCategoriesAxis::setMax(const QString& maxCategory) |
|
139 | void QCategoriesAxis::setMax(const QString& maxCategory) | |
144 | { |
|
140 | { | |
145 | Q_D(QCategoriesAxis); |
|
141 | Q_D(QCategoriesAxis); | |
146 | int maxIndex = d->m_categories.indexOf(maxCategory); |
|
142 | d->setMaxCategory(maxCategory); | |
147 | if (maxIndex == -1) |
|
|||
148 | return; |
|
|||
149 | // else |
|
|||
150 | // QAbstractAxis::setMax(maxIndex); |
|
|||
151 | } |
|
143 | } | |
152 |
|
144 | |||
153 | /*! |
|
145 | /*! | |
154 | Sets range from \a minCategory to \a maxCategory |
|
146 | Sets range from \a minCategory to \a maxCategory | |
155 | */ |
|
147 | */ | |
156 | void QCategoriesAxis::setRange(const QString& minCategory, const QString& maxCategory) |
|
148 | void QCategoriesAxis::setRange(const QString& minCategory, const QString& maxCategory) | |
157 | { |
|
149 | { | |
158 | // TODO: what if maxCategory < minCategory? |
|
150 | Q_D(QCategoriesAxis); | |
159 |
|
|
151 | d->setRangeCategory(minCategory,maxCategory); | |
160 | setMax(maxCategory); |
|
|||
161 | } |
|
152 | } | |
162 |
|
153 | |||
163 | /*! |
|
154 | /*! | |
164 | Returns the type of axis. |
|
155 | Returns the type of axis. | |
165 | */ |
|
156 | */ | |
166 | QAbstractAxis::AxisType QCategoriesAxis::type() const |
|
157 | QAbstractAxis::AxisType QCategoriesAxis::type() const | |
167 | { |
|
158 | { | |
168 | return AxisTypeCategories; |
|
159 | return AxisTypeCategories; | |
169 | } |
|
160 | } | |
170 |
|
161 | |||
171 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
162 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
172 |
|
163 | |||
173 | QCategoriesAxisPrivate::QCategoriesAxisPrivate(QCategoriesAxis* q): |
|
164 | QCategoriesAxisPrivate::QCategoriesAxisPrivate(QCategoriesAxis* q): | |
174 | QAbstractAxisPrivate(q) |
|
165 | QAbstractAxisPrivate(q) | |
175 | { |
|
166 | { | |
176 |
|
167 | |||
177 | } |
|
168 | } | |
178 |
|
169 | |||
179 | QCategoriesAxisPrivate::~QCategoriesAxisPrivate() |
|
170 | QCategoriesAxisPrivate::~QCategoriesAxisPrivate() | |
180 | { |
|
171 | { | |
181 |
|
172 | |||
182 | } |
|
173 | } | |
183 |
|
174 | |||
|
175 | void QCategoriesAxisPrivate::setMinCategory(const QString& minCategory) | |||
|
176 | { | |||
|
177 | // Convert the category to value | |||
|
178 | int minIndex = m_categories.indexOf(minCategory); | |||
|
179 | if (minIndex == -1) { | |||
|
180 | return; | |||
|
181 | } | |||
|
182 | setRange(minIndex,m_max); | |||
|
183 | } | |||
184 |
|
184 | |||
185 |
void QCategoriesAxisPrivate::setM |
|
185 | void QCategoriesAxisPrivate::setMaxCategory(const QString& maxCategory) | |
186 | { |
|
186 | { | |
187 | Q_Q(QCategoriesAxis); |
|
187 | // Convert the category to value | |
188 | q->setMin(min.toString()); |
|
188 | int maxIndex = m_categories.indexOf(maxCategory); | |
|
189 | if (maxIndex == -1) { | |||
|
190 | return; | |||
|
191 | } | |||
|
192 | setRange(m_min,maxIndex); | |||
189 | } |
|
193 | } | |
190 |
|
194 | |||
191 |
void QCategoriesAxisPrivate::set |
|
195 | void QCategoriesAxisPrivate::setRangeCategory(const QString& minCategory, const QString& maxCategory) | |
192 | { |
|
196 | { | |
193 | Q_Q(QCategoriesAxis); |
|
197 | // TODO: | |
194 | q->setMax(max.toString()); |
|
198 | int minIndex = m_categories.indexOf(minCategory); | |
|
199 | if (minIndex == -1) { | |||
|
200 | return; | |||
|
201 | } | |||
|
202 | int maxIndex = m_categories.indexOf(maxCategory); | |||
|
203 | if (maxIndex == -1) { | |||
|
204 | return; | |||
|
205 | } | |||
|
206 | setRange(minIndex,maxIndex); | |||
195 | } |
|
207 | } | |
196 |
|
208 | |||
197 |
void QCategoriesAxisPrivate::set |
|
209 | void QCategoriesAxisPrivate::setMin(const qreal min) | |
|
210 | { | |||
|
211 | setRange(min,m_max); | |||
|
212 | } | |||
|
213 | ||||
|
214 | void QCategoriesAxisPrivate::setMax(const qreal max) | |||
|
215 | { | |||
|
216 | setRange(m_min,max); | |||
|
217 | } | |||
|
218 | ||||
|
219 | void QCategoriesAxisPrivate::setRange(const qreal min, const qreal max) | |||
198 | { |
|
220 | { | |
199 | Q_Q(QCategoriesAxis); |
|
221 | Q_Q(QCategoriesAxis); | |
200 | q->setRange(min.toString(),max.toString()); |
|
222 | bool changed = false; | |
|
223 | if (!qFuzzyIsNull(m_min - min)) { | |||
|
224 | m_min = min; | |||
|
225 | changed = true; | |||
|
226 | } | |||
|
227 | ||||
|
228 | if (!qFuzzyIsNull(m_max - max)) { | |||
|
229 | m_max = max; | |||
|
230 | changed = true; | |||
|
231 | } | |||
|
232 | ||||
|
233 | if (changed) { | |||
|
234 | emit this->changed(m_min, m_max, m_ticksCount, false); | |||
|
235 | emit q->categoriesChanged(); | |||
|
236 | } | |||
201 | } |
|
237 | } | |
202 |
|
238 | |||
203 | int QCategoriesAxisPrivate::ticksCount() const |
|
239 | int QCategoriesAxisPrivate::ticksCount() const | |
204 | { |
|
240 | { | |
205 | return m_categories.count()+1; |
|
241 | return m_categories.count()+1; | |
206 | } |
|
242 | } | |
207 |
|
243 | |||
|
244 | void QCategoriesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |||
|
245 | { | |||
|
246 | // Q_Q(QCategoriesAxis); | |||
|
247 | // q->setRange(min,max); | |||
|
248 | // q->setTicksCount(count); | |||
|
249 | m_min = min; | |||
|
250 | m_max = max; | |||
|
251 | m_ticksCount = count; | |||
|
252 | ||||
|
253 | // TODO?: | |||
|
254 | //emit updated(); | |||
|
255 | } | |||
|
256 | ||||
208 | ChartAxis* QCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) |
|
257 | ChartAxis* QCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) | |
209 | { |
|
258 | { | |
210 | Q_Q( QCategoriesAxis); |
|
259 | Q_Q( QCategoriesAxis); | |
211 | if(m_orientation == Qt::Vertical){ |
|
260 | if(m_orientation == Qt::Vertical){ | |
212 | return new ChartCategoriesAxisY(q,presenter); |
|
261 | return new ChartCategoriesAxisY(q,presenter); | |
213 | }else{ |
|
262 | }else{ | |
214 | return new ChartCategoriesAxisX(q,presenter); |
|
263 | return new ChartCategoriesAxisX(q,presenter); | |
215 | } |
|
264 | } | |
216 |
|
||||
217 | } |
|
265 | } | |
218 |
|
266 | |||
219 | #include "moc_qcategoriesaxis.cpp" |
|
267 | #include "moc_qcategoriesaxis.cpp" | |
220 | #include "moc_qcategoriesaxis_p.cpp" |
|
268 | #include "moc_qcategoriesaxis_p.cpp" | |
221 |
|
269 | |||
222 | QTCOMMERCIALCHART_END_NAMESPACE |
|
270 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,70 +1,80 | |||||
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 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef QCATEGORIESAXIS_P_H |
|
30 | #ifndef QCATEGORIESAXIS_P_H | |
31 | #define QCATEGORIESAXIS_P_H |
|
31 | #define QCATEGORIESAXIS_P_H | |
32 |
|
32 | |||
33 | #include "qcategoriesaxis.h" |
|
33 | #include "qcategoriesaxis.h" | |
34 | #include "qabstractaxis_p.h" |
|
34 | #include "qabstractaxis_p.h" | |
35 |
|
35 | |||
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
37 |
|
37 | |||
38 | class QCategoriesAxisPrivate : public QAbstractAxisPrivate |
|
38 | class QCategoriesAxisPrivate : public QAbstractAxisPrivate | |
39 | { |
|
39 | { | |
40 | Q_OBJECT |
|
40 | Q_OBJECT | |
41 |
|
41 | |||
42 | public: |
|
42 | public: | |
43 | QCategoriesAxisPrivate(QCategoriesAxis *q); |
|
43 | QCategoriesAxisPrivate(QCategoriesAxis *q); | |
44 | ~QCategoriesAxisPrivate(); |
|
44 | ~QCategoriesAxisPrivate(); | |
45 |
|
45 | |||
46 | public: |
|
46 | public: | |
47 | ChartAxis* createGraphics(ChartPresenter* presenter); |
|
47 | ChartAxis* createGraphics(ChartPresenter* presenter); | |
48 |
|
48 | |||
49 | private: |
|
49 | private: | |
|
50 | void setMinCategory(const QString& minCategory); | |||
|
51 | void setMaxCategory(const QString& maxCategory); | |||
|
52 | void setRangeCategory(const QString& minCategory, const QString& maxCategory); | |||
|
53 | ||||
50 | //range handling |
|
54 | //range handling | |
51 |
void setMin(const |
|
55 | void setMin(const qreal min); | |
52 |
void setMax(const |
|
56 | void setMax(const qreal max); | |
53 |
void setRange(const |
|
57 | void setRange(const qreal min, const qreal max); | |
54 | int ticksCount() const; |
|
58 | int ticksCount() const; | |
55 |
|
59 | |||
|
60 | Q_SIGNALS: | |||
|
61 | void changed(qreal min, qreal max, int tickCount,bool niceNumbers); | |||
|
62 | ||||
|
63 | public Q_SLOTS: | |||
|
64 | void handleAxisRangeChanged(qreal min, qreal max,int count); | |||
|
65 | ||||
56 | private: |
|
66 | private: | |
57 | QStringList m_categories; |
|
67 | QStringList m_categories; | |
58 | QString m_minCategory; |
|
68 | QString m_minCategory; | |
59 | QString m_maxCategory; |
|
69 | QString m_maxCategory; | |
60 |
|
70 | |||
61 | Q_SIGNALS: |
|
71 | // qreal m_rangeMin; | |
62 | void updated(); |
|
72 | // qreal m_rangeMax; | |
63 |
|
73 | |||
64 | private: |
|
74 | private: | |
65 | Q_DECLARE_PUBLIC(QCategoriesAxis) |
|
75 | Q_DECLARE_PUBLIC(QCategoriesAxis) | |
66 | }; |
|
76 | }; | |
67 |
|
77 | |||
68 | QTCOMMERCIALCHART_END_NAMESPACE |
|
78 | QTCOMMERCIALCHART_END_NAMESPACE | |
69 |
|
79 | |||
70 | #endif // QCATEGORIESAXIS_P_H |
|
80 | #endif // QCATEGORIESAXIS_P_H |
@@ -1,265 +1,252 | |||||
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 "qvaluesaxis.h" |
|
21 | #include "qvaluesaxis.h" | |
22 | #include "qvaluesaxis_p.h" |
|
22 | #include "qvaluesaxis_p.h" | |
23 | #include "chartvaluesaxisx_p.h" |
|
23 | #include "chartvaluesaxisx_p.h" | |
24 | #include "chartvaluesaxisy_p.h" |
|
24 | #include "chartvaluesaxisy_p.h" | |
25 | #include <QDebug> |
|
25 | #include <QDebug> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 | /*! |
|
28 | /*! | |
29 | \class QValuesAxis |
|
29 | \class QValuesAxis | |
30 | \brief The QValuesAxis class is used for manipulating chart's axis. |
|
30 | \brief The QValuesAxis class is used for manipulating chart's axis. | |
31 | \mainclass |
|
31 | \mainclass | |
32 |
|
32 | |||
33 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
33 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
34 | */ |
|
34 | */ | |
35 |
|
35 | |||
36 | /*! |
|
36 | /*! | |
37 | \qmlclass Axis QValuesAxis |
|
37 | \qmlclass Axis QValuesAxis | |
38 | \brief The Axis element is used for manipulating chart's axes |
|
38 | \brief The Axis element is used for manipulating chart's axes | |
39 |
|
39 | |||
40 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
40 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
41 |
|
41 | |||
42 | To access Axes you can use ChartView API. For example: |
|
42 | To access Axes you can use ChartView API. For example: | |
43 | \code |
|
43 | \code | |
44 | ChartView { |
|
44 | ChartView { | |
45 | axisX.min: 0 |
|
45 | axisX.min: 0 | |
46 | axisX.max: 3 |
|
46 | axisX.max: 3 | |
47 | axisX.ticksCount: 4 |
|
47 | axisX.ticksCount: 4 | |
48 | axisY.min: 0 |
|
48 | axisY.min: 0 | |
49 | axisY.max: 4 |
|
49 | axisY.max: 4 | |
50 | // Add a few series... |
|
50 | // Add a few series... | |
51 | } |
|
51 | } | |
52 | \endcode |
|
52 | \endcode | |
53 | */ |
|
53 | */ | |
54 |
|
54 | |||
55 | /*! |
|
55 | /*! | |
56 | \property QValuesAxis::min |
|
56 | \property QValuesAxis::min | |
57 | Defines the minimum value on the axis. |
|
57 | Defines the minimum value on the axis. | |
58 | */ |
|
58 | */ | |
59 | /*! |
|
59 | /*! | |
60 | \qmlproperty real Axis::min |
|
60 | \qmlproperty real Axis::min | |
61 | Defines the minimum value on the axis. |
|
61 | Defines the minimum value on the axis. | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | /*! |
|
64 | /*! | |
65 | \property QValuesAxis::max |
|
65 | \property QValuesAxis::max | |
66 | Defines the maximum value on the axis. |
|
66 | Defines the maximum value on the axis. | |
67 | */ |
|
67 | */ | |
68 | /*! |
|
68 | /*! | |
69 | \qmlproperty real Axis::max |
|
69 | \qmlproperty real Axis::max | |
70 | Defines the maximum value on the axis. |
|
70 | Defines the maximum value on the axis. | |
71 | */ |
|
71 | */ | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | \fn void QValuesAxis::minChanged(qreal min) |
|
74 | \fn void QValuesAxis::minChanged(qreal min) | |
75 | Axis emits signal when \a min of axis has changed. |
|
75 | Axis emits signal when \a min of axis has changed. | |
76 | */ |
|
76 | */ | |
77 |
|
77 | |||
78 | /*! |
|
78 | /*! | |
79 | \fn void QValuesAxis::maxChanged(qreal max) |
|
79 | \fn void QValuesAxis::maxChanged(qreal max) | |
80 | Axis emits signal when \a max of axis has changed. |
|
80 | Axis emits signal when \a max of axis has changed. | |
81 | */ |
|
81 | */ | |
82 |
|
82 | |||
83 | /*! |
|
83 | /*! | |
84 | \fn void QValuesAxis::rangeChanged(qreal min, qreal max) |
|
84 | \fn void QValuesAxis::rangeChanged(qreal min, qreal max) | |
85 | Axis emits signal when \a min or \a max of axis has changed. |
|
85 | Axis emits signal when \a min or \a max of axis has changed. | |
86 | */ |
|
86 | */ | |
87 |
|
87 | |||
88 | QValuesAxis::QValuesAxis(QObject *parent) : |
|
88 | QValuesAxis::QValuesAxis(QObject *parent) : | |
89 | QAbstractAxis(*new QValuesAxisPrivate(this),parent) |
|
89 | QAbstractAxis(*new QValuesAxisPrivate(this),parent) | |
90 | { |
|
90 | { | |
91 |
|
91 | |||
92 | } |
|
92 | } | |
93 |
|
93 | |||
94 | QValuesAxis::QValuesAxis(QValuesAxisPrivate &d,QObject *parent) : QAbstractAxis(d,parent) |
|
94 | QValuesAxis::QValuesAxis(QValuesAxisPrivate &d,QObject *parent) : QAbstractAxis(d,parent) | |
95 | { |
|
95 | { | |
96 |
|
96 | |||
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | QValuesAxis::~QValuesAxis() |
|
99 | QValuesAxis::~QValuesAxis() | |
100 | { |
|
100 | { | |
101 |
|
101 | |||
102 | } |
|
102 | } | |
103 |
|
103 | |||
104 | void QValuesAxis::setMin(qreal min) |
|
104 | void QValuesAxis::setMin(qreal min) | |
105 | { |
|
105 | { | |
106 | Q_D(QValuesAxis); |
|
106 | Q_D(QValuesAxis); | |
107 | setRange(min,d->m_max); |
|
107 | setRange(min,d->m_max); | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 | qreal QValuesAxis::min() const |
|
110 | qreal QValuesAxis::min() const | |
111 | { |
|
111 | { | |
112 | Q_D(const QValuesAxis); |
|
112 | Q_D(const QValuesAxis); | |
113 | return d->m_min; |
|
113 | return d->m_min; | |
114 | } |
|
114 | } | |
115 |
|
115 | |||
116 | void QValuesAxis::setMax(qreal max) |
|
116 | void QValuesAxis::setMax(qreal max) | |
117 | { |
|
117 | { | |
118 | Q_D(QValuesAxis); |
|
118 | Q_D(QValuesAxis); | |
119 | setRange(d->m_min,max); |
|
119 | setRange(d->m_min,max); | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
122 | qreal QValuesAxis::max() const |
|
122 | qreal QValuesAxis::max() const | |
123 | { |
|
123 | { | |
124 | Q_D(const QValuesAxis); |
|
124 | Q_D(const QValuesAxis); | |
125 | return d->m_max; |
|
125 | return d->m_max; | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | /*! |
|
128 | /*! | |
129 | Sets range from \a min to \a max on the axis. |
|
129 | Sets range from \a min to \a max on the axis. | |
130 | */ |
|
130 | */ | |
131 | void QValuesAxis::setRange(qreal min, qreal max) |
|
131 | void QValuesAxis::setRange(qreal min, qreal max) | |
132 | { |
|
132 | { | |
133 | Q_D(QValuesAxis); |
|
133 | Q_D(QValuesAxis); | |
134 | bool changed = false; |
|
134 | d->setRange(min,max); | |
135 | if (!qFuzzyIsNull(d->m_min - min)) { |
|
|||
136 | d->m_min = min; |
|
|||
137 | changed = true; |
|
|||
138 | emit minChanged(min); |
|
|||
139 | } |
|
|||
140 |
|
||||
141 | if (!qFuzzyIsNull(d->m_max - max)) { |
|
|||
142 | d->m_max = max; |
|
|||
143 | changed = true; |
|
|||
144 | emit maxChanged(max); |
|
|||
145 | } |
|
|||
146 |
|
||||
147 | if (changed) { |
|
|||
148 | emit rangeChanged(d->m_min,d->m_max); |
|
|||
149 | emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers); |
|
|||
150 | } |
|
|||
151 | } |
|
135 | } | |
152 |
|
136 | |||
153 | /*! |
|
137 | /*! | |
154 | Sets \a count for ticks on the axis. |
|
138 | Sets \a count for ticks on the axis. | |
155 | */ |
|
139 | */ | |
156 | void QValuesAxis::setTicksCount(int count) |
|
140 | void QValuesAxis::setTicksCount(int count) | |
157 | { |
|
141 | { | |
158 | Q_D(QValuesAxis); |
|
142 | Q_D(QValuesAxis); | |
159 | if (d->m_ticksCount != count) { |
|
143 | if (d->m_ticksCount != count) { | |
160 | d->m_ticksCount = count; |
|
144 | d->m_ticksCount = count; | |
161 | emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers); |
|
145 | emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers); | |
162 | } |
|
146 | } | |
163 | } |
|
147 | } | |
164 |
|
148 | |||
165 | /*! |
|
149 | /*! | |
166 | \fn int QAbstractAxis::ticksCount() const |
|
150 | \fn int QAbstractAxis::ticksCount() const | |
167 | Return number of ticks on the axis |
|
151 | Return number of ticks on the axis | |
168 | */ |
|
152 | */ | |
169 | int QValuesAxis::ticksCount() const |
|
153 | int QValuesAxis::ticksCount() const | |
170 | { |
|
154 | { | |
171 | Q_D(const QValuesAxis); |
|
155 | Q_D(const QValuesAxis); | |
172 | return d->m_ticksCount; |
|
156 | return d->m_ticksCount; | |
173 | } |
|
157 | } | |
174 |
|
158 | |||
175 | void QValuesAxis::setNiceNumbersEnabled(bool enable) |
|
159 | void QValuesAxis::setNiceNumbersEnabled(bool enable) | |
176 | { |
|
160 | { | |
177 | Q_D(QValuesAxis); |
|
161 | Q_D(QValuesAxis); | |
178 | if (d->m_niceNumbers != enable){ |
|
162 | if (d->m_niceNumbers != enable){ | |
179 | d->m_niceNumbers = enable; |
|
163 | d->m_niceNumbers = enable; | |
180 | emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers); |
|
164 | emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers); | |
181 | } |
|
165 | } | |
182 | } |
|
166 | } | |
183 |
|
167 | |||
184 | bool QValuesAxis::niceNumbersEnabled() const |
|
168 | bool QValuesAxis::niceNumbersEnabled() const | |
185 | { |
|
169 | { | |
186 | Q_D(const QValuesAxis); |
|
170 | Q_D(const QValuesAxis); | |
187 | return d->m_niceNumbers; |
|
171 | return d->m_niceNumbers; | |
188 | } |
|
172 | } | |
189 |
|
173 | |||
190 | QAbstractAxis::AxisType QValuesAxis::type() const |
|
174 | QAbstractAxis::AxisType QValuesAxis::type() const | |
191 | { |
|
175 | { | |
192 | return AxisTypeValues; |
|
176 | return AxisTypeValues; | |
193 | } |
|
177 | } | |
194 |
|
178 | |||
195 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
179 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
196 |
|
180 | |||
197 | QValuesAxisPrivate::QValuesAxisPrivate(QValuesAxis* q): |
|
181 | QValuesAxisPrivate::QValuesAxisPrivate(QValuesAxis* q): | |
198 | QAbstractAxisPrivate(q), |
|
182 | QAbstractAxisPrivate(q), | |
199 | m_min(0), |
|
183 | m_niceNumbers(false) | |
200 | m_max(0), |
|
|||
201 | m_niceNumbers(false), |
|
|||
202 | m_ticksCount(5) |
|
|||
203 | { |
|
184 | { | |
204 |
|
185 | |||
205 | } |
|
186 | } | |
206 |
|
187 | |||
207 | QValuesAxisPrivate::~QValuesAxisPrivate() |
|
188 | QValuesAxisPrivate::~QValuesAxisPrivate() | |
208 | { |
|
189 | { | |
209 |
|
190 | |||
210 | } |
|
191 | } | |
211 |
|
192 | |||
212 | void QValuesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) |
|
193 | void QValuesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |
213 | { |
|
194 | { | |
214 | Q_Q(QValuesAxis); |
|
195 | Q_Q(QValuesAxis); | |
215 | q->setRange(min,max); |
|
196 | q->setRange(min,max); | |
216 | q->setTicksCount(count); |
|
197 | q->setTicksCount(count); | |
217 | } |
|
198 | } | |
218 |
|
199 | |||
219 |
|
200 | |||
220 |
void QValuesAxisPrivate::setMin(const |
|
201 | void QValuesAxisPrivate::setMin(const qreal min) | |
221 | { |
|
202 | { | |
222 | Q_Q(QValuesAxis); |
|
203 | setRange(min,m_max); | |
223 | bool ok; |
|
|||
224 | qreal value = min.toReal(&ok); |
|
|||
225 | if(ok) q->setMin(value); |
|
|||
226 | } |
|
204 | } | |
227 |
|
205 | |||
228 |
void QValuesAxisPrivate::setMax(const |
|
206 | void QValuesAxisPrivate::setMax(const qreal max) | |
229 | { |
|
207 | { | |
230 | Q_Q(QValuesAxis); |
|
208 | setRange(m_min,max); | |
231 | bool ok; |
|
|||
232 | qreal value = max.toReal(&ok); |
|
|||
233 | if(ok) q->setMax(value); |
|
|||
234 | } |
|
209 | } | |
235 |
|
210 | |||
236 |
void QValuesAxisPrivate::setRange(const |
|
211 | void QValuesAxisPrivate::setRange(const qreal min, const qreal max) | |
237 | { |
|
212 | { | |
238 | Q_Q(QValuesAxis); |
|
213 | Q_Q(QValuesAxis); | |
239 | bool ok1; |
|
214 | bool changed = false; | |
240 | bool ok2; |
|
215 | if (!qFuzzyIsNull(m_min - min)) { | |
241 | qreal value1 = min.toReal(&ok1); |
|
216 | m_min = min; | |
242 | qreal value2 = max.toReal(&ok2); |
|
217 | changed = true; | |
243 | if(ok1&&ok2) q->setRange(value1,value2); |
|
218 | emit q->minChanged(min); | |
|
219 | } | |||
|
220 | ||||
|
221 | if (!qFuzzyIsNull(m_max - max)) { | |||
|
222 | m_max = max; | |||
|
223 | changed = true; | |||
|
224 | emit q->maxChanged(max); | |||
|
225 | } | |||
|
226 | ||||
|
227 | if (changed) { | |||
|
228 | emit q->rangeChanged(m_min,m_max); | |||
|
229 | emit this->changed(m_min, m_max, m_ticksCount, m_niceNumbers); | |||
|
230 | } | |||
244 | } |
|
231 | } | |
245 |
|
232 | |||
246 | int QValuesAxisPrivate::ticksCount() const |
|
233 | int QValuesAxisPrivate::ticksCount() const | |
247 | { |
|
234 | { | |
248 | return m_ticksCount; |
|
235 | return m_ticksCount; | |
249 | } |
|
236 | } | |
250 |
|
237 | |||
251 | ChartAxis* QValuesAxisPrivate::createGraphics(ChartPresenter* presenter) |
|
238 | ChartAxis* QValuesAxisPrivate::createGraphics(ChartPresenter* presenter) | |
252 | { |
|
239 | { | |
253 | Q_Q(QValuesAxis); |
|
240 | Q_Q(QValuesAxis); | |
254 | if(m_orientation == Qt::Vertical){ |
|
241 | if(m_orientation == Qt::Vertical){ | |
255 | return new ChartValuesAxisY(q,presenter); |
|
242 | return new ChartValuesAxisY(q,presenter); | |
256 | }else{ |
|
243 | }else{ | |
257 | return new ChartValuesAxisX(q,presenter); |
|
244 | return new ChartValuesAxisX(q,presenter); | |
258 | } |
|
245 | } | |
259 |
|
246 | |||
260 | } |
|
247 | } | |
261 |
|
248 | |||
262 | #include "moc_qvaluesaxis.cpp" |
|
249 | #include "moc_qvaluesaxis.cpp" | |
263 | #include "moc_qvaluesaxis_p.cpp" |
|
250 | #include "moc_qvaluesaxis_p.cpp" | |
264 |
|
251 | |||
265 | QTCOMMERCIALCHART_END_NAMESPACE |
|
252 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,70 +1,67 | |||||
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 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef QVALUESAXIS_P_H |
|
30 | #ifndef QVALUESAXIS_P_H | |
31 | #define QVALUESAXIS_P_H |
|
31 | #define QVALUESAXIS_P_H | |
32 |
|
32 | |||
33 | #include "qvaluesaxis.h" |
|
33 | #include "qvaluesaxis.h" | |
34 | #include "qabstractaxis_p.h" |
|
34 | #include "qabstractaxis_p.h" | |
35 |
|
35 | |||
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
37 |
|
37 | |||
38 | class QValuesAxisPrivate : public QAbstractAxisPrivate |
|
38 | class QValuesAxisPrivate : public QAbstractAxisPrivate | |
39 | { |
|
39 | { | |
40 | Q_OBJECT |
|
40 | Q_OBJECT | |
41 | public: |
|
41 | public: | |
42 | QValuesAxisPrivate(QValuesAxis *q); |
|
42 | QValuesAxisPrivate(QValuesAxis *q); | |
43 | ~QValuesAxisPrivate(); |
|
43 | ~QValuesAxisPrivate(); | |
44 |
|
44 | |||
45 | Q_SIGNALS: |
|
45 | Q_SIGNALS: | |
46 | void changed(qreal min, qreal max, int tickCount,bool niceNumbers); |
|
46 | void changed(qreal min, qreal max, int tickCount,bool niceNumbers); | |
47 |
|
47 | |||
48 | public Q_SLOTS: |
|
48 | public Q_SLOTS: | |
49 | void handleAxisRangeChanged(qreal min, qreal max,int count); |
|
49 | void handleAxisRangeChanged(qreal min, qreal max,int count); | |
50 |
|
50 | |||
51 | public: |
|
51 | public: | |
52 | ChartAxis* createGraphics(ChartPresenter* presenter); |
|
52 | ChartAxis* createGraphics(ChartPresenter* presenter); | |
53 |
|
53 | |||
54 | protected: |
|
54 | protected: | |
55 |
void setMin(const |
|
55 | void setMin(const qreal min); | |
56 |
void setMax(const |
|
56 | void setMax(const qreal max); | |
57 |
void setRange(const |
|
57 | void setRange(const qreal min, const qreal max); | |
58 | int ticksCount() const; |
|
58 | int ticksCount() const; | |
59 |
|
59 | |||
60 | private: |
|
60 | private: | |
61 | qreal m_min; |
|
|||
62 | qreal m_max; |
|
|||
63 | bool m_niceNumbers; |
|
61 | bool m_niceNumbers; | |
64 | int m_ticksCount; |
|
|||
65 | Q_DECLARE_PUBLIC(QValuesAxis) |
|
62 | Q_DECLARE_PUBLIC(QValuesAxis) | |
66 | }; |
|
63 | }; | |
67 |
|
64 | |||
68 | QTCOMMERCIALCHART_END_NAMESPACE |
|
65 | QTCOMMERCIALCHART_END_NAMESPACE | |
69 |
|
66 | |||
70 | #endif // QVALUESAXIS_P_H |
|
67 | #endif // QVALUESAXIS_P_H |
@@ -1,731 +1,732 | |||||
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 "qbarseries.h" |
|
21 | #include "qbarseries.h" | |
22 | #include "qbarseries_p.h" |
|
22 | #include "qbarseries_p.h" | |
23 | #include "qbarset.h" |
|
23 | #include "qbarset.h" | |
24 | #include "qbarset_p.h" |
|
24 | #include "qbarset_p.h" | |
25 | #include "domain_p.h" |
|
25 | #include "domain_p.h" | |
26 | #include "legendmarker_p.h" |
|
26 | #include "legendmarker_p.h" | |
27 | #include "chartdataset_p.h" |
|
27 | #include "chartdataset_p.h" | |
28 | #include "charttheme_p.h" |
|
28 | #include "charttheme_p.h" | |
29 | #include "chartanimator_p.h" |
|
29 | #include "chartanimator_p.h" | |
30 | #include "qvaluesaxis.h" |
|
30 | #include "qvaluesaxis.h" | |
|
31 | #include "qcategoriesaxis.h" | |||
31 |
|
32 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
34 | |||
34 | /*! |
|
35 | /*! | |
35 | \class QBarSeries |
|
36 | \class QBarSeries | |
36 | \brief Series for creating a bar chart |
|
37 | \brief Series for creating a bar chart | |
37 | \mainclass |
|
38 | \mainclass | |
38 |
|
39 | |||
39 | QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars to |
|
40 | QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars to | |
40 | the position defined by data. Single bar is defined by QPointF, where x value is the x-coordinate of the bar |
|
41 | the position defined by data. Single bar is defined by QPointF, where x value is the x-coordinate of the bar | |
41 | and y-value is the height of the bar. The category names are ignored with this series and x-axis |
|
42 | and y-value is the height of the bar. The category names are ignored with this series and x-axis | |
42 | shows the x-values. |
|
43 | shows the x-values. | |
43 |
|
44 | |||
44 | See the \l {BarChart Example} {bar chart example} to learn how to create a simple bar chart. |
|
45 | See the \l {BarChart Example} {bar chart example} to learn how to create a simple bar chart. | |
45 | \image examples_barchart.png |
|
46 | \image examples_barchart.png | |
46 |
|
47 | |||
47 | \sa QBarSet, QStackedBarSeries, QPercentBarSeries |
|
48 | \sa QBarSet, QStackedBarSeries, QPercentBarSeries | |
48 | */ |
|
49 | */ | |
49 | /*! |
|
50 | /*! | |
50 | \qmlclass BarSeries QBarSeries |
|
51 | \qmlclass BarSeries QBarSeries | |
51 | \inherits AbstractSeries |
|
52 | \inherits AbstractSeries | |
52 |
|
53 | |||
53 | The following QML shows how to create a simple bar chart: |
|
54 | The following QML shows how to create a simple bar chart: | |
54 | \snippet ../demos/qmlchart/qml/qmlchart/View6.qml 1 |
|
55 | \snippet ../demos/qmlchart/qml/qmlchart/View6.qml 1 | |
55 |
|
56 | |||
56 | \beginfloatleft |
|
57 | \beginfloatleft | |
57 | \image demos_qmlchart6.png |
|
58 | \image demos_qmlchart6.png | |
58 | \endfloat |
|
59 | \endfloat | |
59 | \clearfloat |
|
60 | \clearfloat | |
60 | */ |
|
61 | */ | |
61 |
|
62 | |||
62 | /*! |
|
63 | /*! | |
63 | \property QBarSeries::barWidth |
|
64 | \property QBarSeries::barWidth | |
64 | The width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars |
|
65 | The width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars | |
65 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen |
|
66 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen | |
66 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. |
|
67 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. | |
67 | Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar. |
|
68 | Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar. | |
68 | \sa QGroupedBarSeries |
|
69 | \sa QGroupedBarSeries | |
69 | */ |
|
70 | */ | |
70 | /*! |
|
71 | /*! | |
71 | \qmlproperty real BarSeries::barWidth |
|
72 | \qmlproperty real BarSeries::barWidth | |
72 | The width of the bars of the series. The unit of width is the unit of x-axis. The minimum width for bars |
|
73 | The width of the bars of the series. The unit of width is the unit of x-axis. The minimum width for bars | |
73 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen |
|
74 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen | |
74 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. |
|
75 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. | |
75 | Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar. |
|
76 | Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar. | |
76 | */ |
|
77 | */ | |
77 |
|
78 | |||
78 | /*! |
|
79 | /*! | |
79 | \property QBarSeries::count |
|
80 | \property QBarSeries::count | |
80 | Holds the number of sets in series. |
|
81 | Holds the number of sets in series. | |
81 | */ |
|
82 | */ | |
82 | /*! |
|
83 | /*! | |
83 | \qmlproperty int BarSeries::count |
|
84 | \qmlproperty int BarSeries::count | |
84 | Holds the number of sets in series. |
|
85 | Holds the number of sets in series. | |
85 | */ |
|
86 | */ | |
86 |
|
87 | |||
87 | /*! |
|
88 | /*! | |
88 | \property QBarSeries::labelsVisible |
|
89 | \property QBarSeries::labelsVisible | |
89 | Defines the visibility of the labels in series |
|
90 | Defines the visibility of the labels in series | |
90 | */ |
|
91 | */ | |
91 | /*! |
|
92 | /*! | |
92 | \qmlproperty bool BarSeries::labelsVisible |
|
93 | \qmlproperty bool BarSeries::labelsVisible | |
93 | Defines the visibility of the labels in series |
|
94 | Defines the visibility of the labels in series | |
94 | */ |
|
95 | */ | |
95 |
|
96 | |||
96 | /*! |
|
97 | /*! | |
97 | \fn void QBarSeries::clicked(int index, QBarSet *barset) |
|
98 | \fn void QBarSeries::clicked(int index, QBarSet *barset) | |
98 | The signal is emitted if the user clicks with a mouse on top of QBarSet \a barset. |
|
99 | The signal is emitted if the user clicks with a mouse on top of QBarSet \a barset. | |
99 | Clicked bar inside set is indexed by \a index |
|
100 | Clicked bar inside set is indexed by \a index | |
100 | */ |
|
101 | */ | |
101 | /*! |
|
102 | /*! | |
102 | \qmlsignal BarSeries::onClicked(int index, BarSet barset) |
|
103 | \qmlsignal BarSeries::onClicked(int index, BarSet barset) | |
103 | The signal is emitted if the user clicks with a mouse on top of BarSet. |
|
104 | The signal is emitted if the user clicks with a mouse on top of BarSet. | |
104 | Clicked bar inside set is indexed by \a index |
|
105 | Clicked bar inside set is indexed by \a index | |
105 | */ |
|
106 | */ | |
106 |
|
107 | |||
107 | /*! |
|
108 | /*! | |
108 | \fn void QBarSeries::hovered(bool status, QBarSet* barset) |
|
109 | \fn void QBarSeries::hovered(bool status, QBarSet* barset) | |
109 |
|
110 | |||
110 | The signal is emitted if mouse is hovered on top of series. |
|
111 | The signal is emitted if mouse is hovered on top of series. | |
111 | Parameter \a barset is the pointer of barset, where hover happened. |
|
112 | Parameter \a barset is the pointer of barset, where hover happened. | |
112 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. |
|
113 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. | |
113 | */ |
|
114 | */ | |
114 | /*! |
|
115 | /*! | |
115 | \qmlsignal BarSeries::onHovered(bool status, BarSet barset) |
|
116 | \qmlsignal BarSeries::onHovered(bool status, BarSet barset) | |
116 |
|
117 | |||
117 | The signal is emitted if mouse is hovered on top of series. |
|
118 | The signal is emitted if mouse is hovered on top of series. | |
118 | Parameter \a barset is the pointer of barset, where hover happened. |
|
119 | Parameter \a barset is the pointer of barset, where hover happened. | |
119 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. |
|
120 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. | |
120 | */ |
|
121 | */ | |
121 |
|
122 | |||
122 | /*! |
|
123 | /*! | |
123 | \fn void QBarSeries::countChanged() |
|
124 | \fn void QBarSeries::countChanged() | |
124 | This signal is emitted when barset count has been changed, for example by append or remove. |
|
125 | This signal is emitted when barset count has been changed, for example by append or remove. | |
125 | */ |
|
126 | */ | |
126 | /*! |
|
127 | /*! | |
127 | \qmlsignal BarSeries::onCountChanged() |
|
128 | \qmlsignal BarSeries::onCountChanged() | |
128 | This signal is emitted when barset count has been changed, for example by append or remove. |
|
129 | This signal is emitted when barset count has been changed, for example by append or remove. | |
129 | */ |
|
130 | */ | |
130 |
|
131 | |||
131 | /*! |
|
132 | /*! | |
132 | \fn void QBarSeries::labelsVisibleChanged() |
|
133 | \fn void QBarSeries::labelsVisibleChanged() | |
133 | This signal is emitted when labels visibility have changed. |
|
134 | This signal is emitted when labels visibility have changed. | |
134 | \sa isLabelsVisible(), setLabelsVisible() |
|
135 | \sa isLabelsVisible(), setLabelsVisible() | |
135 | */ |
|
136 | */ | |
136 |
|
137 | |||
137 | /*! |
|
138 | /*! | |
138 | \fn void QBarSeries::barsetsAdded(QList<QBarSet*> sets) |
|
139 | \fn void QBarSeries::barsetsAdded(QList<QBarSet*> sets) | |
139 | This signal is emitted when \a sets have been added to the series. |
|
140 | This signal is emitted when \a sets have been added to the series. | |
140 | \sa append(), insert() |
|
141 | \sa append(), insert() | |
141 | */ |
|
142 | */ | |
142 | /*! |
|
143 | /*! | |
143 | \qmlsignal BarSeries::onAdded(BarSet barset) |
|
144 | \qmlsignal BarSeries::onAdded(BarSet barset) | |
144 | Emitted when \a barset has been added to the series. |
|
145 | Emitted when \a barset has been added to the series. | |
145 | */ |
|
146 | */ | |
146 |
|
147 | |||
147 | /*! |
|
148 | /*! | |
148 | \fn void QBarSeries::barsetsRemoved(QList<QBarSet*> sets) |
|
149 | \fn void QBarSeries::barsetsRemoved(QList<QBarSet*> sets) | |
149 | This signal is emitted when \a sets have been removed from the series. |
|
150 | This signal is emitted when \a sets have been removed from the series. | |
150 | \sa remove() |
|
151 | \sa remove() | |
151 | */ |
|
152 | */ | |
152 | /*! |
|
153 | /*! | |
153 | \qmlsignal BarSeries::onRemoved(BarSet barset) |
|
154 | \qmlsignal BarSeries::onRemoved(BarSet barset) | |
154 | Emitted when \a barset has been removed from the series. |
|
155 | Emitted when \a barset has been removed from the series. | |
155 | */ |
|
156 | */ | |
156 |
|
157 | |||
157 | /*! |
|
158 | /*! | |
158 | \qmlmethod BarSet BarSeries::at(int index) |
|
159 | \qmlmethod BarSet BarSeries::at(int index) | |
159 | Returns bar set at \a index. Returns null if the index is not valid. |
|
160 | Returns bar set at \a index. Returns null if the index is not valid. | |
160 | */ |
|
161 | */ | |
161 |
|
162 | |||
162 | /*! |
|
163 | /*! | |
163 | \qmlmethod BarSet BarSeries::append(string label, VariantList values) |
|
164 | \qmlmethod BarSet BarSeries::append(string label, VariantList values) | |
164 | Adds a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints. |
|
165 | Adds a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints. | |
165 | For example: |
|
166 | For example: | |
166 | \code |
|
167 | \code | |
167 | myBarSeries.append("set 1", [0, 0.2, 0.2, 0.5, 0.4, 1.5, 0.9]); |
|
168 | myBarSeries.append("set 1", [0, 0.2, 0.2, 0.5, 0.4, 1.5, 0.9]); | |
168 | myBarSeries.append("set 2", [Qt.point(0, 1), Qt.point(2, 2.5), Qt.point(3.5, 2.2)]); |
|
169 | myBarSeries.append("set 2", [Qt.point(0, 1), Qt.point(2, 2.5), Qt.point(3.5, 2.2)]); | |
169 | \endcode |
|
170 | \endcode | |
170 | */ |
|
171 | */ | |
171 |
|
172 | |||
172 | /*! |
|
173 | /*! | |
173 | \qmlmethod BarSet BarSeries::insert(int index, string label, VariantList values) |
|
174 | \qmlmethod BarSet BarSeries::insert(int index, string label, VariantList values) | |
174 | Inserts a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints. |
|
175 | Inserts a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints. | |
175 | If index is zero or smaller, the new barset is prepended. If the index is count or bigger, the new barset is |
|
176 | If index is zero or smaller, the new barset is prepended. If the index is count or bigger, the new barset is | |
176 | appended. |
|
177 | appended. | |
177 | \sa BarSeries::append() |
|
178 | \sa BarSeries::append() | |
178 | */ |
|
179 | */ | |
179 |
|
180 | |||
180 | /*! |
|
181 | /*! | |
181 | \qmlmethod bool BarSeries::remove(BarSet barset) |
|
182 | \qmlmethod bool BarSeries::remove(BarSet barset) | |
182 | Removes the barset from the series. Returns true if successfull, false otherwise. |
|
183 | Removes the barset from the series. Returns true if successfull, false otherwise. | |
183 | */ |
|
184 | */ | |
184 |
|
185 | |||
185 | /*! |
|
186 | /*! | |
186 | \qmlmethod BarSeries::clear() |
|
187 | \qmlmethod BarSeries::clear() | |
187 | Removes all barsets from the series. |
|
188 | Removes all barsets from the series. | |
188 | */ |
|
189 | */ | |
189 |
|
190 | |||
190 | /*! |
|
191 | /*! | |
191 | Constructs empty QBarSeries. |
|
192 | Constructs empty QBarSeries. | |
192 | QBarSeries is QObject which is a child of a \a parent. |
|
193 | QBarSeries is QObject which is a child of a \a parent. | |
193 | */ |
|
194 | */ | |
194 | QBarSeries::QBarSeries(QObject *parent) : |
|
195 | QBarSeries::QBarSeries(QObject *parent) : | |
195 | QAbstractSeries(*new QBarSeriesPrivate(this),parent) |
|
196 | QAbstractSeries(*new QBarSeriesPrivate(this),parent) | |
196 | { |
|
197 | { | |
197 | } |
|
198 | } | |
198 |
|
199 | |||
199 | /*! |
|
200 | /*! | |
200 | Destructs barseries and owned barsets. |
|
201 | Destructs barseries and owned barsets. | |
201 | */ |
|
202 | */ | |
202 | QBarSeries::~QBarSeries() |
|
203 | QBarSeries::~QBarSeries() | |
203 | { |
|
204 | { | |
204 | Q_D(QBarSeries); |
|
205 | Q_D(QBarSeries); | |
205 | if(d->m_dataset){ |
|
206 | if(d->m_dataset){ | |
206 | d->m_dataset->removeSeries(this); |
|
207 | d->m_dataset->removeSeries(this); | |
207 | } |
|
208 | } | |
208 | } |
|
209 | } | |
209 |
|
210 | |||
210 | /*! |
|
211 | /*! | |
211 | \internal |
|
212 | \internal | |
212 | */ |
|
213 | */ | |
213 | QBarSeries::QBarSeries(QBarSeriesPrivate &d, QObject *parent) : |
|
214 | QBarSeries::QBarSeries(QBarSeriesPrivate &d, QObject *parent) : | |
214 | QAbstractSeries(d,parent) |
|
215 | QAbstractSeries(d,parent) | |
215 | { |
|
216 | { | |
216 | } |
|
217 | } | |
217 |
|
218 | |||
218 | /*! |
|
219 | /*! | |
219 | Returns the type of series. Derived classes override this. |
|
220 | Returns the type of series. Derived classes override this. | |
220 | */ |
|
221 | */ | |
221 | QAbstractSeries::SeriesType QBarSeries::type() const |
|
222 | QAbstractSeries::SeriesType QBarSeries::type() const | |
222 | { |
|
223 | { | |
223 | return QAbstractSeries::SeriesTypeBar; |
|
224 | return QAbstractSeries::SeriesTypeBar; | |
224 | } |
|
225 | } | |
225 |
|
226 | |||
226 | /*! |
|
227 | /*! | |
227 | Sets the width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars |
|
228 | Sets the width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars | |
228 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen |
|
229 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen | |
229 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. |
|
230 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. | |
230 | Note that with \link QGroupedBarSeries \endlink this value means the width of one group of bars instead of just one bar. |
|
231 | Note that with \link QGroupedBarSeries \endlink this value means the width of one group of bars instead of just one bar. | |
231 | */ |
|
232 | */ | |
232 | void QBarSeries::setBarWidth(qreal width) |
|
233 | void QBarSeries::setBarWidth(qreal width) | |
233 | { |
|
234 | { | |
234 | Q_D(QBarSeries); |
|
235 | Q_D(QBarSeries); | |
235 | d->setBarWidth(width); |
|
236 | d->setBarWidth(width); | |
236 | } |
|
237 | } | |
237 |
|
238 | |||
238 | /*! |
|
239 | /*! | |
239 | Returns the width of the bars of the series. |
|
240 | Returns the width of the bars of the series. | |
240 | \sa setBarWidth() |
|
241 | \sa setBarWidth() | |
241 | */ |
|
242 | */ | |
242 | qreal QBarSeries::barWidth() const |
|
243 | qreal QBarSeries::barWidth() const | |
243 | { |
|
244 | { | |
244 | Q_D(const QBarSeries); |
|
245 | Q_D(const QBarSeries); | |
245 | return d->barWidth(); |
|
246 | return d->barWidth(); | |
246 | } |
|
247 | } | |
247 |
|
248 | |||
248 | /*! |
|
249 | /*! | |
249 | Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. |
|
250 | Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. | |
250 | Returns true, if appending succeeded. |
|
251 | Returns true, if appending succeeded. | |
251 | */ |
|
252 | */ | |
252 | bool QBarSeries::append(QBarSet *set) |
|
253 | bool QBarSeries::append(QBarSet *set) | |
253 | { |
|
254 | { | |
254 | Q_D(QBarSeries); |
|
255 | Q_D(QBarSeries); | |
255 | bool success = d->append(set); |
|
256 | bool success = d->append(set); | |
256 | if (success) { |
|
257 | if (success) { | |
257 | QList<QBarSet*> sets; |
|
258 | QList<QBarSet*> sets; | |
258 | sets.append(set); |
|
259 | sets.append(set); | |
259 | emit barsetsAdded(sets); |
|
260 | emit barsetsAdded(sets); | |
260 | emit countChanged(); |
|
261 | emit countChanged(); | |
261 | } |
|
262 | } | |
262 | return success; |
|
263 | return success; | |
263 | } |
|
264 | } | |
264 |
|
265 | |||
265 | /*! |
|
266 | /*! | |
266 | Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set. |
|
267 | Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set. | |
267 | Returns true, if set was removed. |
|
268 | Returns true, if set was removed. | |
268 | */ |
|
269 | */ | |
269 | bool QBarSeries::remove(QBarSet *set) |
|
270 | bool QBarSeries::remove(QBarSet *set) | |
270 | { |
|
271 | { | |
271 | Q_D(QBarSeries); |
|
272 | Q_D(QBarSeries); | |
272 | bool success = d->remove(set); |
|
273 | bool success = d->remove(set); | |
273 | if (success) { |
|
274 | if (success) { | |
274 | QList<QBarSet*> sets; |
|
275 | QList<QBarSet*> sets; | |
275 | sets.append(set); |
|
276 | sets.append(set); | |
276 | emit barsetsRemoved(sets); |
|
277 | emit barsetsRemoved(sets); | |
277 | emit countChanged(); |
|
278 | emit countChanged(); | |
278 | } |
|
279 | } | |
279 | return success; |
|
280 | return success; | |
280 | } |
|
281 | } | |
281 |
|
282 | |||
282 | /*! |
|
283 | /*! | |
283 | Adds a list of barsets to series. Takes ownership of \a sets. |
|
284 | Adds a list of barsets to series. Takes ownership of \a sets. | |
284 | Returns true, if all sets were appended succesfully. If any of the sets is null or is already appended to series, |
|
285 | Returns true, if all sets were appended succesfully. If any of the sets is null or is already appended to series, | |
285 | nothing is appended and function returns false. If any of the sets is in list more than once, nothing is appended |
|
286 | nothing is appended and function returns false. If any of the sets is in list more than once, nothing is appended | |
286 | and function returns false. |
|
287 | and function returns false. | |
287 | */ |
|
288 | */ | |
288 | bool QBarSeries::append(QList<QBarSet* > sets) |
|
289 | bool QBarSeries::append(QList<QBarSet* > sets) | |
289 | { |
|
290 | { | |
290 | Q_D(QBarSeries); |
|
291 | Q_D(QBarSeries); | |
291 | bool success = d->append(sets); |
|
292 | bool success = d->append(sets); | |
292 | if (success) { |
|
293 | if (success) { | |
293 | emit barsetsAdded(sets); |
|
294 | emit barsetsAdded(sets); | |
294 | emit countChanged(); |
|
295 | emit countChanged(); | |
295 | } |
|
296 | } | |
296 | return success; |
|
297 | return success; | |
297 | } |
|
298 | } | |
298 |
|
299 | |||
299 | /*! |
|
300 | /*! | |
300 | Insert a set of bars to series at \a index postion. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. |
|
301 | Insert a set of bars to series at \a index postion. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. | |
301 | Returns true, if inserting succeeded. |
|
302 | Returns true, if inserting succeeded. | |
302 |
|
303 | |||
303 | */ |
|
304 | */ | |
304 | bool QBarSeries::insert(int index, QBarSet *set) |
|
305 | bool QBarSeries::insert(int index, QBarSet *set) | |
305 | { |
|
306 | { | |
306 | Q_D(QBarSeries); |
|
307 | Q_D(QBarSeries); | |
307 | bool success = d->insert(index, set); |
|
308 | bool success = d->insert(index, set); | |
308 | if (success) { |
|
309 | if (success) { | |
309 | QList<QBarSet*> sets; |
|
310 | QList<QBarSet*> sets; | |
310 | sets.append(set); |
|
311 | sets.append(set); | |
311 | emit barsetsAdded(sets); |
|
312 | emit barsetsAdded(sets); | |
312 | emit countChanged(); |
|
313 | emit countChanged(); | |
313 | } |
|
314 | } | |
314 | return success; |
|
315 | return success; | |
315 | } |
|
316 | } | |
316 |
|
317 | |||
317 | /*! |
|
318 | /*! | |
318 | Removes all of the bar sets from the series |
|
319 | Removes all of the bar sets from the series | |
319 | */ |
|
320 | */ | |
320 | void QBarSeries::clear() |
|
321 | void QBarSeries::clear() | |
321 | { |
|
322 | { | |
322 | Q_D(QBarSeries); |
|
323 | Q_D(QBarSeries); | |
323 | QList<QBarSet *> sets = barSets(); |
|
324 | QList<QBarSet *> sets = barSets(); | |
324 | bool success = d->remove(sets); |
|
325 | bool success = d->remove(sets); | |
325 | if (success) { |
|
326 | if (success) { | |
326 | emit barsetsRemoved(sets); |
|
327 | emit barsetsRemoved(sets); | |
327 | emit countChanged(); |
|
328 | emit countChanged(); | |
328 | } |
|
329 | } | |
329 | } |
|
330 | } | |
330 |
|
331 | |||
331 | /*! |
|
332 | /*! | |
332 | Returns number of sets in series. |
|
333 | Returns number of sets in series. | |
333 | */ |
|
334 | */ | |
334 | int QBarSeries::count() const |
|
335 | int QBarSeries::count() const | |
335 | { |
|
336 | { | |
336 | Q_D(const QBarSeries); |
|
337 | Q_D(const QBarSeries); | |
337 | return d->m_barSets.count(); |
|
338 | return d->m_barSets.count(); | |
338 | } |
|
339 | } | |
339 |
|
340 | |||
340 | /*! |
|
341 | /*! | |
341 | Returns a list of sets in series. Keeps ownership of sets. |
|
342 | Returns a list of sets in series. Keeps ownership of sets. | |
342 | */ |
|
343 | */ | |
343 | QList<QBarSet*> QBarSeries::barSets() const |
|
344 | QList<QBarSet*> QBarSeries::barSets() const | |
344 | { |
|
345 | { | |
345 | Q_D(const QBarSeries); |
|
346 | Q_D(const QBarSeries); | |
346 | return d->m_barSets; |
|
347 | return d->m_barSets; | |
347 | } |
|
348 | } | |
348 |
|
349 | |||
349 | /*! |
|
350 | /*! | |
350 | Sets the visibility of labels in series to \a visible |
|
351 | Sets the visibility of labels in series to \a visible | |
351 | */ |
|
352 | */ | |
352 | void QBarSeries::setLabelsVisible(bool visible) |
|
353 | void QBarSeries::setLabelsVisible(bool visible) | |
353 | { |
|
354 | { | |
354 | Q_D(QBarSeries); |
|
355 | Q_D(QBarSeries); | |
355 | if (d->m_labelsVisible != visible) { |
|
356 | if (d->m_labelsVisible != visible) { | |
356 | d->setLabelsVisible(visible); |
|
357 | d->setLabelsVisible(visible); | |
357 | emit labelsVisibleChanged(); |
|
358 | emit labelsVisibleChanged(); | |
358 | } |
|
359 | } | |
359 | } |
|
360 | } | |
360 |
|
361 | |||
361 | /*! |
|
362 | /*! | |
362 | Returns the visibility of labels |
|
363 | Returns the visibility of labels | |
363 | */ |
|
364 | */ | |
364 | bool QBarSeries::isLabelsVisible() const |
|
365 | bool QBarSeries::isLabelsVisible() const | |
365 | { |
|
366 | { | |
366 | Q_D(const QBarSeries); |
|
367 | Q_D(const QBarSeries); | |
367 | return d->m_labelsVisible; |
|
368 | return d->m_labelsVisible; | |
368 | } |
|
369 | } | |
369 |
|
370 | |||
370 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
371 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
371 |
|
372 | |||
372 | QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : |
|
373 | QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : | |
373 | QAbstractSeriesPrivate(q), |
|
374 | QAbstractSeriesPrivate(q), | |
374 | m_barWidth(0.5), // Default value is 50% of category width |
|
375 | m_barWidth(0.5), // Default value is 50% of category width | |
375 | m_labelsVisible(false), |
|
376 | m_labelsVisible(false), | |
376 | m_visible(true) |
|
377 | m_visible(true) | |
377 | { |
|
378 | { | |
378 | } |
|
379 | } | |
379 |
|
380 | |||
380 | int QBarSeriesPrivate::categoryCount() const |
|
381 | int QBarSeriesPrivate::categoryCount() const | |
381 | { |
|
382 | { | |
382 | // No categories defined. return count of longest set. |
|
383 | // No categories defined. return count of longest set. | |
383 | int count = 0; |
|
384 | int count = 0; | |
384 | for (int i=0; i<m_barSets.count(); i++) { |
|
385 | for (int i=0; i<m_barSets.count(); i++) { | |
385 | if (m_barSets.at(i)->count() > count) { |
|
386 | if (m_barSets.at(i)->count() > count) { | |
386 | count = m_barSets.at(i)->count(); |
|
387 | count = m_barSets.at(i)->count(); | |
387 | } |
|
388 | } | |
388 | } |
|
389 | } | |
389 |
|
390 | |||
390 | return count; |
|
391 | return count; | |
391 | } |
|
392 | } | |
392 |
|
393 | |||
393 | void QBarSeriesPrivate::setBarWidth(qreal width) |
|
394 | void QBarSeriesPrivate::setBarWidth(qreal width) | |
394 | { |
|
395 | { | |
395 | if (width < 0.0) { |
|
396 | if (width < 0.0) { | |
396 | width = 0.0; |
|
397 | width = 0.0; | |
397 | } |
|
398 | } | |
398 | m_barWidth = width; |
|
399 | m_barWidth = width; | |
399 | emit updatedBars(); |
|
400 | emit updatedBars(); | |
400 | } |
|
401 | } | |
401 |
|
402 | |||
402 | qreal QBarSeriesPrivate::barWidth() const |
|
403 | qreal QBarSeriesPrivate::barWidth() const | |
403 | { |
|
404 | { | |
404 | return m_barWidth; |
|
405 | return m_barWidth; | |
405 | } |
|
406 | } | |
406 |
|
407 | |||
407 | QBarSet* QBarSeriesPrivate::barsetAt(int index) |
|
408 | QBarSet* QBarSeriesPrivate::barsetAt(int index) | |
408 | { |
|
409 | { | |
409 | return m_barSets.at(index); |
|
410 | return m_barSets.at(index); | |
410 | } |
|
411 | } | |
411 |
|
412 | |||
412 | void QBarSeriesPrivate::setVisible(bool visible) |
|
413 | void QBarSeriesPrivate::setVisible(bool visible) | |
413 | { |
|
414 | { | |
414 | m_visible = visible; |
|
415 | m_visible = visible; | |
415 | emit updatedBars(); |
|
416 | emit updatedBars(); | |
416 | } |
|
417 | } | |
417 |
|
418 | |||
418 | void QBarSeriesPrivate::setLabelsVisible(bool visible) |
|
419 | void QBarSeriesPrivate::setLabelsVisible(bool visible) | |
419 | { |
|
420 | { | |
420 | m_labelsVisible = visible; |
|
421 | m_labelsVisible = visible; | |
421 | emit labelsVisibleChanged(visible); |
|
422 | emit labelsVisibleChanged(visible); | |
422 | } |
|
423 | } | |
423 |
|
424 | |||
424 | qreal QBarSeriesPrivate::min() |
|
425 | qreal QBarSeriesPrivate::min() | |
425 | { |
|
426 | { | |
426 | if (m_barSets.count() <= 0) { |
|
427 | if (m_barSets.count() <= 0) { | |
427 | return 0; |
|
428 | return 0; | |
428 | } |
|
429 | } | |
429 | qreal min = INT_MAX; |
|
430 | qreal min = INT_MAX; | |
430 |
|
431 | |||
431 | for (int i = 0; i < m_barSets.count(); i++) { |
|
432 | for (int i = 0; i < m_barSets.count(); i++) { | |
432 | int categoryCount = m_barSets.at(i)->count(); |
|
433 | int categoryCount = m_barSets.at(i)->count(); | |
433 | for (int j = 0; j < categoryCount; j++) { |
|
434 | for (int j = 0; j < categoryCount; j++) { | |
434 | qreal temp = m_barSets.at(i)->at(j).y(); |
|
435 | qreal temp = m_barSets.at(i)->at(j).y(); | |
435 | if (temp < min) |
|
436 | if (temp < min) | |
436 | min = temp; |
|
437 | min = temp; | |
437 | } |
|
438 | } | |
438 | } |
|
439 | } | |
439 | return min; |
|
440 | return min; | |
440 | } |
|
441 | } | |
441 |
|
442 | |||
442 | qreal QBarSeriesPrivate::max() |
|
443 | qreal QBarSeriesPrivate::max() | |
443 | { |
|
444 | { | |
444 | if (m_barSets.count() <= 0) { |
|
445 | if (m_barSets.count() <= 0) { | |
445 | return 0; |
|
446 | return 0; | |
446 | } |
|
447 | } | |
447 | qreal max = INT_MIN; |
|
448 | qreal max = INT_MIN; | |
448 |
|
449 | |||
449 | for (int i = 0; i < m_barSets.count(); i++) { |
|
450 | for (int i = 0; i < m_barSets.count(); i++) { | |
450 | int categoryCount = m_barSets.at(i)->count(); |
|
451 | int categoryCount = m_barSets.at(i)->count(); | |
451 | for (int j = 0; j < categoryCount; j++) { |
|
452 | for (int j = 0; j < categoryCount; j++) { | |
452 | qreal temp = m_barSets.at(i)->at(j).y(); |
|
453 | qreal temp = m_barSets.at(i)->at(j).y(); | |
453 | if (temp > max) |
|
454 | if (temp > max) | |
454 | max = temp; |
|
455 | max = temp; | |
455 | } |
|
456 | } | |
456 | } |
|
457 | } | |
457 |
|
458 | |||
458 | return max; |
|
459 | return max; | |
459 | } |
|
460 | } | |
460 |
|
461 | |||
461 | qreal QBarSeriesPrivate::valueAt(int set, int category) |
|
462 | qreal QBarSeriesPrivate::valueAt(int set, int category) | |
462 | { |
|
463 | { | |
463 | if ((set < 0) || (set >= m_barSets.count())) { |
|
464 | if ((set < 0) || (set >= m_barSets.count())) { | |
464 | // No set, no value. |
|
465 | // No set, no value. | |
465 | return 0; |
|
466 | return 0; | |
466 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { |
|
467 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { | |
467 | // No category, no value. |
|
468 | // No category, no value. | |
468 | return 0; |
|
469 | return 0; | |
469 | } |
|
470 | } | |
470 |
|
471 | |||
471 | return m_barSets.at(set)->at(category).y(); |
|
472 | return m_barSets.at(set)->at(category).y(); | |
472 | } |
|
473 | } | |
473 |
|
474 | |||
474 | qreal QBarSeriesPrivate::percentageAt(int set, int category) |
|
475 | qreal QBarSeriesPrivate::percentageAt(int set, int category) | |
475 | { |
|
476 | { | |
476 | if ((set < 0) || (set >= m_barSets.count())) { |
|
477 | if ((set < 0) || (set >= m_barSets.count())) { | |
477 | // No set, no value. |
|
478 | // No set, no value. | |
478 | return 0; |
|
479 | return 0; | |
479 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { |
|
480 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { | |
480 | // No category, no value. |
|
481 | // No category, no value. | |
481 | return 0; |
|
482 | return 0; | |
482 | } |
|
483 | } | |
483 |
|
484 | |||
484 | qreal value = m_barSets.at(set)->at(category).y(); |
|
485 | qreal value = m_barSets.at(set)->at(category).y(); | |
485 | qreal sum = categorySum(category); |
|
486 | qreal sum = categorySum(category); | |
486 | if ( qFuzzyIsNull(sum) ) { |
|
487 | if ( qFuzzyIsNull(sum) ) { | |
487 | return 0; |
|
488 | return 0; | |
488 | } |
|
489 | } | |
489 |
|
490 | |||
490 | return value / sum; |
|
491 | return value / sum; | |
491 | } |
|
492 | } | |
492 |
|
493 | |||
493 | qreal QBarSeriesPrivate::categorySum(int category) |
|
494 | qreal QBarSeriesPrivate::categorySum(int category) | |
494 | { |
|
495 | { | |
495 | qreal sum(0); |
|
496 | qreal sum(0); | |
496 | int count = m_barSets.count(); // Count sets |
|
497 | int count = m_barSets.count(); // Count sets | |
497 | for (int set = 0; set < count; set++) { |
|
498 | for (int set = 0; set < count; set++) { | |
498 | if (category < m_barSets.at(set)->count()) |
|
499 | if (category < m_barSets.at(set)->count()) | |
499 | sum += m_barSets.at(set)->at(category).y(); |
|
500 | sum += m_barSets.at(set)->at(category).y(); | |
500 | } |
|
501 | } | |
501 | return sum; |
|
502 | return sum; | |
502 | } |
|
503 | } | |
503 |
|
504 | |||
504 | qreal QBarSeriesPrivate::absoluteCategorySum(int category) |
|
505 | qreal QBarSeriesPrivate::absoluteCategorySum(int category) | |
505 | { |
|
506 | { | |
506 | qreal sum(0); |
|
507 | qreal sum(0); | |
507 | int count = m_barSets.count(); // Count sets |
|
508 | int count = m_barSets.count(); // Count sets | |
508 | for (int set = 0; set < count; set++) { |
|
509 | for (int set = 0; set < count; set++) { | |
509 | if (category < m_barSets.at(set)->count()) |
|
510 | if (category < m_barSets.at(set)->count()) | |
510 | sum += qAbs(m_barSets.at(set)->at(category).y()); |
|
511 | sum += qAbs(m_barSets.at(set)->at(category).y()); | |
511 | } |
|
512 | } | |
512 | return sum; |
|
513 | return sum; | |
513 | } |
|
514 | } | |
514 |
|
515 | |||
515 | qreal QBarSeriesPrivate::maxCategorySum() |
|
516 | qreal QBarSeriesPrivate::maxCategorySum() | |
516 | { |
|
517 | { | |
517 | qreal max = INT_MIN; |
|
518 | qreal max = INT_MIN; | |
518 | int count = categoryCount(); |
|
519 | int count = categoryCount(); | |
519 | for (int i = 0; i < count; i++) { |
|
520 | for (int i = 0; i < count; i++) { | |
520 | qreal sum = categorySum(i); |
|
521 | qreal sum = categorySum(i); | |
521 | if (sum > max) |
|
522 | if (sum > max) | |
522 | max = sum; |
|
523 | max = sum; | |
523 | } |
|
524 | } | |
524 | return max; |
|
525 | return max; | |
525 | } |
|
526 | } | |
526 |
|
527 | |||
527 | qreal QBarSeriesPrivate::minX() |
|
528 | qreal QBarSeriesPrivate::minX() | |
528 | { |
|
529 | { | |
529 | if (m_barSets.count() <= 0) { |
|
530 | if (m_barSets.count() <= 0) { | |
530 | return 0; |
|
531 | return 0; | |
531 | } |
|
532 | } | |
532 | qreal min = INT_MAX; |
|
533 | qreal min = INT_MAX; | |
533 |
|
534 | |||
534 | for (int i = 0; i < m_barSets.count(); i++) { |
|
535 | for (int i = 0; i < m_barSets.count(); i++) { | |
535 | int categoryCount = m_barSets.at(i)->count(); |
|
536 | int categoryCount = m_barSets.at(i)->count(); | |
536 | for (int j = 0; j < categoryCount; j++) { |
|
537 | for (int j = 0; j < categoryCount; j++) { | |
537 | qreal temp = m_barSets.at(i)->at(j).x(); |
|
538 | qreal temp = m_barSets.at(i)->at(j).x(); | |
538 | if (temp < min) |
|
539 | if (temp < min) | |
539 | min = temp; |
|
540 | min = temp; | |
540 | } |
|
541 | } | |
541 | } |
|
542 | } | |
542 | return min; |
|
543 | return min; | |
543 | } |
|
544 | } | |
544 |
|
545 | |||
545 | qreal QBarSeriesPrivate::maxX() |
|
546 | qreal QBarSeriesPrivate::maxX() | |
546 | { |
|
547 | { | |
547 | if (m_barSets.count() <= 0) { |
|
548 | if (m_barSets.count() <= 0) { | |
548 | return 0; |
|
549 | return 0; | |
549 | } |
|
550 | } | |
550 | qreal max = INT_MIN; |
|
551 | qreal max = INT_MIN; | |
551 |
|
552 | |||
552 | for (int i = 0; i < m_barSets.count(); i++) { |
|
553 | for (int i = 0; i < m_barSets.count(); i++) { | |
553 | int categoryCount = m_barSets.at(i)->count(); |
|
554 | int categoryCount = m_barSets.at(i)->count(); | |
554 | for (int j = 0; j < categoryCount; j++) { |
|
555 | for (int j = 0; j < categoryCount; j++) { | |
555 | qreal temp = m_barSets.at(i)->at(j).x(); |
|
556 | qreal temp = m_barSets.at(i)->at(j).x(); | |
556 | if (temp > max) |
|
557 | if (temp > max) | |
557 | max = temp; |
|
558 | max = temp; | |
558 | } |
|
559 | } | |
559 | } |
|
560 | } | |
560 |
|
561 | |||
561 | return max; |
|
562 | return max; | |
562 | } |
|
563 | } | |
563 |
|
564 | |||
564 |
|
565 | |||
565 | void QBarSeriesPrivate::scaleDomain(Domain& domain) |
|
566 | void QBarSeriesPrivate::scaleDomain(Domain& domain) | |
566 | { |
|
567 | { | |
567 | qreal minX(domain.minX()); |
|
568 | qreal minX(domain.minX()); | |
568 | qreal minY(domain.minY()); |
|
569 | qreal minY(domain.minY()); | |
569 | qreal maxX(domain.maxX()); |
|
570 | qreal maxX(domain.maxX()); | |
570 | qreal maxY(domain.maxY()); |
|
571 | qreal maxY(domain.maxY()); | |
571 | int tickXCount(domain.tickXCount()); |
|
572 | int tickXCount(domain.tickXCount()); | |
572 | int tickYCount(domain.tickYCount()); |
|
573 | int tickYCount(domain.tickYCount()); | |
573 |
|
574 | |||
574 | qreal seriesMinX = this->minX(); |
|
575 | qreal seriesMinX = this->minX(); | |
575 | qreal seriesMaxX = this->maxX(); |
|
576 | qreal seriesMaxX = this->maxX(); | |
576 | qreal y = max(); |
|
577 | qreal y = max(); | |
577 | minX = qMin(minX, seriesMinX - 0.5); |
|
578 | minX = qMin(minX, seriesMinX - 0.5); | |
578 | minY = qMin(minY, y); |
|
579 | minY = qMin(minY, y); | |
579 | maxX = qMax(maxX, seriesMaxX + 0.5); |
|
580 | maxX = qMax(maxX, seriesMaxX + 0.5); | |
580 | maxY = qMax(maxY, y); |
|
581 | maxY = qMax(maxY, y); | |
581 | tickXCount = categoryCount()+1; |
|
582 | tickXCount = categoryCount()+1; | |
582 |
|
583 | |||
583 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
584 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); | |
584 | } |
|
585 | } | |
585 |
|
586 | |||
586 | Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
587 | Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
587 | { |
|
588 | { | |
588 | Q_Q(QBarSeries); |
|
589 | Q_Q(QBarSeries); | |
589 |
|
590 | |||
590 | BarChartItem* bar = new BarChartItem(q,presenter); |
|
591 | BarChartItem* bar = new BarChartItem(q,presenter); | |
591 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
592 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
592 | presenter->animator()->addAnimation(bar); |
|
593 | presenter->animator()->addAnimation(bar); | |
593 | } |
|
594 | } | |
594 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
595 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
595 | return bar; |
|
596 | return bar; | |
596 |
|
597 | |||
597 | } |
|
598 | } | |
598 |
|
599 | |||
599 | QList<LegendMarker*> QBarSeriesPrivate::createLegendMarker(QLegend* legend) |
|
600 | QList<LegendMarker*> QBarSeriesPrivate::createLegendMarker(QLegend* legend) | |
600 | { |
|
601 | { | |
601 | Q_Q(QBarSeries); |
|
602 | Q_Q(QBarSeries); | |
602 | QList<LegendMarker*> markers; |
|
603 | QList<LegendMarker*> markers; | |
603 | foreach(QBarSet* set, q->barSets()) { |
|
604 | foreach(QBarSet* set, q->barSets()) { | |
604 | BarLegendMarker* marker = new BarLegendMarker(q,set,legend); |
|
605 | BarLegendMarker* marker = new BarLegendMarker(q,set,legend); | |
605 | markers << marker; |
|
606 | markers << marker; | |
606 | } |
|
607 | } | |
607 |
|
608 | |||
608 | return markers; |
|
609 | return markers; | |
609 | } |
|
610 | } | |
610 |
|
611 | |||
611 | QAbstractAxis* QBarSeriesPrivate::createAxisX(QObject* parent) |
|
612 | QAbstractAxis* QBarSeriesPrivate::createAxisX(QObject* parent) | |
612 | { |
|
613 | { | |
613 |
return new Q |
|
614 | return new QCategoriesAxis(parent); | |
614 | } |
|
615 | } | |
615 |
|
616 | |||
616 | QAbstractAxis* QBarSeriesPrivate::createAxisY(QObject* parent) |
|
617 | QAbstractAxis* QBarSeriesPrivate::createAxisY(QObject* parent) | |
617 | { |
|
618 | { | |
618 | return new QValuesAxis(parent); |
|
619 | return new QValuesAxis(parent); | |
619 | } |
|
620 | } | |
620 |
|
621 | |||
621 | bool QBarSeriesPrivate::append(QBarSet *set) |
|
622 | bool QBarSeriesPrivate::append(QBarSet *set) | |
622 | { |
|
623 | { | |
623 | Q_Q(QBarSeries); |
|
624 | Q_Q(QBarSeries); | |
624 | if ((m_barSets.contains(set)) || (set == 0)) { |
|
625 | if ((m_barSets.contains(set)) || (set == 0)) { | |
625 | // Fail if set is already in list or set is null. |
|
626 | // Fail if set is already in list or set is null. | |
626 | return false; |
|
627 | return false; | |
627 | } |
|
628 | } | |
628 | m_barSets.append(set); |
|
629 | m_barSets.append(set); | |
629 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
630 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); | |
630 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
631 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
631 | emit restructuredBars(); // this notifies barchartitem |
|
632 | emit restructuredBars(); // this notifies barchartitem | |
632 | if (m_dataset) { |
|
633 | if (m_dataset) { | |
633 | m_dataset->updateSeries(q); // this notifies legend |
|
634 | m_dataset->updateSeries(q); // this notifies legend | |
634 | } |
|
635 | } | |
635 | return true; |
|
636 | return true; | |
636 | } |
|
637 | } | |
637 |
|
638 | |||
638 | bool QBarSeriesPrivate::remove(QBarSet *set) |
|
639 | bool QBarSeriesPrivate::remove(QBarSet *set) | |
639 | { |
|
640 | { | |
640 | Q_Q(QBarSeries); |
|
641 | Q_Q(QBarSeries); | |
641 | if (!m_barSets.contains(set)) { |
|
642 | if (!m_barSets.contains(set)) { | |
642 | // Fail if set is not in list |
|
643 | // Fail if set is not in list | |
643 | return false; |
|
644 | return false; | |
644 | } |
|
645 | } | |
645 | m_barSets.removeOne(set); |
|
646 | m_barSets.removeOne(set); | |
646 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
647 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); | |
647 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
648 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
648 | emit restructuredBars(); // this notifies barchartitem |
|
649 | emit restructuredBars(); // this notifies barchartitem | |
649 | if (m_dataset) { |
|
650 | if (m_dataset) { | |
650 | m_dataset->updateSeries(q); // this notifies legend |
|
651 | m_dataset->updateSeries(q); // this notifies legend | |
651 | } |
|
652 | } | |
652 | return true; |
|
653 | return true; | |
653 | } |
|
654 | } | |
654 |
|
655 | |||
655 | bool QBarSeriesPrivate::append(QList<QBarSet* > sets) |
|
656 | bool QBarSeriesPrivate::append(QList<QBarSet* > sets) | |
656 | { |
|
657 | { | |
657 | Q_Q(QBarSeries); |
|
658 | Q_Q(QBarSeries); | |
658 | foreach (QBarSet* set, sets) { |
|
659 | foreach (QBarSet* set, sets) { | |
659 | if ((set == 0) || (m_barSets.contains(set))) { |
|
660 | if ((set == 0) || (m_barSets.contains(set))) { | |
660 | // Fail if any of the sets is null or is already appended. |
|
661 | // Fail if any of the sets is null or is already appended. | |
661 | return false; |
|
662 | return false; | |
662 | } |
|
663 | } | |
663 | if (sets.count(set) != 1) { |
|
664 | if (sets.count(set) != 1) { | |
664 | // Also fail if same set is more than once in given list. |
|
665 | // Also fail if same set is more than once in given list. | |
665 | return false; |
|
666 | return false; | |
666 | } |
|
667 | } | |
667 | } |
|
668 | } | |
668 |
|
669 | |||
669 | foreach (QBarSet* set, sets) { |
|
670 | foreach (QBarSet* set, sets) { | |
670 | m_barSets.append(set); |
|
671 | m_barSets.append(set); | |
671 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
672 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); | |
672 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
673 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
673 | } |
|
674 | } | |
674 | emit restructuredBars(); // this notifies barchartitem |
|
675 | emit restructuredBars(); // this notifies barchartitem | |
675 | if (m_dataset) { |
|
676 | if (m_dataset) { | |
676 | m_dataset->updateSeries(q); // this notifies legend |
|
677 | m_dataset->updateSeries(q); // this notifies legend | |
677 | } |
|
678 | } | |
678 | return true; |
|
679 | return true; | |
679 | } |
|
680 | } | |
680 |
|
681 | |||
681 | bool QBarSeriesPrivate::remove(QList<QBarSet* > sets) |
|
682 | bool QBarSeriesPrivate::remove(QList<QBarSet* > sets) | |
682 | { |
|
683 | { | |
683 | Q_Q(QBarSeries); |
|
684 | Q_Q(QBarSeries); | |
684 | if (sets.count() == 0) { |
|
685 | if (sets.count() == 0) { | |
685 | return false; |
|
686 | return false; | |
686 | } |
|
687 | } | |
687 | foreach (QBarSet* set, sets) { |
|
688 | foreach (QBarSet* set, sets) { | |
688 | if ((set == 0) || (!m_barSets.contains(set))) { |
|
689 | if ((set == 0) || (!m_barSets.contains(set))) { | |
689 | // Fail if any of the sets is null or is not in series |
|
690 | // Fail if any of the sets is null or is not in series | |
690 | return false; |
|
691 | return false; | |
691 | } |
|
692 | } | |
692 | if (sets.count(set) != 1) { |
|
693 | if (sets.count(set) != 1) { | |
693 | // Also fail if same set is more than once in given list. |
|
694 | // Also fail if same set is more than once in given list. | |
694 | return false; |
|
695 | return false; | |
695 | } |
|
696 | } | |
696 | } |
|
697 | } | |
697 |
|
698 | |||
698 | foreach (QBarSet* set, sets) { |
|
699 | foreach (QBarSet* set, sets) { | |
699 | m_barSets.removeOne(set); |
|
700 | m_barSets.removeOne(set); | |
700 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
701 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); | |
701 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
702 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
702 | } |
|
703 | } | |
703 |
|
704 | |||
704 | emit restructuredBars(); // this notifies barchartitem |
|
705 | emit restructuredBars(); // this notifies barchartitem | |
705 | if (m_dataset) { |
|
706 | if (m_dataset) { | |
706 | m_dataset->updateSeries(q); // this notifies legend |
|
707 | m_dataset->updateSeries(q); // this notifies legend | |
707 | } |
|
708 | } | |
708 | return true; |
|
709 | return true; | |
709 | } |
|
710 | } | |
710 |
|
711 | |||
711 | bool QBarSeriesPrivate::insert(int index, QBarSet *set) |
|
712 | bool QBarSeriesPrivate::insert(int index, QBarSet *set) | |
712 | { |
|
713 | { | |
713 | Q_Q(QBarSeries); |
|
714 | Q_Q(QBarSeries); | |
714 | if ((m_barSets.contains(set)) || (set == 0)) { |
|
715 | if ((m_barSets.contains(set)) || (set == 0)) { | |
715 | // Fail if set is already in list or set is null. |
|
716 | // Fail if set is already in list or set is null. | |
716 | return false; |
|
717 | return false; | |
717 | } |
|
718 | } | |
718 | m_barSets.insert(index, set); |
|
719 | m_barSets.insert(index, set); | |
719 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
720 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); | |
720 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
721 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
721 | emit restructuredBars(); // this notifies barchartitem |
|
722 | emit restructuredBars(); // this notifies barchartitem | |
722 | if (m_dataset) { |
|
723 | if (m_dataset) { | |
723 | m_dataset->updateSeries(q); // this notifies legend |
|
724 | m_dataset->updateSeries(q); // this notifies legend | |
724 | } |
|
725 | } | |
725 | return true; |
|
726 | return true; | |
726 | } |
|
727 | } | |
727 |
|
728 | |||
728 | #include "moc_qbarseries.cpp" |
|
729 | #include "moc_qbarseries.cpp" | |
729 | #include "moc_qbarseries_p.cpp" |
|
730 | #include "moc_qbarseries_p.cpp" | |
730 |
|
731 | |||
731 | QTCOMMERCIALCHART_END_NAMESPACE |
|
732 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now