mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Adds Cylinder helper class for cylinder info access in grantlee templates
to allow grantlee to access individual fields of the cylinder_t struct rather than a string representation of the whole cylinder info using a grantlee structure like this one: <table class="table_class"> <tr> <td>Cylinder</td> <td>Start press.</td> <td>End press.</td> <td>Gas mix</td> </tr> {% for cylinderObject in dive.cylinderObjects %} <tr> <td>{{ cylinderObject.description }}</td> <td>{{ cylinderObject.startPressure }}</td> <td>{{ cylinderObject.endPressure }}</td> <td>{{ cylinderObject.gasMix }}</td> </tr> {% endfor %} </table> Signed-off-by: Tim Wootton <tim@tee-jay.org.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
430f5b77c5
commit
bd40ef7f42
5 changed files with 86 additions and 0 deletions
|
@ -55,10 +55,18 @@ static QString getPressures(struct dive *dive, enum returnPressureSelector ret)
|
|||
DiveObjectHelper::DiveObjectHelper(struct dive *d) :
|
||||
m_dive(d)
|
||||
{
|
||||
m_cyls.clear();
|
||||
for (int i = 0; i < MAX_CYLINDERS; i++) {
|
||||
//Don't add blank cylinders, only those that have been defined.
|
||||
if (m_dive->cylinder[i].type.description)
|
||||
m_cyls.append(new CylinderObjectHelper(&m_dive->cylinder[i]));
|
||||
}
|
||||
}
|
||||
|
||||
DiveObjectHelper::~DiveObjectHelper()
|
||||
{
|
||||
while (!m_cyls.isEmpty())
|
||||
delete m_cyls.takeFirst();
|
||||
}
|
||||
|
||||
int DiveObjectHelper::number() const
|
||||
|
@ -275,6 +283,11 @@ QString DiveObjectHelper::cylinder(int idx) const
|
|||
return getFormattedCylinder(m_dive, idx);
|
||||
}
|
||||
|
||||
QList<CylinderObjectHelper*> DiveObjectHelper::cylinderObjects() const
|
||||
{
|
||||
return m_cyls;
|
||||
}
|
||||
|
||||
QString DiveObjectHelper::trip() const
|
||||
{
|
||||
return m_dive->divetrip ? m_dive->divetrip->location : EMPTY_DIVE_STRING;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue