When doing a PageDown or PageUp it should show the next set of cells
Before it would skip out a row depending on the size of the tableview. Now it will show the next set of cells for the direction it is going in. Change-Id: I02926d0b2187ffafffb63f7fff43c233b4d7d6af Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>bb10
parent
b242ab7b10
commit
f5dc5225f6
|
|
@ -1755,13 +1755,13 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi
|
|||
visualRow = bottom;
|
||||
break;
|
||||
case MovePageUp: {
|
||||
int newRow = rowAt(visualRect(current).top() - d->viewport->height());
|
||||
int newRow = rowAt(visualRect(current).bottom() - d->viewport->height());
|
||||
if (newRow == -1)
|
||||
newRow = d->logicalRow(0);
|
||||
return d->model->index(newRow, current.column(), d->root);
|
||||
}
|
||||
case MovePageDown: {
|
||||
int newRow = rowAt(visualRect(current).bottom() + d->viewport->height());
|
||||
int newRow = rowAt(visualRect(current).top() + d->viewport->height());
|
||||
if (newRow == -1)
|
||||
newRow = d->logicalRow(bottom);
|
||||
return d->model->index(newRow, current.column(), d->root);
|
||||
|
|
|
|||
|
|
@ -106,6 +106,8 @@ private slots:
|
|||
void moveCursorStrikesBack_data();
|
||||
void moveCursorStrikesBack();
|
||||
|
||||
void moveCursorBiggerJump();
|
||||
|
||||
void hideRows_data();
|
||||
void hideRows();
|
||||
|
||||
|
|
@ -1353,6 +1355,34 @@ void tst_QTableView::moveCursorStrikesBack()
|
|||
QCOMPARE(newColumn, expectedColumn);
|
||||
}
|
||||
|
||||
void tst_QTableView::moveCursorBiggerJump()
|
||||
{
|
||||
QtTestTableModel model(50, 7);
|
||||
QTableView view;
|
||||
view.setModel(&model);
|
||||
view.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
||||
|
||||
int height = view.horizontalHeader()->height();
|
||||
for (int i=0;i<8;i++)
|
||||
height += view.verticalHeader()->sectionSize(i);
|
||||
view.resize(view.width(), height);
|
||||
view.setCurrentIndex(model.index(0,0));
|
||||
|
||||
QTest::keyClick(&view, Qt::Key_PageDown);
|
||||
QCOMPARE(view.indexAt(QPoint(0,0)), model.index(1,0));
|
||||
QTest::keyClick(&view, Qt::Key_PageDown);
|
||||
QCOMPARE(view.indexAt(QPoint(0,0)), model.index(8,0));
|
||||
QTest::keyClick(&view, Qt::Key_PageDown);
|
||||
QCOMPARE(view.indexAt(QPoint(0,0)), model.index(15,0));
|
||||
QTest::keyClick(&view, Qt::Key_PageUp);
|
||||
QCOMPARE(view.indexAt(QPoint(0,0)), model.index(14,0));
|
||||
QTest::keyClick(&view, Qt::Key_PageUp);
|
||||
QCOMPARE(view.indexAt(QPoint(0,0)), model.index(7,0));
|
||||
QTest::keyClick(&view, Qt::Key_PageUp);
|
||||
QCOMPARE(view.indexAt(QPoint(0,0)), model.index(0,0));
|
||||
}
|
||||
|
||||
void tst_QTableView::hideRows_data()
|
||||
{
|
||||
QTest::addColumn<int>("rowCount");
|
||||
|
|
@ -3761,8 +3791,6 @@ void tst_QTableView::task259308_scrollVerticalHeaderSwappedSections()
|
|||
QTRY_COMPARE(tv.rowAt(0), tv.verticalHeader()->logicalIndex(0));
|
||||
|
||||
int newRow = tv.rowAt(tv.viewport()->height());
|
||||
if (newRow == tv.rowAt(tv.viewport()->height() - 1)) // Overlapping row
|
||||
newRow++;
|
||||
QTest::keyClick(&tv, Qt::Key_PageDown); // Scroll down and check current
|
||||
QTRY_COMPARE(tv.currentIndex().row(), newRow);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue