mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
b36dfc7c4f
commit
9dde9b3d4c
2 changed files with 34 additions and 2 deletions
|
@ -246,7 +246,14 @@ void DivePlannerGraphics::keyRightAction()
|
||||||
|
|
||||||
void DivePlannerGraphics::keyDeleteAction()
|
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()){
|
Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()){
|
||||||
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)){
|
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)){
|
||||||
handles.removeAll(handler);
|
handles.removeAll(handler);
|
||||||
|
@ -254,6 +261,7 @@ void DivePlannerGraphics::keyDeleteAction()
|
||||||
delete i;
|
delete i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createDecoStops();
|
createDecoStops();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,6 +376,14 @@ void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
item->setPos(QPointF(xpos, ypos));
|
item->setPos(QPointF(xpos, ypos));
|
||||||
scene()->addItem(item);
|
scene()->addItem(item);
|
||||||
handles << 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();
|
createDecoStops();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,6 +444,17 @@ void DivePlannerGraphics::createDecoStops()
|
||||||
h->setPos(timeLine->posAtValue(h->sec / 60), depthLine->posAtValue(h->mm / 1000));
|
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
|
// (re-) create the profile with different colors for segments that were
|
||||||
// entered vs. segments that were calculated
|
// entered vs. segments that were calculated
|
||||||
double lastx = timeLine->posAtValue(0);
|
double lastx = timeLine->posAtValue(0);
|
||||||
|
|
|
@ -28,7 +28,6 @@ public:
|
||||||
int mm;
|
int mm;
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Ruler : public QGraphicsLineItem{
|
class Ruler : public QGraphicsLineItem{
|
||||||
|
@ -97,6 +96,12 @@ private:
|
||||||
/* This is the user-entered handles. */
|
/* This is the user-entered handles. */
|
||||||
QList<DiveHandler *> handles;
|
QList<DiveHandler *> handles;
|
||||||
|
|
||||||
|
/* this is the user-entered gases.
|
||||||
|
This must be a button, so the
|
||||||
|
user cna click to choose a new gas.
|
||||||
|
*/
|
||||||
|
QList<Button*> gases;
|
||||||
|
|
||||||
/* those are the lines that follows the mouse. */
|
/* those are the lines that follows the mouse. */
|
||||||
QGraphicsLineItem *verticalLine;
|
QGraphicsLineItem *verticalLine;
|
||||||
QGraphicsLineItem *horizontalLine;
|
QGraphicsLineItem *horizontalLine;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue