summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2013-11-27 22:59:17 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-27 14:13:47 -0800
commit57fb878b41bb803aa9418f84e82aa489b5d542d3 (patch)
treeb254b6a9750c06411168a83ab0bcebc5e82029f3 /qt-ui
parentab4115791bb3b867f2bc0bbfd583238fd5210054 (diff)
downloadsubsurface-57fb878b41bb803aa9418f84e82aa489b5d542d3.tar.gz
Show/save weights up to and including last valid
Previous show and save code would have aborted at the first invalid weight system. This makes sure we save and show all weight systems up until and including the last valid. If we had: integrated: 1kg belt: 2kg ankle: 3kg And changed belt to 0 kg, we would have only saved integrated 1kg, and nothing about the belt or the ankle weights. This will save all of them, and show all of them. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/models.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 76ad6e1e5..b8909dadf 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -543,20 +543,16 @@ void WeightModel::setDive(dive* d)
{
if (current)
clear();
-
- int amount = MAX_WEIGHTSYSTEMS;
+ rows = 0;
for(int i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
- weightsystem_t *weightsystem = &d->weightsystem[i];
- if (weightsystem_none(weightsystem)) {
- amount = i;
- break;
+ if (!weightsystem_none(&d->weightsystem[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();
}
}