diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-06-20 13:53:12 -0300 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-06-20 13:53:12 -0300 |
commit | 88e7aa36be99d9ae985a374a23d84d8e0f969b5a (patch) | |
tree | b19a953b2f8f8fc2c83d0cd5328e8b8e09980a2b | |
parent | b1c526ddb4508a0694e46a6e48a1b0f900072f37 (diff) | |
download | subsurface-88e7aa36be99d9ae985a374a23d84d8e0f969b5a.tar.gz |
Created a cross that follows the mouse on the dive planner.
Created a cross that follows the mouse on the dive planner,
this will help the user to know where it is placing the stop.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
-rw-r--r-- | qt-ui/diveplanner.cpp | 22 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 5 |
2 files changed, 25 insertions, 2 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 0176e2c85..13f15a2e0 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -10,8 +10,17 @@ DivePlanner* DivePlanner::instance() DivePlanner::DivePlanner(QWidget* parent): QGraphicsView(parent) { + setMouseTracking(true); setScene( new QGraphicsScene()); scene()->setSceneRect(0,0,100,100); + + verticalLine = new QGraphicsLineItem(0,0,0, 100); + verticalLine->setPen(QPen(Qt::DotLine)); + scene()->addItem(verticalLine); + + horizontalLine = new QGraphicsLineItem(0,0,100,0); + horizontalLine->setPen(QPen(Qt::DotLine)); + scene()->addItem(horizontalLine); } void DivePlanner::mouseDoubleClickEvent(QMouseEvent* event) @@ -69,3 +78,16 @@ void DivePlanner::showEvent(QShowEvent* event) fitInView(sceneRect(), Qt::KeepAspectRatio); } +void DivePlanner::mouseMoveEvent(QMouseEvent* event) +{ + QPointF mappedPos = mapToScene(event->pos()); + if (mappedPos.x() > sceneRect().width() + || mappedPos.x() < 0 + || mappedPos.y() < 0 + || mappedPos.y() > sceneRect().height()) + { + return; + } + verticalLine->setLine(mappedPos.x(), 0, mappedPos.x(), 100); + horizontalLine->setLine(0, mappedPos.y(), 100, mappedPos.y()); +} diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 9d87b0c78..e66b50d57 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -12,13 +12,14 @@ protected: virtual void mouseDoubleClickEvent(QMouseEvent* event); virtual void showEvent(QShowEvent* event); virtual void resizeEvent(QResizeEvent* event); - + virtual void mouseMoveEvent(QMouseEvent* event); void clear_generated_deco(); void create_deco_stop(); - private: DivePlanner(QWidget* parent = 0); QList<QGraphicsLineItem*> lines; QList<QGraphicsEllipseItem*> handles; + QGraphicsLineItem *verticalLine; + QGraphicsLineItem *horizontalLine; }; #endif |