ui/views/slideshowview/src/glxslideshowwidget.cpp
changeset 54 0f0f3f26f787
parent 52 a3a4c0de738e
child 58 383b67fbdb11
equal deleted inserted replaced
52:a3a4c0de738e 54:0f0f3f26f787
    44 
    44 
    45 GlxSlideShowWidget::GlxSlideShowWidget( QGraphicsItem *parent ) 
    45 GlxSlideShowWidget::GlxSlideShowWidget( QGraphicsItem *parent ) 
    46     : HbWidget( parent ), 
    46     : HbWidget( parent ), 
    47       mEffectEngine( NULL ), 
    47       mEffectEngine( NULL ), 
    48       mSettings( NULL ),
    48       mSettings( NULL ),
       
    49       mAnimItem( NULL ),
    49       mBackGroundItem( NULL ),
    50       mBackGroundItem( NULL ),
    50       mContinueButton( NULL ), 
    51       mContinueButton( NULL ), 
    51       mErrorNote( NULL ),
    52       mErrorNote( NULL ),
    52       mItemIndex( 1 ),  
    53       mItemIndex( 1 ),  
    53       mSlideTimer( NULL ), 
    54       mSlideTimer( NULL ), 
    65     //To:Do error handling
    66     //To:Do error handling
    66     TRACER("GlxSlideShowWidget::setSlideShowWidget()");   
    67     TRACER("GlxSlideShowWidget::setSlideShowWidget()");   
    67     
    68     
    68     //create the effect engine
    69     //create the effect engine
    69     mEffectEngine = new GlxEffectEngine();
    70     mEffectEngine = new GlxEffectEngine();
       
    71     mItemIndex = 1;
    70     
    72     
    71     mBackGroundItem = new HbIconItem( this );
    73     mBackGroundItem = new HbIconItem( this );
    72     mBackGroundItem->setBrush( QBrush( Qt::black ) );
    74     mBackGroundItem->setBrush( QBrush( Qt::black ) );
    73 
    75     mAnimItem = new HbIconItem( this );
       
    76     mAnimItem->setAlignment( Qt::AlignCenter );
       
    77     
    74     // Now load the view and the contents.
    78     // Now load the view and the contents.
    75     // and then set the play icon to the button
    79     // and then set the play icon to the button
    76     mContinueButton = static_cast<HbPushButton*>( DocLoader->findWidget( GLXSLIDESHOW_PB ) );
    80     mContinueButton = static_cast<HbPushButton*>( DocLoader->findWidget( GLXSLIDESHOW_PB ) );
    77     mContinueButton->setIcon( HbIcon( GLXICON_PLAY ) );
    81     mContinueButton->setIcon( HbIcon( GLXICON_PLAY ) );
    78     mContinueButton->hide();
    82     mContinueButton->hide();
   129         mIconItems[i] = NULL;
   133         mIconItems[i] = NULL;
   130     }
   134     }
   131     
   135     
   132     delete mBackGroundItem ;
   136     delete mBackGroundItem ;
   133     mBackGroundItem = NULL;
   137     mBackGroundItem = NULL;
       
   138     
       
   139     delete mAnimItem;
       
   140     mAnimItem = NULL;
   134 
   141 
   135     if( mSlideTimer ) {
   142     if( mSlideTimer ) {
   136         delete mSlideTimer;
   143         delete mSlideTimer;
   137         mSlideTimer = NULL;
   144         mSlideTimer = NULL;
   138     }
   145     }
   144 
   151 
   145     clearCurrentModel();
   152     clearCurrentModel();
   146     HbEffect::remove( QString("HbIconItem"), QString(":/data/transition.fxml"), QString( "Move" ));
   153     HbEffect::remove( QString("HbIconItem"), QString(":/data/transition.fxml"), QString( "Move" ));
   147     HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionleft.fxml"), QString( "LeftMove" ));
   154     HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionleft.fxml"), QString( "LeftMove" ));
   148     HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionright.fxml"), QString( "RightMove" ));
   155     HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionright.fxml"), QString( "RightMove" ));
       
   156 }
       
   157 
       
   158 QGraphicsItem * GlxSlideShowWidget::animationItem() 
       
   159 { 
       
   160     mAnimItem->setIcon( getIcon( mSelIndex[ mItemIndex ] ) ); 
       
   161     return mAnimItem;
       
   162 }
       
   163 
       
   164 void GlxSlideShowWidget::updateAnimationItem() 
       
   165 {
       
   166     mIconItems[ mItemIndex ]->setIcon( HbIcon() );
       
   167     mAnimItem->setZValue( mAnimItem->zValue() + 10 );
   149 }
   168 }
   150 
   169 
   151 void GlxSlideShowWidget::setModel ( QAbstractItemModel *model )
   170 void GlxSlideShowWidget::setModel ( QAbstractItemModel *model )
   152 {
   171 {
   153     TRACER("GlxSlideShowWidget::setModel()");
   172     TRACER("GlxSlideShowWidget::setModel()");
   169     index = ( mItemIndex + 1 ) % NBR_ITEM;
   188     index = ( mItemIndex + 1 ) % NBR_ITEM;
   170     mIconItems[ index ]->setGeometry( QRect( mScreenRect.width(), mScreenRect.top(), mScreenRect.width(), mScreenRect.height() ) );
   189     mIconItems[ index ]->setGeometry( QRect( mScreenRect.width(), mScreenRect.top(), mScreenRect.width(), mScreenRect.height() ) );
   171     index = mItemIndex ? mItemIndex - 1 : NBR_ITEM - 1;    
   190     index = mItemIndex ? mItemIndex - 1 : NBR_ITEM - 1;    
   172     mIconItems[ index ]->setGeometry( QRect( -mScreenRect.width(), mScreenRect.top(), mScreenRect.width(), mScreenRect.height() ) );
   191     mIconItems[ index ]->setGeometry( QRect( -mScreenRect.width(), mScreenRect.top(), mScreenRect.width(), mScreenRect.height() ) );
   173     mBackGroundItem->setGeometry( mScreenRect );
   192     mBackGroundItem->setGeometry( mScreenRect );
       
   193     int xPos = ( mScreenRect.width() - mScreenRect.height() ) >> 1 ;
       
   194     mAnimItem->setGeometry( QRect( xPos, -xPos, mScreenRect.height(), mScreenRect.width() ) );
   174 }
   195 }
   175 
   196 
   176 void GlxSlideShowWidget::triggeredEffect()
   197 void GlxSlideShowWidget::triggeredEffect()
   177 { 
   198 { 
   178     TRACER("GlxSlideShowWidget::triggeredEffect()"); 
   199     TRACER("GlxSlideShowWidget::triggeredEffect()"); 
   239 void GlxSlideShowWidget::dataChanged(QModelIndex startIndex, QModelIndex endIndex)
   260 void GlxSlideShowWidget::dataChanged(QModelIndex startIndex, QModelIndex endIndex)
   240 {
   261 {
   241     Q_UNUSED( endIndex )
   262     Q_UNUSED( endIndex )
   242     TRACER("GlxSlideShowWidget::dataChanged()");
   263     TRACER("GlxSlideShowWidget::dataChanged()");
   243     GLX_LOG_INFO2("GlxSlideShowWidget::dataChanged startIndex = %d mSelIndex = %d ", startIndex.row(), mSelIndex  );
   264     GLX_LOG_INFO2("GlxSlideShowWidget::dataChanged startIndex = %d mSelIndex = %d ", startIndex.row(), mSelIndex  );
       
   265 
       
   266     if ( HbEffect::effectRunning( mAnimItem ) ) {
       
   267         return ;
       
   268     }
   244     
   269     
   245     for( int i = 0; i < NBR_ITEM; ++i ) {
   270     for( int i = 0; i < NBR_ITEM; ++i ) {
   246         if ( mSelIndex[ i ] == startIndex.row() ) {
   271         if ( mSelIndex[ i ] == startIndex.row() ) {
   247             mIconItems[ i ]->setIcon( getIcon( startIndex.row() ) );
   272             mIconItems[ i ]->setIcon( getIcon( startIndex.row() ) );
   248         }
   273         }
   253 {
   278 {
   254     TRACER("GlxSlideShowWidget::rowsInserted()");
   279     TRACER("GlxSlideShowWidget::rowsInserted()");
   255     Q_UNUSED(parent);
   280     Q_UNUSED(parent);
   256     Q_UNUSED(start);
   281     Q_UNUSED(start);
   257     Q_UNUSED(end);
   282     Q_UNUSED(end);
       
   283     if ( HbEffect::effectRunning( mAnimItem ) ) {
       
   284         return ;
       
   285     }
   258     resetSlideShow();  
   286     resetSlideShow();  
   259 }
   287 }
   260 
   288 
   261 void GlxSlideShowWidget::rowsRemoved(const QModelIndex &parent, int start, int end)
   289 void GlxSlideShowWidget::rowsRemoved(const QModelIndex &parent, int start, int end)
   262 {
   290 {
   284 
   312 
   285 
   313 
   286 void GlxSlideShowWidget::orientationChanged(QRect screenRect)
   314 void GlxSlideShowWidget::orientationChanged(QRect screenRect)
   287 {
   315 {
   288     TRACER("GlxSlideShowWidget::orientationChanged()");
   316     TRACER("GlxSlideShowWidget::orientationChanged()");
       
   317     mAnimItem->setIcon( HbIcon() );
       
   318     mAnimItem->setZValue( mAnimItem->zValue() - 10 );
   289     cancelEffect();
   319     cancelEffect();
   290     setItemGeometry( screenRect);
   320     setItemGeometry( screenRect);
   291     resetSlideShow();
   321     resetSlideShow();
   292 }
   322 }
   293 
   323 
   492 {
   522 {
   493     QVariant variant = mModel->data( mModel->index( index, 0 ), GlxImageCorruptRole );
   523     QVariant variant = mModel->data( mModel->index( index, 0 ), GlxImageCorruptRole );
   494     if ( variant.isValid() && variant.canConvert< bool> () ) {
   524     if ( variant.isValid() && variant.canConvert< bool> () ) {
   495         return variant.value< bool > () ;
   525         return variant.value< bool > () ;
   496     }
   526     }
   497     return false ;    
   527     return false ;
   498 }
   528 }
   499 
   529 
   500 bool GlxSlideShowWidget::setFocusItemIcon( )
   530 bool GlxSlideShowWidget::setFocusItemIcon( )
   501 {
   531 {
   502     int nbrItem = mModel->rowCount();
   532     int nbrItem = mModel->rowCount();
   505     for ( int i = 0; i < nbrItem ; ++i ) {
   535     for ( int i = 0; i < nbrItem ; ++i ) {
   506         if ( isCorrupt( focusIndex  ) == false ) {  
   536         if ( isCorrupt( focusIndex  ) == false ) {  
   507             qDebug( "GlxSlideShowWidget::setFocusItemIcon1 focus index %d" , focusIndex );
   537             qDebug( "GlxSlideShowWidget::setFocusItemIcon1 focus index %d" , focusIndex );
   508             mIconItems[ mItemIndex ]->setIcon( getIcon( focusIndex ) ) ;
   538             mIconItems[ mItemIndex ]->setIcon( getIcon( focusIndex ) ) ;
   509             mSelIndex[ mItemIndex ] = focusIndex ;
   539             mSelIndex[ mItemIndex ] = focusIndex ;
   510             if (  i != 0 ) {
   540             mModel->setData( mModel->index( 0, 0 ), focusIndex, GlxFocusIndexRole );
   511                 mModel->setData( mModel->index( 0, 0 ), focusIndex, GlxFocusIndexRole );
   541             mModel->setData( mModel->index( 0, 0 ), focusIndex, GlxVisualWindowIndex );
   512                 mModel->setData( mModel->index( 0, 0 ), focusIndex, GlxVisualWindowIndex );
       
   513             }
       
   514             return true;
   542             return true;
   515         }
   543         }
   516         focusIndex = ( focusIndex + 1 ) % nbrItem;
   544         focusIndex = ( focusIndex + 1 ) % nbrItem;
   517     }
   545     }
   518     mSlideShowItemCount = 0;
   546     mSlideShowItemCount = 0;
   545 
   573 
   546 bool GlxSlideShowWidget::setPreItemIcon()
   574 bool GlxSlideShowWidget::setPreItemIcon()
   547 {
   575 {
   548     int nbrItem = mModel->rowCount() ;
   576     int nbrItem = mModel->rowCount() ;
   549     int imageIndex = mSelIndex[ mItemIndex ] > 0 ? mSelIndex[ mItemIndex ] - 1 : nbrItem - 1 ;
   577     int imageIndex = mSelIndex[ mItemIndex ] > 0 ? mSelIndex[ mItemIndex ] - 1 : nbrItem - 1 ;
   550     int itemIndex = mItemIndex > 0 ? mItemIndex - 1 : mItemIndex  ;
   578     int itemIndex = mItemIndex > 0 ? mItemIndex - 1 : NBR_ITEM - 1  ;
   551     
   579     
   552     for( int i = 1; i < nbrItem; ++i ) {
   580     for( int i = 1; i < nbrItem; ++i ) {
   553         if ( isCorrupt( imageIndex ) == false ) {
   581         if ( isCorrupt( imageIndex ) == false ) {
   554             mIconItems[ itemIndex ]->setIcon( getIcon( imageIndex ) ) ;
   582             mIconItems[ itemIndex ]->setIcon( getIcon( imageIndex ) ) ;
   555             mSelIndex[ itemIndex ] = imageIndex ;
   583             mSelIndex[ itemIndex ] = imageIndex ;