![]() |
Qt 6.x
The Qt SDK
|
#include "qqmlbuiltinfunctions_p.h"
#include <QtQml/qqmlcomponent.h>
#include <QtQml/qqmlfile.h>
#include <private/qqmlengine_p.h>
#include <private/qqmlcomponent_p.h>
#include <private/qqmlloggingcategory_p.h>
#include <private/qqmlstringconverters_p.h>
#include <private/qqmldelayedcallqueue_p.h>
#include <QFileInfo>
#include <private/qqmldebugconnector_p.h>
#include <private/qqmldebugserviceinterfaces_p.h>
#include <private/qqmlglobal_p.h>
#include <private/qqmlplatform_p.h>
#include <private/qv4engine_p.h>
#include <private/qv4functionobject_p.h>
#include <private/qv4include_p.h>
#include <private/qv4context_p.h>
#include <private/qv4stringobject_p.h>
#include <private/qv4dateobject_p.h>
#include <private/qv4mm_p.h>
#include <private/qv4jsonobject_p.h>
#include <private/qv4objectproto_p.h>
#include <private/qv4qobjectwrapper_p.h>
#include <private/qv4stackframe_p.h>
#include <QtCore/qstring.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qcryptographichash.h>
#include <QtCore/qrect.h>
#include <QtCore/qsize.h>
#include <QtCore/qpoint.h>
#include <QtCore/qurl.h>
#include <QtCore/qfile.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qloggingcategory.h>
#include <QDebug>
#include "moc_qqmlbuiltinfunctions_p.cpp"
Go to the source code of this file.
Macros | |
#define | THROW_TYPE_ERROR_WITH_MESSAGE(msg) |
Enumerations | |
enum | ConsoleLogTypes { Log , Info , Warn , Error } |
Functions | |
QT_BEGIN_NAMESPACE | Q_LOGGING_CATEGORY (lcRootProperties, "qt.qml.rootObjectProperties") |
Q_LOGGING_CATEGORY (lcQml, "qml") | |
Q_LOGGING_CATEGORY (lcJs, "js") | |
template<typename T > | |
void | addParameters (QJSEngine *e, QJSValue &result, int i, T parameter) |
template<> | |
void | addParameters< double > (QJSEngine *, QJSValue &result, int i, double parameter) |
template<typename T , typename ... Others> | |
void | addParameters (QJSEngine *e, QJSValue &result, int i, T parameter, Others... others) |
template<typename ... T> | |
static QVariant | constructFromJSValue (QJSEngine *e, QMetaType type, T... parameters) |
static QVariant | colorVariantFromJSValue (const QJSValue &color, bool *ok) |
static QTime | dateTimeToTime (const QDateTime &dateTime) |
static std::optional< QDate > | dateFromString (const QString &string, QV4::ExecutionEngine *engine) |
\qmlmethod string Qt::formatDate(datetime date, variant format, variant localeFormatOption) | |
static std::optional< QTime > | timeFromString (const QString &string, QV4::ExecutionEngine *engine) |
\qmlmethod string Qt::formatTime(datetime time, variant format, variant localeFormatOption) | |
static std::optional< QDateTime > | dateTimeFromString (const QString &string, QV4::ExecutionEngine *engine) |
\qmlmethod string Qt::formatDateTime(datetime dateTime, variant format, variant localeFormatOption) | |
DEFINE_OBJECT_VTABLE (QQmlBindingFunction) | |
static QString | jsStack (QV4::ExecutionEngine *engine) |
static QString | serializeArray (Object *array, ExecutionEngine *v4, QSet< QV4::Heap::Object * > &alreadySeen) |
static ReturnedValue | writeToConsole (const FunctionObject *b, const Value *argv, int argc, ConsoleLogTypes logType, bool printStack=false) |
DEFINE_OBJECT_VTABLE (ConsoleObject) | |
#define THROW_TYPE_ERROR_WITH_MESSAGE | ( | msg | ) |
Definition at line 57 of file qqmlbuiltinfunctions.cpp.
enum ConsoleLogTypes |
Enumerator | |
---|---|
Log | |
Info | |
Warn | |
Error |
Definition at line 1742 of file qqmlbuiltinfunctions.cpp.
Definition at line 490 of file qqmlbuiltinfunctions.cpp.
Referenced by addParameters(), and constructFromJSValue().
void addParameters | ( | QJSEngine * | e, |
QJSValue & | result, | ||
int | i, | ||
T | parameter, | ||
Others... | others | ||
) |
Definition at line 502 of file qqmlbuiltinfunctions.cpp.
References addParameters(), e, and i.
void addParameters< double > | ( | QJSEngine * | , |
QJSValue & | result, | ||
int | i, | ||
double | parameter | ||
) |
Definition at line 496 of file qqmlbuiltinfunctions.cpp.
References i.
Definition at line 624 of file qqmlbuiltinfunctions.cpp.
References QQmlStringConverters::colorFromString(), QVariant::fromValue(), and ok.
Referenced by QtObject::alpha(), QtObject::darker(), QtObject::lighter(), and QtObject::tint().
|
static |
Definition at line 509 of file qqmlbuiltinfunctions.cpp.
References addParameters(), QQmlValueTypeProvider::createValueType(), e, QVariant::isValid(), and variant.
Referenced by QtObject::matrix4x4(), QtObject::quaternion(), QtObject::vector2d(), QtObject::vector3d(), and QtObject::vector4d().
|
static |
\qmlmethod string Qt::formatDate(datetime date, variant format, variant localeFormatOption)
Returns a string representation of date, optionally formatted using format.
The date parameter may be a JavaScript Date
object, a \l{date}{date} property, a QDate, or QDateTime value. The format and localeFormatOption parameter may be any of the possible format values as described for \l{QtQml::Qt::formatDateTime()}{Qt.formatDateTime()}.
If format is not specified, date is formatted using \l {QLocale::FormatType}{Locale.ShortFormat} using the default locale.
Definition at line 781 of file qqmlbuiltinfunctions.cpp.
References arg, date, QDateTime::date(), dateTime, QV4::DateObject::dateTimeToDate(), engine, Qt::ISODate, QDate::isValid(), QDateTime::isValid(), qCWarning, QStringLiteral, QV4::DateObject::stringToDateTime(), and QJSEngine::throwError().
Referenced by QtObject::formatDate(), QtObject::formatDate(), and QQmlStringConverters::variantFromString().
|
static |
\qmlmethod string Qt::formatDateTime(datetime dateTime, variant format, variant localeFormatOption)
Returns a string representation of dateTime, optionally formatted using format and localeFormatOption.
The dateTime parameter may be a JavaScript Date
object, a \l{date}{date} property, a QDate, QTime, or QDateTime value.
If format is not provided, dateTime is formatted using \l {QLocale::FormatType}{Locale.ShortFormat} using the default locale. Otherwise, format should be either:
\list
Qt.RFC2822Date
or Qt.ISODate
. locale
object. \endlistIf format specifies a locale object, \dateTime is formatted with \l{QLocale::toString}. In this case, localeFormatOption can hold a value of type \l {QLocale::FormatType} to further tune the formatting. If none is provided, \l {QLocale::FormatType}{Locale.ShortFormat} is used.
If format specifies a format string, it should use the following expressions to specify the date:
\table \header \li Expression \li Output \row \li d \li the day as number without a leading zero (1 to 31) \row \li dd \li the day as number with a leading zero (01 to 31) \row \li ddd \li the abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses QDate::shortDayName(). \row \li dddd \li the long localized day name (e.g. 'Monday' to 'Qt::Sunday'). Uses QDate::longDayName(). \row \li M \li the month as number without a leading zero (1-12) \row \li MM \li the month as number with a leading zero (01-12) \row \li MMM \li the abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses QDate::shortMonthName(). \row \li MMMM \li the long localized month name (e.g. 'January' to 'December'). Uses QDate::longMonthName(). \row \li yy \li the year as two digit number (00-99) \row \li yyyy \li the year as four digit number \endtable
In addition the following expressions can be used to specify the time:
\table \header \li Expression \li Output \row \li h \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) \row \li hh \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) \row \li m \li the minute without a leading zero (0 to 59) \row \li mm \li the minute with a leading zero (00 to 59) \row \li s \li the second without a leading zero (0 to 59) \row \li ss \li the second with a leading zero (00 to 59) \row \li z \li the milliseconds without leading zeroes (0 to 999) \row \li zzz \li the milliseconds with leading zeroes (000 to 999) \row \li AP \li use AM/PM display. \e AP will be replaced by either "AM" or "PM". \row \li ap \li use am/pm display. \e ap will be replaced by either "am" or "pm". \row \li t \li include a time-zone indicator. \endtable All other input characters will be ignored. Any sequence of characters that are enclosed in single quotes will be treated as text and not be used as an expression. Two consecutive single quotes ("''") are replaced by a single quote in the output.
For example, if the following date/time value was specified:
\code // 21 May 2001 14:13:09 var dateTime = new Date(2001, 5, 21, 14, 13, 09) \endcode
This dateTime value could be passed to Qt.formatDateTime()
, \l {QtQml::Qt::formatDate()}{Qt.formatDate()} or \l {QtQml::Qt::formatTime()}{Qt.formatTime()} with the format values below to produce the following results:
\table \header \li Format \li Result \row \li "dd.MM.yyyy" \li 21.05.2001 \row \li "ddd MMMM d yy" \li Tue May 21 01 \row \li "hh:mm:ss.zzz" \li 14:13:09.042 \row \li "h:m:s ap" \li 2:13:9 pm \endtable \sa Locale
Definition at line 1074 of file qqmlbuiltinfunctions.cpp.
References arg, dateTime, engine, Qt::ISODate, QDateTime::isValid(), QStringLiteral, QV4::DateObject::stringToDateTime(), and QJSEngine::throwError().
Referenced by QtObject::formatDateTime(), QtObject::formatDateTime(), and QQmlStringConverters::variantFromString().
Definition at line 760 of file qqmlbuiltinfunctions.cpp.
References dateTime, QDateTime::time(), and QDateTime::toLocalTime().
Referenced by QtObject::formatTime(), QtObject::formatTime(), and timeFromString().
DEFINE_OBJECT_VTABLE | ( | ConsoleObject | ) |
DEFINE_OBJECT_VTABLE | ( | QQmlBindingFunction | ) |
|
static |
Definition at line 1749 of file qqmlbuiltinfunctions.cpp.
References QList< T >::at(), engine, frame, i, QString::number(), qAbs(), QStringLiteral, and QList< T >::size().
Referenced by QV4::ConsoleObject::method_assert(), QV4::ConsoleObject::method_trace(), and writeToConsole().
Q_LOGGING_CATEGORY | ( | lcJs | , |
"js" | |||
) |
Q_LOGGING_CATEGORY | ( | lcQml | , |
"qml" | |||
) |
QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY | ( | lcRootProperties | , |
"qt.qml.rootObjectProperties" | |||
) |
|
static |
Definition at line 1774 of file qqmlbuiltinfunctions.cpp.
References QSet< T >::contains(), i, QSet< T >::insert(), QSet< T >::remove(), and serializeArray().
Referenced by serializeArray(), and writeToConsole().
|
static |
\qmlmethod string Qt::formatTime(datetime time, variant format, variant localeFormatOption)
Returns a string representation of time, optionally formatted using format, and, if provided, localeFormatOption.
The time parameter may be a JavaScript Date
object, a QTime, or QDateTime value. The format and localeFormatOption parameter may be any of the possible format values as described for \l{QtQml::Qt::formatDateTime()}{Qt.formatDateTime()}.
If format is not specified, time is formatted using \l {QLocale::FormatType}{Locale.ShortFormat} using the default locale.
Definition at line 886 of file qqmlbuiltinfunctions.cpp.
References arg, dateTime, dateTimeToTime(), engine, Qt::ISODate, QTime::isValid(), QDateTime::isValid(), qCWarning, QStringLiteral, QV4::DateObject::stringToDateTime(), QJSEngine::throwError(), time, and QDateTime::time().
Referenced by QtObject::formatTime(), QtObject::formatTime(), and QQmlStringConverters::variantFromString().
|
static |
Definition at line 1799 of file qqmlbuiltinfunctions.cpp.
References category(), QLoggingCategory::categoryName(), QByteArray::constData(), QV4::EngineBase::currentStackFrame, QV4::Scope::engine, Error, frame, i, Info, QLoggingCategory::isCriticalEnabled(), QLoggingCategory::isDebugEnabled(), QLoggingCategory::isInfoEnabled(), QLoggingCategory::isWarningEnabled(), jsStack(), Log, managed(), QV4::ExecutionEngine::qmlEngine(), serializeArray(), THROW_GENERIC_ERROR, QV4::Encode::undefined(), Warn, and wrapper().
Referenced by QV4::ConsoleObject::method_error(), QV4::ConsoleObject::method_exception(), QV4::ConsoleObject::method_info(), QV4::ConsoleObject::method_log(), and QV4::ConsoleObject::method_warn().