ui/viewmanagement/statehandler/src/glxstatemanager.cpp
changeset 36 6481344a6d67
parent 33 1ee2af37811f
child 44 aa2fa096cbfb
equal deleted inserted replaced
33:1ee2af37811f 36:6481344a6d67
    51       mAlbumMediaModel( NULL ),
    51       mAlbumMediaModel( NULL ),
    52       mImageviewerMediaModel( NULL ), 
    52       mImageviewerMediaModel( NULL ), 
    53       mCurrentModel( NULL ), 
    53       mCurrentModel( NULL ), 
    54       mCurrentState( NULL ), 
    54       mCurrentState( NULL ), 
    55       mActionHandler( NULL ),
    55       mActionHandler( NULL ),
    56       mTNObserver ( NULL )
    56       mTNObserver ( NULL ),
       
    57       isProgressbarRunning ( false )
    57 {
    58 {
    58     qDebug("GlxStateManager::GlxStateManager");
    59     qDebug("GlxStateManager::GlxStateManager");
    59     PERFORMANCE_ADV ( d1, "view manager creation time") {
    60     PERFORMANCE_ADV ( d1, "view manager creation time") {
    60         mViewManager = new GlxViewManager();
    61         mViewManager = new GlxViewManager();
    61     }
    62     }
   106     mCurrentState->setState( ALL_ITEM_S );
   107     mCurrentState->setState( ALL_ITEM_S );
   107        
   108        
   108     if ( mTNObserver->getTNLeftCount() > 0 ) {
   109     if ( mTNObserver->getTNLeftCount() > 0 ) {
   109         mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel);
   110         mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel);
   110         mViewManager->launchProgressDialog( mTNObserver->getTNLeftCount() );
   111         mViewManager->launchProgressDialog( mTNObserver->getTNLeftCount() );
       
   112 		isProgressbarRunning = true ;
   111     }
   113     }
   112     else {
   114     else {
   113         createModel( GLX_GRIDVIEW_ID );
   115         createModel( GLX_GRIDVIEW_ID );
   114         mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel);
   116         mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel);
   115     }
   117     }
   146     mViewManager->setupItems();
   148     mViewManager->setupItems();
   147     mViewManager->updateToolBarIcon(GLX_ALL_ACTION_ID);
   149     mViewManager->updateToolBarIcon(GLX_ALL_ACTION_ID);
   148 }
   150 }
   149 
   151 
   150 void GlxStateManager::updateTNProgress( int count)
   152 void GlxStateManager::updateTNProgress( int count)
   151 {
   153 {    
   152     if (  mCurrentState->id() != GLX_GRIDVIEW_ID  && count > 0) {
   154     // this is case when progress bar is not showing
       
   155     // in the case of rename of an image or capture the single item
       
   156     // it is also launching the progress bar, to avoid this scenario add the check of count more than 5
       
   157     if ( mCurrentModel && count > 5 ) { 
   153          goBack( GLX_GRIDVIEW_ID, ALL_ITEM_S ) ;
   158          goBack( GLX_GRIDVIEW_ID, ALL_ITEM_S ) ;
   154     }
       
   155     if ( mCurrentModel && count > 0) {
       
   156          cleanAllModel();   
   159          cleanAllModel();   
   157          mViewManager->launchProgressDialog ( count ) ;
   160          mViewManager->launchProgressDialog ( count ) ;
   158     }
   161          isProgressbarRunning = true ;         
   159     if ( count == 0 ) {
   162     }
   160         createModel( mCurrentState->id() );
   163     
   161         mViewManager->setModel( mCurrentModel );
   164     if ( isProgressbarRunning ){
   162     }
   165         if ( count == 0 ) {
   163     mViewManager->updateProgressDialog( count );
   166             createModel( mCurrentState->id() );
       
   167             mViewManager->setModel( mCurrentModel );
       
   168             isProgressbarRunning = false;
       
   169         }
       
   170         
       
   171         mViewManager->updateProgressDialog( count );
       
   172     }
   164 }
   173 }
   165 
   174 
   166 void GlxStateManager::nextState(qint32 state, int internalState)
   175 void GlxStateManager::nextState(qint32 state, int internalState)
   167 {
   176 {
   168     qDebug("GlxStateManager::nextState next state = %u", state);
   177     qDebug("GlxStateManager::nextState next state = %u", state);
   216 }
   225 }
   217    
   226    
   218 void GlxStateManager::goBack(qint32 stateId, int internalState)
   227 void GlxStateManager::goBack(qint32 stateId, int internalState)
   219 {
   228 {
   220     qDebug("GlxStateManager::goBack()");
   229     qDebug("GlxStateManager::goBack()");
       
   230     
       
   231     //if current state and it internal state is same then no need to do any thing
       
   232     if ( mCurrentState->id() == stateId  && mCurrentState->state() == internalState ) {
       
   233         return ;
       
   234     }
       
   235     
   221     GlxState *state = mCurrentState;
   236     GlxState *state = mCurrentState;
   222     
   237     
   223     while ( mCurrentState ) {
   238     while ( mCurrentState ) {
   224         if ( mCurrentState->id() == stateId  && mCurrentState->state() == internalState ) {
   239         if ( mCurrentState->id() == stateId  && mCurrentState->state() == internalState ) {
   225             break ;           
   240             break ;           
   549        
   564        
   550    case EGlxCmdSetupItem :
   565    case EGlxCmdSetupItem :
   551        emit setupItemsSignal();
   566        emit setupItemsSignal();
   552        break;
   567        break;
   553        
   568        
       
   569    case EGlxCmdAppBackground :
       
   570        if ( isProgressbarRunning ){
       
   571             mTNObserver->stopTNMDaemon();
       
   572        }
       
   573        break;
       
   574  
       
   575    case EGlxCmdAppForeground :
       
   576        if ( isProgressbarRunning ){
       
   577             mTNObserver->startTNMDaemon();
       
   578        }
       
   579        break;
       
   580        
   554     default :
   581     default :
   555         mActionHandler->handleAction(id,mCollectionId);
   582         mActionHandler->handleAction(id,mCollectionId);
   556     	break;
   583     	break;
   557     }	
   584     }	
   558 }
   585 }