diff options
author | Dominik Holland <dominik.holland@pelagicore.com> | 2017-09-06 10:16:25 +0200 |
---|---|---|
committer | Dominik Holland <dominik.holland@pelagicore.com> | 2017-09-15 12:49:04 +0000 |
commit | bbcd4571dbc30b8d660d81b66afae19e9dac615c (patch) | |
tree | 7d5f1a9decb0756f2cc2937c4a39b5aa88477c1c | |
parent | c99b4539534a09e0da836b5dd5057e8b770e9863 (diff) | |
download | qtivi-bbcd4571dbc30b8d660d81b66afae19e9dac615c.tar.gz |
Add the control_panel to the autogenerator tests
Fixed it to make it work also for unzoned interfaces and fixed a issue
when no qml_name is set for the interface, which caused the QML and
the C++ backend to have the same name and cause weird issues.
Change-Id: I0d90fb56b60ff17eb37b41412c1d33a8e628df43
Reviewed-by: Mike Krus <mike.krus@kdab.com>
9 files changed, 48 insertions, 30 deletions
diff --git a/src/tools/ivigenerator/templates_control_panel.yaml b/src/tools/ivigenerator/templates_control_panel.yaml index 3a7f6e3..31aa682 100644 --- a/src/tools/ivigenerator/templates_control_panel.yaml +++ b/src/tools/ivigenerator/templates_control_panel.yaml @@ -19,7 +19,7 @@ generate_rules: - dest_file: "EnumControl.qml" template_file: "EnumControl.qml.tpl" interface_rules: - - dest_file: '{{interface}}.qml' + - dest_file: '{{interface}}ControlUi.qml' template_file: 'interface.qml.tpl' - dest_file: '{{interface|lower}}.cpp' template_file: 'interface.cpp.tpl' diff --git a/src/tools/ivigenerator/templates_control_panel/interface.cpp.tpl b/src/tools/ivigenerator/templates_control_panel/interface.cpp.tpl index 3d00e84..a80ba9c 100644 --- a/src/tools/ivigenerator/templates_control_panel/interface.cpp.tpl +++ b/src/tools/ivigenerator/templates_control_panel/interface.cpp.tpl @@ -52,11 +52,7 @@ const QString INITIAL_MAIN_ZONE = "MainZone"; QT_BEGIN_NAMESPACE -/*! - \class {{interface}} - \inmodule {{module}} -{{ utils.format_comments(interface.comment) }} -*/ +{% if interface.tags.config.zoned %} {{class}}::{{class}}(const QString &zone, QObject *parent) : QObject(parent) , m_currentZone(zone) @@ -74,13 +70,17 @@ QT_BEGIN_NAMESPACE addZone("{{zone_id}}"); {% endfor %} } +{% else %} +{{class}}::{{class}}(QObject *parent) + : QObject(parent) +{ +} +{% endif %} -/*! \internal */ {{class}}::~{{class}}() { } -/*! \internal */ void {{class}}::registerQmlTypes(const QString& uri, int majorVersion, int minorVersion, const QString& qmlName) { {% if 'singleton' in interface.tags %} @@ -90,6 +90,7 @@ void {{class}}::registerQmlTypes(const QString& uri, int majorVersion, int minor {% endif %} } +{% if interface.tags.config.zoned %} void {{class}}::addZone(const QString &newZone) { if (!m_currentZone.isEmpty()) { @@ -122,16 +123,10 @@ QVariantMap {{class}}::zoneAt() const { return m_zoneMap; } +{% endif %} {% for property in interface.properties %} -/*! - \property {{class}}::{{property}} -{{ utils.format_comments(property.comment) }} -{% if property.const %} - \note This property is constant and the value will not change once the plugin is initialized. -{% endif %} -*/ {{property|return_type}} {{class}}::{{property|getter_name}}() const { return m_{{property}}; @@ -148,9 +143,7 @@ void {{class}}::{{property|setter_name}}({{ property|parameter_type }}) {% endfor %} {%- for operation in interface.operations %} -/*! -{{ utils.format_comments(operation.comment) }} -*/ + {{operation|return_type}} {{class}}::{{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){% if operation.const %} const{% endif %} { diff --git a/src/tools/ivigenerator/templates_control_panel/interface.h.tpl b/src/tools/ivigenerator/templates_control_panel/interface.h.tpl index 365ae25..7a4731b 100644 --- a/src/tools/ivigenerator/templates_control_panel/interface.h.tpl +++ b/src/tools/ivigenerator/templates_control_panel/interface.h.tpl @@ -56,29 +56,33 @@ QT_BEGIN_NAMESPACE class {{class}}Private; class {{class}}BackendInterface; -{% if interface.tags.config.zoned %} class {{exportsymbol}} {{class}} : public QObject { -{% else %} -class {{exportsymbol}} {{class}} : public QObject { -{% endif %} Q_OBJECT +{% if interface_zoned %} Q_PROPERTY(QString currentZone READ currentZone NOTIFY currentZoneChanged) Q_PROPERTY(QStringList zones READ zones NOTIFY zonesChanged) Q_PROPERTY(QVariantMap zoneAt READ zoneAt NOTIFY zonesChanged) +{% endif %} {% for property in interface.properties %} Q_PROPERTY({{property|return_type}} {{property}} READ {{property|getter_name}} WRITE {{property|setter_name}} NOTIFY {{property}}Changed) {% endfor %} Q_CLASSINFO("IviPropertyDomains", "{{ interface.properties|json_domain|replace("\"", "\\\"") }}") public: +{% if interface_zoned %} explicit {{class}}(const QString &zone = QString(), QObject *parent = nullptr); +{% else %} + explicit {{class}}(QObject *parent = nullptr); +{% endif %} ~{{class}}(); static void registerQmlTypes(const QString& uri, int majorVersion=1, int minorVersion=0, const QString& qmlName = ""); - Q_INVOKABLE void addZone(const QString& newZone); +{% if interface_zoned %} + Q_INVOKABLE void addZone(const QString& newZone); QString currentZone() const; QStringList zones() const; QVariantMap zoneAt() const; +{% endif %} {% for property in interface.properties %} {{property|return_type}} {{property|getter_name}}() const; {% endfor %} @@ -92,8 +96,10 @@ public Q_SLOTS: {% endfor %} Q_SIGNALS: +{% if interface_zoned %} void currentZoneChanged(); void zonesChanged(); +{% endif %} {% for signal in interface.signals %} void {{signal}}({{signal.parameters|map('parameter_type')|join(', ')}}); {% endfor %} @@ -108,9 +114,8 @@ private: {% if interface_zoned %} QHash<QString,{{class}}*> m_zoneHash; QVariantMap m_zoneMap; -{% endif %} QString m_currentZone; - //ZoneBackend createZoneBackend(); +{% endif %} }; QT_END_NAMESPACE diff --git a/src/tools/ivigenerator/templates_control_panel/interface.qml.tpl b/src/tools/ivigenerator/templates_control_panel/interface.qml.tpl index e835883..d6caa2f 100644 --- a/src/tools/ivigenerator/templates_control_panel/interface.qml.tpl +++ b/src/tools/ivigenerator/templates_control_panel/interface.qml.tpl @@ -57,7 +57,9 @@ Flickable { id: {{backend_obj}} } +{% if interface.tags.config.zoned %} property {{interface|qml_type}} currentZoneObject: {{backend_obj}}.zoneAt[comboZones.displayText] +{% endif %} ColumnLayout { id: layout @@ -92,6 +94,9 @@ Flickable { } {% for property in interface.properties %} +{% if interface.tags.config.zoned %} +{% set backend_obj = 'currentZoneObject' %} +{% endif %} RowLayout { height: 30 Layout.fillWidth: true @@ -102,17 +107,17 @@ Flickable { Connections { target: {{property|lowerfirst}}Control on{{property|qml_binding_property|upperfirst}}Changed: { - currentZoneObject.{{property}} = {{property|lowerfirst}}Control.{{property|qml_binding_property}} + {{backend_obj}}.{{property}} = {{property|lowerfirst}}Control.{{property|qml_binding_property}} } } Binding { target: {{property|lowerfirst}}Control property: "{{property|qml_binding_property}}" - value: currentZoneObject.{{property}} + value: {{backend_obj}}.{{property}} } - {{property|qml_control('currentZoneObject')}} + {{property|qml_control(backend_obj)}} } {% endfor %} {% if interface.operations|count %} diff --git a/src/tools/ivigenerator/templates_control_panel/main.qml.tpl b/src/tools/ivigenerator/templates_control_panel/main.qml.tpl index 4369a1d..a469007 100644 --- a/src/tools/ivigenerator/templates_control_panel/main.qml.tpl +++ b/src/tools/ivigenerator/templates_control_panel/main.qml.tpl @@ -69,7 +69,7 @@ ApplicationWindow { Layout.fillWidth: true currentIndex: bar.currentIndex {% for interface in module.interfaces %} - {{interface}} { + {{interface}}ControlUi { id: {{interface|lowerfirst}} } {% endfor %} diff --git a/src/tools/ivigenerator/templates_control_panel/qml.qrc.tpl b/src/tools/ivigenerator/templates_control_panel/qml.qrc.tpl index 2a6d015..365d76f 100644 --- a/src/tools/ivigenerator/templates_control_panel/qml.qrc.tpl +++ b/src/tools/ivigenerator/templates_control_panel/qml.qrc.tpl @@ -43,7 +43,7 @@ <file>EnumControl.qml</file> <file>FlagControl.qml</file> {% for interface in module.interfaces %} - <file>{{interface}}.qml</file> + <file>{{interface}}ControlUi.qml</file> {% endfor %} </qresource> </RCC> diff --git a/tests/auto/core/ivigenerator/ivigenerator.pro b/tests/auto/core/ivigenerator/ivigenerator.pro index b368853..dfc1c66 100644 --- a/tests/auto/core/ivigenerator/ivigenerator.pro +++ b/tests/auto/core/ivigenerator/ivigenerator.pro @@ -1,3 +1,7 @@ TEMPLATE = subdirs SUBDIRS = projects + +OTHER_FILES = org.example.echo.qface \ + org.example.echo.yaml \ + org.example.echo.noprivate.qface diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/control_panel/control_panel.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/control_panel/control_panel.pro new file mode 100644 index 0000000..029b372 --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/control_panel/control_panel.pro @@ -0,0 +1,10 @@ +TEMPLATE=app +TARGET= echo_noprivate_control_panel +DESTDIR = ../ + +CONFIG += ivigenerator + +QT += ivicore ivicore-private qml quick + +QFACE_FORMAT = control_panel +QFACE_SOURCES = ../../../org.example.echo.noprivate.qface diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro index 7083d85..84e7275 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro @@ -3,6 +3,7 @@ TEMPLATE = subdirs SUBDIRS = frontend \ backend_simulator \ validator \ + control_panel \ backend_simulator.depends = frontend validator.depends = frontend |