22 #include <QGraphicsSceneMouseEvent> |
22 #include <QGraphicsSceneMouseEvent> |
23 #include <QDebug> |
23 #include <QDebug> |
24 #include <QGesture> |
24 #include <QGesture> |
25 #include <hbpangesture.h> |
25 #include <hbpangesture.h> |
26 #include <hbiconanimator.h> |
26 #include <hbiconanimator.h> |
|
27 #include <hbinstance.h> |
27 |
28 |
28 //User Includes |
29 //User Includes |
29 #include <glxmodelparm.h> |
30 #include <glxmodelparm.h> |
30 #include <glxcoverflow.h> |
31 #include <glxcoverflow.h> |
31 #include "glxviewids.h" |
32 #include "glxviewids.h" |
32 |
33 |
33 #define GLX_COVERFLOW_SPEED 32 |
34 #define GLX_COVERFLOW_SPEED 32 |
34 #define GLX_BOUNCEBACK_SPEED 16 |
35 #define GLX_BOUNCEBACK_SPEED 16 |
35 #define GLX_BOUNCEBACK_DELTA 8 |
36 #define GLX_BOUNCEBACK_DELTA 8 |
36 |
37 |
37 GlxCoverFlow::GlxCoverFlow(QGraphicsItem *parent ) |
38 GlxCoverFlow::GlxCoverFlow( QGraphicsItem *parent ) |
38 : HbWidget(parent), |
39 : HbWidget( parent ), |
39 mSelItemIndex (0), |
40 mSelItemIndex ( 0 ), |
40 mRows(0), |
41 mRows( 0 ), |
41 mSelIndex (0), |
42 mSelIndex ( 0 ), |
42 mStripLen (0), |
43 mStripLen ( 0 ), |
43 mCurrentPos(0), |
44 mCurrentPos( 0 ), |
44 mItemSize (QSize(0,0)), |
45 mItemSize ( QSize( 0, 0 ) ), |
45 mModel ( NULL), |
46 mModel ( NULL ), |
46 mMoveDir(NO_MOVE), |
47 mMoveDir( NO_MOVE ), |
47 mSpeed ( GLX_COVERFLOW_SPEED ), |
48 mSpeed ( GLX_COVERFLOW_SPEED ), |
48 mZoomOn(false), |
49 mZoomOn( false ), |
49 mMultitouchFilter(NULL), |
50 mMultitouchFilter( NULL ), |
50 mTimerId(0) |
51 mTimerId( 0 ), |
51 { |
52 mIsInit( false ) |
52 //TO:DO through exception |
53 { |
53 qDebug("GlxCoverFlow::GlxCoverFlow"); |
54 qDebug( "GlxCoverFlow::GlxCoverFlow" ); |
54 grabGesture(Qt::PanGesture); |
55 grabGesture( Qt::PanGesture ); |
55 grabGesture(Qt::TapGesture); |
56 grabGesture( Qt::TapGesture ); |
56 connect( this, SIGNAL( autoLeftMoveSignal() ), this, SLOT( autoLeftMove() ), Qt::QueuedConnection ); |
57 connect( this, SIGNAL( autoLeftMoveSignal() ), this, SLOT( autoLeftMove() ), Qt::QueuedConnection ); |
57 connect( this, SIGNAL( autoRightMoveSignal() ), this, SLOT( autoRightMove() ), Qt::QueuedConnection ); |
58 connect( this, SIGNAL( autoRightMoveSignal() ), this, SLOT( autoRightMove() ), Qt::QueuedConnection ); |
58 } |
59 } |
59 |
60 |
60 void GlxCoverFlow::setMultitouchFilter(QGraphicsItem* mtFilter) |
61 void GlxCoverFlow::setMultitouchFilter(QGraphicsItem* mtFilter) |
61 { |
62 { |
62 mMultitouchFilter = mtFilter; |
63 mMultitouchFilter = mtFilter; |
63 } |
64 } |
|
65 |
64 void GlxCoverFlow::setCoverFlow() |
66 void GlxCoverFlow::setCoverFlow() |
65 { |
67 { |
66 qDebug("GlxCoverFlow::setCoverFlow"); |
68 qDebug("GlxCoverFlow::setCoverFlow"); |
67 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
69 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
68 mIconItem[i] = new HbIconItem( this ); |
70 mIconItem[i] = new HbIconItem( this ); |
158 } |
161 } |
159 |
162 |
160 void GlxCoverFlow::panGesture ( const QPointF & delta ) |
163 void GlxCoverFlow::panGesture ( const QPointF & delta ) |
161 { |
164 { |
162 qDebug("GlxCoverFlow::panGesture deltaX= %d", (int)delta.x()); |
165 qDebug("GlxCoverFlow::panGesture deltaX= %d", (int)delta.x()); |
163 if(getSubState() == IMAGEVIEWER_S || getSubState() == FETCHER_S ) { |
166 |
|
167 if( !mIsInit || getSubState() == IMAGEVIEWER_S || getSubState() == FETCHER_S ) { |
164 return; |
168 return; |
165 } |
169 } |
166 move((int) delta.x()); |
170 move( ( int ) delta.x() ); |
167 if( delta.x() > 0 ) { |
171 if( delta.x() > 0 ) { |
168 mMoveDir = RIGHT_MOVE; |
172 mMoveDir = RIGHT_MOVE; |
169 } |
173 } |
170 else if ( delta.x() < 0) { |
174 else if ( delta.x() < 0) { |
171 mMoveDir = LEFT_MOVE; |
175 mMoveDir = LEFT_MOVE; |
236 void GlxCoverFlow::autoLeftMove() |
240 void GlxCoverFlow::autoLeftMove() |
237 { |
241 { |
238 int width = mItemSize.width() ; |
242 int width = mItemSize.width() ; |
239 |
243 |
240 qDebug("GlxCoverFlow::autoLeftMove current pos = %d mBounceBackDeltaX x = %d", mCurrentPos, mBounceBackDeltaX); |
244 qDebug("GlxCoverFlow::autoLeftMove current pos = %d mBounceBackDeltaX x = %d", mCurrentPos, mBounceBackDeltaX); |
241 |
245 if ( !mIsInit ) { |
242 if ( mSelIndex == ( mRows -1 )) { |
246 return; |
|
247 } |
|
248 |
|
249 if ( mSelIndex == ( mRows -1 ) ) { |
243 mSpeed = GLX_BOUNCEBACK_SPEED; |
250 mSpeed = GLX_BOUNCEBACK_SPEED; |
244 } |
251 } |
245 //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) |
246 if ( ( mCurrentPos + width ) > ( mStripLen + mBounceBackDeltaX ) && mMoveDir == NO_MOVE ) { |
253 if ( ( mCurrentPos + width ) > ( mStripLen + mBounceBackDeltaX ) && mMoveDir == NO_MOVE ) { |
247 mMoveDir = LEFT_MOVE; |
254 mMoveDir = LEFT_MOVE; |
286 } |
293 } |
287 |
294 |
288 void GlxCoverFlow::autoRightMove() |
295 void GlxCoverFlow::autoRightMove() |
289 { |
296 { |
290 qDebug("GlxCoverFlow::autoRightMove "); |
297 qDebug("GlxCoverFlow::autoRightMove "); |
|
298 if ( !mIsInit ) { |
|
299 return; |
|
300 } |
291 int width = mItemSize.width() ; |
301 int width = mItemSize.width() ; |
292 int diffX = mStripLen - mCurrentPos ; |
302 int diffX = mStripLen - mCurrentPos ; |
293 |
303 |
294 //slow the speed for bounce back effect |
304 //slow the speed for bounce back effect |
295 if ( mSelIndex == 0 ) { |
305 if ( mSelIndex == 0 ) { |
296 mSpeed = GLX_BOUNCEBACK_SPEED; |
306 mSpeed = GLX_BOUNCEBACK_SPEED; |
297 } |
307 } |
298 //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) |
427 } |
442 } |
428 |
443 |
429 void GlxCoverFlow::stopAnimation() |
444 void GlxCoverFlow::stopAnimation() |
430 { |
445 { |
431 mIconItem[ mSelItemIndex ]->animator().stopAnimation(); |
446 mIconItem[ mSelItemIndex ]->animator().stopAnimation(); |
|
447 mIconItem[ mSelItemIndex ]->setIcon( getIcon( mSelIndex ) ); |
432 } |
448 } |
433 |
449 |
434 void GlxCoverFlow::updateIconItem (qint16 selIndex, qint16 selItemIndex, qint16 posX) |
450 void GlxCoverFlow::updateIconItem (qint16 selIndex, qint16 selItemIndex, qint16 posX) |
435 { |
451 { |
436 qDebug("GlxCoverFlow::updateIconItem selIndex = %d, selIconIndex = %d posX = %d", selIndex, selItemIndex, posX ); |
452 qDebug("GlxCoverFlow::updateIconItem selIndex = %d, selIconIndex = %d posX = %d", selIndex, selItemIndex, posX ); |
476 |
492 |
477 void GlxCoverFlow::partiallyClean() |
493 void GlxCoverFlow::partiallyClean() |
478 { |
494 { |
479 qDebug("GlxCoverFlow::partiallyClean Enter"); |
495 qDebug("GlxCoverFlow::partiallyClean Enter"); |
480 clearCurrentModel(); //during the animation data update will not cause the crash |
496 clearCurrentModel(); //during the animation data update will not cause the crash |
|
497 mIsInit = false; |
481 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
498 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
482 if ( mSelItemIndex != i){ |
499 if ( mSelItemIndex != i){ |
483 delete mIconItem[i] ; |
500 delete mIconItem[i] ; |
484 mIconItem[i] = NULL; |
501 mIconItem[i] = NULL; |
485 } |
502 } |
486 } |
503 } |
487 } |
504 } |
488 |
505 |
489 void GlxCoverFlow::partiallyCreate(QAbstractItemModel *model, QSize itemSize) |
506 void GlxCoverFlow::partiallyCreate( QAbstractItemModel *model, QSize itemSize, int posY ) |
490 { |
507 { |
491 qDebug("GlxCoverFlow::resetpartiallyCreated"); |
508 qDebug("GlxCoverFlow::resetpartiallyCreated poxY %d", posY ); |
492 mIconItem[2]->setSize ( itemSize ); |
509 mIconItem[2]->setSize ( itemSize ); |
493 mIconItem[2]->setPos ( QPointF ( 0, 0) ); |
510 mIconItem[2]->setPos ( QPointF ( 0, posY ) ); |
494 mModel = model ; |
511 mModel = model ; |
495 mSelIndex = getFocusIndex(); |
512 mSelIndex = getFocusIndex(); |
496 mIconItem[2]->setIcon( getIcon( mSelIndex ) ) ; |
513 mIconItem[2]->setIcon( getIcon( mSelIndex ) ) ; |
497 mModel = NULL; |
514 mModel = NULL; |
498 } |
515 } |