aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktableview_p_p.h
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-06-19 14:56:24 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-07-18 15:36:59 +0000
commit7661a4197ca7967db0913f888295bb332519fbcc (patch)
treed872ff4eb3166fd4418c998409455bf746aca1ee /src/quick/items/qquicktableview_p_p.h
parentfc0e40f413808dd1a7b5631e5f087c3970db2869 (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_p.h')
-rw-r--r--src/quick/items/qquicktableview_p_p.h40
1 files changed, 7 insertions, 33 deletions
diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h
index b11afb1e5a..cdea202024 100644
--- a/src/quick/items/qquicktableview_p_p.h
+++ b/src/quick/items/qquicktableview_p_p.h
@@ -161,28 +161,6 @@ public:
}
};
- struct ColumnRowSize
- {
- // ColumnRowSize is a helper class for storing row heights
- // and column widths. We calculate the average width of a column
- // the first time it's scrolled into view based on the size of
- // the loaded items in the new column. Since we never load more items
- // that what fits inside the viewport (cachebuffer aside), this calculation
- // would be different depending on which row you were at when the column
- // was scrolling in. To avoid that a column resizes when it's scrolled
- // in and out and in again, we store its width. But to avoid storing
- // the width for all columns, we choose to only store the width if it
- // differs from the column(s) to the left. The same logic applies for row heights.
- // 'index' translates to either 'row' or 'column'.
- int index;
- qreal size;
-
- static bool lessThan(const ColumnRowSize& a, const ColumnRowSize& b)
- {
- return a.index < b.index;
- }
- };
-
public:
QQuickTableViewPrivate();
~QQuickTableViewPrivate() override;
@@ -230,9 +208,10 @@ public:
bool tableInvalid = false;
bool tableRebuilding = false;
bool columnRowPositionsInvalid = false;
+ bool layoutWarningIssued = false;
- QVector<ColumnRowSize> columnWidths;
- QVector<ColumnRowSize> rowHeights;
+ QJSValue rowHeightProvider;
+ QJSValue columnWidthProvider;
const static QPoint kLeft;
const static QPoint kRight;
@@ -249,15 +228,12 @@ public:
int modelIndexAtCell(const QPoint &cell) const;
QPoint cellAtModelIndex(int modelIndex) const;
- void calculateColumnWidthsAfterRebuilding();
- void calculateRowHeightsAfterRebuilding();
- void calculateColumnWidth(int column);
- void calculateRowHeight(int row);
- void calculateEdgeSizeFromLoadRequest();
+ qreal sizeHintForColumn(int column);
+ qreal sizeHintForRow(int row);
void calculateTableSize();
- qreal columnWidth(int column);
- qreal rowHeight(int row);
+ qreal resolveColumnWidth(int column);
+ qreal resolveRowHeight(int row);
void relayoutTable();
void relayoutTableItems();
@@ -347,6 +323,4 @@ public:
QPoint cell;
};
-Q_DECLARE_TYPEINFO(QQuickTableViewPrivate::ColumnRowSize, Q_PRIMITIVE_TYPE);
-
QT_END_NAMESPACE