mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Make it possible to add a handler between others
Make it possible to add a handler between others, someone asked why I didn't make like this from the beginning, the answer is that I wanted to have something stable before messing a bit more with the planner, but since the planer is almost-stable, I added. :) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
55f8979160
commit
603d2f5cb3
1 changed files with 18 additions and 8 deletions
|
@ -18,6 +18,10 @@
|
||||||
#define MAX_DEEPNESS 150
|
#define MAX_DEEPNESS 150
|
||||||
#define MIN_DEEPNESS 40
|
#define MIN_DEEPNESS 40
|
||||||
|
|
||||||
|
bool handlerLessThenMinutes(DiveHandler *d1, DiveHandler *d2){
|
||||||
|
return d1->sec < d2->sec;
|
||||||
|
}
|
||||||
|
|
||||||
DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent), activeDraggedHandler(0),
|
DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent), activeDraggedHandler(0),
|
||||||
lastValidPos(0.0, 0.0)
|
lastValidPos(0.0, 0.0)
|
||||||
{
|
{
|
||||||
|
@ -163,21 +167,25 @@ void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
if (isPointOutOfBoundaries(mappedPos))
|
if (isPointOutOfBoundaries(mappedPos))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (handles.count() && handles.last()->x() > mappedPos.x())
|
|
||||||
return;
|
|
||||||
|
|
||||||
DiveHandler *item = new DiveHandler ();
|
|
||||||
item->setRect(-5,-5,10,10);
|
|
||||||
item->setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
|
||||||
int minutes = rint(timeLine->valueAt(mappedPos));
|
int minutes = rint(timeLine->valueAt(mappedPos));
|
||||||
int meters = rint(depthLine->valueAt(mappedPos));
|
int meters = rint(depthLine->valueAt(mappedPos));
|
||||||
item->sec = minutes * 60;
|
|
||||||
item->mm = meters * 1000;
|
|
||||||
double xpos = timeLine->posAtValue(minutes);
|
double xpos = timeLine->posAtValue(minutes);
|
||||||
double ypos = depthLine->posAtValue(meters);
|
double ypos = depthLine->posAtValue(meters);
|
||||||
|
Q_FOREACH(DiveHandler* handler, handles){
|
||||||
|
if (xpos == handler->pos().x()){
|
||||||
|
qDebug() << "There's already an point at that place.";
|
||||||
|
//TODO: Move this later to a KMessageWidget.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DiveHandler *item = new DiveHandler ();
|
||||||
|
item->sec = minutes * 60;
|
||||||
|
item->mm = meters * 1000;
|
||||||
item->setPos(QPointF(xpos, ypos));
|
item->setPos(QPointF(xpos, ypos));
|
||||||
scene()->addItem(item);
|
scene()->addItem(item);
|
||||||
handles << item;
|
handles << item;
|
||||||
|
qSort(handles.begin(), handles.end(), handlerLessThenMinutes);
|
||||||
createDecoStops();
|
createDecoStops();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,6 +411,8 @@ void DivePlannerGraphics::mouseReleaseEvent(QMouseEvent* event)
|
||||||
|
|
||||||
DiveHandler::DiveHandler(): QGraphicsEllipseItem(), from(0), to(0)
|
DiveHandler::DiveHandler(): QGraphicsEllipseItem(), from(0), to(0)
|
||||||
{
|
{
|
||||||
|
setRect(-5,-5,10,10);
|
||||||
|
setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
||||||
setBrush(Qt::white);
|
setBrush(Qt::white);
|
||||||
setZValue(2);
|
setZValue(2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue