ui/viewmanagement/statehandler/src/glxstatemanager.cpp
changeset 72 0a8e959402e5
parent 71 27f2d7aec52a
equal deleted inserted replaced
71:27f2d7aec52a 72:0a8e959402e5
   129 }
   129 }
   130 
   130 
   131 void GlxStateManager::launchFetcher(int fetcherFilterType)
   131 void GlxStateManager::launchFetcher(int fetcherFilterType)
   132 {
   132 {
   133     qDebug("GlxStateManager::launchFetcher");
   133     qDebug("GlxStateManager::launchFetcher");
   134     mCurrentState = createState(GLX_GRIDVIEW_ID);
   134     mCurrentState = createState( GLX_GRIDVIEW_ID );
   135     mCurrentState->setState(FETCHER_ITEM_S);
   135     mCurrentState->setState( FETCHER_ITEM_S );
   136 	mFetcherFilterType = (GlxFetcherFilterType)fetcherFilterType;
   136 	mFetcherFilterType = ( GlxFetcherFilterType )fetcherFilterType;
   137     createModel(GLX_GRIDVIEW_ID);
   137     createModel( GLX_GRIDVIEW_ID );
   138     mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel);
   138     mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel );
   139 }
   139 }
   140 
   140 
   141 void GlxStateManager::launchApplication()
   141 void GlxStateManager::launchApplication()
   142 {
   142 {
   143     qDebug("GlxStateManager::launchApplication");   
   143     qDebug("GlxStateManager::launchApplication");   
   144     bool activitySuccess = false;  
   144     bool activitySuccess = false;  
   145     //To:Do use it in future once performance code is removed nextState(GLX_GRIDVIEW_ID, ALL_ITEM_S)
   145     //To:Do use it in future once performance code is removed nextState(GLX_GRIDVIEW_ID, ALL_ITEM_S)
   146     
   146     
   147     if( mActivation->reason() == Af::ActivationReasonActivity ) {
   147     if( mActivation->reason() == Af::ActivationReasonActivity ) {
   148         activitySuccess = launchActivity();
   148         activitySuccess = launchActivity();
   149         qDebug("GlxStateManager::launchApplication as Activity");
       
   150     }
   149     }
   151     
   150     
   152     if( !activitySuccess ) { 
   151     if( !activitySuccess ) { 
   153         mCurrentState = createState( GLX_GRIDVIEW_ID );
   152         mCurrentState = createState( GLX_GRIDVIEW_ID );
   154         mCurrentState->setState( ALL_ITEM_S );
   153         mCurrentState->setState( ALL_ITEM_S );
   155        
   154        
   156         int leftCount = mTNObserver->getTNLeftCount() ;
   155         int leftCount = mTNObserver->getTNLeftCount() ;
   157         if (  leftCount > 0  ) {
   156         if (  leftCount > 0  || leftCount == KErrNotReady ) {
   158             mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel );
   157             mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel );
   159             launchProgressDialog();
   158             launchProgressDialog();
   160         }
   159         }
   161         else {
   160         else {
   162             createModel( GLX_GRIDVIEW_ID );
   161             createModel( GLX_GRIDVIEW_ID );
   163             mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel );
   162             mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel );
   164         }    
   163         }    
   165         mTNObserver->startTNObserving() ; 
   164         mTNObserver->startTNObserving() ; 
   166     }
   165     }   
   167     
   166     
   168     
   167     mActivityStorage->removeActivity( "PhotosMainView" );
   169     bool ok = mActivityStorage->removeActivity("PhotosMainView");
       
   170     if ( !ok )
       
   171     {
       
   172          qDebug("launchapplication::Remove activity failed" );
       
   173     } 
       
   174 }
   168 }
   175 
   169 
   176 bool GlxStateManager::launchActivity()
   170 bool GlxStateManager::launchActivity()
   177 {
   171 {
   178     QVariant data = mActivityStorage->activityData("PhotosMainView");
   172     QVariant data = mActivityStorage->activityData("PhotosMainView");
   197     mViewManager->launchApplication(stateId, mCurrentModel); 
   191     mViewManager->launchApplication(stateId, mCurrentModel); 
   198     return true;
   192     return true;
   199 }
   193 }
   200 
   194 
   201 bool GlxStateManager::validateActivityData()
   195 bool GlxStateManager::validateActivityData()
   202 {
   196 {    
   203     
   197     if( ( mSaveActivity.value("ID") == GLX_GRIDVIEW_ID ) || 
   204     if( (mSaveActivity.value("ID") == GLX_GRIDVIEW_ID) || 
   198          ( ( mSaveActivity.value("ID") == GLX_LISTVIEW_ID ) && ( mSaveActivity.value("InternalState") == ALL_ITEM_S ) ) ||
   205          ( (mSaveActivity.value("ID") == GLX_LISTVIEW_ID) && (mSaveActivity.value("InternalState") == ALL_ITEM_S) ) ||
   199              ( mSaveActivity.value("VisibleIndex") >= 0 ) ) {
   206              (mSaveActivity.value("VisibleIndex") >= 0 ) ) {
       
   207         qDebug("GlxStateManager::validation passed");
       
   208         return true;
   200         return true;
   209     }
   201     }
   210     
   202     
   211     qDebug("GlxStateManager::Validation failed");
   203     qDebug("GlxStateManager::Validation failed");
   212     qDebug("VIEW : %u", mSaveActivity.value("ID"));
   204     return false;     
   213     qDebug("SUB STATE: %u", mSaveActivity.value("InternalState"));
       
   214     qDebug("Visible Index: %u", mSaveActivity.value("VisibleIndex"));
       
   215     
       
   216     return false;
       
   217      
       
   218 }
   205 }
   219 
   206 
   220 
   207 
   221 void GlxStateManager::launchFromExternal()
   208 void GlxStateManager::launchFromExternal()
   222 {
   209 {
   241 
   228 
   242 void GlxStateManager::setupItems()
   229 void GlxStateManager::setupItems()
   243 {    
   230 {    
   244     qDebug("GlxStateManager::setupItems()");
   231     qDebug("GlxStateManager::setupItems()");
   245     mActionHandler = new GlxActionHandler();
   232     mActionHandler = new GlxActionHandler();
   246     connect ( mViewManager, SIGNAL(externalCommand(int )), this, SIGNAL(externalCommand(int )) );
       
   247     mViewManager->setupItems();
   233     mViewManager->setupItems();
   248     switch( mSaveActivity.value( "ID" ) ){
   234     
       
   235     switch( mCurrentState->id() ){
   249         case GLX_LISTVIEW_ID:
   236         case GLX_LISTVIEW_ID:
   250             mViewManager->updateToolBarIcon(GLX_ALBUM_ACTION_ID);
   237             mViewManager->updateToolBarIcon( GLX_ALBUM_ACTION_ID );
   251             break;
   238             break;
   252             
   239             
   253         case GLX_GRIDVIEW_ID:
   240         case GLX_GRIDVIEW_ID:
       
   241             mViewManager->updateToolBarIcon( GLX_ALL_ACTION_ID );
       
   242             break;
       
   243             
   254         default:
   244         default:
   255             mViewManager->updateToolBarIcon(GLX_ALL_ACTION_ID);
   245             mViewManager->updateToolBarIcon( GLX_ALL_ACTION_ID );
       
   246             break;
   256     }
   247     }
   257 }
   248 }
   258 
   249 
   259 void GlxStateManager::updateTNProgress( int count)
   250 void GlxStateManager::updateTNProgress( int count)
   260 {    
   251 {    
   261     TRACER("GlxStateManager::updateTNProgress() ");
   252     TRACER("GlxStateManager::updateTNProgress() ");
   262     // this is case when progress bar is not showing
   253     // this is case when progress bar is not showing
   263     // in the case of rename of an image or capture the single item
   254     // in the case of rename of an image or capture the single item
   264     // it is also launching the progress bar, to avoid this scenario add the check of count more than 5
   255     // it is also launching the progress bar, to avoid this scenario add the check of count more than 5
   265     if ( mCurrentModel && ( count > 5  ) ) { 
   256     if ( mCurrentModel && ( count > 5  ) ) { 
   266          goBack( GLX_GRIDVIEW_ID, ALL_ITEM_S ) ;
   257         mViewManager->cancelViewTransitionEffect();
   267          cleanAllModel();
   258         goBack( GLX_GRIDVIEW_ID, ALL_ITEM_S ) ;
   268          launchProgressDialog();
   259         cleanAllModel();
       
   260         launchProgressDialog();
   269     }
   261     }
   270     
   262     
   271     if ( isProgressbarRunning ){
   263     if ( isProgressbarRunning ){
   272         if ( count == 0 ) {
   264         if ( count == 0 ) {
   273             vanishProgressDialog();
   265             vanishProgressDialog();
   316             qDebug("SaveData::Save activity failed" );
   308             qDebug("SaveData::Save activity failed" );
   317         }
   309         }
   318     }
   310     }
   319 }
   311 }
   320 
   312 
   321 void GlxStateManager::nextState(qint32 state, int internalState)
   313 void GlxStateManager::nextState( qint32 state, int internalState )
   322 {
   314 {
   323     qDebug("GlxStateManager::nextState next state = %u", state);
   315     qDebug("GlxStateManager::nextState next state = %u", state);
       
   316     //no view transition is aloo during the progress dialog display
       
   317     if( isProgressbarRunning ) {
       
   318         return ;
       
   319     }
       
   320     
   324     GlxEffect effect = NO_EFFECT ;
   321     GlxEffect effect = NO_EFFECT ;
   325     GlxViewEffect viewEffect = NO_VIEW ;
   322     GlxViewEffect viewEffect = NO_VIEW ;
   326     
   323     
   327     PERFORMANCE ( d1, State Creation Time ) {
   324     mCurrentState = createState( state ); //create a new state
   328         mCurrentState = createState(state); //create a new state
   325     mCurrentState->setState( internalState );     
   329         mCurrentState->setState(internalState); 
   326     createModel( state ); //model should created after the internal state was set.
   330     }
   327 
   331     
   328     mCurrentState->setTranstionParameter( FORWARD_DIR, effect, viewEffect ); // to run the transtion effect
   332     createModel(state); //model should created after the internal state was set.
   329     if ( viewEffect == NO_VIEW ) {
   333     
   330         mViewManager->launchView( state, mCurrentModel );
   334     PERFORMANCE ( d2, view launch time ) {
   331     }
   335         mCurrentState->setTranstionParameter( FORWARD_DIR, effect, viewEffect); // to run the transtion effect
   332     else {
   336         if ( viewEffect == NO_VIEW ) {
   333         mViewManager->launchView( state, mCurrentModel, effect, viewEffect );
   337             mViewManager->launchView( state, mCurrentModel );
       
   338         }
       
   339         else {
       
   340             mViewManager->launchView( state, mCurrentModel, effect, viewEffect);
       
   341         }
       
   342     }
   334     }
   343 }
   335 }
   344 
   336 
   345 void GlxStateManager::previousState()
   337 void GlxStateManager::previousState()
   346 {
   338 {
   347     qDebug("GlxStateManager::previousState");
   339     qDebug("GlxStateManager::previousState");
       
   340     //no view transition is aloo during the progress dialog display
       
   341     if( isProgressbarRunning ) {
       
   342         return ;
       
   343     }
       
   344     
   348     GlxEffect effect = NO_EFFECT ;
   345     GlxEffect effect = NO_EFFECT ;
   349     GlxViewEffect viewEffect = NO_VIEW ;
   346     GlxViewEffect viewEffect = NO_VIEW ;
   350 
   347 
   351     GlxState *state = mCurrentState; // To delete the current state later  
   348     GlxState *state = mCurrentState; // To delete the current state later  
   352 
   349 
   399     }
   396     }
   400 	
   397 	
   401 void GlxStateManager::goBack(qint32 stateId, int internalState)
   398 void GlxStateManager::goBack(qint32 stateId, int internalState)
   402 {
   399 {
   403     qDebug("GlxStateManager::goBack()");
   400     qDebug("GlxStateManager::goBack()");
   404     
   401     //no view transition is aloo during the progress dialog display
       
   402     if( isProgressbarRunning ) {
       
   403         return ;
       
   404     }
       
   405         
   405     //if current state and it internal state is same then no need to do any thing
   406     //if current state and it internal state is same then no need to do any thing
   406     if ( mCurrentState->id() == stateId  && mCurrentState->state() == internalState ) {
   407     if ( mCurrentState->id() == stateId  && mCurrentState->state() == internalState ) {
   407         return ;
   408         return ;
   408     }
   409     }
   409     
   410     
   431 }
   432 }
   432 
   433 
   433 void GlxStateManager::changeState(qint32 stateId, int internalState)
   434 void GlxStateManager::changeState(qint32 stateId, int internalState)
   434 {
   435 {
   435     qDebug("GlxStateManager::changeState %d", stateId);	
   436     qDebug("GlxStateManager::changeState %d", stateId);	
   436     
   437     //no view transition is aloo during the progress dialog display
       
   438     if( isProgressbarRunning ) {
       
   439         return ;
       
   440     }
       
   441         
   437     GlxState *state = mCurrentState;
   442     GlxState *state = mCurrentState;
   438     GlxEffect effect = NO_EFFECT ;
   443     GlxEffect effect = NO_EFFECT ;
   439     GlxViewEffect viewEffect = NO_VIEW ;
   444     GlxViewEffect viewEffect = NO_VIEW ;
   440 
   445 
   441     mCurrentState = mCurrentState->previousState();//pervious state of current state become the pervious state of new state 
   446     mCurrentState = mCurrentState->previousState();//pervious state of current state become the pervious state of new state 
   534     case GLX_DETAILSVIEW_ID:
   539     case GLX_DETAILSVIEW_ID:
   535         return new GlxDetailState( mCurrentState );
   540         return new GlxDetailState( mCurrentState );
   536         
   541         
   537     case GLX_SLIDESHOWVIEW_ID :
   542     case GLX_SLIDESHOWVIEW_ID :
   538         return new GlxSlideShowState( this, mCurrentState );
   543         return new GlxSlideShowState( this, mCurrentState );
       
   544         
   539     case GLX_SLIDESHOWSETTINGSVIEW_ID :
   545     case GLX_SLIDESHOWSETTINGSVIEW_ID :
   540         return new GlxSlideShowSettingsState(this, mCurrentState );
   546         return new GlxSlideShowSettingsState(this, mCurrentState );
   541     	
   547     	
   542     default :
   548     default :
   543         return NULL;		
   549         return NULL;		
   763     	id = EGlxCmdHandled;
   769     	id = EGlxCmdHandled;
   764     	break;
   770     	break;
   765     	
   771     	
   766     case EGlxCmdCameraOpen:
   772     case EGlxCmdCameraOpen:
   767 		{
   773 		{
   768 		QProcess::startDetached(QString("cxui.exe"));
   774 		QProcess::startDetached( QString( "cxui.exe" ) );
       
   775 		mViewManager->updateToolBarActionState( GLX_CAMERA_ACTION_ID, false );
   769 		id = EGlxCmdHandled;
   776 		id = EGlxCmdHandled;
   770 		}
   777 		}
   771         break;	
   778         break;	
   772         
   779         
   773     case EGlxCmdOviOpen:
   780     case EGlxCmdOviOpen:
   774 		{
   781 		{
   775 		HbNotificationDialog::launchDialog("Not Implemented");
   782 		HbNotificationDialog::launchDialog( "Not Implemented" );
       
   783 		mViewManager->updateToolBarActionState( GLX_OVI_ACTION_ID, false );
   776         id = EGlxCmdHandled;
   784         id = EGlxCmdHandled;
   777 		}
   785 		}
   778         break;	
   786         break;	
   779         
   787         
   780    case EGlxCmdMarkAll :
   788    case EGlxCmdMarkAll :
   822     delete mActivation;
   830     delete mActivation;
   823     delete mActivityStorage;
   831     delete mActivityStorage;
   824     qDebug("GlxStateManager::~GlxStateManager delete Model");
   832     qDebug("GlxStateManager::~GlxStateManager delete Model");
   825     
   833     
   826     disconnect ( mViewManager, SIGNAL(actionTriggered(qint32 )), this, SLOT(actionTriggered(qint32 )) );
   834     disconnect ( mViewManager, SIGNAL(actionTriggered(qint32 )), this, SLOT(actionTriggered(qint32 )) );
   827     disconnect ( mViewManager, SIGNAL(externalCommand(int )), this, SIGNAL(externalCommand(int )) );
       
   828     disconnect ( mTNObserver, SIGNAL( leftTNCount( int ) ), this, SLOT( updateTNProgress( int ) ) );
   835     disconnect ( mTNObserver, SIGNAL( leftTNCount( int ) ), this, SLOT( updateTNProgress( int ) ) );
   829     disconnect ( this, SIGNAL( setupItemsSignal() ), this, SLOT( setupItems() ) );
   836     disconnect ( this, SIGNAL( setupItemsSignal() ), this, SLOT( setupItems() ) );
   830     disconnect ( qobject_cast<HbApplication*>(qApp), SIGNAL (aboutToQuit()), this, SLOT(saveData()));
   837     disconnect ( qobject_cast<HbApplication*>(qApp), SIGNAL (aboutToQuit()), this, SLOT(saveData()));
   831     
   838     
   832     delete mTNObserver;
   839     delete mTNObserver;