@@ -160,16 +160,16 @@ ListViewWithPageHeader::ListViewWithPageHeader()
160160// m_clipItem = new QQuickRectangle(contentItem());
161161// ((QQuickRectangle*)m_clipItem)->setColor(Qt::gray);
162162
163− m_headerShowAnimation = new QQuickNumberAnimation(this);
164− m_headerShowAnimation->setEasing(QEasingCurve::OutQuad);
165− m_headerShowAnimation->setProperty("contentY");
166− m_headerShowAnimation->setDuration(200);
167− m_headerShowAnimation->setTargetObject(this);
163+ m_contentYAnimation = new QQuickNumberAnimation(this);
164+ m_contentYAnimation->setEasing(QEasingCurve::OutQuad);
165+ m_contentYAnimation->setProperty("contentY");
166+ m_contentYAnimation->setDuration(200);
167+ m_contentYAnimation->setTargetObject(this);
168168
169169 connect(this, SIGNAL(contentWidthChanged()), this, SLOT(onContentWidthChanged()));
170170 connect(this, SIGNAL(contentHeightChanged()), this, SLOT(onContentHeightChanged()));
171171 connect(this, SIGNAL(heightChanged()), this, SLOT(onHeightChanged()));
172− connect(m_headerShowAnimation, SIGNAL(stopped()), this, SLOT(onShowHeaderAnimationFinished()));
172+ connect(m_contentYAnimation, SIGNAL(stopped()), this, SLOT(onShowHeaderAnimationFinished()));
173173}
174174
175175ListViewWithPageHeader::~ListViewWithPageHeader()
@@ -374,8 +374,32 @@ void ListViewWithPageHeader::showHeader()
374374 layout();
375375 }
376376 }
377− m_headerShowAnimation->setTo(to);
378− m_headerShowAnimation->start();
377+ m_contentYAnimation->setTo(to);
378+ contentYAnimationIsShownHeader = true;
379+ m_contentYAnimation->start();
380+ }
381+}
382+
383+QQuickItem *ListViewWithPageHeader::item(int modelIndex) const
384+{
385+ ListItem *item = itemAtIndex(modelIndex);
386+ if (item)
387+ return item->m_item;
388+ else
389+ return nullptr;
390+}
391+
392+void ListViewWithPageHeader::maximizeVisibleArea(int modelIndex)
393+{
394+ ListItem *listItem = itemAtIndex(modelIndex);
395+ if (listItem)
396+ {
397+ // Check if we can scroll the list up to show more stuff
398+ if (m_clipItem->y() + listItem->y() > contentY() && m_clipItem->y() + listItem->y() + listItem->height() > contentY() + height()) {
399+ m_contentYAnimation->setTo(m_clipItem->y() + listItem->y());
400+ contentYAnimationIsShownHeader = false;
401+ m_contentYAnimation->start();
402+ }
379403 }
380404}
381405
@@ -435,7 +459,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
435459 // We will be changing the clip item, need to accomadate for it
436460 // otherwise we move the firstItem down/up twice (unless the
437461 // show header animation is running, where we want to keep the viewport stable)
438− if (!m_headerShowAnimation->isRunning()) {
462+ if (!(m_contentYAnimation->isRunning() && contentYAnimationIsShownHeader)) {
439463 diff += oldHeaderItemShownHeight - m_headerItemShownHeight;
440464 } else {
441465 diff = -diff;
@@ -445,7 +469,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
445469 updateClipItem();
446470 ListItem *firstItem = m_visibleItems.first();
447471 firstItem->setY(firstItem->y() + diff);
448− if (m_headerShowAnimation->isRunning()) {
472+ if (m_contentYAnimation->isRunning() && contentYAnimationIsShownHeader) {
449473 adjustMinYExtent();
450474 }
451475 }