diff --git a/src/piechart/piechart.pri b/src/piechart/piechart.pri index 3638c92..d22639b 100644 --- a/src/piechart/piechart.pri +++ b/src/piechart/piechart.pri @@ -3,13 +3,13 @@ DEPENDPATH += $$PWD SOURCES += \ $$PWD/qpieseries.cpp \ - $$PWD/pieslice.cpp \ + $$PWD/piesliceitem.cpp \ $$PWD/piechartitem.cpp \ $$PWD/qpieslice.cpp PRIVATE_HEADERS += \ $$PWD/piechartitem_p.h \ - $$PWD/pieslice_p.h \ + $$PWD/piesliceitem_p.h \ $$PWD/qpiesliceprivate_p.h \ $$PWD/qpieseriesprivate_p.h diff --git a/src/piechart/piechartitem.cpp b/src/piechart/piechartitem.cpp index c4a0269..5a8902d 100644 --- a/src/piechart/piechartitem.cpp +++ b/src/piechart/piechartitem.cpp @@ -1,5 +1,5 @@ #include "piechartitem_p.h" -#include "pieslice_p.h" +#include "piesliceitem_p.h" #include "qpieslice.h" #include "qpiesliceprivate_p.h" #include "qpieseries.h" @@ -55,12 +55,12 @@ void PieChartItem::handleSlicesAdded(QList slices) m_presenter->theme()->decorate(m_series, m_presenter->dataSet()->seriesIndex(m_series)); foreach (QPieSlice *s, slices) { - PieSlice* slice = new PieSlice(this); - m_slices.insert(s, slice); + PieSliceItem* item = new PieSliceItem(this); + m_slices.insert(s, item); connect(s, SIGNAL(changed()), this, SLOT(handleSliceChanged())); - connect(slice, SIGNAL(clicked()), s, SIGNAL(clicked())); - connect(slice, SIGNAL(hoverEnter()), s, SIGNAL(hoverEnter())); - connect(slice, SIGNAL(hoverLeave()), s, SIGNAL(hoverLeave())); + connect(item, SIGNAL(clicked()), s, SIGNAL(clicked())); + connect(item, SIGNAL(hoverEnter()), s, SIGNAL(hoverEnter())); + connect(item, SIGNAL(hoverLeave()), s, SIGNAL(hoverLeave())); PieSliceData data = sliceData(s); @@ -129,7 +129,7 @@ void PieChartItem::calculatePieLayout() PieSliceData PieChartItem::sliceData(QPieSlice *slice) { PieSliceData sliceData = slice->d_ptr->m_data; - sliceData.m_center = PieSlice::sliceCenter(m_pieCenter, m_pieRadius, slice); + sliceData.m_center = PieSliceItem::sliceCenter(m_pieCenter, m_pieRadius, slice); sliceData.m_radius = m_pieRadius; sliceData.m_angleSpan = slice->endAngle() - slice->startAngle(); return sliceData; @@ -165,22 +165,22 @@ void PieChartItem::updateLayout(QPieSlice *slice, const PieSliceData &sliceData) void PieChartItem::setLayout(const PieLayout &layout) { foreach (QPieSlice *slice, layout.keys()) { - PieSlice *s = m_slices.value(slice); - Q_ASSERT(s); - s->setSliceData(layout.value(slice)); - s->updateGeometry(); - s->update(); + PieSliceItem *item = m_slices.value(slice); + Q_ASSERT(item); + item->setSliceData(layout.value(slice)); + item->updateGeometry(); + item->update(); } } void PieChartItem::setLayout(QPieSlice *slice, const PieSliceData &sliceData) { // find slice - PieSlice *s = m_slices.value(slice); - Q_ASSERT(s); - s->setSliceData(sliceData); - s->updateGeometry(); - s->update(); + PieSliceItem *item = m_slices.value(slice); + Q_ASSERT(item); + item->setSliceData(sliceData); + item->updateGeometry(); + item->update(); } void PieChartItem::destroySlice(QPieSlice *slice) diff --git a/src/piechart/piechartitem_p.h b/src/piechart/piechartitem_p.h index 43c866a..3ec4da8 100644 --- a/src/piechart/piechartitem_p.h +++ b/src/piechart/piechartitem_p.h @@ -3,7 +3,7 @@ #include "qpieseries.h" #include "chartitem_p.h" -#include "pieslice_p.h" +#include "piesliceitem_p.h" class QGraphicsItem; QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -45,8 +45,8 @@ public: void destroySlice(QPieSlice *slice); private: - friend class PieSlice; - QHash m_slices; + friend class PieSliceItem; + QHash m_slices; QPieSeries *m_series; QRectF m_rect; QPointF m_pieCenter; diff --git a/src/piechart/pieslice.cpp b/src/piechart/piesliceitem.cpp similarity index 86% rename from src/piechart/pieslice.cpp rename to src/piechart/piesliceitem.cpp index c08093e..09ae0d5 100644 --- a/src/piechart/pieslice.cpp +++ b/src/piechart/piesliceitem.cpp @@ -1,4 +1,4 @@ -#include "pieslice_p.h" +#include "piesliceitem_p.h" #include "piechartitem_p.h" #include "qpieseries.h" #include "qpieslice.h" @@ -20,7 +20,7 @@ QPointF offset(qreal angle, qreal length) return QPointF(dx, -dy); } -PieSlice::PieSlice(QGraphicsItem* parent) +PieSliceItem::PieSliceItem(QGraphicsItem* parent) :QGraphicsObject(parent) { setAcceptHoverEvents(true); @@ -28,24 +28,24 @@ PieSlice::PieSlice(QGraphicsItem* parent) setZValue(ChartPresenter::PieSeriesZValue); } -PieSlice::~PieSlice() +PieSliceItem::~PieSliceItem() { } -QRectF PieSlice::boundingRect() const +QRectF PieSliceItem::boundingRect() const { return m_boundingRect; } -QPainterPath PieSlice::shape() const +QPainterPath PieSliceItem::shape() const { // Don't include the label and label arm. // This is used to detect a mouse clicks. We do not want clicks from label. return m_slicePath; } -void PieSlice::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/) +void PieSliceItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/) { painter->setClipRect(parentItem()->boundingRect()); @@ -66,27 +66,27 @@ void PieSlice::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option } } -void PieSlice::hoverEnterEvent(QGraphicsSceneHoverEvent* /*event*/) +void PieSliceItem::hoverEnterEvent(QGraphicsSceneHoverEvent* /*event*/) { emit hoverEnter(); } -void PieSlice::hoverLeaveEvent(QGraphicsSceneHoverEvent* /*event*/) +void PieSliceItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* /*event*/) { emit hoverLeave(); } -void PieSlice::mousePressEvent(QGraphicsSceneMouseEvent* /*event*/) +void PieSliceItem::mousePressEvent(QGraphicsSceneMouseEvent* /*event*/) { emit clicked(); } -void PieSlice::setSliceData(PieSliceData sliceData) +void PieSliceItem::setSliceData(PieSliceData sliceData) { m_data = sliceData; } -void PieSlice::updateGeometry() +void PieSliceItem::updateGeometry() { if (m_data.m_radius <= 0) return; @@ -112,7 +112,7 @@ void PieSlice::updateGeometry() m_boundingRect = m_slicePath.boundingRect().united(m_labelArmPath.boundingRect()).united(m_labelTextRect); } -QPointF PieSlice::sliceCenter(QPointF point, qreal radius, QPieSlice *slice) +QPointF PieSliceItem::sliceCenter(QPointF point, qreal radius, QPieSlice *slice) { if (slice->isExploded()) { qreal centerAngle = slice->startAngle() + ((slice->endAngle() - slice->startAngle())/2); @@ -124,7 +124,7 @@ QPointF PieSlice::sliceCenter(QPointF point, qreal radius, QPieSlice *slice) return point; } -QPainterPath PieSlice::slicePath(QPointF center, qreal radius, qreal startAngle, qreal angleSpan, qreal* centerAngle, QPointF* armStart) +QPainterPath PieSliceItem::slicePath(QPointF center, qreal radius, qreal startAngle, qreal angleSpan, qreal* centerAngle, QPointF* armStart) { // calculate center angle *centerAngle = startAngle + (angleSpan/2); @@ -146,7 +146,7 @@ QPainterPath PieSlice::slicePath(QPointF center, qreal radius, qreal startAngle, return path; } -QPainterPath PieSlice::labelArmPath(QPointF start, qreal angle, qreal length, qreal textWidth, QPointF* textStart) +QPainterPath PieSliceItem::labelArmPath(QPointF start, qreal angle, qreal length, qreal textWidth, QPointF* textStart) { qreal dx = qSin(angle*(PI/180)) * length; qreal dy = -qCos(angle*(PI/180)) * length; @@ -173,12 +173,12 @@ QPainterPath PieSlice::labelArmPath(QPointF start, qreal angle, qreal length, qr return path; } -QRectF PieSlice::labelTextRect(QFont font, QString text) +QRectF PieSliceItem::labelTextRect(QFont font, QString text) { QFontMetricsF fm(font); return fm.boundingRect(text); } -#include "moc_pieslice_p.cpp" +#include "moc_piesliceitem_p.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/piechart/pieslice_p.h b/src/piechart/piesliceitem_p.h similarity index 88% rename from src/piechart/pieslice_p.h rename to src/piechart/piesliceitem_p.h index 54c140c..0163fd1 100644 --- a/src/piechart/pieslice_p.h +++ b/src/piechart/piesliceitem_p.h @@ -1,5 +1,5 @@ -#ifndef PIESLICE_H -#define PIESLICE_H +#ifndef PIESLICEITEM_H +#define PIESLICEITEM_H #include "qchartglobal.h" #include "charttheme_p.h" @@ -17,13 +17,13 @@ class PieChartItem; class PieSliceLabel; class QPieSlice; -class PieSlice : public QGraphicsObject +class PieSliceItem : public QGraphicsObject { Q_OBJECT public: - PieSlice(QGraphicsItem* parent = 0); - ~PieSlice(); + PieSliceItem(QGraphicsItem* parent = 0); + ~PieSliceItem(); public: // from QGraphicsItem QRectF boundingRect() const; @@ -56,4 +56,4 @@ private: QTCOMMERCIALCHART_END_NAMESPACE -#endif // PIESLICE_H +#endif // PIESLICEITEM_H