1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
{%+ macro enum_decl(enum) -%}
enum {{enum}}Enum {
{% for member in enum.members %}
{{member.name}} = {{member.value}}{% if not loop.last %},{%endif%}
{% endfor %}
};
{% if enum.is_flag %}
Q_DECLARE_FLAGS({{enum}}Enums, {{enum}}Enum)
Q_FLAG({{enum}}Enum)
{% else %}
Q_ENUM({{enum}}Enum)
{% endif %}
{%- endmacro %}
{% macro property_decl(property, notifiable=True) -%}
Q_PROPERTY({{property|qt.returnType}} {{property}} READ {{property}} {% if not property.readonly %}WRITE push{{property|upperfirst}}{% endif %}{% if not property.const and notifiable %} NOTIFY {{property}}Changed{% endif %})
{%- endmacro %}
{% macro property_pusher_decl(property, ending=";", prefix='virtual') -%}
{{prefix}} void push{{property|upperfirst}}({{ property|qt.parameterType }}){{ending}}
{%- endmacro %}
{% macro property_setter_decl(property, ending=";", prefix='virtual') -%}
{{prefix}} void set{{property|upperfirst}}({{ property|qt.parameterType }}){{ending}}
{%- endmacro %}
{% macro property_getter_decl(property, ending=";", prefix='virtual') -%}
{{prefix}} {{property|qt.returnType}} {{property}}() const{{ending}}
{%- endmacro %}
{% macro signal_decl(symbol, postfix="") -%}
void {{symbol}}{{postfix}}();
{%- endmacro %}
{% macro property_member_decl(property) -%}
{{property|qt.returnType}} m_{{property}};
{%- endmacro %}
{% macro property_pusher_impl(class, property, notifiable=True) -%}
void {{class}}::push{{property|upperfirst}}({{ property|qt.parameterType }})
{
{% if notifiable %}
if (m_{{property}} != {{property}}) {
m_{{property}} = {{property}};
Q_EMIT {{property}}Changed();
}
{% else %}
m_{{property}} = {{property}};
{% endif %}
}
{%- endmacro %}
{% macro property_setter_impl(class, property, notifiable=True) -%}
/*!
\qmlproperty {{property.type}} {{class}}::{{property}}
{% with doc = property.comment|parse_doc %}
\brief {{doc.brief|join(" ")}}
{{doc.description|join("\n ")}}
{% endwith %}
*/
void {{class}}::set{{property|upperfirst}}({{ property|qt.parameterType }})
{
{% if notifiable %}
if (m_{{property}} != {{property}}) {
m_{{property}} = {{property}};
Q_EMIT {{property}}Changed();
}
{% else %}
m_{{property}} = {{property}};
{% endif %}
}
{%- endmacro %}
{% macro property_getter_impl(class, property) -%}
{{property|qt.returnType}} {{class}}::{{property}}() const
{
return m_{{property}};
}
{%- endmacro %}
{% macro operation_impl(class, operation) -%}
/*!
\qmlmethod {{operation.type}} {{class}}::{{operation}}({{operation|qt.parameters}})
{% with doc = operation.comment|parse_doc %}
\brief {{doc.brief}}
{{doc.description|join("\n ")}}
{% endwith %}
*/
{{operation|qt.returnType}} {{class}}::{{operation}}({{operation|qt.parameters}})
{
{% for parameter in operation.parameters %}
Q_UNUSED({{parameter.name}});
{% endfor %}
qWarning() << "{{class}}::{{operation}}(...) not implemented";
return {{operation|qt.defaultValue}};
}
{%- endmacro %}
{% macro operation_decl(operation, ending=";") -%}
virtual {{operation|qt.returnType}} {{operation}}({{operation|qt.parameters}}){{ending}}
{%- endmacro %}
{% macro autogenerated(prefix="//") -%}
{{prefix}} This is an auto-generated file.
{{prefix}} Do not edit! All changes made to it will be lost.
{%- endmacro %}
{% macro preserved(prefix="//") -%}
{{prefix}} This is a preserved file.
{{prefix}} Changes will not be overriden by the generator.
{{prefix}} To reset the file you need to delete it first.
{%- endmacro %}
|