ListView.contentHeight does not include header and footer item heights
authorMartin Jones <martin.jones@nokia.com>
Mon, 12 Mar 2012 07:55:38 +0000 (17:55 +1000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 13 Mar 2012 01:02:49 +0000 (02:02 +0100)
Task-number: QTBUG-24664

Change-Id: I2a2fe144835e61665b8693d58ca4fb9ba506e8a8
Reviewed-by: Bea Lam <bea.lam@nokia.com>
src/quick/items/qquickitemview.cpp
tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
tests/auto/quick/qquicklistview/tst_qquicklistview.cpp

index c6f45aa..501b206 100644 (file)
@@ -1658,10 +1658,11 @@ void QQuickItemViewPrivate::updateViewport()
 {
     Q_Q(QQuickItemView);
     if (isValid()) {
+        qreal extra = headerSize() + footerSize();
         if (layoutOrientation() == Qt::Vertical)
-            q->setContentHeight(endPosition() - startPosition());
+            q->setContentHeight(endPosition() - startPosition() + extra);
         else
-            q->setContentWidth(endPosition() - startPosition());
+            q->setContentWidth(endPosition() - startPosition() + extra);
     }
 }
 
index f33883c..fe534e4 100644 (file)
@@ -2810,6 +2810,11 @@ void tst_QQuickGridView::footer()
     QCOMPARE(footer->height(), 30.);
     QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos);
 
+    if (flow == QQuickGridView::LeftToRight)
+        QCOMPARE(gridview->contentHeight(), (model.count()+2) / 3 * 60. + footer->height());
+    else
+        QCOMPARE(gridview->contentWidth(), (model.count()+3) / 5 * 80. + footer->width());
+
     QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
     QVERIFY(item);
     QCOMPARE(item->pos(), firstDelegatePos);
@@ -2971,6 +2976,11 @@ void tst_QQuickGridView::header()
     QCOMPARE(header->height(), 30.);
     QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos);
 
+    if (flow == QQuickGridView::LeftToRight)
+        QCOMPARE(gridview->contentHeight(), (model.count()+2) / 3 * 60. + header->height());
+    else
+        QCOMPARE(gridview->contentWidth(), (model.count()+3) / 5 * 80. + header->width());
+
     QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
     QVERIFY(item);
     QCOMPARE(item->pos(), firstDelegatePos);
index 037d9e9..1584bc3 100644 (file)
@@ -3057,6 +3057,11 @@ void tst_QQuickListView::header()
     QCOMPARE(header->pos(), initialHeaderPos);
     QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos);
 
+    if (orientation == QQuickListView::Vertical)
+        QCOMPARE(listview->contentHeight(), model.count() * 30. + header->height());
+    else
+        QCOMPARE(listview->contentWidth(), model.count() * 240. + header->width());
+
     QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
     QVERIFY(item);
     QCOMPARE(item->pos(), firstDelegatePos);
@@ -3241,6 +3246,11 @@ void tst_QQuickListView::footer()
     QCOMPARE(footer->height(), 30.);
     QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos);
 
+    if (orientation == QQuickListView::Vertical)
+        QCOMPARE(listview->contentHeight(), model.count() * 20. + footer->height());
+    else
+        QCOMPARE(listview->contentWidth(), model.count() * 40. + footer->width());
+
     QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
     QVERIFY(item);
     QCOMPARE(item->pos(), firstDelegatePos);