aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktableview_p.h
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-07-20 14:05:09 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-08-02 09:50:35 +0000
commit382812cd2917180a160917d24b11825a7eeb2cf1 (patch)
treedac6fbf8260e90e0347e23b5f863128d9689607c /src/quick/items/qquicktableview_p.h
parentca1f69757421845f563ebe90a5880509839efb31 (diff)
QQuickTableView: implement support for reusing delegate items
This patch will make use of the recent changes in QQmlTableInstanceModel to support reusing delegate items. The API in TableView to enable this will mainly be a new property "reuseItems". This property is true by default. By setting it to false, reusing items will never happen. When an item is reused, the signal "TableView.reused" is emitted after the fact, in case the delegate item needs to execute some extra code during the process. Likewise, a signal "TableView.pooled" is emitted when the item is pooled. From an implementation point of view, TableView only need to do two things to enable reusing of items. First, whenever it releases items, it provides a second argument to release(), informing QQmlTableInstanceModel if the item can be reused. Second, it needs to call drainReusePool() at appropriate times to ensure that no item will be kept alive in the pool for too long. Change-Id: I830e2eace776302ac58946733566208aa8954159 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quick/items/qquicktableview_p.h')
-rw-r--r--src/quick/items/qquicktableview_p.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/quick/items/qquicktableview_p.h b/src/quick/items/qquicktableview_p.h
index fe18de5cc4..fa7561554e 100644
--- a/src/quick/items/qquicktableview_p.h
+++ b/src/quick/items/qquicktableview_p.h
@@ -78,6 +78,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTableView : public QQuickFlickable
Q_PROPERTY(QJSValue columnWidthProvider READ columnWidthProvider WRITE setColumnWidthProvider NOTIFY columnWidthProviderChanged)
Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
+ Q_PROPERTY(bool reuseItems READ reuseItems WRITE setReuseItems NOTIFY reuseItemsChanged)
public:
QQuickTableView(QQuickItem *parent = nullptr);
@@ -118,6 +119,9 @@ public:
QQmlComponent *delegate() const;
void setDelegate(QQmlComponent *);
+ bool reuseItems() const;
+ void setReuseItems(bool reuseItems);
+
static QQuickTableViewAttached *qmlAttachedProperties(QObject *);
Q_SIGNALS:
@@ -134,6 +138,7 @@ Q_SIGNALS:
void columnWidthProviderChanged();
void modelChanged();
void delegateChanged();
+ void reuseItemsChanged();
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
@@ -165,6 +170,8 @@ public:
Q_SIGNALS:
void tableViewChanged();
+ void pooled();
+ void reused();
private:
QPointer<QQuickTableView> m_tableview;