ganeswidgets/inc/hggridcontainer.h
author hgs
Wed, 06 Oct 2010 14:53:41 +0300
changeset 20 a60f8b6b1d32
parent 17 a10844a9914d
permissions -rw-r--r--
201039
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#ifndef HGGRIDCONTAINER_H
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#define HGGRIDCONTAINER_H
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
6
hgs
parents: 3
diff changeset
    21
#include "hgcontainer.h"
17
hgs
parents: 6
diff changeset
    22
#include <QPropertyAnimation>
hgs
parents: 6
diff changeset
    23
#include <QQueue>
0
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
class HgWidgetItem;
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
class HgMediaWallRenderer;
17
hgs
parents: 6
diff changeset
    27
class HbPinchGesture;
0
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
class HgGridContainer : public HgContainer
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
{
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
    Q_OBJECT
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
    Q_DISABLE_COPY(HgGridContainer)
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
public:
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
    explicit HgGridContainer(QGraphicsItem *parent = 0);
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
    
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
    virtual ~HgGridContainer();
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
3
c863538fcbb6 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
    39
    void setEffect3dEnabled(bool effect3dEnabled);
c863538fcbb6 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
    40
    bool effect3dEnabled() const;
c863538fcbb6 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
    41
    
17
hgs
parents: 6
diff changeset
    42
    void setPinchEnabled(bool pinchEnabled);
hgs
parents: 6
diff changeset
    43
    bool pinchEnabled() const;
hgs
parents: 6
diff changeset
    44
    void setPinchLevels(QPair<int,int> levels, Qt::Orientation scrollDirection);
hgs
parents: 6
diff changeset
    45
    QPair<int,int> pinchLevels(Qt::Orientation scrollDirection) const;
hgs
parents: 6
diff changeset
    46
    
hgs
parents: 6
diff changeset
    47
    void setRowCount(int count, Qt::Orientation scrollDirection = Qt::Horizontal);
hgs
parents: 6
diff changeset
    48
    int rowCount(Qt::Orientation scrollDirection) const;
hgs
parents: 6
diff changeset
    49
20
hgs
parents: 17
diff changeset
    50
    void setReflectionsEnabled(bool reflectionsEnabled);
hgs
parents: 17
diff changeset
    51
    bool reflectionsEnabled() const;    
hgs
parents: 17
diff changeset
    52
    
17
hgs
parents: 6
diff changeset
    53
signals:
hgs
parents: 6
diff changeset
    54
hgs
parents: 6
diff changeset
    55
    void emptySpacePressed();
hgs
parents: 6
diff changeset
    56
    
0
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
protected:
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
    // events
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
    virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
    
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
    // from HgContainer
1
e48454f237ca Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    63
    virtual HgMediaWallRenderer* createRenderer(Qt::Orientation scrollDirection);
0
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
    virtual qreal getCameraDistance(qreal springVelocity);
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
    virtual qreal getCameraRotationY(qreal springVelocity);
17
hgs
parents: 6
diff changeset
    66
    virtual bool handleTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex);
hgs
parents: 6
diff changeset
    67
    virtual bool handleLongTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemindex);
1
e48454f237ca Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    68
    virtual void onScrollPositionChanged(qreal pos);
17
hgs
parents: 6
diff changeset
    69
    virtual bool handleTap(Qt::GestureState state, const QPointF &pos);
hgs
parents: 6
diff changeset
    70
    virtual bool handleLongTap(Qt::GestureState state, const QPointF &pos);
hgs
parents: 6
diff changeset
    71
    virtual void setOrientation(Qt::Orientation orientation, bool animate=true);
3
c863538fcbb6 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
    72
17
hgs
parents: 6
diff changeset
    73
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
hgs
parents: 6
diff changeset
    74
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
hgs
parents: 6
diff changeset
    75
    void gestureEvent(QGestureEvent* event);
hgs
parents: 6
diff changeset
    76
    bool event(QEvent *e);
hgs
parents: 6
diff changeset
    77
    
hgs
parents: 6
diff changeset
    78
    void handlePinchEnd();
hgs
parents: 6
diff changeset
    79
    void handlePinchUpdate(HbPinchGesture* pinch);    
hgs
parents: 6
diff changeset
    80
20
hgs
parents: 17
diff changeset
    81
    void updateReflections(bool enable, int start, int end);
hgs
parents: 17
diff changeset
    82
hgs
parents: 17
diff changeset
    83
    virtual void addItems(int start, int end);
hgs
parents: 17
diff changeset
    84
    virtual void removeItems(int start, int end);
hgs
parents: 17
diff changeset
    85
    virtual void moveItems(int start, int end, int destination);
hgs
parents: 17
diff changeset
    86
    
17
hgs
parents: 6
diff changeset
    87
public slots:
hgs
parents: 6
diff changeset
    88
    
hgs
parents: 6
diff changeset
    89
    void effectFinished();
hgs
parents: 6
diff changeset
    90
    
3
c863538fcbb6 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
    91
private:    
c863538fcbb6 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
    92
    
c863538fcbb6 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
    93
    bool mEffect3dEnabled;
17
hgs
parents: 6
diff changeset
    94
    bool mPinchEnabled;
hgs
parents: 6
diff changeset
    95
    bool mPinchingOngoing;
hgs
parents: 6
diff changeset
    96
    int mTempImageHeightForLineGrid;    //this is changed during pinching
hgs
parents: 6
diff changeset
    97
    int mTempImageHeightFinal;          //this is changed during pinching
hgs
parents: 6
diff changeset
    98
    int mTempRowCount;                  //this is changed during pinching
hgs
parents: 6
diff changeset
    99
    int mTargetRowCount;
hgs
parents: 6
diff changeset
   100
    QQueue<qreal> iTargetRowCountList;
hgs
parents: 6
diff changeset
   101
    QSizeF mTargetImageSize;
hgs
parents: 6
diff changeset
   102
    bool mPinchEndAlreadyHandled;
hgs
parents: 6
diff changeset
   103
    bool mReactToOnlyPanGestures;
hgs
parents: 6
diff changeset
   104
    QPropertyAnimation iFadeAnimation;
hgs
parents: 6
diff changeset
   105
    int mHorizontalRowCount;
hgs
parents: 6
diff changeset
   106
    int mVerticalColumnCount;
hgs
parents: 6
diff changeset
   107
    QPair<int,int> mHorizontalPinchLevels;
hgs
parents: 6
diff changeset
   108
    QPair<int,int> mVerticalPinchLevels;
0
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
};
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
89c329efa980 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
#endif