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/qqmlobjectmodel_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/qqmlobjectmodel_p.h')
-rw-r--r-- | src/qmlmodels/qqmlobjectmodel_p.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/qmlmodels/qqmlobjectmodel_p.h b/src/qmlmodels/qqmlobjectmodel_p.h index 99a1fe2379..6c68e55012 100644 --- a/src/qmlmodels/qqmlobjectmodel_p.h +++ b/src/qmlmodels/qqmlobjectmodel_p.h @@ -72,6 +72,11 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlInstanceModel : public QObject QML_ANONYMOUS public: + enum ReusableFlag { + NotReusable, + Reusable + }; + virtual ~QQmlInstanceModel() {} enum ReleaseFlag { Referenced = 0x01, Destroyed = 0x02, Pooled = 0x04 }; @@ -80,13 +85,16 @@ public: virtual int count() const = 0; virtual bool isValid() const = 0; virtual QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) = 0; - virtual ReleaseFlags release(QObject *object) = 0; + virtual ReleaseFlags release(QObject *object, ReusableFlag reusableFlag = NotReusable) = 0; virtual void cancel(int) {} QString stringValue(int index, const QString &role) { return variantValue(index, role).toString(); } virtual QVariant variantValue(int, const QString &) = 0; virtual void setWatchedRoles(const QList<QByteArray> &roles) = 0; virtual QQmlIncubator::Status incubationStatus(int index) = 0; + virtual void drainReusableItemsPool(int maxPoolTime) { Q_UNUSED(maxPoolTime) } + virtual int poolSize() { return 0; } + virtual int indexOf(QObject *object, QObject *objectContext) const = 0; virtual const QAbstractItemModel *abstractItemModel() const { return nullptr; } @@ -125,7 +133,7 @@ public: int count() const override; bool isValid() const override; QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override; - ReleaseFlags release(QObject *object) override; + ReleaseFlags release(QObject *object, ReusableFlag reusable = NotReusable) override; QVariant variantValue(int index, const QString &role) override; void setWatchedRoles(const QList<QByteArray> &) override {} QQmlIncubator::Status incubationStatus(int index) override; |