ui/views/fullscreenview/inc/glxzoomwidget.h
changeset 33 1ee2af37811f
equal deleted inserted replaced
29:2c833fc9e98f 33:1ee2af37811f
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   glxzoomwidget.h
       
    15 *               definition of the class glxzoomwidget which controls the Zoom behavior of coverflow.
       
    16 *
       
    17 */
       
    18 #ifndef GLXZOOMWIDGET_H
       
    19 #define GLXZOOMWIDGET_H
       
    20 
       
    21 #include <QObject>
       
    22 #include <QGraphicsWidget>
       
    23 #include <QPixmap>
       
    24 #include <hbscrollarea.h>
       
    25 
       
    26 class QGestureEvent;
       
    27 class QPinchGesture;
       
    28 class HbIconItem;
       
    29 class GlxImageDecoderWrapper;
       
    30 
       
    31 const int MAXZVALUE = 100;
       
    32 const int MINZVALUE = 0;
       
    33 
       
    34 class GlxZoomWidget : public HbScrollArea
       
    35 {
       
    36     Q_OBJECT
       
    37 
       
    38     public:
       
    39     GlxZoomWidget (QGraphicsItem *parent = NULL);
       
    40     ~GlxZoomWidget ();
       
    41     void setModel (QAbstractItemModel *model) ;
       
    42     void indexChanged(int index);
       
    43     void setWindowSize(QSize windowSize);
       
    44     void cleanUp();
       
    45     void activate();
       
    46 
       
    47     signals:
       
    48     void pinchGestureReceived(int index);
       
    49     void zoomWidgetMovedBackground(int index);
       
    50 
       
    51     public slots:
       
    52     //for Decoder support
       
    53     void decodedImageAvailable();
       
    54 
       
    55     protected:
       
    56     bool sceneEvent(QEvent *event);
       
    57     bool sceneEventFilter(QGraphicsItem *watched,QEvent *event);
       
    58     protected slots:
       
    59     void dataChanged(QModelIndex startIndex, QModelIndex endIndex);
       
    60     void sendDecodeRequest(int index);
       
    61 
       
    62     private:
       
    63     bool executeGestureEvent(QGraphicsItem *source,QGestureEvent *event);
       
    64     //Responsible for changing the transforms of the widget wrt the ZF and center
       
    65 	//Also adjusts the ZF, center and final size so as to respect the boundaries
       
    66     void zoomImage(qreal zoomFactor, QPointF center);
       
    67     //This API will adjust the gesture center to maintain boundaries
       
    68 	//called from GlxZoomWidget::zoomImage
       
    69     void adjustGestureCenter(QPointF & gestureCenter, qreal& zoomFactor);
       
    70     //this API will limit the max/min Zoom Size possible
       
    71 	//called from GlxZoomWidget::zoomImage
       
    72     void limitRequiredSize(QSizeF &requiredSize);
       
    73 	//gets the latest focussed image from the model
       
    74     void retreiveFocusedImage();
       
    75     //finalize the transform and update the sizehint of mZoomWidget
       
    76     void finalizeWidgetTransform();
       
    77     //get the focused image from the model
       
    78     QPixmap getFocusedImage();
       
    79 
       
    80     //data members
       
    81     private:
       
    82     //view widgets
       
    83     QGraphicsPixmapItem *mZoomItem;   //Item containing the pixmap
       
    84     QGraphicsWidget *mZoomWidget;     //container :all scaling and transforms would be done on this widget
       
    85     HbIconItem* mBlackBackgroundItem; //for setting black background
       
    86 
       
    87     //to be in sync with the model
       
    88     QAbstractItemModel *mModel;
       
    89     int mFocusIndex;
       
    90 
       
    91     //size parameter
       
    92     QSizeF mItemSize;        // the actual pixmap size. Keep it updated with latest pixmap size
       
    93     QSizeF mStepCurrentSize; //to save the size before gesture started
       
    94     QSizeF mCurrentSize;     //save sizes scaled by gesture
       
    95     QSize mWindowSize;      //the window size
       
    96     QSizeF mMinScaleSize;   //minimum posible size
       
    97     QSizeF mMinDecScaleSize;   //the Minimum scale limit after which the image scaling down should be decelerated
       
    98     QSizeF mMaxScaleSize;   // the maximum scale limit
       
    99     QSizeF mMaxScaleDecSize;   // the Maximum scale limit after which the image scaling should be decelerated
       
   100 
       
   101     //for Decoder support
       
   102     GlxImageDecoderWrapper* mImageDecoder;
       
   103 
       
   104     //status flags
       
   105 	//To check if the decode request has already been send or not
       
   106     bool mImageDecodeRequestSend; 
       
   107 	//To check if the pinch gesture is in progress to block any events to HbScrollArea
       
   108     bool mPinchGestureOngoing; 
       
   109     //to check if decoded image is available
       
   110     bool mDecodedImageAvailable;
       
   111 
       
   112 };
       
   113 #endif  //GLXZOOMWIDGET_H