Fix regression in QListView

The fix was originally applied to Qt 4.8 (4c64464), but missed
Qt 5 which had already been branched at that point of time.

Task-number: QTBUG-33089
Task-number: QTBUG-21433
Change-Id: Ia3cd35d29dbdc70ba55b6f0840c4082e232c24ae
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
This commit is contained in:
J-P Nurmi 2013-09-03 13:44:34 +02:00 committed by The Qt Project
parent cdbf8dd276
commit 5236f74942

View File

@ -1456,7 +1456,7 @@ void QListView::doItemsLayout()
void QListView::updateGeometries() void QListView::updateGeometries()
{ {
Q_D(QListView); Q_D(QListView);
if (d->model->rowCount(d->root) <= 0 || d->model->columnCount(d->root) <= 0) { if (geometry().isEmpty() || d->model->rowCount(d->root) <= 0 || d->model->columnCount(d->root) <= 0) {
horizontalScrollBar()->setRange(0, 0); horizontalScrollBar()->setRange(0, 0);
verticalScrollBar()->setRange(0, 0); verticalScrollBar()->setRange(0, 0);
} else { } else {
@ -1471,15 +1471,15 @@ void QListView::updateGeometries()
// if the scroll bars are turned off, we resize the contents to the viewport // if the scroll bars are turned off, we resize the contents to the viewport
if (d->movement == Static && !d->isWrapping()) { if (d->movement == Static && !d->isWrapping()) {
const QSize maxSize = maximumViewportSize(); d->layoutChildren(); // we need the viewport size to be updated
if (d->flow == TopToBottom) { if (d->flow == TopToBottom) {
if (horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) { if (horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
d->setContentsSize(maxSize.width(), contentsSize().height()); d->setContentsSize(viewport()->width(), contentsSize().height());
horizontalScrollBar()->setRange(0, 0); // we see all the contents anyway horizontalScrollBar()->setRange(0, 0); // we see all the contents anyway
} }
} else { // LeftToRight } else { // LeftToRight
if (verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) { if (verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
d->setContentsSize(contentsSize().width(), maxSize.height()); d->setContentsSize(contentsSize().width(), viewport()->height());
verticalScrollBar()->setRange(0, 0); // we see all the contents anyway verticalScrollBar()->setRange(0, 0); // we see all the contents anyway
} }
} }