ui/views/slideshowview/src/glxslideshowwidget.cpp
changeset 54 0f0f3f26f787
parent 52 a3a4c0de738e
child 58 383b67fbdb11
--- a/ui/views/slideshowview/src/glxslideshowwidget.cpp	Fri Jul 23 20:41:04 2010 +0530
+++ b/ui/views/slideshowview/src/glxslideshowwidget.cpp	Fri Aug 06 20:44:25 2010 +0530
@@ -46,6 +46,7 @@
     : HbWidget( parent ), 
       mEffectEngine( NULL ), 
       mSettings( NULL ),
+      mAnimItem( NULL ),
       mBackGroundItem( NULL ),
       mContinueButton( NULL ), 
       mErrorNote( NULL ),
@@ -67,10 +68,13 @@
     
     //create the effect engine
     mEffectEngine = new GlxEffectEngine();
+    mItemIndex = 1;
     
     mBackGroundItem = new HbIconItem( this );
     mBackGroundItem->setBrush( QBrush( Qt::black ) );
-
+    mAnimItem = new HbIconItem( this );
+    mAnimItem->setAlignment( Qt::AlignCenter );
+    
     // Now load the view and the contents.
     // and then set the play icon to the button
     mContinueButton = static_cast<HbPushButton*>( DocLoader->findWidget( GLXSLIDESHOW_PB ) );
@@ -131,6 +135,9 @@
     
     delete mBackGroundItem ;
     mBackGroundItem = NULL;
+    
+    delete mAnimItem;
+    mAnimItem = NULL;
 
     if( mSlideTimer ) {
         delete mSlideTimer;
@@ -148,6 +155,18 @@
     HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionright.fxml"), QString( "RightMove" ));
 }
 
+QGraphicsItem * GlxSlideShowWidget::animationItem() 
+{ 
+    mAnimItem->setIcon( getIcon( mSelIndex[ mItemIndex ] ) ); 
+    return mAnimItem;
+}
+
+void GlxSlideShowWidget::updateAnimationItem() 
+{
+    mIconItems[ mItemIndex ]->setIcon( HbIcon() );
+    mAnimItem->setZValue( mAnimItem->zValue() + 10 );
+}
+
 void GlxSlideShowWidget::setModel ( QAbstractItemModel *model )
 {
     TRACER("GlxSlideShowWidget::setModel()");
@@ -171,6 +190,8 @@
     index = mItemIndex ? mItemIndex - 1 : NBR_ITEM - 1;    
     mIconItems[ index ]->setGeometry( QRect( -mScreenRect.width(), mScreenRect.top(), mScreenRect.width(), mScreenRect.height() ) );
     mBackGroundItem->setGeometry( mScreenRect );
+    int xPos = ( mScreenRect.width() - mScreenRect.height() ) >> 1 ;
+    mAnimItem->setGeometry( QRect( xPos, -xPos, mScreenRect.height(), mScreenRect.width() ) );
 }
 
 void GlxSlideShowWidget::triggeredEffect()
@@ -241,6 +262,10 @@
     Q_UNUSED( endIndex )
     TRACER("GlxSlideShowWidget::dataChanged()");
     GLX_LOG_INFO2("GlxSlideShowWidget::dataChanged startIndex = %d mSelIndex = %d ", startIndex.row(), mSelIndex  );
+
+    if ( HbEffect::effectRunning( mAnimItem ) ) {
+        return ;
+    }
     
     for( int i = 0; i < NBR_ITEM; ++i ) {
         if ( mSelIndex[ i ] == startIndex.row() ) {
@@ -255,6 +280,9 @@
     Q_UNUSED(parent);
     Q_UNUSED(start);
     Q_UNUSED(end);
+    if ( HbEffect::effectRunning( mAnimItem ) ) {
+        return ;
+    }
     resetSlideShow();  
 }
 
@@ -286,6 +314,8 @@
 void GlxSlideShowWidget::orientationChanged(QRect screenRect)
 {
     TRACER("GlxSlideShowWidget::orientationChanged()");
+    mAnimItem->setIcon( HbIcon() );
+    mAnimItem->setZValue( mAnimItem->zValue() - 10 );
     cancelEffect();
     setItemGeometry( screenRect);
     resetSlideShow();
@@ -494,7 +524,7 @@
     if ( variant.isValid() && variant.canConvert< bool> () ) {
         return variant.value< bool > () ;
     }
-    return false ;    
+    return false ;
 }
 
 bool GlxSlideShowWidget::setFocusItemIcon( )
@@ -507,10 +537,8 @@
             qDebug( "GlxSlideShowWidget::setFocusItemIcon1 focus index %d" , focusIndex );
             mIconItems[ mItemIndex ]->setIcon( getIcon( focusIndex ) ) ;
             mSelIndex[ mItemIndex ] = focusIndex ;
-            if (  i != 0 ) {
-                mModel->setData( mModel->index( 0, 0 ), focusIndex, GlxFocusIndexRole );
-                mModel->setData( mModel->index( 0, 0 ), focusIndex, GlxVisualWindowIndex );
-            }
+            mModel->setData( mModel->index( 0, 0 ), focusIndex, GlxFocusIndexRole );
+            mModel->setData( mModel->index( 0, 0 ), focusIndex, GlxVisualWindowIndex );
             return true;
         }
         focusIndex = ( focusIndex + 1 ) % nbrItem;
@@ -547,7 +575,7 @@
 {
     int nbrItem = mModel->rowCount() ;
     int imageIndex = mSelIndex[ mItemIndex ] > 0 ? mSelIndex[ mItemIndex ] - 1 : nbrItem - 1 ;
-    int itemIndex = mItemIndex > 0 ? mItemIndex - 1 : mItemIndex  ;
+    int itemIndex = mItemIndex > 0 ? mItemIndex - 1 : NBR_ITEM - 1  ;
     
     for( int i = 1; i < nbrItem; ++i ) {
         if ( isCorrupt( imageIndex ) == false ) {