core: convert weightsystem_t and weightsystem_table to C++

As for cylinders, this had to be done simultaneously,

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-29 07:03:03 +02:00 committed by bstoeger
parent 28520da655
commit 640ecb345b
28 changed files with 137 additions and 247 deletions

View file

@ -1228,11 +1228,11 @@ void QMLManager::commitChanges(QString diveId, QString number, QString date, QSt
diveChanged = true;
// not sure what we'd do if there was more than one weight system
// defined - for now just ignore that case
if (d->weightsystems.nr == 0) {
weightsystem_t ws = { { parseWeightToGrams(weight) } , strdup(qPrintable(tr("weight"))), false };
add_to_weightsystem_table(&d->weightsystems, 0, ws); // takes ownership of the string
} else if (d->weightsystems.nr == 1) {
d->weightsystems.weightsystems[0].weight.grams = parseWeightToGrams(weight);
if (d->weightsystems.size() == 0) {
weightsystem_t ws = { { parseWeightToGrams(weight) } , tr("weight").toStdString(), false };
add_to_weightsystem_table(&d->weightsystems, 0, std::move(ws));
} else if (d->weightsystems.size() == 1) {
d->weightsystems[0].weight.grams = parseWeightToGrams(weight);
}
}
// start and end pressures