diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2019-09-12 14:14:05 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2019-12-04 01:34:07 +0100 |
commit | 4b58d69d56c5876a1b1d71ce6a96b4c6c81a833f (patch) | |
tree | 094a0240be7462a2768084985d49f2f58a294ab1 /src/qmlmodels/qqmltableinstancemodel_p.h | |
parent | af9a96ca10e72517a7e8aa1ada7ec2d635e2a9ff (diff) |
QQmlTableInstanceModel: factor out reuse pool
Factor out the reuse pool logic in TableInstanceModel into a
separate class, so that we can share it with the upcoming implementation
for recycling items in QQmlDelegateModel.
Change-Id: If8f700b7a0208bac7d1cb1de087792e2c3a9b512
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/qmlmodels/qqmltableinstancemodel_p.h')
-rw-r--r-- | src/qmlmodels/qqmltableinstancemodel_p.h | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/qmlmodels/qqmltableinstancemodel_p.h b/src/qmlmodels/qqmltableinstancemodel_p.h index 1ea5ee7401..d924455918 100644 --- a/src/qmlmodels/qqmltableinstancemodel_p.h +++ b/src/qmlmodels/qqmltableinstancemodel_p.h @@ -86,12 +86,6 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlTableInstanceModel : public QQmlInstanceMod Q_OBJECT public: - - enum ReusableFlag { - NotReusable, - Reusable - }; - QQmlTableInstanceModel(QQmlContext *qmlContext, QObject *parent = nullptr); ~QQmlTableInstanceModel() override; @@ -115,14 +109,11 @@ public: const QAbstractItemModel *abstractItemModel() const override; QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override; - ReleaseFlags release(QObject *object) override { return release(object, NotReusable); } - ReleaseFlags release(QObject *object, ReusableFlag reusable); + ReleaseFlags release(QObject *object, ReusableFlag reusable = NotReusable) override; void cancel(int) override; - void insertIntoReusableItemsPool(QQmlDelegateModelItem *modelItem); - QQmlDelegateModelItem *takeFromReusableItemsPool(const QQmlComponent *delegate); - void drainReusableItemsPool(int maxPoolTime); - int poolSize() { return m_reusableItemsPool.size(); } + void drainReusableItemsPool(int maxPoolTime) override; + int poolSize() override { return m_reusableItemsPool.size(); } void reuseItem(QQmlDelegateModelItem *item, int newModelIndex); QQmlIncubator::Status incubationStatus(int index) override; @@ -145,7 +136,7 @@ private: QQmlDelegateModelItemMetaType *m_metaType; QHash<int, QQmlDelegateModelItem *> m_modelItems; - QList<QQmlDelegateModelItem *> m_reusableItemsPool; + QQmlReusableDelegateModelItemsPool m_reusableItemsPool; QList<QQmlIncubator *> m_finishedIncubationTasks; void incubateModelItem(QQmlDelegateModelItem *modelItem, QQmlIncubator::IncubationMode incubationMode); @@ -153,6 +144,7 @@ private: void deleteIncubationTaskLater(QQmlIncubator *incubationTask); void deleteAllFinishedIncubationTasks(); QQmlDelegateModelItem *resolveModelItem(int index); + void destroyModelItem(QQmlDelegateModelItem *modelItem); void dataChangedCallback(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles); |