Fix min extents to correctly consider header size
Regression from c0fc795f
which changed implementation to always position
header at a negative position, and not just when visibleItems is empty.
Task-number: QTBUG-21207
Change-Id: I9a888e7e30b00f70835734b1e0e75e57ed282602
Reviewed-on: http://codereview.qt.nokia.com/4159
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
This commit is contained in:
parent
0fdd97f613
commit
8282beb53d
|
@ -973,7 +973,7 @@ qreal QSGItemView::minYExtent() const
|
|||
|
||||
if (d->minExtentDirty) {
|
||||
d->minExtent = -d->startPosition();
|
||||
if (d->header && d->visibleItems.count())
|
||||
if (d->header)
|
||||
d->minExtent += d->headerSize();
|
||||
if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) {
|
||||
d->minExtent += d->highlightRangeStart;
|
||||
|
@ -1044,7 +1044,7 @@ qreal QSGItemView::minXExtent() const
|
|||
endPositionFirstItem = d->endPositionAt(0);
|
||||
highlightStart = d->highlightRangeStart;
|
||||
highlightEnd = d->highlightRangeEnd;
|
||||
if (d->header && d->visibleItems.count())
|
||||
if (d->header)
|
||||
d->minExtent += d->headerSize();
|
||||
}
|
||||
if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) {
|
||||
|
@ -1093,7 +1093,7 @@ qreal QSGItemView::maxXExtent() const
|
|||
d->maxExtent = -(d->endPosition() - width());
|
||||
}
|
||||
if (d->isContentFlowReversed()) {
|
||||
if (d->header && d->visibleItems.count())
|
||||
if (d->header)
|
||||
d->maxExtent -= d->headerSize();
|
||||
} else {
|
||||
if (d->footer)
|
||||
|
|
|
@ -24,8 +24,8 @@ Rectangle {
|
|||
GridView {
|
||||
id: grid
|
||||
objectName: "grid"
|
||||
width: 240
|
||||
height: 320
|
||||
width: initialViewWidth
|
||||
height: initialViewHeight
|
||||
cellWidth: 80
|
||||
cellHeight: 60
|
||||
model: testModel
|
||||
|
|
|
@ -2459,17 +2459,15 @@ void tst_QSGGridView::header()
|
|||
QFETCH(QPointF, firstDelegatePos);
|
||||
QFETCH(QPointF, resizeContentPos);
|
||||
|
||||
QSGView *canvas = createView();
|
||||
|
||||
TestModel model;
|
||||
for (int i = 0; i < 30; i++)
|
||||
model.addItem("Item" + QString::number(i), "");
|
||||
|
||||
QDeclarativeContext *ctxt = canvas->rootContext();
|
||||
ctxt->setContextProperty("testModel", &model);
|
||||
|
||||
QSGView *canvas = createView();
|
||||
canvas->rootContext()->setContextProperty("testModel", &model);
|
||||
canvas->rootContext()->setContextProperty("initialViewWidth", 240);
|
||||
canvas->rootContext()->setContextProperty("initialViewHeight", 320);
|
||||
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml"));
|
||||
qApp->processEvents();
|
||||
|
||||
QSGGridView *gridview = findItem<QSGGridView>(canvas->rootObject(), "grid");
|
||||
QTRY_VERIFY(gridview != 0);
|
||||
|
@ -2525,6 +2523,27 @@ void tst_QSGGridView::header()
|
|||
QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), resizeContentPos);
|
||||
|
||||
delete canvas;
|
||||
|
||||
|
||||
// QTBUG-21207 header should become visible if view resizes from initial empty size
|
||||
|
||||
canvas = createView();
|
||||
canvas->rootContext()->setContextProperty("testModel", &model);
|
||||
canvas->rootContext()->setContextProperty("initialViewWidth", 240);
|
||||
canvas->rootContext()->setContextProperty("initialViewHeight", 320);
|
||||
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml"));
|
||||
|
||||
gridview = findItem<QSGGridView>(canvas->rootObject(), "grid");
|
||||
QTRY_VERIFY(gridview != 0);
|
||||
gridview->setFlow(flow);
|
||||
gridview->setLayoutDirection(layoutDirection);
|
||||
|
||||
gridview->setWidth(240);
|
||||
gridview->setHeight(320);
|
||||
QTRY_COMPARE(gridview->headerItem()->pos(), initialHeaderPos);
|
||||
QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos);
|
||||
|
||||
delete canvas;
|
||||
}
|
||||
|
||||
void tst_QSGGridView::header_data()
|
||||
|
|
|
@ -24,8 +24,8 @@ Rectangle {
|
|||
id: list
|
||||
objectName: "list"
|
||||
focus: true
|
||||
width: 240
|
||||
height: 320
|
||||
width: initialViewWidth
|
||||
height: initialViewHeight
|
||||
snapMode: ListView.SnapToItem
|
||||
model: testModel
|
||||
delegate: myDelegate
|
||||
|
|
|
@ -2463,17 +2463,15 @@ void tst_QSGListView::header()
|
|||
QFETCH(QPointF, changedContentPos);
|
||||
QFETCH(QPointF, resizeContentPos);
|
||||
|
||||
QSGView *canvas = createView();
|
||||
|
||||
TestModel model;
|
||||
for (int i = 0; i < 30; i++)
|
||||
model.addItem("Item" + QString::number(i), "");
|
||||
|
||||
QDeclarativeContext *ctxt = canvas->rootContext();
|
||||
ctxt->setContextProperty("testModel", &model);
|
||||
|
||||
QSGView *canvas = createView();
|
||||
canvas->rootContext()->setContextProperty("testModel", &model);
|
||||
canvas->rootContext()->setContextProperty("initialViewWidth", 240);
|
||||
canvas->rootContext()->setContextProperty("initialViewHeight", 320);
|
||||
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml"));
|
||||
qApp->processEvents();
|
||||
|
||||
QSGListView *listview = findItem<QSGListView>(canvas->rootObject(), "list");
|
||||
QTRY_VERIFY(listview != 0);
|
||||
|
@ -2521,6 +2519,27 @@ void tst_QSGListView::header()
|
|||
QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), changedContentPos);
|
||||
QCOMPARE(item->pos(), firstDelegatePos);
|
||||
|
||||
delete canvas;
|
||||
|
||||
|
||||
// QTBUG-21207 header should become visible if view resizes from initial empty size
|
||||
|
||||
canvas = createView();
|
||||
canvas->rootContext()->setContextProperty("testModel", &model);
|
||||
canvas->rootContext()->setContextProperty("initialViewWidth", 0.0);
|
||||
canvas->rootContext()->setContextProperty("initialViewHeight", 0.0);
|
||||
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml"));
|
||||
|
||||
listview = findItem<QSGListView>(canvas->rootObject(), "list");
|
||||
QTRY_VERIFY(listview != 0);
|
||||
listview->setOrientation(orientation);
|
||||
listview->setLayoutDirection(layoutDirection);
|
||||
|
||||
listview->setWidth(240);
|
||||
listview->setHeight(320);
|
||||
QTRY_COMPARE(listview->headerItem()->pos(), initialHeaderPos);
|
||||
QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos);
|
||||
|
||||
header->setHeight(10);
|
||||
header->setWidth(40);
|
||||
QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), resizeContentPos);
|
||||
|
@ -2800,8 +2819,8 @@ void tst_QSGListView::headerFooter()
|
|||
QVERIFY(footer);
|
||||
QCOMPARE(footer->y(), 0.);
|
||||
|
||||
QVERIFY(static_cast<LVAccessor*>(listview)->minY() == 0);
|
||||
QVERIFY(static_cast<LVAccessor*>(listview)->maxY() == 0);
|
||||
QCOMPARE(static_cast<LVAccessor*>(listview)->minY(), header->height());
|
||||
QCOMPARE(static_cast<LVAccessor*>(listview)->maxY(), header->height());
|
||||
|
||||
delete canvas;
|
||||
}
|
||||
|
@ -2831,8 +2850,8 @@ void tst_QSGListView::headerFooter()
|
|||
QVERIFY(footer);
|
||||
QCOMPARE(footer->x(), 0.);
|
||||
|
||||
QVERIFY(static_cast<LVAccessor*>(listview)->minX() == 0);
|
||||
QVERIFY(static_cast<LVAccessor*>(listview)->maxX() == 0);
|
||||
QCOMPARE(static_cast<LVAccessor*>(listview)->minX(), header->width());
|
||||
QCOMPARE(static_cast<LVAccessor*>(listview)->maxX(), header->width());
|
||||
|
||||
delete canvas;
|
||||
}
|
||||
|
@ -2863,8 +2882,8 @@ void tst_QSGListView::headerFooter()
|
|||
QVERIFY(footer);
|
||||
QCOMPARE(footer->x(), -footer->width());
|
||||
|
||||
QCOMPARE(static_cast<LVAccessor*>(listview)->minX(), 240.);
|
||||
QCOMPARE(static_cast<LVAccessor*>(listview)->maxX(), 240.);
|
||||
QCOMPARE(static_cast<LVAccessor*>(listview)->minX(), 240. - header->width());
|
||||
QCOMPARE(static_cast<LVAccessor*>(listview)->maxX(), 240. - header->width());
|
||||
|
||||
delete canvas;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue