ui/views/fullscreenview/src/glxcoverflow.cpp
changeset 58 383b67fbdb11
parent 54 0f0f3f26f787
child 62 36d93b4dc635
--- a/ui/views/fullscreenview/src/glxcoverflow.cpp	Fri Aug 06 20:44:25 2010 +0530
+++ b/ui/views/fullscreenview/src/glxcoverflow.cpp	Mon Aug 23 18:06:16 2010 +0530
@@ -51,11 +51,14 @@
        mTimerId( 0 ),
        mIsInit( false )
 {
-   qDebug( "GlxCoverFlow::GlxCoverFlow" );
-   grabGesture( Qt::PanGesture );
-   grabGesture( Qt::TapGesture );
-   connect( this, SIGNAL( autoLeftMoveSignal() ), this, SLOT( autoLeftMove() ), Qt::QueuedConnection );
-   connect( this, SIGNAL( autoRightMoveSignal() ), this, SLOT( autoRightMove() ), Qt::QueuedConnection );   
+    qDebug( "GlxCoverFlow::GlxCoverFlow" );
+    mIsAutoMoving = FALSE;
+    grabGesture( Qt::PanGesture );
+    grabGesture( Qt::TapGesture );
+    connect( this, SIGNAL( autoLeftMoveSignal() ), this, SLOT( autoLeftMove() ), Qt::QueuedConnection );
+    connect( this, SIGNAL( autoRightMoveSignal() ), this, SLOT( autoRightMove() ), Qt::QueuedConnection );
+    connect( this, SIGNAL( moveNextSignal() ), this, SLOT( moveNextImage() ), Qt::QueuedConnection );
+    connect( this, SIGNAL( movePreviousSignal() ), this, SLOT( movePreviousImage() ), Qt::QueuedConnection ); 
 }
 
 void GlxCoverFlow::setMultitouchFilter(QGraphicsItem* mtFilter)
@@ -117,7 +120,7 @@
     if(QTapGesture *gesture = static_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) {        
         if (gesture->state() == Qt::GestureFinished) {
             if(!mTimerId) {
-                mTimerId = startTimer(500);
+                mTimerId = startTimer( DOUBLETAP_TIMEINTERVAL );
             }
             else {
                 killTimer(mTimerId);
@@ -137,23 +140,27 @@
                 event->accept(panningGesture);            
             }
             
-            if(hbPanGesture->state() == Qt::GestureFinished) {
-                switch( mMoveDir ) {
-                    case LEFT_MOVE : 
-                        mMoveDir = NO_MOVE;
-                        mBounceBackDeltaX = ( mItemSize.width() >> 2 )  + ( mItemSize.width() >> 3 );
-                        emit autoLeftMoveSignal();
-                        break ;
-                
-                    case RIGHT_MOVE :
-                        mMoveDir = NO_MOVE;
-                        mBounceBackDeltaX = ( mItemSize.width() >> 2 )  + ( mItemSize.width() >> 3 );
-                        emit autoRightMoveSignal();
-                        break;
-                
-                    default:
-                        break;
-                } 
+            if( hbPanGesture->state() == Qt::GestureFinished  ) {
+                if( mIsAutoMoving == FALSE ) {
+                    switch( mMoveDir ) {
+                        case LEFT_MOVE : 
+                            mMoveDir = NO_MOVE;
+                            mBounceBackDeltaX = ( mItemSize.width() >> 2 )  + ( mItemSize.width() >> 3 );
+                            emit autoLeftMoveSignal();
+                            mIsAutoMoving = TRUE;
+                            break ;
+                    
+                        case RIGHT_MOVE :
+                            mMoveDir = NO_MOVE;
+                            mBounceBackDeltaX = ( mItemSize.width() >> 2 )  + ( mItemSize.width() >> 3 );
+                            emit autoRightMoveSignal();
+                            mIsAutoMoving = TRUE;
+                            break;
+                    
+                        default:
+                            break;
+                    } 
+                }
                 event->accept(panningGesture);
             }
         }
@@ -164,9 +171,10 @@
 {
     qDebug("GlxCoverFlow::panGesture deltaX= %d", (int)delta.x());  
    
-    if( !mIsInit || getSubState() == IMAGEVIEWER_S || getSubState() == FETCHER_S ) {
+    if( !mIsInit || getSubState() == IMAGEVIEWER_S || getSubState() == FETCHER_S || mIsAutoMoving == TRUE ) {
         return;
     }
+    
     move( ( int ) delta.x() );    
     if( delta.x() > 0 ) {     
         mMoveDir = RIGHT_MOVE;
@@ -181,12 +189,6 @@
     }
 }
 
-void GlxCoverFlow::longPressGesture(const QPointF &point)
-{
-     qDebug("GlxCoverFlow::longPressGesture x = %d  y = %d", point.x(), point.y());
-     mMoveDir = LONGPRESS_MOVE;
-}
-
 void GlxCoverFlow::dataChanged(QModelIndex startIndex, QModelIndex endIndex)
 {
     Q_UNUSED(endIndex);
@@ -272,23 +274,10 @@
         //for bounce back of first image
         if ( mMoveDir == RIGHT_MOVE ) {
             emit autoRightMoveSignal();
-            return;
         }
-        int selIndex = mCurrentPos / width ;
-        if ( mRows == 1 || selIndex != mSelIndex ) {
-            stopAnimation();
-            mSelIndex = selIndex;
-            mSelItemIndex = ( ++mSelItemIndex ) % NBR_ICON_ITEM;
-            selIndex = ( mSelItemIndex + 2 ) % NBR_ICON_ITEM;
-            updateIconItem( mSelIndex + 2, selIndex, width * 2 ) ;
-            playAnimation();
-			if(!mZoomOn) {
-                emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ;
-			}
-        }
-        mMoveDir = NO_MOVE;
-        mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA;
-        mSpeed = GLX_COVERFLOW_SPEED;
+        else {
+            emit moveNextSignal();
+        }        
     }   
 }
 
@@ -331,24 +320,53 @@
         //for bounce back of last image
         if ( mMoveDir == LEFT_MOVE ) {
             emit autoLeftMoveSignal();
-            return;
+        }
+        else {
+            emit movePreviousSignal();
+        }
+    }
+}
+
+void GlxCoverFlow::moveNextImage()
+{
+    int width = mItemSize.width() ;
+    int selIndex = mCurrentPos / width ;
+    if ( mRows == 1 || selIndex != mSelIndex ) {
+        stopAnimation() ;
+        mSelIndex = selIndex ;
+        mSelItemIndex = ( ++mSelItemIndex ) % NBR_ICON_ITEM ;
+        selIndex = ( mSelItemIndex + 2 ) % NBR_ICON_ITEM ;
+        updateIconItem( mSelIndex + 2, selIndex, width * 2 ) ;
+        playAnimation() ;
+        if( !mZoomOn ) {
+            emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ;
         }
-        int selIndex = mCurrentPos / width ;
-        if ( mRows == 1 || selIndex != mSelIndex ) {
-            stopAnimation();
-            mSelIndex = selIndex;
-            mSelItemIndex = ( mSelItemIndex == 0 ) ?  NBR_ICON_ITEM -1 : --mSelItemIndex;
-            selIndex = ( mSelItemIndex + 3 ) % NBR_ICON_ITEM;
-            updateIconItem( mSelIndex - 2, selIndex, - width * 2 ) ;
-            playAnimation();
-			if(!mZoomOn) {
-                emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ;
-			}
+    }
+    mMoveDir = NO_MOVE;
+    mIsAutoMoving = FALSE;
+    mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA ;
+    mSpeed = GLX_COVERFLOW_SPEED ;
+}
+
+void GlxCoverFlow::movePreviousImage()
+{
+    int width = mItemSize.width();
+    int selIndex = mCurrentPos / width;
+    if ( mRows == 1 || selIndex != mSelIndex ) {
+        stopAnimation();
+        mSelIndex = selIndex;
+        mSelItemIndex = ( mSelItemIndex == 0 ) ?  NBR_ICON_ITEM -1 : --mSelItemIndex;
+        selIndex = ( mSelItemIndex + 3 ) % NBR_ICON_ITEM;
+        updateIconItem( mSelIndex - 2, selIndex, - width * 2 ) ;
+        playAnimation();
+        if(!mZoomOn) {
+            emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ;
         }
-        mMoveDir = NO_MOVE;
-        mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA;
-        mSpeed = GLX_COVERFLOW_SPEED;
     }
+    mMoveDir = NO_MOVE;
+    mIsAutoMoving = FALSE;
+    mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA;
+    mSpeed = GLX_COVERFLOW_SPEED;
 }
 
 void GlxCoverFlow::move(int value)
@@ -357,9 +375,9 @@
     QPointF pos(0,0);
 
     for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) {
-        pos.setX( mIconItem[i]->pos().x() + value);
-        pos.setY(mIconItem[i]->pos().y());
-        mIconItem[i]->setPos(pos);
+        pos.setX( mIconItem[i]->pos().x() + value );
+        pos.setY( mIconItem[i]->pos().y() );
+        mIconItem[i]->setPos( pos );
     }
     
     mCurrentPos -= value;
@@ -553,24 +571,23 @@
 	mZoomOn = true;	
 }
 
-void GlxCoverFlow::zoomFinished(int index)
+void GlxCoverFlow::zoomFinished( int index )
 { 
 	mZoomOn = false;
 	playAnimation();
 	indexChanged(index);
 }
 
-void GlxCoverFlow::timerEvent(QTimerEvent *event)
+void GlxCoverFlow::timerEvent( QTimerEvent *event )
 {
-    if(mTimerId == event->timerId())
-    {
-        killTimer(mTimerId);
+    if(mTimerId == event->timerId()) {
+        killTimer( mTimerId );
         mTimerId = 0;
         emit coverFlowEvent( TAP_EVENT );
     }
 }
 
-int GlxCoverFlow::getFocusIndex( )
+int GlxCoverFlow::getFocusIndex()
 {
     QVariant variant = mModel->data( mModel->index( 0, 0 ), GlxFocusIndexRole ) ;
     if ( variant.isValid() && variant.canConvert< int > () ) {