26 #include <hbmainwindow.h> |
26 #include <hbmainwindow.h> |
27 #include <hbdocumentloader.h> |
27 #include <hbdocumentloader.h> |
28 #include <QAbstractItemModel> |
28 #include <QAbstractItemModel> |
29 #include <QGesture> |
29 #include <QGesture> |
30 #include <hbpangesture.h> |
30 #include <hbpangesture.h> |
|
31 #include <hblabel.h> |
31 |
32 |
32 //User Includes |
33 //User Includes |
33 #include "glxicondefs.h" //Contains the icon names/Ids |
34 #include "glxicondefs.h" //Contains the icon names/Ids |
34 #include "glxmodelparm.h" |
35 #include "glxmodelparm.h" |
35 #include "glxeffectengine.h" |
36 #include "glxeffectengine.h" |
36 #include "glxdocloaderdefs.h" |
37 #include "glxdocloaderdefs.h" |
37 #include "glxslideshowwidget.h" |
38 #include "glxslideshowwidget.h" |
38 #include "glxsettinginterface.h" |
39 #include "glxsettinginterface.h" |
|
40 #include "glxlocalisationstrings.h" |
39 #include "glxlog.h" |
41 #include "glxlog.h" |
40 #include "glxtracer.h" |
42 #include "glxtracer.h" |
41 |
43 |
42 |
44 |
43 GlxSlideShowWidget::GlxSlideShowWidget( QGraphicsItem *parent ) |
45 GlxSlideShowWidget::GlxSlideShowWidget( QGraphicsItem *parent ) |
44 : HbWidget(parent), |
46 : HbWidget( parent ), |
45 mEffectEngine(NULL), |
47 mEffectEngine( NULL ), |
46 mSettings( NULL ), |
48 mSettings( NULL ), |
47 mContinueButton(NULL), |
49 mContinueButton( NULL ), |
48 mItemIndex(1), |
50 mErrorNote( NULL ), |
49 mSelIndex(0), |
51 mItemIndex( 1 ), |
50 mSlideTimer(NULL), |
52 mSlideTimer( NULL ), |
51 mModel(NULL) |
53 mModel( NULL ), |
|
54 mSlideShowItemCount( 0 ) |
52 { |
55 { |
53 TRACER("GlxSlideShowWidget::GlxSlideShowWidget()"); |
56 TRACER("GlxSlideShowWidget::GlxSlideShowWidget()"); |
54 mSettings = GlxSettingInterface::instance() ; //no owner ship |
57 mSettings = GlxSettingInterface::instance() ; //no owner ship |
55 grabGesture( Qt::PanGesture ); |
58 grabGesture( Qt::PanGesture ); |
56 grabGesture( Qt::TapGesture ); |
59 grabGesture( Qt::TapGesture ); |
64 //create the effect engine |
67 //create the effect engine |
65 mEffectEngine = new GlxEffectEngine(); |
68 mEffectEngine = new GlxEffectEngine(); |
66 |
69 |
67 // Now load the view and the contents. |
70 // Now load the view and the contents. |
68 // and then set the play icon to the button |
71 // and then set the play icon to the button |
69 mContinueButton = static_cast<HbPushButton*>(DocLoader->findWidget(GLXSLIDESHOW_PB)); |
72 mContinueButton = static_cast<HbPushButton*>( DocLoader->findWidget( GLXSLIDESHOW_PB ) ); |
70 mContinueButton->setIcon(HbIcon(GLXICON_PLAY)); |
73 mContinueButton->setIcon( HbIcon( GLXICON_PLAY ) ); |
71 mContinueButton->hide(); |
74 mContinueButton->hide(); |
72 mIsPause = false; |
75 mIsPause = false; |
73 |
76 |
74 for ( int i = 0; i < NBR_ITEM ; i++) { |
77 for ( int i = 0; i < NBR_ITEM ; i++) { |
75 mIconItems[i] = new HbIconItem(this); |
78 mSelIndex[ i ] = -1; |
76 mIconItems[i]->setBrush(QBrush(Qt::black)); |
79 mIconItems[ i ] = new HbIconItem( this ); |
77 mIconItems[i]->setAlignment( Qt::AlignCenter ); |
80 mIconItems[ i ]->setBrush( QBrush( Qt::black ) ); |
78 mIconItems[i]->setObjectName( QString( "SlideShowIcon%1" ).arg( i ) ); |
81 mIconItems[ i ]->setAlignment( Qt::AlignCenter ); |
|
82 mIconItems[ i ]->setObjectName( QString( "SlideShowIcon%1" ).arg( i ) ); |
79 } |
83 } |
80 |
84 |
81 mSlideTimer = new QTimer(); |
85 mSlideTimer = new QTimer(); |
82 mItemList.clear(); |
86 mItemList.clear(); |
83 |
87 |
109 void GlxSlideShowWidget::cleanUp() |
113 void GlxSlideShowWidget::cleanUp() |
110 { |
114 { |
111 TRACER("GlxSlideShowWidget::cleanUp()"); |
115 TRACER("GlxSlideShowWidget::cleanUp()"); |
112 removeConnections(); |
116 removeConnections(); |
113 |
117 |
114 if(mEffectEngine) { |
118 if( mEffectEngine ) { |
115 mEffectEngine->deRegisterEffect( QString("HbIconItem") ); |
119 mEffectEngine->deRegisterEffect( QString("HbIconItem") ); |
116 delete mEffectEngine; |
120 delete mEffectEngine; |
117 mEffectEngine = NULL; |
121 mEffectEngine = NULL; |
118 } |
122 } |
119 |
123 |
120 for ( int i = 0; i < NBR_ITEM ; i++) { |
124 for ( int i = 0; i < NBR_ITEM ; i++) { |
121 delete mIconItems[i] ; |
125 delete mIconItems[i] ; |
122 mIconItems[i] = NULL; |
126 mIconItems[i] = NULL; |
123 } |
127 } |
124 |
128 |
125 if(mSlideTimer) { |
129 if( mSlideTimer ) { |
126 delete mSlideTimer; |
130 delete mSlideTimer; |
127 mSlideTimer = NULL; |
131 mSlideTimer = NULL; |
|
132 } |
|
133 |
|
134 if ( mErrorNote ) { |
|
135 delete mErrorNote ; |
|
136 mErrorNote = NULL; |
128 } |
137 } |
129 |
138 |
130 clearCurrentModel(); |
139 clearCurrentModel(); |
131 HbEffect::remove( QString("HbIconItem"), QString(":/data/transition.fxml"), QString( "Move" )); |
140 HbEffect::remove( QString("HbIconItem"), QString(":/data/transition.fxml"), QString( "Move" )); |
132 HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionleft.fxml"), QString( "LeftMove" )); |
141 HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionleft.fxml"), QString( "LeftMove" )); |
174 emit slideShowEvent( EFFECT_STARTED ); |
183 emit slideShowEvent( EFFECT_STARTED ); |
175 } |
184 } |
176 |
185 |
177 void GlxSlideShowWidget::effectFinshed() |
186 void GlxSlideShowWidget::effectFinshed() |
178 { |
187 { |
179 TRACER("GlxSlideShowWidget::effectFinshed()"); |
|
180 //To:Do boundery condition or last item check implemented after behaviour of slide show clear |
|
181 int rowCount = mModel->rowCount(); |
|
182 GLX_LOG_INFO2("GlxSlideShowWidget::effectFinshed() before image selected index %d array index %d", mSelIndex, mItemIndex); |
188 GLX_LOG_INFO2("GlxSlideShowWidget::effectFinshed() before image selected index %d array index %d", mSelIndex, mItemIndex); |
183 |
189 |
184 mSelIndex = ( ++mSelIndex ) % rowCount; |
|
185 mItemIndex = ( ++mItemIndex ) % NBR_ITEM; |
190 mItemIndex = ( ++mItemIndex ) % NBR_ITEM; |
186 mModel->setData( mModel->index(mSelIndex, 0), mSelIndex, GlxFocusIndexRole ); |
191 mModel->setData( mModel->index( 0, 0 ), mSelIndex[ mItemIndex ], GlxFocusIndexRole ); |
187 mModel->setData( mModel->index(mSelIndex, 0), mSelIndex, GlxVisualWindowIndex ); |
192 mModel->setData( mModel->index( 0, 0 ), mSelIndex[ mItemIndex ], GlxVisualWindowIndex ); |
188 setIconItems( MOVE_FORWARD ); |
193 setNextItemIcon(); |
189 |
194 |
190 GLX_LOG_INFO2("GlxSlideShowWidget::effectFinshed() after image selected index %d array index %d ", mSelIndex, mItemIndex); |
195 GLX_LOG_INFO2("GlxSlideShowWidget::effectFinshed() after image selected index %d array index %d ", mSelIndex, mItemIndex); |
191 |
196 |
192 if ( mIsPause == false ) { |
197 startSlideShow(); |
193 mSlideTimer->start( mSettings->slideShowDelayTime() ); |
|
194 } |
|
195 mItemList.clear(); |
198 mItemList.clear(); |
196 emit indexchanged(); // on each item change |
199 emit indexchanged(); // on each item change |
197 } |
200 } |
198 |
201 |
199 void GlxSlideShowWidget::cancelEffect() |
202 void GlxSlideShowWidget::cancelEffect() |
209 mIsPause = true; |
212 mIsPause = true; |
210 mSlideTimer->stop(); |
213 mSlideTimer->stop(); |
211 cancelEffect(); |
214 cancelEffect(); |
212 mContinueButton->setZValue( this->zValue() + 2); |
215 mContinueButton->setZValue( this->zValue() + 2); |
213 mContinueButton->show() ; |
216 mContinueButton->show() ; |
214 emit slideShowEvent(UI_ON_EVENT); |
217 emit slideShowEvent( UI_ON_EVENT ); |
215 } |
218 } |
216 |
219 |
217 void GlxSlideShowWidget::continueSlideShow(bool checked) |
220 void GlxSlideShowWidget::continueSlideShow(bool checked) |
218 { |
221 { |
219 Q_UNUSED( checked ) |
222 Q_UNUSED( checked ) |
220 TRACER("GlxSlideShowWidget::continueSlideShow()"); |
223 TRACER("GlxSlideShowWidget::continueSlideShow()"); |
221 mIsPause = false; |
224 mIsPause = false; |
222 if ( mModel && mModel->rowCount() > 1 ) { |
225 if ( mModel && mSlideShowItemCount > 1 ) { |
223 mSlideTimer->start( mSettings->slideShowDelayTime() ); |
226 mSlideTimer->start( mSettings->slideShowDelayTime() ); |
224 } |
227 } |
225 mContinueButton->hide(); |
228 mContinueButton->hide(); |
226 emit slideShowEvent(UI_OFF_EVENT); |
229 emit slideShowEvent( UI_OFF_EVENT ); |
227 } |
230 } |
228 |
231 |
229 void GlxSlideShowWidget::dataChanged(QModelIndex startIndex, QModelIndex endIndex) |
232 void GlxSlideShowWidget::dataChanged(QModelIndex startIndex, QModelIndex endIndex) |
230 { |
233 { |
231 Q_UNUSED( endIndex ) |
234 Q_UNUSED( endIndex ) |
232 TRACER("GlxSlideShowWidget::dataChanged()"); |
235 TRACER("GlxSlideShowWidget::dataChanged()"); |
233 GLX_LOG_INFO2("GlxSlideShowWidget::dataChanged startIndex = %d mSelIndex = %d ", startIndex.row(), mSelIndex ); |
236 GLX_LOG_INFO2("GlxSlideShowWidget::dataChanged startIndex = %d mSelIndex = %d ", startIndex.row(), mSelIndex ); |
234 int deltaIndex = startIndex.row() - mSelIndex; |
237 |
235 |
238 for( int i = 0; i < NBR_ITEM; ++i ) { |
236 if ( deltaIndex <= 1 && deltaIndex >= -1 ) { |
239 if ( mSelIndex[ i ] == startIndex.row() ) { |
237 int index = ( mItemIndex + deltaIndex + NBR_ITEM ) % NBR_ITEM; //calculated the array index in which data sould be updated |
240 mIconItems[ i ]->setIcon( getIcon( startIndex.row() ) ); |
238 GLX_LOG_INFO2("GlxSlideShowWidget::dataChanged index = %d mSelItemIndex = %d ", index, mItemIndex ); |
|
239 |
|
240 QVariant variant = mModel->data( startIndex, GlxFsImageRole ); |
|
241 if ( variant.isValid() && variant.canConvert<HbIcon> () ) { |
|
242 mIconItems[index]->setIcon ( variant.value<HbIcon>() ) ; |
|
243 } |
241 } |
244 else { |
242 } |
245 mIconItems[index]->setIcon ( HbIcon() ) ; |
|
246 } |
|
247 } |
|
248 } |
243 } |
249 |
244 |
250 void GlxSlideShowWidget::rowsInserted(const QModelIndex &parent, int start, int end) |
245 void GlxSlideShowWidget::rowsInserted(const QModelIndex &parent, int start, int end) |
251 { |
246 { |
252 TRACER("GlxSlideShowWidget::rowsInserted()"); |
247 TRACER("GlxSlideShowWidget::rowsInserted()"); |
311 void GlxSlideShowWidget::leftMoveEffectFinished( const HbEffect::EffectStatus &status ) |
305 void GlxSlideShowWidget::leftMoveEffectFinished( const HbEffect::EffectStatus &status ) |
312 { |
306 { |
313 Q_UNUSED(status) |
307 Q_UNUSED(status) |
314 TRACER("GlxSlideShowWidget::leftMoveEffectFinished()"); |
308 TRACER("GlxSlideShowWidget::leftMoveEffectFinished()"); |
315 GLX_LOG_INFO1("GlxSlideShowWidget::leftMoveEffectFinished() %d status", status.reason); |
309 GLX_LOG_INFO1("GlxSlideShowWidget::leftMoveEffectFinished() %d status", status.reason); |
316 |
310 |
317 int rowCount = mModel->rowCount(); |
|
318 mSelIndex = ( ++mSelIndex ) % rowCount; |
|
319 mItemIndex = ( ++mItemIndex ) % NBR_ITEM; |
311 mItemIndex = ( ++mItemIndex ) % NBR_ITEM; |
320 mModel->setData( mModel->index(mSelIndex, 0), mSelIndex, GlxFocusIndexRole ); |
312 mModel->setData( mModel->index( 0, 0 ), mSelIndex[ mItemIndex ], GlxFocusIndexRole ); |
321 mModel->setData( mModel->index(mSelIndex, 0), mSelIndex, GlxVisualWindowIndex ); |
313 mModel->setData( mModel->index( 0, 0 ), mSelIndex[ mItemIndex ], GlxVisualWindowIndex ); |
322 |
314 setNextItemIcon(); |
323 setIconItems( MOVE_FORWARD ); |
|
324 startSlideShow(); |
315 startSlideShow(); |
325 emit indexchanged(); // on left swipe |
316 emit indexchanged(); // on left swipe |
326 } |
317 } |
327 |
318 |
328 void GlxSlideShowWidget::rightMoveEffectFinished( const HbEffect::EffectStatus &status ) |
319 void GlxSlideShowWidget::rightMoveEffectFinished( const HbEffect::EffectStatus &status ) |
329 { |
320 { |
330 Q_UNUSED(status) |
321 Q_UNUSED(status) |
331 TRACER ( "GlxSlideShowWidget::rightMoveEffectFinished( ) "); |
322 TRACER ( "GlxSlideShowWidget::rightMoveEffectFinished( ) "); |
332 GLX_LOG_INFO1("GlxSlideShowWidget::rightMoveEffectFinished() %d status", status.reason); |
323 GLX_LOG_INFO1("GlxSlideShowWidget::rightMoveEffectFinished() %d status", status.reason); |
333 |
324 |
334 int rowCount = mModel->rowCount(); |
|
335 mSelIndex = mSelIndex ? --mSelIndex : rowCount - 1; |
|
336 mItemIndex = mItemIndex ? mItemIndex - 1 : NBR_ITEM - 1; |
325 mItemIndex = mItemIndex ? mItemIndex - 1 : NBR_ITEM - 1; |
337 mModel->setData( mModel->index(mSelIndex, 0), mSelIndex, GlxFocusIndexRole ); |
326 mModel->setData( mModel->index( 0, 0 ), mSelIndex[ mItemIndex ], GlxFocusIndexRole ); |
338 mModel->setData( mModel->index(mSelIndex, 0), mSelIndex, GlxVisualWindowIndex ); |
327 mModel->setData( mModel->index( 0, 0 ), mSelIndex[ mItemIndex ], GlxVisualWindowIndex ); |
339 |
328 setPreItemIcon(); |
340 setIconItems( MOVE_BACKWARD ); |
|
341 startSlideShow(); |
329 startSlideShow(); |
342 emit indexchanged(); // on right swipe |
330 emit indexchanged(); // on right swipe |
343 } |
331 } |
344 |
332 |
345 void GlxSlideShowWidget::gestureEvent(QGestureEvent *event) |
333 void GlxSlideShowWidget::gestureEvent(QGestureEvent *event) |
394 disconnect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted(QModelIndex,int,int))); |
386 disconnect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted(QModelIndex,int,int))); |
395 disconnect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); |
387 disconnect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); |
396 disconnect(mModel, SIGNAL(destroyed()), this, SLOT( modelDestroyed())); |
388 disconnect(mModel, SIGNAL(destroyed()), this, SLOT( modelDestroyed())); |
397 mModel = NULL ; |
389 mModel = NULL ; |
398 } |
390 } |
399 /* |
|
400 disconnect(mModel, SIGNAL(destroyed()), this, SLOT(_q_modelDestroyed())); |
|
401 disconnect(mModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int))); |
|
402 */ |
|
403 } |
391 } |
404 |
392 |
405 void GlxSlideShowWidget::initializeNewModel() |
393 void GlxSlideShowWidget::initializeNewModel() |
406 { |
394 { |
407 TRACER("GlxSlideShowWidget::initializeNewModel" ); |
395 TRACER("GlxSlideShowWidget::initializeNewModel" ); |
411 connect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); |
399 connect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); |
412 connect(mModel, SIGNAL(destroyed()), this, SLOT( modelDestroyed())); |
400 connect(mModel, SIGNAL(destroyed()), this, SLOT( modelDestroyed())); |
413 } |
401 } |
414 } |
402 } |
415 |
403 |
416 |
|
417 void GlxSlideShowWidget::resetSlideShow() |
404 void GlxSlideShowWidget::resetSlideShow() |
418 { |
405 { |
419 TRACER("GlxSlideShowWidget::resetSlideShow()" ); |
406 TRACER("GlxSlideShowWidget::resetSlideShow()" ); |
420 if(! mModel) { |
407 if( mModel == NULL || mModel->rowCount() == 0 ) { |
421 return; |
408 return; |
422 } |
409 } |
423 QVariant variant = mModel->data( mModel->index( mSelIndex, 0 ), GlxFocusIndexRole ); |
410 |
424 if ( variant.isValid() && variant.canConvert<int> () ) { |
411 mSlideShowItemCount = mModel->rowCount(); |
425 mSelIndex = variant.value<int>() ; |
412 setFocusItemIcon() ; |
426 GLX_LOG_INFO1("GlxSlideShowWidget::resetSlideShow() selected index %d", mSelIndex ); |
413 setNextItemIcon() ; |
427 } |
414 setPreItemIcon() ; |
428 |
415 startSlideShow(); |
429 variant = mModel->data( mModel->index( mSelIndex, 0 ), GlxFsImageRole ); |
416 |
430 if ( variant.isValid() && variant.canConvert<HbIcon> () ) { |
417 qDebug( "GlxSlideShowWidget::resetSlideShow slide show item count %d" , mSlideShowItemCount ); |
431 mIconItems[mItemIndex]->setIcon ( variant.value<HbIcon>() ) ; |
418 if ( mErrorNote && mErrorNote->isVisible() && mSlideShowItemCount > 1 ){ |
432 } |
419 hideErrorNote(); |
433 else { |
420 } |
434 mIconItems[mItemIndex]->setIcon ( HbIcon() ) ; |
|
435 } |
|
436 |
|
437 setIconItems(MOVE_FORWARD); |
|
438 setIconItems(MOVE_BACKWARD); |
|
439 if ( mIsPause == false && mModel && mModel->rowCount() > 1 ) { |
|
440 mSlideTimer->start( mSettings->slideShowDelayTime() ); |
|
441 } |
|
442 } |
|
443 |
|
444 void GlxSlideShowWidget::setIconItems( int moveDir ) |
|
445 { |
|
446 TRACER("GlxSlideShowWidget::setIconItems()"); |
|
447 int index = 0, itemIndex = 0; |
|
448 int rowCount = mModel->rowCount(); |
|
449 GLX_LOG_INFO1("GlxSlideShowWidget::setIconItems() rowcount %d ", rowCount); |
|
450 |
|
451 if ( rowCount == 0 ) { |
|
452 return ; |
|
453 } |
|
454 |
|
455 if ( moveDir == MOVE_FORWARD ) { |
|
456 index = ( mSelIndex + 1 ) % rowCount; |
|
457 itemIndex = ( mItemIndex + 1) % NBR_ITEM; |
|
458 } |
|
459 else { |
|
460 index = mSelIndex ? mSelIndex - 1 : rowCount - 1; |
|
461 itemIndex = mItemIndex ? mItemIndex - 1 : NBR_ITEM - 1; |
|
462 } |
|
463 |
|
464 GLX_LOG_INFO4("GlxSlideShowWidget::setIconItems() image selected index %d array index %d index %d icon index %d", mSelIndex, mItemIndex, index, itemIndex); |
|
465 |
|
466 QVariant variant = mModel->data( mModel->index( index, 0 ), GlxFsImageRole ); |
|
467 if ( variant.isValid() && variant.canConvert<HbIcon> () ) { |
|
468 mIconItems[itemIndex]->setIcon ( variant.value<HbIcon>() ) ; |
|
469 } |
|
470 else { |
|
471 mIconItems[itemIndex]->setIcon ( HbIcon() ) ; |
|
472 } |
|
473 } |
421 } |
474 |
422 |
475 void GlxSlideShowWidget::moveImage(int nextIndex, int posX, const QString & move, char * callBack) |
423 void GlxSlideShowWidget::moveImage(int nextIndex, int posX, const QString & move, char * callBack) |
476 { |
424 { |
477 TRACER("GlxSlideShowWidget::MoveImage()"); |
425 TRACER("GlxSlideShowWidget::MoveImage()"); |
478 |
426 |
479 if ( mModel->rowCount() <= 1 || mEffectEngine->isEffectRuning( mItemList ) ) { |
427 if ( mSlideShowItemCount <= 1 || mEffectEngine->isEffectRuning( mItemList ) ) { |
480 return ; |
428 return ; |
481 } |
429 } |
482 |
430 |
483 mSlideTimer->stop(); |
431 mSlideTimer->stop(); |
484 HbEffect::start( mIconItems[mItemIndex], QString("HbIconItem"), move ); |
432 HbEffect::start( mIconItems[mItemIndex], QString("HbIconItem"), move ); |
512 } |
460 } |
513 if ( mContinueButton ) { |
461 if ( mContinueButton ) { |
514 disconnect( mContinueButton, SIGNAL( clicked(bool) ), this, SLOT( continueSlideShow(bool) ) ); |
462 disconnect( mContinueButton, SIGNAL( clicked(bool) ), this, SLOT( continueSlideShow(bool) ) ); |
515 } |
463 } |
516 } |
464 } |
|
465 |
|
466 int GlxSlideShowWidget::getFocusIndex( ) |
|
467 { |
|
468 QVariant variant = mModel->data( mModel->index( 0, 0 ), GlxFocusIndexRole ) ; |
|
469 if ( variant.isValid() && variant.canConvert< int > () ) { |
|
470 return variant.value< int > (); |
|
471 } |
|
472 return -1; |
|
473 } |
|
474 |
|
475 HbIcon GlxSlideShowWidget::getIcon( int index ) |
|
476 { |
|
477 QVariant variant = mModel->data( mModel->index( index, 0 ), GlxFsImageRole ); |
|
478 if ( variant.isValid() && variant.canConvert< HbIcon > () ) { |
|
479 return variant.value< HbIcon > () ; |
|
480 } |
|
481 return HbIcon() ; |
|
482 } |
|
483 |
|
484 bool GlxSlideShowWidget::isCorrupt( int index ) |
|
485 { |
|
486 QVariant variant = mModel->data( mModel->index( index, 0 ), GlxImageCorruptRole ); |
|
487 if ( variant.isValid() && variant.canConvert< bool> () ) { |
|
488 return variant.value< bool > () ; |
|
489 } |
|
490 return false ; |
|
491 } |
|
492 |
|
493 bool GlxSlideShowWidget::setFocusItemIcon( ) |
|
494 { |
|
495 int nbrItem = mModel->rowCount(); |
|
496 int focusIndex = getFocusIndex(); |
|
497 |
|
498 for ( int i = 0; i < nbrItem ; ++i ) { |
|
499 if ( isCorrupt( focusIndex ) == false ) { |
|
500 qDebug( "GlxSlideShowWidget::setFocusItemIcon1 focus index %d" , focusIndex ); |
|
501 mIconItems[ mItemIndex ]->setIcon( getIcon( focusIndex ) ) ; |
|
502 mSelIndex[ mItemIndex ] = focusIndex ; |
|
503 if ( i != 0 ) { |
|
504 mModel->setData( mModel->index( 0, 0 ), focusIndex, GlxFocusIndexRole ); |
|
505 mModel->setData( mModel->index( 0, 0 ), focusIndex, GlxVisualWindowIndex ); |
|
506 } |
|
507 return true; |
|
508 } |
|
509 focusIndex = ( focusIndex + 1 ) % nbrItem; |
|
510 } |
|
511 mSlideShowItemCount = 0; |
|
512 return false; |
|
513 } |
|
514 |
|
515 bool GlxSlideShowWidget::setNextItemIcon( ) |
|
516 { |
|
517 int nbrItem = mModel->rowCount(); |
|
518 int imageIndex = ( mSelIndex[ mItemIndex ] + 1 ) % nbrItem ; |
|
519 int itemIndex = ( mItemIndex + 1 ) % NBR_ITEM ; |
|
520 |
|
521 for( int i = 1; i < nbrItem; ++i ) { |
|
522 if ( isCorrupt( imageIndex ) == false ) { |
|
523 mIconItems[ itemIndex ]->setIcon( getIcon( imageIndex ) ); |
|
524 mSelIndex[ itemIndex ] = imageIndex ; |
|
525 return true; |
|
526 } |
|
527 imageIndex = ( imageIndex + 1 ) % nbrItem ; |
|
528 } |
|
529 |
|
530 if ( isCorrupt( imageIndex ) ) { |
|
531 mSlideShowItemCount = 0; |
|
532 } |
|
533 else { |
|
534 mSlideShowItemCount = 1; |
|
535 } |
|
536 return false ; |
|
537 } |
|
538 |
|
539 bool GlxSlideShowWidget::setPreItemIcon() |
|
540 { |
|
541 int nbrItem = mModel->rowCount() ; |
|
542 int imageIndex = mSelIndex[ mItemIndex ] > 0 ? mSelIndex[ mItemIndex ] - 1 : nbrItem - 1 ; |
|
543 int itemIndex = mItemIndex > 0 ? mItemIndex - 1 : mItemIndex ; |
|
544 |
|
545 for( int i = 1; i < nbrItem; ++i ) { |
|
546 if ( isCorrupt( imageIndex ) == false ) { |
|
547 mIconItems[ itemIndex ]->setIcon( getIcon( imageIndex ) ) ; |
|
548 mSelIndex[ itemIndex ] = imageIndex ; |
|
549 return true; |
|
550 } |
|
551 imageIndex = imageIndex > 0 ? imageIndex - 1 : nbrItem - 1 ; |
|
552 } |
|
553 if ( isCorrupt( imageIndex ) ) { |
|
554 mSlideShowItemCount = 0; |
|
555 } |
|
556 else { |
|
557 mSlideShowItemCount = 1; |
|
558 } |
|
559 return false; |
|
560 } |
|
561 |
|
562 void GlxSlideShowWidget::showErrorNote() |
|
563 { |
|
564 if ( mErrorNote == NULL ){ |
|
565 mErrorNote = new HbLabel( QString( GLX_NOIMAGE_PLAY_SLIDESHOW ), this); |
|
566 mErrorNote->setObjectName( "No Image" ); |
|
567 mErrorNote->setGeometry( mIconItems[ 0 ]->geometry() ); |
|
568 mErrorNote->setAlignment( Qt::AlignCenter ); |
|
569 } |
|
570 |
|
571 for( int i = 0; i < NBR_ITEM; ++i ){ |
|
572 mIconItems[ i ]->setVisible( false ); |
|
573 } |
|
574 mErrorNote->setVisible( true ); |
|
575 emit slideShowEvent( UI_ON_EVENT ); |
|
576 } |
|
577 |
|
578 void GlxSlideShowWidget::hideErrorNote() |
|
579 { |
|
580 for( int i = 0; i < NBR_ITEM; ++i ){ |
|
581 mIconItems[ i ]->setVisible( true ); |
|
582 } |
|
583 mErrorNote->setVisible( false ); |
|
584 emit slideShowEvent( UI_OFF_EVENT ); |
|
585 } |
|
586 |