email/imum/Utils/Src/MuiuDynamicSettingsItemFinder.cpp
branchRCL_3
changeset 60 7fdbb852d323
parent 0 72b543305e3a
equal deleted inserted replaced
57:ebe688cedc25 60:7fdbb852d323
       
     1 /*
       
     2 * Copyright (c) 2006 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:  MuiuDynamicSettingsItemFinder.cpp
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32base.h>
       
    22 #include "MuiuDynamicSettingsArray.hrh"
       
    23 #include "MuiuDynamicSettingsArray.h"
       
    24 
       
    25 #include "MuiuDynamicSettingsItemFinder.h"
       
    26 
       
    27 
       
    28 // EXTERNAL DATA STRUCTURES
       
    29 // EXTERNAL FUNCTION PROTOTYPES
       
    30 // CONSTANTS
       
    31 // MACROS
       
    32 // LOCAL CONSTANTS AND MACROS
       
    33 // MODULE DATA STRUCTURES
       
    34 // LOCAL FUNCTION PROTOTYPES
       
    35 // FORWARD DECLARATIONS
       
    36 
       
    37 // ============================ MEMBER FUNCTIONS ===============================
       
    38 
       
    39 // ----------------------------------------------------------------------------
       
    40 // CMuiuDynamicSettingsItemFinder::CMuiuDynamicSettingsItemFinder()
       
    41 // ----------------------------------------------------------------------------
       
    42 CMuiuDynamicSettingsItemFinder::CMuiuDynamicSettingsItemFinder(
       
    43     MMuiuDynamicSettingsItemFinderInterface& aObserver )
       
    44     :
       
    45     iObserver( aObserver ),
       
    46     iSubArrays( NULL ),
       
    47     iTempItem( NULL ),
       
    48     iSearchItem( 0 ),
       
    49     iCurrentItem( 0 ),
       
    50     iFinderArray( NULL )
       
    51     {
       
    52     }
       
    53 
       
    54 // ----------------------------------------------------------------------------
       
    55 // CMuiuDynamicSettingsItemFinder::ConstructL()
       
    56 // ----------------------------------------------------------------------------
       
    57 //
       
    58 void CMuiuDynamicSettingsItemFinder::ConstructL()
       
    59     {
       
    60     }
       
    61 
       
    62 // ----------------------------------------------------------------------------
       
    63 // CMuiuDynamicSettingsItemFinder::~CMuiuDynamicSettingsItemFinder()
       
    64 // ----------------------------------------------------------------------------
       
    65 //
       
    66 CMuiuDynamicSettingsItemFinder::~CMuiuDynamicSettingsItemFinder()
       
    67     {
       
    68     // Shouldn't exist but remove anyway
       
    69     if ( iSubArrays )
       
    70         {
       
    71         iSubArrays->Reset();
       
    72         }
       
    73 
       
    74     delete iSubArrays;
       
    75     iSubArrays = NULL;
       
    76 
       
    77     iTempItem = NULL;
       
    78 
       
    79     // Clean and remove the array
       
    80     if ( iFinderArray )
       
    81         {
       
    82         iFinderArray->Reset();
       
    83         }
       
    84 
       
    85     delete iFinderArray;
       
    86     iFinderArray = NULL;
       
    87     }
       
    88 
       
    89 // ----------------------------------------------------------------------------
       
    90 // CMuiuDynamicSettingsItemFinder::NewL()
       
    91 // ----------------------------------------------------------------------------
       
    92 //
       
    93 CMuiuDynamicSettingsItemFinder* CMuiuDynamicSettingsItemFinder::NewL(
       
    94     MMuiuDynamicSettingsItemFinderInterface& aObserver )
       
    95     {
       
    96     CMuiuDynamicSettingsItemFinder* self = NewLC( aObserver );
       
    97     CleanupStack::Pop( self );
       
    98 
       
    99     return self;
       
   100     }
       
   101 
       
   102 // ----------------------------------------------------------------------------
       
   103 // CMuiuDynamicSettingsItemFinder::NewLC()
       
   104 // ----------------------------------------------------------------------------
       
   105 //
       
   106 CMuiuDynamicSettingsItemFinder* CMuiuDynamicSettingsItemFinder::NewLC(
       
   107     MMuiuDynamicSettingsItemFinderInterface& aObserver )
       
   108     {
       
   109     CMuiuDynamicSettingsItemFinder* self =
       
   110         new ( ELeave ) CMuiuDynamicSettingsItemFinder( aObserver );
       
   111 
       
   112     CleanupStack::PushL( self );
       
   113     self->ConstructL();
       
   114 
       
   115     return self;
       
   116     }
       
   117 
       
   118 
       
   119 // ----------------------------------------------------------------------------
       
   120 // CMuiuDynamicSettingsItemFinder::SetSearchFlags()
       
   121 // ----------------------------------------------------------------------------
       
   122 //
       
   123 void CMuiuDynamicSettingsItemFinder::SetSearchFlags(
       
   124     const TMuiuFlags& aSearchFlags )
       
   125     {
       
   126     iSearchFlags = aSearchFlags;
       
   127     }
       
   128 
       
   129 
       
   130 // ----------------------------------------------------------------------------
       
   131 // CMuiuDynamicSettingsItemFinder::SearchFlags()
       
   132 // ----------------------------------------------------------------------------
       
   133 //
       
   134 TMuiuFlags CMuiuDynamicSettingsItemFinder::SearchFlags() const
       
   135     {
       
   136     return iSearchFlags;
       
   137     }
       
   138 
       
   139 // ----------------------------------------------------------------------------
       
   140 // CMuiuDynamicSettingsItemFinder::StartSearchL()
       
   141 // ----------------------------------------------------------------------------
       
   142 //
       
   143 void CMuiuDynamicSettingsItemFinder::StartSearchL(
       
   144     CMuiuDynSetItemArray& aItemArray,
       
   145     const TUid& aId )
       
   146     {
       
   147     InitializeSearchL( KErrUnknown );
       
   148     SearchIdFromTreeL( aItemArray, aId );
       
   149     FinalizeSearchL();
       
   150     }
       
   151 
       
   152 // ----------------------------------------------------------------------------
       
   153 // CMuiuDynamicSettingsItemFinder::StartSearchL()
       
   154 // ----------------------------------------------------------------------------
       
   155 //
       
   156 void CMuiuDynamicSettingsItemFinder::StartSearchL(
       
   157     CMuiuDynSetItemArray& aItemArray,
       
   158     const TInt aNth )
       
   159     {
       
   160     InitializeSearchL( aNth );
       
   161     SearchIndexFromTreeL( aItemArray );
       
   162     FinalizeSearchL();
       
   163     }
       
   164 
       
   165 // ----------------------------------------------------------------------------
       
   166 // CMuiuDynamicSettingsItemFinder::InitializeSearchL()
       
   167 // ----------------------------------------------------------------------------
       
   168 //
       
   169 void CMuiuDynamicSettingsItemFinder::InitializeSearchL(
       
   170     const TInt aItem )
       
   171     {
       
   172     iSearchItem = aItem;
       
   173     iTempItem = NULL;
       
   174 
       
   175     // Clear flags
       
   176     iSearchFlags.ClearFlag( EFinderItemFound );
       
   177     iSearchFlags.ClearFlag( EFinderItemFindError );
       
   178     iSearchFlags.ClearFlag( EFinderExit );
       
   179 
       
   180     iSubArrays =
       
   181         new ( ELeave ) CMuiuDynSetItemArray( KMuiuDynArrayGranularity );
       
   182 
       
   183     // Create arrays
       
   184     if ( !iFinderArray )
       
   185         {
       
   186         iFinderArray =
       
   187             new ( ELeave ) CMuiuDynFinderItemArray( KMuiuDynArrayGranularity );
       
   188         }
       
   189     // Clean and remove the array
       
   190     else if ( !iSearchFlags.Flag( EFinderKeepLastResult ) )
       
   191         {
       
   192         iFinderArray->Reset();
       
   193         }
       
   194     else
       
   195         {
       
   196         // make lint to keep quiet
       
   197         }
       
   198     }
       
   199 
       
   200 // ----------------------------------------------------------------------------
       
   201 // CMuiuDynamicSettingsItemFinder::FinalizeSearchL()
       
   202 // ----------------------------------------------------------------------------
       
   203 //
       
   204 void CMuiuDynamicSettingsItemFinder::FinalizeSearchL()
       
   205     {
       
   206     if ( iSubArrays )
       
   207         {
       
   208         iSubArrays->Reset();
       
   209         }
       
   210 
       
   211     delete iSubArrays;
       
   212     iSubArrays = NULL;
       
   213 
       
   214     iTempItem = NULL;
       
   215 
       
   216     // Clear flags
       
   217     iSearchFlags.ClearFlag( EFinderItemFound );
       
   218     iSearchFlags.ClearFlag( EFinderItemFindError );
       
   219     iSearchFlags.ClearFlag( EFinderExit );
       
   220 
       
   221     iSearchItem = 0;
       
   222     iCurrentItem = 0;
       
   223     }
       
   224 
       
   225 // ----------------------------------------------------------------------------
       
   226 // CMuiuDynamicSettingsItemFinder::ContinueSearch()
       
   227 // ----------------------------------------------------------------------------
       
   228 //
       
   229 TBool CMuiuDynamicSettingsItemFinder::ContinueSearch(
       
   230     const TInt aCurrentItem,
       
   231     const TInt aMaxItems )
       
   232     {
       
   233     // First check if the search should be cancelled
       
   234     if ( iSearchFlags.Flag( EFinderExit ) )
       
   235         {
       
   236         return EFalse;
       
   237         }
       
   238 
       
   239     // Check if the item is found, and that it's enough
       
   240     if ( iSearchFlags.Flag( EFinderItemFound ) &&
       
   241          !iSearchFlags.Flag( EFinderSearchAll ) &&
       
   242          !iSearchFlags.Flag( EFinderResourceSearch ) )
       
   243         {
       
   244         return EFalse;
       
   245         }
       
   246 
       
   247     // Set the current item
       
   248     iCurrentItem = aCurrentItem;
       
   249 
       
   250     // Check if the last item is in progress
       
   251     if ( iCurrentItem >= aMaxItems )
       
   252         {
       
   253         if ( !iSearchFlags.Flag( EFinderItemFound ) )
       
   254             {
       
   255             iSearchFlags.SetFlag( EFinderItemFindError );
       
   256             }
       
   257 
       
   258         iSearchFlags.SetFlag( EFinderExit );
       
   259         return EFalse;
       
   260         }
       
   261 
       
   262     // Do custom checks if needed
       
   263     if ( iSearchFlags.Flag( EFinderCustomCheck ) &&
       
   264          !iObserver.SearchDoContinuationCheck( *iTempItem, iCurrentItem ) )
       
   265         {
       
   266         iSearchFlags.SetFlag( EFinderExit );
       
   267         return EFalse;
       
   268         }
       
   269 
       
   270     // New round is about to start, clear the item found flag
       
   271     iSearchFlags.ClearFlag( EFinderItemFound );
       
   272 
       
   273     // All checks done, continue searching
       
   274     return ETrue;
       
   275     }
       
   276 
       
   277 // ----------------------------------------------------------------------------
       
   278 // CMuiuDynamicSettingsItemFinder::SearchingItem()
       
   279 // ----------------------------------------------------------------------------
       
   280 //
       
   281 TBool CMuiuDynamicSettingsItemFinder::SearchingItem()
       
   282     {
       
   283     TBool result = EFalse;
       
   284 
       
   285     // If resource search, compare against resource id of the
       
   286     // current item
       
   287     if ( iSearchFlags.Flag( EFinderResourceSearch ) )
       
   288         {
       
   289         result = ( iTempItem->iItemResourceId == iSearchItem );
       
   290         }
       
   291     // When going through all items in the list, set found
       
   292     // item as true
       
   293     else if ( iSearchFlags.Flag( EFinderSearchAll ) )
       
   294         {
       
   295         result = ETrue;
       
   296         }
       
   297     // Index search is on, compare against the item index
       
   298     else
       
   299         {
       
   300         result = !iSearchItem--;
       
   301         }
       
   302 
       
   303     // Turn the flag according the search mode
       
   304     result ^= iSearchFlags.Flag( EFinderExlusiveSearch );
       
   305 
       
   306     return result;
       
   307     }
       
   308 
       
   309 // ----------------------------------------------------------------------------
       
   310 // CMuiuDynamicSettingsItemFinder::ItemToArrayL()
       
   311 // ----------------------------------------------------------------------------
       
   312 //
       
   313 void CMuiuDynamicSettingsItemFinder::ItemToArrayL()
       
   314     {
       
   315     TMuiuFinderItem item;
       
   316 
       
   317     item.iIndex = iCurrentItem;
       
   318     item.iItem = iTempItem;
       
   319     iFinderArray->AppendL( item );
       
   320     }
       
   321 
       
   322 // ----------------------------------------------------------------------------
       
   323 // CMuiuDynamicSettingsItemFinder::ItemCheck()
       
   324 // ----------------------------------------------------------------------------
       
   325 //
       
   326 void CMuiuDynamicSettingsItemFinder::ItemCheckL( const TUid& aId )
       
   327     {
       
   328     // Make custom check for item, EXIT search
       
   329     if ( iSearchFlags.Flag( EFinderCustomCheck ) &&
       
   330          !iObserver.SearchDoItemCheck( *iTempItem ) )
       
   331         {
       
   332         return;
       
   333         }
       
   334 
       
   335     // If user has chosen to ingore rest of the checks, CONTINUE the search
       
   336     if ( iSearchFlags.Flag( EFinderOverrideChecks ) )
       
   337         {
       
   338         // Remove flags
       
   339         iSearchFlags.ClearFlag( EFinderItemFound );
       
   340         iSearchFlags.ClearFlag( EFinderExit );
       
   341 
       
   342         return;
       
   343         }
       
   344 
       
   345     // Id check
       
   346     if ( iTempItem->iItemId == aId )
       
   347         {
       
   348         // Id's of both items matches, so quit the search
       
   349         iSearchFlags.SetFlag( EFinderItemFound );
       
   350         ItemToArrayL();
       
   351         }
       
   352     }
       
   353 
       
   354 // ----------------------------------------------------------------------------
       
   355 // CMuiuDynamicSettingsItemFinder::ItemCheckL()
       
   356 // ----------------------------------------------------------------------------
       
   357 //
       
   358 void CMuiuDynamicSettingsItemFinder::ItemCheckL()
       
   359     {
       
   360     // Make custom check for item, EXIT search
       
   361     if ( iSearchFlags.Flag( EFinderCustomCheck ) &&
       
   362          !iObserver.SearchDoItemCheck( *iTempItem ) )
       
   363         {
       
   364         // It's decided that item has matched, add to array
       
   365         iSearchFlags.SetFlag( EFinderItemFound );
       
   366         ItemToArrayL();
       
   367         return;
       
   368         }
       
   369 
       
   370     // If user has chosen to ingore rest of the checks, CONTINUE the search
       
   371     if ( iSearchFlags.Flag( EFinderOverrideChecks ) )
       
   372         {
       
   373         // Remove flags
       
   374         iSearchFlags.ClearFlag( EFinderItemFound );
       
   375         iSearchFlags.ClearFlag( EFinderExit );
       
   376         iSearchFlags.ClearFlag( EFinderOverrideChecks );
       
   377 
       
   378         return;
       
   379         }
       
   380 
       
   381     // Make hidden item check
       
   382     // If EFinderDoHideCheck is turned on, hidden items are not allowed
       
   383     // to be included into the search. When off, hidden items, except
       
   384     // permanently hidden items, are included into search
       
   385     // The item is found, when iSearchItem reaches zero.
       
   386     if ( !IsHidden() && SearchingItem() )
       
   387         {
       
   388         // Id's of both items matches, so quit the search
       
   389         iSearchFlags.SetFlag( EFinderItemFound );
       
   390         ItemToArrayL();
       
   391         }
       
   392     }
       
   393 
       
   394 // ----------------------------------------------------------------------------
       
   395 // CMuiuDynamicSettingsItemFinder::ItemSubArrayCheck()
       
   396 // ----------------------------------------------------------------------------
       
   397 //
       
   398 TBool CMuiuDynamicSettingsItemFinder::ItemSubArrayCheck()
       
   399     {
       
   400     // Check if item quit is issued. The search shouldn't be cancelled even
       
   401     // if the item is found
       
   402     if ( iSearchFlags.Flag( EFinderExit ) )
       
   403         {
       
   404         return EFalse;
       
   405         }
       
   406 
       
   407     // Check if the subfolders need to be searched
       
   408     if ( !iSearchFlags.Flag( EFinderSearchSubFolders ) )
       
   409         {
       
   410         return EFalse;
       
   411         }
       
   412 
       
   413     // Check if the item is subarray item
       
   414     return iTempItem->HasLinkArray();
       
   415 
       
   416     }
       
   417 
       
   418 // ----------------------------------------------------------------------------
       
   419 // CMuiuDynamicSettingsItemFinder::ContinueSubSearch()
       
   420 // ----------------------------------------------------------------------------
       
   421 //
       
   422 TBool CMuiuDynamicSettingsItemFinder::ContinueSubSearch()
       
   423     {
       
   424     // If search is finished, don't continue the search
       
   425     if ( iSearchFlags.Flag( EFinderExit ) )
       
   426         {
       
   427         return EFalse;
       
   428         }
       
   429 
       
   430     // If items left in subarray list
       
   431     return iSubArrays->Count() > 0;
       
   432     }
       
   433 
       
   434 // ----------------------------------------------------------------------------
       
   435 // CMuiuDynamicSettingsItemFinder::IsHidden()
       
   436 // ----------------------------------------------------------------------------
       
   437 //
       
   438 TInt CMuiuDynamicSettingsItemFinder::IsHidden()
       
   439     {
       
   440     // Permanently hidden items are shown only, if the ownership of the
       
   441     // array is moved to client. As then the client will get full access
       
   442     // to items in the array
       
   443     if ( iTempItem->iItemFlags.Flag( EMuiuDynItemPermanentlyHidden ) &&
       
   444          !iSearchFlags.Flag( EFinderMoveOwnership ) &&
       
   445          iSearchFlags.Flag( EFinderDoHideCheck ) )
       
   446         {
       
   447         return KErrNotSupported;
       
   448         }
       
   449     // Hidden items are available only, if flag EFinderDoHideCheck
       
   450     // is turned off.
       
   451     else if ( iSearchFlags.Flag( EFinderDoHideCheck ) &&
       
   452         iTempItem->iItemFlags.Flag( EMuiuDynItemHidden ) )
       
   453         {
       
   454         return KErrNotFound;
       
   455         }
       
   456     // The item is included into the search
       
   457     else
       
   458         {
       
   459         return KErrNone;
       
   460         }
       
   461     }
       
   462 
       
   463 // ----------------------------------------------------------------------------
       
   464 // CMuiuDynamicSettingsItemFinder::DoIndexSearchL()
       
   465 // ----------------------------------------------------------------------------
       
   466 //
       
   467 void CMuiuDynamicSettingsItemFinder::DoIndexSearchL(
       
   468     CMuiuDynSetItemArray& aItemArray )
       
   469     {
       
   470     // Search for the item in the current array before moving inside
       
   471     // the subarrays
       
   472     TInt currentItem = 0;
       
   473     TInt max = aItemArray.Count();
       
   474     for ( ; ContinueSearch( currentItem, max ); currentItem++ )
       
   475         {
       
   476         // Store the item in array to member
       
   477         iTempItem = aItemArray[currentItem];
       
   478 
       
   479         // Check if the item matches and set quit flag if the id of the item
       
   480         // matches with the one that is searched
       
   481         ItemCheckL();
       
   482 
       
   483         // If the item wasn't the searched one, check if it contains subarray
       
   484         // and append it to stack, for later searching
       
   485         if ( ItemSubArrayCheck() )
       
   486             {
       
   487             iSubArrays->AppendL( iTempItem );
       
   488             }
       
   489         }
       
   490     }
       
   491 
       
   492 // ----------------------------------------------------------------------------
       
   493 // CMuiuDynamicSettingsItemFinder::DoIdSearchL()
       
   494 // ----------------------------------------------------------------------------
       
   495 //
       
   496 void CMuiuDynamicSettingsItemFinder::DoIdSearchL(
       
   497     CMuiuDynSetItemArray& aItemArray,
       
   498     const TUid& aId )
       
   499     {
       
   500     // Search for the item in the current array before moving inside
       
   501     // the subarrays
       
   502     TInt currentItem = 0;
       
   503     TInt max = aItemArray.Count();
       
   504     for ( ; ContinueSearch( currentItem, max ); currentItem++ )
       
   505         {
       
   506         // Store the item in array to member
       
   507         iTempItem = aItemArray[iCurrentItem];
       
   508 
       
   509         // Check if the item matches and set quit flag if the id of the item
       
   510         // matches with the one that is searched
       
   511         ItemCheckL( aId );
       
   512 
       
   513         // If the item wasn't the searched one, check if it contains subarray
       
   514         // and append it to stack, for later searching
       
   515         if ( ItemSubArrayCheck() )
       
   516             {
       
   517             iSubArrays->AppendL( iTempItem );
       
   518             }
       
   519         }
       
   520     }
       
   521 
       
   522 // ----------------------------------------------------------------------------
       
   523 // CMuiuDynamicSettingsItemFinder::SearchSubArraysL()
       
   524 // ----------------------------------------------------------------------------
       
   525 //
       
   526 void CMuiuDynamicSettingsItemFinder::DoIdSearchSubArraysL(
       
   527     const TUid& aId )
       
   528     {
       
   529     // If the correct item couldn't be found from the array,
       
   530     // search from the subarrays
       
   531     while ( ContinueSubSearch() )
       
   532         {
       
   533         // Get the first item in the array and remove it from there
       
   534         CMuiuSettingsLink* item =
       
   535             static_cast<CMuiuSettingsLink*>( iSubArrays->At( 0 ) );
       
   536         iSubArrays->Delete( 0 );
       
   537 
       
   538         // Search through the new tree
       
   539         if ( item->HasLinkArray() )
       
   540             {
       
   541             SearchIdFromTreeL( *item->iItemLinkArray, aId );
       
   542             }
       
   543         }
       
   544     }
       
   545 
       
   546 // ----------------------------------------------------------------------------
       
   547 // CMuiuDynamicSettingsItemFinder::SearchSubArraysL()
       
   548 // ----------------------------------------------------------------------------
       
   549 //
       
   550 void CMuiuDynamicSettingsItemFinder::DoIndexSearchSubArraysL()
       
   551     {
       
   552     // If the correct item couldn't be found from the array,
       
   553     // search from the subarrays
       
   554     while ( ContinueSubSearch() )
       
   555         {
       
   556         // Get the first item in the array and remove it from there
       
   557         CMuiuSettingsLink* item =
       
   558             static_cast<CMuiuSettingsLink*>( iSubArrays->At( 0 ) );
       
   559         iSubArrays->Delete( 0 );
       
   560 
       
   561         // Search through the new tree
       
   562         if ( item->HasLinkArray() )
       
   563             {
       
   564             SearchIndexFromTreeL( *item->iItemLinkArray );
       
   565             }
       
   566         }
       
   567     }
       
   568 
       
   569 // ----------------------------------------------------------------------------
       
   570 // CMuiuDynamicSettingsItemFinder::SearchIdFromTreeL()
       
   571 // ----------------------------------------------------------------------------
       
   572 //
       
   573 void CMuiuDynamicSettingsItemFinder::SearchIdFromTreeL(
       
   574     CMuiuDynSetItemArray& aItemArray,
       
   575     const TUid& aId )
       
   576     {
       
   577     // The search is made in following pattern:
       
   578     // First: The given array is searched through until EFinderExit flag is
       
   579     //        set or the end has been reached. The flag is set when given
       
   580     //        item(s) is (are) found. Each matching item and its index will
       
   581     //        be stored into array.
       
   582     //        Each item is checked for subarrays (during the first search).
       
   583     //        If the item has subarray, the item will be stored for
       
   584     //        searching.
       
   585     // Second: After the given array has been searched, each subarray will
       
   586     //         be searched, until conditions mentioned above have met, or
       
   587     //         each of the subarray's has been searched through.
       
   588     // The function is recursive
       
   589 
       
   590     // Search for the item in the current array
       
   591     DoIdSearchL( aItemArray, aId );
       
   592 
       
   593     // Before searching subarrays, check if subarray search is actually
       
   594     // need at all
       
   595     SearchShouldStop();
       
   596 
       
   597     // Search through the subarrays, if any exists
       
   598     DoIdSearchSubArraysL( aId );
       
   599     }
       
   600 
       
   601 // ----------------------------------------------------------------------------
       
   602 // CMuiuDynamicSettingsItemFinder::SearchIndexFromTreeL()
       
   603 // ----------------------------------------------------------------------------
       
   604 //
       
   605 void CMuiuDynamicSettingsItemFinder::SearchIndexFromTreeL(
       
   606     CMuiuDynSetItemArray& aItemArray )
       
   607     {
       
   608     // Search for the index from the existing array
       
   609     DoIndexSearchL( aItemArray );
       
   610 
       
   611     // Before searching subarrays, check if subarray search is actually
       
   612     // need at all
       
   613     SearchShouldStop();
       
   614 
       
   615     // Check the subarrays for the existing index
       
   616     DoIndexSearchSubArraysL();
       
   617     }
       
   618 
       
   619 // ----------------------------------------------------------------------------
       
   620 // CMuiuDynamicSettingsItemFinder::SearchShouldStop()
       
   621 // ----------------------------------------------------------------------------
       
   622 //
       
   623 void CMuiuDynamicSettingsItemFinder::SearchShouldStop()
       
   624     {
       
   625     // Check if searching has been issued to be stopped
       
   626     if ( iSearchFlags.Flag( EFinderExit ) )
       
   627         {
       
   628         // Store flags to variables to keep things readable
       
   629         TBool found = iSearchFlags.Flag( EFinderItemFound );
       
   630         TBool seekAll =
       
   631             iSearchFlags.Flag( EFinderResourceSearch ) ||
       
   632             iSearchFlags.Flag( EFinderSearchAll );
       
   633 
       
   634         // If item has been found and only single item is searched
       
   635         // allow quitting, otherwise the search must continue
       
   636         iSearchFlags.ChangeFlag( EFinderExit, found && !seekAll );
       
   637         }
       
   638     }
       
   639 
       
   640 // ----------------------------------------------------------------------------
       
   641 // CMuiuDynamicSettingsItemFinder::FinderArray()
       
   642 // ----------------------------------------------------------------------------
       
   643 //
       
   644 CMuiuDynFinderItemArray* CMuiuDynamicSettingsItemFinder::FinderArray() const
       
   645     {
       
   646     return iFinderArray;
       
   647     }
       
   648 
       
   649 // ----------------------------------------------------------------------------
       
   650 // CMuiuDynamicSettingsItemFinder::CopyFinderArrayLC()
       
   651 // ----------------------------------------------------------------------------
       
   652 //
       
   653 CMuiuDynFinderItemArray* CMuiuDynamicSettingsItemFinder::FinderArrayLC() const
       
   654     {
       
   655     // Create new array object
       
   656     CMuiuDynFinderItemArray* finderArray =
       
   657         new ( ELeave ) CMuiuDynFinderItemArray( KMuiuDynArrayGranularity );
       
   658     CleanupStack::PushL( finderArray );
       
   659 
       
   660     // Duplicate the array
       
   661     TInt items = iFinderArray->Count();
       
   662     for ( TInt item = 0; item < items; item++ )
       
   663         {
       
   664         finderArray->AppendL( iFinderArray->At( item ) );
       
   665         }
       
   666 
       
   667     return finderArray;
       
   668     }
       
   669 
       
   670 
       
   671 
       
   672 //  End of File