diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-05-30 12:54:29 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-04 13:03:06 +0000 |
commit | 1cec68315de67e2e2a905e16b4054d8874532b8e (patch) | |
tree | e1efdbdb7eb9a72392e746d4723c3532501654bf /src/qml | |
parent | 5eee819890a4d874455900ecc8397555b81d23c8 (diff) |
QQmlDelegateModel: factor out addCacheItem()
The code for adding an item to the cache will also be needed
in subsequent patches for recycling items, so factor it out
into a function alongside removeCacheItem(). This patch will
not change any logic, it will just move the code out into a
separate function.
Change-Id: I199a4e1c823ded29c576afba12cddfa27a543431
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/types/qqmldelegatemodel.cpp | 12 | ||||
-rw-r--r-- | src/qml/types/qqmldelegatemodel_p_p.h | 1 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 61cbb8700a..78a7937e4b 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -891,6 +891,13 @@ void QQmlDelegateModelPrivate::releaseIncubator(QQDMIncubationTask *incubationTa } } +void QQmlDelegateModelPrivate::addCacheItem(QQmlDelegateModelItem *item, Compositor::iterator it) +{ + m_cache.insert(it.cacheIndex, item); + m_compositor.setFlags(it, 1, Compositor::CacheFlag); + Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache)); +} + void QQmlDelegateModelPrivate::removeCacheItem(QQmlDelegateModelItem *cacheItem) { int cidx = m_cache.lastIndexOf(cacheItem); @@ -980,10 +987,7 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQ return nullptr; cacheItem->groups = it->flags; - - m_cache.insert(it.cacheIndex, cacheItem); - m_compositor.setFlags(it, 1, Compositor::CacheFlag); - Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache)); + addCacheItem(cacheItem, it); } // Bump the reference counts temporarily so neither the content data or the delegate object diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h index 3f9dd12243..2c0383a7e2 100644 --- a/src/qml/types/qqmldelegatemodel_p_p.h +++ b/src/qml/types/qqmldelegatemodel_p_p.h @@ -269,6 +269,7 @@ public: Q_EMIT q_func()->initItem(incubationTask->index[m_compositorGroup], item); } void emitDestroyingPackage(QQuickPackage *package); void emitDestroyingItem(QObject *item) { Q_EMIT q_func()->destroyingItem(item); } + void addCacheItem(QQmlDelegateModelItem *item, Compositor::iterator it); void removeCacheItem(QQmlDelegateModelItem *cacheItem); void updateFilterGroup(); |