core: use C++ structures for tanksystem info

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-03 23:18:45 +02:00 committed by bstoeger
parent 1af00703b3
commit 3c1401785b
13 changed files with 93 additions and 123 deletions

View file

@ -219,9 +219,7 @@ void TankInfoDelegate::setModelData(QWidget *, QAbstractItemModel *model, const
return;
}
volume_t tankSize = {0};
pressure_t tankPressure = {0};
get_tank_info_data(&tank_info_table, qPrintable(cylinderName), &tankSize, &tankPressure);
auto [tankSize, tankPressure] = get_tank_info_data(tank_info_table, cylinderName.toStdString());
mymodel->setData(IDX(CylindersModel::TYPE), cylinderName, CylindersModel::TEMP_ROLE);
mymodel->setData(IDX(CylindersModel::WORKINGPRESS), tankPressure.mbar, CylindersModel::TEMP_ROLE);
mymodel->setData(IDX(CylindersModel::SIZE), tankSize.mliter, CylindersModel::TEMP_ROLE);

View file

@ -26,11 +26,12 @@ void PreferencesEquipment::refreshSettings()
ui->include_unused_tanks->setChecked(prefs.include_unused_tanks);
ui->display_default_tank_infos->setChecked(prefs.display_default_tank_infos);
ui->default_cylinder->clear();
for (int i = 0; i < tank_info_table.nr; i++) {
const tank_info &ti = tank_info_table.infos[i];
ui->default_cylinder->addItem(ti.name);
if (qPrefEquipment::default_cylinder() == ti.name)
int i = 0;
for (const tank_info &ti: tank_info_table) {
ui->default_cylinder->addItem(QString::fromStdString(ti.name));
if (qPrefEquipment::default_cylinder() == QString::fromStdString(ti.name))
ui->default_cylinder->setCurrentIndex(i);
++i;
}
}
@ -45,5 +46,5 @@ void PreferencesEquipment::syncSettings()
// reset the tank_info_table. It is somewhat questionable
// to do this here. Moreover, it is a bit crude, as this
// will be called for *any* preferences change.
reset_tank_info_table(&tank_info_table);
reset_tank_info_table(tank_info_table);
}