diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2020-03-28 03:04:38 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2020-03-28 03:04:38 +0100 |
commit | aaba53a9bf90784e2dc00351c554fbab34ecb778 (patch) | |
tree | d46c70e9d74d5521bf8973a5c485a9e8d320d89a | |
parent | 6aa5a0bf13e2b15acecb7a64a1a787f9ac42df9b (diff) | |
parent | 9a1d79ac5cc2abf4eccacf0a50143e127e444a77 (diff) |
Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I51d9f667bc93bba8bdba3b8970dfefe070511a6d
-rw-r--r-- | examples/ivicore/qface-ivi-climate/example-ivi-climate.yaml | 2 | ||||
-rw-r--r-- | src/ivicore/qivisimulationglobalobject.cpp | 32 | ||||
-rw-r--r-- | src/ivicore/qivistandarditem.cpp | 2 | ||||
-rw-r--r-- | src/ivicore/qivistandarditem.h | 4 | ||||
-rw-r--r-- | src/ivimedia/qiviplayableitem.cpp | 4 | ||||
-rw-r--r-- | src/ivimedia/qiviplayableitem.h | 8 | ||||
-rw-r--r-- | src/ivimedia/qivitunerstation.cpp | 4 | ||||
-rw-r--r-- | src/ivimedia/qivitunerstation.h | 8 | ||||
-rwxr-xr-x | src/tools/ivigenerator/generate.py | 6 | ||||
-rw-r--r-- | src/tools/ivigenerator/generator/global_functions.py | 7 | ||||
-rw-r--r-- | src/tools/ivigenerator/templates/common/backend_simulation.cpp.tpl | 8 |
11 files changed, 50 insertions, 35 deletions
diff --git a/examples/ivicore/qface-ivi-climate/example-ivi-climate.yaml b/examples/ivicore/qface-ivi-climate/example-ivi-climate.yaml index f114ef0..2d1a751 100644 --- a/examples/ivicore/qface-ivi-climate/example-ivi-climate.yaml +++ b/examples/ivicore/qface-ivi-climate/example-ivi-climate.yaml @@ -1,6 +1,6 @@ Example.IVI.Climate.ClimateControl: config_simulator: - zones: { left : FrontLeft, right : FrontRight, rear: Rear } + zones: [ FrontLeft, FrontRight, Rear ] Example.IVI.Climate.ClimateControl#airConditioning: config_simulator: diff --git a/src/ivicore/qivisimulationglobalobject.cpp b/src/ivicore/qivisimulationglobalobject.cpp index 48c47ea..853d7a2 100644 --- a/src/ivicore/qivisimulationglobalobject.cpp +++ b/src/ivicore/qivisimulationglobalobject.cpp @@ -429,17 +429,33 @@ bool QIviSimulationGlobalObject::checkSettings(const QVariantMap &data, const QV } } const QVariant domainDomain = parseDomainValue(data, domainLiteral, zone); + bool valueToDouble = value.canConvert(QVariant::Double); + bool minDomainToDouble = minDomain.canConvert(QVariant::Double); + bool maxDomainToDouble = maxDomain.canConvert(QVariant::Double); - if (unsupportedDomain.isValid()) + if (unsupportedDomain.isValid()) { return !unsupportedDomain.toBool(); - if (minDomain.isValid() && maxDomain.isValid()) - return !(value < minDomain || value > maxDomain); - if (minDomain.isValid()) - return value >= minDomain; - if (maxDomain.isValid()) - return value <= maxDomain; - if (domainDomain.isValid()) + } else if (minDomain.isValid() && maxDomain.isValid()) { + if (!valueToDouble || !minDomainToDouble || !maxDomainToDouble) { + qWarning() << "Can't compare values: " << value << minDomain << maxDomain; + return false; + } + return !(value.toDouble() < minDomain.toDouble() || value.toDouble() > maxDomain.toDouble()); + } else if (minDomain.isValid()) { + if (!valueToDouble || !minDomainToDouble) { + qWarning() << "Can't compare values: " << value << minDomain; + return false; + } + return value.toDouble() >= minDomain.toDouble(); + } else if (maxDomain.isValid()) { + if (!valueToDouble || !maxDomainToDouble) { + qWarning() << "Can't compare values: " << value << maxDomain; + return false; + } + return value.toDouble() <= maxDomain.toDouble(); + } if (domainDomain.isValid()) { return domainDomain.toList().contains(value); + } return true; } diff --git a/src/ivicore/qivistandarditem.cpp b/src/ivicore/qivistandarditem.cpp index 3d287cd..53a5746 100644 --- a/src/ivicore/qivistandarditem.cpp +++ b/src/ivicore/qivistandarditem.cpp @@ -174,7 +174,7 @@ void QIviStandardItem::setData(const QVariantMap &data) \sa operator!=() */ -bool QIviStandardItem::operator==(const QIviStandardItem &other) +bool QIviStandardItem::operator==(const QIviStandardItem &other) const { return (d->m_id == other.d->m_id); } diff --git a/src/ivicore/qivistandarditem.h b/src/ivicore/qivistandarditem.h index a319d31..1659d88 100644 --- a/src/ivicore/qivistandarditem.h +++ b/src/ivicore/qivistandarditem.h @@ -75,8 +75,8 @@ public: virtual QVariantMap data() const; virtual void setData(const QVariantMap &data); - bool operator==(const QIviStandardItem &other); - inline bool operator!=(const QIviStandardItem &other) { return !(*this == other); } + bool operator==(const QIviStandardItem &other) const; + inline bool operator!=(const QIviStandardItem &other) const { return !(*this == other); } private: QSharedDataPointer<QIviStandardItemPrivate> d; diff --git a/src/ivimedia/qiviplayableitem.cpp b/src/ivimedia/qiviplayableitem.cpp index cdda057..aad95a8 100644 --- a/src/ivimedia/qiviplayableitem.cpp +++ b/src/ivimedia/qiviplayableitem.cpp @@ -173,7 +173,7 @@ QString QIviPlayableItem::type() const \sa operator!=() */ -bool QIviPlayableItem::operator==(const QIviPlayableItem &other) +bool QIviPlayableItem::operator==(const QIviPlayableItem &other) const { return (QIviStandardItem::operator==(other) && d->m_url == other.d->m_url); @@ -454,7 +454,7 @@ QString QIviAudioTrackItem::type() const \sa operator!=() */ -bool QIviAudioTrackItem::operator==(const QIviAudioTrackItem &other) +bool QIviAudioTrackItem::operator==(const QIviAudioTrackItem &other) const { return (QIviPlayableItem::operator==(other) && d->m_title == other.d->m_title && diff --git a/src/ivimedia/qiviplayableitem.h b/src/ivimedia/qiviplayableitem.h index 3e41c1c..ff2de2f 100644 --- a/src/ivimedia/qiviplayableitem.h +++ b/src/ivimedia/qiviplayableitem.h @@ -69,8 +69,8 @@ public: virtual void setUrl(const QUrl &url); virtual QString type() const override; - bool operator==(const QIviPlayableItem &other); - inline bool operator!=(const QIviPlayableItem &other) { return !(*this == other); } + bool operator==(const QIviPlayableItem &other) const; + inline bool operator!=(const QIviPlayableItem &other) const { return !(*this == other); } private: QSharedDataPointer<QIviPlayableItemPrivate> d; @@ -118,8 +118,8 @@ public: virtual QString name() const override; virtual QString type() const override; - bool operator==(const QIviAudioTrackItem &other); - inline bool operator!=(const QIviAudioTrackItem &other) { return !(*this == other); } + bool operator==(const QIviAudioTrackItem &other) const; + inline bool operator!=(const QIviAudioTrackItem &other) const { return !(*this == other); } private: QSharedDataPointer<QIviAudioTrackItemPrivate> d; diff --git a/src/ivimedia/qivitunerstation.cpp b/src/ivimedia/qivitunerstation.cpp index af119b6..908de32 100644 --- a/src/ivimedia/qivitunerstation.cpp +++ b/src/ivimedia/qivitunerstation.cpp @@ -298,7 +298,7 @@ QString QIviTunerStation::type() const \sa operator!=() */ -bool QIviTunerStation::operator==(const QIviTunerStation &other) +bool QIviTunerStation::operator==(const QIviTunerStation &other) const { return (QIviStandardItem::operator==(other) && d->m_stationName == other.d->m_stationName && @@ -400,7 +400,7 @@ QString QIviAmFmTunerStation::type() const \sa operator!=() */ -bool QIviAmFmTunerStation::operator==(const QIviAmFmTunerStation &other) +bool QIviAmFmTunerStation::operator==(const QIviAmFmTunerStation &other) const { return (QIviTunerStation::operator==(other) && d->m_band == other.d->m_band); diff --git a/src/ivimedia/qivitunerstation.h b/src/ivimedia/qivitunerstation.h index b1e7f4b..715b62d 100644 --- a/src/ivimedia/qivitunerstation.h +++ b/src/ivimedia/qivitunerstation.h @@ -84,8 +84,8 @@ public: virtual QString name() const override; virtual QString type() const override; - bool operator==(const QIviTunerStation &other); - inline bool operator!=(const QIviTunerStation &other) { return !(*this == other); } + bool operator==(const QIviTunerStation &other) const; + inline bool operator!=(const QIviTunerStation &other) const { return !(*this == other); } private: QSharedDataPointer<QIviTunerStationPrivate> d; @@ -108,8 +108,8 @@ public: virtual void setBand(QIviAmFmTuner::Band band); virtual QString type() const override; - bool operator==(const QIviAmFmTunerStation &other); - inline bool operator!=(const QIviAmFmTunerStation &other) { return !(*this == other); } + bool operator==(const QIviAmFmTunerStation &other) const; + inline bool operator!=(const QIviAmFmTunerStation &other) const { return !(*this == other); } private: QSharedDataPointer<QIviAmFmTunerStationPrivate> d; diff --git a/src/tools/ivigenerator/generate.py b/src/tools/ivigenerator/generate.py index ba35506..ba6c213 100755 --- a/src/tools/ivigenerator/generate.py +++ b/src/tools/ivigenerator/generate.py @@ -50,7 +50,7 @@ from qface.generator import FileSystem, Generator from qface.watch import monitor import generator.builtin_config as builtin_config -from generator.global_functions import register_global_functions +import generator.global_functions as global_functions from generator.filters import register_filters from generator.rule_generator import CustomRuleGenerator @@ -61,7 +61,6 @@ log = logging.getLogger(__file__) builtinTemplatesPath = Path(here / 'templates') builtinTemplates = [os.path.splitext(f)[0] for f in os.listdir(builtinTemplatesPath) if fnmatch.fnmatch(f, '*.yaml')] - def validateType(srcFile, type, errorString): if type.is_interface: sys.exit("{0}: {1} of type 'interface' are not supported".format(srcFile, errorString)) @@ -116,12 +115,13 @@ def generate(tplconfig, moduleConfig, annotations, imports, src, dst): srcFile = os.path.basename(src[0]) srcBase = os.path.splitext(srcFile)[0] + global_functions.currentSrcFile = srcFile ctx = {'qtASVersion': builtin_config.config["VERSION"], 'srcFile': srcFile, 'srcBase': srcBase} generator = CustomRuleGenerator(search_path=[tplconfig, builtinTemplatesPath], destination=dst, context=ctx, modules=module_names) generator.env.keep_trailing_newline = True - register_global_functions(generator) + global_functions.register_global_functions(generator) register_filters(generator) validateSystem(srcFile, system) diff --git a/src/tools/ivigenerator/generator/global_functions.py b/src/tools/ivigenerator/generator/global_functions.py index 69c60e5..279baa2 100644 --- a/src/tools/ivigenerator/generator/global_functions.py +++ b/src/tools/ivigenerator/generator/global_functions.py @@ -45,6 +45,7 @@ import click from jinja2 import TemplateAssertionError from jinja2 import contextfunction +currentSrcFile = "" def jinjaTrace(): """ @@ -60,9 +61,7 @@ def jinjaTrace(): frame = frame.f_back return infos - -@contextfunction -def jinja_error(context, msg): +def jinja_error(msg): """ Throws an error for the current jinja template and the templates this is included from This can be used inside a filter to indicate problems with the passed arguments or direclty @@ -74,7 +73,7 @@ def jinja_error(context, msg): if len(infos) > 1: for info in infos[1:]: message = message + "\n{0}:{1}: instantiated from here".format(info[0], info[1]) - message = message + "\n{0}: instantiated from here".format(context["srcFile"]) + message = message + "\n{0}: instantiated from here".format(currentSrcFile) raise TemplateAssertionError(message, infos[0][1], "", infos[0][0]) raise TemplateAssertionError(msg, -1, "", "unknown") diff --git a/src/tools/ivigenerator/templates/common/backend_simulation.cpp.tpl b/src/tools/ivigenerator/templates/common/backend_simulation.cpp.tpl index 9ee929e..4c146e1 100644 --- a/src/tools/ivigenerator/templates/common/backend_simulation.cpp.tpl +++ b/src/tools/ivigenerator/templates/common/backend_simulation.cpp.tpl @@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE , m_{{ property }}(new {{property|upperfirst}}ModelBackend(this)); {% endif %} {% else %} - , m_{{ property }}({{property|default_value}}) + , m_{{ property }}({{property|default_type_value}}) {% endif %} {% endfor %} { @@ -103,7 +103,7 @@ QT_BEGIN_NAMESPACE : {{class}}Interface(parent) {% for property in interface.properties %} {% if not property.type.is_model %} - , m_{{ property }}({{property|default_value}}) + , m_{{ property }}({{property|default_type_value}}) {% endif %} {% endfor %} {% if interface_zoned %} @@ -198,7 +198,7 @@ void {{class}}::addZone(const QString &zone) return zo->{{property|getter_name}}(); else qWarning() << "No such Zone"; - return {{property|default_value}}; + return {{property|default_type_value}}; } {% else %} {{ivi.prop_getter(property, class, model_interface = true)}} @@ -257,7 +257,7 @@ void {{class}}::addZone(const QString &zone) Q_UNUSED(zone); {% endif %} - qWarning() << "Not implemented!"; + qWarning() << "{{operation}}: Not implemented!"; //Fake that the reply always succeeded QIviPendingReply<{{operation|return_type}}> successReply; |