##// END OF EJS Templates
Fixes mouse handling in base class of chartseries
Michal Klocek -
r1747:19ac79b0cec7
parent child
Show More
@@ -143,6 +143,7 void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
143 void AreaChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
143 void AreaChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
144 {
144 {
145 emit clicked(m_upper->calculateDomainPoint(event->pos()));
145 emit clicked(m_upper->calculateDomainPoint(event->pos()));
146 ChartItem::mousePressEvent(event);
146 }
147 }
147
148
148 #include "moc_areachartitem_p.cpp"
149 #include "moc_areachartitem_p.cpp"
@@ -45,6 +45,7 void Bar::mousePressEvent(QGraphicsSceneMouseEvent *event)
45 {
45 {
46 Q_UNUSED(event)
46 Q_UNUSED(event)
47 emit clicked(m_index, m_barset);
47 emit clicked(m_index, m_barset);
48 QGraphicsItem::mousePressEvent(event);
48 }
49 }
49
50
50 void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
51 void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
@@ -52,6 +53,7 void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
52 Q_UNUSED(event)
53 Q_UNUSED(event)
53 m_hovering = true;
54 m_hovering = true;
54 emit hovered(true, m_barset);
55 emit hovered(true, m_barset);
56
55 }
57 }
56
58
57 void Bar::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
59 void Bar::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
@@ -57,11 +57,13 public:
57 GridZValue,
57 GridZValue,
58 SeriesZValue,
58 SeriesZValue,
59 LineChartZValue = SeriesZValue,
59 LineChartZValue = SeriesZValue,
60 SplineChartZValue = SeriesZValue,
60 BarSeriesZValue = SeriesZValue,
61 BarSeriesZValue = SeriesZValue,
61 ScatterSeriesZValue = SeriesZValue,
62 ScatterSeriesZValue = SeriesZValue,
62 PieSeriesZValue = SeriesZValue,
63 PieSeriesZValue = SeriesZValue,
63 AxisZValue,
64 AxisZValue,
64 LegendZValue
65 LegendZValue,
66 TopMostZValue
65 };
67 };
66
68
67 enum State {
69 enum State {
@@ -107,6 +107,7 void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
107 void LineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
107 void LineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
108 {
108 {
109 emit XYChart::clicked(calculateDomainPoint(event->pos()));
109 emit XYChart::clicked(calculateDomainPoint(event->pos()));
110 QGraphicsItem::mousePressEvent(event);
110 }
111 }
111
112
112 #include "moc_linechartitem_p.cpp"
113 #include "moc_linechartitem_p.cpp"
@@ -132,6 +132,7 void PieSliceItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* /*event*/)
132 void PieSliceItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
132 void PieSliceItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
133 {
133 {
134 emit clicked(event->buttons());
134 emit clicked(event->buttons());
135 QGraphicsItem::mousePressEvent(event);
135 }
136 }
136
137
137 void PieSliceItem::setLayout(const PieSliceData &sliceData)
138 void PieSliceItem::setLayout(const PieSliceData &sliceData)
@@ -68,14 +68,14 void ScatterChartItem::createPoints(int count)
68
68
69 switch (m_shape) {
69 switch (m_shape) {
70 case QScatterSeries::MarkerShapeCircle: {
70 case QScatterSeries::MarkerShapeCircle: {
71 QGraphicsEllipseItem* i = new QGraphicsEllipseItem(0,0,m_size,m_size);
71 QGraphicsEllipseItem* i = new QGraphicsEllipseItem(0,0,m_size,m_size,this);
72 const QRectF& rect = i->boundingRect();
72 const QRectF& rect = i->boundingRect();
73 i->setPos(-rect.width()/2,-rect.height()/2);
73 i->setPos(-rect.width()/2,-rect.height()/2);
74 item = new Marker(i,this);
74 item = new Marker(i,this);
75 break;
75 break;
76 }
76 }
77 case QScatterSeries::MarkerShapeRectangle: {
77 case QScatterSeries::MarkerShapeRectangle: {
78 QGraphicsRectItem* i = new QGraphicsRectItem(0,0,m_size,m_size);
78 QGraphicsRectItem* i = new QGraphicsRectItem(0,0,m_size,m_size,this);
79 i->setPos(-m_size/2,-m_size/2);
79 i->setPos(-m_size/2,-m_size/2);
80 item = new Marker(i,this);
80 item = new Marker(i,this);
81 break;
81 break;
@@ -198,6 +198,7 void ScatterChartItem::handleUpdated()
198 void ScatterChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
198 void ScatterChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
199 {
199 {
200 emit XYChart::clicked(calculateDomainPoint(event->pos()));
200 emit XYChart::clicked(calculateDomainPoint(event->pos()));
201 QGraphicsItem::mousePressEvent(event);
201 }
202 }
202
203
203 #include "moc_scatterchartitem_p.cpp"
204 #include "moc_scatterchartitem_p.cpp"
@@ -138,6 +138,7 protected:
138 {
138 {
139 Q_UNUSED(event)
139 Q_UNUSED(event)
140 m_parent->markerSelected(this);
140 m_parent->markerSelected(this);
141 QAbstractGraphicsShapeItem::mousePressEvent(event);
141 }
142 }
142
143
143 private:
144 private:
@@ -34,7 +34,7 SplineChartItem::SplineChartItem(QSplineSeries *series, ChartPresenter *presente
34 m_pointsVisible(false),
34 m_pointsVisible(false),
35 m_animation(0)
35 m_animation(0)
36 {
36 {
37 setZValue(ChartPresenter::LineChartZValue);
37 setZValue(ChartPresenter::SplineChartZValue);
38 QObject::connect(m_series->d_func(),SIGNAL(updated()),this,SLOT(handleUpdated()));
38 QObject::connect(m_series->d_func(),SIGNAL(updated()),this,SLOT(handleUpdated()));
39 QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated()));
39 QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated()));
40 handleUpdated();
40 handleUpdated();
@@ -169,6 +169,7 void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
169 void SplineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
169 void SplineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
170 {
170 {
171 emit XYChart::clicked(calculateDomainPoint(event->pos()));
171 emit XYChart::clicked(calculateDomainPoint(event->pos()));
172 QGraphicsItem::mousePressEvent(event);
172 }
173 }
173
174
174 #include "moc_splinechartitem_p.cpp"
175 #include "moc_splinechartitem_p.cpp"
General Comments 0
You need to be logged in to leave comments. Login now