ui/widgets/glxzoomwidget/inc/glxzoomwidget.h
branchRCL_3
changeset 59 8e5f6eea9c9f
equal deleted inserted replaced
57:ea65f74e6de4 59:8e5f6eea9c9f
       
     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 #include <glxzoomwidget_global.h>
       
    27 
       
    28 class QGestureEvent;
       
    29 class QPinchGesture;
       
    30 class HbIconItem;
       
    31 class GlxImageDecoderWrapper;
       
    32 class QTimeLine;
       
    33 
       
    34 
       
    35 
       
    36 class GLXZOOMWIDGETSHARED_EXPORT GlxZoomWidget : public HbScrollArea
       
    37 {
       
    38     Q_OBJECT
       
    39 
       
    40     public:
       
    41     GlxZoomWidget (QGraphicsItem *parent = NULL);
       
    42     ~GlxZoomWidget ();
       
    43     void setModel (QAbstractItemModel *model) ;
       
    44     void indexChanged(int index);
       
    45     void setWindowSize(QSize windowSize);
       
    46     void cleanUp();
       
    47     void activate();
       
    48     void setMinMaxZValue(int minZvalue, int maxZvalue);
       
    49     void connectDecodeRequestToPinchEvent();
       
    50     
       
    51     /*
       
    52      * This is an overloaded function when an index is changes due to deletion 
       
    53      */
       
    54     void indexChanged();
       
    55     void forceZoomToBackground();
       
    56     
       
    57     signals:
       
    58     void pinchGestureReceived(int index);
       
    59     void zoomWidgetMovedBackground(int index);
       
    60     void stepZoom();
       
    61     
       
    62     public slots:
       
    63     //for Decoder support
       
    64     void decodedImageAvailable();
       
    65     void sendDecodeRequest(int index);
       
    66 
       
    67 	//for animation effects
       
    68 	void animateZoomIn(QPointF animRefPoint);
       
    69 	void animateZoomOut(QPointF animRefPoint);
       
    70 	void animationTimeLineFinished();
       
    71 
       
    72 	//animate double tap
       
    73 	void animateDoubleTap();
       
    74 	
       
    75     protected:
       
    76     bool sceneEvent(QEvent *event);
       
    77     bool sceneEventFilter(QGraphicsItem *watched,QEvent *event);
       
    78     void timerEvent(QTimerEvent *event);
       
    79     protected slots:
       
    80     void dataChanged(QModelIndex startIndex, QModelIndex endIndex);
       
    81     void modelDestroyed();
       
    82 
       
    83     private:
       
    84     bool executeGestureEvent(QGraphicsItem *source,QGestureEvent *event);
       
    85     //Responsible for changing the transforms of the widget wrt the ZF and center
       
    86 	//Also adjusts the ZF, center and final size so as to respect the boundaries
       
    87     void zoomImage(qreal zoomFactor, QPointF center);
       
    88     //This API will adjust the gesture center to maintain boundaries
       
    89 	//called from GlxZoomWidget::zoomImage
       
    90     void adjustGestureCenter(QPointF & gestureCenter, qreal& zoomFactor);
       
    91     //this API will limit the max/min Zoom Size possible
       
    92 	//called from GlxZoomWidget::zoomImage
       
    93     void limitRequiredSize(QSizeF &requiredSize);
       
    94 	//gets the latest focussed image from the model
       
    95     void retreiveFocusedImage();
       
    96     //finalize the transform and update the sizehint of mZoomWidget
       
    97     void finalizeWidgetTransform();
       
    98     //get the focused image from the model
       
    99     QPixmap getFocusedImage();
       
   100     //set all the zoom parameters as per the circumstances
       
   101     void setZoomParams();
       
   102 
       
   103     bool isFocussedItemCorrupt();
       
   104     //data members
       
   105 private:
       
   106     //to be in sync with the model
       
   107     QAbstractItemModel *mModel;
       
   108 
       
   109     //view Z values 
       
   110     //might push to layouts later
       
   111     int mMinZValue ;
       
   112     int mMaxZValue ;
       
   113     int mTimerId;
       
   114 
       
   115     //status flags
       
   116     //To check if the decode request has already been send or not
       
   117     bool mImageDecodeRequestSend; 
       
   118     //To check if the pinch gesture is in progress to block any events to HbScrollArea
       
   119     bool mPinchGestureOngoing; 
       
   120     //to check if decoded image is available
       
   121     bool mDecodedImageAvailable;
       
   122     //to check if the widget is actually in Foreground
       
   123     bool mZoomOngoing;
       
   124 
       
   125     //view widgets
       
   126     QGraphicsPixmapItem *mZoomItem;   //Item containing the pixmap
       
   127     QGraphicsWidget *mZoomWidget;     //container :all scaling and transforms would be done on this widget
       
   128     HbIconItem* mBlackBackgroundItem; //for setting black background
       
   129 
       
   130     int mFocusIndex;
       
   131 
       
   132     //size parameter
       
   133     QSizeF mItemSize;        // the actual pixmap size. Keep it updated with latest pixmap size
       
   134     QSizeF mStepCurrentSize; //to save the size before gesture started
       
   135     QSizeF mCurrentSize;     //save sizes scaled by gesture
       
   136     QSize mWindowSize;      //the window size
       
   137     QSizeF mMinScaleSize;   //minimum posible size
       
   138     QSizeF mMinDecScaleSize;   //the Minimum scale limit after which the image scaling down should be decelerated
       
   139     QSizeF mMaxScaleSize;   // the maximum scale limit
       
   140     QSizeF mMaxScaleDecSize;   // the Maximum scale limit after which the image scaling should be decelerated
       
   141 	//for animation effect
       
   142 	qreal m_FinalAnimatedScaleFactor;
       
   143 	QPointF m_AnimRefPoint;
       
   144 	QTimeLine *m_AnimTimeLine;
       
   145     //for Decoder support
       
   146     GlxImageDecoderWrapper* mImageDecoder;
       
   147 
       
   148     //stores the incremental scalingfactor(sf) while performing double tap animation
       
   149     qreal mIncSF;
       
   150     //stores the scalingfactor increment applicable for each step of double tap animation
       
   151     qreal msfInc;
       
   152     //stores the item size before performing zoomout or zoomin
       
   153     QSizeF minitSize;
       
   154     //counter to track the double tap animation steps
       
   155     int mdoubletapSteps;
       
   156 };
       
   157 #endif  //GLXZOOMWIDGET_H