ui/views/fullscreenview/src/glxcoverflow.cpp
changeset 43 72396548277c
parent 42 5e1df1b52eb3
child 44 aa2fa096cbfb
equal deleted inserted replaced
42:5e1df1b52eb3 43:72396548277c
    27 //User Includes
    27 //User Includes
    28 #include <glxmodelparm.h>
    28 #include <glxmodelparm.h>
    29 #include <glxcoverflow.h>
    29 #include <glxcoverflow.h>
    30 #include "glxviewids.h"
    30 #include "glxviewids.h"
    31 
    31 
    32 #define GLX_COVERFLOW_SPEED 60
    32 #define GLX_COVERFLOW_SPEED  32
    33 #define GLX_BOUNCEBACK_SPEED 15
    33 #define GLX_BOUNCEBACK_SPEED 16
       
    34 #define GLX_BOUNCEBACK_DELTA 8
    34 
    35 
    35 GlxCoverFlow::GlxCoverFlow(QGraphicsItem *parent ) 
    36 GlxCoverFlow::GlxCoverFlow(QGraphicsItem *parent ) 
    36      : HbWidget(parent), 
    37      : HbWidget(parent), 
    37        mSelItemIndex (0),
    38        mSelItemIndex (0),
    38        mRows(0),
    39        mRows(0),
    67         mIconItem[i]->installSceneEventFilter(mMultitouchFilter);
    68         mIconItem[i]->installSceneEventFilter(mMultitouchFilter);
    68         mIconItem[i]->setBrush(QBrush(Qt::black));
    69         mIconItem[i]->setBrush(QBrush(Qt::black));
    69         mIconItem[i]->setSize(QSize(0,0));
    70         mIconItem[i]->setSize(QSize(0,0));
    70     }
    71     }
    71     mUiOn = FALSE;
    72     mUiOn = FALSE;
    72     mBounceBackDeltaX = 10;
    73     mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA;
    73 }
    74 }
    74 
    75 
    75 void GlxCoverFlow::setItemSize(QSize &size)
    76 void GlxCoverFlow::setItemSize(QSize &size)
    76 {
    77 {
    77     qDebug("GlxCoverFlow::setSize width = %d",size.width() );
    78     qDebug("GlxCoverFlow::setSize width = %d",size.width() );
   103     }
   104     }
   104 }
   105 }
   105 
   106 
   106 void GlxCoverFlow::gestureEvent(QGestureEvent *event)
   107 void GlxCoverFlow::gestureEvent(QGestureEvent *event)
   107 {    
   108 {    
   108  if(QTapGesture *gesture = static_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) {        
   109     if(QTapGesture *gesture = static_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) {        
   109         if (gesture->state() == Qt::GestureFinished) {
   110         if (gesture->state() == Qt::GestureFinished) {
   110                      emit coverFlowEvent( TAP_EVENT );
   111             emit coverFlowEvent( TAP_EVENT );
   111                       event->accept(gesture);
   112             event->accept(gesture);
       
   113         }
       
   114     }
       
   115   
       
   116     if (QPanGesture *panningGesture = qobject_cast<QPanGesture*>(event->gesture(Qt::PanGesture))) {
       
   117         HbPanGesture *hbPanGesture = qobject_cast<HbPanGesture *>(panningGesture);
       
   118         if (hbPanGesture) {
       
   119             if(hbPanGesture->state() == Qt::GestureUpdated) {
       
   120                 QPointF delta(hbPanGesture->sceneDelta());
       
   121                 panGesture(delta);
       
   122                 event->accept(panningGesture);            
   112             }
   123             }
   113         }
   124             
   114   
   125             if(hbPanGesture->state() == Qt::GestureFinished) {
   115   if (QPanGesture *panningGesture = qobject_cast<QPanGesture*>(event->gesture(Qt::PanGesture))) {
   126                 switch( mMoveDir ) {
   116         HbPanGesture *hbPanGesture = qobject_cast<HbPanGesture *>(panningGesture);
   127                     case LEFT_MOVE : 
   117          if (hbPanGesture) {
   128                         mMoveDir = NO_MOVE;
   118             if(hbPanGesture->state() == Qt::GestureUpdated) {
   129                         mBounceBackDeltaX = ( mItemSize.width() >> 2 )  + ( mItemSize.width() >> 3 );
   119                  QPointF delta(hbPanGesture->sceneDelta());
   130                         emit autoLeftMoveSignal();
   120                  panGesture(delta);
   131                         break ;
   121                   event->accept(panningGesture);
   132                 
   122 
   133                     case RIGHT_MOVE :
       
   134                         mMoveDir = NO_MOVE;
       
   135                         mBounceBackDeltaX = ( mItemSize.width() >> 2 )  + ( mItemSize.width() >> 3 );
       
   136                         emit autoRightMoveSignal();
       
   137                         break;
       
   138                 
       
   139                     default:
       
   140                         break;
       
   141                 } 
       
   142                 event->accept(panningGesture);
   123             }
   143             }
   124              if(hbPanGesture->state() == Qt::GestureFinished) {
   144         }
   125                  switch( mMoveDir ) {
   145     }  
   126     
       
   127                         case LEFT_MOVE: 
       
   128                             mMoveDir = NO_MOVE;
       
   129                             emit autoLeftMoveSignal();
       
   130                             break ;
       
   131         
       
   132                         case RIGHT_MOVE :
       
   133                             mMoveDir = NO_MOVE;
       
   134                             emit autoRightMoveSignal();
       
   135                             break;
       
   136         
       
   137                         default:
       
   138                             break;
       
   139                     } 
       
   140                   event->accept(panningGesture);
       
   141 
       
   142             }
       
   143          }
       
   144     }
       
   145   
       
   146 }
   146 }
   147 
   147 
   148 void GlxCoverFlow::panGesture ( const QPointF & delta )  
   148 void GlxCoverFlow::panGesture ( const QPointF & delta )  
   149 {
   149 {
   150     qDebug("GlxCoverFlow::panGesture deltaX= %d", (int)delta.x());  
   150     qDebug("GlxCoverFlow::panGesture deltaX= %d", (int)delta.x());  
   161     
   161     
   162     if ( mUiOn == TRUE  ) {
   162     if ( mUiOn == TRUE  ) {
   163         emit coverFlowEvent( PANNING_START_EVENT );
   163         emit coverFlowEvent( PANNING_START_EVENT );
   164         mUiOn = FALSE;
   164         mUiOn = FALSE;
   165     }
   165     }
   166 }
       
   167 
       
   168 void GlxCoverFlow::leftGesture(int value)
       
   169 {
       
   170     Q_UNUSED(value);
       
   171     qDebug("GlxCoverFlow::leftGesture CurrentPos= %d value %d", mCurrentPos, value); 
       
   172     if(getSubState() == IMAGEVIEWER_S || getSubState() == FETCHER_S ) {
       
   173         return;
       
   174     }
       
   175     mMoveDir = NO_MOVE;
       
   176     mBounceBackDeltaX = ( mItemSize.width() >> 2 )  + ( mItemSize.width() >> 3 );
       
   177     emit autoLeftMoveSignal();
       
   178     if ( mUiOn == TRUE ) {
       
   179         mUiOn = FALSE;
       
   180         emit coverFlowEvent( PANNING_START_EVENT );        
       
   181     }
       
   182 }
       
   183 
       
   184 void GlxCoverFlow::rightGesture(int value)
       
   185 {
       
   186     Q_UNUSED(value);
       
   187     qDebug("GlxCoverFlow::rightGesture CurrentPos= %d value %d ", mCurrentPos, value);
       
   188     if(getSubState() == IMAGEVIEWER_S || getSubState() == FETCHER_S ) {
       
   189         return;
       
   190     }
       
   191     mMoveDir = NO_MOVE;
       
   192     mBounceBackDeltaX = ( mItemSize.width() >> 2 )  + ( mItemSize.width() >> 3 );
       
   193     emit autoRightMoveSignal();
       
   194     if ( mUiOn == TRUE  ) {
       
   195         mUiOn = FALSE;
       
   196         emit coverFlowEvent( PANNING_START_EVENT );
       
   197     }     
       
   198 }
   166 }
   199 
   167 
   200 void GlxCoverFlow::longPressGesture(const QPointF &point)
   168 void GlxCoverFlow::longPressGesture(const QPointF &point)
   201 {
   169 {
   202      qDebug("GlxCoverFlow::longPressGesture x = %d  y = %d", point.x(), point.y());
   170      qDebug("GlxCoverFlow::longPressGesture x = %d  y = %d", point.x(), point.y());
   264         mSpeed = GLX_BOUNCEBACK_SPEED;
   232         mSpeed = GLX_BOUNCEBACK_SPEED;
   265     }
   233     }
   266     //for bounce back effect for last image ( it will do the back)
   234     //for bounce back effect for last image ( it will do the back)
   267     if ( ( mCurrentPos + width ) > ( mStripLen + mBounceBackDeltaX ) && mMoveDir == NO_MOVE ) {
   235     if ( ( mCurrentPos + width ) > ( mStripLen + mBounceBackDeltaX ) && mMoveDir == NO_MOVE ) {
   268         mMoveDir = LEFT_MOVE;
   236         mMoveDir = LEFT_MOVE;
   269         mBounceBackDeltaX = 10;
   237         mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA;
   270         autoRightMoveSignal();
   238         autoRightMoveSignal();
   271         return ;
   239         return ;
   272     }
   240     }
   273     
   241     
   274     int deltaX = width - mCurrentPos %  width ; 
   242     int deltaX = width - mCurrentPos %  width ; 
   297 			if(!mZoomOn) {
   265 			if(!mZoomOn) {
   298             emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ;
   266             emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ;
   299 			}
   267 			}
   300         }
   268         }
   301         mMoveDir = NO_MOVE;
   269         mMoveDir = NO_MOVE;
   302         mBounceBackDeltaX = 10;
   270         mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA;
   303         mSpeed = GLX_COVERFLOW_SPEED;
   271         mSpeed = GLX_COVERFLOW_SPEED;
   304     }   
   272     }   
   305 }
   273 }
   306 
   274 
   307 void GlxCoverFlow::autoRightMove()
   275 void GlxCoverFlow::autoRightMove()
   316     }
   284     }
   317     //for bounce back effect for back image ( it will do the back)
   285     //for bounce back effect for back image ( it will do the back)
   318     qDebug("GlxCoverFlow::autoRightMove diffX x = %d current pos = %d mBounceBackDeltaX x = %d", diffX, mCurrentPos, mBounceBackDeltaX);
   286     qDebug("GlxCoverFlow::autoRightMove diffX x = %d current pos = %d mBounceBackDeltaX x = %d", diffX, mCurrentPos, mBounceBackDeltaX);
   319     if ( diffX > mBounceBackDeltaX && diffX < width && mMoveDir == NO_MOVE ){
   287     if ( diffX > mBounceBackDeltaX && diffX < width && mMoveDir == NO_MOVE ){
   320         mMoveDir = RIGHT_MOVE;
   288         mMoveDir = RIGHT_MOVE;
   321         mBounceBackDeltaX = 10;
   289         mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA;
   322         autoLeftMoveSignal();  
   290         autoLeftMoveSignal();  
   323         return ;
   291         return ;
   324     }
   292     }
   325     
   293     
   326     int deltaX = mCurrentPos %  width ; 
   294     int deltaX = mCurrentPos %  width ; 
   351 			if(!mZoomOn) {
   319 			if(!mZoomOn) {
   352             emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ;
   320             emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ;
   353 			}
   321 			}
   354         }
   322         }
   355         mMoveDir = NO_MOVE;
   323         mMoveDir = NO_MOVE;
   356         mBounceBackDeltaX = 10;
   324         mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA;
   357         mSpeed = GLX_COVERFLOW_SPEED;
   325         mSpeed = GLX_COVERFLOW_SPEED;
   358     }
   326     }
   359 }
   327 }
   360 
   328 
   361 void GlxCoverFlow::move(int value)
   329 void GlxCoverFlow::move(int value)
   552     if ( variant.isValid() &&  variant.canConvert<int> ()  ) {
   520     if ( variant.isValid() &&  variant.canConvert<int> ()  ) {
   553         substate = variant.value<int>();
   521         substate = variant.value<int>();
   554     }
   522     }
   555     return substate;
   523     return substate;
   556 }
   524 }
       
   525 
   557 void GlxCoverFlow::zoomStarted(int index)
   526 void GlxCoverFlow::zoomStarted(int index)
   558 {
   527 {
       
   528     Q_UNUSED(index)
   559 	mZoomOn = true;	
   529 	mZoomOn = true;	
   560 }
   530 }
       
   531 
   561 void GlxCoverFlow::zoomFinished(int index)
   532 void GlxCoverFlow::zoomFinished(int index)
   562 { 
   533 { 
   563 	mZoomOn = false;
   534 	mZoomOn = false;
   564 	indexChanged(index);
   535 	indexChanged(index);
   565 
   536