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