ui/widgets/glxzoomwidget/src/glxzoomwidget.cpp
author hgs
Fri, 23 Jul 2010 20:41:04 +0530
changeset 52 a3a4c0de738e
parent 50 a0f57508af73
child 54 0f0f3f26f787
permissions -rw-r--r--
201029
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43
hgs
parents:
diff changeset
     1
 /*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:   glxzoomwidget.cpp
hgs
parents:
diff changeset
    15
*               description of the class GlxGlxZoomWidget which controls the Zoom behavior of coverflow.
hgs
parents:
diff changeset
    16
*
hgs
parents:
diff changeset
    17
*/
hgs
parents:
diff changeset
    18
#include <QPinchGesture>
hgs
parents:
diff changeset
    19
#include <hbiconitem.h>
hgs
parents:
diff changeset
    20
#include <QTimeLine>
hgs
parents:
diff changeset
    21
#include <QGesture>
50
hgs
parents: 45
diff changeset
    22
#include <hbinstance.h>
43
hgs
parents:
diff changeset
    23
#include "glximagedecoderwrapper.h"
hgs
parents:
diff changeset
    24
#include "glxmodelparm.h"
hgs
parents:
diff changeset
    25
#include "glxzoomwidget.h"
hgs
parents:
diff changeset
    26
52
hgs
parents: 50
diff changeset
    27
GlxZoomWidget::GlxZoomWidget(QGraphicsItem *parent):HbScrollArea(parent), 
hgs
parents: 50
diff changeset
    28
            mModel(NULL), mMinZValue(MINZVALUE), 
hgs
parents: 50
diff changeset
    29
            mMaxZValue(MAXZVALUE), mTimerId(0),
hgs
parents: 50
diff changeset
    30
            mImageDecodeRequestSend(false), 
hgs
parents: 50
diff changeset
    31
            mPinchGestureOngoing(false), mDecodedImageAvailable(false),
hgs
parents: 50
diff changeset
    32
            mZoomOngoing(false)
43
hgs
parents:
diff changeset
    33
{
hgs
parents:
diff changeset
    34
    grabGesture(Qt::PinchGesture);
44
hgs
parents: 43
diff changeset
    35
    grabGesture(Qt::TapGesture);
43
hgs
parents:
diff changeset
    36
    setAcceptTouchEvents(true) ;
hgs
parents:
diff changeset
    37
    setFrictionEnabled(false);
hgs
parents:
diff changeset
    38
    setZValue(mMinZValue);
hgs
parents:
diff changeset
    39
    //create the child items and background
hgs
parents:
diff changeset
    40
    mZoomWidget = new QGraphicsWidget(this);
hgs
parents:
diff changeset
    41
    mZoomItem = new QGraphicsPixmapItem(mZoomWidget);
hgs
parents:
diff changeset
    42
    mZoomItem->setTransformationMode(Qt::SmoothTransformation);
hgs
parents:
diff changeset
    43
    //the black background
hgs
parents:
diff changeset
    44
    //replace when a proper substitute for setting backgrounds is known
hgs
parents:
diff changeset
    45
    mBlackBackgroundItem = new HbIconItem(this);
hgs
parents:
diff changeset
    46
    mBlackBackgroundItem->setBrush(QBrush(Qt::black));
hgs
parents:
diff changeset
    47
    mBlackBackgroundItem->hide();
hgs
parents:
diff changeset
    48
    //does not work so is commented
hgs
parents:
diff changeset
    49
    //setBackgroundItem(mBlackBackgroundItem);
hgs
parents:
diff changeset
    50
hgs
parents:
diff changeset
    51
    //initializing the image decoder
hgs
parents:
diff changeset
    52
    mImageDecoder = new GlxImageDecoderWrapper;
hgs
parents:
diff changeset
    53
hgs
parents:
diff changeset
    54
	//inititalizing the timer for animation
44
hgs
parents: 43
diff changeset
    55
	m_AnimTimeLine = new QTimeLine(500, this);
43
hgs
parents:
diff changeset
    56
	m_AnimTimeLine->setFrameRange(0, 100);
hgs
parents:
diff changeset
    57
	connect(m_AnimTimeLine, SIGNAL(frameChanged(int)), this, SLOT(animationFrameChanged(int)));
hgs
parents:
diff changeset
    58
	connect(m_AnimTimeLine, SIGNAL(finished()), this, SLOT(animationTimeLineFinished()));
hgs
parents:
diff changeset
    59
}
hgs
parents:
diff changeset
    60
hgs
parents:
diff changeset
    61
GlxZoomWidget::~GlxZoomWidget()
hgs
parents:
diff changeset
    62
{
hgs
parents:
diff changeset
    63
    //disconnect all existing signals
hgs
parents:
diff changeset
    64
    disconnect(this,SIGNAL( pinchGestureReceived(int) ), this, SLOT( sendDecodeRequest(int) ) );
hgs
parents:
diff changeset
    65
    //no Null checks required
hgs
parents:
diff changeset
    66
    delete mZoomItem;
hgs
parents:
diff changeset
    67
//    delete mZoomWidget; //as this is a content widegt it will automatically be deleted
hgs
parents:
diff changeset
    68
    delete mBlackBackgroundItem;
hgs
parents:
diff changeset
    69
    //reset the decoder to cancel pending tasks
hgs
parents:
diff changeset
    70
    if(mImageDecoder) {
hgs
parents:
diff changeset
    71
        mImageDecoder->resetDecoder();
hgs
parents:
diff changeset
    72
        delete mImageDecoder;
hgs
parents:
diff changeset
    73
    }
hgs
parents:
diff changeset
    74
}
hgs
parents:
diff changeset
    75
hgs
parents:
diff changeset
    76
void GlxZoomWidget::setModel (QAbstractItemModel *model)
hgs
parents:
diff changeset
    77
{
hgs
parents:
diff changeset
    78
    if(model)
hgs
parents:
diff changeset
    79
    {
hgs
parents:
diff changeset
    80
        mModel = model;
hgs
parents:
diff changeset
    81
        retreiveFocusedImage(); //Update mZoomItem with focused Image
hgs
parents:
diff changeset
    82
        connect( mModel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ), this, SLOT( dataChanged(QModelIndex,QModelIndex) ) );
45
hgs
parents: 44
diff changeset
    83
        connect( mModel, SIGNAL( destroyed() ), this, SLOT( modelDestroyed() ) );
43
hgs
parents:
diff changeset
    84
    }
hgs
parents:
diff changeset
    85
}
hgs
parents:
diff changeset
    86
hgs
parents:
diff changeset
    87
void GlxZoomWidget::setWindowSize(QSize windowSize)
hgs
parents:
diff changeset
    88
{
hgs
parents:
diff changeset
    89
    mWindowSize = windowSize;
hgs
parents:
diff changeset
    90
    mBlackBackgroundItem->setGeometry(QRectF(QPointF(0,0), mWindowSize));
hgs
parents:
diff changeset
    91
    //try to reset the max and min zoomed size here
50
hgs
parents: 45
diff changeset
    92
    //In case the zoom widget is in background reset it
hgs
parents: 45
diff changeset
    93
    if(!mZoomOngoing && mModel) {
hgs
parents: 45
diff changeset
    94
        retreiveFocusedImage();
hgs
parents: 45
diff changeset
    95
    }
hgs
parents: 45
diff changeset
    96
    setZoomParams();
hgs
parents: 45
diff changeset
    97
}
hgs
parents: 45
diff changeset
    98
hgs
parents: 45
diff changeset
    99
void GlxZoomWidget::forceZoomToBackground()
hgs
parents: 45
diff changeset
   100
{
hgs
parents: 45
diff changeset
   101
    mBlackBackgroundItem->hide();
hgs
parents: 45
diff changeset
   102
    //push the widget back to background
hgs
parents: 45
diff changeset
   103
    setZValue(mMinZValue);
hgs
parents: 45
diff changeset
   104
    mZoomOngoing = false;
hgs
parents: 45
diff changeset
   105
    emit zoomWidgetMovedBackground(mFocusIndex);
hgs
parents: 45
diff changeset
   106
    //this actually resets the ZoomWidget and decoder
hgs
parents: 45
diff changeset
   107
    if(mImageDecoder) {
hgs
parents: 45
diff changeset
   108
        mImageDecoder->resetDecoder();
hgs
parents: 45
diff changeset
   109
    }
hgs
parents: 45
diff changeset
   110
    retreiveFocusedImage();
hgs
parents: 45
diff changeset
   111
43
hgs
parents:
diff changeset
   112
}
hgs
parents:
diff changeset
   113
hgs
parents:
diff changeset
   114
void GlxZoomWidget::indexChanged(int index)
hgs
parents:
diff changeset
   115
{
hgs
parents:
diff changeset
   116
    if(mFocusIndex != index) {
hgs
parents:
diff changeset
   117
        mImageDecoder->resetDecoder();//reset the decoder first to cancel pending tasks
hgs
parents:
diff changeset
   118
        mImageDecodeRequestSend = false;
hgs
parents:
diff changeset
   119
        mDecodedImageAvailable = false;
hgs
parents:
diff changeset
   120
        retreiveFocusedImage();  //Update mZoomItem with focused Image
hgs
parents:
diff changeset
   121
    }
hgs
parents:
diff changeset
   122
}
hgs
parents:
diff changeset
   123
hgs
parents:
diff changeset
   124
void GlxZoomWidget::cleanUp()
hgs
parents:
diff changeset
   125
{
44
hgs
parents: 43
diff changeset
   126
    if(mModel) {
hgs
parents: 43
diff changeset
   127
        disconnect( mModel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ), this, SLOT( dataChanged(QModelIndex,QModelIndex) ) );
45
hgs
parents: 44
diff changeset
   128
        disconnect( mModel, SIGNAL( destroyed() ), this, SLOT( modelDestroyed() ) );
44
hgs
parents: 43
diff changeset
   129
        mModel = NULL;
hgs
parents: 43
diff changeset
   130
    }
43
hgs
parents:
diff changeset
   131
    if(mImageDecoder) {
hgs
parents:
diff changeset
   132
        mImageDecoder->resetDecoder();
hgs
parents:
diff changeset
   133
    }
hgs
parents:
diff changeset
   134
    mZoomItem->setPixmap(QPixmap());
hgs
parents:
diff changeset
   135
}
hgs
parents:
diff changeset
   136
hgs
parents:
diff changeset
   137
void GlxZoomWidget::activate()
hgs
parents:
diff changeset
   138
{
hgs
parents:
diff changeset
   139
}
hgs
parents:
diff changeset
   140
hgs
parents:
diff changeset
   141
void GlxZoomWidget::setMinMaxZValue(int minZvalue, int maxZvalue)
hgs
parents:
diff changeset
   142
{
hgs
parents:
diff changeset
   143
    mMinZValue = minZvalue;
hgs
parents:
diff changeset
   144
    mMaxZValue = maxZvalue;
hgs
parents:
diff changeset
   145
}
hgs
parents:
diff changeset
   146
hgs
parents:
diff changeset
   147
void GlxZoomWidget::connectDecodeRequestToPinchEvent()
hgs
parents:
diff changeset
   148
{
hgs
parents:
diff changeset
   149
    connect(this,SIGNAL( pinchGestureReceived(int) ), this, SLOT( sendDecodeRequest(int) ), Qt::QueuedConnection );
hgs
parents:
diff changeset
   150
}
hgs
parents:
diff changeset
   151
hgs
parents:
diff changeset
   152
bool GlxZoomWidget::sceneEvent(QEvent *event)
hgs
parents:
diff changeset
   153
{
hgs
parents:
diff changeset
   154
    bool consume(false);
hgs
parents:
diff changeset
   155
    if (event->type() == QEvent::Gesture) {
hgs
parents:
diff changeset
   156
        consume = executeGestureEvent(this, static_cast<QGestureEvent*>(event));
hgs
parents:
diff changeset
   157
    }
hgs
parents:
diff changeset
   158
    if(!consume)
hgs
parents:
diff changeset
   159
    {
hgs
parents:
diff changeset
   160
        consume = HbScrollArea::sceneEvent(event);
hgs
parents:
diff changeset
   161
    }
hgs
parents:
diff changeset
   162
    return consume;
hgs
parents:
diff changeset
   163
}
hgs
parents:
diff changeset
   164
hgs
parents:
diff changeset
   165
bool GlxZoomWidget::sceneEventFilter(QGraphicsItem *watched,QEvent *event)
hgs
parents:
diff changeset
   166
{
hgs
parents:
diff changeset
   167
     qDebug("GlxCoverFlow::eventFilter " );
hgs
parents:
diff changeset
   168
    bool consume = false;
hgs
parents:
diff changeset
   169
    if (event->type() == QEvent::Gesture) {
hgs
parents:
diff changeset
   170
        consume = executeGestureEvent(watched, static_cast<QGestureEvent*>(event));
hgs
parents:
diff changeset
   171
    }
hgs
parents:
diff changeset
   172
hgs
parents:
diff changeset
   173
    if(!consume) {
hgs
parents:
diff changeset
   174
        consume = HbScrollArea::sceneEventFilter(watched,event);
hgs
parents:
diff changeset
   175
    }
hgs
parents:
diff changeset
   176
    return consume;
hgs
parents:
diff changeset
   177
hgs
parents:
diff changeset
   178
}
hgs
parents:
diff changeset
   179
hgs
parents:
diff changeset
   180
bool GlxZoomWidget::executeGestureEvent(QGraphicsItem *source,QGestureEvent *event)
hgs
parents:
diff changeset
   181
{
44
hgs
parents: 43
diff changeset
   182
         if(QTapGesture *gesture = static_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) {        
hgs
parents: 43
diff changeset
   183
            if (gesture->state() == Qt::GestureFinished) {
hgs
parents: 43
diff changeset
   184
                if(!mTimerId) {
hgs
parents: 43
diff changeset
   185
                    mTimerId = startTimer(500);
hgs
parents: 43
diff changeset
   186
                }
hgs
parents: 43
diff changeset
   187
            else {
hgs
parents: 43
diff changeset
   188
                killTimer(mTimerId);
hgs
parents: 43
diff changeset
   189
                mTimerId = 0;
50
hgs
parents: 45
diff changeset
   190
                animateZoomOut(hbInstance->allMainWindows().first()->mapToScene(gesture->position().toPoint()));
44
hgs
parents: 43
diff changeset
   191
            }
hgs
parents: 43
diff changeset
   192
        }
hgs
parents: 43
diff changeset
   193
        event->accept(gesture);
hgs
parents: 43
diff changeset
   194
        return true;
hgs
parents: 43
diff changeset
   195
    }
43
hgs
parents:
diff changeset
   196
     if (QGesture *pinch = event->gesture(Qt::PinchGesture))  {
52
hgs
parents: 50
diff changeset
   197
         if (isFocussedItemCorrupt()){
hgs
parents: 50
diff changeset
   198
         return true;
hgs
parents: 50
diff changeset
   199
         }
43
hgs
parents:
diff changeset
   200
       QPinchGesture* pinchG = static_cast<QPinchGesture *>(pinch);
hgs
parents:
diff changeset
   201
       QPinchGesture::ChangeFlags changeFlags = pinchG->changeFlags();
hgs
parents:
diff changeset
   202
       if (changeFlags & QPinchGesture::ScaleFactorChanged) {
hgs
parents:
diff changeset
   203
            mPinchGestureOngoing = true;
50
hgs
parents: 45
diff changeset
   204
            mZoomOngoing = true;
43
hgs
parents:
diff changeset
   205
            //bring the zoom widget to foreground
hgs
parents:
diff changeset
   206
            setZValue(mMaxZValue);
hgs
parents:
diff changeset
   207
            //show the black background
hgs
parents:
diff changeset
   208
            mBlackBackgroundItem->setParentItem(parentItem());
hgs
parents:
diff changeset
   209
            mBlackBackgroundItem->setZValue(mMaxZValue - 1);
hgs
parents:
diff changeset
   210
            mBlackBackgroundItem->show();
hgs
parents:
diff changeset
   211
hgs
parents:
diff changeset
   212
            //retreive the gesture values
hgs
parents:
diff changeset
   213
            qreal value = pinchG->scaleFactor() / pinchG->lastScaleFactor();
hgs
parents:
diff changeset
   214
            QPointF center = pinchG->property("centerPoint").toPointF();
hgs
parents:
diff changeset
   215
            //set the gesture center to the scene coordinates
50
hgs
parents: 45
diff changeset
   216
            QPointF sceneGestureCenter = hbInstance->allMainWindows().first()->mapToScene(center.toPoint());
43
hgs
parents:
diff changeset
   217
            zoomImage(value, sceneGestureCenter);
hgs
parents:
diff changeset
   218
hgs
parents:
diff changeset
   219
        }
hgs
parents:
diff changeset
   220
       if (pinchG->state() == Qt::GestureStarted) {
hgs
parents:
diff changeset
   221
           emit pinchGestureReceived(mFocusIndex);
hgs
parents:
diff changeset
   222
       }
hgs
parents:
diff changeset
   223
hgs
parents:
diff changeset
   224
       if (pinchG->state() == Qt::GestureFinished) {
hgs
parents:
diff changeset
   225
           if(mStepCurrentSize != mCurrentSize) {
hgs
parents:
diff changeset
   226
               //For giving a spring effect when user has zoomed more than normal.
hgs
parents:
diff changeset
   227
               if(mStepCurrentSize.width() > mMaxScaleDecSize.width())   {
hgs
parents:
diff changeset
   228
                   //scale the image to limited size
hgs
parents:
diff changeset
   229
                   qreal value = mMaxScaleDecSize.width()/mCurrentSize.width();
hgs
parents:
diff changeset
   230
                   QPointF center(mWindowSize.width()/2, mWindowSize.height()/2);
hgs
parents:
diff changeset
   231
                   QPointF sceneGestureCenter = source->sceneTransform().map(center);
hgs
parents:
diff changeset
   232
                   zoomImage(value, sceneGestureCenter);
hgs
parents:
diff changeset
   233
               }
hgs
parents:
diff changeset
   234
               mPinchGestureOngoing = false;
hgs
parents:
diff changeset
   235
                //finalize the transforms to the geometry else panning will not work
hgs
parents:
diff changeset
   236
                finalizeWidgetTransform();
hgs
parents:
diff changeset
   237
           }
hgs
parents:
diff changeset
   238
//push the Zoom widget to background when zoomed image size nears FS image
hgs
parents:
diff changeset
   239
           if(mStepCurrentSize.width() <= mMinDecScaleSize.width()*1.3)  {
hgs
parents:
diff changeset
   240
               mBlackBackgroundItem->hide();
hgs
parents:
diff changeset
   241
               //push the widget back to background
hgs
parents:
diff changeset
   242
               setZValue(mMinZValue);
50
hgs
parents: 45
diff changeset
   243
               mZoomOngoing = false;
43
hgs
parents:
diff changeset
   244
               emit zoomWidgetMovedBackground(mFocusIndex);
hgs
parents:
diff changeset
   245
               //do not reset the transform here as it will then zoom-in the widget to decoded image size
hgs
parents:
diff changeset
   246
           }
hgs
parents:
diff changeset
   247
       }
hgs
parents:
diff changeset
   248
       //gesture accepted
hgs
parents:
diff changeset
   249
       return true;
hgs
parents:
diff changeset
   250
     }
hgs
parents:
diff changeset
   251
     //gesture rejected
hgs
parents:
diff changeset
   252
     if(!mPinchGestureOngoing) {
hgs
parents:
diff changeset
   253
         return false; 
hgs
parents:
diff changeset
   254
     }
hgs
parents:
diff changeset
   255
     return true;
hgs
parents:
diff changeset
   256
hgs
parents:
diff changeset
   257
}
hgs
parents:
diff changeset
   258
hgs
parents:
diff changeset
   259
void GlxZoomWidget::zoomImage(qreal zoomFactor, QPointF center)
hgs
parents:
diff changeset
   260
{
50
hgs
parents: 45
diff changeset
   261
        // Pinch event filtering for very small zoom factors
hgs
parents: 45
diff changeset
   262
    if (qAbs(1.0 - zoomFactor) < 0.007) {
hgs
parents: 45
diff changeset
   263
        return;
hgs
parents: 45
diff changeset
   264
    }
43
hgs
parents:
diff changeset
   265
    adjustGestureCenter(center, zoomFactor);
hgs
parents:
diff changeset
   266
    QSizeF requiredSize(mCurrentSize.width()*zoomFactor, mCurrentSize.height()*zoomFactor);
hgs
parents:
diff changeset
   267
    limitRequiredSize(requiredSize);
hgs
parents:
diff changeset
   268
    if(requiredSize != mCurrentSize) {
hgs
parents:
diff changeset
   269
        QTransform zoomTransform = mZoomWidget->transform();
hgs
parents:
diff changeset
   270
        QPointF transformedCenter = mZoomWidget->sceneTransform().inverted().map(center);
hgs
parents:
diff changeset
   271
        zoomTransform.translate(transformedCenter.x(),transformedCenter.y());
hgs
parents:
diff changeset
   272
        zoomTransform.scale(requiredSize.width()/mCurrentSize.width(), requiredSize.height()/mCurrentSize.height());
hgs
parents:
diff changeset
   273
        zoomTransform.translate(-transformedCenter.x(),-transformedCenter.y());
hgs
parents:
diff changeset
   274
        mZoomWidget->setTransform(zoomTransform);
hgs
parents:
diff changeset
   275
        mCurrentSize = requiredSize;
hgs
parents:
diff changeset
   276
    }
hgs
parents:
diff changeset
   277
hgs
parents:
diff changeset
   278
}
hgs
parents:
diff changeset
   279
hgs
parents:
diff changeset
   280
hgs
parents:
diff changeset
   281
void GlxZoomWidget::limitRequiredSize(QSizeF &requiredSize)
hgs
parents:
diff changeset
   282
{
hgs
parents:
diff changeset
   283
    if(requiredSize.width() > mMaxScaleSize.width() ) {
hgs
parents:
diff changeset
   284
        requiredSize = mMaxScaleSize ;
hgs
parents:
diff changeset
   285
    }
hgs
parents:
diff changeset
   286
    else if(requiredSize.width() < mMinDecScaleSize.width() ) {
hgs
parents:
diff changeset
   287
        requiredSize = mMinDecScaleSize ;
hgs
parents:
diff changeset
   288
    }
hgs
parents:
diff changeset
   289
hgs
parents:
diff changeset
   290
hgs
parents:
diff changeset
   291
}
hgs
parents:
diff changeset
   292
hgs
parents:
diff changeset
   293
//makes sure that the gesture is on the screen center if the image is smaller than the screen
hgs
parents:
diff changeset
   294
void GlxZoomWidget::adjustGestureCenter(QPointF & gestureCenter, qreal& zoomFactor)
hgs
parents:
diff changeset
   295
{
hgs
parents:
diff changeset
   296
    if(zoomFactor > 1 &&zoomFactor > 1.2 )  {
hgs
parents:
diff changeset
   297
        zoomFactor = 1.2;
hgs
parents:
diff changeset
   298
    }
hgs
parents:
diff changeset
   299
hgs
parents:
diff changeset
   300
    if(zoomFactor < 1 &&zoomFactor < 0.8 )   {
hgs
parents:
diff changeset
   301
        zoomFactor = 0.8;
hgs
parents:
diff changeset
   302
    }
hgs
parents:
diff changeset
   303
    QSizeF requiredSize(mCurrentSize.width()*zoomFactor, mCurrentSize.height()*zoomFactor);
hgs
parents:
diff changeset
   304
    //keep smaller image centered
hgs
parents:
diff changeset
   305
    if(mCurrentSize.width() <= mWindowSize.width() )
hgs
parents:
diff changeset
   306
    {
hgs
parents:
diff changeset
   307
        gestureCenter.setX(mWindowSize.width()/2);
hgs
parents:
diff changeset
   308
hgs
parents:
diff changeset
   309
    }
hgs
parents:
diff changeset
   310
    if(mCurrentSize.height() <= mWindowSize.height())
hgs
parents:
diff changeset
   311
    {
hgs
parents:
diff changeset
   312
        gestureCenter.setY(mWindowSize.height()/2);
hgs
parents:
diff changeset
   313
hgs
parents:
diff changeset
   314
    }
hgs
parents:
diff changeset
   315
    //maintains the boundary of the edges for zoom out conditions
50
hgs
parents: 45
diff changeset
   316
    if(zoomFactor < 1) {
43
hgs
parents:
diff changeset
   317
        QPointF itemOriginPos = mZoomWidget->sceneTransform().map(QPointF(0,0));
hgs
parents:
diff changeset
   318
        bool hasWidthExceededWindow = mCurrentSize.width() > mWindowSize.width();
hgs
parents:
diff changeset
   319
        bool hasHeightExceededWindow = mCurrentSize.height() > mWindowSize.height();
50
hgs
parents: 45
diff changeset
   320
        if(hasWidthExceededWindow) {
hgs
parents: 45
diff changeset
   321
            bool hasItemCrossedBoundary = false;
hgs
parents: 45
diff changeset
   322
            if(itemOriginPos.x() >= -5)  {
hgs
parents: 45
diff changeset
   323
                //image has crossed left boundry leaving blank space
43
hgs
parents:
diff changeset
   324
                //stick the gesture to the left corner
hgs
parents:
diff changeset
   325
                gestureCenter.setX(itemOriginPos.x());
50
hgs
parents: 45
diff changeset
   326
                hasItemCrossedBoundary = true;
hgs
parents: 45
diff changeset
   327
            }
hgs
parents: 45
diff changeset
   328
        
hgs
parents: 45
diff changeset
   329
            //Check if the right boundry can be adjusted
hgs
parents: 45
diff changeset
   330
            if(itemOriginPos.x()+ mCurrentSize.width() <= mWindowSize.width()+5) {
hgs
parents: 45
diff changeset
   331
                //Image is before the right boundry leaving blank space
hgs
parents: 45
diff changeset
   332
                gestureCenter.setX(itemOriginPos.x()+ mCurrentSize.width() );
hgs
parents: 45
diff changeset
   333
                hasItemCrossedBoundary = true;
hgs
parents: 45
diff changeset
   334
            }
hgs
parents: 45
diff changeset
   335
            if((mCurrentSize.width() - mWindowSize.width() <= 20) && !hasItemCrossedBoundary) {
hgs
parents: 45
diff changeset
   336
                gestureCenter.setX(mWindowSize.width()/2 + (qAbs(itemOriginPos.x()) - 10));
43
hgs
parents:
diff changeset
   337
            }
hgs
parents:
diff changeset
   338
        }
50
hgs
parents: 45
diff changeset
   339
hgs
parents: 45
diff changeset
   340
        if(hasHeightExceededWindow) {
hgs
parents: 45
diff changeset
   341
             bool hasItemCrossedBoundary = false;
hgs
parents: 45
diff changeset
   342
            //check if the upper boundry could be adjusted
hgs
parents: 45
diff changeset
   343
            if(itemOriginPos.y() >= -5) {
hgs
parents: 45
diff changeset
   344
                //image has crossed the upper boundry leaving blank space
hgs
parents: 45
diff changeset
   345
                //stick the image to the upper boundry
hgs
parents: 45
diff changeset
   346
                gestureCenter.setY(itemOriginPos.y());
hgs
parents: 45
diff changeset
   347
                hasItemCrossedBoundary = true;
hgs
parents: 45
diff changeset
   348
            }
hgs
parents: 45
diff changeset
   349
            //check if the lower boundry could be adjusted
hgs
parents: 45
diff changeset
   350
            if(itemOriginPos.y()+ mCurrentSize.height() <= mWindowSize.height()+5) {
43
hgs
parents:
diff changeset
   351
                //Image is before the right boundry leaving blank space
hgs
parents:
diff changeset
   352
                //stick the image to the right corner
hgs
parents:
diff changeset
   353
                gestureCenter.setY(itemOriginPos.y()+ mCurrentSize.height());
50
hgs
parents: 45
diff changeset
   354
                hasItemCrossedBoundary = true;
43
hgs
parents:
diff changeset
   355
            }
50
hgs
parents: 45
diff changeset
   356
            if((mCurrentSize.height() - mWindowSize.height() <= 20) && !hasItemCrossedBoundary) {
hgs
parents: 45
diff changeset
   357
                gestureCenter.setY(mWindowSize.height()/2 + (qAbs(itemOriginPos.y()) - 10));
hgs
parents: 45
diff changeset
   358
            }
43
hgs
parents:
diff changeset
   359
        }
hgs
parents:
diff changeset
   360
    }
hgs
parents:
diff changeset
   361
    //control the zoom Factor to boundaries
hgs
parents:
diff changeset
   362
    if(mCurrentSize.width() > mWindowSize.width() && requiredSize.width() <= mWindowSize.width())
hgs
parents:
diff changeset
   363
    {
hgs
parents:
diff changeset
   364
        zoomFactor =  mWindowSize.width()/mCurrentSize.width();
hgs
parents:
diff changeset
   365
hgs
parents:
diff changeset
   366
    }
hgs
parents:
diff changeset
   367
    else if(mCurrentSize.height() > mWindowSize.height() && requiredSize.height() <= mWindowSize.height())
hgs
parents:
diff changeset
   368
    {
hgs
parents:
diff changeset
   369
        zoomFactor =  mWindowSize.height()/mCurrentSize.height();
hgs
parents:
diff changeset
   370
hgs
parents:
diff changeset
   371
    }
hgs
parents:
diff changeset
   372
hgs
parents:
diff changeset
   373
    //reduce the ZF so as to show a decelerated effect at max/min levels
hgs
parents:
diff changeset
   374
hgs
parents:
diff changeset
   375
    if(mCurrentSize.width() > mMaxScaleDecSize.width() && zoomFactor > 1 ) {
hgs
parents:
diff changeset
   376
        zoomFactor = 1.0 + ((zoomFactor-1.0)/6) ;
hgs
parents:
diff changeset
   377
    }
hgs
parents:
diff changeset
   378
        if(mCurrentSize.width() < mMinDecScaleSize.width() && zoomFactor < 1 ) {
hgs
parents:
diff changeset
   379
        zoomFactor = 1.0 - ((1.0-zoomFactor)/6) ;
hgs
parents:
diff changeset
   380
    }
hgs
parents:
diff changeset
   381
hgs
parents:
diff changeset
   382
hgs
parents:
diff changeset
   383
}
hgs
parents:
diff changeset
   384
hgs
parents:
diff changeset
   385
//get the latest focused image and set it to mZoomItem
hgs
parents:
diff changeset
   386
void GlxZoomWidget::retreiveFocusedImage()
hgs
parents:
diff changeset
   387
{
hgs
parents:
diff changeset
   388
hgs
parents:
diff changeset
   389
    QPixmap targetPixmap(getFocusedImage());
hgs
parents:
diff changeset
   390
    //initialize all the variables wrt the focussed pixmap
hgs
parents:
diff changeset
   391
    mZoomWidget->resetTransform();
hgs
parents:
diff changeset
   392
    mItemSize = targetPixmap.size();
hgs
parents:
diff changeset
   393
    mMaxScaleSize = mItemSize;
hgs
parents:
diff changeset
   394
    mMaxScaleSize.scale(mWindowSize*13, Qt::KeepAspectRatio);
hgs
parents:
diff changeset
   395
    mMaxScaleDecSize = mItemSize;
hgs
parents:
diff changeset
   396
    mMaxScaleDecSize.scale(mWindowSize*7, Qt::KeepAspectRatio);
hgs
parents:
diff changeset
   397
    mMinScaleSize = mItemSize* 0.7;
hgs
parents:
diff changeset
   398
    mMinDecScaleSize = mItemSize;
hgs
parents:
diff changeset
   399
    QPointF originPos = sceneTransform().map(QPointF(0,0));
hgs
parents:
diff changeset
   400
    mZoomWidget->setGeometry(QRectF(QPointF(mWindowSize.width()/2 - mItemSize.width()/2,mWindowSize.height()/2 - mItemSize.height()/2),mItemSize )); //chk this
hgs
parents:
diff changeset
   401
    mZoomWidget->setPreferredSize(mItemSize);
hgs
parents:
diff changeset
   402
    mZoomItem->setPixmap(targetPixmap);
hgs
parents:
diff changeset
   403
    mCurrentSize = mItemSize;
hgs
parents:
diff changeset
   404
    mStepCurrentSize = mItemSize;
hgs
parents:
diff changeset
   405
    setContentWidget(mZoomWidget);
hgs
parents:
diff changeset
   406
    show();
hgs
parents:
diff changeset
   407
}
hgs
parents:
diff changeset
   408
hgs
parents:
diff changeset
   409
hgs
parents:
diff changeset
   410
void GlxZoomWidget::dataChanged(QModelIndex startIndex, QModelIndex endIndex)
hgs
parents:
diff changeset
   411
{
hgs
parents:
diff changeset
   412
    if(mFocusIndex >= startIndex.row() && mFocusIndex <= endIndex.row()) {
hgs
parents:
diff changeset
   413
        //get the latest image from the model
hgs
parents:
diff changeset
   414
        //will replace a decoded image if callback is received after decoded image is received so a fix is required
hgs
parents:
diff changeset
   415
        //retreiveFocusedImage();
hgs
parents:
diff changeset
   416
        if(!mDecodedImageAvailable)  {
hgs
parents:
diff changeset
   417
        QPixmap targetPixmap(getFocusedImage());
44
hgs
parents: 43
diff changeset
   418
        mItemSize = targetPixmap.size();
hgs
parents: 43
diff changeset
   419
        mMaxScaleSize = mItemSize;
hgs
parents: 43
diff changeset
   420
        mMaxScaleSize.scale(mWindowSize*13, Qt::KeepAspectRatio);
hgs
parents: 43
diff changeset
   421
        mMaxScaleDecSize = mItemSize;
hgs
parents: 43
diff changeset
   422
        mMaxScaleDecSize.scale(mWindowSize*7, Qt::KeepAspectRatio);
hgs
parents: 43
diff changeset
   423
        mMinScaleSize = mItemSize* 0.7;
hgs
parents: 43
diff changeset
   424
        mMinDecScaleSize = mItemSize;
43
hgs
parents:
diff changeset
   425
        mZoomItem->setPixmap(targetPixmap);
hgs
parents:
diff changeset
   426
        finalizeWidgetTransform();
hgs
parents:
diff changeset
   427
        }
hgs
parents:
diff changeset
   428
    }
hgs
parents:
diff changeset
   429
}
hgs
parents:
diff changeset
   430
45
hgs
parents: 44
diff changeset
   431
void GlxZoomWidget::modelDestroyed()
hgs
parents: 44
diff changeset
   432
{
hgs
parents: 44
diff changeset
   433
    mModel = NULL ;    
hgs
parents: 44
diff changeset
   434
}
hgs
parents: 44
diff changeset
   435
hgs
parents: 44
diff changeset
   436
void GlxZoomWidget::indexChanged()
hgs
parents: 44
diff changeset
   437
    {
hgs
parents: 44
diff changeset
   438
    retreiveFocusedImage();
hgs
parents: 44
diff changeset
   439
    }
hgs
parents: 44
diff changeset
   440
43
hgs
parents:
diff changeset
   441
void GlxZoomWidget::decodedImageAvailable()
hgs
parents:
diff changeset
   442
{
hgs
parents:
diff changeset
   443
    //new bitmap with better resolution is available
hgs
parents:
diff changeset
   444
    //so set it to the item
hgs
parents:
diff changeset
   445
    QPixmap decodedPixmap = mImageDecoder->getPixmap();
hgs
parents:
diff changeset
   446
    disconnect(mImageDecoder, SIGNAL(pixmapDecoded()), this, SLOT(decodedImageAvailable()));
hgs
parents:
diff changeset
   447
    if(decodedPixmap.isNull()){
hgs
parents:
diff changeset
   448
        return;
hgs
parents:
diff changeset
   449
    }
hgs
parents:
diff changeset
   450
    mDecodedImageAvailable = true;
hgs
parents:
diff changeset
   451
    mZoomItem->setPixmap(decodedPixmap);
hgs
parents:
diff changeset
   452
    mItemSize = decodedPixmap.size();
hgs
parents:
diff changeset
   453
    //this is important if not done then old transforms will be applied on the new image
hgs
parents:
diff changeset
   454
    finalizeWidgetTransform();
hgs
parents:
diff changeset
   455
}
hgs
parents:
diff changeset
   456
hgs
parents:
diff changeset
   457
void GlxZoomWidget::sendDecodeRequest(int index)
hgs
parents:
diff changeset
   458
{
hgs
parents:
diff changeset
   459
    if(!mImageDecodeRequestSend) {
hgs
parents:
diff changeset
   460
        QString imagePath = (mModel->data(mModel->index(index,0),GlxUriRole)).value<QString>();
hgs
parents:
diff changeset
   461
        mImageDecoder->decodeImage(imagePath);
hgs
parents:
diff changeset
   462
        connect(mImageDecoder, SIGNAL(pixmapDecoded()), this, SLOT(decodedImageAvailable()));
hgs
parents:
diff changeset
   463
        mImageDecodeRequestSend = true;
hgs
parents:
diff changeset
   464
    }
hgs
parents:
diff changeset
   465
}
hgs
parents:
diff changeset
   466
hgs
parents:
diff changeset
   467
hgs
parents:
diff changeset
   468
void GlxZoomWidget::finalizeWidgetTransform()
hgs
parents:
diff changeset
   469
{
hgs
parents:
diff changeset
   470
    QPointF widgetPos = mZoomWidget->sceneTransform().map(QPointF(0,0)); //Map the origin wrt scene
hgs
parents:
diff changeset
   471
    mZoomWidget->resetTransform();
hgs
parents:
diff changeset
   472
    mZoomWidget->scale(mCurrentSize.width()/mItemSize.width(), mCurrentSize.height()/mItemSize.height());
hgs
parents:
diff changeset
   473
    mZoomWidget->setGeometry(QRectF(widgetPos , mCurrentSize));
hgs
parents:
diff changeset
   474
    // this updates HbScrollArea on the sizeHint of ZoomWidget
hgs
parents:
diff changeset
   475
    mZoomWidget->setPreferredSize(mCurrentSize);
hgs
parents:
diff changeset
   476
    mStepCurrentSize = mCurrentSize;
hgs
parents:
diff changeset
   477
}
hgs
parents:
diff changeset
   478
hgs
parents:
diff changeset
   479
QPixmap GlxZoomWidget::getFocusedImage()
hgs
parents:
diff changeset
   480
{
hgs
parents:
diff changeset
   481
    mFocusIndex = mModel->data(mModel->index(0,0),GlxFocusIndexRole).value<int>();
hgs
parents:
diff changeset
   482
    QVariant iconVariant = mModel->data(mModel->index(mFocusIndex,0),GlxFsImageRole);
hgs
parents:
diff changeset
   483
    QVariant sizeVariant = mModel->data(mModel->index(mFocusIndex,0),GlxDimensionsRole);
hgs
parents:
diff changeset
   484
    QPixmap targetPixmap;
hgs
parents:
diff changeset
   485
    //retreive pixmap from the HbIcon received from model
hgs
parents:
diff changeset
   486
    //should change the model to return and save pixmaps and convert to HbIcons Instead
hgs
parents:
diff changeset
   487
    if ( iconVariant.isValid() &&  iconVariant.canConvert<HbIcon> () ) {
hgs
parents:
diff changeset
   488
         QIcon itemIcon = iconVariant.value<HbIcon>().qicon();
hgs
parents:
diff changeset
   489
         QSize itemSize = itemIcon.actualSize(mWindowSize);
hgs
parents:
diff changeset
   490
         QSize scaleSize;
hgs
parents:
diff changeset
   491
         if(sizeVariant.isValid() &&  sizeVariant.canConvert<QSize> ()) {
hgs
parents:
diff changeset
   492
             scaleSize = sizeVariant.toSize();
hgs
parents:
diff changeset
   493
             if(!(scaleSize.width() < mWindowSize.width() && scaleSize.height() < mWindowSize.height()))  {
hgs
parents:
diff changeset
   494
                 scaleSize = mWindowSize;
hgs
parents:
diff changeset
   495
             }
hgs
parents:
diff changeset
   496
         }
hgs
parents:
diff changeset
   497
         targetPixmap = itemIcon.pixmap(itemSize).scaled(scaleSize, Qt::KeepAspectRatio);
hgs
parents:
diff changeset
   498
         mItemSize = targetPixmap.size();
hgs
parents:
diff changeset
   499
    }
hgs
parents:
diff changeset
   500
    return targetPixmap;
hgs
parents:
diff changeset
   501
hgs
parents:
diff changeset
   502
}
hgs
parents:
diff changeset
   503
50
hgs
parents: 45
diff changeset
   504
void GlxZoomWidget::setZoomParams()
hgs
parents: 45
diff changeset
   505
{
hgs
parents: 45
diff changeset
   506
    if (mModel)  {
hgs
parents: 45
diff changeset
   507
        QVariant sizeVariant = mModel->data(mModel->index(mFocusIndex,0),GlxDimensionsRole);
hgs
parents: 45
diff changeset
   508
        QSize fsSize;
hgs
parents: 45
diff changeset
   509
        if(sizeVariant.isValid() &&  sizeVariant.canConvert<QSize> ()) {
hgs
parents: 45
diff changeset
   510
            fsSize = sizeVariant.toSize();
hgs
parents: 45
diff changeset
   511
            if(!(fsSize.width() < mWindowSize.width() && fsSize.height() < mWindowSize.height()))  {
hgs
parents: 45
diff changeset
   512
                fsSize.scale( mWindowSize, Qt::KeepAspectRatio);
hgs
parents: 45
diff changeset
   513
            }
hgs
parents: 45
diff changeset
   514
            mMaxScaleSize = fsSize;
hgs
parents: 45
diff changeset
   515
            mMaxScaleSize.scale(mWindowSize*13, Qt::KeepAspectRatio);
hgs
parents: 45
diff changeset
   516
            mMaxScaleDecSize = fsSize;
hgs
parents: 45
diff changeset
   517
            mMaxScaleDecSize.scale(mWindowSize*7, Qt::KeepAspectRatio);
hgs
parents: 45
diff changeset
   518
            mMinScaleSize = fsSize* 0.7;
hgs
parents: 45
diff changeset
   519
            mMinDecScaleSize = fsSize;
hgs
parents: 45
diff changeset
   520
        }
hgs
parents: 45
diff changeset
   521
    }
43
hgs
parents:
diff changeset
   522
hgs
parents:
diff changeset
   523
50
hgs
parents: 45
diff changeset
   524
}
hgs
parents: 45
diff changeset
   525
43
hgs
parents:
diff changeset
   526
hgs
parents:
diff changeset
   527
hgs
parents:
diff changeset
   528
void GlxZoomWidget::animateZoomIn(QPointF animRefPoint)
hgs
parents:
diff changeset
   529
{
52
hgs
parents: 50
diff changeset
   530
    if (isFocussedItemCorrupt()){
hgs
parents: 50
diff changeset
   531
    return;
hgs
parents: 50
diff changeset
   532
    }
hgs
parents: 50
diff changeset
   533
    emit pinchGestureReceived(mFocusIndex);
hgs
parents: 50
diff changeset
   534
    //bring the zoom widget to foreground
hgs
parents: 50
diff changeset
   535
    mZoomOngoing = true;
hgs
parents: 50
diff changeset
   536
    setZValue(mMaxZValue);
hgs
parents: 50
diff changeset
   537
    //show the black background
hgs
parents: 50
diff changeset
   538
    mBlackBackgroundItem->setParentItem(parentItem());
hgs
parents: 50
diff changeset
   539
    mBlackBackgroundItem->setZValue(mMaxZValue - 1);
hgs
parents: 50
diff changeset
   540
    mBlackBackgroundItem->show();
hgs
parents: 50
diff changeset
   541
    m_AnimRefPoint = animRefPoint;
43
hgs
parents:
diff changeset
   542
    QSizeF requiredSize = mItemSize;
hgs
parents:
diff changeset
   543
    requiredSize.scale(mWindowSize*3.5, Qt::KeepAspectRatio);
44
hgs
parents: 43
diff changeset
   544
	m_FinalAnimatedScaleFactor = requiredSize.width()/mMinDecScaleSize.width();
43
hgs
parents:
diff changeset
   545
	m_AnimTimeLine->setDirection(QTimeLine::Forward);
hgs
parents:
diff changeset
   546
	m_AnimTimeLine->start();
hgs
parents:
diff changeset
   547
  //  zoomImage(5, m_AnimRefPoint);
hgs
parents:
diff changeset
   548
hgs
parents:
diff changeset
   549
}
hgs
parents:
diff changeset
   550
void GlxZoomWidget::animateZoomOut(QPointF animRefPoint)
hgs
parents:
diff changeset
   551
{
hgs
parents:
diff changeset
   552
	m_AnimRefPoint = animRefPoint;
44
hgs
parents: 43
diff changeset
   553
	m_FinalAnimatedScaleFactor = mMinDecScaleSize.width()/mCurrentSize.width();
43
hgs
parents:
diff changeset
   554
	//m_AnimTimeLine->setDirection(QTimeLine::Backward);
hgs
parents:
diff changeset
   555
	m_AnimTimeLine->start();
hgs
parents:
diff changeset
   556
}
hgs
parents:
diff changeset
   557
void GlxZoomWidget::animationFrameChanged(int frameNumber)
hgs
parents:
diff changeset
   558
{
hgs
parents:
diff changeset
   559
qreal scaleFactor = 1;
hgs
parents:
diff changeset
   560
	if(m_FinalAnimatedScaleFactor > 1) {
44
hgs
parents: 43
diff changeset
   561
        scaleFactor = (1.0 + (((m_FinalAnimatedScaleFactor - 1)/100)*frameNumber))/(mCurrentSize.width()/mMinDecScaleSize.width());
43
hgs
parents:
diff changeset
   562
	}
hgs
parents:
diff changeset
   563
	if(m_FinalAnimatedScaleFactor < 1) {
44
hgs
parents: 43
diff changeset
   564
        scaleFactor = (m_FinalAnimatedScaleFactor+ (((1 - m_FinalAnimatedScaleFactor)/100)*frameNumber))/(mCurrentSize.width()/mMinDecScaleSize.width());
43
hgs
parents:
diff changeset
   565
	}
hgs
parents:
diff changeset
   566
hgs
parents:
diff changeset
   567
	zoomImage(scaleFactor, m_AnimRefPoint);
hgs
parents:
diff changeset
   568
hgs
parents:
diff changeset
   569
}
hgs
parents:
diff changeset
   570
void GlxZoomWidget::animationTimeLineFinished()
hgs
parents:
diff changeset
   571
{
hgs
parents:
diff changeset
   572
	finalizeWidgetTransform();
hgs
parents:
diff changeset
   573
//push the Zoom widget to background when zoomed image size nears FS image
hgs
parents:
diff changeset
   574
           if(mStepCurrentSize.width() <= mMinDecScaleSize.width()*1.3)  {
hgs
parents:
diff changeset
   575
               mBlackBackgroundItem->hide();
hgs
parents:
diff changeset
   576
               //push the widget back to background
hgs
parents:
diff changeset
   577
               setZValue(mMinZValue);
50
hgs
parents: 45
diff changeset
   578
               mZoomOngoing = false;
43
hgs
parents:
diff changeset
   579
               emit zoomWidgetMovedBackground(mFocusIndex);
hgs
parents:
diff changeset
   580
               //do not reset the transform here as it will then zoom-in the widget to decoded image size
hgs
parents:
diff changeset
   581
           }
hgs
parents:
diff changeset
   582
}
hgs
parents:
diff changeset
   583
44
hgs
parents: 43
diff changeset
   584
hgs
parents: 43
diff changeset
   585
void GlxZoomWidget::timerEvent(QTimerEvent *event)
hgs
parents: 43
diff changeset
   586
{
hgs
parents: 43
diff changeset
   587
    if(mTimerId == event->timerId())
hgs
parents: 43
diff changeset
   588
    {
hgs
parents: 43
diff changeset
   589
        killTimer(mTimerId);
hgs
parents: 43
diff changeset
   590
        mTimerId = 0;
hgs
parents: 43
diff changeset
   591
    }
hgs
parents: 43
diff changeset
   592
}
52
hgs
parents: 50
diff changeset
   593
hgs
parents: 50
diff changeset
   594
bool GlxZoomWidget::isFocussedItemCorrupt()
hgs
parents: 50
diff changeset
   595
{
hgs
parents: 50
diff changeset
   596
    QVariant variant = mModel->data( mModel->index( mFocusIndex, 0 ), GlxImageCorruptRole );
hgs
parents: 50
diff changeset
   597
    if ( variant.isValid() && variant.canConvert< bool> () ) {
hgs
parents: 50
diff changeset
   598
        return variant.value< bool > () ;
hgs
parents: 50
diff changeset
   599
    }
hgs
parents: 50
diff changeset
   600
    return false ;    
hgs
parents: 50
diff changeset
   601
}
hgs
parents: 50
diff changeset
   602