Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmlbuiltinfunctions.cpp File Reference

(1392a245a0800c5653e73d43704a32b2716f9834)

#include "qqmlbuiltinfunctions_p.h"
#include <private/qqmlcomponent_p.h>
#include <private/qqmldebugconnector_p.h>
#include <private/qqmldebugserviceinterfaces_p.h>
#include <private/qqmldelayedcallqueue_p.h>
#include <private/qqmlengine_p.h>
#include <private/qqmlloggingcategorybase_p.h>
#include <private/qqmlplatform_p.h>
#include <private/qqmlstringconverters_p.h>
#include <private/qv4dateobject_p.h>
#include <private/qv4domerrors_p.h>
#include <private/qv4engine_p.h>
#include <private/qv4functionobject_p.h>
#include <private/qv4include_p.h>
#include <private/qv4mm_p.h>
#include <private/qv4qobjectwrapper_p.h>
#include <private/qv4sequenceobject_p.h>
#include <private/qv4stackframe_p.h>
#include <QtQml/qqmlfile.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qcryptographichash.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qloggingcategory.h>
#include <QtCore/qpoint.h>
#include <QtCore/qrect.h>
#include <QtCore/qsize.h>
#include <QtCore/qstring.h>
#include <QtCore/qurl.h>
#include "moc_qqmlbuiltinfunctions_p.cpp"
Include dependency graph for qqmlbuiltinfunctions.cpp:

Go to the source code of this file.

Macros

#define THROW_TYPE_ERROR_WITH_MESSAGE(msg)

Enumerations

enum  ConsoleLogTypes {
  Log , Info , Warn , Error ,
  Log , Info , Warn , Error
}
enum  ConsoleLogTypes {
  Log , Info , Warn , Error ,
  Log , Info , Warn , Error
}

Functions

QT_BEGIN_NAMESPACE Q_STATIC_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< QDatedateFromString (const QString &string, QV4::ExecutionEngine *engine)
 \qmlmethod string Qt::formatDate(datetime date, variant format, variant localeFormatOption)
static std::optional< QTimetimeFromString (const QString &string, QV4::ExecutionEngine *engine)
 \qmlmethod string Qt::formatTime(datetime time, variant format, variant localeFormatOption)
static std::optional< QDateTimedateTimeFromString (const QString &string, QV4::ExecutionEngine *engine)
 \qmlmethod string Qt::formatDateTime(datetime dateTime, variant format, variant localeFormatOption)
static QV4::ReturnedValue throwInvalidCharacter (QV4::ExecutionEngine *engine)
static QByteArray convertVariantList (const QVariantList &data, QV4::ExecutionEngine *engine)
static Q_DECL_COLD_FUNCTION void throw_invalid_compilation_mode (QV4::ExecutionEngine *engine, QQmlComponent::CompilationMode mode)
 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)
template<>
void addParameters< double > (QJSEngine *, QJSValue &result, int i, double parameter)

Macro Definition Documentation

◆ THROW_TYPE_ERROR_WITH_MESSAGE

#define THROW_TYPE_ERROR_WITH_MESSAGE ( msg)
Value:
do { \
return scope.engine->throwTypeError(QString::fromUtf8(msg)); \
} while (false)
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:6061

Definition at line 46 of file qqmlbuiltinfunctions.cpp.

Enumeration Type Documentation

◆ ConsoleLogTypes [1/2]

Enumerator
Log 
Info 
Warn 
Error 
Log 
Info 
Warn 
Error 

Definition at line 1985 of file qqmlbuiltinfunctions.cpp.

◆ ConsoleLogTypes [2/2]

Enumerator
Log 
Info 
Warn 
Error 
Log 
Info 
Warn 
Error 

Definition at line 1985 of file qqmlbuiltinfunctions.cpp.

Function Documentation

◆ addParameters() [1/2]

template<typename T>
void addParameters ( QJSEngine * e,
QJSValue & result,
int i,
T parameter )

Definition at line 489 of file qqmlbuiltinfunctions.cpp.

◆ addParameters() [2/2]

template<typename T, typename ... Others>
void addParameters ( QJSEngine * e,
QJSValue & result,
int i,
T parameter,
Others... others )

Definition at line 501 of file qqmlbuiltinfunctions.cpp.

◆ addParameters< double >() [1/2]

template<>
void addParameters< double > ( QJSEngine * ,
QJSValue & result,
int i,
double parameter )

Definition at line 495 of file qqmlbuiltinfunctions.cpp.

◆ addParameters< double >() [2/2]

template<>
void addParameters< double > ( QJSEngine * ,
QJSValue & result,
int i,
double parameter )

Definition at line 495 of file qqmlbuiltinfunctions.cpp.

◆ colorVariantFromJSValue()

QVariant colorVariantFromJSValue ( const QJSValue & color,
bool * ok )
static

Definition at line 623 of file qqmlbuiltinfunctions.cpp.

◆ constructFromJSValue()

template<typename ... T>
QVariant constructFromJSValue ( QJSEngine * e,
QMetaType type,
T... parameters )
static

Definition at line 508 of file qqmlbuiltinfunctions.cpp.

◆ convertVariantList()

QByteArray convertVariantList ( const QVariantList & data,
QV4::ExecutionEngine * engine )
static

Definition at line 1317 of file qqmlbuiltinfunctions.cpp.

◆ dateFromString()

std::optional< QDate > dateFromString ( const QString & string,
QV4::ExecutionEngine * engine )
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.

See also
Locale

Definition at line 781 of file qqmlbuiltinfunctions.cpp.

◆ dateTimeFromString()

std::optional< QDateTime > dateTimeFromString ( const QString & string,
QV4::ExecutionEngine * engine )
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

If 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.

◆ dateTimeToTime()

QTime dateTimeToTime ( const QDateTime & dateTime)
static

Definition at line 760 of file qqmlbuiltinfunctions.cpp.

◆ DEFINE_OBJECT_VTABLE() [1/2]

DEFINE_OBJECT_VTABLE ( ConsoleObject )

◆ DEFINE_OBJECT_VTABLE() [2/2]

DEFINE_OBJECT_VTABLE ( QQmlBindingFunction )

◆ jsStack()

QString jsStack ( QV4::ExecutionEngine * engine)
static

Definition at line 1992 of file qqmlbuiltinfunctions.cpp.

◆ Q_LOGGING_CATEGORY() [1/2]

Q_LOGGING_CATEGORY ( lcJs ,
"js"  )

◆ Q_LOGGING_CATEGORY() [2/2]

Q_LOGGING_CATEGORY ( lcQml ,
"qml"  )

◆ Q_STATIC_LOGGING_CATEGORY()

QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY ( lcRootProperties ,
"qt.qml.rootObjectProperties"  )

◆ serializeArray()

QString serializeArray ( Object * array,
ExecutionEngine * v4,
QSet< QV4::Heap::Object * > & alreadySeen )
static

Definition at line 2019 of file qqmlbuiltinfunctions.cpp.

◆ throw_invalid_compilation_mode()

Q_DECL_COLD_FUNCTION void throw_invalid_compilation_mode ( QV4::ExecutionEngine * engine,
QQmlComponent::CompilationMode mode )
static

Definition at line 1655 of file qqmlbuiltinfunctions.cpp.

◆ throwInvalidCharacter()

QV4::ReturnedValue throwInvalidCharacter ( QV4::ExecutionEngine * engine)
static

Definition at line 1283 of file qqmlbuiltinfunctions.cpp.

◆ timeFromString()

std::optional< QTime > timeFromString ( const QString & string,
QV4::ExecutionEngine * engine )
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.

See also
Locale

Definition at line 886 of file qqmlbuiltinfunctions.cpp.

◆ writeToConsole()

ReturnedValue writeToConsole ( const FunctionObject * b,
const Value * argv,
int argc,
ConsoleLogTypes logType,
bool printStack = false )
static

Definition at line 2051 of file qqmlbuiltinfunctions.cpp.

References Error, Info, Log, and Warn.