diff options
author | Fabian Kosmale <[email protected]> | 2019-08-15 10:03:57 +0200 |
---|---|---|
committer | Fabian Kosmale <[email protected]> | 2019-09-12 09:19:25 +0200 |
commit | 0cc6d2a8ac895c592ccdc430ad08bd399e19ba19 (patch) | |
tree | 97107dcc00ab69b7ba885ad95ef2a411e5285e8b /src/qmlmodels/qqmltableinstancemodel.cpp | |
parent | 1909f99aac4a14d70ffcc004fc9e16c154485c25 (diff) |
Support required properties in model delegates
If a delegates declares a required property of a given name, and that
name exists as a role in the model, we set the property accordingly.
The same holds true for the special properties that come from the
QQmlDelegateModel like "index" and "model".
All roles are still injected into scope and thus accessible;
changing this in Qt5 would be tedious or even impossible while still
maintaining backwardscompatibility with delegates that do not use
required properties.
Change-Id: I4f388ba549c42f1ff9822bdb3b8357c4d45e4b66
Reviewed-by: Ulf Hermann <[email protected]>
Diffstat (limited to 'src/qmlmodels/qqmltableinstancemodel.cpp')
-rw-r--r-- | src/qmlmodels/qqmltableinstancemodel.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp index b244a007e5..9b79df3441 100644 --- a/src/qmlmodels/qqmltableinstancemodel.cpp +++ b/src/qmlmodels/qqmltableinstancemodel.cpp @@ -525,8 +525,13 @@ const QAbstractItemModel *QQmlTableInstanceModel::abstractItemModel() const void QQmlTableInstanceModelIncubationTask::setInitialState(QObject *object) { - modelItemToIncubate->object = object; - emit tableInstanceModel->initItem(modelItemToIncubate->index, object); + initializeRequiredProperties(modelItemToIncubate, object); + if (QQmlIncubatorPrivate::get(this)->requiredProperties().empty()) { + modelItemToIncubate->object = object; + emit tableInstanceModel->initItem(modelItemToIncubate->index, object); + } else { + object->deleteLater(); + } } void QQmlTableInstanceModelIncubationTask::statusChanged(QQmlIncubator::Status status) |