diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-07-21 12:12:31 -0300 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-07-21 12:12:31 -0300 |
commit | 9dde9b3d4cb1d96eae8f42ac9d7f6361d5702c95 (patch) | |
tree | 75bb46caa2a5f9f0a00eac24116fc5b75b0a0026 /qt-ui/diveplanner.cpp | |
parent | b36dfc7c4fce4b7b452ee352a866d340c19ff479 (diff) | |
download | subsurface-9dde9b3d4cb1d96eae8f42ac9d7f6361d5702c95.tar.gz |
Added the current gas used on the planner
Added the current gas used on the planner, now it's a matter
of choosing the new gas, that will be done in the next commit.e
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index a94c3daf8..9115203f5 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -246,7 +246,14 @@ void DivePlannerGraphics::keyRightAction() void DivePlannerGraphics::keyDeleteAction() { - if(scene()->selectedItems().count()){ + int selCount = scene()->selectedItems().count(); + if(selCount){ + + while(selCount--){ + Button *btn = gases.takeLast(); + delete btn; + } + Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()){ if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)){ handles.removeAll(handler); @@ -254,6 +261,7 @@ void DivePlannerGraphics::keyDeleteAction() delete i; } } + createDecoStops(); } } @@ -368,6 +376,14 @@ void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event) item->setPos(QPointF(xpos, ypos)); scene()->addItem(item); handles << item; + + Button *gasChooseBtn = new Button(); + gasChooseBtn ->setText(tr("Air")); + scene()->addItem(gasChooseBtn); + gasChooseBtn->setZValue(10); + connect(gasChooseBtn, SIGNAL(clicked()), this, SLOT(changeGas())); + + gases << gasChooseBtn; createDecoStops(); } @@ -428,6 +444,17 @@ void DivePlannerGraphics::createDecoStops() h->setPos(timeLine->posAtValue(h->sec / 60), depthLine->posAtValue(h->mm / 1000)); } + int gasCount = gases.count(); + for(int i = 0; i < gasCount; i++){ + QPointF p1 = (i == 0) ? QPointF(timeLine->posAtValue(0), depthLine->posAtValue(0)) : handles[i-1]->pos(); + QPointF p2 = handles[i]->pos(); + + QLineF line(p1, p2); + QPointF pos = line.pointAt(0.5); + gases[i]->setPos(pos); + qDebug() << "Adding a gas at" << pos; + } + // (re-) create the profile with different colors for segments that were // entered vs. segments that were calculated double lastx = timeLine->posAtValue(0); |