equal
deleted
inserted
replaced
29 #include "hbdeviceprofile.h" |
29 #include "hbdeviceprofile.h" |
30 #include "hbinstance.h" |
30 #include "hbinstance.h" |
31 #include <hbwidgetfeedback.h> |
31 #include <hbwidgetfeedback.h> |
32 #include <hbevent.h> |
32 #include <hbevent.h> |
33 #include "hbglobal_p.h" |
33 #include "hbglobal_p.h" |
|
34 #include <hbtapgesture.h> |
|
35 #include <hbnamespace_p.h> |
34 |
36 |
35 #include <QGesture> |
37 #include <QGesture> |
36 |
38 |
37 #include <QDebug> |
39 #include <QDebug> |
38 |
40 |
140 This signal is emitted whenever a scrolling action ends. |
142 This signal is emitted whenever a scrolling action ends. |
141 */ |
143 */ |
142 |
144 |
143 /*! |
145 /*! |
144 \fn void HbScrollArea::scrollPositionChanged(QPointF newposition) |
146 \fn void HbScrollArea::scrollPositionChanged(QPointF newposition) |
145 This signal is emitted when scroll position is changed. |
147 This signal is emitted when scroll position is changed and someone is connected to the signal. |
146 */ |
148 */ |
147 |
149 |
148 /*! |
150 /*! |
149 \enum HbScrollArea::ClampingStyle |
151 \enum HbScrollArea::ClampingStyle |
150 |
152 |
218 |
220 |
219 HbScrollArea shows scroll bar for short period of time when the content is displayed or scrolled. Scroll bar is not shown if not needed. |
221 HbScrollArea shows scroll bar for short period of time when the content is displayed or scrolled. Scroll bar is not shown if not needed. |
220 |
222 |
221 This is the default behavior. |
223 This is the default behavior. |
222 */ |
224 */ |
|
225 |
|
226 /*! |
|
227 \primitives |
|
228 \primitives{continuation-indicator-bottom} HbFrameItem representing the scrollarea continuation indicator on the bottom of the scrollarea. |
|
229 \primitives{continuation-indicator-top} HbFrameItem representing the scrollarea continuation indicator on the top of the scrollarea. |
|
230 \primitives{continuation-indicator-left} HbFrameItem representing the scrollarea continuation indicator on the left side of the scrollarea. |
|
231 \primitives{continuation-indicator-right} HbFrameItem representing the scrollarea continuation indicator on the right side of the scrollarea. |
|
232 */ |
223 |
233 |
224 /*! |
234 /*! |
225 Constructor |
235 Constructor |
226 |
236 |
227 \sa HbScrollArea::HbScrollArea |
237 \sa HbScrollArea::HbScrollArea |
232 Q_D( HbScrollArea ); |
242 Q_D( HbScrollArea ); |
233 d->q_ptr = this; |
243 d->q_ptr = this; |
234 d->init(); |
244 d->init(); |
235 } |
245 } |
236 |
246 |
|
247 /*! |
|
248 Protected constructor. |
|
249 */ |
237 HbScrollArea::HbScrollArea(HbScrollAreaPrivate &dd, QGraphicsItem *parent): |
250 HbScrollArea::HbScrollArea(HbScrollAreaPrivate &dd, QGraphicsItem *parent): |
238 HbWidget( dd, parent ) |
251 HbWidget( dd, parent ) |
239 { |
252 { |
240 Q_D( HbScrollArea ); |
253 Q_D( HbScrollArea ); |
241 d->q_ptr = this; |
254 d->q_ptr = this; |
428 { |
441 { |
429 Q_D( HbScrollArea ); |
442 Q_D( HbScrollArea ); |
430 |
443 |
431 bool isChanged = (d->mScrollDirections != value); |
444 bool isChanged = (d->mScrollDirections != value); |
432 |
445 |
433 d->mScrollDirections = value; |
446 d->mScrollDirections = value; |
|
447 if (d->mContents && isChanged) { |
|
448 QPointF pos = d->mContents->pos(); |
|
449 QEvent layoutRequest(QEvent::LayoutRequest); |
|
450 QCoreApplication::sendEvent(this, &layoutRequest); |
|
451 d->mContents->setPos(pos); |
|
452 } |
434 |
453 |
435 if (isChanged) { |
454 if (isChanged) { |
436 emit scrollDirectionsChanged( value ); |
455 emit scrollDirectionsChanged( value ); |
437 } |
456 } |
438 } |
457 } |
617 void HbScrollArea::longPressGesture(const QPointF &) |
636 void HbScrollArea::longPressGesture(const QPointF &) |
618 { |
637 { |
619 HB_DEPRECATED("HbScrollArea::longPressGesture(const QPointF &) is deprecated. Use gesture FW."); |
638 HB_DEPRECATED("HbScrollArea::longPressGesture(const QPointF &) is deprecated. Use gesture FW."); |
620 } |
639 } |
621 |
640 |
622 /* |
641 /*! |
623 \reimp |
642 \reimp |
624 */ |
643 */ |
625 void HbScrollArea::mousePressEvent(QGraphicsSceneMouseEvent *event) |
644 void HbScrollArea::mousePressEvent(QGraphicsSceneMouseEvent *event) |
626 { |
645 { |
627 Q_UNUSED (event); |
646 Q_UNUSED (event); |
628 } |
647 } |
629 |
648 |
678 //qDebug() << "focusout"; |
697 //qDebug() << "focusout"; |
679 if ( !d->positionOutOfBounds() ) { |
698 if ( !d->positionOutOfBounds() ) { |
680 d->stopAnimating(); |
699 d->stopAnimating(); |
681 } |
700 } |
682 } else if( event->type() == QEvent::GestureOverride ) { |
701 } else if( event->type() == QEvent::GestureOverride ) { |
683 if(static_cast<QGestureEvent *>(event)->gesture(Qt::TapGesture) && |
702 if(HbTapGesture *tap = qobject_cast<HbTapGesture*>(static_cast<QGestureEvent *>(event)->gesture(Qt::TapGesture))) { |
684 d->mIsAnimating && !d->positionOutOfBounds() && !d->mMultiFlickEnabled) { |
703 if (d->mIsAnimating && !d->positionOutOfBounds() && !d->mMultiFlickEnabled) { |
685 event->accept(); |
704 event->accept(); |
686 return true; |
705 return true; |
|
706 } else if (tap->state() == Qt::GestureStarted){ |
|
707 if (d->mAbleToScrollY) { |
|
708 tap->setProperty(HbPrivate::VerticallyRestricted.latin1(), true); |
|
709 } |
|
710 if (d->mAbleToScrollX){ |
|
711 tap->setProperty(HbPrivate::HorizontallyRestricted.latin1(), true); |
|
712 } |
|
713 } |
687 } |
714 } |
688 } else if (event->type() == QEvent::LayoutRequest) { |
715 } else if (event->type() == QEvent::LayoutRequest) { |
689 if (d->mContents) { |
716 if (d->mContents) { |
690 if (preferredSize() != d->mContents->preferredSize()) { |
717 if (preferredSize() != d->mContents->preferredSize()) { |
691 updateGeometry(); |
718 updateGeometry(); |
754 Q_UNUSED(obj); |
781 Q_UNUSED(obj); |
755 Q_D(HbScrollArea); |
782 Q_D(HbScrollArea); |
756 if (event && event->type() == QEvent::GraphicsSceneResize) { |
783 if (event && event->type() == QEvent::GraphicsSceneResize) { |
757 if (isVisible()) { |
784 if (isVisible()) { |
758 d->adjustContent(); |
785 d->adjustContent(); |
|
786 } |
|
787 |
|
788 if (d->mAbleToScrollX && d->mHorizontalScrollBar->isVisible()) { |
|
789 d->updateScrollBar(Qt::Horizontal); |
|
790 } |
|
791 |
|
792 if (d->mAbleToScrollY && d->mVerticalScrollBar->isVisible()) { |
|
793 d->updateScrollBar(Qt::Vertical); |
759 } |
794 } |
760 } // no else |
795 } // no else |
761 |
796 |
762 return false; |
797 return false; |
763 } |
798 } |
813 if(QTapGesture *gesture = static_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) { |
848 if(QTapGesture *gesture = static_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) { |
814 // Stop scrolling on tap |
849 // Stop scrolling on tap |
815 if (gesture->state() == Qt::GestureStarted) { |
850 if (gesture->state() == Qt::GestureStarted) { |
816 if (d->mIsAnimating && !d->positionOutOfBounds() && !d->mMultiFlickEnabled) { |
851 if (d->mIsAnimating && !d->positionOutOfBounds() && !d->mMultiFlickEnabled) { |
817 d->stopAnimating(); |
852 d->stopAnimating(); |
|
853 HbWidgetFeedback::triggered(this, Hb::InstantPressed, Hb::ModifierScrolling); |
818 event->accept(gesture); |
854 event->accept(gesture); |
819 } else { |
855 } else { |
820 event->ignore(gesture); |
856 event->ignore(gesture); |
821 } |
857 } |
822 } |
858 } |
836 /*! |
872 /*! |
837 Returns the scrollbar policy for vertical scrollbar |
873 Returns the scrollbar policy for vertical scrollbar |
838 |
874 |
839 \sa horizontalScrollBarPolicy(), setVerticalScrollBarPolicy() |
875 \sa horizontalScrollBarPolicy(), setVerticalScrollBarPolicy() |
840 */ |
876 */ |
841 |
|
842 HbScrollArea::ScrollBarPolicy HbScrollArea::verticalScrollBarPolicy() const |
877 HbScrollArea::ScrollBarPolicy HbScrollArea::verticalScrollBarPolicy() const |
843 { |
878 { |
844 Q_D(const HbScrollArea); |
879 Q_D(const HbScrollArea); |
845 return d->mVerticalScrollBarPolicy; |
880 return d->mVerticalScrollBarPolicy; |
846 } |
881 } |
893 /*! |
928 /*! |
894 \brief Returns the policy for horizontal scrollbar |
929 \brief Returns the policy for horizontal scrollbar |
895 |
930 |
896 \sa verticalScrollBarPolicy(), setHorizontalScrollBarPolicy() |
931 \sa verticalScrollBarPolicy(), setHorizontalScrollBarPolicy() |
897 */ |
932 */ |
898 |
|
899 HbScrollArea::ScrollBarPolicy HbScrollArea::horizontalScrollBarPolicy() const |
933 HbScrollArea::ScrollBarPolicy HbScrollArea::horizontalScrollBarPolicy() const |
900 { |
934 { |
901 Q_D(const HbScrollArea); |
935 Q_D(const HbScrollArea); |
902 return d->mHorizontalScrollBarPolicy; |
936 return d->mHorizontalScrollBarPolicy; |
903 } |
937 } |
1038 Scrolls the contents of the scroll area to the \a newPosition in a given \a time. |
1072 Scrolls the contents of the scroll area to the \a newPosition in a given \a time. |
1039 If the time is 0, contents is scrolled to the position instantly. |
1073 If the time is 0, contents is scrolled to the position instantly. |
1040 */ |
1074 */ |
1041 void HbScrollArea::scrollContentsTo (const QPointF& newPosition, int time) { |
1075 void HbScrollArea::scrollContentsTo (const QPointF& newPosition, int time) { |
1042 Q_D(HbScrollArea); |
1076 Q_D(HbScrollArea); |
|
1077 |
|
1078 if (!contentWidget()) |
|
1079 return; |
|
1080 |
1043 if (time > 0){ |
1081 if (time > 0){ |
1044 d->startTargetAnimation (newPosition, qMax (0, time)); |
1082 d->startTargetAnimation (newPosition, qMax (0, time)); |
1045 } else { |
1083 } else { |
1046 scrollByAmount(newPosition - (-d->mContents->pos())); |
1084 scrollByAmount(newPosition - (-d->mContents->pos())); |
1047 d->stopScrolling(); |
1085 d->stopScrolling(); |
1048 |
1086 } |
1049 } |
1087 } |
1050 } |
1088 |
1051 |
1089 /*! |
1052 /* |
|
1053 \reimp |
1090 \reimp |
1054 */ |
1091 */ |
1055 void HbScrollArea::polish(HbStyleParameters& params) |
1092 void HbScrollArea::polish(HbStyleParameters& params) |
1056 { |
1093 { |
1057 Q_D(HbScrollArea); |
1094 Q_D(HbScrollArea); |
1095 if (d->mContinuationIndicators) { |
1132 if (d->mContinuationIndicators) { |
1096 d->updateIndicators(-d->mContents->pos()); |
1133 d->updateIndicators(-d->mContents->pos()); |
1097 } |
1134 } |
1098 } |
1135 } |
1099 |
1136 |
|
1137 /*! |
|
1138 \reimp |
|
1139 |
|
1140 */ |
|
1141 void HbScrollArea::timerEvent(QTimerEvent *event) |
|
1142 { |
|
1143 Q_D(HbScrollArea); |
|
1144 if (event->timerId() == d->mScrollTimerId) { |
|
1145 d->_q_animateScrollTimeout(); |
|
1146 } else if (event->timerId() == d->mScrollBarHideTimerId) { |
|
1147 d->_q_hideScrollBars(); |
|
1148 } |
|
1149 } |
|
1150 |
|
1151 /*! |
|
1152 \reimp |
|
1153 */ |
|
1154 void HbScrollArea::disconnectNotify (const char *signal) |
|
1155 { |
|
1156 Q_D(HbScrollArea); |
|
1157 if (d->mEmitPositionChangedSignal && |
|
1158 QLatin1String(signal) == SIGNAL(scrollPositionChanged(QPointF))) { |
|
1159 if (receivers(SIGNAL(scrollPositionChanged(QPointF))) == 0) { |
|
1160 d->mEmitPositionChangedSignal = false; |
|
1161 } |
|
1162 } |
|
1163 HbWidget::disconnectNotify(signal); |
|
1164 } |
|
1165 |
|
1166 /*! |
|
1167 \reimp |
|
1168 */ |
|
1169 void HbScrollArea::connectNotify(const char * signal) |
|
1170 { |
|
1171 Q_D(HbScrollArea); |
|
1172 if (!d->mEmitPositionChangedSignal && |
|
1173 QLatin1String(signal) == SIGNAL(scrollPositionChanged(QPointF))) { |
|
1174 d->mEmitPositionChangedSignal = true; |
|
1175 } |
|
1176 HbWidget::connectNotify(signal); |
|
1177 } |
1100 #include "moc_hbscrollarea.cpp" |
1178 #include "moc_hbscrollarea.cpp" |