Changeset View
Changeset View
Standalone View
Standalone View
file_templates/classes/qobject_pimpl/class.cpp
1 | {% extends "cpp_implementation.cpp" %} | 1 | {% extends "cpp_qobject_pimpl_implementation.cpp" %} | ||
---|---|---|---|---|---|
2 | {% load kdev_filters %} | | |||
3 | | ||||
4 | {% block includes %} | | |||
5 | #include "{{ output_file_header }}" | | |||
6 | #include "{{ output_file_privateheader }}" | | |||
7 | {% endblock includes %} | | |||
8 | | ||||
9 | | ||||
10 | {% block extra_definitions %} | | |||
11 | | ||||
12 | {% for method in private_functions %} | | |||
13 | {% with name|add:"Private" as name %} | | |||
14 | | ||||
15 | {% include "method_definition_cpp.txt" %} | | |||
16 | { | | |||
17 | {% if method.type %} | | |||
18 | return {{ method.default_return_value }}; | | |||
19 | {% endif %} | | |||
20 | } | | |||
21 | | ||||
22 | {% endwith %} | | |||
23 | {% endfor %} | | |||
24 | | ||||
25 | {% endblock extra_definitions %} | | |||
26 | | ||||
27 | {% block function_definitions %} | | |||
28 | | ||||
29 | {% for method in public_functions %} | | |||
30 | {% with method.arguments as arguments %} | | |||
31 | | ||||
32 | {% include "method_definition_cpp.txt" %} | | |||
33 | {% if method.isConstructor %} | | |||
34 | {% with arguments|first as argFirst %} | | |||
35 | {# copy constructor? #} | | |||
36 | {% if arguments|length == 1 and argFirst.type == method.name|arg_type %} | | |||
37 | : d_ptr(new {{ name }}Private(*{{ argFirst.name }}.d_ptr)) | | |||
38 | {% else %} | | |||
39 | : d_ptr(new {{ name }}Private()) | | |||
40 | {% endif %} | | |||
41 | {% endwith %} | | |||
42 | {% endif %} | | |||
43 | { | | |||
44 | {% if method.isDestructor %} | | |||
45 | delete d_ptr; | | |||
46 | {% endif %} | | |||
47 | {% if method.type %}return {{ method.default_return_value }}; | | |||
48 | {% endif %} | | |||
49 | } | | |||
50 | | ||||
51 | {% endwith %} | | |||
52 | {% endfor %} | | |||
53 | | ||||
54 | {% for method in protected_functions %} | | |||
55 | {% with method.arguments as arguments %} | | |||
56 | | ||||
57 | {% include "method_definition_cpp.txt" %} | | |||
58 | {% if method.isConstructor %} | | |||
59 | {% with arguments|first as argFirst %} | | |||
60 | {# copy constructor? #} | | |||
61 | {% if arguments|length == 1 and argFirst.type == method.name|arg_type %} | | |||
62 | : d_ptr(new {{ name }}Private(*{{ argFirst.name }}.d_ptr)) | | |||
63 | {% else %} | | |||
64 | : d_ptr(new {{ name }}Private()) | | |||
65 | {% endif %} | | |||
66 | {% endwith %} | | |||
67 | {% endif %} | | |||
68 | { | | |||
69 | {% if method.isDestructor %} | | |||
70 | delete d_ptr; | | |||
71 | {% endif %} | | |||
72 | {% if method.type %}return {{ method.default_return_value }}; | | |||
73 | {% endif %} | | |||
74 | } | | |||
75 | | ||||
76 | {% endwith %} | | |||
77 | {% endfor %} | | |||
78 | | ||||
79 | {% for property in members %} | | |||
80 | | ||||
81 | | ||||
82 | {% include "class_property_getter_definition_cpp.txt" %} | | |||
83 | { | | |||
84 | Q_D(const {{ name }}); | | |||
85 | return d->{{ property.name }}; | | |||
86 | } | | |||
87 | | ||||
88 | | ||||
89 | {% include "class_property_setter_definition_cpp.txt" %} | | |||
90 | { | | |||
91 | Q_D({{ name }}); | | |||
92 | if (d->{{ property.name }} == {{ property.name }}) { | | |||
93 | return; | | |||
94 | } | | |||
95 | | ||||
96 | | ||||
97 | d->{{ property.name }} = {{ property.name }}; | | |||
98 | emit {{ property.name }}Changed(d->{{ property.name }}); | | |||
99 | } | | |||
100 | | ||||
101 | {% endfor %} | | |||
102 | | ||||
103 | {% endblock function_definitions %} | |