Fix insertion of one item in ListView.

Off-by-one meant that the item was not created by the ListView.

Change-Id: If9658487a615e189c21c419e4d29e7e709e05cef
Fixes: QTBUG-19675
Reviewed-on: http://codereview.qt.nokia.com/2251
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Bea Lam <bea.lam@nokia.com>
This commit is contained in:
Martin Jones 2011-07-27 16:56:08 +10:00 committed by Qt by Nokia
parent aa99d4f5cb
commit a8d3802938
3 changed files with 17 additions and 1 deletions

View File

@ -3287,7 +3287,7 @@ void QDeclarative1ListView::itemsInserted(int modelIndex, int count)
}
} else {
int i = 0;
int to = d->buffer+tempPos+d->size()-1;
int to = d->buffer+tempPos+d->size();
for (i = 0; i < count && pos <= to; ++i) {
if (!addedVisible) {
d->scheduleLayout();

View File

@ -620,6 +620,14 @@ void tst_QSGListView::inserted()
// QTRY_COMPARE(listview->contentItemHeight(), model.count() * 20.0);
// QTBUG-19675
model.clear();
model.insertItem(0, "Hello", "1234");
QSGItem *item = findItem<QSGItem>(contentItem, "wrapper", 0);
QVERIFY(item);
QCOMPARE(item->y(), 0.);
QVERIFY(listview->contentY() == 0);
delete canvas;
delete testObject;
}

View File

@ -557,6 +557,14 @@ void tst_QDeclarative1ListView::inserted()
// QTRY_COMPARE(listview->contentItemHeight(), model.count() * 20.0);
// QTBUG-19675
model.clear();
model.insertItem(0, "Hello", "1234");
QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0);
QVERIFY(item);
QCOMPARE(item->y(), 0.);
QVERIFY(listview->contentY() == 0);
delete canvas;
delete testObject;
}