diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-05-18 13:41:04 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-05-28 15:10:05 +0000 |
commit | 2e17c1bed2f0690342f98130701ebfe088075a60 (patch) | |
tree | 1a5d21784a7dbebe6d53a5b9c29a6a29c83a5c25 /src/qml/types/qqmllistmodel_p_p.h | |
parent | 7f93ecd31494d17351ff8e16820b7117aa07d90b (diff) |
Fix language change support for qsTr in ListElement
We must store translations by binding reference in order to support
translation changes. This is similar to commit
db15c3455971f47b86078a44a30e0f0a13b54204.
[ChangeLog][QtQml] Fix QQmlEngine::retranslate() with ListElement
objects that use translation functions such as qsTr.
Task-number: QTBUG-68350
Change-Id: Ie5b4d5beb0505a260b524da820c0ce1142893d54
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/types/qqmllistmodel_p_p.h')
-rw-r--r-- | src/qml/types/qqmllistmodel_p_p.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h index 738ed0713e..75eeaeed0c 100644 --- a/src/qml/types/qqmllistmodel_p_p.h +++ b/src/qml/types/qqmllistmodel_p_p.h @@ -244,6 +244,22 @@ private: QStringHash<Role *> roleHash; }; +struct StringOrTranslation +{ + explicit StringOrTranslation(const QString &s); + explicit StringOrTranslation(const QV4::CompiledData::Binding *binding); + ~StringOrTranslation(); + bool isSet() const { return d.flag(); } + bool isTranslation() const { return d.isT2(); } + void setString(const QString &s); + void setTranslation(const QV4::CompiledData::Binding *binding); + QString toString(const QQmlListModel *owner) const; + QString asString() const; +private: + void clear(); + QBiPointer<QStringData, const QV4::CompiledData::Binding> d; +}; + /*! \internal */ @@ -279,6 +295,7 @@ private: int setVariantMapProperty(const ListLayout::Role &role, QVariantMap *m); int setDateTimeProperty(const ListLayout::Role &role, const QDateTime &dt); int setFunctionProperty(const ListLayout::Role &role, const QJSValue &f); + int setTranslationProperty(const ListLayout::Role &role, const QV4::CompiledData::Binding *b); void setStringPropertyFast(const ListLayout::Role &role, const QString &s); void setDoublePropertyFast(const ListLayout::Role &role, double n); @@ -293,7 +310,7 @@ private: QVariant getProperty(const ListLayout::Role &role, const QQmlListModel *owner, QV4::ExecutionEngine *eng); ListModel *getListProperty(const ListLayout::Role &role); - QString *getStringProperty(const ListLayout::Role &role); + StringOrTranslation *getStringProperty(const ListLayout::Role &role); QObject *getQObjectProperty(const ListLayout::Role &role); QPointer<QObject> *getGuardProperty(const ListLayout::Role &role); QVariantMap *getVariantMapProperty(const ListLayout::Role &role); |