##// END OF EJS Templates
Added hovered support to areachart. Might need to be re-thought
Marek Rosa -
r2264:6a6c0b791c1a
parent child
Show More
@@ -40,6 +40,7 AreaChartItem::AreaChartItem(QAreaSeries *areaSeries, ChartPresenter *presenter)
40 40 m_lower(0),
41 41 m_pointsVisible(false)
42 42 {
43 setAcceptHoverEvents(true);
43 44 setZValue(ChartPresenter::LineChartZValue);
44 45 m_upper = new AreaBoundItem(this, m_series->upperSeries(), presenter);
45 46 if (m_series->lowerSeries())
@@ -49,6 +50,7 AreaChartItem::AreaChartItem(QAreaSeries *areaSeries, ChartPresenter *presenter)
49 50 QObject::connect(m_series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated()));
50 51 QObject::connect(m_series, SIGNAL(opacityChanged()), this, SLOT(handleUpdated()));
51 52 QObject::connect(this, SIGNAL(clicked(QPointF)), areaSeries, SIGNAL(clicked(QPointF)));
53 QObject::connect(this, SIGNAL(hovered(QPointF,bool)), areaSeries, SIGNAL(hovered(QPointF,bool)));
52 54
53 55 handleUpdated();
54 56 }
@@ -147,6 +149,20 void AreaChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
147 149 ChartItem::mousePressEvent(event);
148 150 }
149 151
152 void AreaChartItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
153 {
154 emit hovered(m_upper->calculateDomainPoint(event->pos()), true);
155 event->accept();
156 // QGraphicsItem::hoverEnterEvent(event);
157 }
158
159 void AreaChartItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
160 {
161 emit hovered(m_upper->calculateDomainPoint(event->pos()), false);
162 event->accept();
163 // QGraphicsItem::hoverEnterEvent(event);
164 }
165
150 166 #include "moc_areachartitem_p.cpp"
151 167
152 168 QTCOMMERCIALCHART_END_NAMESPACE
@@ -58,9 +58,12 public:
58 58
59 59 protected:
60 60 void mousePressEvent(QGraphicsSceneMouseEvent *event);
61 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
62 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
61 63
62 64 Q_SIGNALS:
63 65 void clicked(const QPointF &point);
66 void hovered(const QPointF &point, bool state);
64 67
65 68 public Q_SLOTS:
66 69 void handleUpdated();
@@ -68,6 +68,7 public:
68 68
69 69 Q_SIGNALS:
70 70 void clicked(const QPointF &point);
71 void hovered(const QPointF &point, bool state);
71 72 void selected();
72 73 void colorChanged(QColor color);
73 74 void borderColorChanged(QColor color);
General Comments 0
You need to be logged in to leave comments. Login now