While at Akademy I have been doing some Grantlee work on adding support for enumerations in string templates.
This was some fun stuff digging into the possibilities in QMetaEnum and using some undocumented API for supporting enums in the Qt namespace.
The resulting possibilities are already in the Grantlee API documentation.
{% ifequal document.alignment Qt.AlignRight %}
Right aligned
{% endifequal %}
{% ifequal myObject.property MyClass.Thing2 %}
Is Thing2
{% endifequal %}
Alignment is {{ document.alignment.key }}. // Outputs "Alignment is AlignRight", for example.
This is a feature it would be nice to see in QML. Hopefully I can convince the QML developers to add enum support.
July 4, 2010 at 9:11 pm |
[...] Steveire’s Blog Just another WordPress.com weblog « Grantlee gets enum support [...]