Speed Improvemens: fewer calls to mapFromScene / mapToScene

We did three cals to mapToScene / mapFromScene on the mouse moveEvent at
the ProfileWidget2 where we only needed to call one in the common case and
two in the worst case.

This doesn't really help in terms of speed (unless you have a really old
cpu) but since it's code that gets called *very* often, it seemed a
reasonable thing to do.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2015-01-14 14:41:56 -02:00 committed by Dirk Hohndel
parent db4ffd0b70
commit 501f72c697

View file

@ -814,16 +814,16 @@ void ProfileWidget2::scrollViewTo(const QPoint &pos)
void ProfileWidget2::mouseMoveEvent(QMouseEvent *event) void ProfileWidget2::mouseMoveEvent(QMouseEvent *event)
{ {
toolTipItem->refresh(mapToScene(event->pos())); QPointF pos = mapToScene(event->pos());
QPoint toolTipPos = mapFromScene(toolTipItem->pos()); toolTipItem->refresh(pos);
if (zoomLevel == 0) { if (zoomLevel == 0) {
QGraphicsView::mouseMoveEvent(event); QGraphicsView::mouseMoveEvent(event);
} else { } else {
QPoint toolTipPos = mapFromScene(toolTipItem->pos());
scrollViewTo(event->pos()); scrollViewTo(event->pos());
toolTipItem->setPos(mapToScene(toolTipPos)); toolTipItem->setPos(mapToScene(toolTipPos));
} }
QPointF pos = mapToScene(event->pos());
qreal vValue = profileYAxis->valueAt(pos); qreal vValue = profileYAxis->valueAt(pos);
qreal hValue = timeAxis->valueAt(pos); qreal hValue = timeAxis->valueAt(pos);
if (profileYAxis->maximum() >= vValue && profileYAxis->minimum() <= vValue) { if (profileYAxis->maximum() >= vValue && profileYAxis->minimum() <= vValue) {