printing: remove DiveObjectHelperGrantlee

This was a weird helper object, needed for grantlee. Instead
of storing this object, loop over cylinders and dives directly.

The actual accessor function is unchanged and now generates
a DiveObjectHelper or DiveCylinderHelper for every variable
access. Obviously, this is very inefficient. However, this
will be replaced in future commits by direct calls to formatting
functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-12-14 23:21:58 +01:00 committed by Dirk Hohndel
parent bf8261c001
commit d9942269a9
6 changed files with 42 additions and 69 deletions

View file

@ -143,3 +143,24 @@ QStringList formatFullCylinderList()
return cylinders;
}
static QString formattedCylinder(const struct dive *dive, int idx)
{
const cylinder_t *cyl = get_cylinder(dive, idx);
const char *desc = cyl->type.description;
QString fmt = desc ? QString(desc) : gettextFromC::tr("unknown");
fmt += ", " + get_volume_string(cyl->type.size, true);
fmt += ", " + get_pressure_string(cyl->type.workingpressure, true);
fmt += ", " + get_pressure_string(cyl->start, false) + " - " + get_pressure_string(cyl->end, true);
fmt += ", " + get_gas_string(cyl->gasmix);
return fmt;
}
QStringList formatCylinders(const dive *d)
{
QStringList cylinders;
for (int i = 0; i < d->cylinders.nr; i++) {
QString cyl = formattedCylinder(d, i);
cylinders << cyl;
}
return cylinders;
}