mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Clean up coding style
Just to keep me sane. The code still shows compile time warnings which are the areas where we need to complete things to actually do the deco calculations, etc. But now seemed a good time to merge it into master as hopefully more people can contribute. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
31449dca22
commit
106775b196
2 changed files with 76 additions and 77 deletions
|
@ -71,9 +71,8 @@ void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
if (isPointOutOfBoundaries(mappedPos))
|
if (isPointOutOfBoundaries(mappedPos))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(handles.count() && handles.last()->x() > mappedPos.x()){
|
if (handles.count() && handles.last()->x() > mappedPos.x())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
DiveHandler *item = new DiveHandler ();
|
DiveHandler *item = new DiveHandler ();
|
||||||
item->setRect(-5,-5,10,10);
|
item->setRect(-5,-5,10,10);
|
||||||
|
@ -91,23 +90,23 @@ void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
QGraphicsLineItem *first = new QGraphicsLineItem(xpos,ypos, mappedPos.x(), mappedPos.y());
|
QGraphicsLineItem *first = new QGraphicsLineItem(xpos,ypos, mappedPos.x(), mappedPos.y());
|
||||||
item->from = first;
|
item->from = first;
|
||||||
lines.push_back(first);
|
lines.push_back(first);
|
||||||
create_deco_stop();
|
createDecoStops();
|
||||||
scene()->addItem(first);
|
scene()->addItem(first);
|
||||||
} else {
|
} else {
|
||||||
clear_generated_deco();
|
clearGeneratedDeco();
|
||||||
DiveHandler *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());
|
QGraphicsLineItem *line = new QGraphicsLineItem(prevHandle->x(), prevHandle->y(), item->x(), item->y());
|
||||||
prevHandle->to = line;
|
prevHandle->to = line;
|
||||||
item->from = line;
|
item->from = line;
|
||||||
lines.push_back(line);
|
lines.push_back(line);
|
||||||
scene()->addItem(line);
|
scene()->addItem(line);
|
||||||
create_deco_stop();
|
createDecoStops();
|
||||||
}
|
}
|
||||||
item->time = (timeLine->valueAt(mappedPos));
|
item->time = (timeLine->valueAt(mappedPos));
|
||||||
item->depth = (depthLine->valueAt(mappedPos));
|
item->depth = (depthLine->valueAt(mappedPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePlannerGraphics::clear_generated_deco()
|
void DivePlannerGraphics::clearGeneratedDeco()
|
||||||
{
|
{
|
||||||
for (int i = handles.count(); i <= lines.count(); i++) {
|
for (int i = handles.count(); i <= lines.count(); i++) {
|
||||||
scene()->removeItem(lines.last());
|
scene()->removeItem(lines.last());
|
||||||
|
@ -116,7 +115,7 @@ void DivePlannerGraphics::clear_generated_deco()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePlannerGraphics::create_deco_stop()
|
void DivePlannerGraphics::createDecoStops()
|
||||||
{
|
{
|
||||||
// This needs to be done in the following steps:
|
// This needs to be done in the following steps:
|
||||||
// Get the user-input and calculate the dive info
|
// Get the user-input and calculate the dive info
|
||||||
|
@ -231,8 +230,8 @@ void DivePlannerGraphics::moveActiveHandler(const QPointF& pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activeDraggedHandler == handles.last()) {
|
if (activeDraggedHandler == handles.last()) {
|
||||||
clear_generated_deco();
|
clearGeneratedDeco();
|
||||||
create_deco_stop();
|
createDecoStops();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,10 +241,10 @@ bool DivePlannerGraphics::isPointOutOfBoundaries(const QPointF& point)
|
||||||
double xpos = timeLine->valueAt(point);
|
double xpos = timeLine->valueAt(point);
|
||||||
double ypos = depthLine->valueAt(point);
|
double ypos = depthLine->valueAt(point);
|
||||||
|
|
||||||
if (xpos > timeLine->maximum()
|
if (xpos > timeLine->maximum() ||
|
||||||
|| xpos < timeLine->minimum()
|
xpos < timeLine->minimum() ||
|
||||||
|| ypos > depthLine->maximum()
|
ypos > depthLine->maximum() ||
|
||||||
|| ypos < depthLine->minimum())
|
ypos < depthLine->minimum())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -326,9 +325,9 @@ void Ruler::setTickInterval(double i)
|
||||||
qreal Ruler::valueAt(const QPointF& p)
|
qreal Ruler::valueAt(const QPointF& p)
|
||||||
{
|
{
|
||||||
QLineF m = line();
|
QLineF m = line();
|
||||||
double retValue = orientation == Qt::Horizontal
|
double retValue = orientation == Qt::Horizontal ?
|
||||||
? max * (p.x() - m.x1()) / (m.x2() - m.x1())
|
max * (p.x() - m.x1()) / (m.x2() - m.x1()) :
|
||||||
: max * (p.y() - m.y1()) / (m.y2() - m.y1());
|
max * (p.y() - m.y1()) / (m.y2() - m.y1());
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,13 +336,13 @@ qreal Ruler::posAtValue(qreal value)
|
||||||
QLineF m = line();
|
QLineF m = line();
|
||||||
double size = max - min;
|
double size = max - min;
|
||||||
double percent = value / size;
|
double percent = value / size;
|
||||||
double realSize = orientation == Qt::Horizontal
|
double realSize = orientation == Qt::Horizontal ?
|
||||||
? m.x2() - m.x1()
|
m.x2() - m.x1() :
|
||||||
: m.y2() - m.y1();
|
m.y2() - m.y1();
|
||||||
double retValue = realSize * percent;
|
double retValue = realSize * percent;
|
||||||
retValue = (orientation == Qt::Horizontal)
|
retValue = (orientation == Qt::Horizontal) ?
|
||||||
? retValue + m.x1()
|
retValue + m.x1() :
|
||||||
: retValue + m.y1();
|
retValue + m.y1();
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,8 @@ protected:
|
||||||
virtual void mousePressEvent(QMouseEvent* event);
|
virtual void mousePressEvent(QMouseEvent* event);
|
||||||
virtual void mouseReleaseEvent(QMouseEvent* event);
|
virtual void mouseReleaseEvent(QMouseEvent* event);
|
||||||
|
|
||||||
void clear_generated_deco();
|
void clearGeneratedDeco();
|
||||||
void create_deco_stop();
|
void createDecoStops();
|
||||||
bool isPointOutOfBoundaries(const QPointF& point);
|
bool isPointOutOfBoundaries(const QPointF& point);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
Loading…
Add table
Reference in a new issue