From 1fb023d3c67834df047c3bd97f7c701a92afbd97 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 20 Jun 2013 14:20:45 -0300 Subject: [PATCH] Make the cross red when you cant plot a dive stop Make the cross red when you cant plot a dive stop, also make impossible to put a dive stop before the last one. Signed-off-by: Tomaz Canabrava --- qt-ui/diveplanner.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index d4dd7d5bf..fc5b701a7 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -29,6 +29,10 @@ void DivePlanner::mouseDoubleClickEvent(QMouseEvent* event) if(isPointOutOfBoundaries(mappedPos)) return; + if(handles.count() && handles.last()->x() > mappedPos.x()){ + return; + } + QGraphicsEllipseItem *item = new QGraphicsEllipseItem(-5,-5,10,10); item->setFlag(QGraphicsItem::ItemIgnoresTransformations); @@ -87,8 +91,20 @@ void DivePlanner::mouseMoveEvent(QMouseEvent* event) QPointF mappedPos = mapToScene(event->pos()); if (isPointOutOfBoundaries(mappedPos)) return; + verticalLine->setLine(mappedPos.x(), 0, mappedPos.x(), 100); horizontalLine->setLine(0, mappedPos.y(), 100, mappedPos.y()); + + if (!handles.count()) + return; + + if (handles.last()->x() > mappedPos.x()){ + verticalLine->setPen( QPen(QBrush(Qt::red), 0, Qt::SolidLine)); + horizontalLine->setPen( QPen(QBrush(Qt::red), 0, Qt::SolidLine)); + }else{ + verticalLine->setPen(QPen(Qt::DotLine)); + horizontalLine->setPen(QPen(Qt::DotLine)); + } } bool DivePlanner::isPointOutOfBoundaries(QPointF point)