diff options
author | Alexander Volkov <a.volkov@rusbitech.ru> | 2019-02-01 15:34:49 +0300 |
---|---|---|
committer | Alexander Volkov <a.volkov@rusbitech.ru> | 2019-02-06 09:50:58 +0000 |
commit | f6edb0ef721c5c3734c2c05352febf0f9003ef6a (patch) | |
tree | aa79a7b474e7708c13a7a311e98d1114f70763b7 /tests/auto | |
parent | 670b8433697d0f71e5abc349aa0c53436f995c15 (diff) |
Improve keyboard navigation in QListView when isWrapping is enabled
Search the previous item or the next item in a model instead
of searching them on visual layout. This way the cursor will
not stop at the beginning or at the end of a row or a column.
Fixes: QTBUG-14444
Change-Id: I0ef203a4dcd876e4c50559fb87e61585f07434d1
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index 5227db64ec..9175c0bff4 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -380,8 +380,11 @@ void tst_QListView::cursorMove() << Qt::Key_Up << Qt::Key_Up << Qt::Key_Up << Qt::Key_Up << Qt::Key_Up << Qt::Key_Left << Qt::Key_Left << Qt::Key_Up << Qt::Key_Down; - int displayRow = rows / displayColumns - 1; - int displayColumn = displayColumns - (rows % displayColumns) - 1; + int lastRow = rows / displayColumns - 1; + int lastColumn = displayColumns - 1; + + int displayRow = lastRow; + int displayColumn = lastColumn - (rows % displayColumns); QApplication::instance()->processEvents(); for (int i = 0; i < keymoves.size(); ++i) { @@ -395,10 +398,24 @@ void tst_QListView::cursorMove() displayRow = qMin(rows / displayColumns - 1, displayRow + 1); break; case Qt::Key_Left: - displayColumn = qMax(0, displayColumn - 1); + if (displayColumn > 0) { + displayColumn--; + } else { + if (displayRow > 0) { + displayRow--; + displayColumn = lastColumn; + } + } break; case Qt::Key_Right: - displayColumn = qMin(displayColumns-1, displayColumn + 1); + if (displayColumn < lastColumn) { + displayColumn++; + } else { + if (displayRow < lastRow) { + displayRow++; + displayColumn = 0; + } + } break; default: QVERIFY(false); |