summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2013-11-27 22:59:16 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-27 14:13:02 -0800
commitab4115791bb3b867f2bc0bbfd583238fd5210054 (patch)
treecf822454e386a2188adc37304e66ca365743a886
parent27bfc587cfe026ac4e1b38ac32af35696f4a65a3 (diff)
downloadsubsurface-ab4115791bb3b867f2bc0bbfd583238fd5210054.tar.gz
Show cylinders up to and including the last valid
Previous code aborted at the first invalid cylinder. This instead finds the last valid and prints all the ones up until that one. Fixes #295 Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/models.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 8dfdb5c1f..76ad6e1e5 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -353,19 +353,16 @@ void CylindersModel::setDive(dive* d)
clear();
if (!d)
return;
- int amount = MAX_CYLINDERS;
+ rows = 0;
for(int i = 0; i < MAX_CYLINDERS; i++) {
- cylinder_t *cylinder = &d->cylinder[i];
- if (cylinder_none(cylinder)) {
- amount = i;
- break;
+ if (!cylinder_none(&d->cylinder[i])) {
+ rows = i+1;
}
}
- rows = amount;
current = d;
changed = false;
- if (amount > 0) {
- beginInsertRows(QModelIndex(), 0, amount - 1);
+ if (rows > 0) {
+ beginInsertRows(QModelIndex(), 0, rows-1);
endInsertRows();
}
}