##// END OF EJS Templates
pieslice: update docs
Jani Honkonen -
r1277:06179f33651d
parent child
Show More
@@ -1,498 +1,533
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 "qpieslice.h"
21 #include "qpieslice.h"
22 #include "qpieslice_p.h"
22 #include "qpieslice_p.h"
23
23
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25
25
26 /*!
26 /*!
27 \class QPieSlice
27 \class QPieSlice
28 \brief Defines a slice in pie series.
28 \brief Defines a slice in pie series.
29
29
30 This object defines the properties of a single slice in a QPieSeries.
30 This object defines the properties of a single slice in a QPieSeries.
31
31
32 In addition to the obvious value and label properties the user can also control
32 In addition to the obvious value and label properties the user can also control
33 the visual appearance of a slice. By modifying the visual appearance also means that
33 the visual appearance of a slice. By modifying the visual appearance also means that
34 the user is overriding the default appearance set by the theme. Even if the theme is
34 the user is overriding the default appearance set by the theme.
35 changed users settings will persist.
36
35
37 To enable user interaction customization with the slices some basic signals
36 Note that if the user has customized slices and theme is changed all customizations will be lost.
38 are provided about clicking and hovering.
37
38 To enable user interaction with the pie some basic signals are provided about clicking and hovering.
39 */
39 */
40
40
41 /*!
41 /*!
42 \property QPieSlice::label
42 \property QPieSlice::label
43
43
44 Label of the slice.
44 Label of the slice.
45
46 \sa labelVisible, labelPen, labelFont, labelArmLengthFactor
47 */
48
49 /*!
50 \fn void QPieSlice::labelChanged()
51
52 This signal emitted when the slice label has been changed.
53
54 \sa label
45 */
55 */
46
56
47 /*!
57 /*!
48 \property QPieSlice::value
58 \property QPieSlice::value
49
59
50 Value of the slice.
60 Value of the slice.
51
61
52 \sa percentage(), QPieSeries::sum()
62 \sa percentage(), QPieSeries::sum()
53 */
63 */
54
64
55 /*!
65 /*!
56 Constructs an empty slice with a \a parent.
66 \fn void QPieSlice::valueChanged()
57
67
58 \sa QPieSeries::append(), QPieSeries::insert()
68 This signal is emitted when the slice value changes.
59 */
60 QPieSlice::QPieSlice(QObject *parent)
61 :QObject(parent),
62 d_ptr(new QPieSlicePrivate(this))
63 {
64
69
65 }
70 \sa value
71 */
66
72
67 /*!
73 /*!
68 Constructs an empty slice with given \a value, \a label and a \a parent.
74 \property QPieSlice::labelVisible
69 \sa QPieSeries::append(), QPieSeries::insert()
75
76 Defienes the visibility of the slice label.
77
78 Default is not visible.
79
80 \sa label, labelPen, labelFont, labelArmLengthFactor
70 */
81 */
71 QPieSlice::QPieSlice(QString label, qreal value, QObject *parent)
72 :QObject(parent),
73 d_ptr(new QPieSlicePrivate(this))
74 {
75 d_ptr->m_data.m_value = value;
76 d_ptr->m_data.m_labelText = label;
77 }
78
82
79 /*!
83 /*!
80 Destroys the slice.
84 \fn void QPieSlice::labelVisibleChanged()
81 User should not delete the slice if it has been added to the series.
82 */
83 QPieSlice::~QPieSlice()
84 {
85
85
86 }
86 This signal emitted when visibility of the slice label has changed.
87
87
88 /*!
88 \sa labelVisible
89 Gets the value of the slice.
90 Note that all values in the series
91 \sa setValue()
92 */
89 */
93 qreal QPieSlice::value() const
94 {
95 return d_ptr->m_data.m_value;
96 }
97
90
98 /*!
91 /*!
99 Gets the label of the slice.
92 \property QPieSlice::exploded
100 \sa setLabel()
93
94 Defines if the slice is exploded from the pie.
95
96 \sa explodeDistanceFactor
101 */
97 */
102 QString QPieSlice::label() const
103 {
104 return d_ptr->m_data.m_labelText;
105 }
106
98
107 /*!
99 /*!
108 Returns true if label is set as visible.
100 \fn void QPieSlice::explodedChanged()
109 \sa setLabelVisible()
101
102 This signal is emitted the the slice has been exploded from the pie or is returned back to the pie.
103
104 \sa exploded
110 */
105 */
111 bool QPieSlice::isLabelVisible() const
112 {
113 return d_ptr->m_data.m_isLabelVisible;
114 }
115
106
116 /*!
107 /*!
117 Returns true if slice is exloded from the pie.
108 \property QPieSlice::pen
118 \sa setExploded(), explodeDistanceFactor(), setExplodeDistanceFactor()
109
110 Pen used to draw the slice border.
119 */
111 */
120 bool QPieSlice::isExploded() const
121 {
122 return d_ptr->m_data.m_isExploded;
123 }
124
112
125 /*!
113 /*!
126 Returns the explode distance factor.
114 \fn void QPieSlice::penChanged()
127
115
128 The factor is relative to pie radius. For example:
116 This signal is emitted when the pen of the slice has changed.
129 1.0 means the distance is the same as the radius.
117
130 0.5 means the distance is half of the radius.
118 \sa pen
119 */
131
120
132 Default value is 0.15.
121 /*!
122 \property QPieSlice::brush
133
123
134 \sa setExplodeDistanceFactor(), isExploded(), setExploded()
124 Brush used to draw the slice.
135 */
125 */
136 qreal QPieSlice::explodeDistanceFactor() const
137 {
138 return d_ptr->m_data.m_explodeDistanceFactor;
139 }
140
126
141 /*!
127 /*!
142 Returns the percentage of this slice compared to the sum of all slices in the same series.
128 \fn void QPieSlice::brushChanged()
143 The returned value ranges from 0 to 1.0.
144
129
145 Updated internally after the slice is added to the series.
130 This signal is emitted when the brush of the slice has changed.
146
131
147 \sa QPieSeries::sum()
132 \sa brush
148 */
133 */
149 qreal QPieSlice::percentage() const
150 {
151 return d_ptr->m_data.m_percentage;
152 }
153
134
154 /*!
135 /*!
155 Returns the starting angle of this slice in the series it belongs to.
136 \property QPieSlice::labelPen
156
137
157 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
138 Pen used to draw label and label arm of the slice.
158
139
159 Updated internally after the slice is added to the series.
140 \sa label, labelVisible, labelFont, labelArmLengthFactor
160 */
141 */
161 qreal QPieSlice::startAngle() const
162 {
163 return d_ptr->m_data.m_startAngle;
164 }
165
142
166 /*!
143 /*!
167 Returns the end angle of this slice in the series it belongs to.
144 \fn void QPieSlice::labelPenChanged()
168
145
169 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
146 This signal is emitted when the label pen of the slice has changed.
170
147
171 Updated internally after the slice is added to the series.
148 \sa labelPen
172 */
149 */
173 qreal QPieSlice::angleSpan() const
174 {
175 return d_ptr->m_data.m_angleSpan;
176 }
177
150
178 /*!
151 /*!
179 Returns the pen used to draw this slice.
152 \property QPieSlice::labelFont
180 \sa setPen()
153
154 Font used for drawing label text.
155
156 \sa label, labelVisible, labelArmLengthFactor
181 */
157 */
182 QPen QPieSlice::pen() const
183 {
184 return d_ptr->m_data.m_slicePen;
185 }
186
158
187 /*!
159 /*!
188 Returns the brush used to draw this slice.
160 \fn void QPieSlice::labelFontChanged()
189 \sa setBrush()
161
162 This signal is emitted when the label font of the slice has changed.
163
164 \sa labelFont
190 */
165 */
191 QBrush QPieSlice::brush() const
192 {
193 return d_ptr->m_data.m_sliceBrush;
194 }
195
166
196 /*!
167 /*!
197 Returns the pen used to draw the label in this slice.
168 \property QPieSlice::labelArmLengthFactor
198 \sa setLabelPen()
169
170 Defines the length of the label arm.
171
172 The factor is relative to pie radius. For example:
173 1.0 means the length is the same as the radius.
174 0.5 means the length is half of the radius.
175
176 Default value is 0.15
177
178 \sa label, labelVisible, labelPen, labelFont
199 */
179 */
200 QPen QPieSlice::labelPen() const
201 {
202 return d_ptr->m_data.m_labelPen;
203 }
204
180
205 /*!
181 /*!
206 Returns the font used to draw label in this slice.
182 \fn void QPieSlice::labelArmLengthFactorChanged()
207 \sa setLabelFont()
183
184 This signal is emitted when the label arm factor of the slice has changed.
185
186 \sa labelArmLengthFactor
208 */
187 */
209 QFont QPieSlice::labelFont() const
210 {
211 return d_ptr->m_data.m_labelFont;
212 }
213
188
214 /*!
189 /*!
215 Gets the label arm length factor.
190 \property QPieSlice::explodeDistanceFactor
191
192 When the slice is exploded this factor defines how far the slice is exploded away from the pie.
216
193
217 The factor is relative to pie radius. For example:
194 The factor is relative to pie radius. For example:
218 1.0 means the length is the same as the radius.
195 1.0 means the distance is the same as the radius.
219 0.5 means the length is half of the radius.
196 0.5 means the distance is half of the radius.
220
197
221 Default value is 0.15
198 Default value is 0.15
222
199
223 \sa setLabelArmLengthFactor()
200 \sa exploded
224 */
201 */
225 qreal QPieSlice::labelArmLengthFactor() const
226 {
227 return d_ptr->m_data.m_labelArmLengthFactor;
228 }
229
202
230 /*!
203 /*!
231 \fn void QPieSlice::labelChanged()
204 \fn void QPieSlice::explodeDistanceFactorChanged()
232
205
233 This signal is emitted when the slice label changes.
206 This signal is emitted when the explode distance factor of the slice has changed.
234
207
235 \sa setLabel()
208 \sa explodeDistanceFactor
236 */
209 */
237
210
238 /*!
211 /*!
239 \fn void QPieSlice::valueChanged()
212 \property QPieSlice::percentage
240
213
241 This signal is emitted when the slice value changes.
214 Percentage of the slice compared to the sum of all slices in the series.
215
216 The actual value ranges from 0.0 to 1.0.
217
218 Updated automatically once the slice is added to the series.
219
220 \sa value, QPieSeries::sum
221 */
222
223 /*!
224 \fn void QPieSlice::percentageChanged()
225
226 This signal is emitted when the percentage of the slice has changed.
227
228 \sa percentage
229 */
230
231 /*!
232 \property QPieSlice::startAngle
233
234 Defines the starting angle of this slice in the series it belongs to.
242
235
243 \sa setValue()
236 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
237
238 Updated automatically once the slice is added to the series.
244 */
239 */
245
240
246 /*!
241 /*!
247 \fn void QPieSlice::appearanceChanged()
242 \fn void QPieSlice::startAngleChanged()
243
244 This signal is emitted when the starting angle f the slice has changed.
245
246 \sa startAngle
247 */
248
248
249 This signal is emitted when visual appearance of the slice changes.
249 /*!
250 \property QPieSlice::angleSpan
251
252 Span of the slice in degrees.
253
254 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
250
255
251 \sa setPen(), setBrush(), setLabelVisible(), setExploded()
256 Updated automatically once the slice is added to the series.
252 */
257 */
253
258
254 /*!
259 /*!
255 \fn void QPieSlice::calculatedDataChanged()
260 \fn void QPieSlice::angleSpanChanged()
256
261
257 This signal is emitted when calculated data for this slice changes.
262 This signal is emitted when the angle span of the slice has changed.
258
263
259 \sa percentage(), startAngle(), endAngle()
264 \sa angleSpan
260 */
265 */
261
266
267
262 /*!
268 /*!
263 \fn void QPieSlice::clicked()
269 \fn void QPieSlice::clicked()
264
270
265 This signal is emitted when user has clicked the slice.
271 This signal is emitted when user has clicked the slice.
266
272
267 \sa QPieSeries::clicked()
273 \sa QPieSeries::clicked()
268 */
274 */
269
275
270 /*!
276 /*!
271 \fn void QPieSlice::hovered(bool state)
277 \fn void QPieSlice::hovered(bool state)
272
278
273 This signal is emitted when user has hovered over or away from the slice.
279 This signal is emitted when user has hovered over or away from the slice.
274
280
275 \a state is true when user has hovered over the slice and false when hover has moved away from the slice.
281 \a state is true when user has hovered over the slice and false when hover has moved away from the slice.
276
282
277 \sa QPieSeries::hovered()
283 \sa QPieSeries::hovered()
278 */
284 */
279
285
280 /*!
286 /*!
281 Sets the \a value of this slice.
287 Constructs an empty slice with a \a parent.
282 \sa value()
288
289 \sa QPieSeries::append(), QPieSeries::insert()
283 */
290 */
284 void QPieSlice::setValue(qreal value)
291 QPieSlice::QPieSlice(QObject *parent)
292 :QObject(parent),
293 d_ptr(new QPieSlicePrivate(this))
285 {
294 {
286 if (!qFuzzyIsNull(d_ptr->m_data.m_value - value)) {
295
287 d_ptr->m_data.m_value = value;
288 emit valueChanged();
289 }
290 }
296 }
291
297
292 /*!
298 /*!
293 Sets the \a label of the slice.
299 Constructs an empty slice with given \a value, \a label and a \a parent.
294 \sa label()
300 \sa QPieSeries::append(), QPieSeries::insert()
295 */
301 */
302 QPieSlice::QPieSlice(QString label, qreal value, QObject *parent)
303 :QObject(parent),
304 d_ptr(new QPieSlicePrivate(this))
305 {
306 d_ptr->m_data.m_value = value;
307 d_ptr->m_data.m_labelText = label;
308 }
309
310 /*!
311 Destroys the slice.
312 User should not delete the slice if it has been added to the series.
313 */
314 QPieSlice::~QPieSlice()
315 {
316
317 }
318
296 void QPieSlice::setLabel(QString label)
319 void QPieSlice::setLabel(QString label)
297 {
320 {
298 if (d_ptr->m_data.m_labelText != label) {
321 if (d_ptr->m_data.m_labelText != label) {
299 d_ptr->m_data.m_labelText = label;
322 d_ptr->m_data.m_labelText = label;
300 emit labelChanged();
323 emit labelChanged();
301 }
324 }
302 }
325 }
303
326
304 /*!
327 QString QPieSlice::label() const
305 Sets the label \a visible in this slice.
328 {
306 \sa isLabelVisible(), QPieSeries::setLabelsVisible()
329 return d_ptr->m_data.m_labelText;
307 */
330 }
331
332 void QPieSlice::setValue(qreal value)
333 {
334 if (!qFuzzyIsNull(d_ptr->m_data.m_value - value)) {
335 d_ptr->m_data.m_value = value;
336 emit valueChanged();
337 }
338 }
339
340 qreal QPieSlice::value() const
341 {
342 return d_ptr->m_data.m_value;
343 }
344
308 void QPieSlice::setLabelVisible(bool visible)
345 void QPieSlice::setLabelVisible(bool visible)
309 {
346 {
310 if (d_ptr->m_data.m_isLabelVisible != visible) {
347 if (d_ptr->m_data.m_isLabelVisible != visible) {
311 d_ptr->m_data.m_isLabelVisible = visible;
348 d_ptr->m_data.m_isLabelVisible = visible;
312 emit labelVisibleChanged();
349 emit labelVisibleChanged();
313 }
350 }
314 }
351 }
315
352
316 /*!
353 bool QPieSlice::isLabelVisible() const
317 Sets this slices \a exploded state.
354 {
318
355 return d_ptr->m_data.m_isLabelVisible;
319 If the slice is exploded it is moved away from the pie center. The distance is defined by the explode distance factor.
356 }
320
357
321 \sa isExploded(), explodeDistanceFactor(), setExplodeDistanceFactor()
322 */
323 void QPieSlice::setExploded(bool exploded)
358 void QPieSlice::setExploded(bool exploded)
324 {
359 {
325 if (d_ptr->m_data.m_isExploded != exploded) {
360 if (d_ptr->m_data.m_isExploded != exploded) {
326 d_ptr->m_data.m_isExploded = exploded;
361 d_ptr->m_data.m_isExploded = exploded;
327 emit explodedChanged();
362 emit explodedChanged();
328 }
363 }
329 }
364 }
330
365
331 /*!
366 bool QPieSlice::isExploded() const
332 Sets the explode distance \a factor.
333
334 The factor is relative to pie radius. For example:
335 1.0 means the distance is the same as the radius.
336 0.5 means the distance is half of the radius.
337
338 Default value is 0.15
339
340 \sa explodeDistanceFactor(), isExploded(), setExploded()
341 */
342 void QPieSlice::setExplodeDistanceFactor(qreal factor)
343 {
367 {
344 if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) {
368 return d_ptr->m_data.m_isExploded;
345 d_ptr->m_data.m_explodeDistanceFactor = factor;
346 emit explodeDistanceFactorChanged();
347 }
348 }
369 }
349
370
350 /*!
351 Sets the \a pen used to draw this slice.
352
353 Overrides the pen set by the theme.
354
355 \sa pen()
356 */
357 void QPieSlice::setPen(const QPen &pen)
371 void QPieSlice::setPen(const QPen &pen)
358 {
372 {
359 d_ptr->setPen(pen, false);
373 d_ptr->setPen(pen, false);
360 }
374 }
361
375
362 /*!
376 QPen QPieSlice::pen() const
363 Sets the \a brush used to draw this slice.
377 {
364
378 return d_ptr->m_data.m_slicePen;
365 Overrides the brush set by the theme.
379 }
366
380
367 \sa brush()
368 */
369 void QPieSlice::setBrush(const QBrush &brush)
381 void QPieSlice::setBrush(const QBrush &brush)
370 {
382 {
371 d_ptr->setBrush(brush, false);
383 d_ptr->setBrush(brush, false);
372 }
384 }
373
385
374 /*!
386 QBrush QPieSlice::brush() const
375 Sets the \a pen used to draw the label in this slice.
387 {
376
388 return d_ptr->m_data.m_sliceBrush;
377 Overrides the pen set by the theme.
389 }
378
390
379 \sa labelPen()
380 */
381 void QPieSlice::setLabelPen(const QPen &pen)
391 void QPieSlice::setLabelPen(const QPen &pen)
382 {
392 {
383 d_ptr->setLabelPen(pen, false);
393 d_ptr->setLabelPen(pen, false);
384 }
394 }
385
395
386 /*!
396 QPen QPieSlice::labelPen() const
387 Sets the \a font used to draw the label in this slice.
397 {
388
398 return d_ptr->m_data.m_labelPen;
389 Overrides the font set by the theme.
399 }
390
400
391 \sa labelFont()
392 */
393 void QPieSlice::setLabelFont(const QFont &font)
401 void QPieSlice::setLabelFont(const QFont &font)
394 {
402 {
395 d_ptr->setLabelFont(font, false);
403 d_ptr->setLabelFont(font, false);
396 }
404 }
397
405
398 /*!
406 QFont QPieSlice::labelFont() const
399 Sets the label arm length \a factor.
407 {
400
408 return d_ptr->m_data.m_labelFont;
401 The factor is relative to pie radius. For example:
409 }
402 1.0 means the length is the same as the radius.
403 0.5 means the length is half of the radius.
404
405 Default value is 0.15
406
410
407 \sa labelArmLengthFactor()
408 */
409 void QPieSlice::setLabelArmLengthFactor(qreal factor)
411 void QPieSlice::setLabelArmLengthFactor(qreal factor)
410 {
412 {
411 if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) {
413 if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) {
412 d_ptr->m_data.m_labelArmLengthFactor = factor;
414 d_ptr->m_data.m_labelArmLengthFactor = factor;
413 emit labelArmLengthFactorChanged();
415 emit labelArmLengthFactorChanged();
414 }
416 }
415 }
417 }
416
418
419 qreal QPieSlice::labelArmLengthFactor() const
420 {
421 return d_ptr->m_data.m_labelArmLengthFactor;
422 }
423
424 void QPieSlice::setExplodeDistanceFactor(qreal factor)
425 {
426 if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) {
427 d_ptr->m_data.m_explodeDistanceFactor = factor;
428 emit explodeDistanceFactorChanged();
429 }
430 }
431
432 qreal QPieSlice::explodeDistanceFactor() const
433 {
434 return d_ptr->m_data.m_explodeDistanceFactor;
435 }
436
437 qreal QPieSlice::percentage() const
438 {
439 return d_ptr->m_data.m_percentage;
440 }
441
442 qreal QPieSlice::startAngle() const
443 {
444 return d_ptr->m_data.m_startAngle;
445 }
446
447 qreal QPieSlice::angleSpan() const
448 {
449 return d_ptr->m_data.m_angleSpan;
450 }
451
417 QPieSlicePrivate::QPieSlicePrivate(QPieSlice *parent)
452 QPieSlicePrivate::QPieSlicePrivate(QPieSlice *parent)
418 :QObject(parent),
453 :QObject(parent),
419 q_ptr(parent)
454 q_ptr(parent)
420 {
455 {
421
456
422 }
457 }
423
458
424 QPieSlicePrivate::~QPieSlicePrivate()
459 QPieSlicePrivate::~QPieSlicePrivate()
425 {
460 {
426
461
427 }
462 }
428
463
429 QPieSlicePrivate *QPieSlicePrivate::fromSlice(QPieSlice *slice)
464 QPieSlicePrivate *QPieSlicePrivate::fromSlice(QPieSlice *slice)
430 {
465 {
431 return slice->d_func();
466 return slice->d_func();
432 }
467 }
433
468
434 void QPieSlicePrivate::setPen(const QPen &pen, bool themed)
469 void QPieSlicePrivate::setPen(const QPen &pen, bool themed)
435 {
470 {
436 if (m_data.m_slicePen != pen) {
471 if (m_data.m_slicePen != pen) {
437 m_data.m_slicePen = pen;
472 m_data.m_slicePen = pen;
438 m_data.m_slicePen.setThemed(themed);
473 m_data.m_slicePen.setThemed(themed);
439 emit q_ptr->penChanged();
474 emit q_ptr->penChanged();
440 }
475 }
441 }
476 }
442
477
443 void QPieSlicePrivate::setBrush(const QBrush &brush, bool themed)
478 void QPieSlicePrivate::setBrush(const QBrush &brush, bool themed)
444 {
479 {
445 if (m_data.m_sliceBrush != brush) {
480 if (m_data.m_sliceBrush != brush) {
446 m_data.m_sliceBrush = brush;
481 m_data.m_sliceBrush = brush;
447 m_data.m_sliceBrush.setThemed(themed);
482 m_data.m_sliceBrush.setThemed(themed);
448 emit q_ptr->brushChanged();
483 emit q_ptr->brushChanged();
449 }
484 }
450 }
485 }
451
486
452 void QPieSlicePrivate::setLabelPen(const QPen &pen, bool themed)
487 void QPieSlicePrivate::setLabelPen(const QPen &pen, bool themed)
453 {
488 {
454 if (m_data.m_labelPen != pen) {
489 if (m_data.m_labelPen != pen) {
455 m_data.m_labelPen = pen;
490 m_data.m_labelPen = pen;
456 m_data.m_labelPen.setThemed(themed);
491 m_data.m_labelPen.setThemed(themed);
457 emit q_ptr->labelPenChanged();
492 emit q_ptr->labelPenChanged();
458 }
493 }
459 }
494 }
460
495
461 void QPieSlicePrivate::setLabelFont(const QFont &font, bool themed)
496 void QPieSlicePrivate::setLabelFont(const QFont &font, bool themed)
462 {
497 {
463 if (m_data.m_labelFont != font) {
498 if (m_data.m_labelFont != font) {
464 m_data.m_labelFont = font;
499 m_data.m_labelFont = font;
465 m_data.m_labelFont.setThemed(themed);
500 m_data.m_labelFont.setThemed(themed);
466 emit q_ptr->labelFontChanged();
501 emit q_ptr->labelFontChanged();
467 }
502 }
468 }
503 }
469
504
470 void QPieSlicePrivate::setPercentage(qreal percentage)
505 void QPieSlicePrivate::setPercentage(qreal percentage)
471 {
506 {
472 if (!qFuzzyIsNull(m_data.m_percentage - percentage)) {
507 if (!qFuzzyIsNull(m_data.m_percentage - percentage)) {
473 m_data.m_percentage = percentage;
508 m_data.m_percentage = percentage;
474 emit q_ptr->percentageChanged();
509 emit q_ptr->percentageChanged();
475 }
510 }
476 }
511 }
477
512
478 void QPieSlicePrivate::setStartAngle(qreal angle)
513 void QPieSlicePrivate::setStartAngle(qreal angle)
479 {
514 {
480 if (!qFuzzyIsNull(m_data.m_startAngle - angle)) {
515 if (!qFuzzyIsNull(m_data.m_startAngle - angle)) {
481 m_data.m_startAngle = angle;
516 m_data.m_startAngle = angle;
482 emit q_ptr->startAngleChanged();
517 emit q_ptr->startAngleChanged();
483 }
518 }
484 }
519 }
485
520
486 void QPieSlicePrivate::setAngleSpan(qreal span)
521 void QPieSlicePrivate::setAngleSpan(qreal span)
487 {
522 {
488 if (!qFuzzyIsNull(m_data.m_angleSpan - span)) {
523 if (!qFuzzyIsNull(m_data.m_angleSpan - span)) {
489 m_data.m_angleSpan = span;
524 m_data.m_angleSpan = span;
490 emit q_ptr->angleSpanChanged();
525 emit q_ptr->angleSpanChanged();
491 }
526 }
492 }
527 }
493
528
494 QTCOMMERCIALCHART_END_NAMESPACE
529 QTCOMMERCIALCHART_END_NAMESPACE
495
530
496 QTCOMMERCIALCHART_USE_NAMESPACE
531 QTCOMMERCIALCHART_USE_NAMESPACE
497 #include "moc_qpieslice.cpp"
532 #include "moc_qpieslice.cpp"
498 #include "moc_qpieslice_p.cpp"
533 #include "moc_qpieslice_p.cpp"
@@ -1,114 +1,114
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 QPIESLICE_H
21 #ifndef QPIESLICE_H
22 #define QPIESLICE_H
22 #define QPIESLICE_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <QObject>
25 #include <QObject>
26 #include <QPen>
26 #include <QPen>
27 #include <QBrush>
27 #include <QBrush>
28 #include <QFont>
28 #include <QFont>
29
29
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 class QPieSlicePrivate;
31 class QPieSlicePrivate;
32
32
33 class QTCOMMERCIALCHART_EXPORT QPieSlice : public QObject
33 class QTCOMMERCIALCHART_EXPORT QPieSlice : public QObject
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
36 Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
37 Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
37 Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
38 Q_PROPERTY(bool labelVisible READ isLabelVisible WRITE setLabelVisible NOTIFY labelVisibleChanged)
38 Q_PROPERTY(bool labelVisible READ isLabelVisible WRITE setLabelVisible NOTIFY labelVisibleChanged)
39 Q_PROPERTY(bool exploded READ isExploded WRITE setExploded NOTIFY explodedChanged)
39 Q_PROPERTY(bool exploded READ isExploded WRITE setExploded NOTIFY explodedChanged)
40 Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
40 Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
41 Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
41 Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
42 Q_PROPERTY(QPen labelPen READ labelPen WRITE setLabelPen NOTIFY labelPenChanged)
42 Q_PROPERTY(QPen labelPen READ labelPen WRITE setLabelPen NOTIFY labelPenChanged)
43 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged)
43 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged)
44 Q_PROPERTY(qreal LabelArmLengthFactor READ labelArmLengthFactor WRITE setLabelArmLengthFactor)
44 Q_PROPERTY(qreal labelArmLengthFactor READ labelArmLengthFactor WRITE setLabelArmLengthFactor)
45 Q_PROPERTY(qreal explodeDistanceFactor READ explodeDistanceFactor WRITE setExplodeDistanceFactor)
45 Q_PROPERTY(qreal explodeDistanceFactor READ explodeDistanceFactor WRITE setExplodeDistanceFactor)
46 Q_PROPERTY(qreal percentage READ percentage NOTIFY percentageChanged)
46 Q_PROPERTY(qreal percentage READ percentage NOTIFY percentageChanged)
47 Q_PROPERTY(qreal startAngle READ startAngle NOTIFY startAngleChanged)
47 Q_PROPERTY(qreal startAngle READ startAngle NOTIFY startAngleChanged)
48 Q_PROPERTY(qreal angleSpan READ angleSpan NOTIFY angleSpanChanged)
48 Q_PROPERTY(qreal angleSpan READ angleSpan NOTIFY angleSpanChanged)
49
49
50 public:
50 public:
51 explicit QPieSlice(QObject *parent = 0);
51 explicit QPieSlice(QObject *parent = 0);
52 QPieSlice(QString label, qreal value, QObject *parent = 0);
52 QPieSlice(QString label, qreal value, QObject *parent = 0);
53 virtual ~QPieSlice();
53 virtual ~QPieSlice();
54
54
55 void setLabel(QString label);
55 void setLabel(QString label);
56 QString label() const;
56 QString label() const;
57
57
58 void setValue(qreal value);
58 void setValue(qreal value);
59 qreal value() const;
59 qreal value() const;
60
60
61 void setLabelVisible(bool visible = true);
61 void setLabelVisible(bool visible = true);
62 bool isLabelVisible() const;
62 bool isLabelVisible() const;
63
63
64 void setExploded(bool exploded = true);
64 void setExploded(bool exploded = true);
65 bool isExploded() const;
65 bool isExploded() const;
66
66
67 void setPen(const QPen &pen);
67 void setPen(const QPen &pen);
68 QPen pen() const;
68 QPen pen() const;
69
69
70 void setBrush(const QBrush &brush);
70 void setBrush(const QBrush &brush);
71 QBrush brush() const;
71 QBrush brush() const;
72
72
73 void setLabelPen(const QPen &pen);
73 void setLabelPen(const QPen &pen);
74 QPen labelPen() const;
74 QPen labelPen() const;
75
75
76 void setLabelFont(const QFont &font);
76 void setLabelFont(const QFont &font);
77 QFont labelFont() const;
77 QFont labelFont() const;
78
78
79 void setLabelArmLengthFactor(qreal factor);
79 void setLabelArmLengthFactor(qreal factor);
80 qreal labelArmLengthFactor() const;
80 qreal labelArmLengthFactor() const;
81
81
82 void setExplodeDistanceFactor(qreal factor);
82 void setExplodeDistanceFactor(qreal factor);
83 qreal explodeDistanceFactor() const;
83 qreal explodeDistanceFactor() const;
84
84
85 qreal percentage() const;
85 qreal percentage() const;
86 qreal startAngle() const;
86 qreal startAngle() const;
87 qreal angleSpan() const;
87 qreal angleSpan() const;
88
88
89 Q_SIGNALS:
89 Q_SIGNALS:
90 void labelChanged();
90 void labelChanged();
91 void valueChanged();
91 void valueChanged();
92 void labelVisibleChanged();
92 void labelVisibleChanged();
93 void explodedChanged();
93 void explodedChanged();
94 void penChanged();
94 void penChanged();
95 void brushChanged();
95 void brushChanged();
96 void labelPenChanged();
96 void labelPenChanged();
97 void labelFontChanged();
97 void labelFontChanged();
98 void labelArmLengthFactorChanged();
98 void labelArmLengthFactorChanged();
99 void explodeDistanceFactorChanged();
99 void explodeDistanceFactorChanged();
100 void percentageChanged();
100 void percentageChanged();
101 void startAngleChanged();
101 void startAngleChanged();
102 void angleSpanChanged();
102 void angleSpanChanged();
103 void clicked();
103 void clicked();
104 void hovered(bool state);
104 void hovered(bool state);
105
105
106 private:
106 private:
107 QPieSlicePrivate * const d_ptr;
107 QPieSlicePrivate * const d_ptr;
108 Q_DECLARE_PRIVATE(QPieSlice)
108 Q_DECLARE_PRIVATE(QPieSlice)
109 Q_DISABLE_COPY(QPieSlice)
109 Q_DISABLE_COPY(QPieSlice)
110 };
110 };
111
111
112 QTCOMMERCIALCHART_END_NAMESPACE
112 QTCOMMERCIALCHART_END_NAMESPACE
113
113
114 #endif // QPIESLICE_H
114 #endif // QPIESLICE_H
General Comments 0
You need to be logged in to leave comments. Login now