@@ -160,16 +160,16 @@ ListViewWithPageHeader::ListViewWithPageHeader()
160// m_clipItem = new QQuickRectangle(contentItem());
160// m_clipItem = new QQuickRectangle(contentItem());
161// ((QQuickRectangle*)m_clipItem)->setColor(Qt::gray);
161// ((QQuickRectangle*)m_clipItem)->setColor(Qt::gray);
163− m_headerShowAnimation = new QQuickNumberAnimation(this);
163+ m_contentYAnimation = new QQuickNumberAnimation(this);
164− m_headerShowAnimation->setEasing(QEasingCurve::OutQuad);
164+ m_contentYAnimation->setEasing(QEasingCurve::OutQuad);
165− m_headerShowAnimation->setProperty("contentY");
165+ m_contentYAnimation->setProperty("contentY");
166− m_headerShowAnimation->setDuration(200);
166+ m_contentYAnimation->setDuration(200);
167− m_headerShowAnimation->setTargetObject(this);
167+ m_contentYAnimation->setTargetObject(this);
169 connect(this, SIGNAL(contentWidthChanged()), this, SLOT(onContentWidthChanged()));
169 connect(this, SIGNAL(contentWidthChanged()), this, SLOT(onContentWidthChanged()));
170 connect(this, SIGNAL(contentHeightChanged()), this, SLOT(onContentHeightChanged()));
170 connect(this, SIGNAL(contentHeightChanged()), this, SLOT(onContentHeightChanged()));
171 connect(this, SIGNAL(heightChanged()), this, SLOT(onHeightChanged()));
171 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()));
175ListViewWithPageHeader::~ListViewWithPageHeader()
175ListViewWithPageHeader::~ListViewWithPageHeader()
@@ -374,8 +374,32 @@ void ListViewWithPageHeader::showHeader()
374 layout();
374 layout();
377− m_headerShowAnimation->setTo(to);
377+ m_contentYAnimation->setTo(to);
378− m_headerShowAnimation->start();
378+ contentYAnimationIsShownHeader = true;
379+ m_contentYAnimation->start();
383+QQuickItem *ListViewWithPageHeader::item(int modelIndex) const
385+ ListItem *item = itemAtIndex(modelIndex);
387+ return item->m_item;
392+void ListViewWithPageHeader::maximizeVisibleArea(int modelIndex)
394+ ListItem *listItem = itemAtIndex(modelIndex);
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();
@@ -435,7 +459,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
435 // We will be changing the clip item, need to accomadate for it
459 // We will be changing the clip item, need to accomadate for it
436 // otherwise we move the firstItem down/up twice (unless the
460 // otherwise we move the firstItem down/up twice (unless the
437 // show header animation is running, where we want to keep the viewport stable)
461 // show header animation is running, where we want to keep the viewport stable)
438− if (!m_headerShowAnimation->isRunning()) {
462+ if (!(m_contentYAnimation->isRunning() && contentYAnimationIsShownHeader)) {
439 diff += oldHeaderItemShownHeight - m_headerItemShownHeight;
463 diff += oldHeaderItemShownHeight - m_headerItemShownHeight;
441 diff = -diff;
465 diff = -diff;
@@ -445,7 +469,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
445 updateClipItem();
469 updateClipItem();
446 ListItem *firstItem = m_visibleItems.first();
470 ListItem *firstItem = m_visibleItems.first();
447 firstItem->setY(firstItem->y() + diff);
471 firstItem->setY(firstItem->y() + diff);
448− if (m_headerShowAnimation->isRunning()) {
472+ if (m_contentYAnimation->isRunning() && contentYAnimationIsShownHeader) {
449 adjustMinYExtent();
473 adjustMinYExtent();