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;
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) {
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)
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);
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()
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);
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);
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;
}
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;
}
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;
}