diff options
author | Juergen Bocklage-Ryannel <jbocklage-ryannel@luxoft.com> | 2018-03-07 13:25:48 +0100 |
---|---|---|
committer | Juergen Bocklage-Ryannel <jbocklage-ryannel@luxoft.com> | 2018-03-07 13:30:45 +0100 |
commit | 424658eb33b96e73841af5ee231ac9459fb862be (patch) | |
tree | 860959495ff5f6c3ac54c67b54d565bd921434f5 | |
parent | aef0548e6963b163e7e0e2a35db8efa87f13ee14 (diff) |
add support for constant properties in macro lib
-rw-r--r-- | qface/templates/qface/qtcpp.j2 | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/qface/templates/qface/qtcpp.j2 b/qface/templates/qface/qtcpp.j2 index 3d248b0..84a2961 100644 --- a/qface/templates/qface/qtcpp.j2 +++ b/qface/templates/qface/qtcpp.j2 @@ -13,8 +13,8 @@ {% endif %} {%- endmacro %} -{% macro property(property) -%} -Q_PROPERTY({{property|returnType}} {{property}} READ {{property}} {% if not property.readonly %}WRITE set{{property|upperfirst}} {% endif %}{% if not property.const %}NOTIFY {{property}}Changed{% endif %}) +{% macro property(property, notifiable=True) -%} +Q_PROPERTY({{property|returnType}} {{property}} READ {{property}} {% if not property.readonly %}WRITE set{{property|upperfirst}}{% endif %}{% if not property.const and notifiable %} NOTIFY {{property}}Changed{% endif %}) {%- endmacro %} {% macro property_setter_decl(property, ending=";") -%} @@ -33,7 +33,7 @@ void {{symbol}}{{postfix}}({{symbol|parameters}}); {{property|returnType}} m_{{property}}; {%- endmacro %} -{% macro property_setter_impl(class, property) -%} +{% macro property_setter_impl(class, property, notifiable=True) -%} /*! \qmlproperty {{property.type}} {{class}}::{{property}} {% with doc = property.comment|parse_doc %} @@ -45,10 +45,15 @@ void {{symbol}}{{postfix}}({{symbol|parameters}}); void {{class}}::set{{property|upperfirst}}({{ property|parameterType }}) { +{% if notifiable %} if (m_{{property}} != {{property}}) { m_{{property}} = {{property}}; Q_EMIT {{property}}Changed({{property}}); } +{% else %} + m_{{property}} = {{property}}; +{% endif %} + } {%- endmacro %} |