ui/views/fullscreenview/inc/glxcoverflow.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 23 Jun 2010 18:12:48 +0300
changeset 48 d0b4e67b3a60
parent 36 6481344a6d67
child 45 863223ea6961
permissions -rw-r--r--
Revision: 201023 Kit: 2010125

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:   ?Description
*
*/



#ifndef GLXCOVERFLOW_H
#define GLXCOVERFLOW_H

#define NBR_ICON_ITEM 5

#include <hbscrollarea.h>
#include <hbeffect.h>

//forward declaration
class HbIconItem;
class HbMainWindow;
class QAbstractItemModel;

class QGestureEvent;
typedef enum
{
    NO_MOVE,
    TAP_MOVE,
    LEFT_MOVE,
    RIGHT_MOVE,
    LONGPRESS_MOVE,
} GlxUserMove;

typedef enum
{
    TAP_EVENT, //send the signal when user tap on full screen
    PANNING_START_EVENT, //send the signal when panning of full screen start
    EMPTY_ROW_EVENT //send the signal when model have no data
} GlxCoverFlowEvent;

class GlxCoverFlow : public HbWidget
{
Q_OBJECT

public :
	GlxCoverFlow (QGraphicsItem *parent = NULL);
	~GlxCoverFlow ();
    void setItemSize (QSize &size);
    void setModel (QAbstractItemModel *model);
    void indexChanged (int index);
    void setUiOn(bool uiOn) { mUiOn = uiOn; }
    void partiallyClean();
    void partiallyCreate(QAbstractItemModel *model, QSize itemSize);
	void setCoverFlow();
    void ClearCoverFlow();
	void setMultitouchFilter(QGraphicsItem* multitouchFilter);
		    
public slots:
	void zoomStarted(int index);
	void zoomFinished(int index);

signals :
    void coverFlowEvent(GlxCoverFlowEvent e);
    void changeSelectedIndex(const QModelIndex &index);
    void autoLeftMoveSignal();
    void autoRightMoveSignal();
    void doubleTapEventReceived(QPointF position);

protected slots:
    void panGesture ( const QPointF & delta )  ;
    void longPressGesture(const QPointF &point) ;
    void dataChanged(QModelIndex startIndex, QModelIndex endIndex);
    void rowsInserted(const QModelIndex &parent, int start, int end);
    void rowsRemoved(const QModelIndex &parent, int start, int end);
    void autoLeftMove();
    void autoRightMove();

protected:
	void gestureEvent(QGestureEvent *event);

    void move(int value);

    void setRows() ;
    void setStripLen();
    int calculateIndex(int index);
    
    void loadIconItems (); 
    void updateIconItem (qint16 selIndex, qint16 selIconIndex, qint16 deltaX);
    
    //clear all the model connection
    void clearCurrentModel();
    //add the connection to the model
    void initializeNewModel();
    //reset all the data of cover flow
    void resetCoverFlow();
    int getSubState();
    void timerEvent(QTimerEvent *event);

private:
	HbIconItem *mIconItem[NBR_ICON_ITEM];      //at most contain only five item
    qint16 mSelItemIndex;                    // current full screen index
    qint16 mRows;                        // total number of item  
    //QModelIndex mIndex;                  //current model index of seleced item
    qint16 mSelIndex;                    // remove once model concept is integreted
    qint32 mStripLen;                    //virtual strip lenght
    qint32 mCurrentPos;                   //current postion in the virtual strip
    QSize mItemSize;                     //hb icon item size
    bool mUiOn;
    int mBounceBackDeltaX;
    QAbstractItemModel *mModel;
    GlxUserMove mMoveDir;
    int mSpeed;        
	bool mZoomOn;
	QGraphicsItem* mMultitouchFilter;
    int mTimerId;
};

#endif /* GLXCOVERFLOW_H_ */