diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-06-19 14:56:24 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-07-18 15:36:59 +0000 |
commit | 7661a4197ca7967db0913f888295bb332519fbcc (patch) | |
tree | d872ff4eb3166fd4418c998409455bf746aca1ee /src/quick/items/qquicktableview_p.h | |
parent | fc0e40f413808dd1a7b5631e5f087c3970db2869 (diff) |
QQuickTableView: change how tableview resolves column width and row height
The current solution of storing column widths as the user flicks around
turns out to not scale so well for huge data models. We basically don't
want to take on the responsibility of storing column widths and row
heights for e.g 100 000 rows/columns. Instead, we now choose to ask the
application for the sizes, whenever we need them. This way, the application
developer can optimize how to store/calculate/determine/persist row and
column sizes locally.
To implement this functionality, we add two new properties:
rowHeightProvider and columnWidthProvider. They both accept a javascript
function that takes one argument (row or column), and returns the
corresponing row height or column width.
If no function is assigned to the properties, TableView will calculate
the row height / column width based on the currently visible items, as
before.
Change-Id: I6e5552599f63c896531cf3963e8745658ba4d45a
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.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/quick/items/qquicktableview_p.h b/src/quick/items/qquicktableview_p.h index d2c3f17bc4..c0dbaf4d48 100644 --- a/src/quick/items/qquicktableview_p.h +++ b/src/quick/items/qquicktableview_p.h @@ -60,7 +60,6 @@ QT_BEGIN_NAMESPACE class QQuickTableViewAttached; class QQuickTableViewPrivate; -class QQmlChangeSet; class Q_QUICK_PRIVATE_EXPORT QQuickTableView : public QQuickFlickable { @@ -75,7 +74,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTableView : public QQuickFlickable Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged) - + Q_PROPERTY(QJSValue rowHeightProvider READ rowHeightProvider WRITE setRowHeightProvider NOTIFY rowHeightProviderChanged) + 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) @@ -106,6 +106,12 @@ public: int cacheBuffer() const; void setCacheBuffer(int newBuffer); + QJSValue rowHeightProvider() const; + void setRowHeightProvider(QJSValue provider); + + QJSValue columnWidthProvider() const; + void setColumnWidthProvider(QJSValue provider); + QVariant model() const; void setModel(const QVariant &newModel); @@ -124,6 +130,8 @@ Q_SIGNALS: void leftMarginChanged(); void rightMarginChanged(); void cacheBufferChanged(); + void rowHeightProviderChanged(); + void columnWidthProviderChanged(); void modelChanged(); void delegateChanged(); |