##// 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 m_lower(0),
40 m_lower(0),
41 m_pointsVisible(false)
41 m_pointsVisible(false)
42 {
42 {
43 setAcceptHoverEvents(true);
43 setZValue(ChartPresenter::LineChartZValue);
44 setZValue(ChartPresenter::LineChartZValue);
44 m_upper = new AreaBoundItem(this, m_series->upperSeries(), presenter);
45 m_upper = new AreaBoundItem(this, m_series->upperSeries(), presenter);
45 if (m_series->lowerSeries())
46 if (m_series->lowerSeries())
@@ -49,6 +50,7 AreaChartItem::AreaChartItem(QAreaSeries *areaSeries, ChartPresenter *presenter)
49 QObject::connect(m_series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated()));
50 QObject::connect(m_series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated()));
50 QObject::connect(m_series, SIGNAL(opacityChanged()), this, SLOT(handleUpdated()));
51 QObject::connect(m_series, SIGNAL(opacityChanged()), this, SLOT(handleUpdated()));
51 QObject::connect(this, SIGNAL(clicked(QPointF)), areaSeries, SIGNAL(clicked(QPointF)));
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 handleUpdated();
55 handleUpdated();
54 }
56 }
@@ -147,6 +149,20 void AreaChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
147 ChartItem::mousePressEvent(event);
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 #include "moc_areachartitem_p.cpp"
166 #include "moc_areachartitem_p.cpp"
151
167
152 QTCOMMERCIALCHART_END_NAMESPACE
168 QTCOMMERCIALCHART_END_NAMESPACE
@@ -58,9 +58,12 public:
58
58
59 protected:
59 protected:
60 void mousePressEvent(QGraphicsSceneMouseEvent *event);
60 void mousePressEvent(QGraphicsSceneMouseEvent *event);
61 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
62 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
61
63
62 Q_SIGNALS:
64 Q_SIGNALS:
63 void clicked(const QPointF &point);
65 void clicked(const QPointF &point);
66 void hovered(const QPointF &point, bool state);
64
67
65 public Q_SLOTS:
68 public Q_SLOTS:
66 void handleUpdated();
69 void handleUpdated();
@@ -67,7 +67,8 public:
67 bool pointsVisible() const;
67 bool pointsVisible() const;
68
68
69 Q_SIGNALS:
69 Q_SIGNALS:
70 void clicked(const QPointF &point);
70 void clicked(const QPointF &point);
71 void hovered(const QPointF &point, bool state);
71 void selected();
72 void selected();
72 void colorChanged(QColor color);
73 void colorChanged(QColor color);
73 void borderColorChanged(QColor color);
74 void borderColorChanged(QColor color);
General Comments 0
You need to be logged in to leave comments. Login now