summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/itemviews/qlistview.cpp12
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp30
2 files changed, 27 insertions, 15 deletions
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index 88002e0..b6e0ab7 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -1921,7 +1921,7 @@ void QListModeViewBase::updateHorizontalScrollBar(const QSize &step)
if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem
&& ((flow() == QListView::TopToBottom && isWrapping())
|| (flow() == QListView::LeftToRight && !isWrapping()))) {
- int steps = (flow() == QListView::TopToBottom ? segmentPositions : flowPositions).count() - 1;
+ int steps = (flow() == QListView::TopToBottom ? segmentPositions : scrollValueMap).count() - 1;
if (steps > 0) {
const int pageSteps = perItemScrollingPageSteps(viewport()->width(), contentsSize.width(), isWrapping());
horizontalScrollBar()->setSingleStep(1);
@@ -1966,8 +1966,8 @@ int QListModeViewBase::horizontalOffset() const
return (isRightToLeft() ? maximum - position : position);
}
} else if (flow() == QListView::LeftToRight && !flowPositions.isEmpty()) {
- int position = flowPositions.at(horizontalScrollBar()->value());
- int maximum = flowPositions.at(horizontalScrollBar()->maximum());
+ int position = flowPositions.at(scrollValueMap.at(horizontalScrollBar()->value()));
+ int maximum = flowPositions.at(scrollValueMap.at(horizontalScrollBar()->maximum()));
return (isRightToLeft() ? maximum - position : position);
}
}
@@ -2000,7 +2000,7 @@ int QListModeViewBase::horizontalScrollToValue(int index, QListView::ScrollHint
if (horizontalScrollMode() != QAbstractItemView::ScrollPerItem)
return QCommonListViewBase::horizontalScrollToValue(index, hint, leftOf, rightOf, area, rect);
- int value = qBound(0, horizontalScrollBar()->value(), flowPositions.count() - 1);
+ int value = qBound(0, scrollValueMap.at(horizontalScrollBar()->value()), flowPositions.count() - 1);
if (leftOf)
hint = QListView::PositionAtTop;
else if (rightOf)
@@ -2049,8 +2049,8 @@ void QListModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand)
} else if (horizontal && flow() == QListView::LeftToRight && dx != 0) {
int currentValue = qBound(0, horizontalValue, max);
int previousValue = qBound(0, currentValue + dx, max);
- int currentCoordinate = flowPositions.at(currentValue);
- int previousCoordinate = flowPositions.at(previousValue);
+ int currentCoordinate = flowPositions.at(scrollValueMap.at(currentValue));
+ int previousCoordinate = flowPositions.at(scrollValueMap.at(previousValue));
dx = previousCoordinate - currentCoordinate;
}
}
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index ed02317..6e211ae 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -117,7 +117,8 @@ private slots:
void shiftSelectionWithNonUniformItemSizes();
void clickOnViewportClearsSelection();
void task262152_setModelColumnNavigate();
- void taskQTBUG_2233_scrollHiddenRows();
+ void taskQTBUG_2233_scrollHiddenItems_data();
+ void taskQTBUG_2233_scrollHiddenItems();
};
// Testing get/set functions
@@ -1781,18 +1782,27 @@ void tst_QListView::task262152_setModelColumnNavigate()
view.setModelColumn(1);
view.show();
- QTest::qWait(30);
+ QTest::qWait(100);
QTest::keyClick(&view, Qt::Key_Down);
- QTest::qWait(10);
+ QTest::qWait(100);
QCOMPARE(view.currentIndex(), model.index(1,1));
QTest::keyClick(&view, Qt::Key_Down);
- QTest::qWait(10);
+ QTest::qWait(100);
QCOMPARE(view.currentIndex(), model.index(2,1));
}
-void tst_QListView::taskQTBUG_2233_scrollHiddenRows()
+void tst_QListView::taskQTBUG_2233_scrollHiddenItems_data()
{
+ QTest::addColumn<int>("flow");
+
+ QTest::newRow("TopToBottom") << static_cast<int>(QListView::TopToBottom);
+ QTest::newRow("LeftToRight") << static_cast<int>(QListView::LeftToRight);
+}
+
+void tst_QListView::taskQTBUG_2233_scrollHiddenItems()
+{
+ QFETCH(int, flow);
const int rowCount = 200;
QListView view;
@@ -1804,14 +1814,16 @@ void tst_QListView::taskQTBUG_2233_scrollHiddenRows()
model.setStringList(list);
view.setModel(&model);
view.setViewMode(QListView::ListMode);
- view.setFlow(QListView::TopToBottom);
for (int i = 0; i < rowCount / 2; ++i)
view.setRowHidden(2 * i, true);
- view.resize(250, 130);
+ view.setFlow(static_cast<QListView::Flow>(flow));
+ view.resize(130, 130);
for (int i = 0; i < 10; ++i) {
- view.verticalScrollBar()->setValue(i);
- QModelIndex index = view.indexAt(QPoint(20,0));
+ (view.flow() == QListView::TopToBottom
+ ? view.verticalScrollBar()
+ : view.horizontalScrollBar())->setValue(i);
+ QModelIndex index = view.indexAt(QPoint(0,0));
QVERIFY(index.isValid());
QCOMPARE(index.row(), 2 * i + 1);
}