src/hbcore/gui/hbscrollarea_p.cpp
changeset 30 80e4d18b72f5
parent 28 b7da29130b0e
equal deleted inserted replaced
28:b7da29130b0e 30:80e4d18b72f5
   706         !scrollAreaBoundingRect.isValid())
   706         !scrollAreaBoundingRect.isValid())
   707         return;    
   707         return;    
   708 
   708 
   709     QRectF contentsBoundingRect = mContents->boundingRect();
   709     QRectF contentsBoundingRect = mContents->boundingRect();
   710     QPointF alignedPosition = mContents->pos();
   710     QPointF alignedPosition = mContents->pos();
   711     bool xAlignmentNeeded = (!mAbleToScrollX && ((-alignedPosition.x() < leftBoundary()) ||
   711     bool xAlignmentNeeded = mResetAlignment || (!mAbleToScrollX && ((-alignedPosition.x() < leftBoundary()) ||
   712                                                  -alignedPosition.x() > rightBoundary()));
   712                                                  -alignedPosition.x() > rightBoundary()));
   713     bool yAlignmentNeeded = (!mAbleToScrollY && ((-alignedPosition.y() < topBoundary()) ||
   713     bool yAlignmentNeeded = mResetAlignment || (!mAbleToScrollY && ((-alignedPosition.y() < topBoundary()) ||
   714                                                  -alignedPosition.y() > bottomBoundary()));
   714                                                  -alignedPosition.y() > bottomBoundary()));
   715     if (mResetAlignment || xAlignmentNeeded || yAlignmentNeeded) {
   715     if (xAlignmentNeeded) {
   716         if (mAlignment & Qt::AlignHCenter) {
   716         if (mAlignment & Qt::AlignHCenter) {
   717             alignedPosition.setX((scrollAreaBoundingRect.width() - contentsBoundingRect.width()) / 2.0);
   717             alignedPosition.setX((scrollAreaBoundingRect.width() - contentsBoundingRect.width()) / 2.0);
   718         } else if (mAlignment & Qt::AlignRight) {
   718         } else if (mAlignment & Qt::AlignRight) {
   719             alignedPosition.setX(scrollAreaBoundingRect.width() - mContents->size().width());
   719             alignedPosition.setX(scrollAreaBoundingRect.width() - mContents->size().width());
   720         } else if ((mAlignment & Qt::AlignLeft) ||
   720         } else if ((mAlignment & Qt::AlignLeft) ||
   721                    mContents->pos().x() + contentsBoundingRect.x() > 0.0) {
   721                    mContents->pos().x() + contentsBoundingRect.x() > 0.0) {
   722             alignedPosition.setX(-contentsBoundingRect.x());
   722             alignedPosition.setX(-contentsBoundingRect.x());
   723         }
   723         }
   724 
   724     }
       
   725     if (yAlignmentNeeded) {
   725         if (mAlignment & Qt::AlignVCenter) {
   726         if (mAlignment & Qt::AlignVCenter) {
   726             alignedPosition.setY((scrollAreaBoundingRect.height() - contentsBoundingRect.height()) / 2.0);
   727             alignedPosition.setY((scrollAreaBoundingRect.height() - contentsBoundingRect.height()) / 2.0);
   727         } else if (mAlignment & Qt::AlignBottom) {
   728         } else if (mAlignment & Qt::AlignBottom) {
   728             alignedPosition.setY(scrollAreaBoundingRect.height() - mContents->size().height());
   729             alignedPosition.setY(scrollAreaBoundingRect.height() - mContents->size().height());
   729         } else if ((mAlignment & Qt::AlignTop) ||
   730         } else if ((mAlignment & Qt::AlignTop) ||
   742     } else if (mAbleToScrollY && (-alignedPosition.y() > bottomBoundary())) {
   743     } else if (mAbleToScrollY && (-alignedPosition.y() > bottomBoundary())) {
   743         alignedPosition.setY(-bottomBoundary());
   744         alignedPosition.setY(-bottomBoundary());
   744     }
   745     }
   745     if (alignedPosition != mContents->pos()) {
   746     if (alignedPosition != mContents->pos()) {
   746         setContentPosition(alignedPosition);
   747         setContentPosition(alignedPosition);
       
   748         if (mAbleToScrollX && mHorizontalScrollBar->isVisible()) {
       
   749             updateScrollBar(Qt::Horizontal);
       
   750         }
       
   751         if (mAbleToScrollY && mVerticalScrollBar->isVisible()) {
       
   752             updateScrollBar(Qt::Vertical);
       
   753         }
   747     }
   754     }
   748     if (mContinuationIndicators) {
   755     if (mContinuationIndicators) {
   749         updateIndicators(-mContents->pos());
   756         updateIndicators(-mContents->pos());
   750     }
   757     }
   751 }
   758 }
   977             mVerticalScrollBar->setVisible(false);
   984             mVerticalScrollBar->setVisible(false);
   978         }
   985         }
   979     }
   986     }
   980 }
   987 }
   981 
   988 
       
   989 void HbScrollAreaPrivate::_q_thumbPositionChanged(qreal value, Qt::Orientation orientation)
       
   990 {
       
   991     Q_Q( HbScrollArea );
       
   992     // TODO Making syncronous asynhronous...Qt::QueuedConnection in signal slot connection would have done the job. 
       
   993     // Doing it requires Qt::Orientation to be registered as meta type. When done, handling Qt::Orientation as 
       
   994     // QMetaEnum is broken. When fixed by Qt, this workaround can be replaced by Qt::QueuedConnection.
       
   995     QMetaObject::invokeMethod(q, "_q_thumbPositionChanged2", Qt::QueuedConnection, Q_ARG(qreal, value), Q_ARG(int, orientation));
       
   996 }
       
   997 
   982 /**
   998 /**
   983  *
   999  *
   984  */
  1000  */
   985 void HbScrollAreaPrivate::_q_thumbPositionChanged(qreal value, Qt::Orientation orientation)
  1001 void HbScrollAreaPrivate::_q_thumbPositionChanged2(qreal value, int orientation)
   986 {
  1002 {
   987     if ( mTargetAnimationInProgress ) {
  1003     if ( mTargetAnimationInProgress ) {
   988         stopAnimating();
  1004         stopAnimating();
   989     }
  1005     }
   990 
  1006 
   998     }
  1014     }
   999     if (!mContents) {
  1015     if (!mContents) {
  1000         return;
  1016         return;
  1001     }
  1017     }
  1002 
  1018 
  1003     setContentPosition(value, orientation, false);
  1019     setContentPosition(value, (Qt::Orientation)orientation, false);
  1004 
  1020 
  1005     reStartScrollbarHideTimer();
  1021     reStartScrollbarHideTimer();
  1006     if (mContinuationIndicators) {
  1022     if (mContinuationIndicators) {
  1007         updateIndicators(-mContents->pos());
  1023         updateIndicators(-mContents->pos());
  1008     }
  1024     }