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

@ -335,10 +335,10 @@ void WSInfoDelegate::editorClosed(QWidget *, QAbstractItemDelegate::EndEditHint
void WSInfoDelegate::setModelData(QWidget *, QAbstractItemModel *, const QModelIndex &) const
{
WeightModel *mymodel = qobject_cast<WeightModel *>(currCombo.model);
QString weightName = currCombo.activeText;
weight_t weight = get_weightsystem_weight(qPrintable(weightName));
std::string weightName = currCombo.activeText.toStdString();
weight_t weight = get_weightsystem_weight(weightName.c_str());
mymodel->setTempWS(currCombo.currRow, weightsystem_t{ weight, copy_qstring(weightName), false });
mymodel->setTempWS(currCombo.currRow, weightsystem_t( weight, std::move(weightName), false ));
}
static QAbstractItemModel *createWSInfoModel(QWidget *parent)

View file

@ -356,12 +356,9 @@ void DiveComponentSelection::buttonClicked(QAbstractButton *button)
}
}
if (what->weights) {
int w;
text << tr("Weights:\n");
for (w = 0; w < current_dive->weightsystems.nr; w++) {
weightsystem_t ws = current_dive->weightsystems.weightsystems[w];
text << ws.description << ws.weight.grams / 1000 << "kg\n";
}
for (auto &ws: current_dive->weightsystems)
text << QString::fromStdString(ws.description) << ws.weight.grams / 1000 << "kg\n";
}
if (what->number)
text << tr("Dive number: ") << current_dive->number << "\n";

View file

@ -562,7 +562,7 @@ QVariant TemplateLayout::getValue(QString list, QString property, const State &s
} else if (property == "weights") {
return formatWeights(d);
} else if (property == "singleWeight") {
return d->weightsystems.nr <= 1;
return d->weightsystems.size() <= 1;
} else if (property == "suit") {
return d->suit;
} else if (property == "cylinderList") {