From bd40ef7f424604013e1fe1b5feea648ab6304b72 Mon Sep 17 00:00:00 2001 From: Tim Wootton Date: Sun, 31 Jul 2016 22:27:07 +0100 Subject: 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: {% for cylinderObject in dive.cylinderObjects %} {% endfor %}
Cylinder Start press. End press. Gas mix
{{ cylinderObject.description }} {{ cylinderObject.startPressure }} {{ cylinderObject.endPressure }} {{ cylinderObject.gasMix }}
Signed-off-by: Tim Wootton Signed-off-by: Dirk Hohndel --- core/subsurface-qt/CylinderObjectHelper.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 core/subsurface-qt/CylinderObjectHelper.h (limited to 'core/subsurface-qt/CylinderObjectHelper.h') diff --git a/core/subsurface-qt/CylinderObjectHelper.h b/core/subsurface-qt/CylinderObjectHelper.h new file mode 100644 index 000000000..c523eee20 --- /dev/null +++ b/core/subsurface-qt/CylinderObjectHelper.h @@ -0,0 +1,31 @@ +#ifndef CYLINDER_QOBJECT_H +#define CYLINDER_QOBJECT_H + +#include "../dive.h" +#include +#include + +class CylinderObjectHelper : public QObject { + Q_OBJECT + Q_PROPERTY(QString description READ description CONSTANT) + Q_PROPERTY(QString size READ size CONSTANT) + Q_PROPERTY(QString workingPressure READ workingPressure CONSTANT) + Q_PROPERTY(QString startPressure READ startPressure CONSTANT) + Q_PROPERTY(QString endPressure READ endPressure CONSTANT) + Q_PROPERTY(QString gasMix READ gasMix CONSTANT) +public: + CylinderObjectHelper(cylinder_t *cylinder = NULL); + ~CylinderObjectHelper(); + QString description() const; + QString size() const; + QString workingPressure() const; + QString startPressure() const; + QString endPressure() const; + QString gasMix() const; + +private: + cylinder_t *m_cyl; +}; + + Q_DECLARE_METATYPE(CylinderObjectHelper *) +#endif \ No newline at end of file -- cgit v1.2.3-70-g09d2