menucontentsrv/engsrc/menuengitemlister.cpp
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     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 
       
    18 // INCLUDE FILES
       
    19 
       
    20 #include "menuengitemlister.h"
       
    21 #include "menuengfilter.h"
       
    22 #include "menuengobject.h"
       
    23 #include "menueng.h"
       
    24 
       
    25 // ================= MEMBER FUNCTIONS =======================
       
    26 
       
    27 // ---------------------------------------------------------
       
    28 // TMenuEngItemLister::TMenuEngItemLister
       
    29 // ---------------------------------------------------------
       
    30 //
       
    31 TMenuEngItemLister::TMenuEngItemLister( 
       
    32         const CMenuEng& aEng,
       
    33         RArray<TMenuItem>& aItemArray,
       
    34         TInt aFolder,
       
    35         const MMenuEngFilter* aFilter,
       
    36         TBool aRecursive )
       
    37 : iEng( aEng ),
       
    38   iItemArray( aItemArray ),
       
    39   iFolder( aFolder ),
       
    40   iFilter( aFilter ),
       
    41   iRecursive( aRecursive )
       
    42     {
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------
       
    46 // TMenuEngItemLister::VisitEnterL
       
    47 // ---------------------------------------------------------
       
    48 //
       
    49 TBool TMenuEngItemLister::VisitEnterL( CMenuEngObject& aFolder )
       
    50     {
       
    51     if ( iFolder == aFolder.Id() )
       
    52         {
       
    53         // We need content below this folder (but not the folder itself).
       
    54         return ETrue;
       
    55         }
       
    56     
       
    57     // A folder below iFolder - add and (optionally) recurse.
       
    58     AddL( aFolder );
       
    59     return iRecursive;
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------
       
    63 // TMenuEngItemLister::VisitLeaveL
       
    64 // ---------------------------------------------------------
       
    65 //
       
    66 TBool TMenuEngItemLister::VisitLeaveL( CMenuEngObject& /*aFolder*/ )
       
    67     {
       
    68     return ETrue;
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------
       
    72 // TMenuEngItemLister::VisitL
       
    73 // ---------------------------------------------------------
       
    74 //
       
    75 TBool TMenuEngItemLister::VisitL( CMenuEngObject& aLeaf )
       
    76     {
       
    77     AddL( aLeaf );
       
    78     return ETrue;
       
    79     }
       
    80 
       
    81 // ---------------------------------------------------------
       
    82 // TMenuEngItemLister::AddL
       
    83 // ---------------------------------------------------------
       
    84 //
       
    85 void TMenuEngItemLister::AddL( CMenuEngObject& aObject )
       
    86     {
       
    87     if ( !iFilter || iFilter->MatchesObject( aObject ) )
       
    88         {
       
    89         TMenuItem hdr;
       
    90         hdr.SetId( aObject.Id() );
       
    91         hdr.SetFlags( aObject.Flags() );
       
    92         hdr.SetType( aObject.Type() );
       
    93         TInt parent;
       
    94         iEng.ParentFolderL( aObject.Id(), parent );
       
    95         hdr.SetParent( parent );
       
    96         iItemArray.AppendL( hdr );
       
    97         }
       
    98     }
       
    99 
       
   100 //  End of File