##// END OF EJS Templates
Added hovered support to scatter series
Marek Rosa -
r2261:f149ef311d71
parent child
Show More
@@ -96,6 +96,11 void ScatterChartItem::markerSelected(QGraphicsItem *marker)
96 emit XYChart::clicked(calculateDomainPoint(m_markerMap[marker]));
96 emit XYChart::clicked(calculateDomainPoint(m_markerMap[marker]));
97 }
97 }
98
98
99 void ScatterChartItem::markerHovered(QGraphicsItem *marker, bool state)
100 {
101 emit XYChart::hovered(calculateDomainPoint(m_markerMap[marker]), state);
102 }
103
99 void ScatterChartItem::updateGeometry()
104 void ScatterChartItem::updateGeometry()
100 {
105 {
101
106
@@ -55,6 +55,7 public:
55 void setBrush(const QBrush &brush);
55 void setBrush(const QBrush &brush);
56
56
57 void markerSelected(QGraphicsItem *item);
57 void markerSelected(QGraphicsItem *item);
58 void markerHovered(QGraphicsItem *item, bool state);
58
59
59 public Q_SLOTS:
60 public Q_SLOTS:
60 void handleUpdated();
61 void handleUpdated();
@@ -84,6 +85,7 public:
84 : QGraphicsEllipseItem(x, y, w, h, parent),
85 : QGraphicsEllipseItem(x, y, w, h, parent),
85 m_parent(parent)
86 m_parent(parent)
86 {
87 {
88 setAcceptHoverEvents(true);
87 }
89 }
88
90
89 protected:
91 protected:
@@ -92,6 +94,16 protected:
92 m_parent->markerSelected(this);
94 m_parent->markerSelected(this);
93 QGraphicsEllipseItem::mousePressEvent(event);
95 QGraphicsEllipseItem::mousePressEvent(event);
94 }
96 }
97 void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
98 {
99 m_parent->markerHovered(this, true);
100 QGraphicsEllipseItem::hoverEnterEvent(event);
101 }
102 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
103 {
104 m_parent->markerHovered(this, false);
105 QGraphicsEllipseItem::hoverLeaveEvent(event);
106 }
95
107
96 private:
108 private:
97 ScatterChartItem *m_parent;
109 ScatterChartItem *m_parent;
@@ -105,6 +117,7 public:
105 : QGraphicsRectItem(x, y, w, h, parent),
117 : QGraphicsRectItem(x, y, w, h, parent),
106 m_parent(parent)
118 m_parent(parent)
107 {
119 {
120 setAcceptHoverEvents(true);
108 }
121 }
109
122
110 protected:
123 protected:
@@ -113,6 +126,16 protected:
113 m_parent->markerSelected(this);
126 m_parent->markerSelected(this);
114 QGraphicsRectItem::mousePressEvent(event);
127 QGraphicsRectItem::mousePressEvent(event);
115 }
128 }
129 void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
130 {
131 m_parent->markerHovered(this, true);
132 QGraphicsRectItem::hoverEnterEvent(event);
133 }
134 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
135 {
136 m_parent->markerHovered(this, false);
137 QGraphicsRectItem::hoverLeaveEvent(event);
138 }
116
139
117 private:
140 private:
118 ScatterChartItem *m_parent;
141 ScatterChartItem *m_parent;
General Comments 0
You need to be logged in to leave comments. Login now