if (item == q) {
if (newGeometry.height() != oldGeometry.height() || newGeometry.width() != oldGeometry.width()) {
updateViewport();
+ forceLayout = true;
q->polish();
}
}
--- /dev/null
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ property real initialHeight
+
+ GridView {
+ id: grid
+ objectName: "grid"
+ width: 240
+ height: initialHeight
+ cellWidth: 80
+ cellHeight: 60
+ model: testModel
+ delegate: Rectangle {
+ objectName: "wrapper"
+ width: 80
+ height: 60
+ border.width: 1
+ }
+ }
+}
+
void footer_data();
void header();
void header_data();
+ void resizeViewAndRepaint();
void indexAt();
void onAdd();
void onAdd_data();
<< QPointF(-(240 - 40), 0);
}
+void tst_QSGGridView::resizeViewAndRepaint()
+{
+ QSGView *canvas = createView();
+ canvas->show();
+
+ TestModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("initialHeight", 100);
+
+ canvas->setSource(QUrl::fromLocalFile(TESTDATA("resizeview.qml")));
+ qApp->processEvents();
+
+ QSGGridView *gridview = findItem<QSGGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QSGItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // item at index 10 should not be currently visible
+ QVERIFY(!findItem<QSGItem>(contentItem, "wrapper", 10));
+
+ gridview->setHeight(320);
+ QTRY_VERIFY(findItem<QSGItem>(contentItem, "wrapper", 10));
+
+ gridview->setHeight(100);
+ QTRY_VERIFY(!findItem<QSGItem>(contentItem, "wrapper", 10));
+
+ delete canvas;
+}
+
void tst_QSGGridView::indexAt()
{
QSGView *canvas = createView();
--- /dev/null
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ property real initialHeight
+
+ ListView {
+ id: list
+ objectName: "list"
+ width: 240
+ height: initialHeight
+ model: testModel
+ delegate: Rectangle {
+ objectName: "wrapper"
+ width: 240
+ height: 20
+ border.width: 1
+ }
+ }
+}
+
void footer_data();
void headerFooter();
void resizeView();
+ void resizeViewAndRepaint();
void sizeLessThan1();
void QTBUG_14821();
void resizeDelegate();
delete testObject;
}
+void tst_QSGListView::resizeViewAndRepaint()
+{
+ QSGView *canvas = createView();
+ canvas->show();
+
+ TestModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("initialHeight", 100);
+
+ canvas->setSource(QUrl::fromLocalFile(TESTDATA("resizeview.qml")));
+ qApp->processEvents();
+
+ QSGListView *listview = findItem<QSGListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QSGItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // item at index 10 should not be currently visible
+ QVERIFY(!findItem<QSGItem>(contentItem, "wrapper", 10));
+
+ listview->setHeight(320);
+ QTRY_VERIFY(findItem<QSGItem>(contentItem, "wrapper", 10));
+
+ listview->setHeight(100);
+ QTRY_VERIFY(!findItem<QSGItem>(contentItem, "wrapper", 10));
+
+ delete canvas;
+}
+
void tst_QSGListView::sizeLessThan1()
{
QSGView *canvas = createView();