For very large tables, don't fallback to rendering all rows

* lastRow can return -1 in some situations where there's no last row visible,
  but we don't want to render potentially millions of invisible rows.
This commit is contained in:
baldurk
2019-01-04 16:44:00 +00:00
parent cea0129b9a
commit f3dda7959e
+5 -1
View File
@@ -233,7 +233,11 @@ void RDTableView::paintEvent(QPaintEvent *e)
int firstRow = qMax(verticalHeader()->visualIndexAt(0), 0);
int lastRow = verticalHeader()->visualIndexAt(viewport()->height());
if(lastRow < 0)
lastRow = verticalHeader()->count() - 1;
{
// if lastRow is negative, display as many will fit. This is a reasonable upper bound without
// displaying all rows which could be massive
lastRow = firstRow + (viewport()->height() / qMax(1, rowHeight(firstRow))) + 1;
}
lastRow = qMin(lastRow, verticalHeader()->count() - 1);
int firstCol = qMax(horizontalHeader()->visualIndexAt(horizontalHeader()->pinnedWidth() + 1), 0);