diff options
| author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2022-05-20 09:52:59 +0200 |
|---|---|---|
| committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2022-05-31 13:05:08 +0200 |
| commit | a1297194ca0b679eedf03a133fa1785a68bcc662 (patch) | |
| tree | 8af1d9f7c608eb9c1a9f6cb3011a3c63f0f7dcf3 /src/quick/items/qquicktableview.cpp | |
| parent | 065fb607863e6df5d079b27dd275790e64bd982c (diff) | |
QQuickTableView: ensure we use the correct margins during key navigation
Ensure we use the correct margins when navigating with the arrow
keys at the beginning and end of the table. When e.g navigating
to the first column in the model, we want to flick the view all
the way to the start, margins included.
It should already have worked like this, but must have
broke after earlier copy/pase operations.
Change-Id: I438b20518602e4cc5b49e137f633a7f550a9dec8
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquicktableview.cpp')
| -rw-r--r-- | src/quick/items/qquicktableview.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 899616f3d8..2e8d794385 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -4931,7 +4931,7 @@ void QQuickTableView::keyPressEvent(QKeyEvent *e) const int nextRow = d->nextVisibleEdgeIndex(Qt::TopEdge, currentCell.y() - 1); if (nextRow == kEdgeIndexAtEnd) break; - const qreal marginY = d->atTableEnd(Qt::TopEdge, nextRow - 1) ? topMargin() : 0; + const qreal marginY = d->atTableEnd(Qt::TopEdge, nextRow - 1) ? -topMargin() : 0; positionViewAtRow(nextRow, Contain, marginY); endMoveCurrentIndex({currentCell.x(), nextRow}); break; } @@ -4940,7 +4940,7 @@ void QQuickTableView::keyPressEvent(QKeyEvent *e) const int nextRow = d->nextVisibleEdgeIndex(Qt::BottomEdge, currentCell.y() + 1); if (nextRow == kEdgeIndexAtEnd) break; - const qreal marginY = d->atTableEnd(Qt::TopEdge, nextRow + 1) ? bottomMargin() : 0; + const qreal marginY = d->atTableEnd(Qt::BottomEdge, nextRow + 1) ? bottomMargin() : 0; positionViewAtRow(nextRow, Contain, marginY); endMoveCurrentIndex({currentCell.x(), nextRow}); break; } @@ -4949,7 +4949,7 @@ void QQuickTableView::keyPressEvent(QKeyEvent *e) const int nextColumn = d->nextVisibleEdgeIndex(Qt::LeftEdge, currentCell.x() - 1); if (nextColumn == kEdgeIndexAtEnd) break; - const qreal marginX = d->atTableEnd(Qt::LeftEdge, nextColumn - 1) ? leftMargin() : 0; + const qreal marginX = d->atTableEnd(Qt::LeftEdge, nextColumn - 1) ? -leftMargin() : 0; positionViewAtColumn(nextColumn, Contain, marginX); endMoveCurrentIndex({nextColumn, currentCell.y()}); break; } @@ -4958,7 +4958,7 @@ void QQuickTableView::keyPressEvent(QKeyEvent *e) const int nextColumn = d->nextVisibleEdgeIndex(Qt::RightEdge, currentCell.x() + 1); if (nextColumn == kEdgeIndexAtEnd) break; - const qreal marginX = d->atTableEnd(Qt::LeftEdge, nextColumn + 1) ? leftMargin() : 0; + const qreal marginX = d->atTableEnd(Qt::RightEdge, nextColumn + 1) ? rightMargin() : 0; positionViewAtColumn(nextColumn, Contain, marginX); endMoveCurrentIndex({nextColumn, currentCell.y()}); break; } |
