New profile: fix Information overlay location

By simply storing the coordinates based on the scene (instead of trying to
map them to real coordinates) the overlay position is correctly restored.

Also remove the redundant positioning before readPos is called.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-03-13 10:23:20 -07:00
parent 13e2210d75
commit ae2f18678d
2 changed files with 3 additions and 6 deletions

View file

@ -184,10 +184,9 @@ void ToolTipItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void ToolTipItem::persistPos()
{
QPoint currentPos = scene()->views().at(0)->mapFromScene(pos());
QSettings s;
s.beginGroup("ProfileMap");
s.setValue("tooltip_position", currentPos);
s.setValue("tooltip_position", pos());
s.endGroup();
}
@ -195,8 +194,7 @@ void ToolTipItem::readPos()
{
QSettings s;
s.beginGroup("ProfileMap");
QPointF value = scene()->views().at(0)->mapToScene(
s.value("tooltip_position").toPoint());
QPointF value = s.value("tooltip_position").toPoint();
if (!scene()->sceneRect().contains(value)) {
value = QPointF(0, 0);
}

View file

@ -335,13 +335,12 @@ void ProfileWidget2::plotDives(QList<dive *> dives)
firstCall = false;
}
// restore default zoom level and tooltip position
// restore default zoom level
if (zoomLevel) {
const qreal defScale = 1.0 / qPow(zoomFactor, (qreal)zoomLevel);
scale(defScale, defScale);
zoomLevel = 0;
}
toolTipItem->setPos(0, 0);
// No need to do this again if we are already showing the same dive
// computer of the same dive, so we check the unique id of the dive