ui/viewmanagement/statehandler/src/glxstatemanager.cpp
changeset 23 74c9f037fd5d
child 24 99ad1390cd33
equal deleted inserted replaced
5:f7f0874bfe7d 23:74c9f037fd5d
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 #include <glxstatemanager.h>
       
    19 #include <glxviewmanager.h>
       
    20 #include <glxviewids.h>
       
    21 #include <glxmediamodel.h>
       
    22 #include <glxgridstate.h>
       
    23 #include <glxliststate.h>
       
    24 #include <glxfullscreenstate.h>
       
    25 #include <glxdetailstate.h>
       
    26 #include <glxslideshowstate.h>
       
    27 #include <glxmodelparm.h>
       
    28 #include <glxcollectionpluginall.hrh>
       
    29 #include <glxcollectionplugincamera.hrh>
       
    30 #include <glxcollectionpluginalbums.hrh>
       
    31 #include <glxcollectionpluginimageviewer.hrh>
       
    32 #include <glxexternalutility.h>
       
    33 #include <glxalbummodel.h>
       
    34 #include <glxloggerenabler.h>
       
    35 #include <glxmediaid.h>
       
    36 #include "processhandler.h"
       
    37 #include <glxactionhandler.h>
       
    38 #include <glxcommandhandlers.hrh>
       
    39 #include <QApplication>
       
    40 #include <glxplugincommandid.hrh>
       
    41 #include <QDebug>
       
    42 #include <QItemSelectionModel>
       
    43 #include <hbmessagebox.h>
       
    44 
       
    45 GlxStateManager::GlxStateManager() : mAllMediaModel(NULL), mAlbumGridMediaModel(NULL),
       
    46             mAlbumMediaModel(NULL),mImageviewerMediaModel(NULL), mCurrentModel (NULL), mCurrentState (NULL), mActionHandler (NULL)
       
    47 {
       
    48     qDebug("GlxStateManager::GlxStateManager");
       
    49     PERFORMANCE_ADV ( d1, "view manager creation time") {
       
    50         mViewManager = new GlxViewManager();
       
    51     }
       
    52     connect ( this, SIGNAL( setupItemsSignal() ), this, SLOT( setupItems() ), Qt::QueuedConnection );
       
    53     connect ( mViewManager, SIGNAL(actionTriggered(qint32 )), this, SLOT(actionTriggered(qint32 )) );
       
    54 	//TO:DO TBD through exception when it is null
       
    55 }
       
    56 
       
    57 void GlxStateManager::enterMarkingMode()
       
    58 {
       
    59     mViewManager->enterMarkingMode(mCurrentState->id());
       
    60 }
       
    61 
       
    62 void GlxStateManager::exitMarkingMode()
       
    63 {
       
    64     mViewManager->exitMarkingMode(mCurrentState->id());
       
    65 }
       
    66 
       
    67 bool GlxStateManager::executeCommand(qint32 commandId)
       
    68 {
       
    69     qDebug( "GlxStateManager::executeCommand() : command ID %d", commandId);
       
    70     QItemSelectionModel * selectionModel = mViewManager->getSelectionModel(mCurrentState->id());
       
    71     if ( selectionModel == NULL )
       
    72         return FALSE;
       
    73     
       
    74     QModelIndexList indexList = selectionModel->selectedIndexes();
       
    75     //if no item is selected then do nothing
       
    76     if (indexList.count() == 0) 
       
    77         return FALSE;
       
    78     
       
    79     for ( int i = 0; i < indexList.count(); i++) {
       
    80         qDebug( "GlxGridView::doneAction() : index %d", indexList[i].row());            
       
    81         mCurrentModel->setData( indexList[i], indexList[i].row(), GlxSelectedIndexRole );
       
    82     }
       
    83     mActionHandler->handleAction(commandId, mCollectionId);
       
    84     return TRUE;
       
    85 }
       
    86 
       
    87 void GlxStateManager::launchApplication()
       
    88 {
       
    89    qDebug("GlxStateManager::launchApplication");   
       
    90    //To:Do use it in future once performance code is removed nextState(GLX_GRIDVIEW_ID, ALL_ITEM_S)
       
    91    
       
    92    mCurrentState = createState(GLX_GRIDVIEW_ID);
       
    93    mCurrentState->setState(ALL_ITEM_S);
       
    94    
       
    95    PERFORMANCE_ADV ( d1, "Media model creation time" ) {
       
    96        createModel(GLX_GRIDVIEW_ID);
       
    97    }
       
    98    
       
    99    PERFORMANCE_ADV ( d2, "Grid View Launch time" ) {
       
   100        mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel);
       
   101    }   
       
   102 }
       
   103 
       
   104 void GlxStateManager::launchFromExternal()
       
   105 {
       
   106     qDebug("GlxStateManager::launchApplication");
       
   107     mCurrentState = createState(GLX_FULLSCREENVIEW_ID);
       
   108     mCurrentState->setState(IMAGEVIEWER_S);
       
   109     
       
   110     createModel(GLX_FULLSCREENVIEW_ID);
       
   111     mCurrentModel->setData( mCurrentModel->index(0,0), 0, GlxFocusIndexRole );
       
   112     mViewManager->launchApplication( GLX_FULLSCREENVIEW_ID, mCurrentModel);
       
   113     //todo remove state dependency from view manager
       
   114 	mViewManager->setupItems(IMAGEVIEWER_S);
       
   115 }
       
   116 
       
   117 void GlxStateManager::actionTriggered(qint32 id)
       
   118 {
       
   119     qDebug("GlxStateManager::actionTriggered action ID = %d", id);
       
   120     mCurrentState->eventHandler(id);
       
   121     if (id != EGlxCmdHandled ) {
       
   122         eventHandler(id);
       
   123     }
       
   124 }
       
   125 
       
   126 void GlxStateManager::setupItems()
       
   127 {    
       
   128     qDebug("GlxStateManager::setupItems()");
       
   129     mActionHandler = new GlxActionHandler();
       
   130     connect ( mViewManager, SIGNAL(externalCommand(int )), this, SIGNAL(externalCommand(int )) );
       
   131     mViewManager->setupItems();
       
   132     mViewManager->updateToolBarIcon(GLX_ALL_ACTION_ID);
       
   133 }
       
   134 
       
   135 void GlxStateManager::nextState(qint32 state, int internalState)
       
   136 {
       
   137     qDebug("GlxStateManager::nextState next state = %u", state);
       
   138     GlxEffect effect = NO_EFFECT ;
       
   139     GlxViewEffect viewEffect = NO_VIEW ;
       
   140     
       
   141     PERFORMANCE ( d1, State Creation Time ) {
       
   142         mCurrentState = createState(state); //create a new state
       
   143         mCurrentState->setState(internalState); 
       
   144     }
       
   145     
       
   146     createModel(state); //model should created after the internal state was set.
       
   147     
       
   148     PERFORMANCE ( d2, view launch time ) {
       
   149         mCurrentState->setTranstionParameter( FORWARD_DIR, effect, viewEffect); // to run the transtion effect
       
   150         if ( viewEffect == NO_VIEW ) {
       
   151             mViewManager->launchView( state, mCurrentModel );
       
   152         }
       
   153         else {
       
   154             mViewManager->launchView( state, mCurrentModel, effect, viewEffect);
       
   155         }
       
   156     }
       
   157 }
       
   158 
       
   159 void GlxStateManager::previousState()
       
   160 {
       
   161     qDebug("GlxStateManager::previousState");
       
   162     GlxEffect effect = NO_EFFECT ;
       
   163     GlxViewEffect viewEffect = NO_VIEW ;
       
   164 
       
   165     GlxState *state = mCurrentState; // To delete the current state later  
       
   166 
       
   167     if ( mCurrentState->previousState() == NULL ) { //In the case only one state in stack then exit from the application
       
   168         exitApplication() ;
       
   169         mCurrentState = NULL;
       
   170     }
       
   171     else {
       
   172         //effect parameter should be set here other wise there is no way to know from where it come from
       
   173         mCurrentState->setTranstionParameter( BACKWARD_DIR, effect, viewEffect);
       
   174         mCurrentState = mCurrentState->previousState(); //get the pervious state
       
   175         createModel( mCurrentState->id(), BACKWARD_DIR ); 
       
   176 
       
   177         if ( viewEffect == NO_VIEW ) {
       
   178             mViewManager->launchView( mCurrentState->id(), mCurrentModel );
       
   179         }
       
   180         else {
       
   181             mViewManager->launchView( mCurrentState->id(), mCurrentModel, effect, viewEffect);
       
   182         }
       
   183     }
       
   184     delete state;
       
   185 }
       
   186    
       
   187 void GlxStateManager::goBack(qint32 stateId, int internalState)
       
   188 {
       
   189     qDebug("GlxStateManager::goBack()");
       
   190     GlxState *state = mCurrentState;
       
   191     
       
   192     do {
       
   193         mCurrentState = mCurrentState->previousState(); // set pervious state to the current state
       
   194         delete state; //delete the current state
       
   195         state = mCurrentState;
       
   196     }
       
   197     while ( mCurrentState && mCurrentState->id() != stateId ); //check, cuurent state is a new state
       
   198     
       
   199     //case when new state is not hierarchy then create a new state
       
   200     if ( mCurrentState == NULL ) {
       
   201         mCurrentState = createState(stateId);
       
   202         mCurrentState->setState( internalState );
       
   203     }   
       
   204     
       
   205     qDebug("GlxStateManager::goBack() state %u", mCurrentState);
       
   206     createModel( mCurrentState->id() ); //model should created after the internal state was set.
       
   207     mViewManager->launchView( mCurrentState->id(), mCurrentModel );   
       
   208 }
       
   209 
       
   210 void GlxStateManager::changeState(qint32 stateId, int internalState)
       
   211 {
       
   212     qDebug("GlxStateManager::changeState %d", stateId);	
       
   213     
       
   214     GlxState *state = mCurrentState;
       
   215     GlxEffect effect = NO_EFFECT ;
       
   216     GlxViewEffect viewEffect = NO_VIEW ;
       
   217 
       
   218     mCurrentState = mCurrentState->previousState();//pervious state of current state become the pervious state of new state 
       
   219     
       
   220     mCurrentState = createState(stateId);
       
   221     mCurrentState->setState( internalState );
       
   222     createModel( stateId ); //model should created after the internal state was set.
       
   223     
       
   224     mCurrentState->setTranstionParameter( NO_DIR, effect, viewEffect); //set the transition parameter    
       
   225     if ( viewEffect == NO_VIEW ) {
       
   226         mViewManager->launchView( mCurrentState->id(), mCurrentModel );
       
   227     }
       
   228     else {
       
   229         mViewManager->launchView( mCurrentState->id(), mCurrentModel, effect, viewEffect);
       
   230     }
       
   231     delete state;
       
   232 }
       
   233 
       
   234 void GlxStateManager::removeCurrentModel()
       
   235 {
       
   236     if ( mCurrentModel == mAllMediaModel ) {
       
   237         qDebug("GlxStateManager::removeCurrentModel() remove all media model");	
       
   238         delete mAllMediaModel ;
       
   239         mAllMediaModel = NULL ;
       
   240         mCurrentModel = NULL ;
       
   241     }
       
   242     else if ( mCurrentModel == mAlbumGridMediaModel ) {
       
   243         qDebug("GlxStateManager::removeCurrentModel() remove album grid media model");	
       
   244         delete mAlbumGridMediaModel ;
       
   245         mAlbumGridMediaModel = NULL ;
       
   246         mCurrentModel = NULL ;
       
   247     }
       
   248     else if ( mCurrentModel == mAlbumMediaModel ) {
       
   249         qDebug("GlxStateManager::removeCurrentModel() remove  model");	
       
   250         delete mAlbumMediaModel ;
       
   251         mAlbumMediaModel = NULL ;
       
   252         mCurrentModel = NULL ;
       
   253     }
       
   254     else {
       
   255     	qDebug("GlxStateManager::removeCurrentModel() do nothing");
       
   256     	//do nothing
       
   257     }
       
   258 }
       
   259 
       
   260 GlxState * GlxStateManager::createState(qint32 stateId)
       
   261 {
       
   262     qDebug("GlxStateManager::createState state id = %d", stateId);
       
   263     
       
   264     switch( stateId ) {    
       
   265     case GLX_GRIDVIEW_ID :
       
   266         return new GlxGridState( this, mCurrentState );
       
   267         
       
   268     case GLX_LISTVIEW_ID :
       
   269         return new GlxListState( mCurrentState );    	
       
   270     	
       
   271     case GLX_FULLSCREENVIEW_ID :
       
   272         return new GlxFullScreenState( mCurrentState );
       
   273         
       
   274     case GLX_DETAILSVIEW_ID:
       
   275         return new GlxDetailState( mCurrentState );
       
   276         
       
   277     case GLX_SLIDESHOWVIEW_ID :
       
   278         return new GlxSlideShowState( this, mCurrentState );
       
   279     	
       
   280     default :
       
   281         return NULL;		
       
   282     } 
       
   283 }
       
   284 
       
   285 void GlxStateManager::createModel(qint32 stateId, NavigationDir dir)
       
   286 {
       
   287     switch( stateId ) {
       
   288     case GLX_GRIDVIEW_ID :
       
   289         createGridModel( mCurrentState->state(), dir );
       
   290         mCurrentModel->setData(QModelIndex(), (int)GlxContextGrid, GlxContextRole );
       
   291         break;
       
   292 
       
   293     case GLX_LISTVIEW_ID :
       
   294     	//To:Do change the code when integrate the album list model
       
   295         if (mAlbumMediaModel == NULL) {
       
   296             GlxModelParm modelParm (KGlxCollectionPluginAlbumsImplementationUid, 0);
       
   297             mAlbumMediaModel = new GlxAlbumModel (modelParm);
       
   298         }
       
   299         mCurrentModel = mAlbumMediaModel;
       
   300         mCurrentModel->setData(QModelIndex(), (int)GlxContextPtList, GlxContextRole );
       
   301         mViewManager->updateToolBarIcon(GLX_ALBUM_ACTION_ID);
       
   302         break;
       
   303         
       
   304     case GLX_FULLSCREENVIEW_ID :
       
   305 		if ( mCurrentState->state() == IMAGEVIEWER_S) {
       
   306                 GlxModelParm modelParm (KGlxCollectionPluginImageViewerImplementationUid, 0);
       
   307                 mCurrentModel = mImageviewerMediaModel = new GlxMediaModel (modelParm);
       
   308 		}
       
   309         else if ( mCurrentState->state() == EXTERNAL_S) {
       
   310             if(!mAllMediaModel) {
       
   311                 GlxModelParm modelParm (KGlxCollectionPluginAllImplementationUid, 0);
       
   312                 mCurrentModel = mAllMediaModel = new GlxMediaModel (modelParm);
       
   313             }
       
   314             else {
       
   315                 mCurrentModel = mAllMediaModel;
       
   316             }
       
   317         mCollectionId = KGlxCollectionPluginAllImplementationUid;
       
   318         }
       
   319         if ( mViewManager->orientation() == Qt::Horizontal ) {
       
   320             mCurrentModel->setData(QModelIndex(), (int)GlxContextLsFs, GlxContextRole );
       
   321         }
       
   322         else {
       
   323             mCurrentModel->setData(QModelIndex(), (int)GlxContextPtFs, GlxContextRole );
       
   324         }
       
   325         break;
       
   326         
       
   327     case GLX_DETAILSVIEW_ID :
       
   328         if ( mViewManager->orientation() == Qt::Horizontal ) {
       
   329             mCurrentModel->setData(QModelIndex(), (int)GlxContextLsFs, GlxContextRole );
       
   330         }
       
   331         else {
       
   332             mCurrentModel->setData(QModelIndex(), (int)GlxContextPtFs, GlxContextRole );
       
   333         }
       
   334         break;
       
   335         
       
   336     case GLX_SLIDESHOWVIEW_ID :
       
   337         if ( mCurrentState->state() == ALBUM_ITEM_S ) {
       
   338             GlxModelParm modelParm ( KGlxAlbumsMediaId , 0);
       
   339             mCurrentModel = mAlbumGridMediaModel = new GlxMediaModel( modelParm );
       
   340         }
       
   341         if ( mViewManager->orientation() == Qt::Horizontal ) {
       
   342             mCurrentModel->setData(QModelIndex(), (int)GlxContextLsFs, GlxContextRole );
       
   343         }
       
   344         else {
       
   345             mCurrentModel->setData(QModelIndex(), (int)GlxContextPtFs, GlxContextRole );
       
   346         }
       
   347         break;
       
   348     	    	
       
   349     default :
       
   350         break;
       
   351     }
       
   352 }
       
   353 
       
   354 void GlxStateManager::createGridModel(int internalState, NavigationDir dir)
       
   355 {
       
   356     GlxModelParm modelParm;
       
   357     
       
   358     switch( internalState) {
       
   359     case ALL_ITEM_S :
       
   360         if ( mAllMediaModel == NULL ) {
       
   361             modelParm.setCollection( KGlxCollectionPluginAllImplementationUid );
       
   362             modelParm.setDepth(0);
       
   363             mAllMediaModel = new GlxMediaModel( modelParm );
       
   364         }
       
   365         mCollectionId = KGlxCollectionPluginAllImplementationUid;
       
   366         mCurrentModel = mAllMediaModel;
       
   367         mViewManager->updateToolBarIcon(GLX_ALL_ACTION_ID);
       
   368         break;
       
   369         
       
   370     case ALBUM_ITEM_S :
       
   371         if ( dir != BACKWARD_DIR ) { 
       
   372             modelParm.setCollection( KGlxAlbumsMediaId );
       
   373             modelParm.setDepth(0); 
       
   374             mAlbumGridMediaModel = new GlxMediaModel( modelParm );
       
   375         }               
       
   376         mCollectionId = KGlxAlbumsMediaId;
       
   377         mCurrentModel = mAlbumGridMediaModel ;
       
   378         mViewManager->updateToolBarIcon(NO_ACTION_ID);
       
   379         break;
       
   380     
       
   381     default :
       
   382         break;
       
   383     }
       
   384 }
       
   385 
       
   386 void GlxStateManager::eventHandler(qint32 &id)
       
   387 {
       
   388     qDebug("GlxStateManager::eventHandler action id = %d", id);
       
   389     switch(id) {
       
   390     case EGlxCmdAllGridOpen :
       
   391         changeState( GLX_GRIDVIEW_ID, ALL_ITEM_S );
       
   392         id = EGlxCmdHandled;
       
   393         break;
       
   394     	
       
   395     case EGlxCmdAlbumListOpen:
       
   396         changeState( GLX_LISTVIEW_ID, -1 );
       
   397         id = EGlxCmdHandled;
       
   398         break;
       
   399     	
       
   400     case EGlxCmdAlbumGridOpen:
       
   401         nextState( GLX_GRIDVIEW_ID, ALBUM_ITEM_S );
       
   402         id = EGlxCmdHandled;
       
   403         break;
       
   404       
       
   405     case EGlxCmdFirstSlideshow :
       
   406         //play the slide show with first item
       
   407         mCurrentModel->setData( mCurrentModel->index(0, 0), 0, GlxFocusIndexRole );
       
   408         nextState( GLX_SLIDESHOWVIEW_ID, SLIDESHOW_GRID_ITEM_S );
       
   409         id = EGlxCmdHandled;
       
   410         break;
       
   411         
       
   412     case EGlxCmdSelectSlideshow:
       
   413         //play the slide show with selected item
       
   414         nextState( GLX_SLIDESHOWVIEW_ID, SLIDESHOW_GRID_ITEM_S );
       
   415         id = EGlxCmdHandled;
       
   416         break;
       
   417         
       
   418     case EGlxCmdAlbumSlideShow:
       
   419         //play the slide show for a album
       
   420         nextState( GLX_SLIDESHOWVIEW_ID, SLIDESHOW_ALBUM_ITEM_S );
       
   421         id = EGlxCmdHandled;
       
   422         break;
       
   423         
       
   424     case EGlxCmdDetailsOpen:
       
   425         qDebug("GlxStateManager::eventHandler EGlxCmdDetailsOpen");
       
   426         nextState( GLX_DETAILSVIEW_ID, -1 );
       
   427         id = EGlxCmdHandled;
       
   428         break;
       
   429         
       
   430     case EGlxCmdEmptyData :
       
   431         goBack(GLX_GRIDVIEW_ID, NO_GRID_S);
       
   432         id = EGlxCmdHandled;
       
   433         break;
       
   434     	
       
   435     case EGlxCmdBack :
       
   436     	previousState();
       
   437     	id = EGlxCmdHandled;
       
   438     	break;
       
   439     	
       
   440     /*case EGlxCmdCameraOpen:
       
   441 		{
       
   442         ProcessHandler*  processHandler = new ProcessHandler(this);
       
   443         processHandler->StartCameraApp();
       
   444         id = EGlxCmdHandled;
       
   445 		}
       
   446         break;	*/
       
   447     case EGlxCmdOviOpen:
       
   448 		{
       
   449 		HbMessageBox box(HbMessageBox::MessageTypeInformation);
       
   450 		box.setText("Not Implemented");
       
   451 		box.exec();
       
   452         id = EGlxCmdHandled;
       
   453 		}
       
   454         break;	
       
   455     
       
   456    case EGlxCmdDelete :
       
   457 		{
       
   458         GlxExternalData* externalItems = GlxExternalUtility::instance()->getExternalData();
       
   459         if(externalItems){
       
   460             QVariant variant = mCurrentModel->data( mCurrentModel->index(0,0), GlxFocusIndexRole );    
       
   461             if ( variant.isValid() &&  variant.canConvert<int> () ) {
       
   462                 int selIndex = variant.value<int>(); 
       
   463                 int externalDataCount = externalItems->count();
       
   464                 if(selIndex < externalDataCount){
       
   465                     GlxInterfaceParams tmp = externalItems->value(selIndex);
       
   466                     tmp.isSelected = true;
       
   467                     externalItems->replace(selIndex,tmp);
       
   468                     emit externalCommand(EGlxPluginCmdDelete);
       
   469                     return;
       
   470                 }
       
   471             }
       
   472         }
       
   473         mActionHandler->handleAction(id,mCollectionId);
       
   474 		}
       
   475         break;
       
   476         
       
   477    case EGlxCmdMarkAll:
       
   478    case EGlxCmdUnMarkAll:
       
   479        mViewManager->handleUserAction(mCurrentState->id(), id);
       
   480        id = EGlxCmdHandled;
       
   481        break;
       
   482    case EGlxCmdRotate:
       
   483        mViewManager->handleUserAction(mCurrentState->id(), id);
       
   484 	   //Disable Rotate CH mActionHandler->handleAction(id,mCollectionId);
       
   485        id = EGlxCmdHandled;
       
   486        break;    
       
   487        
       
   488    case EGlxCmdSend:
       
   489        {
       
   490        mViewManager->handleUserAction(mCurrentState->id(), id);
       
   491        id = EGlxCmdHandled;
       
   492        }
       
   493        break;
       
   494        
       
   495    case EGlxCmdSetupItem :
       
   496        emit setupItemsSignal();
       
   497        break;
       
   498        
       
   499     default :
       
   500         mActionHandler->handleAction(id,mCollectionId);
       
   501     	break;
       
   502     }	
       
   503 }
       
   504 
       
   505 void GlxStateManager::exitApplication()
       
   506 {
       
   507     if ( mCurrentState->id( ) == GLX_FULLSCREENVIEW_ID && mCurrentState->state() == EXTERNAL_S ) {
       
   508         emit externalCommand(EGlxPluginCmdBack);
       
   509     }
       
   510     else {
       
   511     //To:Do memory cleanup
       
   512         QApplication::quit();
       
   513     }    
       
   514 }
       
   515 
       
   516 GlxStateManager::~GlxStateManager()
       
   517 {
       
   518     qDebug("GlxStateManager::~GlxStateManager");
       
   519     delete mAllMediaModel;
       
   520     delete mAlbumMediaModel;
       
   521     delete mAlbumGridMediaModel;
       
   522 	
       
   523     delete mActionHandler;
       
   524     qDebug("GlxStateManager::~GlxStateManager delete Model");
       
   525     
       
   526     disconnect ( mViewManager, SIGNAL(actionTriggered(qint32 )), this, SLOT(actionTriggered(qint32 )) );
       
   527     disconnect ( mViewManager, SIGNAL(externalCommand(int )), this, SIGNAL(externalCommand(int )) );
       
   528     delete mViewManager; 
       
   529     qDebug("GlxStateManager::~GlxStateManager delete view manager");
       
   530     delete mImageviewerMediaModel;
       
   531     GlxState *tmp;   
       
   532     while (mCurrentState) {
       
   533         tmp = mCurrentState;
       
   534         mCurrentState = mCurrentState->previousState();
       
   535         delete tmp;        
       
   536     }
       
   537     disconnect ( this, SIGNAL( setupItemsSignal() ), this, SLOT( setupItems() ) );
       
   538     qDebug("GlxStateManager::~GlxStateManager Exit");
       
   539 }
       
   540 
       
   541 void GlxStateManager::cleanupExternal()
       
   542 {
       
   543     qDebug("GlxStateManager::cleanupExternal");
       
   544     mViewManager->deactivateCurrentView();
       
   545     GlxMediaModel *glxModel = dynamic_cast<GlxMediaModel *>(mCurrentModel);
       
   546     glxModel->clearExternalItems();  
       
   547 }