aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsapi/qjsvalue.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-04-20 10:43:11 +0200
committerUlf Hermann <ulf.hermann@qt.io>2021-04-22 22:15:36 +0200
commit3c9339f3c817c985f9ff3410f1f0ef864554687a (patch)
tree05305a6a503b35f9627456435cc2523f5c9909ed /src/qml/jsapi/qjsvalue.cpp
parente44a949f9028df1d4750dad2925b074c9c59efcc (diff)
Support native transformation between UrlObject and QVariant/QUrl
URL has become a builtin type. We should support it on the same level as QString/String and QDateTime/Date. In order to continue support for comparing URL properties with the JavaScript equality operators, we still pass URLs as variants when using them in JavaScript. However, we now create proper URL objects for QJSValue and QJSManagedValue, and we allow transforming the URL-carrying variant objects back into QUrls. Change-Id: I78cb2d7d51ac720877217d2d4b4d0ab17cdd2a4b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsapi/qjsvalue.cpp')
-rw-r--r--src/qml/jsapi/qjsvalue.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp
index 0cff55ac9d..03cd1e9aa9 100644
--- a/src/qml/jsapi/qjsvalue.cpp
+++ b/src/qml/jsapi/qjsvalue.cpp
@@ -56,6 +56,7 @@
#include <private/qv4mm_p.h>
#include <private/qv4jscall_p.h>
#include <private/qv4qobjectwrapper_p.h>
+#include <private/qv4urlobject_p.h>
/*!
\since 5.0
@@ -371,6 +372,15 @@ bool QJSValue::isError() const
}
/*!
+ Returns true if this QJSValue is an object of the URL class;
+ otherwise returns false.
+*/
+bool QJSValue::isUrl() const
+{
+ return QJSValuePrivate::asManagedType<UrlObject>(this);
+}
+
+/*!
\since 5.12
Returns the error type this QJSValue represents if it is an Error object.
Otherwise, returns \c NoError."