--- a/src/hbcore/gui/hbscrollarea.cpp Wed Jun 23 18:33:25 2010 +0300
+++ b/src/hbcore/gui/hbscrollarea.cpp Tue Jul 06 14:36:53 2010 +0300
@@ -31,6 +31,8 @@
#include <hbwidgetfeedback.h>
#include <hbevent.h>
#include "hbglobal_p.h"
+#include <hbtapgesture.h>
+#include <hbnamespace_p.h>
#include <QGesture>
@@ -142,7 +144,7 @@
/*!
\fn void HbScrollArea::scrollPositionChanged(QPointF newposition)
- This signal is emitted when scroll position is changed.
+ This signal is emitted when scroll position is changed and someone is connected to the signal.
*/
/*!
@@ -441,7 +443,13 @@
bool isChanged = (d->mScrollDirections != value);
- d->mScrollDirections = value;
+ d->mScrollDirections = value;
+ if (d->mContents && isChanged) {
+ QPointF pos = d->mContents->pos();
+ QEvent layoutRequest(QEvent::LayoutRequest);
+ QCoreApplication::sendEvent(this, &layoutRequest);
+ d->mContents->setPos(pos);
+ }
if (isChanged) {
emit scrollDirectionsChanged( value );
@@ -691,10 +699,18 @@
d->stopAnimating();
}
} else if( event->type() == QEvent::GestureOverride ) {
- if(static_cast<QGestureEvent *>(event)->gesture(Qt::TapGesture) &&
- d->mIsAnimating && !d->positionOutOfBounds() && !d->mMultiFlickEnabled) {
- event->accept();
- return true;
+ if(HbTapGesture *tap = qobject_cast<HbTapGesture*>(static_cast<QGestureEvent *>(event)->gesture(Qt::TapGesture))) {
+ if (d->mIsAnimating && !d->positionOutOfBounds() && !d->mMultiFlickEnabled) {
+ event->accept();
+ return true;
+ } else if (tap->state() == Qt::GestureStarted){
+ if (d->mAbleToScrollY) {
+ tap->setProperty(HbPrivate::VerticallyRestricted.latin1(), true);
+ }
+ if (d->mAbleToScrollX){
+ tap->setProperty(HbPrivate::HorizontallyRestricted.latin1(), true);
+ }
+ }
}
} else if (event->type() == QEvent::LayoutRequest) {
if (d->mContents) {
@@ -768,6 +784,14 @@
if (isVisible()) {
d->adjustContent();
}
+
+ if (d->mAbleToScrollX && d->mHorizontalScrollBar->isVisible()) {
+ d->updateScrollBar(Qt::Horizontal);
+ }
+
+ if (d->mAbleToScrollY && d->mVerticalScrollBar->isVisible()) {
+ d->updateScrollBar(Qt::Vertical);
+ }
} // no else
return false;
@@ -1050,12 +1074,15 @@
*/
void HbScrollArea::scrollContentsTo (const QPointF& newPosition, int time) {
Q_D(HbScrollArea);
+
+ if (!contentWidget())
+ return;
+
if (time > 0){
d->startTargetAnimation (newPosition, qMax (0, time));
} else {
scrollByAmount(newPosition - (-d->mContents->pos()));
d->stopScrolling();
-
}
}
@@ -1107,4 +1134,45 @@
}
}
+/*!
+ \reimp
+
+ */
+void HbScrollArea::timerEvent(QTimerEvent *event)
+{
+ Q_D(HbScrollArea);
+ if (event->timerId() == d->mScrollTimerId) {
+ d->_q_animateScrollTimeout();
+ } else if (event->timerId() == d->mScrollBarHideTimerId) {
+ d->_q_hideScrollBars();
+ }
+}
+
+/*!
+ \reimp
+*/
+void HbScrollArea::disconnectNotify (const char *signal)
+{
+ Q_D(HbScrollArea);
+ if (d->mEmitPositionChangedSignal &&
+ QLatin1String(signal) == SIGNAL(scrollPositionChanged(QPointF))) {
+ if (receivers(SIGNAL(scrollPositionChanged(QPointF))) == 0) {
+ d->mEmitPositionChangedSignal = false;
+ }
+ }
+ HbWidget::disconnectNotify(signal);
+}
+
+/*!
+ \reimp
+*/
+void HbScrollArea::connectNotify(const char * signal)
+{
+ Q_D(HbScrollArea);
+ if (!d->mEmitPositionChangedSignal &&
+ QLatin1String(signal) == SIGNAL(scrollPositionChanged(QPointF))) {
+ d->mEmitPositionChangedSignal = true;
+ }
+ HbWidget::connectNotify(signal);
+}
#include "moc_hbscrollarea.cpp"