ui/viewmanagement/statehandler/src/glxactionhandler.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: 
       
    15 *
       
    16 */
       
    17 #include <glxactionhandler.h>
       
    18 #include <QDebug>
       
    19 #include <glxcommandhandlers.hrh>
       
    20 #include <glxcommandhandler.h>
       
    21 #include<glxcommandhandlerfactory.h>
       
    22 #include "glxmediaid.h"
       
    23 
       
    24 GlxActionHandler::GlxActionHandler()
       
    25 {
       
    26 }
       
    27 
       
    28 GlxActionHandler::~GlxActionHandler()
       
    29 {
       
    30     foreach( GlxCommandHandler *cmdhandler, mCommandHandlerList)
       
    31         delete cmdhandler;
       
    32     mCommandHandlerList.clear();
       
    33 }
       
    34 
       
    35 void GlxActionHandler::handleAction(qint32 commandId,int collectionId)
       
    36 {
       
    37     GlxCommandHandler* cmdHandler = NULL;
       
    38 	switch ( commandId ) {
       
    39 	    case EGlxCmdContextAddToAlbum:
       
    40 	        commandId = EGlxCmdAddToAlbum;
       
    41 	        break;
       
    42 	    case EGlxCmdContextDelete:
       
    43 	        commandId = EGlxCmdDelete;
       
    44 	        break;
       
    45 	    case EGlxCmdContextAlbumDelete:
       
    46 	        commandId = EGlxCmdDelete;
       
    47 			collectionId = KGlxAlbumsMediaId;
       
    48 	        break;
       
    49 		default : break;	
       
    50 		}
       
    51 		
       
    52     if(mCommandHandlerList.contains(commandId)){
       
    53         cmdHandler = mCommandHandlerList.value(commandId);
       
    54     }
       
    55     else{
       
    56         cmdHandler = GlxCommandHandlerFactory::CreateCommandHandler(commandId);
       
    57         addCommandHandler(commandId,cmdHandler);
       
    58     }
       
    59     if ( cmdHandler ) {
       
    60         cmdHandler->executeCommand(commandId,collectionId);
       
    61     }
       
    62 }
       
    63 
       
    64 void GlxActionHandler::addCommandHandler(int commandId,GlxCommandHandler* commandHandler)
       
    65 {
       
    66     if(!mCommandHandlerList.contains(commandId)){
       
    67         mCommandHandlerList.insert(commandId,commandHandler);
       
    68         }
       
    69 }
       
    70