From 6ed811ace1fbe841de6e37a9b0929f096a3a4fa7 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Fri, 3 Apr 2020 09:57:57 +0200 Subject: ivigenerator: Set the export define when building the frontend The users needed to do this themself before, but there is no good reason why this can't be done by the autogenerator directly. Change-Id: Ie0004e295ba2ac4bdd2c03b83346580055487a8d Reviewed-by: Robert Griebl --- src/tools/ivigenerator/templates/frontend/module.pri.tpl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tools/ivigenerator/templates/frontend/module.pri.tpl b/src/tools/ivigenerator/templates/frontend/module.pri.tpl index acd167f..beb9da8 100644 --- a/src/tools/ivigenerator/templates/frontend/module.pri.tpl +++ b/src/tools/ivigenerator/templates/frontend/module.pri.tpl @@ -42,6 +42,9 @@ ## Do not edit! All changes made to it will be lost. ############################################################################# +# Export all symbols when building this library +DEFINES *= QT_BUILD_{{module|upper|replace('.', '_')|strip_QT}}_LIB + HEADERS += \ {% for interface in module.interfaces %} $$PWD/{{interface|lower}}.h \ -- cgit v1.2.3 From d15d570d0730b917785b73f5f267fe3b8ea05b18 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Fri, 3 Apr 2020 09:59:28 +0200 Subject: ivigenerator: Deprecate old filters and don't use them internally Removing the number of supported filters should make it easier to maintain them and implement new features. Change-Id: I8d936905ca8ef2ce0a47b5bf55a2166c7fc91b52 Reviewed-by: Robert Griebl --- .../doc/src/ivigenerator/filter-reference.qdoc | 24 ++++++++++++ src/tools/ivigenerator/generator/filters.py | 43 ++++++++++++++++++++++ .../templates/common/backend_simulation.cpp.tpl | 2 +- .../templates/frontend/interface.h.tpl | 1 - .../ivigenerator/templates/frontend/struct.h.tpl | 1 - 5 files changed, 68 insertions(+), 3 deletions(-) diff --git a/src/ivicore/doc/src/ivigenerator/filter-reference.qdoc b/src/ivicore/doc/src/ivigenerator/filter-reference.qdoc index ca11196..72e7151 100644 --- a/src/ivicore/doc/src/ivigenerator/filter-reference.qdoc +++ b/src/ivicore/doc/src/ivigenerator/filter-reference.qdoc @@ -74,6 +74,8 @@ Returns the default value for the passed symbol. Models are initialized as \c nu \target default_value(symbol, zone="=") \section2 default_value(symbol, zone="=") +\note This filter is deprecated and will be removed in future Qt versions. + Returns the default value for the passed symbol set by the \c @default annotation. If not set uses \c default_type_value instead. @@ -82,6 +84,8 @@ The zone parameter is used to identify different default values per zone. \target model_type(symbol) \section2 model_type(symbol) +\note This filter is deprecated and will be removed in future Qt versions. + Returns the C++ class name for this model. \target flag_type(symbol) @@ -115,11 +119,15 @@ Only lowers the first character of the given string. \target range_low(property) \section2 range_low(property) +\note This filter is deprecated and will be removed in future Qt versions. + Returns the minimum value for the passed property using the \c @range or \c @minimum annotations. \target range_high(property) \section2 range_high(property) +\note This filter is deprecated and will be removed in future Qt versions. + Returns the maximum value for the passed property using the \c @range or \c @maximum annotations. \target strip_QT(string) @@ -130,6 +138,8 @@ Removes the 'QT' at the beginning, if the string starts with it. \target domain_values(symbol) \section2 domain_values(symbol) +\note This filter is deprecated and will be removed in future Qt versions. + Returns the domain values for the passed property using the \c @domain annotation. \target enum_value(value, module_name) @@ -143,12 +153,16 @@ Also supports passing '|' connected values. \target tag_by_path(symbol, path, default_value=False) \section2 tag_by_path(symbol, path, default_value=False) +\note This filter is deprecated and will be removed in future Qt versions. + Find the tag given by its full path in the object hierarchy, like \c property.config_sim.zones.right. If some parts of the path are missing, return \c None. \target conf_sim_tag(symbol, path, default_value=False) \section2 conf_sim_tag(symbol, path, default_value=False) +\note This filter is deprecated and will be removed in future Qt versions. + Find the tag, given by its path, located under the "config_simulator" sub-object. Returns \c None, if parts of the path are missing. @@ -160,11 +174,15 @@ Returns a JSON representation of the given obj. \target has_domains(properties) \section2 has_domains(properties) +\note This filter is deprecated and will be removed in future Qt versions. + Returns \c true if any of the given properties has \c @range or \c @domain annotations. \target json_domain(properties) \section2 json_domain(properties) +\note This filter is deprecated and will be removed in future Qt versions. + Returns the property domains for the given properties formated in JSON. \target qml_type(interface) @@ -177,12 +195,16 @@ module_name is used. \target qml_control(symbol, backend_obj) \section2 qml_control(symbol, backend_obj) +\note This filter is deprecated and will be removed in future Qt versions. + Returns the QML code for the control (or group of controls) to represent the editing UI for the passed symbol. \target qml_binding_property(symbol) \section2 qml_binding_property(symbol) +\note This filter is deprecated and will be removed in future Qt versions. + Returns the name of the property of the QML control to be bound with. E.g. "value" for a Slider and "checked" for a CheckBox. @@ -190,6 +212,8 @@ E.g. "value" for a Slider and "checked" for a CheckBox. \target qml_control_signal_parameters(symbol) \section2 qml_control_signal_parameters(symbol) +\note This filter is deprecated and will be removed in future Qt versions + Returns the parameters for calling the signal using the values from the UI controls. \target struct_includes(symbol) diff --git a/src/tools/ivigenerator/generator/filters.py b/src/tools/ivigenerator/generator/filters.py index 7e7c3d5..52ccd22 100644 --- a/src/tools/ivigenerator/generator/filters.py +++ b/src/tools/ivigenerator/generator/filters.py @@ -40,6 +40,7 @@ # SPDX-License-Identifier: LGPL-3.0 import json +import inspect from qface.idl.domain import Module, Interface, Property, Parameter, Field, Struct from qface.helper.generic import lower_first, upper_first @@ -49,12 +50,21 @@ from .global_functions import jinja_error, jinja_warning from . import builtin_config +def deprecated_filter(name=None): + if not name: + name = inspect.stack()[1][3] + jinja_warning("The '{0}' filter is deprecated and will be removed in future Qt " + "versions".format(name)) + + def tag_by_path(symbol, path, default_value=False): """ Find the tag given by its full path in the object hierarchy, like "property.config_sim.zones.right". If some part of the path is missing, return None """ + deprecated_filter() + path_parts = path.split(".") cur_level_obj = symbol.tags for path_part in path_parts: @@ -73,6 +83,8 @@ def conf_sim_tag(symbol, path, default_value=False): Find tag, given by its path, located under "config_simulator" sub-object. Returns None, of any of the path parts is missing """ + deprecated_filter() + return tag_by_path(symbol, "config_simulator." + path, default_value) @@ -207,6 +219,8 @@ def default_value(symbol, zone='='): """ Find the default value used by the simulator backend """ + deprecated_filter() + res = default_type_value(symbol) if symbol.type.is_model: res = '{}' @@ -330,6 +344,8 @@ def domain_values(symbol): """ Returns domain values for property (if defined by @domain) """ + deprecated_filter() + if type(symbol) is Property: if 'config_simulator' in symbol.tags: if 'domain' in symbol.tags['config_simulator']: @@ -361,6 +377,8 @@ def range_value(symbol, index, key): """ Returns value for property (if defined by @range index or key) """ + deprecated_filter() + if type(symbol) is Property and symbol.type.is_int or symbol.type.is_real: if 'config_simulator' in symbol.tags: if 'range' in symbol.tags['config_simulator']: @@ -374,6 +392,8 @@ def range_high(symbol): """ Returns maximum value for property (if defined by @range or @maximum) """ + deprecated_filter() + return range_value(symbol, 1, 'maximum') @@ -381,6 +401,8 @@ def range_low(symbol): """ Returns minimum value for property (if defined by @range or @minimum) """ + deprecated_filter() + return range_value(symbol, 0, 'minimum') @@ -388,6 +410,8 @@ def has_domains(properties): """ Returns true if any property has range or domain tags """ + deprecated_filter() + for property in properties: if 'config_simulator' in property.tags: for p in ['range', 'domain', 'minimum', 'maximum']: @@ -410,6 +434,8 @@ def json_domain(properties): """ Returns property domains formated in json """ + deprecated_filter() + data = {} if len(properties): data["iviVersion"] = builtin_config.config["VERSION"] @@ -483,6 +509,8 @@ def qml_control_properties(symbol, backend_object): Returns properties of the QML control matching to this IDL type (e.g. min/max properties) """ + deprecated_filter() + prop_str = lower_first(symbol) + "Control" if isinstance(symbol, Property): top = range_high(symbol) @@ -523,6 +551,8 @@ def qml_control_signal_parameters(symbol): """ Returns the parameters for calling the signal using the values from the ui controls """ + deprecated_filter() + return ', '.join('{0}Param{1}Control.{2}'.format(e.operation, lower_first(e),qml_binding_property(e)) for e in symbol.parameters) @@ -532,6 +562,8 @@ def qml_meta_control_name(symbol): data of the symbol -- if symbol has some meta data (e.g. value limits or domain) then control name is taken based on these constraints. Otherwise returns None. """ + deprecated_filter() + top = range_high(symbol) bottom = range_low(symbol) if top is not None and bottom is not None: @@ -549,6 +581,8 @@ def qml_type_control_name(symbol): """ Returns name of the QML control inferred based on the type of the symbol. """ + deprecated_filter() + t = symbol.type if t.is_string or t.is_int or t.is_real: return "TextField" @@ -570,6 +604,8 @@ def qml_control_name(symbol): influence the control type) and if nothing is defined there, it falls back to the symbol actual type. """ + deprecated_filter() + # First try to calculate control name based on the tags control_name = qml_meta_control_name(symbol) # If nothing is defined, calculate it based on its type @@ -583,6 +619,7 @@ def qml_control(symbol, backend_object): Returns QML code for the control (or group of controls) to represent the editing UI for the symbol. """ + deprecated_filter() if symbol.type.is_struct: return qml_struct_control(symbol) @@ -596,6 +633,8 @@ def qml_binding_property(symbol): :param symbol: property which is being bound by the control :return: name of the property of the QML control to be bound with """ + deprecated_filter() + control_name = qml_control_name(symbol) if control_name == "CheckBox": return "checked" @@ -609,6 +648,8 @@ def qml_binding_property(symbol): def qml_struct_control(symbol): + deprecated_filter() + if symbol.type.is_struct and symbol.type.reference.fields: result = "Rectangle { ColumnLayout { " for field in symbol.type.reference.fields: @@ -655,6 +696,8 @@ def qml_type(symbol): def model_type(symbol): + deprecated_filter() + if symbol.type.is_model: nested = symbol.type.nested return '{0}Model'.format(nested) diff --git a/src/tools/ivigenerator/templates/common/backend_simulation.cpp.tpl b/src/tools/ivigenerator/templates/common/backend_simulation.cpp.tpl index f8f2cd7..fdf597a 100644 --- a/src/tools/ivigenerator/templates/common/backend_simulation.cpp.tpl +++ b/src/tools/ivigenerator/templates/common/backend_simulation.cpp.tpl @@ -268,7 +268,7 @@ void {{class}}::addZone(const QString &zone) //Fake that the reply always succeeded QIviPendingReply<{{operation|return_type}}> successReply; - successReply.setSuccess({{operation|default_value}}); + successReply.setSuccess({{operation|default_type_value}}); return successReply; } diff --git a/src/tools/ivigenerator/templates/frontend/interface.h.tpl b/src/tools/ivigenerator/templates/frontend/interface.h.tpl index e1dc448..fd7d0ef 100644 --- a/src/tools/ivigenerator/templates/frontend/interface.h.tpl +++ b/src/tools/ivigenerator/templates/frontend/interface.h.tpl @@ -76,7 +76,6 @@ class {{exportsymbol}} {{class}} : public {{base_class}} {% for property in interface.properties %} {{ivi.property(property)}} {% endfor %} - Q_CLASSINFO("IviPropertyDomains", "{{ interface.properties|json_domain|replace("\"", "\\\"") }}") public: {% if interface.tags.config.zoned %} diff --git a/src/tools/ivigenerator/templates/frontend/struct.h.tpl b/src/tools/ivigenerator/templates/frontend/struct.h.tpl index 3eaa480..9405c60 100644 --- a/src/tools/ivigenerator/templates/frontend/struct.h.tpl +++ b/src/tools/ivigenerator/templates/frontend/struct.h.tpl @@ -70,7 +70,6 @@ class {{exportsymbol}} {{class}} : public QIviStandardItem {% for field in struct.fields %} {{ivi.property(field, notify=false)}} {% endfor %} - Q_CLASSINFO("IviPropertyDomains", "{{ struct.fields|json_domain|replace("\"", "\\\"") }}") public: {{class}}(); -- cgit v1.2.3