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:
Tim Wootton 2016-07-31 22:27:07 +01:00 committed by Dirk Hohndel
parent 430f5b77c5
commit bd40ef7f42
5 changed files with 86 additions and 0 deletions

View file

@ -2,6 +2,7 @@
#define DIVE_QOBJECT_H
#include "../dive.h"
#include "CylinderObjectHelper.h"
#include <QObject>
#include <QString>
#include <QStringList>
@ -34,6 +35,7 @@ class DiveObjectHelper : public QObject {
Q_PROPERTY(QString suit READ suit CONSTANT)
Q_PROPERTY(QString cylinderList READ cylinderList CONSTANT)
Q_PROPERTY(QStringList cylinders READ cylinders CONSTANT)
Q_PROPERTY(QList<CylinderObjectHelper*> cylinderObjects READ cylinderObjects CONSTANT)
Q_PROPERTY(QString trip READ trip CONSTANT)
Q_PROPERTY(QString tripMeta READ tripMeta CONSTANT)
Q_PROPERTY(int maxcns READ maxcns CONSTANT)
@ -77,6 +79,7 @@ public:
QString cylinderList() const;
QStringList cylinders() const;
QString cylinder(int idx) const;
QList<CylinderObjectHelper*> cylinderObjects() const;
QString trip() const;
QString tripMeta() const;
int maxcns() const;
@ -92,6 +95,7 @@ public:
private:
struct dive *m_dive;
QList<CylinderObjectHelper*> m_cyls;
};
Q_DECLARE_METATYPE(DiveObjectHelper *)