A change in ListView's header height can cause it to overlap the items
If there are no visibleItems the header has no choice but to set visiblePos to a value after itself. Change-Id: I7748db46272989e421eeca88577b6fcf79814b5b Fixes: QTBUG-19844 Reviewed-on: http://codereview.qt.nokia.com/2254 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Bea Lam <bea.lam@nokia.com>
This commit is contained in:
parent
a8d3802938
commit
3b3a997cfa
|
@ -1281,8 +1281,7 @@ void QDeclarative1ListViewPrivate::updateHeader()
|
|||
header->setPosition(startPos - header->size());
|
||||
}
|
||||
} else {
|
||||
if (itemCount == 0)
|
||||
visiblePos = header->size();
|
||||
visiblePos = header->size();
|
||||
header->setPosition(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1948,6 +1948,38 @@ void tst_QDeclarative1ListView::header()
|
|||
model.clear();
|
||||
QTRY_COMPARE(header->y(), 0.0);
|
||||
|
||||
delete canvas;
|
||||
}
|
||||
{
|
||||
// QTBUG-19844
|
||||
QDeclarativeView *canvas = createView();
|
||||
|
||||
TestModel model;
|
||||
|
||||
QDeclarativeContext *ctxt = canvas->rootContext();
|
||||
ctxt->setContextProperty("testModel", &model);
|
||||
|
||||
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml"));
|
||||
qApp->processEvents();
|
||||
|
||||
QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
|
||||
QTRY_VERIFY(listview != 0);
|
||||
|
||||
QDeclarativeItem *contentItem = listview->contentItem();
|
||||
QTRY_VERIFY(contentItem != 0);
|
||||
|
||||
QDeclarative1Text *header = findItem<QDeclarative1Text>(contentItem, "header");
|
||||
QVERIFY(header);
|
||||
|
||||
header->setHeight(500);
|
||||
|
||||
model.addItem("Item 0", "");
|
||||
|
||||
header->setHeight(40);
|
||||
QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0);
|
||||
QVERIFY(item);
|
||||
QTRY_VERIFY(header->y() + header->height() == item->y());
|
||||
|
||||
delete canvas;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue