ui/views/fullscreenview/src/glxcoverflow.cpp
changeset 52 a3a4c0de738e
parent 50 a0f57508af73
child 54 0f0f3f26f787
equal deleted inserted replaced
50:a0f57508af73 52:a3a4c0de738e
    33 
    33 
    34 #define GLX_COVERFLOW_SPEED  32
    34 #define GLX_COVERFLOW_SPEED  32
    35 #define GLX_BOUNCEBACK_SPEED 16
    35 #define GLX_BOUNCEBACK_SPEED 16
    36 #define GLX_BOUNCEBACK_DELTA 8
    36 #define GLX_BOUNCEBACK_DELTA 8
    37 
    37 
    38 GlxCoverFlow::GlxCoverFlow(QGraphicsItem *parent ) 
    38 GlxCoverFlow::GlxCoverFlow( QGraphicsItem *parent ) 
    39      : HbWidget(parent), 
    39      : HbWidget( parent ), 
    40        mSelItemIndex (0),
    40        mSelItemIndex ( 0 ),
    41        mRows(0),
    41        mRows( 0 ),
    42        mSelIndex (0),
    42        mSelIndex ( 0 ),
    43        mStripLen (0),
    43        mStripLen ( 0 ),
    44        mCurrentPos(0),
    44        mCurrentPos( 0 ),
    45        mItemSize (QSize(0,0)),
    45        mItemSize ( QSize( 0, 0 ) ),
    46        mModel ( NULL),
    46        mModel ( NULL ),
    47        mMoveDir(NO_MOVE),
    47        mMoveDir( NO_MOVE ),
    48        mSpeed ( GLX_COVERFLOW_SPEED ),
    48        mSpeed ( GLX_COVERFLOW_SPEED ),
    49 	   mZoomOn(false),
    49 	   mZoomOn( false ),
    50 	   mMultitouchFilter(NULL),
    50 	   mMultitouchFilter( NULL ),
    51        mTimerId(0)
    51        mTimerId( 0 ),
    52 {
    52        mIsInit( false )
    53 //TO:DO through exception
    53 {
    54    qDebug("GlxCoverFlow::GlxCoverFlow");
    54    qDebug( "GlxCoverFlow::GlxCoverFlow" );
    55    grabGesture(Qt::PanGesture);
    55    grabGesture( Qt::PanGesture );
    56    grabGesture(Qt::TapGesture);
    56    grabGesture( Qt::TapGesture );
    57    connect( this, SIGNAL( autoLeftMoveSignal() ), this, SLOT( autoLeftMove() ), Qt::QueuedConnection );
    57    connect( this, SIGNAL( autoLeftMoveSignal() ), this, SLOT( autoLeftMove() ), Qt::QueuedConnection );
    58    connect( this, SIGNAL( autoRightMoveSignal() ), this, SLOT( autoRightMove() ), Qt::QueuedConnection );   
    58    connect( this, SIGNAL( autoRightMoveSignal() ), this, SLOT( autoRightMove() ), Qt::QueuedConnection );   
    59 }
    59 }
    60 
    60 
    61 void GlxCoverFlow::setMultitouchFilter(QGraphicsItem* mtFilter)
    61 void GlxCoverFlow::setMultitouchFilter(QGraphicsItem* mtFilter)
    62 {
    62 {
    63 	mMultitouchFilter = mtFilter;
    63 	mMultitouchFilter = mtFilter;
    64 }
    64 }
       
    65 
    65 void GlxCoverFlow::setCoverFlow()
    66 void GlxCoverFlow::setCoverFlow()
    66 {
    67 {
    67     qDebug("GlxCoverFlow::setCoverFlow");
    68     qDebug("GlxCoverFlow::setCoverFlow");
    68     for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) {
    69     for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) {
    69         mIconItem[i] = new HbIconItem( this );
    70         mIconItem[i] = new HbIconItem( this );
    73         mIconItem[i]->setSize( QSize( 0, 0 ) );
    74         mIconItem[i]->setSize( QSize( 0, 0 ) );
    74         mIconItem[i]->setAlignment( Qt::AlignCenter );
    75         mIconItem[i]->setAlignment( Qt::AlignCenter );
    75         mIconItem[i]->setObjectName( QString( "Cover%1" ).arg( i ) );
    76         mIconItem[i]->setObjectName( QString( "Cover%1" ).arg( i ) );
    76     }
    77     }
    77     
    78     
    78     mUiOn = FALSE;
    79     mIsInit = true;
       
    80     mUiOn = false;
    79     mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA;
    81     mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA;
    80 }
    82 }
    81 
    83 
    82 void GlxCoverFlow::setItemSize(QSize &size)
    84 void GlxCoverFlow::setItemSize(QSize &size)
    83 {
    85 {
   159 }
   161 }
   160 
   162 
   161 void GlxCoverFlow::panGesture ( const QPointF & delta )  
   163 void GlxCoverFlow::panGesture ( const QPointF & delta )  
   162 {
   164 {
   163     qDebug("GlxCoverFlow::panGesture deltaX= %d", (int)delta.x());  
   165     qDebug("GlxCoverFlow::panGesture deltaX= %d", (int)delta.x());  
   164     if(getSubState() == IMAGEVIEWER_S || getSubState() == FETCHER_S ) {
   166    
       
   167     if( !mIsInit || getSubState() == IMAGEVIEWER_S || getSubState() == FETCHER_S ) {
   165         return;
   168         return;
   166     }
   169     }
   167     move((int) delta.x());    
   170     move( ( int ) delta.x() );    
   168     if( delta.x() > 0 ) {     
   171     if( delta.x() > 0 ) {     
   169         mMoveDir = RIGHT_MOVE;
   172         mMoveDir = RIGHT_MOVE;
   170     }
   173     }
   171     else if ( delta.x() < 0) {
   174     else if ( delta.x() < 0) {
   172         mMoveDir = LEFT_MOVE;
   175         mMoveDir = LEFT_MOVE;
   237 void GlxCoverFlow::autoLeftMove()
   240 void GlxCoverFlow::autoLeftMove()
   238 {
   241 {
   239     int width = mItemSize.width() ;
   242     int width = mItemSize.width() ;
   240     
   243     
   241     qDebug("GlxCoverFlow::autoLeftMove current pos = %d mBounceBackDeltaX x = %d", mCurrentPos, mBounceBackDeltaX);
   244     qDebug("GlxCoverFlow::autoLeftMove current pos = %d mBounceBackDeltaX x = %d", mCurrentPos, mBounceBackDeltaX);
   242     
   245     if ( !mIsInit ) {
   243     if ( mSelIndex == ( mRows -1 )) {
   246         return;
       
   247     }
       
   248     
       
   249     if ( mSelIndex == ( mRows -1 ) ) {
   244         mSpeed = GLX_BOUNCEBACK_SPEED;
   250         mSpeed = GLX_BOUNCEBACK_SPEED;
   245     }
   251     }
   246     //for bounce back effect for last image ( it will do the back)
   252     //for bounce back effect for last image ( it will do the back)
   247     if ( ( mCurrentPos + width ) > ( mStripLen + mBounceBackDeltaX ) && mMoveDir == NO_MOVE ) {
   253     if ( ( mCurrentPos + width ) > ( mStripLen + mBounceBackDeltaX ) && mMoveDir == NO_MOVE ) {
   248         mMoveDir = LEFT_MOVE;
   254         mMoveDir = LEFT_MOVE;
   287 }
   293 }
   288 
   294 
   289 void GlxCoverFlow::autoRightMove()
   295 void GlxCoverFlow::autoRightMove()
   290 {
   296 {
   291     qDebug("GlxCoverFlow::autoRightMove ");
   297     qDebug("GlxCoverFlow::autoRightMove ");
       
   298     if ( !mIsInit ) {
       
   299         return;
       
   300     }
   292     int width = mItemSize.width()  ;
   301     int width = mItemSize.width()  ;
   293     int diffX = mStripLen - mCurrentPos ;
   302     int diffX = mStripLen - mCurrentPos ;
   294     
   303  
   295     //slow the speed for bounce back effect
   304     //slow the speed for bounce back effect
   296     if ( mSelIndex == 0 ) {
   305     if ( mSelIndex == 0 ) {
   297         mSpeed = GLX_BOUNCEBACK_SPEED;
   306         mSpeed = GLX_BOUNCEBACK_SPEED;
   298     }
   307     }
   299     //for bounce back effect for back image ( it will do the back)
   308     //for bounce back effect for back image ( it will do the back)
   399 }
   408 }
   400 
   409 
   401 void GlxCoverFlow::loadIconItems()
   410 void GlxCoverFlow::loadIconItems()
   402 {  
   411 {  
   403     qDebug("GlxCoverFlow::loadIconItems ");
   412     qDebug("GlxCoverFlow::loadIconItems ");
       
   413     
       
   414     if ( !mIsInit ) {
       
   415         return ;
       
   416     }
       
   417 
   404     int index = 0;
   418     int index = 0;
   405     stopAnimation();
   419     stopAnimation();
   406     mSelIndex = getFocusIndex();
   420     mSelIndex = getFocusIndex();
   407     
   421     
   408     qDebug("GlxCoverFlow::loadIconItems index = %d, width = %d", mSelIndex, size().width() );    
   422     qDebug("GlxCoverFlow::loadIconItems index = %d, width = %d", mSelIndex, size().width() );    
   477 
   491 
   478 void GlxCoverFlow::partiallyClean()
   492 void GlxCoverFlow::partiallyClean()
   479 {
   493 {
   480     qDebug("GlxCoverFlow::partiallyClean Enter");
   494     qDebug("GlxCoverFlow::partiallyClean Enter");
   481     clearCurrentModel(); //during the animation data update will not cause the crash
   495     clearCurrentModel(); //during the animation data update will not cause the crash
       
   496     mIsInit = false;
   482     for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) {
   497     for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) {
   483         if ( mSelItemIndex != i){
   498         if ( mSelItemIndex != i){
   484             delete mIconItem[i] ;
   499             delete mIconItem[i] ;
   485             mIconItem[i] = NULL;
   500             mIconItem[i] = NULL;
   486         }
   501         }
   507 }
   522 }
   508 
   523 
   509 void GlxCoverFlow::ClearCoverFlow()
   524 void GlxCoverFlow::ClearCoverFlow()
   510 {
   525 {
   511     qDebug("GlxCoverFlow::ClearCoverFlow  " );
   526     qDebug("GlxCoverFlow::ClearCoverFlow  " );
       
   527     mIsInit = false;
   512     clearCurrentModel();    
   528     clearCurrentModel();    
   513     for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) {
   529     for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) {
   514         if(mIconItem[i] != NULL ) {
   530         if(mIconItem[i] != NULL ) {
   515             delete mIconItem[i] ;
   531             delete mIconItem[i] ;
   516             mIconItem[i] = NULL;
   532             mIconItem[i] = NULL;