diff options
author | Sebastian Sauer <sebastian.sauer.ford@kdab.com> | 2014-08-12 18:53:00 +0700 |
---|---|---|
committer | Sebastian Sauer <sebastian.sauer@kdab.com> | 2014-08-25 17:29:21 +0200 |
commit | cae7176827eb3c23428cfcd8f6dabb00f8dcaef3 (patch) | |
tree | 948a32f66791eff082363c6aca5a1436cd4e9353 /src/qml/qml/qqmlscriptstring.cpp | |
parent | 99fd3a6b22a7eabf2aff656a942b0b7e32093254 (diff) |
QSM: Reintroduce guard argument evaluation
Implements the suggestion from Simon Hausmann (codereview 89716
from 08-05 14:46) to use QQmlScriptString rather then the previous
used MetaObject-manipulation.
This also introduces comparison operators for QQmlScriptString
to be able to determinate if a QQmlScriptString changed what
is needed cause there is otherwise no way to access (all) the
needed details within QQmlScriptStringPrivate.
Change-Id: I198479eac8fd37cbdd98a99aacdd8eebf7b75d21
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlscriptstring.cpp')
-rw-r--r-- | src/qml/qml/qqmlscriptstring.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlscriptstring.cpp b/src/qml/qml/qqmlscriptstring.cpp index b18bd4d420..c8227070c5 100644 --- a/src/qml/qml/qqmlscriptstring.cpp +++ b/src/qml/qml/qqmlscriptstring.cpp @@ -114,6 +114,44 @@ QQmlScriptString &QQmlScriptString::operator=(const QQmlScriptString &other) } /*! +Returns \c true if this and the \a other QQmlScriptString objects are equal. + +\sa operator!=() +*/ +bool QQmlScriptString::operator==(const QQmlScriptString &other) const +{ + if (d == other.d) + return true; + + if (d->isNumberLiteral || other.d->isNumberLiteral) + return d->isNumberLiteral && other.d->isNumberLiteral && d->numberValue == other.d->numberValue; + + if (d->isStringLiteral || other.d->isStringLiteral) + return d->isStringLiteral && other.d->isStringLiteral && d->script == other.d->script; + + if (d->script == QStringLiteral("true") || + d->script == QStringLiteral("false") || + d->script == QStringLiteral("undefined") || + d->script == QStringLiteral("null")) + return d->script == other.d->script; + + return d->context == other.d->context && + d->scope == other.d->scope && + d->script == other.d->script && + d->bindingId == other.d->bindingId; +} + +/*! +Returns \c true if this and the \a other QQmlScriptString objects are different. + +\sa operator==() +*/ +bool QQmlScriptString::operator!=(const QQmlScriptString &other) const +{ + return !operator==(other); +} + +/*! Returns whether the QQmlScriptString is empty. */ bool QQmlScriptString::isEmpty() const |