ui/views/slideshowview/src/glxslideshowwidget.cpp
changeset 52 a3a4c0de738e
parent 50 a0f57508af73
child 54 0f0f3f26f787
equal deleted inserted replaced
50:a0f57508af73 52:a3a4c0de738e
    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       mBackGroundItem( NULL ),
    49       mContinueButton( NULL ), 
    50       mContinueButton( NULL ), 
    50       mErrorNote( NULL ),
    51       mErrorNote( NULL ),
    51       mItemIndex( 1 ),  
    52       mItemIndex( 1 ),  
    52       mSlideTimer( NULL ), 
    53       mSlideTimer( NULL ), 
    53       mModel( NULL ), 
    54       mModel( NULL ), 
    64     //To:Do error handling
    65     //To:Do error handling
    65     TRACER("GlxSlideShowWidget::setSlideShowWidget()");   
    66     TRACER("GlxSlideShowWidget::setSlideShowWidget()");   
    66     
    67     
    67     //create the effect engine
    68     //create the effect engine
    68     mEffectEngine = new GlxEffectEngine();
    69     mEffectEngine = new GlxEffectEngine();
       
    70     
       
    71     mBackGroundItem = new HbIconItem( this );
       
    72     mBackGroundItem->setBrush( QBrush( Qt::black ) );
    69 
    73 
    70     // Now load the view and the contents.
    74     // Now load the view and the contents.
    71     // and then set the play icon to the button
    75     // and then set the play icon to the button
    72     mContinueButton = static_cast<HbPushButton*>( DocLoader->findWidget( GLXSLIDESHOW_PB ) );
    76     mContinueButton = static_cast<HbPushButton*>( DocLoader->findWidget( GLXSLIDESHOW_PB ) );
    73     mContinueButton->setIcon( HbIcon( GLXICON_PLAY ) );
    77     mContinueButton->setIcon( HbIcon( GLXICON_PLAY ) );
    75     mIsPause = false;
    79     mIsPause = false;
    76 
    80 
    77     for ( int i = 0; i < NBR_ITEM ; i++) {
    81     for ( int i = 0; i < NBR_ITEM ; i++) {
    78         mSelIndex[ i ] = -1;
    82         mSelIndex[ i ] = -1;
    79         mIconItems[ i ] = new HbIconItem( this );
    83         mIconItems[ i ] = new HbIconItem( this );
    80         mIconItems[ i ]->setBrush( QBrush( Qt::black ) );
       
    81         mIconItems[ i ]->setAlignment( Qt::AlignCenter );
    84         mIconItems[ i ]->setAlignment( Qt::AlignCenter );
    82         mIconItems[ i ]->setObjectName( QString( "SlideShowIcon%1" ).arg( i ) );
    85         mIconItems[ i ]->setObjectName( QString( "SlideShowIcon%1" ).arg( i ) );
    83     }
    86     }    
    84 
    87     
    85     mSlideTimer = new QTimer();
    88     mSlideTimer = new QTimer();
    86     mItemList.clear();    
    89     mItemList.clear();    
    87 
    90 
    88     //Add the signal-slot for this widget.
    91     //Add the signal-slot for this widget.
    89     addConnections();
    92     addConnections();
   123     
   126     
   124     for ( int i = 0; i < NBR_ITEM ; i++) {
   127     for ( int i = 0; i < NBR_ITEM ; i++) {
   125         delete mIconItems[i] ;
   128         delete mIconItems[i] ;
   126         mIconItems[i] = NULL;
   129         mIconItems[i] = NULL;
   127     }
   130     }
       
   131     
       
   132     delete mBackGroundItem ;
       
   133     mBackGroundItem = NULL;
   128 
   134 
   129     if( mSlideTimer ) {
   135     if( mSlideTimer ) {
   130         delete mSlideTimer;
   136         delete mSlideTimer;
   131         mSlideTimer = NULL;
   137         mSlideTimer = NULL;
   132     }
   138     }
   140     HbEffect::remove( QString("HbIconItem"), QString(":/data/transition.fxml"), QString( "Move" ));
   146     HbEffect::remove( QString("HbIconItem"), QString(":/data/transition.fxml"), QString( "Move" ));
   141     HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionleft.fxml"), QString( "LeftMove" ));
   147     HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionleft.fxml"), QString( "LeftMove" ));
   142     HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionright.fxml"), QString( "RightMove" ));
   148     HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionright.fxml"), QString( "RightMove" ));
   143 }
   149 }
   144 
   150 
   145 void GlxSlideShowWidget::setModel (QAbstractItemModel *model)
   151 void GlxSlideShowWidget::setModel ( QAbstractItemModel *model )
   146 {
   152 {
   147     TRACER("GlxSlideShowWidget::setModel()");
   153     TRACER("GlxSlideShowWidget::setModel()");
   148     if ( model == mModel ) {
   154     if ( model == mModel ) {
   149         return ;
   155         return ;
   150     }
   156     }
   152     mModel = model;
   158     mModel = model;
   153     initializeNewModel();
   159     initializeNewModel();
   154     resetSlideShow();
   160     resetSlideShow();
   155 }
   161 }
   156 
   162 
   157 void GlxSlideShowWidget::setItemGeometry(QRect screenRect)
   163 void GlxSlideShowWidget::setItemGeometry( QRect screenRect )
   158 {
   164 {
   159     TRACER("GlxSlideShowWidget::setItemGeometry()");
   165     TRACER("GlxSlideShowWidget::setItemGeometry()");
   160     int index = mItemIndex;
   166     int index = mItemIndex;
   161     mScreenRect = screenRect;   
   167     mScreenRect = screenRect;   
   162     mIconItems[index]->setGeometry(mScreenRect);
   168     mIconItems[ index ]->setGeometry( mScreenRect );
   163     index = ( mItemIndex + 1) % NBR_ITEM;
   169     index = ( mItemIndex + 1 ) % NBR_ITEM;
   164     mIconItems[index]->setGeometry( QRect( mScreenRect.width(), mScreenRect.top(), mScreenRect.width(), mScreenRect.height() ) );
   170     mIconItems[ index ]->setGeometry( QRect( mScreenRect.width(), mScreenRect.top(), mScreenRect.width(), mScreenRect.height() ) );
   165     index = mItemIndex ? mItemIndex - 1 : NBR_ITEM - 1;    
   171     index = mItemIndex ? mItemIndex - 1 : NBR_ITEM - 1;    
   166     mIconItems[index]->setGeometry( QRect( -mScreenRect.width(), mScreenRect.top(), mScreenRect.width(), mScreenRect.height() ) );     
   172     mIconItems[ index ]->setGeometry( QRect( -mScreenRect.width(), mScreenRect.top(), mScreenRect.width(), mScreenRect.height() ) );
       
   173     mBackGroundItem->setGeometry( mScreenRect );
   167 }
   174 }
   168 
   175 
   169 void GlxSlideShowWidget::triggeredEffect()
   176 void GlxSlideShowWidget::triggeredEffect()
   170 { 
   177 { 
   171     TRACER("GlxSlideShowWidget::triggeredEffect()"); 
   178     TRACER("GlxSlideShowWidget::triggeredEffect()");