diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2018-09-28 10:57:35 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2018-10-04 07:00:50 +0000 |
commit | b2610d9d04c2a65d60b36ebf43e3a8d469c0397a (patch) | |
tree | 20b0dd669ea8eaa7f2128443def81cc2d3066aa1 /src/quick/items/qquickgridview.cpp | |
parent | bd28fb093c422a802f34a9e8f8a3b031757e8920 (diff) |
QQuickGridView: Respect margins
The margin has to be taken into account when calculating the positions
for the dimension we are not scrolling and when calculating the number
of columns available.
Fixes: QTBUG-69863
Change-Id: Id2a53ced263c8926a8bfaf658376be293af3e8c9
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/quick/items/qquickgridview.cpp')
-rw-r--r-- | src/quick/items/qquickgridview.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp index d7b3b0708c..272d4a4df5 100644 --- a/src/quick/items/qquickgridview.cpp +++ b/src/quick/items/qquickgridview.cpp @@ -417,11 +417,11 @@ qreal QQuickGridViewPrivate::contentXForPosition(qreal pos) const if (flow == QQuickGridView::FlowLeftToRight) { // vertical scroll if (q->effectiveLayoutDirection() == Qt::LeftToRight) { - return 0; + return -q->leftMargin(); } else { qreal colSize = cellWidth; - int columns = q->width()/colSize; - return -q->width() + (cellWidth * columns); + int columns = (q->width() - q->leftMargin() - q->rightMargin()) / colSize; + return -q->width() + q->rightMargin() + (cellWidth * columns); } } else { // horizontal scroll @@ -444,16 +444,18 @@ qreal QQuickGridViewPrivate::contentYForPosition(qreal pos) const } else { // horizontal scroll if (verticalLayoutDirection == QQuickItemView::TopToBottom) - return 0; + return -q->topMargin(); else - return -q->height(); + return -q->height() + q->bottomMargin(); } } void QQuickGridViewPrivate::resetColumns() { Q_Q(QQuickGridView); - qreal length = flow == QQuickGridView::FlowLeftToRight ? q->width() : q->height(); + qreal length = flow == QQuickGridView::FlowLeftToRight + ? q->width() - q->leftMargin() - q->rightMargin() + : q->height() - q->topMargin() - q->bottomMargin(); columns = qMax(1, qFloor(length / colSize())); } |