609 void HgContainer::boundSpring() |
611 void HgContainer::boundSpring() |
610 { |
612 { |
611 FUNC_LOG; |
613 FUNC_LOG; |
612 |
614 |
613 qreal x = mSpring.endPos().x(); |
615 qreal x = mSpring.endPos().x(); |
614 x = qBound(qreal(0), x, worldWidth()); |
|
615 if (mRenderer->coverflowModeEnabled()) { |
616 if (mRenderer->coverflowModeEnabled()) { |
616 qreal i = floorf(x); |
617 qreal i = floorf(x); |
617 x = (x - i > 0.5f) ? ceilf(x) : i; |
618 x = (x - i > 0.5f) ? ceilf(x) : i; |
618 mSpring.animateToPos(QPointF(x, 0)); |
619 } |
619 } |
620 |
620 |
621 mSpring.animateToPosAfterPanning(QPointF(x, 0), worldWidth()); |
621 mSpring.animateToPos(QPointF(x, 0)); |
|
622 |
622 |
623 } |
623 } |
624 |
624 |
625 bool HgContainer::handlePanning(QPanGesture *gesture) |
625 bool HgContainer::handlePanning(QPanGesture *gesture) |
626 { |
626 { |
677 else if (mDragged && gesture->state() == Qt::GestureFinished) { |
677 else if (mDragged && gesture->state() == Qt::GestureFinished) { |
678 mDrag.update(delta, pos, itemSide); |
678 mDrag.update(delta, pos, itemSide); |
679 mDragged = false; |
679 mDragged = false; |
680 qreal newPos(0); |
680 qreal newPos(0); |
681 if (mDrag.finish(pos, mRenderer->coverflowModeEnabled(), newPos)) { |
681 if (mDrag.finish(pos, mRenderer->coverflowModeEnabled(), newPos)) { |
682 mSpring.animateToPos(QPointF(qBound(qreal(0), newPos, worldWidth()), 0)); |
682 |
|
683 mSpring.animateToPosAfterPanning(QPointF(newPos, 0), worldWidth()); |
|
684 |
683 HgWidgetItem* item = itemByIndex(newPos); |
685 HgWidgetItem* item = itemByIndex(newPos); |
684 if (item && item->modelIndex() != mSelectionModel->currentIndex()) { |
686 if (item && item->modelIndex() != mSelectionModel->currentIndex()) { |
685 // mSelectionModel->setCurrentIndex(item->modelIndex(), QItemSelectionModel::Current); |
687 // mSelectionModel->setCurrentIndex(item->modelIndex(), QItemSelectionModel::Current); |
686 } |
688 } |
687 } |
689 } |
705 bool HgContainer::handleTap(Qt::GestureState state, const QPointF &pos) |
707 bool HgContainer::handleTap(Qt::GestureState state, const QPointF &pos) |
706 { |
708 { |
707 FUNC_LOG; |
709 FUNC_LOG; |
708 |
710 |
709 bool handleGesture = false; |
711 bool handleGesture = false; |
710 |
712 |
711 if (hasItemAt(pos)) { |
713 if (hasItemAt(pos)) { |
712 switch (state) |
714 switch (state) |
713 { |
715 { |
714 case Qt::GestureStarted: |
716 case Qt::GestureStarted: |
715 { |
717 { |
716 if (mRenderer->coverflowModeEnabled() || !mSpring.isActive()) { |
718 if (mRenderer->coverflowModeEnabled() || !mSpring.isActive()) { |
717 mIgnoreGestureAction = false; |
719 mIgnoreGestureAction = false; |
718 startLongPressWatcher(pos); |
720 startLongPressWatcher(pos); |
719 } else if(mSpring.isActive()) { |
721 } else if(mSpring.isActive()) { |
720 mSpring.cancel(); |
722 |
|
723 int rowCount = mRenderer->getRowCount(); |
|
724 if(rowCount != 0) //just in case, should not be zero |
|
725 { |
|
726 qreal springPos = mSpring.pos().x(); |
|
727 int gridTotalHeightInImages = ceilf( mItems.count() / rowCount ); |
|
728 qreal currentViewHeightInImages; |
|
729 if (scrollDirection() == Qt::Horizontal ) { |
|
730 int rowHeight = mRenderer->getImageSize().width() + mRenderer->getSpacing().width(); |
|
731 currentViewHeightInImages = rect().width() / rowHeight; |
|
732 } else { |
|
733 int rowHeight = mRenderer->getImageSize().height() + mRenderer->getSpacing().height(); |
|
734 currentViewHeightInImages = rect().height() / rowHeight; |
|
735 } |
|
736 |
|
737 // If list does not currently fill the whole screen (some theme background behind the list |
|
738 // is visible), and list is moving, then do not react to tapping. |
|
739 if( springPos >= 0 |
|
740 && springPos <= (gridTotalHeightInImages - currentViewHeightInImages) ) |
|
741 { |
|
742 mSpring.cancel(); |
|
743 } |
|
744 } |
721 mIgnoreGestureAction = true; |
745 mIgnoreGestureAction = true; |
722 } |
746 } |
723 break; |
747 break; |
724 } |
748 } |
725 case Qt::GestureFinished: |
749 case Qt::GestureFinished: |