diff --git a/example/piechartcustomization/main.cpp b/example/piechartcustomization/main.cpp index 58021c7..73baa81 100644 --- a/example/piechartcustomization/main.cpp +++ b/example/piechartcustomization/main.cpp @@ -29,15 +29,15 @@ public Q_SLOTS: void handleHoverEnter() { - QBrush brush = this->brush(); + QBrush brush = this->sliceBrush(); m_originalBrush = brush; brush.setColor(brush.color().lighter()); - setBrush(brush); + setSliceBrush(brush); } void handleHoverLeave() { - setBrush(m_originalBrush); + setSliceBrush(m_originalBrush); } private: diff --git a/src/charttheme.cpp b/src/charttheme.cpp index e555b85..1f4ebf7 100644 --- a/src/charttheme.cpp +++ b/src/charttheme.cpp @@ -284,8 +284,8 @@ void ChartTheme::decorate(PiePresenter* item, QPieSeries* series, int /*count*/) // finally update colors foreach (QPieSlice* s, series->slices()) { QColor c = colors.takeFirst(); - s->setPen(c); - s->setBrush(c); + s->setSlicePen(c); + s->setSliceBrush(c); } } diff --git a/src/piechart/pieslice.cpp b/src/piechart/pieslice.cpp index a275d4a..9f3d203 100644 --- a/src/piechart/pieslice.cpp +++ b/src/piechart/pieslice.cpp @@ -55,8 +55,8 @@ void PieSlice::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option painter->setClipRect(parentItem()->boundingRect()); painter->save(); - painter->setPen(m_pen); - painter->setBrush(m_brush); + painter->setPen(m_slicePen); + painter->setBrush(m_sliceBrush); painter->drawPath(m_slicePath); painter->restore(); @@ -125,14 +125,14 @@ void PieSlice::updateData(const QPieSlice* sliceData) m_angleSpan = sliceData->m_angleSpan; m_isExploded = sliceData->isExploded(); m_explodeDistanceFactor = sliceData->explodeDistanceFactor(); - m_pen = sliceData->pen(); - m_brush = sliceData->brush(); + m_slicePen = sliceData->slicePen(); + m_sliceBrush = sliceData->sliceBrush(); m_labelVisible = sliceData->isLabelVisible(); m_labelText = sliceData->label(); m_labelFont = sliceData->labelFont(); m_labelArmLengthFactor = sliceData->labelArmLengthFactor(); - m_labelArmPen = sliceData->labelPen(); + m_labelArmPen = sliceData->labelArmPen(); updateGeometry(); update(); diff --git a/src/piechart/pieslice_p.h b/src/piechart/pieslice_p.h index 3d6c324..760c8c7 100644 --- a/src/piechart/pieslice_p.h +++ b/src/piechart/pieslice_p.h @@ -57,8 +57,8 @@ private: bool m_isExploded; qreal m_explodeDistanceFactor; bool m_labelVisible; - QPen m_pen; - QBrush m_brush; + QPen m_slicePen; + QBrush m_sliceBrush; QPainterPath m_labelArmPath; qreal m_labelArmLengthFactor; diff --git a/src/piechart/qpieslice.cpp b/src/piechart/qpieslice.cpp index fb8cc0b..80ce8a6 100644 --- a/src/piechart/qpieslice.cpp +++ b/src/piechart/qpieslice.cpp @@ -46,9 +46,9 @@ QPieSlice::QPieSlice(QObject *parent) m_percentage(0), m_startAngle(0), m_angleSpan(0), - m_pen(DEFAULT_PEN_COLOR), - m_brush(DEFAULT_BRUSH_COLOR), - m_labelPen(DEFAULT_PEN_COLOR), + m_slicePen(DEFAULT_PEN_COLOR), + m_sliceBrush(DEFAULT_BRUSH_COLOR), + m_labelArmPen(DEFAULT_PEN_COLOR), m_labelArmLengthFactor(DEFAULT_LABEL_ARM_LENGTH_FACTOR) { @@ -69,9 +69,9 @@ QPieSlice::QPieSlice(qreal value, QString label, QObject *parent) m_percentage(0), m_startAngle(0), m_angleSpan(0), - m_pen(DEFAULT_PEN_COLOR), - m_brush(DEFAULT_BRUSH_COLOR), - m_labelPen(DEFAULT_PEN_COLOR), + m_slicePen(DEFAULT_PEN_COLOR), + m_sliceBrush(DEFAULT_BRUSH_COLOR), + m_labelArmPen(DEFAULT_PEN_COLOR), m_labelArmLengthFactor(DEFAULT_LABEL_ARM_LENGTH_FACTOR) { @@ -176,29 +176,29 @@ qreal QPieSlice::endAngle() const /*! Returns the pen used to draw this slice. - \sa setPen() + \sa setSlicePen() */ -QPen QPieSlice::pen() const +QPen QPieSlice::slicePen() const { - return m_pen; + return m_slicePen; } /*! Returns the brush used to draw this slice. - \sa setBrush() + \sa setSliceBrush() */ -QBrush QPieSlice::brush() const +QBrush QPieSlice::sliceBrush() const { - return m_brush; + return m_sliceBrush; } /*! - Returns the pen used to draw label in this slice. - \sa setLabelPen() + Returns the pen used to draw label arm in this slice. + \sa setLabelArmPen() */ -QPen QPieSlice::labelPen() const +QPen QPieSlice::labelArmPen() const { - return m_labelPen; + return m_labelArmPen; } /*! @@ -328,12 +328,12 @@ void QPieSlice::setExplodeDistanceFactor(qreal factor) /*! Sets the \a pen used to draw this slice. Note that applying a theme will override this. - \sa pen() + \sa slicePen() */ -void QPieSlice::setPen(QPen pen) +void QPieSlice::setSlicePen(const QPen &pen) { - if (m_pen != pen) { - m_pen = pen; + if (m_slicePen != pen) { + m_slicePen = pen; emit changed(); } } @@ -341,25 +341,25 @@ void QPieSlice::setPen(QPen pen) /*! Sets the \a brush used to draw this slice. Note that applying a theme will override this. - \sa brush() + \sa sliceBrush() */ -void QPieSlice::setBrush(QBrush brush) +void QPieSlice::setSliceBrush(const QBrush &brush) { - if (m_brush != brush) { - m_brush = brush; + if (m_sliceBrush != brush) { + m_sliceBrush = brush; emit changed(); } } /*! - Sets the \a pen used to draw the label in this slice. + Sets the \a pen used to draw the label arm in this slice. Note that applying a theme will override this. - \sa labelPen() + \sa labelArmPen() */ -void QPieSlice::setLabelPen(QPen pen) +void QPieSlice::setLabelArmPen(const QPen &pen) { - if (m_labelPen != pen) { - m_labelPen = pen; + if (m_labelArmPen != pen) { + m_labelArmPen = pen; emit changed(); } } @@ -369,7 +369,7 @@ void QPieSlice::setLabelPen(QPen pen) Note that applying a theme will override this. \sa labelFont() */ -void QPieSlice::setLabelFont(QFont font) +void QPieSlice::setLabelFont(const QFont &font) { if (m_labelFont != font) { m_labelFont = font; diff --git a/src/piechart/qpieslice.h b/src/piechart/qpieslice.h index 427fd75..8df8670 100644 --- a/src/piechart/qpieslice.h +++ b/src/piechart/qpieslice.h @@ -38,13 +38,13 @@ public: qreal endAngle() const; // customization - void setPen(QPen pen); - QPen pen() const; - void setBrush(QBrush brush); - QBrush brush() const; - void setLabelPen(QPen pen); - QPen labelPen() const; - void setLabelFont(QFont font); + void setSlicePen(const QPen &pen); + QPen slicePen() const; + void setSliceBrush(const QBrush &brush); + QBrush sliceBrush() const; + void setLabelArmPen(const QPen &pen); + QPen labelArmPen() const; + void setLabelFont(const QFont &font); QFont labelFont() const; void setLabelArmLengthFactor(qreal factor); qreal labelArmLengthFactor() const; @@ -79,10 +79,10 @@ private: qreal m_angleSpan; // customization - QPen m_pen; - QBrush m_brush; - QPen m_labelPen; + QPen m_slicePen; + QBrush m_sliceBrush; QFont m_labelFont; + QPen m_labelArmPen; qreal m_labelArmLengthFactor; };