mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Make the plan handlers to not move across other handlers.
This patch disables the hability to move handlers across the others, making a 'zigzag' in the time line. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
607f82ade3
commit
52a0e6c82d
2 changed files with 48 additions and 19 deletions
|
@ -98,24 +98,8 @@ void DivePlanner::mouseMoveEvent(QMouseEvent* event)
|
||||||
verticalLine->setLine(mappedPos.x(), 0, mappedPos.x(), 100);
|
verticalLine->setLine(mappedPos.x(), 0, mappedPos.x(), 100);
|
||||||
horizontalLine->setLine(0, mappedPos.y(), 100, mappedPos.y());
|
horizontalLine->setLine(0, mappedPos.y(), 100, mappedPos.y());
|
||||||
|
|
||||||
if (activeDraggedHandler){
|
if(activeDraggedHandler)
|
||||||
int idx = handles.indexOf(activeDraggedHandler);
|
moveActiveHandler(mappedPos);
|
||||||
activeDraggedHandler->setPos(mappedPos);
|
|
||||||
if (activeDraggedHandler->from){
|
|
||||||
QLineF f = activeDraggedHandler->from->line();
|
|
||||||
activeDraggedHandler->from->setLine(f.x1(), f.y1(), mappedPos.x(), mappedPos.y());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(activeDraggedHandler == handles.last()){
|
|
||||||
clear_generated_deco();
|
|
||||||
create_deco_stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (activeDraggedHandler->to){
|
|
||||||
QLineF f = activeDraggedHandler->to->line();
|
|
||||||
activeDraggedHandler->to->setLine(mappedPos.x(), mappedPos.y(), f.x2(), f.y2());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!handles.count())
|
if (!handles.count())
|
||||||
return;
|
return;
|
||||||
|
@ -129,6 +113,50 @@ void DivePlanner::mouseMoveEvent(QMouseEvent* event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivePlanner::moveActiveHandler(QPointF pos)
|
||||||
|
{
|
||||||
|
int idx = handles.indexOf(activeDraggedHandler);
|
||||||
|
bool moveLines = false;;
|
||||||
|
// do not allow it to move between handlers.
|
||||||
|
if (handles.count() > 1){
|
||||||
|
if (idx == 0 ){ // first
|
||||||
|
if (pos.x() < handles[1]->x()){
|
||||||
|
activeDraggedHandler->setPos(pos);
|
||||||
|
moveLines = true;
|
||||||
|
}
|
||||||
|
}else if (idx == handles.count()-1){ // last
|
||||||
|
if (pos.x() > handles[idx-1]->x()){
|
||||||
|
activeDraggedHandler->setPos(pos);
|
||||||
|
moveLines = true;
|
||||||
|
}
|
||||||
|
}else{ // middle
|
||||||
|
if (pos.x() > handles[idx-1]->x() && pos.x() < handles[idx+1]->x()){
|
||||||
|
activeDraggedHandler->setPos(pos);
|
||||||
|
moveLines = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
activeDraggedHandler->setPos(pos);
|
||||||
|
moveLines = true;
|
||||||
|
}
|
||||||
|
if (moveLines){
|
||||||
|
if (activeDraggedHandler->from){
|
||||||
|
QLineF f = activeDraggedHandler->from->line();
|
||||||
|
activeDraggedHandler->from->setLine(f.x1(), f.y1(), pos.x(), pos.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activeDraggedHandler->to){
|
||||||
|
QLineF f = activeDraggedHandler->to->line();
|
||||||
|
activeDraggedHandler->to->setLine(pos.x(), pos.y(), f.x2(), f.y2());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(activeDraggedHandler == handles.last()){
|
||||||
|
clear_generated_deco();
|
||||||
|
create_deco_stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool DivePlanner::isPointOutOfBoundaries(QPointF point)
|
bool DivePlanner::isPointOutOfBoundaries(QPointF point)
|
||||||
{
|
{
|
||||||
if (point.x() > sceneRect().width()
|
if (point.x() > sceneRect().width()
|
||||||
|
|
|
@ -29,6 +29,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DivePlanner(QWidget* parent = 0);
|
DivePlanner(QWidget* parent = 0);
|
||||||
|
void moveActiveHandler(QPointF pos);
|
||||||
QList<QGraphicsLineItem*> lines;
|
QList<QGraphicsLineItem*> lines;
|
||||||
QList<DiveHandler *> handles;
|
QList<DiveHandler *> handles;
|
||||||
QGraphicsLineItem *verticalLine;
|
QGraphicsLineItem *verticalLine;
|
||||||
|
|
Loading…
Add table
Reference in a new issue