ui/widgets/glxzoomwidget/src/glxzoomwidget.cpp
changeset 52 a3a4c0de738e
parent 50 a0f57508af73
child 54 0f0f3f26f787
equal deleted inserted replaced
50:a0f57508af73 52:a3a4c0de738e
    22 #include <hbinstance.h>
    22 #include <hbinstance.h>
    23 #include "glximagedecoderwrapper.h"
    23 #include "glximagedecoderwrapper.h"
    24 #include "glxmodelparm.h"
    24 #include "glxmodelparm.h"
    25 #include "glxzoomwidget.h"
    25 #include "glxzoomwidget.h"
    26 
    26 
    27 GlxZoomWidget::GlxZoomWidget(QGraphicsItem *parent):HbScrollArea(parent), mModel(NULL), mMinZValue(MINZVALUE), mMaxZValue(MAXZVALUE), mImageDecodeRequestSend(false), mPinchGestureOngoing(false), mDecodedImageAvailable(false),mZoomOngoing(false), mTimerId(0)
    27 GlxZoomWidget::GlxZoomWidget(QGraphicsItem *parent):HbScrollArea(parent), 
       
    28             mModel(NULL), mMinZValue(MINZVALUE), 
       
    29             mMaxZValue(MAXZVALUE), mTimerId(0),
       
    30             mImageDecodeRequestSend(false), 
       
    31             mPinchGestureOngoing(false), mDecodedImageAvailable(false),
       
    32             mZoomOngoing(false)
    28 {
    33 {
    29     grabGesture(Qt::PinchGesture);
    34     grabGesture(Qt::PinchGesture);
    30     grabGesture(Qt::TapGesture);
    35     grabGesture(Qt::TapGesture);
    31     setAcceptTouchEvents(true) ;
    36     setAcceptTouchEvents(true) ;
    32     setFrictionEnabled(false);
    37     setFrictionEnabled(false);
   187         }
   192         }
   188         event->accept(gesture);
   193         event->accept(gesture);
   189         return true;
   194         return true;
   190     }
   195     }
   191      if (QGesture *pinch = event->gesture(Qt::PinchGesture))  {
   196      if (QGesture *pinch = event->gesture(Qt::PinchGesture))  {
       
   197          if (isFocussedItemCorrupt()){
       
   198          return true;
       
   199          }
   192        QPinchGesture* pinchG = static_cast<QPinchGesture *>(pinch);
   200        QPinchGesture* pinchG = static_cast<QPinchGesture *>(pinch);
   193        QPinchGesture::ChangeFlags changeFlags = pinchG->changeFlags();
   201        QPinchGesture::ChangeFlags changeFlags = pinchG->changeFlags();
   194        if (changeFlags & QPinchGesture::ScaleFactorChanged) {
   202        if (changeFlags & QPinchGesture::ScaleFactorChanged) {
   195             mPinchGestureOngoing = true;
   203             mPinchGestureOngoing = true;
   196             mZoomOngoing = true;
   204             mZoomOngoing = true;
   517 
   525 
   518 
   526 
   519 
   527 
   520 void GlxZoomWidget::animateZoomIn(QPointF animRefPoint)
   528 void GlxZoomWidget::animateZoomIn(QPointF animRefPoint)
   521 {
   529 {
   522       emit pinchGestureReceived(mFocusIndex);
   530     if (isFocussedItemCorrupt()){
   523             //bring the zoom widget to foreground
   531     return;
   524             mZoomOngoing = true;
   532     }
   525             setZValue(mMaxZValue);
   533     emit pinchGestureReceived(mFocusIndex);
   526             //show the black background
   534     //bring the zoom widget to foreground
   527             mBlackBackgroundItem->setParentItem(parentItem());
   535     mZoomOngoing = true;
   528             mBlackBackgroundItem->setZValue(mMaxZValue - 1);
   536     setZValue(mMaxZValue);
   529             mBlackBackgroundItem->show();
   537     //show the black background
   530 	m_AnimRefPoint = animRefPoint;
   538     mBlackBackgroundItem->setParentItem(parentItem());
       
   539     mBlackBackgroundItem->setZValue(mMaxZValue - 1);
       
   540     mBlackBackgroundItem->show();
       
   541     m_AnimRefPoint = animRefPoint;
   531     QSizeF requiredSize = mItemSize;
   542     QSizeF requiredSize = mItemSize;
   532     requiredSize.scale(mWindowSize*3.5, Qt::KeepAspectRatio);
   543     requiredSize.scale(mWindowSize*3.5, Qt::KeepAspectRatio);
   533 	m_FinalAnimatedScaleFactor = requiredSize.width()/mMinDecScaleSize.width();
   544 	m_FinalAnimatedScaleFactor = requiredSize.width()/mMinDecScaleSize.width();
   534 	m_AnimTimeLine->setDirection(QTimeLine::Forward);
   545 	m_AnimTimeLine->setDirection(QTimeLine::Forward);
   535 	m_AnimTimeLine->start();
   546 	m_AnimTimeLine->start();
   577     {
   588     {
   578         killTimer(mTimerId);
   589         killTimer(mTimerId);
   579         mTimerId = 0;
   590         mTimerId = 0;
   580     }
   591     }
   581 }
   592 }
       
   593 
       
   594 bool GlxZoomWidget::isFocussedItemCorrupt()
       
   595 {
       
   596     QVariant variant = mModel->data( mModel->index( mFocusIndex, 0 ), GlxImageCorruptRole );
       
   597     if ( variant.isValid() && variant.canConvert< bool> () ) {
       
   598         return variant.value< bool > () ;
       
   599     }
       
   600     return false ;    
       
   601 }
       
   602