49 mZoomOn( false ), |
49 mZoomOn( false ), |
50 mMultitouchFilter( NULL ), |
50 mMultitouchFilter( NULL ), |
51 mTimerId( 0 ), |
51 mTimerId( 0 ), |
52 mIsInit( false ) |
52 mIsInit( false ) |
53 { |
53 { |
54 qDebug( "GlxCoverFlow::GlxCoverFlow" ); |
54 qDebug( "GlxCoverFlow::GlxCoverFlow" ); |
55 grabGesture( Qt::PanGesture ); |
55 mIsAutoMoving = FALSE; |
56 grabGesture( Qt::TapGesture ); |
56 grabGesture( Qt::PanGesture ); |
57 connect( this, SIGNAL( autoLeftMoveSignal() ), this, SLOT( autoLeftMove() ), Qt::QueuedConnection ); |
57 grabGesture( Qt::TapGesture ); |
58 connect( this, SIGNAL( autoRightMoveSignal() ), this, SLOT( autoRightMove() ), Qt::QueuedConnection ); |
58 connect( this, SIGNAL( autoLeftMoveSignal() ), this, SLOT( autoLeftMove() ), Qt::QueuedConnection ); |
|
59 connect( this, SIGNAL( autoRightMoveSignal() ), this, SLOT( autoRightMove() ), Qt::QueuedConnection ); |
|
60 connect( this, SIGNAL( moveNextSignal() ), this, SLOT( moveNextImage() ), Qt::QueuedConnection ); |
|
61 connect( this, SIGNAL( movePreviousSignal() ), this, SLOT( movePreviousImage() ), Qt::QueuedConnection ); |
59 } |
62 } |
60 |
63 |
61 void GlxCoverFlow::setMultitouchFilter(QGraphicsItem* mtFilter) |
64 void GlxCoverFlow::setMultitouchFilter(QGraphicsItem* mtFilter) |
62 { |
65 { |
63 mMultitouchFilter = mtFilter; |
66 mMultitouchFilter = mtFilter; |
135 QPointF delta(hbPanGesture->sceneDelta()); |
138 QPointF delta(hbPanGesture->sceneDelta()); |
136 panGesture(delta); |
139 panGesture(delta); |
137 event->accept(panningGesture); |
140 event->accept(panningGesture); |
138 } |
141 } |
139 |
142 |
140 if(hbPanGesture->state() == Qt::GestureFinished) { |
143 if( hbPanGesture->state() == Qt::GestureFinished ) { |
141 switch( mMoveDir ) { |
144 if( mIsAutoMoving == FALSE ) { |
142 case LEFT_MOVE : |
145 switch( mMoveDir ) { |
143 mMoveDir = NO_MOVE; |
146 case LEFT_MOVE : |
144 mBounceBackDeltaX = ( mItemSize.width() >> 2 ) + ( mItemSize.width() >> 3 ); |
147 mMoveDir = NO_MOVE; |
145 emit autoLeftMoveSignal(); |
148 mBounceBackDeltaX = ( mItemSize.width() >> 2 ) + ( mItemSize.width() >> 3 ); |
146 break ; |
149 emit autoLeftMoveSignal(); |
147 |
150 mIsAutoMoving = TRUE; |
148 case RIGHT_MOVE : |
151 break ; |
149 mMoveDir = NO_MOVE; |
152 |
150 mBounceBackDeltaX = ( mItemSize.width() >> 2 ) + ( mItemSize.width() >> 3 ); |
153 case RIGHT_MOVE : |
151 emit autoRightMoveSignal(); |
154 mMoveDir = NO_MOVE; |
152 break; |
155 mBounceBackDeltaX = ( mItemSize.width() >> 2 ) + ( mItemSize.width() >> 3 ); |
153 |
156 emit autoRightMoveSignal(); |
154 default: |
157 mIsAutoMoving = TRUE; |
155 break; |
158 break; |
156 } |
159 |
|
160 default: |
|
161 break; |
|
162 } |
|
163 } |
157 event->accept(panningGesture); |
164 event->accept(panningGesture); |
158 } |
165 } |
159 } |
166 } |
160 } |
167 } |
161 } |
168 } |
162 |
169 |
163 void GlxCoverFlow::panGesture ( const QPointF & delta ) |
170 void GlxCoverFlow::panGesture ( const QPointF & delta ) |
164 { |
171 { |
165 qDebug("GlxCoverFlow::panGesture deltaX= %d", (int)delta.x()); |
172 qDebug("GlxCoverFlow::panGesture deltaX= %d", (int)delta.x()); |
166 |
173 |
167 if( !mIsInit || getSubState() == IMAGEVIEWER_S || getSubState() == FETCHER_S ) { |
174 if( !mIsInit || getSubState() == IMAGEVIEWER_S || getSubState() == FETCHER_S || mIsAutoMoving == TRUE ) { |
168 return; |
175 return; |
169 } |
176 } |
|
177 |
170 move( ( int ) delta.x() ); |
178 move( ( int ) delta.x() ); |
171 if( delta.x() > 0 ) { |
179 if( delta.x() > 0 ) { |
172 mMoveDir = RIGHT_MOVE; |
180 mMoveDir = RIGHT_MOVE; |
173 } |
181 } |
174 else if ( delta.x() < 0) { |
182 else if ( delta.x() < 0) { |
270 } |
272 } |
271 else { |
273 else { |
272 //for bounce back of first image |
274 //for bounce back of first image |
273 if ( mMoveDir == RIGHT_MOVE ) { |
275 if ( mMoveDir == RIGHT_MOVE ) { |
274 emit autoRightMoveSignal(); |
276 emit autoRightMoveSignal(); |
275 return; |
277 } |
276 } |
278 else { |
277 int selIndex = mCurrentPos / width ; |
279 emit moveNextSignal(); |
278 if ( mRows == 1 || selIndex != mSelIndex ) { |
280 } |
279 stopAnimation(); |
|
280 mSelIndex = selIndex; |
|
281 mSelItemIndex = ( ++mSelItemIndex ) % NBR_ICON_ITEM; |
|
282 selIndex = ( mSelItemIndex + 2 ) % NBR_ICON_ITEM; |
|
283 updateIconItem( mSelIndex + 2, selIndex, width * 2 ) ; |
|
284 playAnimation(); |
|
285 if(!mZoomOn) { |
|
286 emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ; |
|
287 } |
|
288 } |
|
289 mMoveDir = NO_MOVE; |
|
290 mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA; |
|
291 mSpeed = GLX_COVERFLOW_SPEED; |
|
292 } |
281 } |
293 } |
282 } |
294 |
283 |
295 void GlxCoverFlow::autoRightMove() |
284 void GlxCoverFlow::autoRightMove() |
296 { |
285 { |
329 } |
318 } |
330 else { |
319 else { |
331 //for bounce back of last image |
320 //for bounce back of last image |
332 if ( mMoveDir == LEFT_MOVE ) { |
321 if ( mMoveDir == LEFT_MOVE ) { |
333 emit autoLeftMoveSignal(); |
322 emit autoLeftMoveSignal(); |
334 return; |
323 } |
335 } |
324 else { |
336 int selIndex = mCurrentPos / width ; |
325 emit movePreviousSignal(); |
337 if ( mRows == 1 || selIndex != mSelIndex ) { |
326 } |
338 stopAnimation(); |
327 } |
339 mSelIndex = selIndex; |
328 } |
340 mSelItemIndex = ( mSelItemIndex == 0 ) ? NBR_ICON_ITEM -1 : --mSelItemIndex; |
329 |
341 selIndex = ( mSelItemIndex + 3 ) % NBR_ICON_ITEM; |
330 void GlxCoverFlow::moveNextImage() |
342 updateIconItem( mSelIndex - 2, selIndex, - width * 2 ) ; |
331 { |
343 playAnimation(); |
332 int width = mItemSize.width() ; |
344 if(!mZoomOn) { |
333 int selIndex = mCurrentPos / width ; |
345 emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ; |
334 if ( mRows == 1 || selIndex != mSelIndex ) { |
346 } |
335 stopAnimation() ; |
347 } |
336 mSelIndex = selIndex ; |
348 mMoveDir = NO_MOVE; |
337 mSelItemIndex = ( ++mSelItemIndex ) % NBR_ICON_ITEM ; |
349 mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA; |
338 selIndex = ( mSelItemIndex + 2 ) % NBR_ICON_ITEM ; |
350 mSpeed = GLX_COVERFLOW_SPEED; |
339 updateIconItem( mSelIndex + 2, selIndex, width * 2 ) ; |
351 } |
340 playAnimation() ; |
|
341 if( !mZoomOn ) { |
|
342 emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ; |
|
343 } |
|
344 } |
|
345 mMoveDir = NO_MOVE; |
|
346 mIsAutoMoving = FALSE; |
|
347 mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA ; |
|
348 mSpeed = GLX_COVERFLOW_SPEED ; |
|
349 } |
|
350 |
|
351 void GlxCoverFlow::movePreviousImage() |
|
352 { |
|
353 int width = mItemSize.width(); |
|
354 int selIndex = mCurrentPos / width; |
|
355 if ( mRows == 1 || selIndex != mSelIndex ) { |
|
356 stopAnimation(); |
|
357 mSelIndex = selIndex; |
|
358 mSelItemIndex = ( mSelItemIndex == 0 ) ? NBR_ICON_ITEM -1 : --mSelItemIndex; |
|
359 selIndex = ( mSelItemIndex + 3 ) % NBR_ICON_ITEM; |
|
360 updateIconItem( mSelIndex - 2, selIndex, - width * 2 ) ; |
|
361 playAnimation(); |
|
362 if(!mZoomOn) { |
|
363 emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ; |
|
364 } |
|
365 } |
|
366 mMoveDir = NO_MOVE; |
|
367 mIsAutoMoving = FALSE; |
|
368 mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA; |
|
369 mSpeed = GLX_COVERFLOW_SPEED; |
352 } |
370 } |
353 |
371 |
354 void GlxCoverFlow::move(int value) |
372 void GlxCoverFlow::move(int value) |
355 { |
373 { |
356 qDebug("GlxCoverFlow::move "); |
374 qDebug("GlxCoverFlow::move "); |
357 QPointF pos(0,0); |
375 QPointF pos(0,0); |
358 |
376 |
359 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
377 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
360 pos.setX( mIconItem[i]->pos().x() + value); |
378 pos.setX( mIconItem[i]->pos().x() + value ); |
361 pos.setY(mIconItem[i]->pos().y()); |
379 pos.setY( mIconItem[i]->pos().y() ); |
362 mIconItem[i]->setPos(pos); |
380 mIconItem[i]->setPos( pos ); |
363 } |
381 } |
364 |
382 |
365 mCurrentPos -= value; |
383 mCurrentPos -= value; |
366 if ( mCurrentPos < 0 ) { |
384 if ( mCurrentPos < 0 ) { |
367 mCurrentPos += mStripLen; |
385 mCurrentPos += mStripLen; |
551 emit coverFlowEvent( ZOOM_START_EVENT ); |
569 emit coverFlowEvent( ZOOM_START_EVENT ); |
552 stopAnimation(); |
570 stopAnimation(); |
553 mZoomOn = true; |
571 mZoomOn = true; |
554 } |
572 } |
555 |
573 |
556 void GlxCoverFlow::zoomFinished(int index) |
574 void GlxCoverFlow::zoomFinished( int index ) |
557 { |
575 { |
558 mZoomOn = false; |
576 mZoomOn = false; |
559 playAnimation(); |
577 playAnimation(); |
560 indexChanged(index); |
578 indexChanged(index); |
561 } |
579 } |
562 |
580 |
563 void GlxCoverFlow::timerEvent(QTimerEvent *event) |
581 void GlxCoverFlow::timerEvent( QTimerEvent *event ) |
564 { |
582 { |
565 if(mTimerId == event->timerId()) |
583 if(mTimerId == event->timerId()) { |
566 { |
584 killTimer( mTimerId ); |
567 killTimer(mTimerId); |
|
568 mTimerId = 0; |
585 mTimerId = 0; |
569 emit coverFlowEvent( TAP_EVENT ); |
586 emit coverFlowEvent( TAP_EVENT ); |
570 } |
587 } |
571 } |
588 } |
572 |
589 |
573 int GlxCoverFlow::getFocusIndex( ) |
590 int GlxCoverFlow::getFocusIndex() |
574 { |
591 { |
575 QVariant variant = mModel->data( mModel->index( 0, 0 ), GlxFocusIndexRole ) ; |
592 QVariant variant = mModel->data( mModel->index( 0, 0 ), GlxFocusIndexRole ) ; |
576 if ( variant.isValid() && variant.canConvert< int > () ) { |
593 if ( variant.isValid() && variant.canConvert< int > () ) { |
577 return variant.value< int > (); |
594 return variant.value< int > (); |
578 } |
595 } |