src/hbcore/gui/hbscrollarea.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 2 06ff229162e9
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    25 
    25 
    26 #include "hbscrollarea.h"
    26 #include "hbscrollarea.h"
    27 #include "hbscrollarea_p.h"
    27 #include "hbscrollarea_p.h"
    28 #include "hbscrollbar.h"
    28 #include "hbscrollbar.h"
    29 #include "hbdeviceprofile.h"
    29 #include "hbdeviceprofile.h"
       
    30 #include "hbinstance.h"
    30 #include <hbwidgetfeedback.h>
    31 #include <hbwidgetfeedback.h>
    31 #include <hbevent.h>
    32 #include <hbevent.h>
       
    33 #include "hbglobal_p.h"
       
    34 
       
    35 #include <QGesture>
    32 
    36 
    33 #include <QDebug>
    37 #include <QDebug>
    34 
    38 
    35 /*!
    39 /*!
    36  *  @stable
    40  *  @beta
    37  *  @hbcore
    41  *  @hbcore
    38  *  \class HbScrollArea
    42  *  \class HbScrollArea
    39  *  \brief HbScrollArea provides a finger-touch enabled scrollable container class.  
    43  *  \brief HbScrollArea provides a finger-touch enabled scrollable container class.  
    40  *
    44  *
    41  *  HbScrollArea handles the events need to scroll the contents placed inside it.  It also
    45  *  HbScrollArea handles the events need to scroll the contents placed inside it.  It also
   123 
   127 
   124     This signal is emitted when scrolling direction is changed.
   128     This signal is emitted when scrolling direction is changed.
   125 */
   129 */
   126 
   130 
   127 /*!
   131 /*!
   128     \fn void HbScrollArea::gestureSceneFilterChanged(HbGestureSceneFilter* newFilter)
       
   129 
       
   130     This signal is emitted when gesture filters are changed.
       
   131 */
       
   132 
       
   133 /*!
       
   134     \fn void HbScrollArea::scrollingStarted()
   132     \fn void HbScrollArea::scrollingStarted()
   135 
   133 
   136     This signal is emitted whenever a scrolling action begins.
   134     This signal is emitted whenever a scrolling action begins.
   137 */
   135 */
   138 
   136 
   249  *
   247  *
   250  * \sa HbScrollArea::~HbScrollArea
   248  * \sa HbScrollArea::~HbScrollArea
   251  */
   249  */
   252 HbScrollArea::~HbScrollArea()
   250 HbScrollArea::~HbScrollArea()
   253 {
   251 {
       
   252     Q_D( HbScrollArea );
       
   253     if (d && d->mContents) {
       
   254         d->mContents->setParentLayoutItem(0);
       
   255     }
   254 }
   256 }
   255 
   257 
   256 /*!
   258 /*!
   257  * Returns a pointer to the QGraphicsWidget,which is the content of scrollable area.
   259  * Returns a pointer to the QGraphicsWidget,which is the content of scrollable area.
   258  *
   260  *
   280     }
   282     }
   281 
   283 
   282     d->stopAnimating();
   284     d->stopAnimating();
   283 
   285 
   284     if (0 != d->mContents) {
   286     if (0 != d->mContents) {
       
   287         d->mContents->setParentLayoutItem(0);
   285         delete d->mContents;
   288         delete d->mContents;
   286     }
   289     }
   287     d->mContents = contents;
   290     d->mContents = contents;
   288     updateGeometry();
   291     updateGeometry();
   289 
   292 
   290     if (0 != contents) {
   293     if (0 != contents) {
       
   294         contents->setParentLayoutItem(this);
   291         contents->setParentItem(this);
   295         contents->setParentItem(this);
   292         contents->installEventFilter(this);
   296         contents->installEventFilter(this);
       
   297         d->mResetAlignment = true;
   293         d->adjustContent();
   298         d->adjustContent();
   294         setContinuationIndicators(d->mContinuationIndicators);
   299         setContinuationIndicators(d->mContinuationIndicators);
   295     } else {
   300     } else {
   296         d->hideChildComponents();
   301         d->hideChildComponents();
   297     }
   302     }
   312     QGraphicsWidget* content = d->mContents;
   317     QGraphicsWidget* content = d->mContents;
   313     d->mContents = 0;
   318     d->mContents = 0;
   314 
   319 
   315     // Reset the ownership
   320     // Reset the ownership
   316     if (content) {
   321     if (content) {
       
   322         content->setParentLayoutItem(0);
   317         content->setParentItem(0);
   323         content->setParentItem(0);
   318         content->removeEventFilter(this);
   324         content->removeEventFilter(this);
   319     }
   325     }
   320 
   326 
   321     d->hideChildComponents();
   327     d->hideChildComponents();
   368 
   374 
   369     return d->mScrollingStyle;
   375     return d->mScrollingStyle;
   370 }
   376 }
   371 
   377 
   372 /*!
   378 /*!
   373  * Sets the scrollingStyle property that controls how the style of scrolling interaction
   379   Sets the scrollingStyle property that controls how the style of scrolling interaction
   374  * provided by the widget
   380   provided by the widget
   375  *
   381  
   376  * Possible values for the clamping style include:
   382   Possible values for the clamping style include:
   377  *
   383  
   378  *		Pan - dragging motion pans the view with no follow-on scrolling animation
   384  		Pan - dragging motion pans the view with no follow-on scrolling animation
   379  *		PanOrFlick - dragging motion pans the view with no follow-on scrolling animation, quick flicking motion triggers scrolling animation
   385  \deprecated PanOrFlick
   380  *		PanWithFollowOn - dragging motion pans the view, velocity at end of drag motion triggers follow-on animated scrolling
   386                     is deprecated.
   381  *
   387  		PanWithFollowOn - dragging motion pans the view, velocity at end of drag motion triggers follow-on animated scrolling
   382  * The default value is PanWithFollowOn.
   388  
   383  *
   389   The default value is PanWithFollowOn.
   384  * \sa HbScrollArea::scrollingStyle()
   390  
       
   391   \sa HbScrollArea::scrollingStyle()
   385  */
   392  */
   386 void HbScrollArea::setScrollingStyle(ScrollingStyle value)
   393 void HbScrollArea::setScrollingStyle(ScrollingStyle value)
   387 {
   394 {
   388     Q_D( HbScrollArea );
   395     Q_D( HbScrollArea );
   389 
   396 
   390     bool isChanged = (d->mScrollingStyle != value);
   397     if (value == HbScrollArea::PanOrFlick) {
   391 
   398         d->mScrollingStyle = HbScrollArea::PanWithFollowOn;
   392     d->mScrollingStyle = value;
   399         HB_DEPRECATED("HbScrollArea::PanOrFlick is deprecated");
   393 
   400     } else {
   394     if (isChanged) {
   401         d->mScrollingStyle = value;
   395         d->updateGestures();
       
   396         emit gestureSceneFilterChanged( d->mGestureFilter );
       
   397     }
   402     }
   398 }
   403 }
   399 
   404 
   400 /*!
   405 /*!
   401  * Returns the value of the scrollDirections property.
   406  * Returns the value of the scrollDirections property.
   426     bool isChanged = (d->mScrollDirections != value);
   431     bool isChanged = (d->mScrollDirections != value);
   427 
   432 
   428     d->mScrollDirections = value;
   433     d->mScrollDirections = value;
   429 
   434 
   430     if (isChanged) {
   435     if (isChanged) {
   431         d->updateGestures();
       
   432 
       
   433         emit scrollDirectionsChanged( value );
   436         emit scrollDirectionsChanged( value );
   434 
       
   435         emit gestureSceneFilterChanged( d->mGestureFilter );
       
   436     }
   437     }
   437 }
   438 }
   438 
   439 
   439 /*!
   440 /*!
   440  * Returns true if the inertia scrolling effect is enabled, false otherwise.
   441  * Returns true if the inertia scrolling effect is enabled, false otherwise.
   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  */
   692 {
   659 {
   693     Q_D( HbScrollArea );
   660     Q_D( HbScrollArea );
   694 
   661 
   695     return d->scrollByAmount(delta);
   662     return d->scrollByAmount(delta);
   696 }
   663 }
   697 
   664  
   698 #if 0
       
   699 
       
   700 bool HbScrollArea::sceneEvent(QEvent *event)
       
   701 {
       
   702     Q_D( HbScrollArea );
       
   703     bool eventAccepted(false);
       
   704     eventAccepted = d->sceneEvent(event);
       
   705     if(!eventAccepted);
       
   706         eventAccepted = HbWidget::sceneEvent(event);
       
   707     return eventAccepted;
       
   708 }
       
   709 
       
   710 #endif // HB_NEW_GESTURE_FW
       
   711 
       
   712 /*!
   665 /*!
   713    \reimp
   666    \reimp
   714  */
   667  */
   715 bool HbScrollArea::event(QEvent *event)
   668 bool HbScrollArea::event(QEvent *event)
   716 {
   669 {
   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 }
   793         d->stopAnimating();
   796         d->stopAnimating();
   794     }
   797     }
   795 
   798 
   796 }
   799 }
   797 
   800 
       
   801 #ifdef HB_GESTURE_FW
       
   802 void HbScrollArea::gestureEvent(QGestureEvent *event)
       
   803 {    
       
   804     Q_D ( HbScrollArea );
       
   805     if(QTapGesture *gesture = static_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) {        
       
   806         // Stop scrolling on tap
       
   807         if (gesture->state() == Qt::GestureStarted) {
       
   808             if (d->mIsAnimating && !d->positionOutOfBounds() && !d->mMultiFlickEnabled) {
       
   809                 d->stopAnimating();
       
   810                 event->accept(gesture);
       
   811             } else {
       
   812                 event->ignore(gesture);
       
   813             }
       
   814         }
       
   815     }
       
   816     if (QPanGesture *panGesture = qobject_cast<QPanGesture*>(event->gesture(Qt::PanGesture))) {
       
   817         if (!d->pan(panGesture)) {
       
   818             event->ignore(panGesture);
       
   819         } else {
       
   820             event->accept(panGesture);
       
   821             setFocus(Qt::MouseFocusReason);
       
   822         }
       
   823     }
       
   824 }
       
   825 
       
   826 #endif
       
   827 
   798 /*!
   828 /*!
   799     Returns the scrollbar policy for vertical scrollbar
   829     Returns the scrollbar policy for vertical scrollbar
   800 
   830 
   801     \sa horizontalScrollBarPolicy(), setVerticalScrollBarPolicy()
   831     \sa horizontalScrollBarPolicy(), setVerticalScrollBarPolicy()
   802 */
   832 */
   919 
   949 
   920 void HbScrollArea::setAlignment(Qt::Alignment alignment)
   950 void HbScrollArea::setAlignment(Qt::Alignment alignment)
   921 {
   951 {
   922     Q_D(HbScrollArea);
   952     Q_D(HbScrollArea);
   923     d->mAlignment = alignment;
   953     d->mAlignment = alignment;
       
   954     d->mResetAlignment = true;
   924     if (d->mContents)
   955     if (d->mContents)
   925         d->adjustContent();
   956         d->adjustContent();
   926 }
   957 }
   927 /*!
   958 /*!
   928     \brief the alignment of the scroll area's widget
   959     \brief the alignment of the scroll area's widget
  1003     Q_D(HbScrollArea);
  1034     Q_D(HbScrollArea);
  1004     if (time > 0){
  1035     if (time > 0){
  1005         d->startTargetAnimation (newPosition, qMax (0, time));
  1036         d->startTargetAnimation (newPosition, qMax (0, time));
  1006     } else {
  1037     } else {
  1007         scrollByAmount(newPosition - (-d->mContents->pos()));
  1038         scrollByAmount(newPosition - (-d->mContents->pos()));
  1008         if (d->positionOutOfBounds() && d->mClampingStyle == BounceBackClamping) {
  1039         d->stopScrolling();
  1009             d->startAnimating();
  1040 
  1010         } else {
       
  1011             d->stopScrolling();
       
  1012         }
       
  1013     }
  1041     }
  1014 }
  1042 }
  1015 
  1043 
  1016 /*
  1044 /*
  1017  * \reimp
  1045  * \reimp