diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-06-20 14:29:32 -0300 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-06-20 14:29:32 -0300 |
commit | 021a6a076e76e45bf5f6f8b976e2178a666ec1bd (patch) | |
tree | 0be9f2adb2702086ae7a6cd2f10a0a284b89e294 /qt-ui/diveplanner.cpp | |
parent | 1fb023d3c67834df047c3bd97f7c701a92afbd97 (diff) | |
download | subsurface-021a6a076e76e45bf5f6f8b976e2178a666ec1bd.tar.gz |
Created a class DiveHandle to make drag drop work.
Create d a class DiveHandle to make drag drop works,
it has a from and to Lines, and it will move them
around.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index fc5b701a7..07f195120 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -33,23 +33,25 @@ void DivePlanner::mouseDoubleClickEvent(QMouseEvent* event) return; } - QGraphicsEllipseItem *item = new QGraphicsEllipseItem(-5,-5,10,10); + DiveHandler *item = new DiveHandler (); + item->setRect(-5,-5,10,10); item->setFlag(QGraphicsItem::ItemIgnoresTransformations); - - item->setPos( mappedPos ); scene()->addItem(item); handles << item; if (lines.empty()){ QGraphicsLineItem *first = new QGraphicsLineItem(0,0, mappedPos.x(), mappedPos.y()); + item->from = first; lines.push_back(first); create_deco_stop(); scene()->addItem(first); }else{ clear_generated_deco(); - QGraphicsEllipseItem *prevHandle = handles.at( handles.count()-2); + DiveHandler *prevHandle = handles.at( handles.count()-2); QGraphicsLineItem *line = new QGraphicsLineItem(prevHandle->x(), prevHandle->y(), item->x(), item->y()); + prevHandle->to = line; + item->from = line; lines.push_back(line); scene()->addItem(line); create_deco_stop(); @@ -68,7 +70,8 @@ void DivePlanner::clear_generated_deco() void DivePlanner::create_deco_stop() { // this needs to create everything - // for the calculated deco. + // for the calculated deco. it should return the *first* + // line that's calculated, so the QGraphicsLineItem *item = new QGraphicsLineItem(handles.last()->x(), handles.last()->y(), 100, 0); scene()->addItem(item); lines << item; @@ -118,3 +121,9 @@ bool DivePlanner::isPointOutOfBoundaries(QPointF point) } return false; } + + + +DiveHandler::DiveHandler(): QGraphicsEllipseItem(), from(0), to(0) +{ +} |