diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-09-16 16:41:27 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-09-23 14:54:46 +0200 |
commit | 8e222a70d19d5eef616e1d6306415da64fbab4cb (patch) | |
tree | 535e4cd02c2dbca0289bc6ec39f2699856554737 /src/qml/qml/qqmllocale_p.h | |
parent | 90b5d7fa03f9818fa5edc897ee6a109fcc182b9e (diff) |
Allow proper registration of value types
You can now have an extension object on a value type that offers
additional properties. This is how we model the QtQuick value types. It
allows us to retrieve the extension's metaobject without using the
virtual functions in the value type provider.
As before, this mechanism is still rather dangerous and not fit for
public consumption. It relies on the extension object having exactly the
same layout as the original value type, and it hides any properties the
original value type might expose.
Furthermore we enforce now that gadgets should have lowercase names.
The ones that didn't before are split up into an anonymous value type
and a namespace that contains all the addressable bits.
Task-number: QTBUG-82443
Change-Id: Ic93d6764538d6ccc0774b3c5648eee08ba0939c0
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.h | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h index d7bff5a1b7..a1acb2bad8 100644 --- a/src/qml/qml/qqmllocale_p.h +++ b/src/qml/qml/qqmllocale_p.h @@ -91,35 +91,32 @@ private: }; -class Q_QML_PRIVATE_EXPORT QQmlLocale +namespace QQmlLocale { - Q_GADGET + Q_NAMESPACE QML_NAMED_ELEMENT(Locale) - QML_UNCREATABLE("Locale cannot be instantiated. Use Qt.locale().") QML_ADDED_IN_VERSION(2, 2) -public: - ~QQmlLocale(); - enum MeasurementSystem { MetricSystem = QLocale::MetricSystem, ImperialSystem = QLocale::ImperialSystem, ImperialUSSystem = QLocale::ImperialUSSystem, ImperialUKSystem = QLocale::ImperialUKSystem }; - Q_ENUM(MeasurementSystem) + Q_ENUM_NS(MeasurementSystem) + enum FormatType { LongFormat = QLocale::LongFormat, ShortFormat = QLocale::ShortFormat, NarrowFormat = QLocale::NarrowFormat }; - Q_ENUM(FormatType) + Q_ENUM_NS(FormatType) enum CurrencySymbolFormat { CurrencyIsoCode = QLocale::CurrencyIsoCode, CurrencySymbol = QLocale::CurrencySymbol, CurrencyDisplayName = QLocale::CurrencyDisplayName }; - Q_ENUM(CurrencySymbolFormat) + Q_ENUM_NS(CurrencySymbolFormat) // Qt defines Sunday as 7, but JS Date assigns Sunday 0 enum DayOfWeek { Sunday = 0, @@ -130,7 +127,7 @@ public: Friday = Qt::Friday, Saturday = Qt::Saturday }; - Q_ENUM(DayOfWeek) + Q_ENUM_NS(DayOfWeek) enum NumberOptions { DefaultNumberOptions = QLocale::DefaultNumberOptions, OmitGroupSeparator = QLocale::OmitGroupSeparator, @@ -140,17 +137,12 @@ public: IncludeTrailingZeroesAfterDot = QLocale::IncludeTrailingZeroesAfterDot, RejectTrailingZeroesAfterDot = QLocale::RejectTrailingZeroesAfterDot }; - Q_ENUM(NumberOptions) - - static QV4::ReturnedValue locale(QV4::ExecutionEngine *engine, const QString &localeName); - static QV4::ReturnedValue wrap(QV4::ExecutionEngine *engine, const QLocale &locale); - - static void registerStringLocaleCompare(QV4::ExecutionEngine *engine); - -private: - QQmlLocale(); + Q_ENUM_NS(NumberOptions) - static QV4::ReturnedValue method_localeCompare(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + QV4::ReturnedValue locale(QV4::ExecutionEngine *engine, const QString &localeName); + QV4::ReturnedValue wrap(QV4::ExecutionEngine *engine, const QLocale &locale); + void registerStringLocaleCompare(QV4::ExecutionEngine *engine); + QV4::ReturnedValue method_localeCompare(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); }; namespace QV4 { |