diff --git a/file_templates/CMakeLists.txt b/file_templates/CMakeLists.txt --- a/file_templates/CMakeLists.txt +++ b/file_templates/CMakeLists.txt @@ -27,6 +27,13 @@ common/method_definition_cpp.txt common/license_header_cpp.txt common/class_declaration_cpp.txt + common/class_declaration_apidox_cpp.txt + common/class_method_declaration_cpp.txt + common/class_method_declaration_apidox_cpp.txt + common/class_property_setter_declaration_cpp.txt + common/class_property_setter_declaration_apidox_cpp.txt + common/class_property_getter_declaration_cpp.txt + common/class_property_getter_declaration_apidox_cpp.txt common/cpp_header.h common/cpp_header_onlyfunctions.h common/cpp_implementation.cpp diff --git a/file_templates/classes/qobject/class.h b/file_templates/classes/qobject/class.h --- a/file_templates/classes/qobject/class.h +++ b/file_templates/classes/qobject/class.h @@ -13,6 +13,7 @@ {% if base_classes %} {{ block.super }} {% else %} +{% include "class_declaration_apidox_cpp.txt" %} class {{ name }} : public QObject { {% endif %} @@ -29,36 +30,53 @@ public: {% endif %} {% for method in public_functions %} - {% include "method_declaration_cpp.txt" %} + + {% include "class_method_declaration_apidox_cpp.txt" %} + {% include "class_method_declaration_cpp.txt" %} + {% endfor %} {% for property in members %} - {{ property.type }} {{ property.name }}() const; + + {% include "class_property_getter_declaration_apidox_cpp.txt" %} + {% include "class_property_getter_declaration_cpp.txt" %} + {% endfor %} {% if members %} public Q_SLOTS: {% for property in members %} - void set{{ property.name|upper_first }}({{ property.type|arg_type }} {{ property.name }}); + + {% include "class_property_setter_declaration_apidox_cpp.txt" %} + {% include "class_property_setter_declaration_cpp.txt" %} + {% endfor %} {% endif %} {% if protected_functions %} protected: {% for method in protected_functions %} - {% include "method_declaration_cpp.txt" %} + + {% include "class_method_declaration_apidox_cpp.txt" %} + {% include "class_method_declaration_cpp.txt" %} + {% endfor %} {% endif %} +{% if private_functions or members %} private: {% for method in private_functions %} - {% include "method_declaration.txt" %} + + {% include "class_method_declaration_apidox_cpp.txt" %} + {% include "class_method_declaration_cpp.txt" %} + {% endfor %} {% for property in members %} {{property.type}} m_{{property.name}}; {% endfor %} +{% endif %} {% endblock class_body %} diff --git a/file_templates/classes/qt_interface/interface.h b/file_templates/classes/qt_interface/interface.h --- a/file_templates/classes/qt_interface/interface.h +++ b/file_templates/classes/qt_interface/interface.h @@ -20,13 +20,20 @@ {% for method in public_functions %} {# skipping any defined destructor #} {% if not method.isDestructor %} - {% include "method_declaration_cpp.txt" %} + + {% include "class_method_declaration_apidox_cpp.txt" %} + {% include "class_method_declaration_cpp.txt" %} + {% endif %} {% endfor %} {% for property in members %} + {% include "class_property_getter_declaration_apidox_cpp.txt" %} virtual {{ property.type }} {{ property.name }}() const = 0; + + + {% include "class_property_setter_declaration_apidox_cpp.txt" %} virtual void set{{ property.name|upper_first }}({{ property.type|arg_type }} {{ property.name }}) = 0; {% endfor %} @@ -36,7 +43,10 @@ {% for method in protected_functions %} {# skipping any defined destructor #} {% if not method.isDestructor %} - {% include "method_declaration_cpp.txt" %} + + {% include "class_method_declaration_apidox_cpp.txt" %} + {% include "class_method_declaration_cpp.txt" %} + {% endif %} {% endfor %} {% endif %} @@ -46,7 +56,10 @@ {% for method in private_functions %} {# skipping any defined destructor #} {% if not method.isDestructor %} - {% include "method_declaration.txt" %} + + {% include "class_method_declaration_apidox_cpp.txt" %} + {% include "class_method_declaration_cpp.txt" %} + {% endif %} {% endfor %} {% endif %} diff --git a/file_templates/classes/qt_shared/class.h b/file_templates/classes/qt_shared/class.h --- a/file_templates/classes/qt_shared/class.h +++ b/file_templates/classes/qt_shared/class.h @@ -12,13 +12,20 @@ {% block class_body %} {{ block.super }} +{% if members %} -{% for member in members %} +public: +{% for property in members %} - {{ member.type }} {{ member.name }}() const; - void set{{ member.name|capfirst }}({{ member.type|arg_type }} {{ member.name }}); + {% include "class_property_getter_declaration_apidox_cpp.txt" %} + {% include "class_property_getter_declaration_cpp.txt" %} + + + {% include "class_property_setter_declaration_apidox_cpp.txt" %} + {% include "class_property_setter_declaration_cpp.txt" %} {% endfor %} +{% endif %} private: QSharedDataPointer<{{ name }}Data> d; diff --git a/file_templates/classes/qt_shared/class.cpp b/file_templates/classes/qt_shared/class.cpp --- a/file_templates/classes/qt_shared/class.cpp +++ b/file_templates/classes/qt_shared/class.cpp @@ -11,7 +11,7 @@ { public: {% for member in members %} -{{ member.type }} {{ member.name }}; + {{ member.type }} {{ member.name }}; {% endfor %} }; diff --git a/file_templates/classes/qt_widget/class.h b/file_templates/classes/qt_widget/class.h --- a/file_templates/classes/qt_widget/class.h +++ b/file_templates/classes/qt_widget/class.h @@ -8,9 +8,13 @@ {% block class_body %} Q_OBJECT + + {{ block.super }} +{% if not private_members and not private_functions %} private: +{% endif %} Ui::{{ name }}* ui; {% endblock class_body %} diff --git a/file_templates/common/class_declaration_apidox_cpp.txt b/file_templates/common/class_declaration_apidox_cpp.txt new file mode 100644 --- /dev/null +++ b/file_templates/common/class_declaration_apidox_cpp.txt @@ -0,0 +1,4 @@ +{# Template for api dox in front of class declaration #} +/** + * @todo write docs + */ diff --git a/file_templates/common/class_declaration_cpp.txt b/file_templates/common/class_declaration_cpp.txt --- a/file_templates/common/class_declaration_cpp.txt +++ b/file_templates/common/class_declaration_cpp.txt @@ -1 +1 @@ -class {{ name }}{% if base_classes %} :{% for base in base_clasess %} {{ base.inheritanceType }} {{ base.baseName }}{% if not forloop.last %}, {% endif %}{% endfor %}{% endif %} +class {{ name }}{% if base_classes %} :{% for base in base_classes %} {{ base.inheritanceMode }} {{ base.baseType }}{% if not forloop.last %}, {% endif %}{% endfor %}{% endif %} diff --git a/file_templates/common/class_method_declaration_apidox_cpp.txt b/file_templates/common/class_method_declaration_apidox_cpp.txt new file mode 100644 --- /dev/null +++ b/file_templates/common/class_method_declaration_apidox_cpp.txt @@ -0,0 +1,23 @@ +{# Template for api dox in front of class method declaration #} +{% with method.arguments as arguments %} + {# standard four spaces indentation to match context #} + /** + {% if method.isConstructor %} + * {% if not arguments %}Default constructor{% else %}Constructor{% endif %} + {% elif method.isDestructor %} + * Destructor + {% else %} + * @todo write docs + {% endif %} + {# and > or, so we go here if arguments or (returntype and not constructor/destructor) #} + {% if arguments or method.returnType and not method.isConstructor and not method.isDestructor %} + * + {% endif %} + {% for argument in arguments %} + * @param {{ argument.name }} TODO + {% endfor %} + {% if method.returnType and not method.isConstructor and not method.isDestructor %} + * @return TODO + {% endif %} + */ +{% endwith %} diff --git a/file_templates/common/class_method_declaration_cpp.txt b/file_templates/common/class_method_declaration_cpp.txt new file mode 100644 --- /dev/null +++ b/file_templates/common/class_method_declaration_cpp.txt @@ -0,0 +1,5 @@ +{# Template for class method declaration #} +{% with method.arguments as arguments %} + {# standard four spaces indentation to match context #} + {% if method.isStatic %}static {% endif %}{% if method.isVirtual and not method.isOverriding %}virtual {% endif %}{% if not method.isConstructor and not method.isDestructor %}{{ method.returnType|default:"void" }} {% endif %}{% if method.isConstructor %}{{ name }}{% else %}{{ method.name }}{% endif %}({% include "arguments_types_names.txt" %}){% if method.isConst %} const{% endif %}{% if method.isVirtual %}{% if method.isFinal %} final{% elif method.isOverriding %} override{% elif method.isAbstract %} = 0{% endif %}{% endif %}; +{% endwith %} diff --git a/file_templates/common/class_property_getter_declaration_apidox_cpp.txt b/file_templates/common/class_property_getter_declaration_apidox_cpp.txt new file mode 100644 --- /dev/null +++ b/file_templates/common/class_property_getter_declaration_apidox_cpp.txt @@ -0,0 +1,5 @@ +{# Template for api dox in front of class property getter method declaration #} + {# standard four spaces indentation to match context #} + /** + * @return the {{ property.name }} + */ diff --git a/file_templates/common/class_property_getter_declaration_cpp.txt b/file_templates/common/class_property_getter_declaration_cpp.txt new file mode 100644 --- /dev/null +++ b/file_templates/common/class_property_getter_declaration_cpp.txt @@ -0,0 +1,3 @@ +{# Template for class property setter method declaration #} + {# standard four spaces indentation to match context #} + {{ property.type }} {{ property.name }}() const; diff --git a/file_templates/common/class_property_setter_declaration_apidox_cpp.txt b/file_templates/common/class_property_setter_declaration_apidox_cpp.txt new file mode 100644 --- /dev/null +++ b/file_templates/common/class_property_setter_declaration_apidox_cpp.txt @@ -0,0 +1,7 @@ +{# Template for api dox in front of class property setter method declaration #} + {# standard four spaces indentation to match context #} + /** + * Sets the {{ property.name }}. + * + * @param {{ property.name }} the new {{ property.name }} + */ diff --git a/file_templates/common/class_property_setter_declaration_cpp.txt b/file_templates/common/class_property_setter_declaration_cpp.txt new file mode 100644 --- /dev/null +++ b/file_templates/common/class_property_setter_declaration_cpp.txt @@ -0,0 +1,4 @@ +{# Template for class property setter method declaration #} +{% load kdev_filters %} + {# standard four spaces indentation to match context #} + void set{{ property.name|capfirst }}({{ property.type|arg_type }} {{ property.name }}); diff --git a/file_templates/common/cpp_header.h b/file_templates/common/cpp_header.h --- a/file_templates/common/cpp_header.h +++ b/file_templates/common/cpp_header.h @@ -25,62 +25,85 @@ {% block class_declaration_open %} -class {{ name }}{% if base_classes %} :{% for base in base_classes %} {{ base.inheritanceMode }} {{ base.baseType }}{% if not forloop.last %},{% endif %}{% endfor %}{% endif %} +{% include "class_declaration_apidox_cpp.txt" %} +{% include "class_declaration_cpp.txt" %} { {% endblock class_declaration_open %} - {% block class_body %} {% if public_members or public_functions %} + public: {% endif %} {% if public_functions %} {% for method in public_functions %} - {% include "method_declaration_cpp.txt" %} + + {% include "class_method_declaration_apidox_cpp.txt" %} + {% include "class_method_declaration_cpp.txt" %} + {% endfor %} + {% endif %} {% if public_members %} {% for member in public_members %} {{ member.type }} {{ member.name }}; {% endfor %} + {% endif %} {% if protected_members or protected_functions %} + protected: {% endif %} {% if protected_functions %} {% for method in protected_functions %} - {% include "method_declaration_cpp.txt" %} + + {% include "class_method_declaration_apidox_cpp.txt" %} + {% include "class_method_declaration_cpp.txt" %} + {% endfor %} + {% endif %} {% if protected_members %} {% for member in protected_members %} {{ member.type }} {{ member.name }}; {% endfor %} + {% endif %} {% if private_members or private_functions %} + private: {% endif %} {% if private_functions %} {% for method in private_functions %} - {% include "method_declaration_cpp.txt" %} + + {% include "class_method_declaration_apidox_cpp.txt" %} + {% include "class_method_declaration_cpp.txt" %} + {% endfor %} + {% endif %} + {% if private_members %} {% for member in private_members %} {{ member.type }} {{ member.name }}; {% endfor %} + + {% endif %} {% endblock class_body %} {% block class_bottom %} {% endblock %} {% block class_declaration_close %} }; {% endblock %} + {% block outside_class %} {% endblock %} + {% block namespaces_close %} {% include "namespace_close_cpp.txt" %} {% endblock namespaces_close %} + {% block outside_namespace %} {% endblock %} diff --git a/file_templates/common/cpp_header_onlyfunctions.h b/file_templates/common/cpp_header_onlyfunctions.h --- a/file_templates/common/cpp_header_onlyfunctions.h +++ b/file_templates/common/cpp_header_onlyfunctions.h @@ -25,51 +25,61 @@ {% block class_declaration_open %} -class {{ name }}{% if base_classes %} :{% for base in base_classes %} {{ base.inheritanceMode }} {{ base.baseType }}{% if not forloop.last %},{% endif %}{% endfor %}{% endif %} +{% include "class_declaration_apidox_cpp.txt" %} +{% include "class_declaration_cpp.txt" %} { {% endblock class_declaration_open %} - {% block class_body %} {% if public_functions %} + public: {% for method in public_functions %} - {% include "method_declaration_cpp.txt" %} - {% endfor %} + {% include "class_method_declaration_apidox_cpp.txt" %} + {% include "class_method_declaration_cpp.txt" %} + + {% endfor %} {% endif %} {% if protected_functions %} + protected: {% for method in protected_functions %} - {% include "method_declaration_cpp.txt" %} - {% endfor %} + {% include "class_method_declaration_apidox_cpp.txt" %} + {% include "class_method_declaration_cpp.txt" %} + + {% endfor %} {% endif %} {% if private_functions %} + private: {% for method in private_functions %} - {% include "method_declaration_cpp.txt" %} - {% endfor %} + {% include "class_method_declaration_apidox_cpp.txt" %} + {% include "class_method_declaration_cpp.txt" %} + + {% endfor %} {% endif %} {% endblock class_body %} - {% block class_bottom %} {% endblock %} - {% block class_declaration_close %} }; {% endblock %} + {% block outside_class %} {% endblock %} + {% block namespaces_close %} {% include "namespace_close_cpp.txt" %} {% endblock namespaces_close %} + {% block outside_namespace %} {% endblock %}