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:
Dirk Hohndel 2013-06-23 13:09:29 -07:00
parent 31449dca22
commit 106775b196
2 changed files with 76 additions and 77 deletions

View file

@ -71,9 +71,8 @@ void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event)
if (isPointOutOfBoundaries(mappedPos))
return;
if(handles.count() && handles.last()->x() > mappedPos.x()){
if (handles.count() && handles.last()->x() > mappedPos.x())
return;
}
DiveHandler *item = new DiveHandler ();
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());
item->from = first;
lines.push_back(first);
create_deco_stop();
createDecoStops();
scene()->addItem(first);
} else {
clear_generated_deco();
clearGeneratedDeco();
DiveHandler *prevHandle = handles.at(handles.count()-2);
QGraphicsLineItem *line = new QGraphicsLineItem(prevHandle->x(), prevHandle->y(), item->x(), item->y());
prevHandle->to = line;
item->from = line;
lines.push_back(line);
scene()->addItem(line);
create_deco_stop();
createDecoStops();
}
item->time = (timeLine->valueAt(mappedPos));
item->depth = (depthLine->valueAt(mappedPos));
}
void DivePlannerGraphics::clear_generated_deco()
void DivePlannerGraphics::clearGeneratedDeco()
{
for (int i = handles.count(); i <= lines.count(); i++) {
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:
// Get the user-input and calculate the dive info
@ -231,8 +230,8 @@ void DivePlannerGraphics::moveActiveHandler(const QPointF& pos)
}
if (activeDraggedHandler == handles.last()) {
clear_generated_deco();
create_deco_stop();
clearGeneratedDeco();
createDecoStops();
}
}
}
@ -242,10 +241,10 @@ bool DivePlannerGraphics::isPointOutOfBoundaries(const QPointF& point)
double xpos = timeLine->valueAt(point);
double ypos = depthLine->valueAt(point);
if (xpos > timeLine->maximum()
|| xpos < timeLine->minimum()
|| ypos > depthLine->maximum()
|| ypos < depthLine->minimum())
if (xpos > timeLine->maximum() ||
xpos < timeLine->minimum() ||
ypos > depthLine->maximum() ||
ypos < depthLine->minimum())
{
return true;
}
@ -326,9 +325,9 @@ void Ruler::setTickInterval(double i)
qreal Ruler::valueAt(const QPointF& p)
{
QLineF m = line();
double retValue = orientation == Qt::Horizontal
? max * (p.x() - m.x1()) / (m.x2() - m.x1())
: max * (p.y() - m.y1()) / (m.y2() - m.y1());
double retValue = orientation == Qt::Horizontal ?
max * (p.x() - m.x1()) / (m.x2() - m.x1()) :
max * (p.y() - m.y1()) / (m.y2() - m.y1());
return retValue;
}
@ -337,13 +336,13 @@ qreal Ruler::posAtValue(qreal value)
QLineF m = line();
double size = max - min;
double percent = value / size;
double realSize = orientation == Qt::Horizontal
? m.x2() - m.x1()
: m.y2() - m.y1();
double realSize = orientation == Qt::Horizontal ?
m.x2() - m.x1() :
m.y2() - m.y1();
double retValue = realSize * percent;
retValue = (orientation == Qt::Horizontal)
? retValue + m.x1()
: retValue + m.y1();
retValue = (orientation == Qt::Horizontal) ?
retValue + m.x1() :
retValue + m.y1();
return retValue;
}

View file

@ -59,8 +59,8 @@ protected:
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);
void clear_generated_deco();
void create_deco_stop();
void clearGeneratedDeco();
void createDecoStops();
bool isPointOutOfBoundaries(const QPointF& point);
private slots: