##// END OF EJS Templates
Emit hover leave signal from PieSliceItem when it gets destroyed....
Jani Honkonen -
r1083:b264b1ddc4c8
parent child
Show More
@@ -57,6 +57,7 void DrilldownSlice::updateLabel()
57 void DrilldownSlice::showHighlight(bool show)
57 void DrilldownSlice::showHighlight(bool show)
58 {
58 {
59 setLabelVisible(show);
59 setLabelVisible(show);
60 setExploded(show);
60 }
61 }
61
62
62 #include "moc_drilldownslice.cpp"
63 #include "moc_drilldownslice.cpp"
@@ -40,7 +40,8 QPointF offset(qreal angle, qreal length)
40 }
40 }
41
41
42 PieSliceItem::PieSliceItem(QGraphicsItem* parent)
42 PieSliceItem::PieSliceItem(QGraphicsItem* parent)
43 :QGraphicsObject(parent)
43 :QGraphicsObject(parent),
44 m_hovered(false)
44 {
45 {
45 setAcceptHoverEvents(true);
46 setAcceptHoverEvents(true);
46 setAcceptedMouseButtons(Qt::MouseButtonMask);
47 setAcceptedMouseButtons(Qt::MouseButtonMask);
@@ -49,7 +50,10 PieSliceItem::PieSliceItem(QGraphicsItem* parent)
49
50
50 PieSliceItem::~PieSliceItem()
51 PieSliceItem::~PieSliceItem()
51 {
52 {
52
53 // If user is hovering over the slice and it gets destroyed we do
54 // not get a hover leave event. So we must emit the signal here.
55 if (m_hovered)
56 emit hovered(false);
53 }
57 }
54
58
55 QRectF PieSliceItem::boundingRect() const
59 QRectF PieSliceItem::boundingRect() const
@@ -85,11 +89,13 void PieSliceItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*op
85
89
86 void PieSliceItem::hoverEnterEvent(QGraphicsSceneHoverEvent* /*event*/)
90 void PieSliceItem::hoverEnterEvent(QGraphicsSceneHoverEvent* /*event*/)
87 {
91 {
92 m_hovered = true;
88 emit hovered(true);
93 emit hovered(true);
89 }
94 }
90
95
91 void PieSliceItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* /*event*/)
96 void PieSliceItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* /*event*/)
92 {
97 {
98 m_hovered = false;
93 emit hovered(false);
99 emit hovered(false);
94 }
100 }
95
101
@@ -72,6 +72,7 private:
72 QPainterPath m_slicePath;
72 QPainterPath m_slicePath;
73 QPainterPath m_labelArmPath;
73 QPainterPath m_labelArmPath;
74 QRectF m_labelTextRect;
74 QRectF m_labelTextRect;
75 bool m_hovered;
75 };
76 };
76
77
77 QTCOMMERCIALCHART_END_NAMESPACE
78 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now