ui/views/fullscreenview/src/glxcoverflow.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:
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
74c9f037fd5d Revision: 201007
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".
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:   ?Description
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
//Includes
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <hbiconitem.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <QAbstractItemModel>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <QGraphicsSceneMouseEvent>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <QDebug>
40
hgs
parents: 26
diff changeset
    24
#include <QGesture>
hgs
parents: 26
diff changeset
    25
#include <hbpangesture.h>
45
hgs
parents: 44
diff changeset
    26
#include <hbiconanimator.h>
50
hgs
parents: 45
diff changeset
    27
#include <hbinstance.h>
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
//User Includes
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include <glxmodelparm.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include <glxcoverflow.h>
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    32
#include "glxviewids.h"
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
43
hgs
parents: 42
diff changeset
    34
#define GLX_COVERFLOW_SPEED  32
hgs
parents: 42
diff changeset
    35
#define GLX_BOUNCEBACK_SPEED 16
hgs
parents: 42
diff changeset
    36
#define GLX_BOUNCEBACK_DELTA 8
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
52
hgs
parents: 50
diff changeset
    38
GlxCoverFlow::GlxCoverFlow( QGraphicsItem *parent ) 
hgs
parents: 50
diff changeset
    39
     : HbWidget( parent ), 
hgs
parents: 50
diff changeset
    40
       mSelItemIndex ( 0 ),
hgs
parents: 50
diff changeset
    41
       mRows( 0 ),
hgs
parents: 50
diff changeset
    42
       mSelIndex ( 0 ),
hgs
parents: 50
diff changeset
    43
       mStripLen ( 0 ),
hgs
parents: 50
diff changeset
    44
       mCurrentPos( 0 ),
hgs
parents: 50
diff changeset
    45
       mItemSize ( QSize( 0, 0 ) ),
hgs
parents: 50
diff changeset
    46
       mModel ( NULL ),
hgs
parents: 50
diff changeset
    47
       mMoveDir( NO_MOVE ),
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    48
       mSpeed ( GLX_COVERFLOW_SPEED ),
52
hgs
parents: 50
diff changeset
    49
	   mZoomOn( false ),
hgs
parents: 50
diff changeset
    50
	   mMultitouchFilter( NULL ),
hgs
parents: 50
diff changeset
    51
       mTimerId( 0 ),
hgs
parents: 50
diff changeset
    52
       mIsInit( false )
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
{
52
hgs
parents: 50
diff changeset
    54
   qDebug( "GlxCoverFlow::GlxCoverFlow" );
hgs
parents: 50
diff changeset
    55
   grabGesture( Qt::PanGesture );
hgs
parents: 50
diff changeset
    56
   grabGesture( Qt::TapGesture );
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    57
   connect( this, SIGNAL( autoLeftMoveSignal() ), this, SLOT( autoLeftMove() ), Qt::QueuedConnection );
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    58
   connect( this, SIGNAL( autoRightMoveSignal() ), this, SLOT( autoRightMove() ), Qt::QueuedConnection );   
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    61
void GlxCoverFlow::setMultitouchFilter(QGraphicsItem* mtFilter)
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    62
{
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    63
	mMultitouchFilter = mtFilter;
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    64
}
52
hgs
parents: 50
diff changeset
    65
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
void GlxCoverFlow::setCoverFlow()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
    qDebug("GlxCoverFlow::setCoverFlow");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
    for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) {
44
hgs
parents: 43
diff changeset
    70
        mIconItem[i] = new HbIconItem( this );
hgs
parents: 43
diff changeset
    71
        mIconItem[i]->grabGesture( Qt::PinchGesture, Qt::ReceivePartialGestures );
hgs
parents: 43
diff changeset
    72
        mIconItem[i]->installSceneEventFilter( mMultitouchFilter );
hgs
parents: 43
diff changeset
    73
        mIconItem[i]->setBrush( QBrush( Qt::black ) );
hgs
parents: 43
diff changeset
    74
        mIconItem[i]->setSize( QSize( 0, 0 ) );
hgs
parents: 43
diff changeset
    75
        mIconItem[i]->setAlignment( Qt::AlignCenter );
45
hgs
parents: 44
diff changeset
    76
        mIconItem[i]->setObjectName( QString( "Cover%1" ).arg( i ) );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
    }
45
hgs
parents: 44
diff changeset
    78
    
52
hgs
parents: 50
diff changeset
    79
    mIsInit = true;
hgs
parents: 50
diff changeset
    80
    mUiOn = false;
43
hgs
parents: 42
diff changeset
    81
    mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
void GlxCoverFlow::setItemSize(QSize &size)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
    qDebug("GlxCoverFlow::setSize width = %d",size.width() );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
    if( mItemSize != size) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
        mItemSize = size;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
        resetCoverFlow();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
    }    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
void GlxCoverFlow::setModel(QAbstractItemModel *model)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
    qDebug("GlxCoverFlow::setModel model change = %d", model  );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
    
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    97
    if ( model == mModel) {
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
        return ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
    clearCurrentModel();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
    mModel = model;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
    initializeNewModel();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
    resetCoverFlow();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
void GlxCoverFlow::indexChanged( int index )
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
    qDebug("GlxCoverFlow::indexChanged index = %d mSelIndex = %d ",index, mSelIndex );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
    if ( index != mSelIndex && mModel) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
        loadIconItems();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
40
hgs
parents: 26
diff changeset
   115
void GlxCoverFlow::gestureEvent(QGestureEvent *event)
hgs
parents: 26
diff changeset
   116
{    
43
hgs
parents: 42
diff changeset
   117
    if(QTapGesture *gesture = static_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) {        
40
hgs
parents: 26
diff changeset
   118
        if (gesture->state() == Qt::GestureFinished) {
44
hgs
parents: 43
diff changeset
   119
            if(!mTimerId) {
hgs
parents: 43
diff changeset
   120
                mTimerId = startTimer(500);
hgs
parents: 43
diff changeset
   121
            }
hgs
parents: 43
diff changeset
   122
            else {
hgs
parents: 43
diff changeset
   123
                killTimer(mTimerId);
hgs
parents: 43
diff changeset
   124
                mTimerId = 0;
50
hgs
parents: 45
diff changeset
   125
                emit doubleTapEventReceived(hbInstance->allMainWindows().first()->mapToScene(gesture->position().toPoint()));
44
hgs
parents: 43
diff changeset
   126
            }
43
hgs
parents: 42
diff changeset
   127
            event->accept(gesture);
hgs
parents: 42
diff changeset
   128
        }
hgs
parents: 42
diff changeset
   129
    }
hgs
parents: 42
diff changeset
   130
  
hgs
parents: 42
diff changeset
   131
    if (QPanGesture *panningGesture = qobject_cast<QPanGesture*>(event->gesture(Qt::PanGesture))) {
hgs
parents: 42
diff changeset
   132
        HbPanGesture *hbPanGesture = qobject_cast<HbPanGesture *>(panningGesture);
hgs
parents: 42
diff changeset
   133
        if (hbPanGesture) {
hgs
parents: 42
diff changeset
   134
            if(hbPanGesture->state() == Qt::GestureUpdated) {
hgs
parents: 42
diff changeset
   135
                QPointF delta(hbPanGesture->sceneDelta());
hgs
parents: 42
diff changeset
   136
                panGesture(delta);
hgs
parents: 42
diff changeset
   137
                event->accept(panningGesture);            
hgs
parents: 42
diff changeset
   138
            }
hgs
parents: 42
diff changeset
   139
            
hgs
parents: 42
diff changeset
   140
            if(hbPanGesture->state() == Qt::GestureFinished) {
hgs
parents: 42
diff changeset
   141
                switch( mMoveDir ) {
hgs
parents: 42
diff changeset
   142
                    case LEFT_MOVE : 
hgs
parents: 42
diff changeset
   143
                        mMoveDir = NO_MOVE;
hgs
parents: 42
diff changeset
   144
                        mBounceBackDeltaX = ( mItemSize.width() >> 2 )  + ( mItemSize.width() >> 3 );
hgs
parents: 42
diff changeset
   145
                        emit autoLeftMoveSignal();
hgs
parents: 42
diff changeset
   146
                        break ;
hgs
parents: 42
diff changeset
   147
                
hgs
parents: 42
diff changeset
   148
                    case RIGHT_MOVE :
hgs
parents: 42
diff changeset
   149
                        mMoveDir = NO_MOVE;
hgs
parents: 42
diff changeset
   150
                        mBounceBackDeltaX = ( mItemSize.width() >> 2 )  + ( mItemSize.width() >> 3 );
hgs
parents: 42
diff changeset
   151
                        emit autoRightMoveSignal();
hgs
parents: 42
diff changeset
   152
                        break;
hgs
parents: 42
diff changeset
   153
                
hgs
parents: 42
diff changeset
   154
                    default:
hgs
parents: 42
diff changeset
   155
                        break;
hgs
parents: 42
diff changeset
   156
                } 
hgs
parents: 42
diff changeset
   157
                event->accept(panningGesture);
40
hgs
parents: 26
diff changeset
   158
            }
hgs
parents: 26
diff changeset
   159
        }
43
hgs
parents: 42
diff changeset
   160
    }  
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
void GlxCoverFlow::panGesture ( const QPointF & delta )  
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
    qDebug("GlxCoverFlow::panGesture deltaX= %d", (int)delta.x());  
52
hgs
parents: 50
diff changeset
   166
   
hgs
parents: 50
diff changeset
   167
    if( !mIsInit || getSubState() == IMAGEVIEWER_S || getSubState() == FETCHER_S ) {
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   168
        return;
40
hgs
parents: 26
diff changeset
   169
    }
52
hgs
parents: 50
diff changeset
   170
    move( ( int ) delta.x() );    
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
    if( delta.x() > 0 ) {     
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
        mMoveDir = RIGHT_MOVE;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
    else if ( delta.x() < 0) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
        mMoveDir = LEFT_MOVE;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
    if ( mUiOn == TRUE  ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
        emit coverFlowEvent( PANNING_START_EVENT );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
        mUiOn = FALSE;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
void GlxCoverFlow::longPressGesture(const QPointF &point)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
     qDebug("GlxCoverFlow::longPressGesture x = %d  y = %d", point.x(), point.y());
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
     mMoveDir = LONGPRESS_MOVE;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
void GlxCoverFlow::dataChanged(QModelIndex startIndex, QModelIndex endIndex)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
    Q_UNUSED(endIndex);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
    qDebug("GlxCoverFlow::dataChanged startIndex = %d mSelIndex = %d ", startIndex.row(), mSelIndex  );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
    int index = 0;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
    for (int i = 0; i < NBR_ICON_ITEM ; i++) {
45
hgs
parents: 44
diff changeset
   197
        index = calculateIndex( mSelIndex + i - 2 );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
        if ( index == startIndex.row() ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
            index = ( mSelItemIndex + i - 2 + NBR_ICON_ITEM ) % NBR_ICON_ITEM;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
            qDebug("GlxCoverFlow::dataChanged index = %d mSelItemIndex = %d ", index, mSelItemIndex );
45
hgs
parents: 44
diff changeset
   201
            mIconItem[ index ]->setIcon( getIcon( startIndex.row() ) );
hgs
parents: 44
diff changeset
   202
            if ( index == mSelItemIndex ) {
hgs
parents: 44
diff changeset
   203
                playAnimation( );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
            }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
        }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
void GlxCoverFlow::rowsInserted(const QModelIndex &parent, int start, int end)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
    qDebug("GlxCoverFlow::rowsInserted");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
    Q_UNUSED(parent);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
    Q_UNUSED(start);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
    Q_UNUSED(end);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
    resetCoverFlow();  
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
    emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
void GlxCoverFlow::rowsRemoved(const QModelIndex &parent, int start, int end)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
    Q_UNUSED(parent);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
    Q_UNUSED(start);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
    Q_UNUSED(end);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
    qDebug("GlxCoverFlow::rowsRemoved model %d", mModel);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
    if ( mModel->rowCount() <= 0 ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
        emit coverFlowEvent( EMPTY_ROW_EVENT );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
    else {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
        resetCoverFlow();   
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
        emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
45
hgs
parents: 44
diff changeset
   235
void GlxCoverFlow::modelDestroyed()
hgs
parents: 44
diff changeset
   236
{
hgs
parents: 44
diff changeset
   237
    mModel = NULL ;    
hgs
parents: 44
diff changeset
   238
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
void GlxCoverFlow::autoLeftMove()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
    int width = mItemSize.width() ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
    qDebug("GlxCoverFlow::autoLeftMove current pos = %d mBounceBackDeltaX x = %d", mCurrentPos, mBounceBackDeltaX);
52
hgs
parents: 50
diff changeset
   245
    if ( !mIsInit ) {
hgs
parents: 50
diff changeset
   246
        return;
hgs
parents: 50
diff changeset
   247
    }
40
hgs
parents: 26
diff changeset
   248
    
52
hgs
parents: 50
diff changeset
   249
    if ( mSelIndex == ( mRows -1 ) ) {
40
hgs
parents: 26
diff changeset
   250
        mSpeed = GLX_BOUNCEBACK_SPEED;
hgs
parents: 26
diff changeset
   251
    }
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
    //for bounce back effect for last image ( it will do the back)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
    if ( ( mCurrentPos + width ) > ( mStripLen + mBounceBackDeltaX ) && mMoveDir == NO_MOVE ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
        mMoveDir = LEFT_MOVE;
43
hgs
parents: 42
diff changeset
   255
        mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
        autoRightMoveSignal();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
        return ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
    int deltaX = width - mCurrentPos %  width ; 
40
hgs
parents: 26
diff changeset
   261
    int moveX = deltaX > mSpeed ? mSpeed : deltaX;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
    qDebug("GlxCoverFlow::autoLeftMove delta x = %d current pos = %d move x = %d", deltaX, mCurrentPos, moveX);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
    move (-moveX);//move the image
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
    deltaX -= moveX; //To know the auto move is required or not
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
    if ( deltaX ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
        emit autoLeftMoveSignal();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
    else {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
        //for bounce back of first image
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
        if ( mMoveDir == RIGHT_MOVE ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
            emit autoRightMoveSignal();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
            return;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
        }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
        int selIndex = mCurrentPos / width ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
        if ( mRows == 1 || selIndex != mSelIndex ) {
45
hgs
parents: 44
diff changeset
   279
            stopAnimation();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
            mSelIndex = selIndex;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
            mSelItemIndex = ( ++mSelItemIndex ) % NBR_ICON_ITEM;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
            selIndex = ( mSelItemIndex + 2 ) % NBR_ICON_ITEM;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
            updateIconItem( mSelIndex + 2, selIndex, width * 2 ) ;
45
hgs
parents: 44
diff changeset
   284
            playAnimation();
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   285
			if(!mZoomOn) {
45
hgs
parents: 44
diff changeset
   286
                emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ;
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   287
			}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
        }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
        mMoveDir = NO_MOVE;
43
hgs
parents: 42
diff changeset
   290
        mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA;
40
hgs
parents: 26
diff changeset
   291
        mSpeed = GLX_COVERFLOW_SPEED;
hgs
parents: 26
diff changeset
   292
    }   
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
void GlxCoverFlow::autoRightMove()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
    qDebug("GlxCoverFlow::autoRightMove ");
52
hgs
parents: 50
diff changeset
   298
    if ( !mIsInit ) {
hgs
parents: 50
diff changeset
   299
        return;
hgs
parents: 50
diff changeset
   300
    }
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
    int width = mItemSize.width()  ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
    int diffX = mStripLen - mCurrentPos ;
52
hgs
parents: 50
diff changeset
   303
 
40
hgs
parents: 26
diff changeset
   304
    //slow the speed for bounce back effect
hgs
parents: 26
diff changeset
   305
    if ( mSelIndex == 0 ) {
hgs
parents: 26
diff changeset
   306
        mSpeed = GLX_BOUNCEBACK_SPEED;
hgs
parents: 26
diff changeset
   307
    }
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
    //for bounce back effect for back image ( it will do the back)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
    qDebug("GlxCoverFlow::autoRightMove diffX x = %d current pos = %d mBounceBackDeltaX x = %d", diffX, mCurrentPos, mBounceBackDeltaX);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
    if ( diffX > mBounceBackDeltaX && diffX < width && mMoveDir == NO_MOVE ){
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
        mMoveDir = RIGHT_MOVE;
43
hgs
parents: 42
diff changeset
   312
        mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA;
40
hgs
parents: 26
diff changeset
   313
        autoLeftMoveSignal();  
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
        return ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
    
40
hgs
parents: 26
diff changeset
   317
    int deltaX = mCurrentPos %  width ; 
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
    //in the case of deltaX == 0 ( right flick case ) complete image should move
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
    deltaX = deltaX ? deltaX : width ; 
40
hgs
parents: 26
diff changeset
   320
    int moveX = deltaX > mSpeed ? mSpeed : deltaX;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
    qDebug("GlxCoverFlow::autoRightMove delta x = %d current pos = %d move x = %d", deltaX, mCurrentPos, moveX);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
    move (moveX);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
    deltaX -= moveX;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
    if ( deltaX ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
        emit autoRightMoveSignal();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
    else {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
        //for bounce back of last image
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
        if ( mMoveDir == LEFT_MOVE ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
            emit autoLeftMoveSignal();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
            return;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
        }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
        int selIndex = mCurrentPos / width ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
        if ( mRows == 1 || selIndex != mSelIndex ) {
45
hgs
parents: 44
diff changeset
   338
            stopAnimation();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
            mSelIndex = selIndex;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
            mSelItemIndex = ( mSelItemIndex == 0 ) ?  NBR_ICON_ITEM -1 : --mSelItemIndex;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
            selIndex = ( mSelItemIndex + 3 ) % NBR_ICON_ITEM;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
            updateIconItem( mSelIndex - 2, selIndex, - width * 2 ) ;
45
hgs
parents: 44
diff changeset
   343
            playAnimation();
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   344
			if(!mZoomOn) {
45
hgs
parents: 44
diff changeset
   345
                emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ;
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   346
			}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
        }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
        mMoveDir = NO_MOVE;
43
hgs
parents: 42
diff changeset
   349
        mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA;
40
hgs
parents: 26
diff changeset
   350
        mSpeed = GLX_COVERFLOW_SPEED;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
void GlxCoverFlow::move(int value)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
    qDebug("GlxCoverFlow::move ");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
    QPointF pos(0,0);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
    for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
        pos.setX( mIconItem[i]->pos().x() + value);
40
hgs
parents: 26
diff changeset
   361
        pos.setY(mIconItem[i]->pos().y());
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
        mIconItem[i]->setPos(pos);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
    mCurrentPos -= value;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
    if ( mCurrentPos < 0 ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
        mCurrentPos += mStripLen;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
    else if ( mCurrentPos >= mStripLen ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
        mCurrentPos -= mStripLen;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
    qDebug("GlxCoverFlow::Move value = %d current pos = %d", value, mCurrentPos); 
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
void GlxCoverFlow::setRows()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
    qDebug("GlxCoverFlow::setRows ");
40
hgs
parents: 26
diff changeset
   378
    if (mModel) {
hgs
parents: 26
diff changeset
   379
        mRows = mModel->rowCount();
hgs
parents: 26
diff changeset
   380
    }
hgs
parents: 26
diff changeset
   381
    else {
hgs
parents: 26
diff changeset
   382
        mRows = 0;
hgs
parents: 26
diff changeset
   383
    }
hgs
parents: 26
diff changeset
   384
    qDebug("GlxCoverFlow::setRows number of rows = %d", mRows);
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
void GlxCoverFlow::setStripLen()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
{  
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
    qDebug("GlxCoverFlow::setStripLen ");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
    mStripLen = mRows * mItemSize.width();  
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
    qDebug("GlxCoverFlow::setStripLen rows = %d, striplen %d", mRows, mStripLen);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
int GlxCoverFlow::calculateIndex(int index)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
    qDebug("GlxCoverFlow::calculateIndex index = %d, mRows = %d", index, mRows);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
    if ( mRows == 1 )
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
        return 0;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
    if ( index < 0 ) 
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
        return ( index + mRows );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
   
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
    if ( index >= mRows ) 
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
        return ( index - mRows ) ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
    return index;        
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
void GlxCoverFlow::loadIconItems()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
{  
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
    qDebug("GlxCoverFlow::loadIconItems ");
52
hgs
parents: 50
diff changeset
   413
    
hgs
parents: 50
diff changeset
   414
    if ( !mIsInit ) {
hgs
parents: 50
diff changeset
   415
        return ;
hgs
parents: 50
diff changeset
   416
    }
hgs
parents: 50
diff changeset
   417
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
    int index = 0;
45
hgs
parents: 44
diff changeset
   419
    stopAnimation();
hgs
parents: 44
diff changeset
   420
    mSelIndex = getFocusIndex();
hgs
parents: 44
diff changeset
   421
    
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
    qDebug("GlxCoverFlow::loadIconItems index = %d, width = %d", mSelIndex, size().width() );    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
    for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) {
45
hgs
parents: 44
diff changeset
   425
        index = calculateIndex ( mSelIndex - 2 + i) ; 
hgs
parents: 44
diff changeset
   426
        mIconItem[i]->setIcon( getIcon( index ) );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
        mIconItem[i]->setSize ( mItemSize );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
        mIconItem[i]->setPos ( QPointF ( (i - 2) * mItemSize.width(), 0) );   
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
    mSelItemIndex = 2;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
    mCurrentPos = mItemSize.width() * mSelIndex;
45
hgs
parents: 44
diff changeset
   433
    playAnimation();
hgs
parents: 44
diff changeset
   434
}
hgs
parents: 44
diff changeset
   435
hgs
parents: 44
diff changeset
   436
void GlxCoverFlow::playAnimation()
hgs
parents: 44
diff changeset
   437
{
hgs
parents: 44
diff changeset
   438
    if ( isAnimatedImage( mSelIndex ) ) {
hgs
parents: 44
diff changeset
   439
        mIconItem[ mSelItemIndex ]->setIcon( HbIcon( getUri( mSelIndex ) ) );
hgs
parents: 44
diff changeset
   440
        mIconItem[ mSelItemIndex ]->animator().startAnimation();
hgs
parents: 44
diff changeset
   441
    }
hgs
parents: 44
diff changeset
   442
}
hgs
parents: 44
diff changeset
   443
hgs
parents: 44
diff changeset
   444
void GlxCoverFlow::stopAnimation()
hgs
parents: 44
diff changeset
   445
{
hgs
parents: 44
diff changeset
   446
    mIconItem[ mSelItemIndex ]->animator().stopAnimation();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
void GlxCoverFlow::updateIconItem (qint16 selIndex, qint16 selItemIndex, qint16 posX)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
    qDebug("GlxCoverFlow::updateIconItem selIndex = %d, selIconIndex = %d posX = %d", selIndex, selItemIndex, posX );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
    selIndex = calculateIndex( selIndex );
45
hgs
parents: 44
diff changeset
   454
    mIconItem[ selItemIndex ]->setPos( QPointF( posX, 0 ) );    
hgs
parents: 44
diff changeset
   455
    mIconItem[ selItemIndex ]->setIcon( getIcon( selIndex ) );
hgs
parents: 44
diff changeset
   456
    mIconItem[ selItemIndex ]->setSize ( mItemSize );    
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
void GlxCoverFlow::clearCurrentModel()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
    qDebug("GlxCoverFlow::clearCurrentModel ");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
    if ( mModel ) {
45
hgs
parents: 44
diff changeset
   463
        disconnect( mModel, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ), this, SLOT( dataChanged( QModelIndex, QModelIndex ) ) );
hgs
parents: 44
diff changeset
   464
        disconnect( mModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( rowsInserted( QModelIndex, int, int ) ) );
hgs
parents: 44
diff changeset
   465
        disconnect( mModel, SIGNAL( rowsRemoved( QModelIndex, int, int) ), this, SLOT( rowsRemoved( QModelIndex, int, int ) ) );
hgs
parents: 44
diff changeset
   466
        disconnect( mModel, SIGNAL( destroyed() ), this, SLOT( modelDestroyed() ) );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
        mModel = NULL ;
45
hgs
parents: 44
diff changeset
   468
    } 
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   469
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   471
void GlxCoverFlow::initializeNewModel()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
    qDebug("GlxCoverFlow::initializeNewModel" );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
    if ( mModel ) {
45
hgs
parents: 44
diff changeset
   475
        connect( mModel, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ), this, SLOT( dataChanged( QModelIndex, QModelIndex ) ) );
hgs
parents: 44
diff changeset
   476
        connect( mModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( rowsInserted( QModelIndex, int, int ) ) );
hgs
parents: 44
diff changeset
   477
        connect( mModel, SIGNAL( rowsRemoved( QModelIndex, int, int) ), this, SLOT( rowsRemoved( QModelIndex, int, int ) ) );
hgs
parents: 44
diff changeset
   478
        connect( mModel, SIGNAL( destroyed() ), this, SLOT( modelDestroyed() ) );
hgs
parents: 44
diff changeset
   479
    } 
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
void GlxCoverFlow::resetCoverFlow()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
    qDebug("GlxCoverFlow::resetCoverFlow model %u", mModel );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
    setRows();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
    setStripLen();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
    if ( mModel ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
        loadIconItems( ) ;  
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
void GlxCoverFlow::partiallyClean()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
    qDebug("GlxCoverFlow::partiallyClean Enter");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
    clearCurrentModel(); //during the animation data update will not cause the crash
52
hgs
parents: 50
diff changeset
   496
    mIsInit = false;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
    for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
        if ( mSelItemIndex != i){
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
            delete mIconItem[i] ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   500
            mIconItem[i] = NULL;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   501
        }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
    }      
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
50
hgs
parents: 45
diff changeset
   505
void GlxCoverFlow::partiallyCreate( QAbstractItemModel *model, QSize itemSize, int posY )
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
{
50
hgs
parents: 45
diff changeset
   507
    qDebug("GlxCoverFlow::resetpartiallyCreated poxY %d", posY );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
    mIconItem[2]->setSize ( itemSize );
50
hgs
parents: 45
diff changeset
   509
    mIconItem[2]->setPos ( QPointF ( 0, posY ) ); 
45
hgs
parents: 44
diff changeset
   510
    mModel = model ; 
hgs
parents: 44
diff changeset
   511
    mSelIndex = getFocusIndex();
hgs
parents: 44
diff changeset
   512
    mIconItem[2]->setIcon( getIcon( mSelIndex ) ) ;
hgs
parents: 44
diff changeset
   513
    mModel = NULL;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
GlxCoverFlow::~GlxCoverFlow()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
    qDebug("GlxCoverFlow::~GlxCoverFlow model " );
45
hgs
parents: 44
diff changeset
   519
    ClearCoverFlow();
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   520
    disconnect( this, SIGNAL( autoLeftMoveSignal() ), this, SLOT( autoLeftMove() ) );
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   521
    disconnect( this, SIGNAL( autoRightMoveSignal() ), this, SLOT( autoRightMove() ) );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
void GlxCoverFlow::ClearCoverFlow()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
    qDebug("GlxCoverFlow::ClearCoverFlow  " );
52
hgs
parents: 50
diff changeset
   527
    mIsInit = false;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
    clearCurrentModel();    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
    for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) {
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   530
        if(mIconItem[i] != NULL ) {
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   531
            delete mIconItem[i] ;
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   532
            mIconItem[i] = NULL;
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   533
        }
40
hgs
parents: 26
diff changeset
   534
    }   
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
}
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   536
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   537
int GlxCoverFlow::getSubState()
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   538
{
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   539
    int substate = NO_FULLSCREEN_S;
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   540
    QVariant variant = mModel->data( mModel->index(0,0), GlxSubStateRole );    
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   541
    if ( variant.isValid() &&  variant.canConvert<int> ()  ) {
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   542
        substate = variant.value<int>();
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   543
    }
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   544
    return substate;
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   545
}
43
hgs
parents: 42
diff changeset
   546
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   547
void GlxCoverFlow::zoomStarted(int index)
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   548
{
43
hgs
parents: 42
diff changeset
   549
    Q_UNUSED(index)
50
hgs
parents: 45
diff changeset
   550
    emit coverFlowEvent( ZOOM_START_EVENT );
45
hgs
parents: 44
diff changeset
   551
    stopAnimation();
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   552
	mZoomOn = true;	
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   553
}
43
hgs
parents: 42
diff changeset
   554
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   555
void GlxCoverFlow::zoomFinished(int index)
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   556
{ 
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   557
	mZoomOn = false;
45
hgs
parents: 44
diff changeset
   558
	playAnimation();
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   559
	indexChanged(index);
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   560
}
44
hgs
parents: 43
diff changeset
   561
hgs
parents: 43
diff changeset
   562
void GlxCoverFlow::timerEvent(QTimerEvent *event)
hgs
parents: 43
diff changeset
   563
{
hgs
parents: 43
diff changeset
   564
    if(mTimerId == event->timerId())
hgs
parents: 43
diff changeset
   565
    {
hgs
parents: 43
diff changeset
   566
        killTimer(mTimerId);
hgs
parents: 43
diff changeset
   567
        mTimerId = 0;
hgs
parents: 43
diff changeset
   568
        emit coverFlowEvent( TAP_EVENT );
hgs
parents: 43
diff changeset
   569
    }
45
hgs
parents: 44
diff changeset
   570
}
hgs
parents: 44
diff changeset
   571
hgs
parents: 44
diff changeset
   572
int GlxCoverFlow::getFocusIndex( )
hgs
parents: 44
diff changeset
   573
{
hgs
parents: 44
diff changeset
   574
    QVariant variant = mModel->data( mModel->index( 0, 0 ), GlxFocusIndexRole ) ;
hgs
parents: 44
diff changeset
   575
    if ( variant.isValid() && variant.canConvert< int > () ) {
hgs
parents: 44
diff changeset
   576
        return variant.value< int > ();
hgs
parents: 44
diff changeset
   577
    }
hgs
parents: 44
diff changeset
   578
    return -1;
hgs
parents: 44
diff changeset
   579
}
hgs
parents: 44
diff changeset
   580
hgs
parents: 44
diff changeset
   581
HbIcon GlxCoverFlow::getIcon( int index )
hgs
parents: 44
diff changeset
   582
{
hgs
parents: 44
diff changeset
   583
    QVariant variant = mModel->data( mModel->index( index, 0 ), GlxFsImageRole );
hgs
parents: 44
diff changeset
   584
    if ( variant.isValid() &&  variant.canConvert< HbIcon > () ) {
hgs
parents: 44
diff changeset
   585
        return variant.value<HbIcon> () ;       
hgs
parents: 44
diff changeset
   586
    }
hgs
parents: 44
diff changeset
   587
    return HbIcon() ;
hgs
parents: 44
diff changeset
   588
}
hgs
parents: 44
diff changeset
   589
hgs
parents: 44
diff changeset
   590
QString GlxCoverFlow::getUri( int index )
hgs
parents: 44
diff changeset
   591
{
hgs
parents: 44
diff changeset
   592
    QVariant variant = mModel->data( mModel->index( index, 0 ), GlxUriRole );
hgs
parents: 44
diff changeset
   593
    if ( variant.isValid() && variant.canConvert< QString > () ){
hgs
parents: 44
diff changeset
   594
        return variant.value< QString > () ;
hgs
parents: 44
diff changeset
   595
    }
hgs
parents: 44
diff changeset
   596
    return QString();
hgs
parents: 44
diff changeset
   597
}
hgs
parents: 44
diff changeset
   598
hgs
parents: 44
diff changeset
   599
bool GlxCoverFlow::isAnimatedImage( int index )
hgs
parents: 44
diff changeset
   600
{
hgs
parents: 44
diff changeset
   601
    int frameCount = 0;
hgs
parents: 44
diff changeset
   602
    QVariant variant = mModel->data( mModel->index( index, 0 ), GlxFrameCount );
hgs
parents: 44
diff changeset
   603
    if ( variant.isValid() && variant.canConvert< int > () ) {
hgs
parents: 44
diff changeset
   604
         frameCount = variant.value< int > () ;
hgs
parents: 44
diff changeset
   605
    }
hgs
parents: 44
diff changeset
   606
    return frameCount > 1 ? true : false ;
hgs
parents: 44
diff changeset
   607
}