core: move add_to_weightsystem_table() to weightsystem_table

Feels natural in a C++ code base.

In analogy to other tables, this creates a struct that derives
from std::vector<>. This is generally frowned upon, but it works
and is the pragmatic thing for now. If someone wants to "fix" that,
they may just do it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-07-01 21:54:59 +02:00 committed by bstoeger
parent 498302dcc6
commit 650fda3221
4 changed files with 8 additions and 7 deletions

View file

@ -1228,7 +1228,7 @@ void QMLManager::commitChanges(QString diveId, QString number, QString date, QSt
// defined - for now just ignore that case
if (d->weightsystems.size() == 0) {
weightsystem_t ws = { { parseWeightToGrams(weight) } , tr("weight").toStdString(), false };
add_to_weightsystem_table(&d->weightsystems, 0, std::move(ws));
d->weightsystems.add(0, std::move(ws));
} else if (d->weightsystems.size() == 1) {
d->weightsystems[0].weight.grams = parseWeightToGrams(weight);
}