|
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 |
|
25 //User Includes |
|
26 #include <glxmodelparm.h> |
|
27 #include <glxcoverflow.h> |
|
28 |
|
29 |
|
30 const int KMoveX = 60; //coverflow auto move speed |
|
31 |
|
32 GlxCoverFlow::GlxCoverFlow(QGraphicsItem *parent ) : HbScrollArea(parent), mSelItemIndex (0), |
|
33 mRows(0), mSelIndex (0), mStripLen (0), mCurrentPos(0), |
|
34 mItemSize (QSize(0,0)), mModel ( NULL), mMoveDir(NO_MOVE), rotAngle(0) |
|
35 { |
|
36 //TO:DO through exception |
|
37 qDebug("GlxCoverFlow::GlxCoverFlow"); |
|
38 } |
|
39 |
|
40 void GlxCoverFlow::setCoverFlow() |
|
41 { |
|
42 |
|
43 qDebug("GlxCoverFlow::setCoverFlow"); |
|
44 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
|
45 mIconItem[i] = new HbIconItem(this); |
|
46 mIconItem[i]->setBrush(QBrush(Qt::black)); |
|
47 mIconItem[i]->setSize(QSize(0,0)); |
|
48 } |
|
49 mUiOn = FALSE; |
|
50 mBounceBackDeltaX = 10; |
|
51 connect( this, SIGNAL( autoLeftMoveSignal() ), this, SLOT( autoLeftMove() ), Qt::QueuedConnection ); |
|
52 connect( this, SIGNAL( autoRightMoveSignal() ), this, SLOT( autoRightMove() ), Qt::QueuedConnection ); |
|
53 HbEffect::add( QString("HbIconItem"), QString(":/data/transitionrotate0.fxml"), QString( "RotateImage0" )); |
|
54 HbEffect::add( QString("HbIconItem"), QString(":/data/transitionrotate90.fxml"), QString( "RotateImage90" )); |
|
55 HbEffect::add( QString("HbIconItem"), QString(":/data/transitionrotate180.fxml"), QString( "RotateImage180" )); |
|
56 HbEffect::add( QString("HbIconItem"), QString(":/data/transitionrotate270.fxml"), QString( "RotateImage270" )); |
|
57 } |
|
58 |
|
59 void GlxCoverFlow::setItemSize(QSize &size) |
|
60 { |
|
61 qDebug("GlxCoverFlow::setSize width = %d",size.width() ); |
|
62 if( mItemSize != size) { |
|
63 mItemSize = size; |
|
64 resetCoverFlow(); |
|
65 } |
|
66 } |
|
67 |
|
68 void GlxCoverFlow::setModel(QAbstractItemModel *model) |
|
69 { |
|
70 qDebug("GlxCoverFlow::setModel model change = %d", model ); |
|
71 |
|
72 if ( model == mModel) { |
|
73 return ; |
|
74 } |
|
75 |
|
76 clearCurrentModel(); |
|
77 mModel = model; |
|
78 initializeNewModel(); |
|
79 resetCoverFlow(); |
|
80 } |
|
81 |
|
82 void GlxCoverFlow::indexChanged( int index ) |
|
83 { |
|
84 qDebug("GlxCoverFlow::indexChanged index = %d mSelIndex = %d ",index, mSelIndex ); |
|
85 if ( index != mSelIndex && mModel) { |
|
86 loadIconItems(); |
|
87 if(rotAngle) { |
|
88 rotAngle = 0; |
|
89 //HbEffect::start(mIconItem[mSelItemIndex], QString("HbIconItem"), QString("RotateImage270"), this, "rotationEffectFinished" ); |
|
90 mIconItem[mSelItemIndex]->resetTransform(); |
|
91 mIconItem[mSelItemIndex]->resize(mItemSize); |
|
92 } |
|
93 } |
|
94 } |
|
95 |
|
96 void GlxCoverFlow::rotateImage () |
|
97 { |
|
98 qDebug("GlxCoverFlow::rotateImage "); |
|
99 if(rotAngle == 0) |
|
100 { |
|
101 HbEffect::start(mIconItem[mSelItemIndex], QString("HbIconItem"), QString("RotateImage0"), this, "rotationEffectFinished" ); |
|
102 } |
|
103 if(rotAngle == 90) |
|
104 { |
|
105 HbEffect::start(mIconItem[mSelItemIndex], QString("HbIconItem"), QString("RotateImage90"), this, "rotationEffectFinished" ); |
|
106 } |
|
107 if(rotAngle == 180) |
|
108 { |
|
109 HbEffect::start(mIconItem[mSelItemIndex], QString("HbIconItem"), QString("RotateImage180"), this, "rotationEffectFinished" ); |
|
110 } |
|
111 if(rotAngle == 270) |
|
112 { |
|
113 HbEffect::start(mIconItem[mSelItemIndex], QString("HbIconItem"), QString("RotateImage270"), this, "rotationEffectFinished" ); |
|
114 } |
|
115 |
|
116 rotAngle += 90; |
|
117 rotAngle %= 360; |
|
118 |
|
119 } |
|
120 |
|
121 void GlxCoverFlow::rotationEffectFinished (const HbEffect::EffectStatus &status) |
|
122 { |
|
123 Q_UNUSED(status) |
|
124 |
|
125 qDebug("GlxCoverFlow::rotationEffectFinished"); |
|
126 QSize itemSize = mItemSize; |
|
127 if((rotAngle == 90) || (rotAngle == 270)) { |
|
128 itemSize.transpose(); |
|
129 } |
|
130 mIconItem[mSelItemIndex]->resetTransform(); |
|
131 mIconItem[mSelItemIndex]->resize(itemSize); |
|
132 mIconItem[mSelItemIndex]->setPos((mItemSize.width() - itemSize.width())/2, (mItemSize.height() - itemSize.height())/2 ); |
|
133 QTransform rotateTransform = mIconItem[mSelItemIndex]->transform(); |
|
134 rotateTransform.translate((mItemSize.width()/2)-((mItemSize.width() - itemSize.width())/2),(mItemSize.height()/2) - ((mItemSize.height() - itemSize.height())/2)); |
|
135 rotateTransform.rotate(rotAngle); |
|
136 rotateTransform.translate(-((mItemSize.width()/2)-((mItemSize.width() - itemSize.width())/2)),-((mItemSize.height()/2) - ((mItemSize.height() - itemSize.height())/2))); |
|
137 mIconItem[mSelItemIndex]->setTransform(rotateTransform); |
|
138 |
|
139 } |
|
140 |
|
141 void GlxCoverFlow::panGesture ( const QPointF & delta ) |
|
142 { |
|
143 qDebug("GlxCoverFlow::panGesture deltaX= %d", (int)delta.x()); |
|
144 |
|
145 move((int) delta.x()); |
|
146 if( delta.x() > 0 ) { |
|
147 mMoveDir = RIGHT_MOVE; |
|
148 } |
|
149 else if ( delta.x() < 0) { |
|
150 mMoveDir = LEFT_MOVE; |
|
151 } |
|
152 |
|
153 if ( mUiOn == TRUE ) { |
|
154 emit coverFlowEvent( PANNING_START_EVENT ); |
|
155 mUiOn = FALSE; |
|
156 } |
|
157 } |
|
158 |
|
159 void GlxCoverFlow::leftGesture(int value) |
|
160 { |
|
161 Q_UNUSED(value); |
|
162 qDebug("GlxCoverFlow::leftGesture CurrentPos= %d value %d", mCurrentPos, value); |
|
163 mMoveDir = NO_MOVE; |
|
164 mBounceBackDeltaX = mItemSize.width() >> 2; |
|
165 emit autoLeftMoveSignal(); |
|
166 if ( mUiOn == TRUE ) { |
|
167 mUiOn = FALSE; |
|
168 emit coverFlowEvent( PANNING_START_EVENT ); |
|
169 } |
|
170 } |
|
171 |
|
172 void GlxCoverFlow::rightGesture(int value) |
|
173 { |
|
174 Q_UNUSED(value); |
|
175 qDebug("GlxCoverFlow::rightGesture CurrentPos= %d value %d ", mCurrentPos, value); |
|
176 mMoveDir = NO_MOVE; |
|
177 mBounceBackDeltaX = mItemSize.width() >> 2; |
|
178 emit autoRightMoveSignal(); |
|
179 if ( mUiOn == TRUE ) { |
|
180 mUiOn = FALSE; |
|
181 emit coverFlowEvent( PANNING_START_EVENT ); |
|
182 } |
|
183 } |
|
184 |
|
185 void GlxCoverFlow::longPressGesture(const QPointF &point) |
|
186 { |
|
187 qDebug("GlxCoverFlow::longPressGesture x = %d y = %d", point.x(), point.y()); |
|
188 mMoveDir = LONGPRESS_MOVE; |
|
189 } |
|
190 |
|
191 void GlxCoverFlow::dataChanged(QModelIndex startIndex, QModelIndex endIndex) |
|
192 { |
|
193 Q_UNUSED(endIndex); |
|
194 qDebug("GlxCoverFlow::dataChanged startIndex = %d mSelIndex = %d ", startIndex.row(), mSelIndex ); |
|
195 |
|
196 int index = 0; |
|
197 for (int i = 0; i < NBR_ICON_ITEM ; i++) { |
|
198 index = calculateIndex( mSelIndex + i - 2); |
|
199 if ( index == startIndex.row() ) { |
|
200 index = ( mSelItemIndex + i - 2 + NBR_ICON_ITEM ) % NBR_ICON_ITEM; |
|
201 qDebug("GlxCoverFlow::dataChanged index = %d mSelItemIndex = %d ", index, mSelItemIndex ); |
|
202 |
|
203 QVariant variant = mModel->data( startIndex, GlxFsImageRole ); |
|
204 if ( variant.isValid() && variant.canConvert<HbIcon> () ) { |
|
205 mIconItem[index]->setIcon ( variant.value<HbIcon>() ) ; |
|
206 } |
|
207 else { |
|
208 mIconItem[index]->setIcon( HbIcon() ); |
|
209 } |
|
210 //break; |
|
211 } |
|
212 } |
|
213 } |
|
214 |
|
215 void GlxCoverFlow::rowsInserted(const QModelIndex &parent, int start, int end) |
|
216 { |
|
217 qDebug("GlxCoverFlow::rowsInserted"); |
|
218 Q_UNUSED(parent); |
|
219 Q_UNUSED(start); |
|
220 Q_UNUSED(end); |
|
221 resetCoverFlow(); |
|
222 emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ; |
|
223 } |
|
224 |
|
225 void GlxCoverFlow::rowsRemoved(const QModelIndex &parent, int start, int end) |
|
226 { |
|
227 Q_UNUSED(parent); |
|
228 Q_UNUSED(start); |
|
229 Q_UNUSED(end); |
|
230 qDebug("GlxCoverFlow::rowsRemoved model %d", mModel); |
|
231 |
|
232 if ( mModel->rowCount() <= 0 ) { |
|
233 emit coverFlowEvent( EMPTY_ROW_EVENT ); |
|
234 } |
|
235 else { |
|
236 resetCoverFlow(); |
|
237 emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ; |
|
238 } |
|
239 } |
|
240 |
|
241 void GlxCoverFlow::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
242 { |
|
243 Q_UNUSED(event); |
|
244 qDebug("GlxCoverFlow::mousePressEvent"); |
|
245 mMoveDir = TAP_MOVE; |
|
246 } |
|
247 |
|
248 void GlxCoverFlow::mouseReleaseEvent (QGraphicsSceneMouseEvent *event) |
|
249 { |
|
250 Q_UNUSED(event); |
|
251 qDebug("GlxCoverFlow::mouseReleaseEvent move dir %d", mMoveDir); |
|
252 |
|
253 switch( mMoveDir ) { |
|
254 case NO_MOVE : |
|
255 break; |
|
256 |
|
257 case TAP_MOVE : |
|
258 mMoveDir = NO_MOVE; |
|
259 emit coverFlowEvent( TAP_EVENT ); |
|
260 break; |
|
261 |
|
262 case LEFT_MOVE: |
|
263 mMoveDir = NO_MOVE; |
|
264 emit autoLeftMoveSignal(); |
|
265 break ; |
|
266 |
|
267 case RIGHT_MOVE : |
|
268 mMoveDir = NO_MOVE; |
|
269 emit autoRightMoveSignal(); |
|
270 break; |
|
271 |
|
272 default: |
|
273 break; |
|
274 } |
|
275 } |
|
276 |
|
277 void GlxCoverFlow::autoLeftMove() |
|
278 { |
|
279 qDebug("GlxCoverFlow::autoLeftMove "); |
|
280 int width = mItemSize.width() ; |
|
281 |
|
282 qDebug("GlxCoverFlow::autoLeftMove current pos = %d mBounceBackDeltaX x = %d", mCurrentPos, mBounceBackDeltaX); |
|
283 //for bounce back effect for last image ( it will do the back) |
|
284 if ( ( mCurrentPos + width ) > ( mStripLen + mBounceBackDeltaX ) && mMoveDir == NO_MOVE ) { |
|
285 mMoveDir = LEFT_MOVE; |
|
286 mBounceBackDeltaX = 10; |
|
287 autoRightMoveSignal(); |
|
288 return ; |
|
289 } |
|
290 |
|
291 int deltaX = width - mCurrentPos % width ; |
|
292 int moveX = deltaX > KMoveX ? KMoveX : deltaX; |
|
293 |
|
294 qDebug("GlxCoverFlow::autoLeftMove delta x = %d current pos = %d move x = %d", deltaX, mCurrentPos, moveX); |
|
295 |
|
296 move (-moveX);//move the image |
|
297 deltaX -= moveX; //To know the auto move is required or not |
|
298 |
|
299 if ( deltaX ) { |
|
300 emit autoLeftMoveSignal(); |
|
301 } |
|
302 else { |
|
303 //for bounce back of first image |
|
304 if ( mMoveDir == RIGHT_MOVE ) { |
|
305 emit autoRightMoveSignal(); |
|
306 return; |
|
307 } |
|
308 int selIndex = mCurrentPos / width ; |
|
309 if ( mRows == 1 || selIndex != mSelIndex ) { |
|
310 if(rotAngle) { |
|
311 rotAngle = 0; |
|
312 //HbEffect::start(mIconItem[mSelItemIndex], QString("HbIconItem"), QString("RotateImage270"), this, "rotationEffectFinished" ); |
|
313 mIconItem[mSelItemIndex]->resetTransform(); |
|
314 mIconItem[mSelItemIndex]->resize(mItemSize); |
|
315 mIconItem[mSelItemIndex]->setPos(- mItemSize.width(), 0); |
|
316 } |
|
317 mSelIndex = selIndex; |
|
318 mSelItemIndex = ( ++mSelItemIndex ) % NBR_ICON_ITEM; |
|
319 selIndex = ( mSelItemIndex + 2 ) % NBR_ICON_ITEM; |
|
320 updateIconItem( mSelIndex + 2, selIndex, width * 2 ) ; |
|
321 emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ; |
|
322 } |
|
323 mMoveDir = NO_MOVE; |
|
324 mBounceBackDeltaX = 10; |
|
325 } |
|
326 } |
|
327 |
|
328 void GlxCoverFlow::autoRightMove() |
|
329 { |
|
330 qDebug("GlxCoverFlow::autoRightMove "); |
|
331 int width = mItemSize.width() ; |
|
332 int diffX = mStripLen - mCurrentPos ; |
|
333 |
|
334 //for bounce back effect for back image ( it will do the back) |
|
335 qDebug("GlxCoverFlow::autoRightMove diffX x = %d current pos = %d mBounceBackDeltaX x = %d", diffX, mCurrentPos, mBounceBackDeltaX); |
|
336 if ( diffX > mBounceBackDeltaX && diffX < width && mMoveDir == NO_MOVE ){ |
|
337 mMoveDir = RIGHT_MOVE; |
|
338 mBounceBackDeltaX = 10; |
|
339 autoLeftMoveSignal(); |
|
340 return ; |
|
341 } |
|
342 |
|
343 int deltaX = mCurrentPos % width ; |
|
344 //in the case of deltaX == 0 ( right flick case ) complete image should move |
|
345 deltaX = deltaX ? deltaX : width ; |
|
346 int moveX = deltaX > KMoveX ? KMoveX : deltaX; |
|
347 |
|
348 qDebug("GlxCoverFlow::autoRightMove delta x = %d current pos = %d move x = %d", deltaX, mCurrentPos, moveX); |
|
349 |
|
350 move (moveX); |
|
351 deltaX -= moveX; |
|
352 |
|
353 if ( deltaX ) { |
|
354 emit autoRightMoveSignal(); |
|
355 } |
|
356 else { |
|
357 //for bounce back of last image |
|
358 if ( mMoveDir == LEFT_MOVE ) { |
|
359 emit autoLeftMoveSignal(); |
|
360 return; |
|
361 } |
|
362 int selIndex = mCurrentPos / width ; |
|
363 if ( mRows == 1 || selIndex != mSelIndex ) { |
|
364 if(rotAngle) { |
|
365 rotAngle = 0; |
|
366 //HbEffect::start(mIconItem[mSelItemIndex], QString("HbIconItem"), QString("RotateImage270"), this, "rotationEffectFinished" ); |
|
367 mIconItem[mSelItemIndex]->resetTransform(); |
|
368 mIconItem[mSelItemIndex]->resize(mItemSize); |
|
369 mIconItem[mSelItemIndex]->setPos(mItemSize.width(), 0); |
|
370 |
|
371 } |
|
372 mSelIndex = selIndex; |
|
373 mSelItemIndex = ( mSelItemIndex == 0 ) ? NBR_ICON_ITEM -1 : --mSelItemIndex; |
|
374 selIndex = ( mSelItemIndex + 3 ) % NBR_ICON_ITEM; |
|
375 updateIconItem( mSelIndex - 2, selIndex, - width * 2 ) ; |
|
376 emit changeSelectedIndex ( mModel->index ( mSelIndex, 0 ) ) ; |
|
377 } |
|
378 mMoveDir = NO_MOVE; |
|
379 mBounceBackDeltaX = 10; |
|
380 } |
|
381 } |
|
382 |
|
383 void GlxCoverFlow::move(int value) |
|
384 { |
|
385 qDebug("GlxCoverFlow::move "); |
|
386 QPointF pos(0,0); |
|
387 |
|
388 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
|
389 pos.setX( mIconItem[i]->pos().x() + value); |
|
390 pos.setY(mIconItem[i]->pos().y()); |
|
391 mIconItem[i]->setPos(pos); |
|
392 } |
|
393 |
|
394 mCurrentPos -= value; |
|
395 if ( mCurrentPos < 0 ) { |
|
396 mCurrentPos += mStripLen; |
|
397 } |
|
398 else if ( mCurrentPos >= mStripLen ) { |
|
399 mCurrentPos -= mStripLen; |
|
400 } |
|
401 qDebug("GlxCoverFlow::Move value = %d current pos = %d", value, mCurrentPos); |
|
402 } |
|
403 |
|
404 void GlxCoverFlow::setRows() |
|
405 { |
|
406 qDebug("GlxCoverFlow::setRows "); |
|
407 if (mModel) { |
|
408 mRows = mModel->rowCount(); |
|
409 } |
|
410 else { |
|
411 mRows = 0; |
|
412 } |
|
413 qDebug("GlxCoverFlow::setRows number of rows = %d", mRows); |
|
414 } |
|
415 |
|
416 void GlxCoverFlow::setStripLen() |
|
417 { |
|
418 qDebug("GlxCoverFlow::setStripLen "); |
|
419 mStripLen = mRows * mItemSize.width(); |
|
420 qDebug("GlxCoverFlow::setStripLen rows = %d, striplen %d", mRows, mStripLen); |
|
421 } |
|
422 |
|
423 int GlxCoverFlow::calculateIndex(int index) |
|
424 { |
|
425 qDebug("GlxCoverFlow::calculateIndex index = %d, mRows = %d", index, mRows); |
|
426 |
|
427 if ( mRows == 1 ) |
|
428 return 0; |
|
429 |
|
430 if ( index < 0 ) |
|
431 return ( index + mRows ); |
|
432 |
|
433 if ( index >= mRows ) |
|
434 return ( index - mRows ) ; |
|
435 |
|
436 return index; |
|
437 } |
|
438 |
|
439 void GlxCoverFlow::loadIconItems() |
|
440 { |
|
441 qDebug("GlxCoverFlow::loadIconItems "); |
|
442 int index = 0; |
|
443 QVariant variant = mModel->data( mModel->index(0,0), GlxFocusIndexRole ); |
|
444 if ( variant.isValid() && variant.canConvert<int> () ) { |
|
445 mSelIndex = variant.value<int>(); |
|
446 } |
|
447 |
|
448 qDebug("GlxCoverFlow::loadIconItems index = %d, width = %d", mSelIndex, size().width() ); |
|
449 |
|
450 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
|
451 index = calculateIndex ( mSelIndex - 2 + i) ; |
|
452 QVariant variant = mModel->data( mModel->index(index, 0), GlxFsImageRole ); |
|
453 if ( variant.isValid() && variant.canConvert<HbIcon> () ) { |
|
454 mIconItem[i]->setIcon ( variant.value<HbIcon>() ) ; |
|
455 } |
|
456 else { |
|
457 mIconItem[i]->setIcon( HbIcon() ); |
|
458 } |
|
459 mIconItem[i]->setSize ( mItemSize ); |
|
460 mIconItem[i]->setPos ( QPointF ( (i - 2) * mItemSize.width(), 0) ); |
|
461 } |
|
462 |
|
463 mSelItemIndex = 2; |
|
464 mCurrentPos = mItemSize.width() * mSelIndex; |
|
465 } |
|
466 |
|
467 void GlxCoverFlow::updateIconItem (qint16 selIndex, qint16 selItemIndex, qint16 posX) |
|
468 { |
|
469 qDebug("GlxCoverFlow::updateIconItem selIndex = %d, selIconIndex = %d posX = %d", selIndex, selItemIndex, posX ); |
|
470 mIconItem[selItemIndex]->setPos(QPointF(posX, 0)); |
|
471 |
|
472 selIndex = calculateIndex( selIndex ); |
|
473 |
|
474 QVariant variant = mModel->data( mModel->index(selIndex, 0), GlxFsImageRole ); |
|
475 if ( variant.isValid() && variant.canConvert<HbIcon> () ) { |
|
476 mIconItem[selItemIndex]->setIcon ( variant.value<HbIcon>() ) ; |
|
477 } |
|
478 else { |
|
479 mIconItem[selItemIndex]->setIcon( HbIcon() ); |
|
480 } |
|
481 mIconItem[selItemIndex]->setSize ( mItemSize ); |
|
482 } |
|
483 |
|
484 |
|
485 void GlxCoverFlow::clearCurrentModel() |
|
486 { |
|
487 qDebug("GlxCoverFlow::clearCurrentModel "); |
|
488 if ( mModel ) { |
|
489 disconnect( mModel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ), this, SLOT( dataChanged(QModelIndex,QModelIndex) ) ); |
|
490 disconnect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted(QModelIndex,int,int))); |
|
491 disconnect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); |
|
492 mModel = NULL ; |
|
493 } |
|
494 /* |
|
495 disconnect(mModel, SIGNAL(destroyed()), this, SLOT(_q_modelDestroyed())); |
|
496 disconnect(mModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int))); |
|
497 */ |
|
498 } |
|
499 |
|
500 void GlxCoverFlow::initializeNewModel() |
|
501 { |
|
502 qDebug("GlxCoverFlow::initializeNewModel" ); |
|
503 if ( mModel ) { |
|
504 connect( mModel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ), this, SLOT( dataChanged(QModelIndex,QModelIndex) ) ); |
|
505 connect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted(QModelIndex,int,int))); |
|
506 connect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); |
|
507 } |
|
508 } |
|
509 |
|
510 void GlxCoverFlow::resetCoverFlow() |
|
511 { |
|
512 qDebug("GlxCoverFlow::resetCoverFlow model %u", mModel ); |
|
513 setRows(); |
|
514 setStripLen(); |
|
515 if ( mModel ) { |
|
516 loadIconItems( ) ; |
|
517 } |
|
518 } |
|
519 |
|
520 void GlxCoverFlow::partiallyClean() |
|
521 { |
|
522 qDebug("GlxCoverFlow::partiallyClean Enter"); |
|
523 clearCurrentModel(); //during the animation data update will not cause the crash |
|
524 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
|
525 if ( mSelItemIndex != i){ |
|
526 delete mIconItem[i] ; |
|
527 mIconItem[i] = NULL; |
|
528 } |
|
529 } |
|
530 } |
|
531 |
|
532 void GlxCoverFlow::partiallyCreate(QAbstractItemModel *model, QSize itemSize) |
|
533 { |
|
534 qDebug("GlxCoverFlow::resetpartiallyCreated"); |
|
535 mIconItem[2]->setSize ( itemSize ); |
|
536 mIconItem[2]->setPos ( QPointF ( 0, 0) ); |
|
537 |
|
538 QVariant variant = model->data( model->index(0,0), GlxFocusIndexRole ); |
|
539 if ( variant.isValid() && variant.canConvert<int> () ) { |
|
540 mSelIndex = variant.value<int>(); |
|
541 qDebug("GlxCoverFlow::partiallyCreated index mSelIndex=%d",mSelIndex); |
|
542 } |
|
543 |
|
544 variant = model->data( model->index(mSelIndex, 0), GlxFsImageRole ); |
|
545 if ( variant.isValid() && variant.canConvert<HbIcon> () ) { |
|
546 mIconItem[2]->setIcon ( variant.value<HbIcon>() ) ; |
|
547 qDebug("#########################GlxCoverFlow::partiallyCreated,ICON PRES##################"); |
|
548 } |
|
549 } |
|
550 |
|
551 GlxCoverFlow::~GlxCoverFlow() |
|
552 { |
|
553 qDebug("GlxCoverFlow::~GlxCoverFlow model " ); |
|
554 } |
|
555 |
|
556 |
|
557 void GlxCoverFlow::ClearCoverFlow() |
|
558 { |
|
559 qDebug("GlxCoverFlow::ClearCoverFlow " ); |
|
560 disconnect( this, SIGNAL( autoLeftMoveSignal() ), this, SLOT( autoLeftMove() ) ); |
|
561 disconnect( this, SIGNAL( autoRightMoveSignal() ), this, SLOT( autoRightMove() ) ); |
|
562 clearCurrentModel(); |
|
563 for ( qint8 i = 0; i < NBR_ICON_ITEM ; i++ ) { |
|
564 if(mIconItem[i] != NULL ) |
|
565 delete mIconItem[i] ; |
|
566 } |
|
567 HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionrotate0.fxml"), QString( "RotateImage0" )); |
|
568 HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionrotate90.fxml"), QString( "RotateImage90" )); |
|
569 HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionrotate180.fxml"), QString( "RotateImage180" )); |
|
570 HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionrotate270.fxml"), QString( "RotateImage270" )); |
|
571 } |