aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/profilegraphics.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-10 14:28:44 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-10 14:28:44 -0300
commit34c6eec9bac57846da042aac546578bdb5dcb1af (patch)
tree68df982d69b035384d673fa929658180520aa8db /qt-ui/profilegraphics.cpp
parent45f80afc1f186f65dad95b54f4fba502a5933884 (diff)
downloadsubsurface-34c6eec9bac57846da042aac546578bdb5dcb1af.tar.gz
Save / Restore toolTip information position on the Profile when switching dives.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/profilegraphics.cpp')
-rw-r--r--qt-ui/profilegraphics.cpp40
1 files changed, 31 insertions, 9 deletions
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index 551b2d8dc..9c73e1fdc 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -146,6 +146,7 @@ void ProfileGraphicsView::wheelEvent(QWheelEvent* event)
// Scale the view / do the zoom
QPoint toolTipPos = mapFromScene(toolTip->pos());
+
double scaleFactor = 1.15;
if (event->delta() > 0 && zoomLevel <= 10) {
scale(scaleFactor, scaleFactor);
@@ -172,10 +173,10 @@ void ProfileGraphicsView::mouseMoveEvent(QMouseEvent* event)
ensureVisible(event->pos().x() + dx, event->pos().y() + dy, 1, 1);
- toolTip->setPos(mapToScene(toolTipPos).x(), mapToScene(toolTipPos).y());
-
if (zoomLevel == 0)
QGraphicsView::mouseMoveEvent(event);
+ else
+ toolTip->setPos(mapToScene(toolTipPos).x(), mapToScene(toolTipPos).y());
}
bool ProfileGraphicsView::eventFilter(QObject* obj, QEvent* event)
@@ -256,14 +257,7 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw)
scene()->setSceneRect(0,0, viewport()->width()-50, viewport()->height()-50);
- QSettings s;
- s.beginGroup("ProfileMap");
- QPointF toolTipPos = s.value("tooltip_position", QPointF(0,0)).toPointF();
- s.endGroup();
-
toolTip = new ToolTipItem();
- toolTip->setPos(toolTipPos);
-
scene()->addItem(toolTip);
// Fix this for printing / screen later.
@@ -358,6 +352,7 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw)
if (zoomLevel == 0) {
fitInView(sceneRect());
}
+ toolTip->readPos();
}
void ProfileGraphicsView::plot_depth_scale()
@@ -1409,6 +1404,33 @@ bool ToolTipItem::isExpanded() {
return status == EXPANDED;
}
+void ToolTipItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
+{
+ persistPos();
+}
+
+void ToolTipItem::persistPos()
+{
+ QPoint currentPos = scene()->views().at(0)->mapFromScene(pos());
+ QSettings s;
+ s.beginGroup("ProfileMap");
+ s.setValue("tooltip_position", currentPos);
+ s.endGroup();
+ s.sync();
+ qDebug() << "Salvou" << currentPos;
+}
+
+void ToolTipItem::readPos()
+{
+ QSettings s;
+ s.beginGroup("ProfileMap");
+ QPointF value = scene()->views().at(0)->mapToScene(
+ s.value("tooltip_position").toPoint()
+ );
+ setPos(value);
+}
+
+
EventItem::EventItem(QGraphicsItem* parent): QGraphicsPolygonItem(parent)
{
setFlag(ItemIgnoresTransformations);