summaryrefslogtreecommitdiffstats
path: root/profile-widget/divecartesianaxis.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-05-19 07:37:58 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-05-19 07:48:28 -0700
commit7836a78dca42da91abeaec9f6c28a063ddfb1716 (patch)
tree0b9aef9a98a1b6fed9576f5cc2ffd575d4cc616c /profile-widget/divecartesianaxis.cpp
parent555f2f9565c28abcbaf2fab018860b3d4cc1d434 (diff)
downloadsubsurface-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/divecartesianaxis.cpp')
-rw-r--r--profile-widget/divecartesianaxis.cpp19
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) ?