460 |
461 |
461 d->mFrictionEnabled = value; |
462 d->mFrictionEnabled = value; |
462 } |
463 } |
463 |
464 |
464 /*! |
465 /*! |
465 * Returns true if the scroll area handles |
466 Returns true if the scroll area handles |
466 * long press gestures, false otherwise |
467 long press gestures, false otherwise |
467 * |
468 |
468 * \sa HbScrollArea::setHandleLongPress() |
469 \deprecated HbScrollArea::longPressEnabled() |
|
470 is deprecated. |
|
471 |
|
472 \sa HbScrollArea::setHandleLongPress() |
469 */ |
473 */ |
470 bool HbScrollArea::longPressEnabled() const |
474 bool HbScrollArea::longPressEnabled() const |
471 { |
475 { |
472 Q_D( const HbScrollArea ); |
476 HB_DEPRECATED("HbScrollArea::longPressEnabled() is deprecated"); |
473 |
477 return false; |
474 return d->mHandleLongPress; |
478 } |
475 } |
479 |
476 |
480 /*! |
477 /*! |
481 Sets the value of the handleLongPress property. This value is set |
478 * Sets the value of the handleLongPress property. This value is set |
482 to true if the widget is to respond to long press gestures, false otherwise. |
479 * to true if the widget is to respond to long press gestures, false otherwise. |
483 |
480 * |
484 The default value is false. |
481 * The default value is false. |
485 |
482 * |
486 \deprecated HbScrollArea::setLongPressEnabled(bool) |
483 * \sa HbScrollArea::handleLongPress() |
487 is deprecated. |
|
488 |
|
489 \sa HbScrollArea::handleLongPress() |
484 */ |
490 */ |
485 void HbScrollArea::setLongPressEnabled (bool value) |
491 void HbScrollArea::setLongPressEnabled (bool value) |
486 { |
492 { |
487 Q_D( HbScrollArea ); |
493 HB_DEPRECATED("HbScrollArea::setLongPressEnabled(bool) is deprecated"); |
488 |
494 Q_UNUSED(value); |
489 bool isChanged = (d->mHandleLongPress != value); |
|
490 |
|
491 d->mHandleLongPress = value; |
|
492 |
|
493 if (isChanged) { |
|
494 d->updateGestures(); |
|
495 emit gestureSceneFilterChanged( d->mGestureFilter ); |
|
496 } |
|
497 } |
495 } |
498 |
496 |
499 /* |
497 /* |
500 * \reimp |
498 * \reimp |
501 */ |
499 */ |
502 QVariant HbScrollArea::itemChange(GraphicsItemChange change, const QVariant &value) |
500 QVariant HbScrollArea::itemChange(GraphicsItemChange change, const QVariant &value) |
503 { |
501 { |
504 Q_D( HbScrollArea ); |
502 Q_D( HbScrollArea ); |
505 |
503 |
506 // ??? need to support other changes ??? |
504 if (change == QGraphicsItem::ItemVisibleHasChanged && d->mContents) { |
507 if ( change == QGraphicsItem::ItemSceneHasChanged ) { |
|
508 d->updateGestures(); |
|
509 |
|
510 emit gestureSceneFilterChanged( d->mGestureFilter ); |
|
511 } else if (change == QGraphicsItem::ItemVisibleHasChanged && d->mContents) { |
|
512 if (value.toBool() == true) |
505 if (value.toBool() == true) |
513 d->adjustContent(); |
506 d->adjustContent(); |
514 else |
507 else |
515 d->_q_hideScrollBars(); |
508 d->_q_hideScrollBars(); |
516 } |
509 } |
517 |
510 |
518 return HbWidget::itemChange(change, value); |
511 return HbWidget::itemChange(change, value); |
519 } |
512 } |
520 |
513 |
521 /*! @beta |
514 /*! @beta |
522 * upGesture() is a virtual slot function that is called whenever an |
515 upGesture() is a virtual slot function that is called whenever an |
523 * up flick gesture is detected, if the scrollDirection is set to |
516 up flick gesture is detected, if the scrollDirection is set to |
524 * enable vertical scrolling. |
517 enable vertical scrolling. |
525 * |
518 |
526 * Derived classes can override this method to add custom handling of |
519 Derived classes can override this method to add custom handling of |
527 * the gesture. In most cases, derived classes should call up to the |
520 the gesture. In most cases, derived classes should call up to the |
528 * HbScrollArea parent method. |
521 HbScrollArea parent method. |
529 * |
522 |
|
523 \deprecated HbScrollArea::upGesture(int) |
|
524 is deprecated. |
530 */ |
525 */ |
531 void HbScrollArea::upGesture(int speedPixelsPerSecond) |
526 void HbScrollArea::upGesture(int speedPixelsPerSecond) |
532 { |
527 { |
533 Q_D( HbScrollArea ); |
528 HB_DEPRECATED("HbScrollArea::upGesture(int) is deprecated. Use gesture FW."); |
534 |
529 |
535 // convert the speedPixelsPerSecond to pixels per msec |
530 Q_UNUSED(speedPixelsPerSecond); |
536 QPointF speed; |
|
537 speed.setX(0.0f); |
|
538 speed.setY(-speedPixelsPerSecond * d->mSpeedFactor); |
|
539 d->animateScroll(speed); |
|
540 } |
531 } |
541 |
532 |
542 /*! @beta |
533 /*! @beta |
543 * downGesture() is a virtual slot function that is called whenever an |
534 downGesture() is a virtual slot function that is called whenever an |
544 * down flick gesture is detected, if the scrollDirection is set to |
535 down flick gesture is detected, if the scrollDirection is set to |
545 * enable vertical scrolling. |
536 enable vertical scrolling. |
546 * |
537 |
547 * Derived classes can override this method to add custom handling of |
538 Derived classes can override this method to add custom handling of |
548 * the gesture. In most cases, derived classes should call up to the |
539 the gesture. In most cases, derived classes should call up to the |
549 * HbScrollArea parent method. |
540 HbScrollArea parent method. |
|
541 |
|
542 \deprecated HbScrollArea::downGesture(int) |
|
543 is deprecated. |
550 */ |
544 */ |
551 void HbScrollArea::downGesture(int speedPixelsPerSecond) |
545 void HbScrollArea::downGesture(int speedPixelsPerSecond) |
552 { |
546 { |
553 Q_D( HbScrollArea ); |
547 HB_DEPRECATED("HbScrollArea::downGesture(int) is deprecated. Use gesture FW."); |
554 |
548 Q_UNUSED(speedPixelsPerSecond); |
555 // convert the speedPixelsPerSecond to pixels per msec |
|
556 QPointF speed; |
|
557 speed.setX(0.0f); |
|
558 speed.setY(speedPixelsPerSecond * d->mSpeedFactor); |
|
559 d->animateScroll(speed); |
|
560 } |
549 } |
561 |
550 |
562 /*! @beta |
551 /*! @beta |
563 * leftGesture() is a virtual slot function that is called whenever an |
552 leftGesture() is a virtual slot function that is called whenever an |
564 * left flick gesture is detected, if the scrollDirection is set to |
553 left flick gesture is detected, if the scrollDirection is set to |
565 * enable horizontal scrolling. |
554 enable horizontal scrolling. |
566 * |
555 |
567 * Derived classes can override this method to add custom handling of |
556 Derived classes can override this method to add custom handling of |
568 * the gesture. In most cases, derived classes should call up to the |
557 the gesture. In most cases, derived classes should call up to the |
569 * HbScrollArea parent method. |
558 HbScrollArea parent method. |
|
559 |
|
560 \deprecated HbScrollArea::leftGesture(int) |
|
561 is deprecated. |
570 */ |
562 */ |
571 void HbScrollArea::leftGesture(int speedPixelsPerSecond) |
563 void HbScrollArea::leftGesture(int speedPixelsPerSecond) |
572 { |
564 { |
573 Q_D( HbScrollArea ); |
565 HB_DEPRECATED("HbScrollArea::leftGesture(int) is deprecated. Use gesture FW."); |
574 |
566 Q_UNUSED(speedPixelsPerSecond); |
575 // convert the speedPixelsPerSecond to pixels per msec |
|
576 QPointF speed; |
|
577 speed.setX(-speedPixelsPerSecond * d->mSpeedFactor); |
|
578 speed.setY(0.0f); |
|
579 d->animateScroll(speed); |
|
580 } |
567 } |
581 |
568 |
582 /*! @beta |
569 /*! @beta |
583 * rightGesture() is a virtual slot function that is called whenever an |
570 rightGesture() is a virtual slot function that is called whenever an |
584 * right flick gesture is detected, if the scrollDirection is set to |
571 right flick gesture is detected, if the scrollDirection is set to |
585 * enable horizontal scrolling. |
572 enable horizontal scrolling. |
586 * |
573 |
587 * Derived classes can override this method to add custom handling of |
574 Derived classes can override this method to add custom handling of |
588 * the gesture. In most cases, derived classes should call up to the |
575 the gesture. In most cases, derived classes should call up to the |
589 * HbScrollArea parent method. |
576 HbScrollArea parent method. |
|
577 |
|
578 \deprecated HbScrollArea::rightGesture(int) |
|
579 is deprecated. |
590 */ |
580 */ |
591 void HbScrollArea::rightGesture(int speedPixelsPerSecond) |
581 void HbScrollArea::rightGesture(int speedPixelsPerSecond) |
592 { |
582 { |
593 Q_D( HbScrollArea ); |
583 HB_DEPRECATED("HbScrollArea::rightGesture(int) is deprecated. Use gesture FW."); |
594 |
584 Q_UNUSED(speedPixelsPerSecond); |
595 // convert the speedPixelsPerSecond to pixels per msec |
585 } |
596 QPointF speed; |
586 |
597 speed.setX(speedPixelsPerSecond * d->mSpeedFactor); |
587 |
598 speed.setY(0.0f); |
588 /*! |
599 d->animateScroll(speed); |
589 panGesture() is a virtual slot function that is called whenever an |
|
590 pan gesture is detected. |
|
591 |
|
592 Derived classes can override this method to add custom handling of |
|
593 the gesture. In most cases, derived classes should call up to the |
|
594 HbScrollArea parent method. |
|
595 |
|
596 \deprecated HbScrollArea::panGesture(const QPointF&) |
|
597 is deprecated. |
|
598 */ |
|
599 void HbScrollArea::panGesture(const QPointF &delta) |
|
600 { |
|
601 HB_DEPRECATED("HbScrollArea::panGesture(const QPointF &) is deprecated. Use gesture FW."); |
|
602 Q_UNUSED(delta); |
600 } |
603 } |
601 |
604 |
602 /*! @beta |
605 /*! @beta |
603 * panGesture() is a virtual slot function that is called whenever an |
606 longPressGesture() is a virtual slot function that is called whenever an |
604 * pan gesture is detected. |
607 long press gesture is detected, if the handleLongPress property is set to true. |
605 * |
608 |
606 * Derived classes can override this method to add custom handling of |
609 Derived classes can override this method to add custom handling of |
607 * the gesture. In most cases, derived classes should call up to the |
610 the gesture. By default, HbScrollArea does not respond to a long press. |
608 * HbScrollArea parent method. |
611 |
609 */ |
612 \deprecated HbScrollArea::longPressGesture(const QPointF&) |
610 void HbScrollArea::panGesture(const QPointF &delta) |
613 is deprecated. |
611 { |
614 |
612 Q_D( HbScrollArea ); |
615 \sa setHandleLongPress(), handleLongPress() |
613 if ( d->mIsAnimating ) { |
616 */ |
614 d->stopAnimating(); |
617 void HbScrollArea::longPressGesture(const QPointF &) |
615 } |
618 { |
616 if (scrollingStyle() == HbScrollArea::PanWithFollowOn) { |
619 HB_DEPRECATED("HbScrollArea::longPressGesture(const QPointF &) is deprecated. Use gesture FW."); |
617 d->addPositionToQueue(-delta, d->mDragElapsedTime.elapsed(), true); |
|
618 } |
|
619 if (d->mAbleToScrollY || d->mAbleToScrollX) { |
|
620 // initiate scroll feedback |
|
621 HbWidgetFeedback::continuousTriggered(this, Hb::ContinuousScrolled, delta); |
|
622 d->mScrollFeedbackOngoing = true; |
|
623 } |
|
624 scrollByAmount(-delta); |
|
625 } |
|
626 |
|
627 /*! @beta |
|
628 * longPressGesture() is a virtual slot function that is called whenever an |
|
629 * long press gesture is detected, if the handleLongPress property is set to true. |
|
630 * |
|
631 * Derived classes can override this method to add custom handling of |
|
632 * the gesture. By default, HbScrollArea does not respond to a long press. |
|
633 * |
|
634 * \sa setHandleLongPress(), handleLongPress() |
|
635 */ |
|
636 void HbScrollArea::longPressGesture(const QPointF &/* point */) |
|
637 { |
|
638 // qDebug() << "GOT LONG PRESS GESTURE" << point; |
|
639 } |
620 } |
640 |
621 |
641 /* |
622 /* |
642 \reimp |
623 \reimp |
643 */ |
624 */ |
644 void HbScrollArea::mousePressEvent(QGraphicsSceneMouseEvent *event) |
625 void HbScrollArea::mousePressEvent(QGraphicsSceneMouseEvent *event) |
645 { |
626 { |
646 Q_D( HbScrollArea ); |
627 Q_UNUSED (event); |
647 if (d->mContents) { |
|
648 d->mousePressEvent( event ); |
|
649 } |
|
650 } |
|
651 |
|
652 /* |
|
653 \reimp |
|
654 */ |
|
655 void HbScrollArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
656 { |
|
657 Q_D( HbScrollArea ); |
|
658 if (d->mContents) { |
|
659 d->mouseReleaseEvent ( event ); |
|
660 } |
|
661 } |
628 } |
662 |
629 |
663 /*! |
630 /*! |
664 * Returns true if a scrolling action is in progress, false otherwise. |
631 * Returns true if a scrolling action is in progress, false otherwise. |
665 */ |
632 */ |
721 if(event->type() == QEvent::ApplicationLayoutDirectionChange |
674 if(event->type() == QEvent::ApplicationLayoutDirectionChange |
722 || event->type() == QEvent::LayoutDirectionChange) { |
675 || event->type() == QEvent::LayoutDirectionChange) { |
723 d->changeLayoutDirection(layoutDirection()); |
676 d->changeLayoutDirection(layoutDirection()); |
724 } else if (event->type() == QEvent::GraphicsSceneResize) { |
677 } else if (event->type() == QEvent::GraphicsSceneResize) { |
725 if (isVisible() && d->mContents) { |
678 if (isVisible() && d->mContents) { |
726 d->orientationChanged(); |
679 if ( d->mIsAnimating ) { |
|
680 d->stopAnimating(); |
|
681 } |
|
682 d->adjustContent(); |
727 } |
683 } |
728 } else if (event->type() == HbEvent::ChildFocusOut) { |
684 } else if (event->type() == HbEvent::ChildFocusOut) { |
729 //qDebug() << "focusout"; |
685 //qDebug() << "focusout"; |
730 if ( !d->positionOutOfBounds() ) { |
686 if ( !d->positionOutOfBounds() ) { |
731 d->stopAnimating(); |
687 d->stopAnimating(); |
|
688 } |
|
689 } else if( event->type() == QEvent::GestureOverride ) { |
|
690 if(static_cast<QGestureEvent *>(event)->gesture(Qt::TapGesture) && |
|
691 d->mIsAnimating && !d->positionOutOfBounds() && !d->mMultiFlickEnabled) { |
|
692 event->accept(); |
|
693 return true; |
|
694 } |
|
695 } else if (event->type() == QEvent::LayoutRequest) { |
|
696 if (d->mContents) { |
|
697 if (preferredSize() != d->mContents->preferredSize()) { |
|
698 updateGeometry(); |
|
699 } |
|
700 |
|
701 QSizeF newSize = d->mContents->size(); |
|
702 QSizePolicy contentPolicy = d->mContents->sizePolicy(); |
|
703 |
|
704 if (d->mScrollDirections & Qt::Vertical) { |
|
705 if (contentPolicy.verticalPolicy() != QSizePolicy::Ignored) { |
|
706 newSize.setHeight(d->mContents->preferredHeight()); |
|
707 } |
|
708 } else { |
|
709 newSize.setHeight(size().height()); |
|
710 } |
|
711 |
|
712 if (d->mScrollDirections & Qt::Horizontal) { |
|
713 if (contentPolicy.horizontalPolicy() != QSizePolicy::Ignored) { |
|
714 newSize.setWidth(d->mContents->preferredWidth()); |
|
715 } |
|
716 } else { |
|
717 newSize.setWidth(size().width()); |
|
718 } |
|
719 |
|
720 d->mContents->resize(newSize); |
|
721 } |
|
722 } else if (event->type() == QEvent::GraphicsSceneResize) { |
|
723 if (d->mContents) { |
|
724 QSizeF newSize = d->mContents->size(); |
|
725 |
|
726 if (!(d->mScrollDirections & Qt::Vertical)) { |
|
727 newSize.setHeight(size().height()); |
|
728 } |
|
729 |
|
730 if (!(d->mScrollDirections & Qt::Horizontal)) { |
|
731 newSize.setWidth(size().width()); |
|
732 } |
|
733 |
|
734 d->mContents->resize(newSize); |
732 } |
735 } |
733 } |
736 } |
734 } |
737 } |
735 return value; |
738 return value; |
736 } |
739 } |