From 44e4f8b360367bc846f1d9cbe55876466fea4356 Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Fri, 29 Jun 2018 15:17:47 +0200 Subject: Doc: Mark the \snippet statements with a .pro file Conditionally excluding such statements is required to avoid irrelevant content in documentation in some cases. Change-Id: If6751608dc438de6f7cc0376ffc36f8d994afba6 Reviewed-by: Friedemann Kleint --- src/qml/doc/src/qtqml-cpp.qdoc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/qml') diff --git a/src/qml/doc/src/qtqml-cpp.qdoc b/src/qml/doc/src/qtqml-cpp.qdoc index 971bb88825..2c4d2a5ade 100644 --- a/src/qml/doc/src/qtqml-cpp.qdoc +++ b/src/qml/doc/src/qtqml-cpp.qdoc @@ -36,10 +36,12 @@ following directive: \snippet code/doc_src_qtqml.cpp 0 +\if !defined(qtforpython) To link against the module, add this line to your \l qmake \c .pro file: \snippet code/doc_src_qtqml.pro 0 +\endif For more information on the Qt QML module, see the \l{Qt QML} module documentation. -- cgit v1.2.3 From d3837d4df7dee96db2d9e30270f52def7d49f585 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Tue, 26 Jun 2018 12:13:45 +0200 Subject: Doc: Update QTime to JavaScript Date conversion description MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update description as the behavior changed with 2b8b7a162be52f8cd6c2bc39f498a1ddfb59dd68. * Remove implementation details from description (the specific date), as it may be subject to change. * Simplify a needlessly complicated explanation. Task-number: QTBUG-68516 Change-Id: Ibc25a9923d8c996c47927964cd69b5bd7bbe0240 Reviewed-by: Edward Welbourne Reviewed-by: Topi Reiniƶ --- src/qml/doc/src/cppintegration/data.qdoc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/qml') diff --git a/src/qml/doc/src/cppintegration/data.qdoc b/src/qml/doc/src/cppintegration/data.qdoc index 9b2771c18e..8a606d672a 100644 --- a/src/qml/doc/src/cppintegration/data.qdoc +++ b/src/qml/doc/src/cppintegration/data.qdoc @@ -247,18 +247,18 @@ Similarly, if a C++ type uses a QDateTime for a property type or method parameter, the value can be created as a JavaScript \c Date object in QML, and is automatically converted to a QDateTime value when it is passed to C++. - -\section2 QTime to JavaScript Date +//! Target adds an anchor, so renaming the section won't break incoming links. +\target QTime to JavaScript Date +\section2 QTime and JavaScript Date The QML engine provides automatic type conversion from QTime values to -JavaScript \c Date objects. The date component of the resulting Date -object should not be relied upon, as it is operating system dependent. -Specifically, the year (and month and day) are set to zero. Conversion -from a JavaScript \c Date object to QTime is done by converting to a -QDateTime, and then relying on QVariant to convert it to a QTime. The end -effect is that the date part of the \c Date object is ignored, but the -local timezone will be used ignoring any DST complications it may have. +JavaScript \c Date objects. As QTime values do not contain a date component, +one is created for the conversion only. Thus, you should not rely on the date +component of the resulting Date object. +Under the hood, conversion from a JavaScript \c Date object to QTime is done by +converting to a QDateTime object and calling its \l {QDateTime::}{time()} +method. \section2 Sequence Type to JavaScript Array -- cgit v1.2.3 From f42207cbdb0cbe5e345bfd9e000b3e77b34a503c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 12 Jul 2018 12:43:00 +0200 Subject: Fix conversion of numeric literals in the AST to strings After commit 91f3687ee51db83d9018bd61c3fbc736c6e9912e in qtbase, QString::number includes a zero padding in the exponent that breaks compliance with the ECMAScript tests. Instead of QString::number, we have to use a QLocale instance that turns off the padding of the exponent. Change-Id: Ib8c63bc501cadca026c52359006628f6c271ba6d Task-number: QTBUG-69432 Reviewed-by: Edward Welbourne --- src/qml/parser/qqmljsast.cpp | 22 ++++++++++++++++++++++ src/qml/parser/qqmljsast_p.h | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src/qml') diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp index 34657a7d48..0d1b512c92 100644 --- a/src/qml/parser/qqmljsast.cpp +++ b/src/qml/parser/qqmljsast.cpp @@ -267,6 +267,28 @@ void NumericLiteralPropertyName::accept0(Visitor *visitor) visitor->endVisit(this); } +namespace { +struct LocaleWithoutZeroPadding : public QLocale +{ + LocaleWithoutZeroPadding() + : QLocale(QLocale::C) + { + setNumberOptions(QLocale::OmitLeadingZeroInExponent | QLocale::OmitGroupSeparator); + } +}; +} + +QString NumericLiteralPropertyName::asString()const +{ + // Can't use QString::number here anymore as it does zero padding by default now. + + // In C++11 this initialization is thread-safe (6.7 [stmt.dcl] p4) + static LocaleWithoutZeroPadding locale; + // Because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83562 we can't use thread_local + // for the locale variable and therefore rely on toString(double) to be thread-safe. + return locale.toString(id, 'g', 16); +} + void ArrayMemberExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h index ed3c83badf..9c5fd5adf6 100644 --- a/src/qml/parser/qqmljsast_p.h +++ b/src/qml/parser/qqmljsast_p.h @@ -760,7 +760,7 @@ public: void accept0(Visitor *visitor) override; - QString asString() const override { return QString::number(id, 'g', 16); } + QString asString() const override; // attributes double id; -- cgit v1.2.3