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
parent 3bfbf12b9a
commit 5f36c8ccde
13 changed files with 77 additions and 106 deletions

View file

@ -7,12 +7,12 @@
QVariant TankInfoModel::data(const QModelIndex &index, int role) const
{
if (index.row() < 0 || index.row() >= tank_info_table.nr)
if (index.row() < 0 || index.row() >= (int)tank_info_table.size())
return QVariant();
if (role == Qt::FontRole)
return defaultModelFont();
if (role == Qt::DisplayRole || role == Qt::EditRole) {
const struct tank_info &info = tank_info_table.infos[index.row()];
const struct tank_info &info = tank_info_table[index.row()];
int ml = info.ml;
double bar = (info.psi) ? psi_to_bar(info.psi) : info.bar;
@ -25,7 +25,7 @@ QVariant TankInfoModel::data(const QModelIndex &index, int role) const
case ML:
return ml;
case DESCRIPTION:
return info.name;
return QString::fromStdString(info.name);
}
}
return QVariant();
@ -33,7 +33,7 @@ QVariant TankInfoModel::data(const QModelIndex &index, int role) const
int TankInfoModel::rowCount(const QModelIndex&) const
{
return tank_info_table.nr;
return (int)tank_info_table.size();
}
TankInfoModel::TankInfoModel(QObject *parent) : CleanerTableModel(parent)