diff options
author | Dominik Holland <dominik.holland@pelagicore.com> | 2017-09-07 09:59:37 +0200 |
---|---|---|
committer | Dominik Holland <dominik.holland@pelagicore.com> | 2017-09-19 13:05:24 +0000 |
commit | eabf252bf23a2f54e9c5cf6a5ba64fde6f2df450 (patch) | |
tree | 14c683f1985b01aacfcc1d7b3d2cf2c281a53393 | |
parent | 245b4f9bfc2e8d2241817a7d117daba65cdf4afb (diff) |
ivigenerator: Add support for signals and operations to the control_panel
The control_panel now ofers a control to send signals.
All calls of a operation (e.g. open in the QIviWindowControl) are now
forwarded to the control_panel and logged inside a TextArea.
Change-Id: I893210a723cd1a1792c626711da0d436c00680de
Reviewed-by: Mike Krus <mike.krus@kdab.com>
5 files changed, 64 insertions, 15 deletions
diff --git a/src/tools/ivigenerator/generate.py b/src/tools/ivigenerator/generate.py index 283fef9..08f9af6 100755 --- a/src/tools/ivigenerator/generate.py +++ b/src/tools/ivigenerator/generate.py @@ -382,6 +382,11 @@ def qml_control_properties(symbol, backend_object): if isinstance(symbol, Field): return 'id: {1}_{0}'.format(prop_str, lower_first_filter(symbol.struct)) +def qml_control_signal_parameters(symbol): + """ + Returns the parameters for calling the signal using the values from the ui controls + """ + return ', '.join('{0}Param{1}Control.{2}'.format(e.operation, lower_first_filter(e), qml_binding_property(e)) for e in symbol.parameters) def qml_meta_control_name(symbol): """ @@ -518,6 +523,7 @@ def generate(tplconfig, moduleConfig, src, dst): generator.register_filter('qml_type', qml_type) generator.register_filter('qml_control', qml_control) generator.register_filter('qml_binding_property', qml_binding_property) + generator.register_filter('qml_control_signal_parameters', qml_control_signal_parameters) srcFile = os.path.basename(src[0]) srcBase = os.path.splitext(srcFile)[0] diff --git a/src/tools/ivigenerator/templates_control_panel/interface.cpp.tpl b/src/tools/ivigenerator/templates_control_panel/interface.cpp.tpl index 245dbbe..b21e001 100644 --- a/src/tools/ivigenerator/templates_control_panel/interface.cpp.tpl +++ b/src/tools/ivigenerator/templates_control_panel/interface.cpp.tpl @@ -218,6 +218,23 @@ void {{class}}::{{signal}}({{signal.parameters|map('parameter_type')|join(', ')} {% endfor %} +{% if interface_zoned %} +{% for operation in interface.operations %} +void {{class}}::{{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}{%if operation.parameters|count %}, {% endif %}const QString &zone) +{ + QString z = zone; + if (z.isEmpty()) + z = INITIAL_MAIN_ZONE; + + if (!m_zoneMap.contains(z)) { + return; + } + + emit m_zoneHash[z]->{{operation}}({{operation.parameters|join(', ')}}); +} +{% endfor %} +{% endif %} + QSimulatorConnectionWorker *{{class}}::worker() { {% if interface.tags.config.zoned %} diff --git a/src/tools/ivigenerator/templates_control_panel/interface.h.tpl b/src/tools/ivigenerator/templates_control_panel/interface.h.tpl index d242efb..f6c245f 100644 --- a/src/tools/ivigenerator/templates_control_panel/interface.h.tpl +++ b/src/tools/ivigenerator/templates_control_panel/interface.h.tpl @@ -101,7 +101,7 @@ public Q_SLOTS: Q_SIGNALS: {% for operation in interface.operations %} - {{operation|return_type}} {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){% if operation.const %} const{% endif %}; + void {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}); {% endfor %} {% if interface_zoned %} void currentZoneChanged(); @@ -111,6 +111,12 @@ Q_SIGNALS: void {{property}}Changed({{property|parameter_type}}); {% endfor %} +private Q_SLOTS: +{% if interface_zoned %} +{% for operation in interface.operations %} + void {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}{%if operation.parameters|count %}, {% endif %}const QString &zone); +{% endfor %} +{% endif %} private: QSimulatorConnectionWorker *worker(); {% for property in interface.properties %} diff --git a/src/tools/ivigenerator/templates_control_panel/interface.qml.tpl b/src/tools/ivigenerator/templates_control_panel/interface.qml.tpl index c00013c..83d60b4 100644 --- a/src/tools/ivigenerator/templates_control_panel/interface.qml.tpl +++ b/src/tools/ivigenerator/templates_control_panel/interface.qml.tpl @@ -123,6 +123,7 @@ Flickable { {% if interface.signals|count %} ToolSeparator { orientation: Qt.Horizontal + Layout.fillWidth: true } Text { @@ -135,6 +136,7 @@ Flickable { height: 20 Button { text: "{{signal}}" + onClicked: {{backend_obj}}.{{signal}}({{signal|qml_control_signal_parameters}}); } {% for param in signal.parameters %} Text { @@ -150,27 +152,33 @@ Flickable { ToolSeparator { orientation: Qt.Horizontal + Layout.fillWidth: true } Text { text: "Operations" } + + TextArea { + id: operationArea + readOnly: true + placeholderText: "The called operations will be logged here" + Layout.fillWidth: true + } {% for operation in interface.operations %} - // Button for operation call - RowLayout { - spacing: 2 - height: 20 - Button { - text: "{{operation}}" - } -{% for param in operation.parameters %} - Text { - text: "{{param}}" +{% if interface.tags.config.zoned %} +{% set backend_obj = 'currentZoneObject' %} +{% endif %} + Connections { + target: {{backend_obj}} + on{{operation|upperfirst}}: { + operationArea.text += "{{operation}}(" +{% for parameter in operation.parameters %} + + "{{parameter}}: " + {{parameter}} +{% endfor %} + + ")\n" } - {{param|qml_control(backend_obj)}} - -{% endfor%} - } + } {% endfor %} {% endif %} Item { diff --git a/src/tools/ivigenerator/templates_generation_validator/main.qml.tpl b/src/tools/ivigenerator/templates_generation_validator/main.qml.tpl index 460e08f..031fdcd 100644 --- a/src/tools/ivigenerator/templates_generation_validator/main.qml.tpl +++ b/src/tools/ivigenerator/templates_generation_validator/main.qml.tpl @@ -82,6 +82,18 @@ Window { } {% endfor %} +{% for signal in iface.signals %} + Connections { + target: {{iface|lowerfirst}} + on{{signal|upperfirst}}: { + print("{{signal}}") +{% for parameter in signal.parameters %} + print({{parameter}}) +{% endfor %} + } + } +{% endfor %} + {% endfor %} } } |