aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmllocale_p.h
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2022-10-03 17:43:50 +0800
committerMitch Curtis <mitch.curtis@qt.io>2022-10-24 19:02:40 +0800
commitab52e478201ec692c1df66a08e01216bc7ea02ec (patch)
treeed76fdf402b2d4cb6970dcff3dbcdc174d5c7705 /src/qml/qml/qqmllocale_p.h
parent9ce90305f2836df8afc18db5c0d47ffdc2116a74 (diff)
Locale: add toString functions
Currently, it's not possible to show a single localized day number; Qt.formatDate can show it if "d" is passed as the format string, but that rules out passing a locale. If a locale is passed instead, you can only pass e.g. Locale.ShortFormat or another enum value as the extra argument, as opposed to a format string. This limitation requires users to implement conversion helpers in C++ that allow accounting for the locale. This patch exposes an appropriate subset of the existing date-to-string conversion functions from QLocale to the QML Locale type. For completeness, it also exposes the other relevant overloads: - toString(int i) - toString(double f, char format = 'g', int precision = 6) - toString(Date date, string format) - toString(Date date, FormatType format = LongFormat) [ChangeLog][QtQml][Locale] Added toString() overloads. Fixes: QTBUG-105506 Change-Id: I7061c68097cc11b69179117f5825e368bcfc296b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmllocale_p.h')
-rw-r--r--src/qml/qml/qqmllocale_p.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h
index eca6ebddce..7a497db523 100644
--- a/src/qml/qml/qqmllocale_p.h
+++ b/src/qml/qml/qqmllocale_p.h
@@ -118,6 +118,7 @@ struct QQmlLocaleData : public QV4::Object
static QV4::ReturnedValue method_standaloneMonthName(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
static QV4::ReturnedValue method_dayName(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
static QV4::ReturnedValue method_standaloneDayName(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
+ static QV4::ReturnedValue method_toString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
static QV4::ReturnedValue method_get_firstDayOfWeek(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
static QV4::ReturnedValue method_get_measurementSystem(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc);