##// END OF EJS Templates
Fixed compilation issue on Qt 4.7
Tero Ahola -
r837:84a11356179b
parent child
Show More
@@ -1,401 +1,402
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 "pieslicedata_p.h"
22 #include "pieslicedata_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 Holds all the data of a single slice in a QPieSeries and provides the means
30 Holds all the data of a single slice in a QPieSeries and provides the means
31 to modify slice data and customize the visual appearance of the slice.
31 to modify slice data and customize the visual appearance of the slice.
32
32
33 It also provides the means to customize user interaction with the slice by
33 It also provides the means to customize user interaction with the slice by
34 providing signals for clicking and hover events.
34 providing signals for clicking and hover events.
35 */
35 */
36
36
37 /*!
37 /*!
38 \property QPieSlice::label
38 \property QPieSlice::label
39
39
40 Label of the slice.
40 Label of the slice.
41 */
41 */
42
42
43 /*!
43 /*!
44 \property QPieSlice::value
44 \property QPieSlice::value
45
45
46 Value of the slice.
46 Value of the slice.
47 */
47 */
48
48
49 /*!
49 /*!
50 Constructs an empty slice with a \a parent.
50 Constructs an empty slice with a \a parent.
51
51
52 Note that QPieSeries takes ownership of the slice when it is set/added.
52 Note that QPieSeries takes ownership of the slice when it is set/added.
53
53
54 \sa QPieSeries::replace(), QPieSeries::append()
54 \sa QPieSeries::replace(), QPieSeries::append()
55 */
55 */
56 QPieSlice::QPieSlice(QObject *parent)
56 QPieSlice::QPieSlice(QObject *parent)
57 :QObject(parent),
57 :QObject(parent),
58 d(new PieSliceData())
58 d(new PieSliceData())
59 {
59 {
60
60
61 }
61 }
62
62
63 /*!
63 /*!
64 Constructs an empty slice with given \a value, \a label and a \a parent.
64 Constructs an empty slice with given \a value, \a label and a \a parent.
65 Note that QPieSeries takes ownership of the slice when it is set/added.
65 Note that QPieSeries takes ownership of the slice when it is set/added.
66 \sa QPieSeries::replace(), QPieSeries::append()
66 \sa QPieSeries::replace(), QPieSeries::append()
67 */
67 */
68 QPieSlice::QPieSlice(qreal value, QString label, QObject *parent)
68 QPieSlice::QPieSlice(qreal value, QString label, QObject *parent)
69 :QObject(parent),
69 :QObject(parent),
70 d(new PieSliceData())
70 d(new PieSliceData())
71 {
71 {
72 d->m_value = value;
72 d->m_value = value;
73 d->m_labelText = label;
73 d->m_labelText = label;
74 }
74 }
75
75
76 /*!
76 /*!
77 Destroys the slice.
77 Destroys the slice.
78 User should not delete the slice if it has been added to the series.
78 User should not delete the slice if it has been added to the series.
79 */
79 */
80 QPieSlice::~QPieSlice()
80 QPieSlice::~QPieSlice()
81 {
81 {
82 delete d;
82 delete d;
83 }
83 }
84
84
85 /*!
85 /*!
86 Gets the value of the slice.
86 Gets the value of the slice.
87 Note that all values in the series
87 Note that all values in the series
88 \sa setValue()
88 \sa setValue()
89 */
89 */
90 qreal QPieSlice::value() const
90 qreal QPieSlice::value() const
91 {
91 {
92 return d->m_value;
92 return d->m_value;
93 }
93 }
94
94
95 /*!
95 /*!
96 Gets the label of the slice.
96 Gets the label of the slice.
97 \sa setLabel()
97 \sa setLabel()
98 */
98 */
99 QString QPieSlice::label() const
99 QString QPieSlice::label() const
100 {
100 {
101 return d->m_labelText;
101 return d->m_labelText;
102 }
102 }
103
103
104 /*!
104 /*!
105 Returns true if label is set as visible.
105 Returns true if label is set as visible.
106 \sa setLabelVisible()
106 \sa setLabelVisible()
107 */
107 */
108 bool QPieSlice::isLabelVisible() const
108 bool QPieSlice::isLabelVisible() const
109 {
109 {
110 return d->m_isLabelVisible;
110 return d->m_isLabelVisible;
111 }
111 }
112
112
113 /*!
113 /*!
114 Returns true if slice is exloded from the pie.
114 Returns true if slice is exloded from the pie.
115 \sa setExploded(), setExplodeDistanceFactor()
115 \sa setExploded(), setExplodeDistanceFactor()
116 */
116 */
117 bool QPieSlice::isExploded() const
117 bool QPieSlice::isExploded() const
118 {
118 {
119 return d->m_isExploded;
119 return d->m_isExploded;
120 }
120 }
121
121
122 /*!
122 /*!
123 Returns the explode distance factor.
123 Returns the explode distance factor.
124
124
125 The factor is relative to pie radius. For example:
125 The factor is relative to pie radius. For example:
126 1.0 means the distance is the same as the radius.
126 1.0 means the distance is the same as the radius.
127 0.5 means the distance is half of the radius.
127 0.5 means the distance is half of the radius.
128
128
129 Default value is 0.15.
129 Default value is 0.15.
130
130
131 \sa setExplodeDistanceFactor()
131 \sa setExplodeDistanceFactor()
132 */
132 */
133 qreal QPieSlice::explodeDistanceFactor() const
133 qreal QPieSlice::explodeDistanceFactor() const
134 {
134 {
135 return d->m_explodeDistanceFactor;
135 return d->m_explodeDistanceFactor;
136 }
136 }
137
137
138 /*!
138 /*!
139 Returns the percentage of this slice compared to all slices in the same series.
139 Returns the percentage of this slice compared to all slices in the same series.
140 The returned value ranges from 0 to 1.0.
140 The returned value ranges from 0 to 1.0.
141
141
142 Updated internally after the slice is added to the series.
142 Updated internally after the slice is added to the series.
143 */
143 */
144 qreal QPieSlice::percentage() const
144 qreal QPieSlice::percentage() const
145 {
145 {
146 return d->m_percentage;
146 return d->m_percentage;
147 }
147 }
148
148
149 /*!
149 /*!
150 Returns the starting angle of this slice in the series it belongs to.
150 Returns the starting angle of this slice in the series it belongs to.
151
151
152 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
152 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
153
153
154 Updated internally after the slice is added to the series.
154 Updated internally after the slice is added to the series.
155 */
155 */
156 qreal QPieSlice::startAngle() const
156 qreal QPieSlice::startAngle() const
157 {
157 {
158 return d->m_startAngle;
158 return d->m_startAngle;
159 }
159 }
160
160
161 /*!
161 /*!
162 Returns the end angle of this slice in the series it belongs to.
162 Returns the end angle of this slice in the series it belongs to.
163
163
164 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
164 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
165
165
166 Updated internally after the slice is added to the series.
166 Updated internally after the slice is added to the series.
167 */
167 */
168 qreal QPieSlice::endAngle() const
168 qreal QPieSlice::endAngle() const
169 {
169 {
170 return d->m_startAngle + d->m_angleSpan;
170 return d->m_startAngle + d->m_angleSpan;
171 }
171 }
172
172
173 /*!
173 /*!
174 Returns the pen used to draw this slice.
174 Returns the pen used to draw this slice.
175 \sa setPen()
175 \sa setPen()
176 */
176 */
177 QPen QPieSlice::pen() const
177 QPen QPieSlice::pen() const
178 {
178 {
179 return d->m_slicePen;
179 return d->m_slicePen;
180 }
180 }
181
181
182 /*!
182 /*!
183 Returns the brush used to draw this slice.
183 Returns the brush used to draw this slice.
184 \sa setBrush()
184 \sa setBrush()
185 */
185 */
186 QBrush QPieSlice::brush() const
186 QBrush QPieSlice::brush() const
187 {
187 {
188 return d->m_sliceBrush;
188 return d->m_sliceBrush;
189 }
189 }
190
190
191 /*!
191 /*!
192 Returns the pen used to draw the label in this slice.
192 Returns the pen used to draw the label in this slice.
193 \sa setLabelPen()
193 \sa setLabelPen()
194 */
194 */
195 QPen QPieSlice::labelPen() const
195 QPen QPieSlice::labelPen() const
196 {
196 {
197 return d->m_labelPen;
197 return d->m_labelPen;
198 }
198 }
199
199
200 /*!
200 /*!
201 Returns the font used to draw label in this slice.
201 Returns the font used to draw label in this slice.
202 \sa setLabelFont()
202 \sa setLabelFont()
203 */
203 */
204 QFont QPieSlice::labelFont() const
204 QFont QPieSlice::labelFont() const
205 {
205 {
206 return d->m_labelFont;
206 return d->m_labelFont;
207 }
207 }
208
208
209 /*!
209 /*!
210 Gets the label arm length factor.
210 Gets the label arm length factor.
211
211
212 The factor is relative to pie radius. For example:
212 The factor is relative to pie radius. For example:
213 1.0 means the length is the same as the radius.
213 1.0 means the length is the same as the radius.
214 0.5 means the length is half of the radius.
214 0.5 means the length is half of the radius.
215
215
216 Default value is 0.15
216 Default value is 0.15
217
217
218 \sa setLabelArmLengthFactor()
218 \sa setLabelArmLengthFactor()
219 */
219 */
220 qreal QPieSlice::labelArmLengthFactor() const
220 qreal QPieSlice::labelArmLengthFactor() const
221 {
221 {
222 return d->m_labelArmLengthFactor;
222 return d->m_labelArmLengthFactor;
223 }
223 }
224
224
225 /*!
225 /*!
226 \fn void QPieSlice::clicked(Qt::MouseButtons buttons)
226 \fn void QPieSlice::clicked(Qt::MouseButtons buttons)
227
227
228 This signal is emitted when user has clicked the slice.
228 This signal is emitted when user has clicked the slice.
229
229
230 \sa QPieSeries::clicked()
230 \sa QPieSeries::clicked()
231 */
231 */
232
232
233 /*!
233 /*!
234 \fn void QPieSlice::hoverEnter()
234 \fn void QPieSlice::hoverEnter()
235
235
236 This signal is emitted when user has hovered over the slice.
236 This signal is emitted when user has hovered over the slice.
237
237
238 \sa QPieSeries::hoverEnter()
238 \sa QPieSeries::hoverEnter()
239 */
239 */
240
240
241 /*!
241 /*!
242 \fn void QPieSlice::hoverLeave()
242 \fn void QPieSlice::hoverLeave()
243
243
244 This signal is emitted when user has hovered away from the slice.
244 This signal is emitted when user has hovered away from the slice.
245
245
246 \sa QPieSeries::hoverLeave()
246 \sa QPieSeries::hoverLeave()
247 */
247 */
248
248
249 /*!
249 /*!
250 \fn void QPieSlice::changed()
250 \fn void QPieSlice::changed()
251
251
252 This signal emitted when something has changed in the slice.
252 This signal emitted when something has changed in the slice.
253
253
254 \sa QPieSeries::changed()
254 \sa QPieSeries::changed()
255 */
255 */
256
256
257 /*!
257 /*!
258 Sets the \a value of this slice.
258 Sets the \a value of this slice.
259 \sa value()
259 \sa value()
260 */
260 */
261 void QPieSlice::setValue(qreal value)
261 void QPieSlice::setValue(qreal value)
262 {
262 {
263 if (!qFuzzyIsNull(d->m_value - value)) {
263 if (!qFuzzyIsNull(d->m_value - value)) {
264 d->m_value = value;
264 d->m_value = value;
265 emit changed();
265 emit changed();
266 }
266 }
267 }
267 }
268
268
269 /*!
269 /*!
270 Sets the \a label of the slice.
270 Sets the \a label of the slice.
271 \sa label()
271 \sa label()
272 */
272 */
273 void QPieSlice::setLabel(QString label)
273 void QPieSlice::setLabel(QString label)
274 {
274 {
275 if (d->m_labelText != label) {
275 if (d->m_labelText != label) {
276 d->m_labelText = label;
276 d->m_labelText = label;
277 emit changed();
277 emit changed();
278 }
278 }
279 }
279 }
280
280
281 /*!
281 /*!
282 Sets the label \a visible in this slice.
282 Sets the label \a visible in this slice.
283 \sa isLabelVisible(), QPieSeries::setLabelsVisible()
283 \sa isLabelVisible(), QPieSeries::setLabelsVisible()
284 */
284 */
285 void QPieSlice::setLabelVisible(bool visible)
285 void QPieSlice::setLabelVisible(bool visible)
286 {
286 {
287 if (d->m_isLabelVisible != visible) {
287 if (d->m_isLabelVisible != visible) {
288 d->m_isLabelVisible = visible;
288 d->m_isLabelVisible = visible;
289 emit changed();
289 emit changed();
290 }
290 }
291 }
291 }
292
292
293 /*!
293 /*!
294 Sets this slice \a exploded.
294 Sets this slice \a exploded.
295 \sa isExploded(), explodeDistanceFactor()
295 \sa isExploded(), explodeDistanceFactor()
296 */
296 */
297 void QPieSlice::setExploded(bool exploded)
297 void QPieSlice::setExploded(bool exploded)
298 {
298 {
299 if (d->m_isExploded != exploded) {
299 if (d->m_isExploded != exploded) {
300 d->m_isExploded = exploded;
300 d->m_isExploded = exploded;
301 emit changed();
301 emit changed();
302 }
302 }
303 }
303 }
304
304
305 /*!
305 /*!
306 Sets the explode distance \a factor.
306 Sets the explode distance \a factor.
307
307
308 The factor is relative to pie radius. For example:
308 The factor is relative to pie radius. For example:
309 1.0 means the distance is the same as the radius.
309 1.0 means the distance is the same as the radius.
310 0.5 means the distance is half of the radius.
310 0.5 means the distance is half of the radius.
311
311
312 Default value is 0.15
312 Default value is 0.15
313
313
314 \sa explodeDistanceFactor()
314 \sa explodeDistanceFactor()
315 */
315 */
316 void QPieSlice::setExplodeDistanceFactor(qreal factor)
316 void QPieSlice::setExplodeDistanceFactor(qreal factor)
317 {
317 {
318 if (!qFuzzyIsNull(d->m_explodeDistanceFactor - factor)) {
318 if (!qFuzzyIsNull(d->m_explodeDistanceFactor - factor)) {
319 d->m_explodeDistanceFactor = factor;
319 d->m_explodeDistanceFactor = factor;
320 emit changed();
320 emit changed();
321 }
321 }
322 }
322 }
323
323
324 /*!
324 /*!
325 Sets the \a pen used to draw this slice.
325 Sets the \a pen used to draw this slice.
326 Note that applying a theme will override this.
326 Note that applying a theme will override this.
327 \sa pen()
327 \sa pen()
328 */
328 */
329 void QPieSlice::setPen(const QPen &pen)
329 void QPieSlice::setPen(const QPen &pen)
330 {
330 {
331 if (d->m_slicePen != pen) {
331 if (d->m_slicePen != pen) {
332 d->m_slicePen = pen;
332 d->m_slicePen = pen;
333 d->m_slicePen.setThemed(false);
333 d->m_slicePen.setThemed(false);
334 emit changed();
334 emit changed();
335 }
335 }
336 }
336 }
337
337
338 /*!
338 /*!
339 Sets the \a brush used to draw this slice.
339 Sets the \a brush used to draw this slice.
340 Note that applying a theme will override this.
340 Note that applying a theme will override this.
341 \sa brush()
341 \sa brush()
342 */
342 */
343 void QPieSlice::setBrush(const QBrush &brush)
343 void QPieSlice::setBrush(const QBrush &brush)
344 {
344 {
345 if (d->m_sliceBrush != brush) {
345 if (d->m_sliceBrush != brush) {
346 d->m_sliceBrush = brush;
346 d->m_sliceBrush = brush;
347 d->m_sliceBrush.setThemed(false);
347 d->m_sliceBrush.setThemed(false);
348 emit changed();
348 emit changed();
349 }
349 }
350 }
350 }
351
351
352 /*!
352 /*!
353 Sets the \a pen used to draw the label in this slice.
353 Sets the \a pen used to draw the label in this slice.
354 Note that applying a theme will override this.
354 Note that applying a theme will override this.
355 \sa labelPen()
355 \sa labelPen()
356 */
356 */
357 void QPieSlice::setLabelPen(const QPen &pen)
357 void QPieSlice::setLabelPen(const QPen &pen)
358 {
358 {
359 if (d->m_labelPen != pen) {
359 if (d->m_labelPen != pen) {
360 d->m_labelPen = pen;
360 d->m_labelPen = pen;
361 d->m_labelPen.setThemed(false);
361 d->m_labelPen.setThemed(false);
362 emit changed();
362 emit changed();
363 }
363 }
364 }
364 }
365
365
366 /*!
366 /*!
367 Sets the \a font used to draw the label in this slice.
367 Sets the \a font used to draw the label in this slice.
368 Note that applying a theme will override this.
368 Note that applying a theme will override this.
369 \sa labelFont()
369 \sa labelFont()
370 */
370 */
371 void QPieSlice::setLabelFont(const QFont &font)
371 void QPieSlice::setLabelFont(const QFont &font)
372 {
372 {
373 if (d->m_labelFont != font) {
373 if (d->m_labelFont != font) {
374 d->m_labelFont = font;
374 d->m_labelFont = font;
375 d->m_labelFont.setThemed(false);
375 d->m_labelFont.setThemed(false);
376 emit changed();
376 emit changed();
377 }
377 }
378 }
378 }
379
379
380 /*!
380 /*!
381 Sets the label arm length \a factor.
381 Sets the label arm length \a factor.
382
382
383 The factor is relative to pie radius. For example:
383 The factor is relative to pie radius. For example:
384 1.0 means the length is the same as the radius.
384 1.0 means the length is the same as the radius.
385 0.5 means the length is half of the radius.
385 0.5 means the length is half of the radius.
386
386
387 Default value is 0.15
387 Default value is 0.15
388
388
389 \sa labelArmLengthFactor()
389 \sa labelArmLengthFactor()
390 */
390 */
391 void QPieSlice::setLabelArmLengthFactor(qreal factor)
391 void QPieSlice::setLabelArmLengthFactor(qreal factor)
392 {
392 {
393 if (!qFuzzyIsNull(d->m_labelArmLengthFactor - factor)) {
393 if (!qFuzzyIsNull(d->m_labelArmLengthFactor - factor)) {
394 d->m_labelArmLengthFactor = factor;
394 d->m_labelArmLengthFactor = factor;
395 emit changed();
395 emit changed();
396 }
396 }
397 }
397 }
398
398
399 #include "moc_qpieslice.cpp"
400
401 QTCOMMERCIALCHART_END_NAMESPACE
399 QTCOMMERCIALCHART_END_NAMESPACE
400
401 QTCOMMERCIALCHART_USE_NAMESPACE
402 #include "moc_qpieslice.cpp"
General Comments 0
You need to be logged in to leave comments. Login now