##// END OF EJS Templates
minor. doc fix for pieslice
Michal Klocek -
r361:1c0ad6bac5cd
parent child
Show More
@@ -1,375 +1,375
1 #include "qpieslice.h"
1 #include "qpieslice.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 #define DEFAULT_PEN_COLOR Qt::black
5 #define DEFAULT_PEN_COLOR Qt::black
6 #define DEFAULT_BRUSH_COLOR Qt::white
6 #define DEFAULT_BRUSH_COLOR Qt::white
7 #define DEFAULT_LABEL_ARM_LENGTH 40
7 #define DEFAULT_LABEL_ARM_LENGTH 40
8 #define DEFAULT_EXPOLODE_DISTANCE 20
8 #define DEFAULT_EXPOLODE_DISTANCE 20
9
9
10 /*!
10 /*!
11 \class QPieSlice
11 \class QPieSlice
12 \brief Defines a slice in pie series.
12 \brief Defines a slice in pie series.
13
13
14 Holds all the data of a single slice in a QPieSeries and provides the means
14 Holds all the data of a single slice in a QPieSeries and provides the means
15 to modify slice data and customize the visual appearance of the slice.
15 to modify slice data and customize the visual appearance of the slice.
16
16
17 It also provides the means to customize user interaction with the slice by
17 It also provides the means to customize user interaction with the slice by
18 providing signals for clicking and hover events.
18 providing signals for clicking and hover events.
19 */
19 */
20
20
21 /*!
21 /*!
22 \property QPieSlice::label
22 \property QPieSlice::label
23
23
24 Label of the slice.
24 Label of the slice.
25 */
25 */
26
26
27 /*!
27 /*!
28 \property QPieSlice::value
28 \property QPieSlice::value
29
29
30 Value of the slice.
30 Value of the slice.
31 */
31 */
32
32
33 /*!
33 /*!
34 Constructs an empty slice with a \a parent.
34 Constructs an empty slice with a \a parent.
35
35
36 Note that QPieSeries takes ownership of the slice when it is set/added.
36 Note that QPieSeries takes ownership of the slice when it is set/added.
37
37
38 \sa QPieSeries::set(), QPieSeries::add()
38 \sa QPieSeries::replace(), QPieSeries::add()
39 */
39 */
40 QPieSlice::QPieSlice(QObject *parent)
40 QPieSlice::QPieSlice(QObject *parent)
41 :QObject(parent),
41 :QObject(parent),
42 m_value(0),
42 m_value(0),
43 m_isLabelVisible(false),
43 m_isLabelVisible(false),
44 m_isExploded(false),
44 m_isExploded(false),
45 m_explodeDistance(DEFAULT_EXPOLODE_DISTANCE),
45 m_explodeDistance(DEFAULT_EXPOLODE_DISTANCE),
46 m_percentage(0),
46 m_percentage(0),
47 m_startAngle(0),
47 m_startAngle(0),
48 m_angleSpan(0),
48 m_angleSpan(0),
49 m_pen(DEFAULT_PEN_COLOR),
49 m_pen(DEFAULT_PEN_COLOR),
50 m_brush(DEFAULT_BRUSH_COLOR),
50 m_brush(DEFAULT_BRUSH_COLOR),
51 m_labelPen(DEFAULT_PEN_COLOR),
51 m_labelPen(DEFAULT_PEN_COLOR),
52 m_labelArmLength(DEFAULT_LABEL_ARM_LENGTH)
52 m_labelArmLength(DEFAULT_LABEL_ARM_LENGTH)
53 {
53 {
54
54
55 }
55 }
56
56
57 /*!
57 /*!
58 Constructs an empty slice with given \a value, \a label and a \a parent.
58 Constructs an empty slice with given \a value, \a label and a \a parent.
59 Note that QPieSeries takes ownership of the slice when it is set/added.
59 Note that QPieSeries takes ownership of the slice when it is set/added.
60 \sa QPieSeries::set(), QPieSeries::add()
60 \sa QPieSeries::replace(), QPieSeries::add()
61 */
61 */
62 QPieSlice::QPieSlice(qreal value, QString label, QObject *parent)
62 QPieSlice::QPieSlice(qreal value, QString label, QObject *parent)
63 :QObject(parent),
63 :QObject(parent),
64 m_value(value),
64 m_value(value),
65 m_label(label),
65 m_label(label),
66 m_isLabelVisible(false),
66 m_isLabelVisible(false),
67 m_isExploded(false),
67 m_isExploded(false),
68 m_explodeDistance(DEFAULT_EXPOLODE_DISTANCE),
68 m_explodeDistance(DEFAULT_EXPOLODE_DISTANCE),
69 m_percentage(0),
69 m_percentage(0),
70 m_startAngle(0),
70 m_startAngle(0),
71 m_angleSpan(0),
71 m_angleSpan(0),
72 m_pen(DEFAULT_PEN_COLOR),
72 m_pen(DEFAULT_PEN_COLOR),
73 m_brush(DEFAULT_BRUSH_COLOR),
73 m_brush(DEFAULT_BRUSH_COLOR),
74 m_labelPen(DEFAULT_PEN_COLOR),
74 m_labelPen(DEFAULT_PEN_COLOR),
75 m_labelArmLength(DEFAULT_LABEL_ARM_LENGTH)
75 m_labelArmLength(DEFAULT_LABEL_ARM_LENGTH)
76 {
76 {
77
77
78 }
78 }
79
79
80 /*!
80 /*!
81 Destroys the slice.
81 Destroys the slice.
82 User should not delete the slice if it has been added to the series.
82 User should not delete the slice if it has been added to the series.
83 */
83 */
84 QPieSlice::~QPieSlice()
84 QPieSlice::~QPieSlice()
85 {
85 {
86
86
87 }
87 }
88
88
89 /*!
89 /*!
90 Gets the value of the slice.
90 Gets the value of the slice.
91 Note that all values in the series
91 Note that all values in the series
92 \sa setValue()
92 \sa setValue()
93 */
93 */
94 qreal QPieSlice::value() const
94 qreal QPieSlice::value() const
95 {
95 {
96 return m_value;
96 return m_value;
97 }
97 }
98
98
99 /*!
99 /*!
100 Gets the label of the slice.
100 Gets the label of the slice.
101 \sa setLabel()
101 \sa setLabel()
102 */
102 */
103 QString QPieSlice::label() const
103 QString QPieSlice::label() const
104 {
104 {
105 return m_label;
105 return m_label;
106 }
106 }
107
107
108 /*!
108 /*!
109 Returns true if label is set as visible.
109 Returns true if label is set as visible.
110 \sa setLabelVisible()
110 \sa setLabelVisible()
111 */
111 */
112 bool QPieSlice::isLabelVisible() const
112 bool QPieSlice::isLabelVisible() const
113 {
113 {
114 return m_isLabelVisible;
114 return m_isLabelVisible;
115 }
115 }
116
116
117 /*!
117 /*!
118 Returns true if slice is exloded from the pie.
118 Returns true if slice is exloded from the pie.
119 \sa setExploded()
119 \sa setExploded()
120 */
120 */
121 bool QPieSlice::isExploded() const
121 bool QPieSlice::isExploded() const
122 {
122 {
123 return m_isExploded;
123 return m_isExploded;
124 }
124 }
125
125
126 /*!
126 /*!
127 Returns the explosion distance of the slice.
127 Returns the explosion distance of the slice.
128 Default value is 20.
128 Default value is 20.
129 \sa setExplodeDistance()
129 \sa setExplodeDistance()
130 */
130 */
131 qreal QPieSlice::explodeDistance() const
131 qreal QPieSlice::explodeDistance() const
132 {
132 {
133 return m_explodeDistance;
133 return m_explodeDistance;
134 }
134 }
135
135
136 /*!
136 /*!
137 Returns the percentage of this slice compared to all slices in the same series.
137 Returns the percentage of this slice compared to all slices in the same series.
138
138
139 Updated internally after the slice is added to the series.
139 Updated internally after the slice is added to the series.
140 */
140 */
141 qreal QPieSlice::percentage() const
141 qreal QPieSlice::percentage() const
142 {
142 {
143 return m_percentage;
143 return m_percentage;
144 }
144 }
145
145
146 /*!
146 /*!
147 Returns the starting angle of this slice in the series it belongs to.
147 Returns the starting angle of this slice in the series it belongs to.
148
148
149 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
149 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
150
150
151 Updated internally after the slice is added to the series.
151 Updated internally after the slice is added to the series.
152 */
152 */
153 qreal QPieSlice::startAngle() const
153 qreal QPieSlice::startAngle() const
154 {
154 {
155 return m_startAngle;
155 return m_startAngle;
156 }
156 }
157
157
158 /*!
158 /*!
159 Returns the end angle of this slice in the series it belongs to.
159 Returns the end angle of this slice in the series it belongs to.
160
160
161 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
161 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
162
162
163 Updated internally after the slice is added to the series.
163 Updated internally after the slice is added to the series.
164 */
164 */
165 qreal QPieSlice::endAngle() const
165 qreal QPieSlice::endAngle() const
166 {
166 {
167 return m_startAngle + m_angleSpan;
167 return m_startAngle + m_angleSpan;
168 }
168 }
169
169
170 /*!
170 /*!
171 Returns the pen used to draw this slice.
171 Returns the pen used to draw this slice.
172 \sa setPen()
172 \sa setPen()
173 */
173 */
174 QPen QPieSlice::pen() const
174 QPen QPieSlice::pen() const
175 {
175 {
176 return m_pen;
176 return m_pen;
177 }
177 }
178
178
179 /*!
179 /*!
180 Returns the brush used to draw this slice.
180 Returns the brush used to draw this slice.
181 \sa setBrush()
181 \sa setBrush()
182 */
182 */
183 QBrush QPieSlice::brush() const
183 QBrush QPieSlice::brush() const
184 {
184 {
185 return m_brush;
185 return m_brush;
186 }
186 }
187
187
188 /*!
188 /*!
189 Returns the pen used to draw label in this slice.
189 Returns the pen used to draw label in this slice.
190 \sa setLabelPen()
190 \sa setLabelPen()
191 */
191 */
192 QPen QPieSlice::labelPen() const
192 QPen QPieSlice::labelPen() const
193 {
193 {
194 return m_labelPen;
194 return m_labelPen;
195 }
195 }
196
196
197 /*!
197 /*!
198 Returns the font used to draw label in this slice.
198 Returns the font used to draw label in this slice.
199 \sa setLabelFont()
199 \sa setLabelFont()
200 */
200 */
201 QFont QPieSlice::labelFont() const
201 QFont QPieSlice::labelFont() const
202 {
202 {
203 return m_labelFont;
203 return m_labelFont;
204 }
204 }
205
205
206 /*!
206 /*!
207 Returns the label arm lenght used in this slice.
207 Returns the label arm lenght used in this slice.
208 Default value is 40 pixels.
208 Default value is 40 pixels.
209 \sa setLabelArmLength()
209 \sa setLabelArmLength()
210 */
210 */
211 qreal QPieSlice::labelArmLength() const
211 qreal QPieSlice::labelArmLength() const
212 {
212 {
213 return m_labelArmLength;
213 return m_labelArmLength;
214 }
214 }
215
215
216 /*!
216 /*!
217 \fn void QPieSlice::clicked()
217 \fn void QPieSlice::clicked()
218
218
219 This signal is emitted when user has clicked the slice.
219 This signal is emitted when user has clicked the slice.
220
220
221 \sa QPieSeries::clicked()
221 \sa QPieSeries::clicked()
222 */
222 */
223
223
224 /*!
224 /*!
225 \fn void QPieSlice::hoverEnter()
225 \fn void QPieSlice::hoverEnter()
226
226
227 This signal is emitted when user has hovered over the slice.
227 This signal is emitted when user has hovered over the slice.
228
228
229 \sa QPieSeries::hoverEnter()
229 \sa QPieSeries::hoverEnter()
230 */
230 */
231
231
232 /*!
232 /*!
233 \fn void QPieSlice::hoverLeave()
233 \fn void QPieSlice::hoverLeave()
234
234
235 This signal is emitted when user has hovered away from the slice.
235 This signal is emitted when user has hovered away from the slice.
236
236
237 \sa QPieSeries::hoverLeave()
237 \sa QPieSeries::hoverLeave()
238 */
238 */
239
239
240 /*!
240 /*!
241 \fn void QPieSlice::changed()
241 \fn void QPieSlice::changed()
242
242
243 This signal emitted when something has changed in the slice.
243 This signal emitted when something has changed in the slice.
244
244
245 \sa QPieSeries::changed()
245 \sa QPieSeries::changed()
246 */
246 */
247
247
248 /*!
248 /*!
249 Sets the value of this slice.
249 Sets the value of this slice.
250 \sa value()
250 \sa value()
251 */
251 */
252 void QPieSlice::setValue(qreal value)
252 void QPieSlice::setValue(qreal value)
253 {
253 {
254 if (m_value != value) {
254 if (m_value != value) {
255 m_value = value;
255 m_value = value;
256 emit changed();
256 emit changed();
257 }
257 }
258 }
258 }
259
259
260 /*!
260 /*!
261 Sets the \a label of the slice.
261 Sets the \a label of the slice.
262 \sa label()
262 \sa label()
263 */
263 */
264 void QPieSlice::setLabel(QString label)
264 void QPieSlice::setLabel(QString label)
265 {
265 {
266 if (m_label != label) {
266 if (m_label != label) {
267 m_label = label;
267 m_label = label;
268 emit changed();
268 emit changed();
269 }
269 }
270 }
270 }
271
271
272 /*!
272 /*!
273 Sets the label \a visible in this slice.
273 Sets the label \a visible in this slice.
274 \sa isLabelVisible(), QPieSeries::setLabelsVisible()
274 \sa isLabelVisible(), QPieSeries::setLabelsVisible()
275 */
275 */
276 void QPieSlice::setLabelVisible(bool visible)
276 void QPieSlice::setLabelVisible(bool visible)
277 {
277 {
278 if (m_isLabelVisible != visible) {
278 if (m_isLabelVisible != visible) {
279 m_isLabelVisible = visible;
279 m_isLabelVisible = visible;
280 emit changed();
280 emit changed();
281 }
281 }
282 }
282 }
283
283
284 /*!
284 /*!
285 Sets this slice \a exploded.
285 Sets this slice \a exploded.
286 \sa isExploded(), setExplodeDistance(), QPieSeries::enableClickExplodes()
286 \sa isExploded(), setExplodeDistance(), QPieSeries::enableClickExplodes()
287 */
287 */
288 void QPieSlice::setExploded(bool exploded)
288 void QPieSlice::setExploded(bool exploded)
289 {
289 {
290 if (m_isExploded != exploded) {
290 if (m_isExploded != exploded) {
291 m_isExploded = exploded;
291 m_isExploded = exploded;
292 emit changed();
292 emit changed();
293 }
293 }
294 }
294 }
295
295
296 /*!
296 /*!
297 Sets the explosion \a distance of this slice.
297 Sets the explosion \a distance of this slice.
298 It is the distance the slice is moved away from the pie center.
298 It is the distance the slice is moved away from the pie center.
299 \sa explodeDistance(), isExploded(), QPieSeries::enableClickExplodes()
299 \sa explodeDistance(), isExploded(), QPieSeries::enableClickExplodes()
300 */
300 */
301 void QPieSlice::setExplodeDistance(qreal distance)
301 void QPieSlice::setExplodeDistance(qreal distance)
302 {
302 {
303 if (m_explodeDistance != distance) {
303 if (m_explodeDistance != distance) {
304 m_explodeDistance = distance;
304 m_explodeDistance = distance;
305 emit changed();
305 emit changed();
306 }
306 }
307 }
307 }
308
308
309 /*!
309 /*!
310 Sets the \a pen used to draw this slice.
310 Sets the \a pen used to draw this slice.
311 Note that applying a theme will override this.
311 Note that applying a theme will override this.
312 \sa pen()
312 \sa pen()
313 */
313 */
314 void QPieSlice::setPen(QPen pen)
314 void QPieSlice::setPen(QPen pen)
315 {
315 {
316 if (m_pen != pen) {
316 if (m_pen != pen) {
317 m_pen = pen;
317 m_pen = pen;
318 emit changed();
318 emit changed();
319 }
319 }
320 }
320 }
321
321
322 /*!
322 /*!
323 Sets the \a brush used to draw this slice.
323 Sets the \a brush used to draw this slice.
324 Note that applying a theme will override this.
324 Note that applying a theme will override this.
325 \sa brush()
325 \sa brush()
326 */
326 */
327 void QPieSlice::setBrush(QBrush brush)
327 void QPieSlice::setBrush(QBrush brush)
328 {
328 {
329 if (m_brush != brush) {
329 if (m_brush != brush) {
330 m_brush = brush;
330 m_brush = brush;
331 emit changed();
331 emit changed();
332 }
332 }
333 }
333 }
334
334
335 /*!
335 /*!
336 Sets the \a pen used to draw the label in this slice.
336 Sets the \a pen used to draw the label in this slice.
337 Note that applying a theme will override this.
337 Note that applying a theme will override this.
338 \sa labelPen()
338 \sa labelPen()
339 */
339 */
340 void QPieSlice::setLabelPen(QPen pen)
340 void QPieSlice::setLabelPen(QPen pen)
341 {
341 {
342 if (m_labelPen != pen) {
342 if (m_labelPen != pen) {
343 m_labelPen = pen;
343 m_labelPen = pen;
344 emit changed();
344 emit changed();
345 }
345 }
346 }
346 }
347
347
348 /*!
348 /*!
349 Sets the \a font used to draw the label in this slice.
349 Sets the \a font used to draw the label in this slice.
350 Note that applying a theme will override this.
350 Note that applying a theme will override this.
351 \sa labelFont()
351 \sa labelFont()
352 */
352 */
353 void QPieSlice::setLabelFont(QFont font)
353 void QPieSlice::setLabelFont(QFont font)
354 {
354 {
355 if (m_labelFont != font) {
355 if (m_labelFont != font) {
356 m_labelFont = font;
356 m_labelFont = font;
357 emit changed();
357 emit changed();
358 }
358 }
359 }
359 }
360
360
361 /*!
361 /*!
362 Sets the label arm \a length used to draw the label in this slice.
362 Sets the label arm \a length used to draw the label in this slice.
363 \sa labelArmLength()
363 \sa labelArmLength()
364 */
364 */
365 void QPieSlice::setLabelArmLength(qreal length)
365 void QPieSlice::setLabelArmLength(qreal length)
366 {
366 {
367 if (m_labelArmLength != length) {
367 if (m_labelArmLength != length) {
368 m_labelArmLength = length;
368 m_labelArmLength = length;
369 emit changed();
369 emit changed();
370 }
370 }
371 }
371 }
372
372
373 #include "moc_qpieslice.cpp"
373 #include "moc_qpieslice.cpp"
374
374
375 QTCOMMERCIALCHART_END_NAMESPACE
375 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now