QTableView: Make sure to repaint all needed cells during resizing

Don't try to update the scrollarea geometry while resizing a row or
column since this may lead in flickering and artifacts, esp when the
scroll mode is scrollPerItems. Instead do the calculation only when the
resize is finished.

Fixes: QTBUG-72870
Fixes: QTBUG-82595
Change-Id: Id6903c00485b3be6ed54bd5f9bcafdda6da21598
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Christian Ehrlicher 2020-03-10 21:42:11 +01:00
parent d55dad94f9
commit 1e03015d55

View File

@ -2939,14 +2939,17 @@ void QTableView::timerEvent(QTimerEvent *event)
Q_D(QTableView);
if (event->timerId() == d->columnResizeTimerID) {
updateGeometries();
killTimer(d->columnResizeTimerID);
d->columnResizeTimerID = 0;
const int oldScrollMax = horizontalScrollBar()->maximum();
if (horizontalHeader()->d_func()->state != QHeaderViewPrivate::ResizeSection) {
updateGeometries();
killTimer(d->columnResizeTimerID);
d->columnResizeTimerID = 0;
}
QRect rect;
int viewportHeight = d->viewport->height();
int viewportWidth = d->viewport->width();
if (d->hasSpans()) {
if (d->hasSpans() || horizontalScrollBar()->value() == oldScrollMax) {
rect = QRect(0, 0, viewportWidth, viewportHeight);
} else {
for (int i = d->columnsToUpdate.size()-1; i >= 0; --i) {
@ -2964,14 +2967,17 @@ void QTableView::timerEvent(QTimerEvent *event)
}
if (event->timerId() == d->rowResizeTimerID) {
updateGeometries();
killTimer(d->rowResizeTimerID);
d->rowResizeTimerID = 0;
const int oldScrollMax = verticalScrollBar()->maximum();
if (verticalHeader()->d_func()->state != QHeaderViewPrivate::ResizeSection) {
updateGeometries();
killTimer(d->rowResizeTimerID);
d->rowResizeTimerID = 0;
}
int viewportHeight = d->viewport->height();
int viewportWidth = d->viewport->width();
int top;
if (d->hasSpans()) {
if (d->hasSpans() || verticalScrollBar()->value() == oldScrollMax) {
top = 0;
} else {
top = viewportHeight;