on xenial help sign in
LVWPH: Account for contentHeight not really being "all" of the content height

m_minYExtent is also part of the content height Fixes: #1569976 Approved by: Michael Zanetti

commit77c227cfd2d0e65c7b0b8335c5e7627686a3df09 authorAlbert Astals Cid <albert.astals@canonical.com> dateWed 27 Apr 2016, 14:57 (10 years ago) parentd99694931cf0c6
3 files changed+23−2
plugins/Dash/listviewwithpageheader.cpp+7−2 plugins/Dash/listviewwithpageheader.h+1 tests/plugins/Dash/listviewwithpageheadertest.cpp+15
plugins/Dash/listviewwithpageheader.cpp+7−2
@@ -514,6 +514,11 @@ qreal ListViewWithPageHeader::minYExtent() const
514514 return m_minYExtent;
515515}
516516
517+qreal ListViewWithPageHeader::maxYExtent() const
518+{
519+ return height() - contentHeight();
520+}
521+
517522void ListViewWithPageHeader::componentComplete()
518523{
519524 if (m_delegateModel)
@@ -1186,7 +1191,7 @@ void ListViewWithPageHeader::headerHeightChanged(qreal newHeaderHeight, qreal ol
11861191
11871192void ListViewWithPageHeader::adjustMinYExtent()
11881193{
1189− if (m_visibleItems.isEmpty() || contentHeight() < height()) {
1194+ if (m_visibleItems.isEmpty() || (contentHeight() + m_minYExtent < height())) {
11901195 m_minYExtent = 0;
11911196 } else {
11921197 qreal nonCreatedHeight = 0;
@@ -1368,7 +1373,7 @@ void ListViewWithPageHeader::updatePolish()
13681373
13691374 m_contentHeightDirty = false;
13701375 adjustMinYExtent();
1371− if (contentHeight < height()) {
1376+ if (contentHeight + m_minYExtent < height()) {
13721377 // need this since in the previous call to adjustMinYExtent contentHeight is not set yet
13731378 m_minYExtent = 0;
13741379 }
plugins/Dash/listviewwithpageheader.h+1
@@ -115,6 +115,7 @@ protected:
115115 void componentComplete() override;
116116 void viewportMoved(Qt::Orientations orient) override;
117117 qreal minYExtent() const override;
118+ qreal maxYExtent() const override;
118119 void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) override;
119120 void itemImplicitHeightChanged(QQuickItem *item) override;
120121 void updatePolish() override;
tests/plugins/Dash/listviewwithpageheadertest.cpp+15
@@ -1977,6 +1977,21 @@ private Q_SLOTS:
19771977 verifyItem(0, 50., 200., false);
19781978 }
19791979
1980+ void testBug1569976()
1981+ {
1982+ QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 3), Q_ARG(QVariant, 3));
1983+
1984+ for (int i = 0; i < 10; ++i) {
1985+ scrollToBottom();
1986+ lvwph->showHeader();
1987+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1988+ scrollToTop();
1989+ }
1990+ verifyItem(0, 50., 150., false);
1991+ verifyItem(1, 200., 200., false);
1992+ verifyItem(2, 400., 350., false);
1993+ }
1994+
19801995private:
19811996 QQuickView *view;
19821997 ListViewWithPageHeader *lvwph;