menufw/hierarchynavigator/hnmetadatamodel/src/hnmduimapping.cpp
branchv5backport
changeset 14 1abc632eb502
parent 13 6205fd287e8a
child 20 636d517f67e6
equal deleted inserted replaced
13:6205fd287e8a 14:1abc632eb502
     1 /*
       
     2 * Copyright (c) 2007-2008 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 
       
    18 
       
    19 #include <liwservicehandler.h>
       
    20 #include <e32hashtab.h>
       
    21 
       
    22 #include "menudebug.h"
       
    23 #include "hnmduimapping.h"
       
    24 #include "hnmduimappingelement.h"
       
    25 #include "hnutils.h"
       
    26 #include "hnglobals.h"
       
    27 #include "hnitemmodel.h"
       
    28 
       
    29 // ======== MEMBER FUNCTIONS ========
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // 
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 void CHnMdUiMapping::ConstructL( TXmlEngElement aElement,
       
    36                                  THnMdCommonPointers* aCmnPtrs )
       
    37     {
       
    38     RXmlEngNodeList< TXmlEngElement > children;
       
    39     CleanupClosePushL(children);
       
    40     aElement.GetChildElements(children);
       
    41     TInt amount = children.Count();
       
    42     
       
    43     TPtrC8 n = aElement.Name();
       
    44 
       
    45     for (TInt j = 0; j < amount; j++ )
       
    46         {
       
    47         TXmlEngElement item = children.Next();
       
    48         
       
    49         if ( !item.Name().Compare( KOutputElementItem8 ) )
       
    50             {
       
    51             CHnMdUiMappingElement *element =
       
    52                 CHnMdUiMappingElement::NewL( item , aCmnPtrs );
       
    53             this->AddUiMappingElementL( element );
       
    54             }
       
    55         }
       
    56     CleanupStack::PopAndDestroy( &children );
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // 
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 void CHnMdUiMapping::AddUiMappingElementL( 
       
    64     CHnMdUiMappingElement *aUiMappingElement )
       
    65     {
       
    66     iMappings.AppendL( aUiMappingElement );
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // 
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 CHnMdUiMapping* CHnMdUiMapping::NewL( TXmlEngElement aElement,
       
    74                                       THnMdCommonPointers* aCmnPtrs )
       
    75     {
       
    76     CHnMdUiMapping* self = CHnMdUiMapping::NewLC( aElement, aCmnPtrs );
       
    77     CleanupStack::Pop( self );
       
    78     return self;
       
    79     }
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // 
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 CHnMdUiMapping* CHnMdUiMapping::NewLC( TXmlEngElement aElement,
       
    86                                        THnMdCommonPointers* aCmnPtrs )
       
    87     {
       
    88     CHnMdUiMapping* self = new( ELeave ) CHnMdUiMapping;
       
    89     CleanupStack::PushL( self );
       
    90     self->ConstructL( aElement, aCmnPtrs );
       
    91     return self;
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // 
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 CHnMdUiMapping::CHnMdUiMapping()
       
    99     {
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // 
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 CHnMdUiMapping::~CHnMdUiMapping()
       
   107     {
       
   108     iMappings.ResetAndDestroy();
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // 
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 TBool CHnMdUiMapping::FillGraphicalItemL( CHnItemModel* aItemModel ,
       
   116         const CLiwGenericParamList& aQueriesResultsList, TInt aPos )
       
   117     {
       
   118     RPointerArray< TDesC8 > aliases;
       
   119     CleanupClosePushL( aliases );
       
   120     
       
   121     TBool ret( ETrue );
       
   122     for ( TInt i(0); i < iMappings.Count(); i++ )
       
   123         {     
       
   124         CHnMdUiMappingElement* uiElem = iMappings[ i ];
       
   125         ASSERT( uiElem );
       
   126         TBool alreadyFilled( EFalse );
       
   127         const TDesC8* alias = &uiElem->Alias();
       
   128         for( TInt index( 0 ); index < aliases.Count(); index++ )
       
   129             {
       
   130             if ( !aliases[ index ]->Compare( *alias ) )
       
   131                 {
       
   132                 alreadyFilled = ETrue;
       
   133                 }
       
   134             }
       
   135         if (  !alreadyFilled && uiElem->IsValidL( aQueriesResultsList, aPos ) )
       
   136             {
       
   137             aliases.AppendL( alias );
       
   138             ret = uiElem->FillGraphicalItemL( aItemModel, aQueriesResultsList, aPos );
       
   139             if ( !ret )
       
   140                 {
       
   141                 break;
       
   142                 }
       
   143             }
       
   144         }
       
   145     CleanupStack::PopAndDestroy( &aliases );
       
   146     return ret;
       
   147     }
       
   148