diff -r 6205fd287e8a -r 1abc632eb502 menufw/hierarchynavigator/hnmetadatamodel/src/hnmdeventmapping.cpp --- a/menufw/hierarchynavigator/hnmetadatamodel/src/hnmdeventmapping.cpp Thu Mar 18 14:45:17 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,231 +0,0 @@ -/* -* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include "hnmdeventmapping.h" -#include "hnmdeventmappingelement.h" -#include "hnmdevent.h" -#include "hneventhandler.h" -#include "hnsuitemodel.h" -#include "hnitemmodel.h" -#include "hnmdaction.h" -#include "hnactionmodel.h" - -// ======== MEMBER FUNCTIONS ======== - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -RPointerArray CHnMdEventMapping::GetActionsForEventId( - TInt aEventId ) - { - RPointerArray emptyActions; - CHnMdEventMappingElement* eventMappingElement = NULL; - TBool eventIdFound( EFalse ); - - TInt mappingCount( Count() ); - - for ( TInt i = 0; i < mappingCount; i++ ) - { - CHnMdEventMappingElement* eme = iMappings[i]; - - RPointerArray events = eme->Events(); - - TInt actionsCount = events.Count(); - - for ( TInt j = 0; j < actionsCount; j++ ) - { - CHnMdEvent* event = events[ j ]; - - if (event->Id() == aEventId ) - { - eventIdFound = ETrue; - break; - } - } - if ( eventIdFound ) - { - eventMappingElement = eme; - break; - } - } - - if ( eventIdFound ) - return eventMappingElement->Actions(); - else - return emptyActions; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CHnMdEventMapping::ConstructL( TXmlEngElement aElement, THnMdCommonPointers* aCmnPtrs ) - { - // construction... - iCmnPtrs = aCmnPtrs; - - RXmlEngNodeList< TXmlEngElement > children; - CleanupClosePushL(children); - - aElement.GetChildElements(children); - TInt amount = children.Count(); - - for (TInt i(0);iConstructL( aElement, aCmnPtrs ); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CHnMdEventMapping::CHnMdEventMapping() - { - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CHnMdEventMapping::~CHnMdEventMapping() - { - iMappings.ResetAndDestroy(); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CHnMdEventMapping::AddActionL( - RHashMap *> & aActions, - CHnActionModel *& aActionModel, TInt aEventId ) - { - CArrayPtr** actionsContainer = aActions.Find( aEventId ); - if ( !actionsContainer ) - { - CArrayPtr* newActionsContainer = new( - ELeave ) CArrayPtrFlat( KDefaultGranularity ); - CleanupStack::PushL( newActionsContainer ); - aActions.InsertL( aEventId, newActionsContainer ); - actionsContainer = &newActionsContainer; - CleanupStack::Pop( newActionsContainer ); - } - ( *actionsContainer )->AppendL( aActionModel ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CHnMdEventMapping::FillActionsL( - RHashMap< TInt, CArrayPtr* >& aActions, - const CLiwGenericParamList& aQueriesResultsList, TInt aPos ) - { - RArray< TInt > eventIds; - CleanupClosePushL( eventIds ); - GetEventIdsL( eventIds ); - - for ( TInt i( 0 ); i < eventIds.Count(); i++ ) - { - RPointerArray< CHnMdAction > actions = GetActionsForEventId( - eventIds[ i ] ); - for ( TInt j( 0 ); j < actions.Count(); j++ ) - { - if ( !actions[ j ] || !actions[ j ]->IsValidL( - aQueriesResultsList, aPos ) ) - { - continue; - } - CHnActionModel* actionModel = CHnActionModel::NewL(); - CleanupStack::PushL( actionModel ); - actions[ j ]->EvaluateL( actionModel, aQueriesResultsList, aPos ); - AddActionL( aActions, actionModel, eventIds[ i ] ); - CleanupStack::Pop( actionModel ); - } - } - CleanupStack::PopAndDestroy( &eventIds ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CHnMdEventMapping::GetEventIdsL( RArray< TInt >& aIds ) const - { - TInt mappingCount = Count(); - - for( TInt i = 0; i < mappingCount; i++ ) - { - CHnMdEventMappingElement* eme = iMappings[ i ]; - const RPointerArray< CHnMdEvent >& events = eme->Events(); - TInt eventsCount = events.Count(); - for ( TInt j = 0; j < eventsCount; j++ ) - { - CHnMdEvent* event = events[ j ]; - aIds.AppendL( event->Id() ); - } - } - } -