|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //Includes |
|
20 #include <hbiconitem.h> |
|
21 #include <QAbstractItemModel> |
|
22 #include <QGraphicsSceneMouseEvent> |
|
23 #include <QDebug> |
|
24 #include <QGesture> |
|
25 #include <hbpangesture.h> |
|
26 #include <hbiconanimator.h> |
|
27 #include <hbinstance.h> |
|
28 |
|
29 //User Includes |
|
30 #include <glxmodelparm.h> |
|
31 #include <glxcoverflow.h> |
|
32 #include "glxviewids.h" |
|
33 |
|
34 #define GLX_COVERFLOW_SPEED 32 |
|
35 #define GLX_BOUNCEBACK_SPEED 16 |
|
36 #define GLX_BOUNCEBACK_DELTA 8 |
|
37 |
|
38 GlxCoverFlow::GlxCoverFlow( QGraphicsItem *parent ) |
|
39 : HbWidget( parent ), |
|
40 mSelItemIndex ( 0 ), |
|
41 mRows( 0 ), |
|
42 mSelIndex ( 0 ), |
|
43 mStripLen ( 0 ), |
|
44 mCurrentPos( 0 ), |
|
45 mItemSize ( QSize( 0, 0 ) ), |
|
46 mModel ( NULL ), |
|
47 mMoveDir( NO_MOVE ), |
|
48 mSpeed ( GLX_COVERFLOW_SPEED ), |
|
49 mZoomOn( false ), |
|
50 mMultitouchFilter( NULL ), |
|
51 mTimerId( 0 ), |
|
52 mIsInit( false ) |
|
53 { |
|
54 qDebug( "GlxCoverFlow::GlxCoverFlow" ); |
|
55 mIsAutoMoving = FALSE; |
|
56 grabGesture( Qt::PanGesture ); |
|
57 grabGesture( Qt::TapGesture ); |
|
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 ); |
|
62 } |
|
63 |
|
64 void GlxCoverFlow::setMultitouchFilter(QGraphicsItem* mtFilter) |
|
65 { |
|
66 mMultitouchFilter = mtFilter; |
|
67 } |
|
68 |
|
69 void GlxCoverFlow::setCoverFlow() |
|
70 { |
|
71 qDebug("GlxCoverFlow::setCoverFlow"); |
|
72 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
|
73 mIconItem[i] = new HbIconItem( this ); |
|
74 mIconItem[i]->grabGesture( Qt::PinchGesture, Qt::ReceivePartialGestures ); |
|
75 mIconItem[i]->installSceneEventFilter( mMultitouchFilter ); |
|
76 mIconItem[i]->setBrush( QBrush( Qt::black ) ); |
|
77 mIconItem[i]->setSize( QSize( 0, 0 ) ); |
|
78 mIconItem[i]->setAlignment( Qt::AlignCenter ); |
|
79 mIconItem[i]->setObjectName( QString( "Cover%1" ).arg( i ) ); |
|
80 } |
|
81 |
|
82 mIsInit = true; |
|
83 mUiOn = false; |
|
84 mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA; |
|
85 } |
|
86 |
|
87 void GlxCoverFlow::setItemSize(QSize &size) |
|
88 { |
|
89 qDebug("GlxCoverFlow::setSize width = %d",size.width() ); |
|
90 if( mItemSize != size) { |
|
91 mItemSize = size; |
|
92 resetCoverFlow(); |
|
93 } |
|
94 } |
|
95 |
|
96 void GlxCoverFlow::setModel(QAbstractItemModel *model) |
|
97 { |
|
98 qDebug("GlxCoverFlow::setModel model change = %d", model ); |
|
99 |
|
100 if ( model == mModel) { |
|
101 return ; |
|
102 } |
|
103 |
|
104 clearCurrentModel(); |
|
105 mModel = model; |
|
106 initializeNewModel(); |
|
107 resetCoverFlow(); |
|
108 } |
|
109 |
|
110 void GlxCoverFlow::indexChanged( int index ) |
|
111 { |
|
112 qDebug("GlxCoverFlow::indexChanged index = %d mSelIndex = %d ",index, mSelIndex ); |
|
113 if ( index != mSelIndex && mModel) { |
|
114 loadIconItems(); |
|
115 } |
|
116 } |
|
117 |
|
118 void GlxCoverFlow::gestureEvent(QGestureEvent *event) |
|
119 { |
|
120 if(QTapGesture *gesture = static_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) { |
|
121 if (gesture->state() == Qt::GestureFinished) { |
|
122 if(!mTimerId) { |
|
123 mTimerId = startTimer( DOUBLETAP_TIMEINTERVAL ); |
|
124 } |
|
125 else { |
|
126 killTimer(mTimerId); |
|
127 mTimerId = 0; |
|
128 emit doubleTapEventReceived(hbInstance->allMainWindows().first()->mapToScene(gesture->position().toPoint())); |
|
129 } |
|
130 event->accept(gesture); |
|
131 } |
|
132 } |
|
133 |
|
134 if (QPanGesture *panningGesture = qobject_cast<QPanGesture*>(event->gesture(Qt::PanGesture))) { |
|
135 HbPanGesture *hbPanGesture = qobject_cast<HbPanGesture *>(panningGesture); |
|
136 if (hbPanGesture) { |
|
137 if(hbPanGesture->state() == Qt::GestureUpdated) { |
|
138 QPointF delta(hbPanGesture->sceneDelta()); |
|
139 panGesture(delta); |
|
140 event->accept(panningGesture); |
|
141 } |
|
142 |
|
143 if( hbPanGesture->state() == Qt::GestureFinished ) { |
|
144 if( mIsAutoMoving == FALSE ) { |
|
145 switch( mMoveDir ) { |
|
146 case LEFT_MOVE : |
|
147 mMoveDir = NO_MOVE; |
|
148 mBounceBackDeltaX = ( mItemSize.width() >> 2 ) + ( mItemSize.width() >> 3 ); |
|
149 emit autoLeftMoveSignal(); |
|
150 mIsAutoMoving = TRUE; |
|
151 break ; |
|
152 |
|
153 case RIGHT_MOVE : |
|
154 mMoveDir = NO_MOVE; |
|
155 mBounceBackDeltaX = ( mItemSize.width() >> 2 ) + ( mItemSize.width() >> 3 ); |
|
156 emit autoRightMoveSignal(); |
|
157 mIsAutoMoving = TRUE; |
|
158 break; |
|
159 |
|
160 default: |
|
161 break; |
|
162 } |
|
163 } |
|
164 event->accept(panningGesture); |
|
165 } |
|
166 } |
|
167 } |
|
168 } |
|
169 |
|
170 void GlxCoverFlow::panGesture ( const QPointF & delta ) |
|
171 { |
|
172 qDebug("GlxCoverFlow::panGesture deltaX= %d", (int)delta.x()); |
|
173 |
|
174 if( !mIsInit || getSubState() == IMAGEVIEWER_S || getSubState() == FETCHER_S || mIsAutoMoving == TRUE ) { |
|
175 return; |
|
176 } |
|
177 |
|
178 move( ( int ) delta.x() ); |
|
179 if( delta.x() > 0 ) { |
|
180 mMoveDir = RIGHT_MOVE; |
|
181 } |
|
182 else if ( delta.x() < 0) { |
|
183 mMoveDir = LEFT_MOVE; |
|
184 } |
|
185 |
|
186 if ( mUiOn == TRUE ) { |
|
187 emit coverFlowEvent( PANNING_START_EVENT ); |
|
188 mUiOn = FALSE; |
|
189 } |
|
190 } |
|
191 |
|
192 void GlxCoverFlow::dataChanged(QModelIndex startIndex, QModelIndex endIndex) |
|
193 { |
|
194 Q_UNUSED(endIndex); |
|
195 qDebug("GlxCoverFlow::dataChanged startIndex = %d mSelIndex = %d ", startIndex.row(), mSelIndex ); |
|
196 |
|
197 int index = 0; |
|
198 for (int i = 0; i < NBR_ICON_ITEM ; i++) { |
|
199 index = calculateIndex( mSelIndex + i - 2 ); |
|
200 if ( index == startIndex.row() ) { |
|
201 index = ( mSelItemIndex + i - 2 + NBR_ICON_ITEM ) % NBR_ICON_ITEM; |
|
202 qDebug("GlxCoverFlow::dataChanged index = %d mSelItemIndex = %d ", index, mSelItemIndex ); |
|
203 mIconItem[ index ]->setIcon( getIcon( startIndex.row() ) ); |
|
204 if ( index == mSelItemIndex ) { |
|
205 playAnimation( ); |
|
206 } |
|
207 } |
|
208 } |
|
209 } |
|
210 |
|
211 void GlxCoverFlow::rowsInserted(const QModelIndex &parent, int start, int end) |
|
212 { |
|
213 qDebug("GlxCoverFlow::rowsInserted"); |
|
214 Q_UNUSED(parent); |
|
215 Q_UNUSED(start); |
|
216 Q_UNUSED(end); |
|
217 resetCoverFlow(); |
|
218 emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ; |
|
219 } |
|
220 |
|
221 void GlxCoverFlow::rowsRemoved(const QModelIndex &parent, int start, int end) |
|
222 { |
|
223 Q_UNUSED(parent); |
|
224 Q_UNUSED(start); |
|
225 Q_UNUSED(end); |
|
226 qDebug("GlxCoverFlow::rowsRemoved model %d", mModel); |
|
227 |
|
228 if ( mModel->rowCount() <= 0 ) { |
|
229 emit coverFlowEvent( EMPTY_ROW_EVENT ); |
|
230 } |
|
231 else { |
|
232 resetCoverFlow(); |
|
233 emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ; |
|
234 } |
|
235 } |
|
236 |
|
237 void GlxCoverFlow::modelDestroyed() |
|
238 { |
|
239 mModel = NULL ; |
|
240 } |
|
241 |
|
242 void GlxCoverFlow::autoLeftMove() |
|
243 { |
|
244 int width = mItemSize.width() ; |
|
245 |
|
246 qDebug("GlxCoverFlow::autoLeftMove current pos = %d mBounceBackDeltaX x = %d", mCurrentPos, mBounceBackDeltaX); |
|
247 if ( !mIsInit ) { |
|
248 return; |
|
249 } |
|
250 |
|
251 if ( mSelIndex == ( mRows -1 ) ) { |
|
252 mSpeed = GLX_BOUNCEBACK_SPEED; |
|
253 } |
|
254 //for bounce back effect for last image ( it will do the back) |
|
255 if ( ( mCurrentPos + width ) > ( mStripLen + mBounceBackDeltaX ) && mMoveDir == NO_MOVE ) { |
|
256 mMoveDir = LEFT_MOVE; |
|
257 mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA; |
|
258 autoRightMoveSignal(); |
|
259 return ; |
|
260 } |
|
261 |
|
262 int deltaX = width - mCurrentPos % width ; |
|
263 int moveX = deltaX > mSpeed ? mSpeed : deltaX; |
|
264 |
|
265 qDebug("GlxCoverFlow::autoLeftMove delta x = %d current pos = %d move x = %d", deltaX, mCurrentPos, moveX); |
|
266 |
|
267 move (-moveX);//move the image |
|
268 deltaX -= moveX; //To know the auto move is required or not |
|
269 |
|
270 if ( deltaX ) { |
|
271 emit autoLeftMoveSignal(); |
|
272 } |
|
273 else { |
|
274 //for bounce back of first image |
|
275 if ( mMoveDir == RIGHT_MOVE ) { |
|
276 emit autoRightMoveSignal(); |
|
277 } |
|
278 else { |
|
279 emit moveNextSignal(); |
|
280 } |
|
281 } |
|
282 } |
|
283 |
|
284 void GlxCoverFlow::autoRightMove() |
|
285 { |
|
286 qDebug("GlxCoverFlow::autoRightMove "); |
|
287 if ( !mIsInit ) { |
|
288 return; |
|
289 } |
|
290 int width = mItemSize.width() ; |
|
291 int diffX = mStripLen - mCurrentPos ; |
|
292 |
|
293 //slow the speed for bounce back effect |
|
294 if ( mSelIndex == 0 ) { |
|
295 mSpeed = GLX_BOUNCEBACK_SPEED; |
|
296 } |
|
297 //for bounce back effect for back image ( it will do the back) |
|
298 qDebug("GlxCoverFlow::autoRightMove diffX x = %d current pos = %d mBounceBackDeltaX x = %d", diffX, mCurrentPos, mBounceBackDeltaX); |
|
299 if ( diffX > mBounceBackDeltaX && diffX < width && mMoveDir == NO_MOVE ){ |
|
300 mMoveDir = RIGHT_MOVE; |
|
301 mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA; |
|
302 autoLeftMoveSignal(); |
|
303 return ; |
|
304 } |
|
305 |
|
306 int deltaX = mCurrentPos % width ; |
|
307 //in the case of deltaX == 0 ( right flick case ) complete image should move |
|
308 deltaX = deltaX ? deltaX : width ; |
|
309 int moveX = deltaX > mSpeed ? mSpeed : deltaX; |
|
310 |
|
311 qDebug("GlxCoverFlow::autoRightMove delta x = %d current pos = %d move x = %d", deltaX, mCurrentPos, moveX); |
|
312 |
|
313 move (moveX); |
|
314 deltaX -= moveX; |
|
315 |
|
316 if ( deltaX ) { |
|
317 emit autoRightMoveSignal(); |
|
318 } |
|
319 else { |
|
320 //for bounce back of last image |
|
321 if ( mMoveDir == LEFT_MOVE ) { |
|
322 emit autoLeftMoveSignal(); |
|
323 } |
|
324 else { |
|
325 emit movePreviousSignal(); |
|
326 } |
|
327 } |
|
328 } |
|
329 |
|
330 void GlxCoverFlow::moveNextImage() |
|
331 { |
|
332 int width = mItemSize.width() ; |
|
333 int selIndex = mCurrentPos / width ; |
|
334 if ( mRows == 1 || selIndex != mSelIndex ) { |
|
335 stopAnimation() ; |
|
336 mSelIndex = selIndex ; |
|
337 mSelItemIndex = ( ++mSelItemIndex ) % NBR_ICON_ITEM ; |
|
338 selIndex = ( mSelItemIndex + 2 ) % NBR_ICON_ITEM ; |
|
339 updateIconItem( mSelIndex + 2, selIndex, width * 2 ) ; |
|
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; |
|
370 } |
|
371 |
|
372 void GlxCoverFlow::move(int value) |
|
373 { |
|
374 qDebug("GlxCoverFlow::move "); |
|
375 QPointF pos(0,0); |
|
376 |
|
377 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
|
378 pos.setX( mIconItem[i]->pos().x() + value ); |
|
379 pos.setY( mIconItem[i]->pos().y() ); |
|
380 mIconItem[i]->setPos( pos ); |
|
381 } |
|
382 |
|
383 mCurrentPos -= value; |
|
384 if ( mCurrentPos < 0 ) { |
|
385 mCurrentPos += mStripLen; |
|
386 } |
|
387 else if ( mCurrentPos >= mStripLen ) { |
|
388 mCurrentPos -= mStripLen; |
|
389 } |
|
390 qDebug("GlxCoverFlow::Move value = %d current pos = %d", value, mCurrentPos); |
|
391 } |
|
392 |
|
393 void GlxCoverFlow::setRows() |
|
394 { |
|
395 qDebug("GlxCoverFlow::setRows "); |
|
396 if (mModel) { |
|
397 mRows = mModel->rowCount(); |
|
398 } |
|
399 else { |
|
400 mRows = 0; |
|
401 } |
|
402 qDebug("GlxCoverFlow::setRows number of rows = %d", mRows); |
|
403 } |
|
404 |
|
405 void GlxCoverFlow::setStripLen() |
|
406 { |
|
407 qDebug("GlxCoverFlow::setStripLen "); |
|
408 mStripLen = mRows * mItemSize.width(); |
|
409 qDebug("GlxCoverFlow::setStripLen rows = %d, striplen %d", mRows, mStripLen); |
|
410 } |
|
411 |
|
412 int GlxCoverFlow::calculateIndex(int index) |
|
413 { |
|
414 qDebug("GlxCoverFlow::calculateIndex index = %d, mRows = %d", index, mRows); |
|
415 |
|
416 if ( mRows == 1 ) |
|
417 return 0; |
|
418 |
|
419 if ( index < 0 ) |
|
420 return ( index + mRows ); |
|
421 |
|
422 if ( index >= mRows ) |
|
423 return ( index - mRows ) ; |
|
424 |
|
425 return index; |
|
426 } |
|
427 |
|
428 void GlxCoverFlow::loadIconItems() |
|
429 { |
|
430 qDebug("GlxCoverFlow::loadIconItems "); |
|
431 |
|
432 if ( !mIsInit ) { |
|
433 return ; |
|
434 } |
|
435 |
|
436 int index = 0; |
|
437 stopAnimation(); |
|
438 mSelIndex = getFocusIndex(); |
|
439 |
|
440 qDebug("GlxCoverFlow::loadIconItems index = %d, width = %d", mSelIndex, size().width() ); |
|
441 |
|
442 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
|
443 index = calculateIndex ( mSelIndex - 2 + i) ; |
|
444 mIconItem[i]->setIcon( getIcon( index ) ); |
|
445 mIconItem[i]->setSize ( mItemSize ); |
|
446 mIconItem[i]->setPos ( QPointF ( (i - 2) * mItemSize.width(), 0) ); |
|
447 } |
|
448 |
|
449 mSelItemIndex = 2; |
|
450 mCurrentPos = mItemSize.width() * mSelIndex; |
|
451 playAnimation(); |
|
452 } |
|
453 |
|
454 void GlxCoverFlow::playAnimation() |
|
455 { |
|
456 if ( isAnimatedImage( mSelIndex ) ) { |
|
457 mIconItem[ mSelItemIndex ]->setIcon( HbIcon( getUri( mSelIndex ) ) ); |
|
458 mIconItem[ mSelItemIndex ]->animator().startAnimation(); |
|
459 } |
|
460 } |
|
461 |
|
462 void GlxCoverFlow::stopAnimation() |
|
463 { |
|
464 mIconItem[ mSelItemIndex ]->animator().stopAnimation(); |
|
465 mIconItem[ mSelItemIndex ]->setIcon( getIcon( mSelIndex ) ); |
|
466 } |
|
467 |
|
468 void GlxCoverFlow::updateIconItem (qint16 selIndex, qint16 selItemIndex, qint16 posX) |
|
469 { |
|
470 qDebug("GlxCoverFlow::updateIconItem selIndex = %d, selIconIndex = %d posX = %d", selIndex, selItemIndex, posX ); |
|
471 |
|
472 selIndex = calculateIndex( selIndex ); |
|
473 mIconItem[ selItemIndex ]->setPos( QPointF( posX, 0 ) ); |
|
474 mIconItem[ selItemIndex ]->setIcon( getIcon( selIndex ) ); |
|
475 mIconItem[ selItemIndex ]->setSize ( mItemSize ); |
|
476 } |
|
477 |
|
478 void GlxCoverFlow::clearCurrentModel() |
|
479 { |
|
480 qDebug("GlxCoverFlow::clearCurrentModel "); |
|
481 if ( mModel ) { |
|
482 disconnect( mModel, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ), this, SLOT( dataChanged( QModelIndex, QModelIndex ) ) ); |
|
483 disconnect( mModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( rowsInserted( QModelIndex, int, int ) ) ); |
|
484 disconnect( mModel, SIGNAL( rowsRemoved( QModelIndex, int, int) ), this, SLOT( rowsRemoved( QModelIndex, int, int ) ) ); |
|
485 disconnect( mModel, SIGNAL( destroyed() ), this, SLOT( modelDestroyed() ) ); |
|
486 mModel = NULL ; |
|
487 } |
|
488 } |
|
489 |
|
490 void GlxCoverFlow::initializeNewModel() |
|
491 { |
|
492 qDebug("GlxCoverFlow::initializeNewModel" ); |
|
493 if ( mModel ) { |
|
494 connect( mModel, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ), this, SLOT( dataChanged( QModelIndex, QModelIndex ) ) ); |
|
495 connect( mModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( rowsInserted( QModelIndex, int, int ) ) ); |
|
496 connect( mModel, SIGNAL( rowsRemoved( QModelIndex, int, int) ), this, SLOT( rowsRemoved( QModelIndex, int, int ) ) ); |
|
497 connect( mModel, SIGNAL( destroyed() ), this, SLOT( modelDestroyed() ) ); |
|
498 } |
|
499 } |
|
500 |
|
501 void GlxCoverFlow::resetCoverFlow() |
|
502 { |
|
503 qDebug("GlxCoverFlow::resetCoverFlow model %u", mModel ); |
|
504 setRows(); |
|
505 setStripLen(); |
|
506 if ( mModel ) { |
|
507 loadIconItems( ) ; |
|
508 } |
|
509 } |
|
510 |
|
511 void GlxCoverFlow::partiallyClean() |
|
512 { |
|
513 qDebug("GlxCoverFlow::partiallyClean Enter"); |
|
514 clearCurrentModel(); //during the animation data update will not cause the crash |
|
515 mIsInit = false; |
|
516 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
|
517 if ( mSelItemIndex != i){ |
|
518 delete mIconItem[i] ; |
|
519 mIconItem[i] = NULL; |
|
520 } |
|
521 } |
|
522 } |
|
523 |
|
524 void GlxCoverFlow::partiallyCreate( QAbstractItemModel *model, QSize itemSize, int posY ) |
|
525 { |
|
526 qDebug("GlxCoverFlow::resetpartiallyCreated poxY %d", posY ); |
|
527 mIconItem[2]->setSize ( itemSize ); |
|
528 mIconItem[2]->setPos ( QPointF ( 0, posY ) ); |
|
529 mModel = model ; |
|
530 mSelIndex = getFocusIndex(); |
|
531 mIconItem[2]->setIcon( getIcon( mSelIndex ) ) ; |
|
532 mModel = NULL; |
|
533 } |
|
534 |
|
535 GlxCoverFlow::~GlxCoverFlow() |
|
536 { |
|
537 qDebug("GlxCoverFlow::~GlxCoverFlow model " ); |
|
538 ClearCoverFlow(); |
|
539 disconnect( this, SIGNAL( autoLeftMoveSignal() ), this, SLOT( autoLeftMove() ) ); |
|
540 disconnect( this, SIGNAL( autoRightMoveSignal() ), this, SLOT( autoRightMove() ) ); |
|
541 } |
|
542 |
|
543 void GlxCoverFlow::ClearCoverFlow() |
|
544 { |
|
545 qDebug("GlxCoverFlow::ClearCoverFlow " ); |
|
546 mIsInit = false; |
|
547 clearCurrentModel(); |
|
548 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
|
549 if(mIconItem[i] != NULL ) { |
|
550 delete mIconItem[i] ; |
|
551 mIconItem[i] = NULL; |
|
552 } |
|
553 } |
|
554 } |
|
555 |
|
556 int GlxCoverFlow::getSubState() |
|
557 { |
|
558 int substate = NO_FULLSCREEN_S; |
|
559 QVariant variant = mModel->data( mModel->index(0,0), GlxSubStateRole ); |
|
560 if ( variant.isValid() && variant.canConvert<int> () ) { |
|
561 substate = variant.value<int>(); |
|
562 } |
|
563 return substate; |
|
564 } |
|
565 |
|
566 void GlxCoverFlow::zoomStarted(int index) |
|
567 { |
|
568 Q_UNUSED(index) |
|
569 emit coverFlowEvent( ZOOM_START_EVENT ); |
|
570 stopAnimation(); |
|
571 mZoomOn = true; |
|
572 } |
|
573 |
|
574 void GlxCoverFlow::zoomFinished( int index ) |
|
575 { |
|
576 mZoomOn = false; |
|
577 playAnimation(); |
|
578 indexChanged(index); |
|
579 } |
|
580 |
|
581 void GlxCoverFlow::timerEvent( QTimerEvent *event ) |
|
582 { |
|
583 if(mTimerId == event->timerId()) { |
|
584 killTimer( mTimerId ); |
|
585 mTimerId = 0; |
|
586 emit coverFlowEvent( TAP_EVENT ); |
|
587 } |
|
588 } |
|
589 |
|
590 int GlxCoverFlow::getFocusIndex() |
|
591 { |
|
592 QVariant variant = mModel->data( mModel->index( 0, 0 ), GlxFocusIndexRole ) ; |
|
593 if ( variant.isValid() && variant.canConvert< int > () ) { |
|
594 return variant.value< int > (); |
|
595 } |
|
596 return -1; |
|
597 } |
|
598 |
|
599 HbIcon GlxCoverFlow::getIcon( int index ) |
|
600 { |
|
601 QVariant variant = mModel->data( mModel->index( index, 0 ), GlxFsImageRole ); |
|
602 if ( variant.isValid() && variant.canConvert< HbIcon > () ) { |
|
603 return variant.value<HbIcon> () ; |
|
604 } |
|
605 return HbIcon() ; |
|
606 } |
|
607 |
|
608 QString GlxCoverFlow::getUri( int index ) |
|
609 { |
|
610 QVariant variant = mModel->data( mModel->index( index, 0 ), GlxUriRole ); |
|
611 if ( variant.isValid() && variant.canConvert< QString > () ){ |
|
612 return variant.value< QString > () ; |
|
613 } |
|
614 return QString(); |
|
615 } |
|
616 |
|
617 bool GlxCoverFlow::isAnimatedImage( int index ) |
|
618 { |
|
619 int frameCount = 0; |
|
620 QVariant variant = mModel->data( mModel->index( index, 0 ), GlxFrameCount ); |
|
621 if ( variant.isValid() && variant.canConvert< int > () ) { |
|
622 frameCount = variant.value< int > () ; |
|
623 } |
|
624 return frameCount > 1 ? true : false ; |
|
625 } |