diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-05-19 07:37:58 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-05-19 07:48:28 -0700 |
commit | 7836a78dca42da91abeaec9f6c28a063ddfb1716 (patch) | |
tree | 0b9aef9a98a1b6fed9576f5cc2ffd575d4cc616c /profile-widget | |
parent | 555f2f9565c28abcbaf2fab018860b3d4cc1d434 (diff) | |
download | subsurface-7836a78dca42da91abeaec9f6c28a063ddfb1716.tar.gz |
Profile: minor coding style issues concerning axis-ticks
1) Fix the English of a comment.
2) Remove a number of int-to-double compares:
Make "steps" an integer variable (the number of steps).
Rename the old double "steps" variable to "stepsInRange". This gives
a non-integer number of steps and is necessary to calculate the
correct step size
3) Replace a "x = x/y" by a "x /= y" construct.
4) Remove an unnecessary if clause.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/divecartesianaxis.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/profile-widget/divecartesianaxis.cpp b/profile-widget/divecartesianaxis.cpp index d2b3b9347..e10e5112c 100644 --- a/profile-widget/divecartesianaxis.cpp +++ b/profile-widget/divecartesianaxis.cpp @@ -128,13 +128,11 @@ void DiveCartesianAxis::setLinesVisible(bool arg1) } template <typename T> -void emptyList(QList<T *> &list, double steps) +void emptyList(QList<T *> &list, int steps) { - if (!list.isEmpty() && list.size() > steps) { - while (list.size() > steps) { - T *removedItem = list.takeLast(); - Animations::animDelete(removedItem); - } + while (list.size() > steps) { + T *removedItem = list.takeLast(); + Animations::animDelete(removedItem); } } @@ -145,7 +143,8 @@ void DiveCartesianAxis::updateTicks(color_index_t color) QLineF m = line(); // unused so far: // QGraphicsView *view = scene()->views().first(); - double steps = (max - min) / interval; + double stepsInRange = (max - min) / interval; + int steps = (int)stepsInRange; double currValueText = min; double currValueLine = min; @@ -155,8 +154,8 @@ void DiveCartesianAxis::updateTicks(color_index_t color) emptyList(labels, steps); emptyList(lines, steps); - // Move the remaining Ticks / Text to it's corerct position - // Regartind the possibly new values for the Axis + // Move the remaining ticks / text to their correct positions + // regarding the possible new values for the axis qreal begin, stepSize; if (orientation == TopToBottom) { begin = m.y1(); @@ -171,7 +170,7 @@ void DiveCartesianAxis::updateTicks(color_index_t color) begin = m.x2(); stepSize = (m.x2() - m.x1()); } - stepSize = stepSize / steps; + stepSize /= stepsInRange; for (int i = 0, count = labels.size(); i < count; i++, currValueText += interval) { qreal childPos = (orientation == TopToBottom || orientation == LeftToRight) ? |