@@ -29,15 +29,15 public Q_SLOTS: | |||||
29 |
|
29 | |||
30 | void handleHoverEnter() |
|
30 | void handleHoverEnter() | |
31 | { |
|
31 | { | |
32 |
QBrush brush = this-> |
|
32 | QBrush brush = this->sliceBrush(); | |
33 | m_originalBrush = brush; |
|
33 | m_originalBrush = brush; | |
34 | brush.setColor(brush.color().lighter()); |
|
34 | brush.setColor(brush.color().lighter()); | |
35 | setBrush(brush); |
|
35 | setSliceBrush(brush); | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | void handleHoverLeave() |
|
38 | void handleHoverLeave() | |
39 | { |
|
39 | { | |
40 | setBrush(m_originalBrush); |
|
40 | setSliceBrush(m_originalBrush); | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | private: |
|
43 | private: |
@@ -284,8 +284,8 void ChartTheme::decorate(PiePresenter* item, QPieSeries* series, int /*count*/) | |||||
284 | // finally update colors |
|
284 | // finally update colors | |
285 | foreach (QPieSlice* s, series->slices()) { |
|
285 | foreach (QPieSlice* s, series->slices()) { | |
286 | QColor c = colors.takeFirst(); |
|
286 | QColor c = colors.takeFirst(); | |
287 | s->setPen(c); |
|
287 | s->setSlicePen(c); | |
288 | s->setBrush(c); |
|
288 | s->setSliceBrush(c); | |
289 | } |
|
289 | } | |
290 | } |
|
290 | } | |
291 |
|
291 |
@@ -55,8 +55,8 void PieSlice::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option | |||||
55 | painter->setClipRect(parentItem()->boundingRect()); |
|
55 | painter->setClipRect(parentItem()->boundingRect()); | |
56 |
|
56 | |||
57 | painter->save(); |
|
57 | painter->save(); | |
58 |
painter->setPen(m_ |
|
58 | painter->setPen(m_slicePen); | |
59 |
painter->setBrush(m_ |
|
59 | painter->setBrush(m_sliceBrush); | |
60 | painter->drawPath(m_slicePath); |
|
60 | painter->drawPath(m_slicePath); | |
61 | painter->restore(); |
|
61 | painter->restore(); | |
62 |
|
62 | |||
@@ -125,14 +125,14 void PieSlice::updateData(const QPieSlice* sliceData) | |||||
125 | m_angleSpan = sliceData->m_angleSpan; |
|
125 | m_angleSpan = sliceData->m_angleSpan; | |
126 | m_isExploded = sliceData->isExploded(); |
|
126 | m_isExploded = sliceData->isExploded(); | |
127 | m_explodeDistanceFactor = sliceData->explodeDistanceFactor(); |
|
127 | m_explodeDistanceFactor = sliceData->explodeDistanceFactor(); | |
128 |
m_ |
|
128 | m_slicePen = sliceData->slicePen(); | |
129 |
m_ |
|
129 | m_sliceBrush = sliceData->sliceBrush(); | |
130 |
|
130 | |||
131 | m_labelVisible = sliceData->isLabelVisible(); |
|
131 | m_labelVisible = sliceData->isLabelVisible(); | |
132 | m_labelText = sliceData->label(); |
|
132 | m_labelText = sliceData->label(); | |
133 | m_labelFont = sliceData->labelFont(); |
|
133 | m_labelFont = sliceData->labelFont(); | |
134 | m_labelArmLengthFactor = sliceData->labelArmLengthFactor(); |
|
134 | m_labelArmLengthFactor = sliceData->labelArmLengthFactor(); | |
135 | m_labelArmPen = sliceData->labelPen(); |
|
135 | m_labelArmPen = sliceData->labelArmPen(); | |
136 |
|
136 | |||
137 | updateGeometry(); |
|
137 | updateGeometry(); | |
138 | update(); |
|
138 | update(); |
@@ -57,8 +57,8 private: | |||||
57 | bool m_isExploded; |
|
57 | bool m_isExploded; | |
58 | qreal m_explodeDistanceFactor; |
|
58 | qreal m_explodeDistanceFactor; | |
59 | bool m_labelVisible; |
|
59 | bool m_labelVisible; | |
60 |
QPen m_ |
|
60 | QPen m_slicePen; | |
61 |
QBrush m_ |
|
61 | QBrush m_sliceBrush; | |
62 |
|
62 | |||
63 | QPainterPath m_labelArmPath; |
|
63 | QPainterPath m_labelArmPath; | |
64 | qreal m_labelArmLengthFactor; |
|
64 | qreal m_labelArmLengthFactor; |
@@ -46,9 +46,9 QPieSlice::QPieSlice(QObject *parent) | |||||
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_ |
|
49 | m_slicePen(DEFAULT_PEN_COLOR), | |
50 |
m_ |
|
50 | m_sliceBrush(DEFAULT_BRUSH_COLOR), | |
51 | m_labelPen(DEFAULT_PEN_COLOR), |
|
51 | m_labelArmPen(DEFAULT_PEN_COLOR), | |
52 | m_labelArmLengthFactor(DEFAULT_LABEL_ARM_LENGTH_FACTOR) |
|
52 | m_labelArmLengthFactor(DEFAULT_LABEL_ARM_LENGTH_FACTOR) | |
53 | { |
|
53 | { | |
54 |
|
54 | |||
@@ -69,9 +69,9 QPieSlice::QPieSlice(qreal value, QString label, QObject *parent) | |||||
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_ |
|
72 | m_slicePen(DEFAULT_PEN_COLOR), | |
73 |
m_ |
|
73 | m_sliceBrush(DEFAULT_BRUSH_COLOR), | |
74 | m_labelPen(DEFAULT_PEN_COLOR), |
|
74 | m_labelArmPen(DEFAULT_PEN_COLOR), | |
75 | m_labelArmLengthFactor(DEFAULT_LABEL_ARM_LENGTH_FACTOR) |
|
75 | m_labelArmLengthFactor(DEFAULT_LABEL_ARM_LENGTH_FACTOR) | |
76 | { |
|
76 | { | |
77 |
|
77 | |||
@@ -176,29 +176,29 qreal QPieSlice::endAngle() const | |||||
176 |
|
176 | |||
177 | /*! |
|
177 | /*! | |
178 | Returns the pen used to draw this slice. |
|
178 | Returns the pen used to draw this slice. | |
179 | \sa setPen() |
|
179 | \sa setSlicePen() | |
180 | */ |
|
180 | */ | |
181 |
QPen QPieSlice:: |
|
181 | QPen QPieSlice::slicePen() const | |
182 | { |
|
182 | { | |
183 |
return m_ |
|
183 | return m_slicePen; | |
184 | } |
|
184 | } | |
185 |
|
185 | |||
186 | /*! |
|
186 | /*! | |
187 | Returns the brush used to draw this slice. |
|
187 | Returns the brush used to draw this slice. | |
188 | \sa setBrush() |
|
188 | \sa setSliceBrush() | |
189 | */ |
|
189 | */ | |
190 |
QBrush QPieSlice:: |
|
190 | QBrush QPieSlice::sliceBrush() const | |
191 | { |
|
191 | { | |
192 |
return m_ |
|
192 | return m_sliceBrush; | |
193 | } |
|
193 | } | |
194 |
|
194 | |||
195 | /*! |
|
195 | /*! | |
196 | Returns the pen used to draw label in this slice. |
|
196 | Returns the pen used to draw label arm in this slice. | |
197 | \sa setLabelPen() |
|
197 | \sa setLabelArmPen() | |
198 | */ |
|
198 | */ | |
199 | QPen QPieSlice::labelPen() const |
|
199 | QPen QPieSlice::labelArmPen() const | |
200 | { |
|
200 | { | |
201 | return m_labelPen; |
|
201 | return m_labelArmPen; | |
202 | } |
|
202 | } | |
203 |
|
203 | |||
204 | /*! |
|
204 | /*! | |
@@ -328,12 +328,12 void QPieSlice::setExplodeDistanceFactor(qreal factor) | |||||
328 | /*! |
|
328 | /*! | |
329 | Sets the \a pen used to draw this slice. |
|
329 | Sets the \a pen used to draw this slice. | |
330 | Note that applying a theme will override this. |
|
330 | Note that applying a theme will override this. | |
331 |
\sa |
|
331 | \sa slicePen() | |
332 | */ |
|
332 | */ | |
333 | void QPieSlice::setPen(QPen pen) |
|
333 | void QPieSlice::setSlicePen(const QPen &pen) | |
334 | { |
|
334 | { | |
335 |
if (m_ |
|
335 | if (m_slicePen != pen) { | |
336 |
m_ |
|
336 | m_slicePen = pen; | |
337 | emit changed(); |
|
337 | emit changed(); | |
338 | } |
|
338 | } | |
339 | } |
|
339 | } | |
@@ -341,25 +341,25 void QPieSlice::setPen(QPen pen) | |||||
341 | /*! |
|
341 | /*! | |
342 | Sets the \a brush used to draw this slice. |
|
342 | Sets the \a brush used to draw this slice. | |
343 | Note that applying a theme will override this. |
|
343 | Note that applying a theme will override this. | |
344 |
\sa |
|
344 | \sa sliceBrush() | |
345 | */ |
|
345 | */ | |
346 | void QPieSlice::setBrush(QBrush brush) |
|
346 | void QPieSlice::setSliceBrush(const QBrush &brush) | |
347 | { |
|
347 | { | |
348 |
if (m_ |
|
348 | if (m_sliceBrush != brush) { | |
349 |
m_ |
|
349 | m_sliceBrush = brush; | |
350 | emit changed(); |
|
350 | emit changed(); | |
351 | } |
|
351 | } | |
352 | } |
|
352 | } | |
353 |
|
353 | |||
354 | /*! |
|
354 | /*! | |
355 | Sets the \a pen used to draw the label in this slice. |
|
355 | Sets the \a pen used to draw the label arm in this slice. | |
356 | Note that applying a theme will override this. |
|
356 | Note that applying a theme will override this. | |
357 | \sa labelPen() |
|
357 | \sa labelArmPen() | |
358 | */ |
|
358 | */ | |
359 | void QPieSlice::setLabelPen(QPen pen) |
|
359 | void QPieSlice::setLabelArmPen(const QPen &pen) | |
360 | { |
|
360 | { | |
361 | if (m_labelPen != pen) { |
|
361 | if (m_labelArmPen != pen) { | |
362 | m_labelPen = pen; |
|
362 | m_labelArmPen = pen; | |
363 | emit changed(); |
|
363 | emit changed(); | |
364 | } |
|
364 | } | |
365 | } |
|
365 | } | |
@@ -369,7 +369,7 void QPieSlice::setLabelPen(QPen pen) | |||||
369 | Note that applying a theme will override this. |
|
369 | Note that applying a theme will override this. | |
370 | \sa labelFont() |
|
370 | \sa labelFont() | |
371 | */ |
|
371 | */ | |
372 | void QPieSlice::setLabelFont(QFont font) |
|
372 | void QPieSlice::setLabelFont(const QFont &font) | |
373 | { |
|
373 | { | |
374 | if (m_labelFont != font) { |
|
374 | if (m_labelFont != font) { | |
375 | m_labelFont = font; |
|
375 | m_labelFont = font; |
@@ -38,13 +38,13 public: | |||||
38 | qreal endAngle() const; |
|
38 | qreal endAngle() const; | |
39 |
|
39 | |||
40 | // customization |
|
40 | // customization | |
41 | void setPen(QPen pen); |
|
41 | void setSlicePen(const QPen &pen); | |
42 |
QPen |
|
42 | QPen slicePen() const; | |
43 | void setBrush(QBrush brush); |
|
43 | void setSliceBrush(const QBrush &brush); | |
44 |
QBrush |
|
44 | QBrush sliceBrush() const; | |
45 | void setLabelPen(QPen pen); |
|
45 | void setLabelArmPen(const QPen &pen); | |
46 | QPen labelPen() const; |
|
46 | QPen labelArmPen() const; | |
47 | void setLabelFont(QFont font); |
|
47 | void setLabelFont(const QFont &font); | |
48 | QFont labelFont() const; |
|
48 | QFont labelFont() const; | |
49 | void setLabelArmLengthFactor(qreal factor); |
|
49 | void setLabelArmLengthFactor(qreal factor); | |
50 | qreal labelArmLengthFactor() const; |
|
50 | qreal labelArmLengthFactor() const; | |
@@ -79,10 +79,10 private: | |||||
79 | qreal m_angleSpan; |
|
79 | qreal m_angleSpan; | |
80 |
|
80 | |||
81 | // customization |
|
81 | // customization | |
82 |
QPen m_ |
|
82 | QPen m_slicePen; | |
83 |
QBrush m_ |
|
83 | QBrush m_sliceBrush; | |
84 | QPen m_labelPen; |
|
|||
85 | QFont m_labelFont; |
|
84 | QFont m_labelFont; | |
|
85 | QPen m_labelArmPen; | |||
86 | qreal m_labelArmLengthFactor; |
|
86 | qreal m_labelArmLengthFactor; | |
87 | }; |
|
87 | }; | |
88 |
|
88 |
General Comments 0
You need to be logged in to leave comments.
Login now