diff options
author | Bea Lam <bea.lam@nokia.com> | 2011-07-13 13:46:57 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-21 02:35:45 +0200 |
commit | 0592e17e18e26acc177bc7556a3c9888582f0045 (patch) | |
tree | c66df0adb57ecfbd7eab1105f139e10aed72da36 /src/declarative/items/qsggridview.cpp | |
parent | 7141596fae74938c907209482a46ecb73df1d4f8 (diff) |
Make lastPosition() result consistent among GridView and ListView
lastPosition() returns the end position of the last item so it should
always include a -1 calculation for the last item (as
FxListItemSG::endPosition() and FxGridItemSG::endPosition() do) to get
the last edge pixel of the item. With this fix, both views now
calculate startPosition() and endPosition() in the same way.
This also fixes positioning of GridView items in TopToBottom+RightToLeft
layouts. Incorrect test values in positionViewAtIndex_rightToLeft()
test are fixed (the last edge of a 1-pixel border shouldn't be visible,
since the bottom edge of a 1-pixel border is actually drawn outside,
not inside, the Rectangle).
Change-Id: I253c3836f871c61e13c08f67007ebc75e09378d6
Reviewed-on: http://codereview.qt.nokia.com/1547
Reviewed-by: Bea Lam <bea.lam@nokia.com>
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Diffstat (limited to 'src/declarative/items/qsggridview.cpp')
-rw-r--r-- | src/declarative/items/qsggridview.cpp | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/src/declarative/items/qsggridview.cpp b/src/declarative/items/qsggridview.cpp index ab02dea33b..24fc70851c 100644 --- a/src/declarative/items/qsggridview.cpp +++ b/src/declarative/items/qsggridview.cpp @@ -147,13 +147,11 @@ public: virtual bool isContentFlowReversed() const; bool isRightToLeftTopToBottom() const; - virtual qreal startPosition() const; virtual qreal positionAt(int index) const; - virtual qreal endPosition() const; virtual qreal endPositionAt(int index) const; + virtual qreal originPosition() const; virtual qreal lastPosition() const; - qreal originPosition() const; int rowSize() const; int colSize() const; qreal colPosAt(int modelIndex) const; @@ -255,27 +253,19 @@ qreal QSGGridViewPrivate::originPosition() const qreal QSGGridViewPrivate::lastPosition() const { qreal pos = 0; - if (model && model->count()) - pos = rowPosAt(model->count() - 1) + rowSize(); + if (model && model->count()) { + // get end position of last item + // endPosition() of items calculate -1 to get last edge pixel, so do that here as well + pos = (rowPosAt(model->count() - 1) + rowSize()) - 1; + } return pos; } -qreal QSGGridViewPrivate::startPosition() const -{ - return isRightToLeftTopToBottom() ? -lastPosition()+1 : originPosition(); -} - qreal QSGGridViewPrivate::positionAt(int index) const { return rowPosAt(index); } -qreal QSGGridViewPrivate::endPosition() const -{ - return isRightToLeftTopToBottom() ? -originPosition()+1 : lastPosition(); - -} - qreal QSGGridViewPrivate::endPositionAt(int index) const { return rowPosAt(index) + rowSize(); @@ -524,8 +514,6 @@ bool QSGGridViewPrivate::removeNonVisibleItems(int bufferFrom, int bufferTo) void QSGGridViewPrivate::visibleItemsChanged() { - Q_Q(QSGGridView); - updateHeader(); updateFooter(); updateViewport(); @@ -680,7 +668,7 @@ void QSGGridViewPrivate::updateFooter() colOffset = gridItem->item->width()-cellWidth; } if (visibleItems.count()) { - qreal endPos = lastPosition(); + qreal endPos = lastPosition() + 1; if (findLastVisibleIndex() == model->count()-1) { gridItem->setPosition(colOffset, endPos + rowOffset); } else { |