diff options
author | Ulf Hermann <[email protected]> | 2025-05-26 17:07:28 +0200 |
---|---|---|
committer | Ulf Hermann <[email protected]> | 2025-05-29 19:03:34 +0200 |
commit | 58f50363b1e7d21d20b83bac945bd24e85863885 (patch) | |
tree | 56ebcb2a1e6f4697742f85e7bcdfa610ac2659a9 /src/location/quickmapitems/qdeclarativegeomapitemview.cpp | |
parent | 7142e4bcceb6017191dc22935f0758bd68a25e5c (diff) |
It mirrors the same property from any internal delegate model. By
default, the value is "Qt5ReadWrite".
[ChangeLog][Location] MapItemView now has a new property
delegateModelAccess. Setting it to DelegateModel.ReadWrite allows you to
write values into the model via required properties just as you could
with context properties.
Task-number: QTBUG-132420
Change-Id: Ie0795fc6f793e71def2a9fa2af711dfac942ddfc
Reviewed-by: Fabian Kosmale <[email protected]>
Reviewed-by: Matthias Rauter <[email protected]>
Diffstat (limited to 'src/location/quickmapitems/qdeclarativegeomapitemview.cpp')
-rw-r--r-- | src/location/quickmapitems/qdeclarativegeomapitemview.cpp | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/src/location/quickmapitems/qdeclarativegeomapitemview.cpp b/src/location/quickmapitems/qdeclarativegeomapitemview.cpp index a97174a6..aae41965 100644 --- a/src/location/quickmapitems/qdeclarativegeomapitemview.cpp +++ b/src/location/quickmapitems/qdeclarativegeomapitemview.cpp @@ -87,6 +87,7 @@ void QDeclarativeGeoMapItemView::componentComplete() if (m_delegate) m_delegateModel->setDelegate(m_delegate); + m_delegateModel->setDelegateModelAccess(m_delegateModelAccess); m_delegateModel->componentComplete(); } @@ -189,8 +190,14 @@ void QDeclarativeGeoMapItemView::setModel(const QVariant &model) return; m_itemModel = model; - if (m_componentCompleted) + if (m_componentCompleted) { + + // Make sure to clear all stale items from the map and the model + m_delegateModel->drainReusableItemsPool(0); + removeInstantiatedItems(false); + m_delegateModel->setModel(m_itemModel); + } emit modelChanged(); } @@ -315,6 +322,46 @@ bool QDeclarativeGeoMapItemView::incubateDelegates() const return m_incubationMode == QQmlIncubator::Asynchronous; } +/*! + \qmlproperty enumeration QtLocation::MapItemView::delegateModelAccess + \since 6.10 + + This property determines how delegates can access the model. + + \value DelegateModel.ReadOnly + Prohibit delegates from writing the model via either context properties, + the \c model object, or required properties. + + \value DelegateModel.ReadWrite + Allow delegates to write the model via either context properties, + the \c model object, or required properties. + + \value DelegateModel.Qt5ReadWrite + Allow delegates to write the model via the \c model object and context + properties but \e not via required properties. + + The default is \c DelegateModel.Qt5ReadWrite. + + \sa {Models and Views in Qt Quick#Changing Model Data} +*/ +QQmlDelegateModel::DelegateModelAccess QDeclarativeGeoMapItemView::delegateModelAccess() const +{ + return m_delegateModelAccess; +} + +void QDeclarativeGeoMapItemView::setDelegateModelAccess( + QQmlDelegateModel::DelegateModelAccess delegateModelAccess) +{ + if (m_delegateModelAccess == delegateModelAccess) + return; + + m_delegateModelAccess = delegateModelAccess; + if (m_componentCompleted) + m_delegateModel->setDelegateModelAccess(m_delegateModelAccess); + + emit delegateModelAccessChanged(); +} + QList<QQuickItem *> QDeclarativeGeoMapItemView::mapItems() { return m_instantiatedItems; |