ui/viewmanagement/statehandler/src/glxgridstate.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 
       
    19 
       
    20 #include <glxgridstate.h>
       
    21 #include <glxstatemanager.h>
       
    22 #include <glxcommandhandlers.hrh>
       
    23 #include <QDebug>
       
    24 
       
    25 GlxGridState::GlxGridState(GlxStateManager *stateManager, GlxState *preState ) : GlxState(GLX_GRIDVIEW_ID, preState)
       
    26 {
       
    27      if ( preState)
       
    28          qDebug("GlxGridState::GlxGridState() state id = %d", preState->id());
       
    29      
       
    30      mState = ALL_ITEM_S;
       
    31      mStateManager = stateManager ;
       
    32      mIsMarkingMode = FALSE;
       
    33      mCommandId = EGlxCmdHandled;
       
    34 }
       
    35 
       
    36 void GlxGridState::eventHandler(qint32 &id)
       
    37 {      
       
    38     qDebug("GlxGridState::eventHandler() action id = %d", id);
       
    39     defaultEventHandler (id );
       
    40     if ( id == EGlxCmdHandled ) {
       
    41         return;
       
    42     }
       
    43     
       
    44     switch ( mState ) {
       
    45     case ALL_ITEM_S :
       
    46         allItemEventHandler ( id ) ;
       
    47         break;
       
    48         
       
    49     case ALBUM_ITEM_S :
       
    50     	albumItemEventHandler ( id ) ;
       
    51     	break;
       
    52     	
       
    53     default :
       
    54     	break;
       
    55     }
       
    56 }
       
    57 
       
    58 void GlxGridState::defaultEventHandler ( qint32 &id )
       
    59 {
       
    60    qDebug("GlxGridState::defaultEventHandler() action id = %d", id);
       
    61    
       
    62    switch(id) { 
       
    63    case EGlxCmdFullScreenOpen :
       
    64         id = EGlxCmdHandled;
       
    65         mStateManager->nextState( GLX_FULLSCREENVIEW_ID, -1 );
       
    66         break;
       
    67         
       
    68    case EGlxCmdAddToAlbum :
       
    69    case EGlxCmdDelete :
       
    70        mStateManager->enterMarkingMode();
       
    71        mIsMarkingMode = TRUE;
       
    72        mCommandId = id;
       
    73        id = EGlxCmdHandled;
       
    74        break;
       
    75        
       
    76    case EGlxCmdBack :
       
    77        //here this command will be handled for only marking mode
       
    78        if (mIsMarkingMode == TRUE ) {
       
    79            mStateManager->exitMarkingMode();
       
    80            mIsMarkingMode = FALSE;
       
    81            mCommandId = id = EGlxCmdHandled;
       
    82        }
       
    83        break;
       
    84        
       
    85    case EGlxCmdSelect:
       
    86        if ( mStateManager->executeCommand(mCommandId) ) {
       
    87            mStateManager->exitMarkingMode();
       
    88            mIsMarkingMode = FALSE;
       
    89            mCommandId = EGlxCmdHandled;
       
    90        }
       
    91        id = EGlxCmdHandled;
       
    92        break;
       
    93        
       
    94    case EGlxCmdCancel :
       
    95        mStateManager->exitMarkingMode();
       
    96        mIsMarkingMode = FALSE;
       
    97        mCommandId = id = EGlxCmdHandled;
       
    98        break;
       
    99 	        
       
   100     default:
       
   101        break;
       
   102 	}
       
   103 }
       
   104 
       
   105 void GlxGridState::allItemEventHandler ( qint32 &id )
       
   106 {
       
   107     qDebug("GlxGridState::allItemEventHandler() action id = %d", id);
       
   108     
       
   109     switch(id) {
       
   110     case EGlxCmdAllGridOpen :
       
   111     	id = EGlxCmdHandled;
       
   112     	break ;
       
   113     	
       
   114     default :
       
   115     	break;
       
   116     
       
   117     }
       
   118 }
       
   119 	
       
   120 void GlxGridState::albumItemEventHandler ( qint32 &id )
       
   121 {
       
   122     qDebug("GlxGridState::albumItemEventHandler() action id = %d", id);
       
   123 
       
   124     switch(id) {
       
   125     case EGlxCmdAllGridOpen :
       
   126         mStateManager->goBack( GLX_GRIDVIEW_ID, ALL_ITEM_S );
       
   127         id = EGlxCmdHandled;
       
   128         break ;
       
   129         
       
   130     case EGlxCmdAlbumListOpen :
       
   131     case EGlxCmdBack :
       
   132         mStateManager->removeCurrentModel();
       
   133         mStateManager->previousState();
       
   134         id = EGlxCmdHandled;
       
   135         break;
       
   136     	
       
   137     default :
       
   138         break;
       
   139     }
       
   140 }
       
   141 
       
   142 void GlxGridState::setTranstionParameter(NavigationDir dir, GlxEffect &effect, GlxViewEffect &viewEffect)
       
   143 {
       
   144     qDebug("GlxListState::setTranstionParameter dir = %d", dir);
       
   145     if ( dir == NO_DIR) {
       
   146         effect = ALBUMLIST_TO_GRID ;
       
   147         viewEffect = BOTH_VIEW ;
       
   148     }
       
   149     else {
       
   150         effect = NO_EFFECT ;
       
   151         viewEffect = NO_VIEW ;    
       
   152     }
       
   153 }
       
   154