ui/widgets/glxzoomwidget/src/glxzoomwidget.cpp
changeset 52 a3a4c0de738e
parent 50 a0f57508af73
child 54 0f0f3f26f787
--- a/ui/widgets/glxzoomwidget/src/glxzoomwidget.cpp	Sat Jul 10 00:59:39 2010 +0530
+++ b/ui/widgets/glxzoomwidget/src/glxzoomwidget.cpp	Fri Jul 23 20:41:04 2010 +0530
@@ -24,7 +24,12 @@
 #include "glxmodelparm.h"
 #include "glxzoomwidget.h"
 
-GlxZoomWidget::GlxZoomWidget(QGraphicsItem *parent):HbScrollArea(parent), mModel(NULL), mMinZValue(MINZVALUE), mMaxZValue(MAXZVALUE), mImageDecodeRequestSend(false), mPinchGestureOngoing(false), mDecodedImageAvailable(false),mZoomOngoing(false), mTimerId(0)
+GlxZoomWidget::GlxZoomWidget(QGraphicsItem *parent):HbScrollArea(parent), 
+            mModel(NULL), mMinZValue(MINZVALUE), 
+            mMaxZValue(MAXZVALUE), mTimerId(0),
+            mImageDecodeRequestSend(false), 
+            mPinchGestureOngoing(false), mDecodedImageAvailable(false),
+            mZoomOngoing(false)
 {
     grabGesture(Qt::PinchGesture);
     grabGesture(Qt::TapGesture);
@@ -189,6 +194,9 @@
         return true;
     }
      if (QGesture *pinch = event->gesture(Qt::PinchGesture))  {
+         if (isFocussedItemCorrupt()){
+         return true;
+         }
        QPinchGesture* pinchG = static_cast<QPinchGesture *>(pinch);
        QPinchGesture::ChangeFlags changeFlags = pinchG->changeFlags();
        if (changeFlags & QPinchGesture::ScaleFactorChanged) {
@@ -519,15 +527,18 @@
 
 void GlxZoomWidget::animateZoomIn(QPointF animRefPoint)
 {
-      emit pinchGestureReceived(mFocusIndex);
-            //bring the zoom widget to foreground
-            mZoomOngoing = true;
-            setZValue(mMaxZValue);
-            //show the black background
-            mBlackBackgroundItem->setParentItem(parentItem());
-            mBlackBackgroundItem->setZValue(mMaxZValue - 1);
-            mBlackBackgroundItem->show();
-	m_AnimRefPoint = animRefPoint;
+    if (isFocussedItemCorrupt()){
+    return;
+    }
+    emit pinchGestureReceived(mFocusIndex);
+    //bring the zoom widget to foreground
+    mZoomOngoing = true;
+    setZValue(mMaxZValue);
+    //show the black background
+    mBlackBackgroundItem->setParentItem(parentItem());
+    mBlackBackgroundItem->setZValue(mMaxZValue - 1);
+    mBlackBackgroundItem->show();
+    m_AnimRefPoint = animRefPoint;
     QSizeF requiredSize = mItemSize;
     requiredSize.scale(mWindowSize*3.5, Qt::KeepAspectRatio);
 	m_FinalAnimatedScaleFactor = requiredSize.width()/mMinDecScaleSize.width();
@@ -579,3 +590,13 @@
         mTimerId = 0;
     }
 }
+
+bool GlxZoomWidget::isFocussedItemCorrupt()
+{
+    QVariant variant = mModel->data( mModel->index( mFocusIndex, 0 ), GlxImageCorruptRole );
+    if ( variant.isValid() && variant.canConvert< bool> () ) {
+        return variant.value< bool > () ;
+    }
+    return false ;    
+}
+