diff options
Diffstat (limited to 'src/qml/qml/qqmllocale.cpp')
-rw-r--r-- | src/qml/qml/qqmllocale.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index dca13ac8d4..1743410776 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -478,6 +478,23 @@ ReturnedValue QQmlLocaleData::method_get_firstDayOfWeek(const QV4::FunctionObjec RETURN_RESULT(fdow); } +ReturnedValue QQmlLocaleData::method_get_numberOptions(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { + QV4::Scope scope(b); + const QLocale *locale = getThisLocale(scope, thisObject); + if (!locale) + return Encode::undefined(); + int numberOptions = int(locale->numberOptions()); + RETURN_RESULT(numberOptions); +} + +ReturnedValue QQmlLocaleData::method_set_numberOptions(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { + QV4::Scope scope(b); + QLocale *locale = getThisLocale(scope, thisObject); + int const numberOptions = argc ? int(argv[0].toNumber()) : QLocale::DefaultNumberOptions; + locale->setNumberOptions(QLocale::NumberOptions {numberOptions}); + return Encode::undefined(); +} + ReturnedValue QQmlLocaleData::method_get_measurementSystem(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::Scope scope(b); @@ -701,6 +718,7 @@ QV4LocaleDataDeletable::QV4LocaleDataDeletable(QV4::ExecutionEngine *engine) o->defineAccessorProperty(QStringLiteral("amText"), QQmlLocaleData::method_get_amText, nullptr); o->defineAccessorProperty(QStringLiteral("measurementSystem"), QQmlLocaleData::method_get_measurementSystem, nullptr); o->defineAccessorProperty(QStringLiteral("exponential"), QQmlLocaleData::method_get_exponential, nullptr); + o->defineAccessorProperty(QStringLiteral("numberOptions"), QQmlLocaleData::method_get_numberOptions, QQmlLocaleData::method_set_numberOptions); prototype.set(engine, o); } @@ -817,7 +835,7 @@ QV4::ReturnedValue QQmlLocale::locale(ExecutionEngine *engine, const QString &lo { QLocale qlocale; if (!localeName.isEmpty()) - qlocale = localeName; + qlocale = QLocale(localeName); return wrap(engine, qlocale); } @@ -873,6 +891,16 @@ ReturnedValue QQmlLocale::method_localeCompare(const QV4::FunctionObject *b, con */ /*! + \qmlproperty enumeration QtQml::Locale::NumberOption + + Holds a set of options for number-to-string and + string-to-number conversions. + + \sa Number::toLocaleString() + \sa Number::fromLocaleString() +*/ + +/*! \qmlproperty string QtQml::Locale::percent Holds the percent character of this locale. |