mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
templatelayout.h: expose cylinders and weights in Grantlee HTML
This patch adds the following HTML variables: "dive.cylinders" -> Dive::cylinders() "dive.cylinderX" -> Dive::cylinder(X) "dive.weights" -> Dive::weights() "dive.weightX" -> Dive::weight(X) The patch also creates some macros to ease the Dive variable lookup visually. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
3365a506ef
commit
c78a560442
1 changed files with 49 additions and 34 deletions
|
@ -49,43 +49,58 @@ Q_DECLARE_METATYPE(template_options)
|
|||
Q_DECLARE_METATYPE(print_options)
|
||||
Q_DECLARE_METATYPE(YearInfo)
|
||||
|
||||
#define _CONC_STR(prop, idx) _CONC_STR1(prop, idx)
|
||||
#define _CONC_STR1(prop, idx) _CONC_STR2(prop ## idx)
|
||||
#define _CONC_STR2(prop) #prop
|
||||
|
||||
#define _RETURN_DIVE_PROPERTY(prop) \
|
||||
if (property == #prop) return object.prop()
|
||||
|
||||
#define _RETURN_DIVE_PROPERTY_IDX(prop, idx) \
|
||||
if (property == _CONC_STR(prop, idx)) return object.prop(idx)
|
||||
|
||||
GRANTLEE_BEGIN_LOOKUP(Dive)
|
||||
if (property == "number")
|
||||
return object.number();
|
||||
else if (property == "id")
|
||||
return object.id();
|
||||
else if (property == "date")
|
||||
return object.date();
|
||||
else if (property == "time")
|
||||
return object.time();
|
||||
else if (property == "location")
|
||||
return object.location();
|
||||
else if (property == "duration")
|
||||
return object.duration();
|
||||
else if (property == "depth")
|
||||
return object.depth();
|
||||
else if (property == "divemaster")
|
||||
return object.divemaster();
|
||||
else if (property == "buddy")
|
||||
return object.buddy();
|
||||
else if (property == "airTemp")
|
||||
return object.airTemp();
|
||||
else if (property == "waterTemp")
|
||||
return object.waterTemp();
|
||||
else if (property == "notes")
|
||||
return object.notes();
|
||||
else if (property == "rating")
|
||||
return object.rating();
|
||||
else if (property == "sac")
|
||||
return object.sac();
|
||||
else if (property == "tags")
|
||||
return object.tags();
|
||||
else if (property == "gas")
|
||||
return object.gas();
|
||||
else if (property == "suit")
|
||||
return object.suit();
|
||||
_RETURN_DIVE_PROPERTY(number);
|
||||
else _RETURN_DIVE_PROPERTY(id);
|
||||
else _RETURN_DIVE_PROPERTY(date);
|
||||
else _RETURN_DIVE_PROPERTY(time);
|
||||
else _RETURN_DIVE_PROPERTY(location);
|
||||
else _RETURN_DIVE_PROPERTY(duration);
|
||||
else _RETURN_DIVE_PROPERTY(depth);
|
||||
else _RETURN_DIVE_PROPERTY(buddy);
|
||||
else _RETURN_DIVE_PROPERTY(divemaster);
|
||||
else _RETURN_DIVE_PROPERTY(airTemp);
|
||||
else _RETURN_DIVE_PROPERTY(waterTemp);
|
||||
else _RETURN_DIVE_PROPERTY(notes);
|
||||
else _RETURN_DIVE_PROPERTY(rating);
|
||||
else _RETURN_DIVE_PROPERTY(sac);
|
||||
else _RETURN_DIVE_PROPERTY(tags);
|
||||
else _RETURN_DIVE_PROPERTY(gas);
|
||||
else _RETURN_DIVE_PROPERTY(suit);
|
||||
else _RETURN_DIVE_PROPERTY(cylinders);
|
||||
else _RETURN_DIVE_PROPERTY_IDX(cylinder, 0);
|
||||
else _RETURN_DIVE_PROPERTY_IDX(cylinder, 1);
|
||||
else _RETURN_DIVE_PROPERTY_IDX(cylinder, 2);
|
||||
else _RETURN_DIVE_PROPERTY_IDX(cylinder, 3);
|
||||
else _RETURN_DIVE_PROPERTY_IDX(cylinder, 4);
|
||||
else _RETURN_DIVE_PROPERTY_IDX(cylinder, 5);
|
||||
else _RETURN_DIVE_PROPERTY_IDX(cylinder, 6);
|
||||
else _RETURN_DIVE_PROPERTY_IDX(cylinder, 7);
|
||||
else _RETURN_DIVE_PROPERTY(weights);
|
||||
else _RETURN_DIVE_PROPERTY_IDX(weight, 0);
|
||||
else _RETURN_DIVE_PROPERTY_IDX(weight, 1);
|
||||
else _RETURN_DIVE_PROPERTY_IDX(weight, 2);
|
||||
else _RETURN_DIVE_PROPERTY_IDX(weight, 3);
|
||||
else _RETURN_DIVE_PROPERTY_IDX(weight, 4);
|
||||
else _RETURN_DIVE_PROPERTY_IDX(weight, 5);
|
||||
GRANTLEE_END_LOOKUP
|
||||
|
||||
#undef _RETURN_DIVE_PROPERTY
|
||||
#undef _RETURN_DIVE_PROPERTY_IDX
|
||||
#undef _CONC_STR
|
||||
#undef _CONC_STR1
|
||||
#undef _CONC_STR2
|
||||
|
||||
GRANTLEE_BEGIN_LOOKUP(template_options)
|
||||
if (property == "font") {
|
||||
switch (object.font_index) {
|
||||
|
|
Loading…
Add table
Reference in a new issue