|
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: This file implements class CIpsSetUiBaseArray. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include <e32base.h> // Base symbian include |
|
21 #include <gulutil.h> // KColumnListSeparator |
|
22 #include <eikenv.h> // CEikonEnv |
|
23 #include <eikrutil.h> // EikResourceUtils |
|
24 #include <AknUtils.h> // AknTextUtils |
|
25 |
|
26 #include <data_caging_path_literals.hrh> |
|
27 #include <ipssossettings.rsg> |
|
28 |
|
29 #include "ipssetutilsexception.h" |
|
30 #include "ipssetutilsconsts.h" |
|
31 #include "ipssetuifinder.h" |
|
32 #include "ipssetuiitembase.h" |
|
33 #include "ipssetuiitemvalue.h" |
|
34 #include "ipssetuiitemtext.h" |
|
35 #include "ipssetuiitemlink.h" |
|
36 #include "ipssetuiitemextlink.h" |
|
37 #include "ipssetuifinder.h" |
|
38 #include "ipssetutilspageids.hrh" |
|
39 #include "ipssetuibasearray.h" |
|
40 |
|
41 // This is added at the end of the compulsory setting item string |
|
42 _LIT( KIpsSetUiStrCompulsory, "\t*" ); |
|
43 // The number of characters that can be shown in the screen |
|
44 const TInt KIpsSetUiVisibleTextLength = 30; |
|
45 // |
|
46 const TInt KIpsSetUiPasswordSecLength = 4; |
|
47 |
|
48 _LIT( KCharsToReplace, "\r\n\t\x2028\x2029" ); |
|
49 |
|
50 // ============================ MEMBER FUNCTIONS =============================== |
|
51 |
|
52 // ---------------------------------------------------------------------------- |
|
53 // CIpsSetUiBaseArray::CIpsSetUiBaseArray() |
|
54 // ---------------------------------------------------------------------------- |
|
55 // |
|
56 CIpsSetUiBaseArray::CIpsSetUiBaseArray() |
|
57 : |
|
58 iFinder( NULL ), |
|
59 iItemArray( NULL ), |
|
60 iPasswordFill( 0x00 ), |
|
61 iActiveCount( 0 ), |
|
62 iError( KErrNone ), |
|
63 iEnv( CEikonEnv::Static() ) // faulty CS warning |
|
64 { |
|
65 FUNC_LOG; |
|
66 } |
|
67 |
|
68 // ---------------------------------------------------------------------------- |
|
69 // CIpsSetUiBaseArray::~CIpsSetUiBaseArray() |
|
70 // ---------------------------------------------------------------------------- |
|
71 // |
|
72 CIpsSetUiBaseArray::~CIpsSetUiBaseArray() |
|
73 { |
|
74 FUNC_LOG; |
|
75 CleanArrayItems(); |
|
76 |
|
77 if ( iResourceStack ) |
|
78 { |
|
79 iResourceStack->Reset(); |
|
80 delete iResourceStack; |
|
81 iResourceStack = NULL; |
|
82 } |
|
83 delete iItemArray; |
|
84 delete iTempText; |
|
85 delete iFinder; |
|
86 } |
|
87 |
|
88 // ---------------------------------------------------------------------------- |
|
89 // CIpsSetUiBaseArray::BaseConstructL() |
|
90 // ---------------------------------------------------------------------------- |
|
91 // |
|
92 void CIpsSetUiBaseArray::BaseConstructL() |
|
93 { |
|
94 FUNC_LOG; |
|
95 // Prepare the arrays |
|
96 iItemArray = new ( ELeave ) CIpsSetUiBaseItemArray( KIpsSetUiArrayGranularity ); |
|
97 iResourceStack = new ( ELeave ) RResourceStack( KIpsSetUiArrayGranularity ); |
|
98 iFinder = CIpsSetUiFinder::NewL( *this ); |
|
99 iArrayFlags.SetFlag( EIpsSetUiArrayAllowRefresh ); |
|
100 |
|
101 // Prepare strings |
|
102 iTempText = HBufC::NewL( KIpsSetUiMaxSettingsTextLength ); |
|
103 iPasswordFill = EikResourceUtils::ReadTInt16L( |
|
104 R_IPS_SET_DIALOG_PASSWORD_FILL, iEnv ); |
|
105 } |
|
106 |
|
107 // ---------------------------------------------------------------------------- |
|
108 // CIpsSetUiBaseArray::BaseConstructL() |
|
109 // ---------------------------------------------------------------------------- |
|
110 // |
|
111 void CIpsSetUiBaseArray::BaseConstructL( |
|
112 const TInt aResourceId ) |
|
113 { |
|
114 FUNC_LOG; |
|
115 // Initialize the members |
|
116 BaseConstructL(); |
|
117 |
|
118 // If resource provided add it into the setting array |
|
119 LoadSettingArrayFromResourceL( aResourceId ); |
|
120 |
|
121 UpdateActiveItemsCount(); |
|
122 } |
|
123 |
|
124 TInt CIpsSetUiBaseArray::GetLastResourceId( ) |
|
125 { |
|
126 FUNC_LOG; |
|
127 TInt ret = KErrNotFound; |
|
128 if ( iResourceStack && iResourceStack->Count() > 0 ) |
|
129 { |
|
130 ret = (*iResourceStack)[ iResourceStack->Count() -1 ]; |
|
131 } |
|
132 return ret; |
|
133 } |
|
134 |
|
135 // ---------------------------------------------------------------------------- |
|
136 // CIpsSetUiBaseArray::CleanArrayItems() |
|
137 // ---------------------------------------------------------------------------- |
|
138 // |
|
139 void CIpsSetUiBaseArray::CleanArrayItems() |
|
140 { |
|
141 FUNC_LOG; |
|
142 if ( iItemArray ) |
|
143 { |
|
144 // Search through all items in the array |
|
145 for ( TInt index = iItemArray->Count() - 1 ; index >= 0; index-- ) |
|
146 { |
|
147 // Only certain type of items can contain subarrays |
|
148 CIpsSetUiItem* base = ( *iItemArray )[index]; |
|
149 delete base; |
|
150 base = NULL; |
|
151 } |
|
152 } |
|
153 } |
|
154 |
|
155 // ---------------------------------------------------------------------------- |
|
156 // CIpsSetUiBaseArray::CreateCustomItemToArrayLC() |
|
157 // ---------------------------------------------------------------------------- |
|
158 // |
|
159 CIpsSetUiItem* CIpsSetUiBaseArray::CreateCustomItemToArrayLC( |
|
160 const TUid& /* aId */ ) |
|
161 { |
|
162 FUNC_LOG; |
|
163 return NULL; |
|
164 } |
|
165 |
|
166 // ---------------------------------------------------------------------------- |
|
167 // CIpsSetUiBaseArray::ListboxItemFillMultiLineLabel() |
|
168 // ---------------------------------------------------------------------------- |
|
169 // |
|
170 void CIpsSetUiBaseArray::ListboxItemFillMultiLineLabel( |
|
171 const CIpsSetUiItem& aBaseItem, |
|
172 TIpsSetUtilsTextPlain& aText ) const |
|
173 { |
|
174 FUNC_LOG; |
|
175 aText = static_cast<const CIpsSetUiItemLink*>( |
|
176 &aBaseItem )->iItemSettingText->Left( KIpsSetUiVisibleTextLength ); |
|
177 } |
|
178 |
|
179 // ---------------------------------------------------------------------------- |
|
180 // CIpsSetUiBaseArray::ListboxItemFillEditTextLabel() |
|
181 // ---------------------------------------------------------------------------- |
|
182 // |
|
183 void CIpsSetUiBaseArray::ListboxItemFillEditTextLabel( |
|
184 const CIpsSetUiItem& aBaseItem, |
|
185 TIpsSetUtilsTextPlain& aText ) const |
|
186 { |
|
187 FUNC_LOG; |
|
188 aText.Copy( aBaseItem.Text().Left( KIpsSetUiVisibleTextLength ) ); |
|
189 } |
|
190 |
|
191 // ---------------------------------------------------------------------------- |
|
192 // CIpsSetUiBaseArray::ListboxItemFillEditValueLabel() |
|
193 // ---------------------------------------------------------------------------- |
|
194 // |
|
195 void CIpsSetUiBaseArray::ListboxItemFillEditValueLabel( |
|
196 const CIpsSetUiItem& aBaseItem, |
|
197 TIpsSetUtilsTextPlain& aText ) const |
|
198 { |
|
199 FUNC_LOG; |
|
200 const TInt KNumberSize = 10; |
|
201 |
|
202 if ( aText.MaxLength() - aText.Length() >= KNumberSize ) |
|
203 { |
|
204 aText.AppendNum( aBaseItem.Value() ); |
|
205 } |
|
206 } |
|
207 |
|
208 // ---------------------------------------------------------------------------- |
|
209 // CIpsSetUiBaseArray::ListboxItemFillEditTimeLabel() |
|
210 // ---------------------------------------------------------------------------- |
|
211 // |
|
212 void CIpsSetUiBaseArray::ListboxItemFillEditTimeLabel( |
|
213 const CIpsSetUiItem& aBaseItem, |
|
214 TIpsSetUtilsTextPlain& aText ) const |
|
215 { |
|
216 FUNC_LOG; |
|
217 aText.Append( aBaseItem.Value() ); |
|
218 aText.SetLength( KIpsSetUiVisibleTextLength ); |
|
219 } |
|
220 |
|
221 // ---------------------------------------------------------------------------- |
|
222 // CIpsSetUiBaseArray::ListboxUndefinedFillLabel() |
|
223 // ---------------------------------------------------------------------------- |
|
224 // |
|
225 void CIpsSetUiBaseArray::ListboxUndefinedFillLabel( |
|
226 const CIpsSetUiItem& aBaseItem, |
|
227 TIpsSetUtilsTextPlain& aText ) const |
|
228 { |
|
229 FUNC_LOG; |
|
230 aText = static_cast<const CIpsSetUiItemLinkExt*>( |
|
231 &aBaseItem )->iItemSettingText->Left( KIpsSetUiVisibleTextLength ); |
|
232 } |
|
233 |
|
234 // ---------------------------------------------------------------------------- |
|
235 // CIpsSetUiBaseArray::ListboxRadioButtonFillArrayLabel() |
|
236 // ---------------------------------------------------------------------------- |
|
237 // |
|
238 void CIpsSetUiBaseArray::ListboxRadioButtonFillArrayLabel( |
|
239 const CIpsSetUiItem& aBaseItem, |
|
240 TIpsSetUtilsTextPlain& aText ) const |
|
241 { |
|
242 FUNC_LOG; |
|
243 aText = static_cast<const CIpsSetUiItemLinkExt*>( |
|
244 &aBaseItem )->iItemSettingText->Left( KIpsSetUiVisibleTextLength ); |
|
245 } |
|
246 |
|
247 // ---------------------------------------------------------------------------- |
|
248 // CIpsSetUiBaseArray::ListboxCheckboxFillArrayLabel() |
|
249 // ---------------------------------------------------------------------------- |
|
250 // |
|
251 void CIpsSetUiBaseArray::ListboxCheckboxFillArrayLabel( |
|
252 const CIpsSetUiItem& aBaseItem, |
|
253 TIpsSetUtilsTextPlain& aText ) const |
|
254 { |
|
255 FUNC_LOG; |
|
256 aText = static_cast<const CIpsSetUiItemLinkExt*>( |
|
257 &aBaseItem )->iItemSettingText->Left( KIpsSetUiVisibleTextLength ); |
|
258 } |
|
259 |
|
260 // ---------------------------------------------------------------------------- |
|
261 // CIpsSetUiBaseArray::ListboxItemLabelFillL() |
|
262 // ---------------------------------------------------------------------------- |
|
263 // |
|
264 TPtrC16 CIpsSetUiBaseArray::ListboxItemLabelFillL( |
|
265 CIpsSetUiItem& aBaseItem ) const |
|
266 { |
|
267 FUNC_LOG; |
|
268 // Get the type of the setting item |
|
269 TIpsSetUiSettingsType type = aBaseItem.iItemType; |
|
270 TIpsSetUtilsTextPlain tempSettingText; |
|
271 tempSettingText.Zero(); |
|
272 |
|
273 switch ( type ) |
|
274 { |
|
275 case EIpsSetUiItemMultiLine: |
|
276 ListboxItemFillMultiLineLabel( aBaseItem, tempSettingText ); |
|
277 break; |
|
278 |
|
279 case EIpsSetUiUndefined: |
|
280 ListboxUndefinedFillLabel( aBaseItem, tempSettingText ); |
|
281 break; |
|
282 |
|
283 case EIpsSetUiRadioButtonArray: |
|
284 ListboxRadioButtonFillArrayLabel( aBaseItem, tempSettingText ); |
|
285 break; |
|
286 |
|
287 case EIpsSetUiCheckBoxArray: |
|
288 ListboxCheckboxFillArrayLabel( aBaseItem, tempSettingText ); |
|
289 break; |
|
290 |
|
291 case EIpsSetUiItemText: |
|
292 ListboxItemFillEditTextLabel( aBaseItem, tempSettingText ); |
|
293 break; |
|
294 |
|
295 case EIpsSetUiItemValue: |
|
296 ListboxItemFillEditValueLabel( aBaseItem, tempSettingText ); |
|
297 break; |
|
298 |
|
299 case EIpsSetUiItemTime: |
|
300 ListboxItemFillEditTimeLabel( aBaseItem, tempSettingText ); |
|
301 break; |
|
302 |
|
303 default: |
|
304 // Nothing to show, send empty text |
|
305 break; |
|
306 } |
|
307 |
|
308 // remove line feed from signature line's visible part |
|
309 if( aBaseItem.iItemId == TUid::Uid(EIpsSetUiMailboxSignature) || |
|
310 aBaseItem.iItemId == TUid::Uid(EIpsSetUiMailboxMailboxName) ) |
|
311 { |
|
312 AknTextUtils::ReplaceCharacters( tempSettingText, KCharsToReplace, ' ' ); |
|
313 } |
|
314 |
|
315 // If the setting is marked as password, fill special character |
|
316 // instead of readable text |
|
317 TInt length = tempSettingText.Length(); |
|
318 if ( length > 0 && aBaseItem.iItemFlags.Flag32( KIpsSetUiFlagPassword ) ) |
|
319 { |
|
320 // Add special chars to all type characters in setting field |
|
321 TChar passFill = TChar( iPasswordFill ); |
|
322 tempSettingText.Zero(); |
|
323 tempSettingText.AppendFill( passFill, KIpsSetUiPasswordSecLength ); |
|
324 } |
|
325 |
|
326 return tempSettingText; |
|
327 } |
|
328 |
|
329 /****************************************************************************** |
|
330 |
|
331 Item property editors |
|
332 |
|
333 ******************************************************************************/ |
|
334 |
|
335 // ---------------------------------------------------------------------------- |
|
336 // CIpsSetUiBaseArray::SetItemText() |
|
337 // ---------------------------------------------------------------------------- |
|
338 // |
|
339 void CIpsSetUiBaseArray::SetItemText( |
|
340 CIpsSetUiItem& aBaseItem, |
|
341 const TDesC& aText, |
|
342 const TBool aUpdate ) |
|
343 { |
|
344 FUNC_LOG; |
|
345 switch ( aBaseItem.iItemType ) |
|
346 { |
|
347 case EIpsSetUiItemValue: |
|
348 static_cast<CIpsSetUiItemValue*>( |
|
349 &aBaseItem )->iItemSettingText->Copy( aText ); |
|
350 break; |
|
351 |
|
352 case EIpsSetUiRadioButtonArray: |
|
353 case EIpsSetUiCheckBoxArray: |
|
354 static_cast<CIpsSetUiItemLinkExt*>( |
|
355 &aBaseItem )->iItemSettingText->Copy( aText ); |
|
356 break; |
|
357 |
|
358 default: |
|
359 aBaseItem.SetText( aText ); |
|
360 break; |
|
361 } |
|
362 |
|
363 // Issue update when needed |
|
364 if ( aUpdate ) |
|
365 { |
|
366 Refresh(); |
|
367 } |
|
368 } |
|
369 |
|
370 // ---------------------------------------------------------------------------- |
|
371 // CIpsSetUiBaseArray::ItemText() |
|
372 // ---------------------------------------------------------------------------- |
|
373 // |
|
374 const TDesC& CIpsSetUiBaseArray::ItemText( |
|
375 CIpsSetUiItem& aBaseItem ) |
|
376 { |
|
377 FUNC_LOG; |
|
378 switch ( aBaseItem.iItemType ) |
|
379 { |
|
380 case EIpsSetUiItemValue: |
|
381 return *static_cast<CIpsSetUiItemValue*>( |
|
382 &aBaseItem )->iItemSettingText; |
|
383 |
|
384 case EIpsSetUiRadioButtonArray: |
|
385 case EIpsSetUiCheckBoxArray: |
|
386 return *static_cast<CIpsSetUiItemLinkExt*>( |
|
387 &aBaseItem )->iItemSettingText; |
|
388 } |
|
389 |
|
390 return aBaseItem.Text(); |
|
391 } |
|
392 |
|
393 /****************************************************************************** |
|
394 |
|
395 Base class function definitions |
|
396 |
|
397 ******************************************************************************/ |
|
398 |
|
399 // ---------------------------------------------------------------------------- |
|
400 // CIpsSetUiBaseArray::SearchDoError() |
|
401 // ---------------------------------------------------------------------------- |
|
402 // |
|
403 TBool CIpsSetUiBaseArray::SearchDoError() |
|
404 { |
|
405 FUNC_LOG; |
|
406 return ETrue; |
|
407 } |
|
408 |
|
409 // ---------------------------------------------------------------------------- |
|
410 // CIpsSetUiBaseArray::SearchDoContinuationCheck() |
|
411 // ---------------------------------------------------------------------------- |
|
412 // |
|
413 TBool CIpsSetUiBaseArray::SearchDoContinuationCheck( |
|
414 const CIpsSetUiItem& /* aItem */, |
|
415 const TInt /* aIndex */ ) |
|
416 { |
|
417 FUNC_LOG; |
|
418 return ETrue; |
|
419 } |
|
420 |
|
421 // ---------------------------------------------------------------------------- |
|
422 // CIpsSetUiBaseArray::SearchDoItemCheck() |
|
423 // ---------------------------------------------------------------------------- |
|
424 // |
|
425 TBool CIpsSetUiBaseArray::SearchDoItemCheck( |
|
426 CIpsSetUiItem& /* aItem */ ) |
|
427 { |
|
428 FUNC_LOG; |
|
429 return ETrue; |
|
430 } |
|
431 |
|
432 // ---------------------------------------------------------------------------- |
|
433 // CIpsSetUiBaseArray::MdcaCount() |
|
434 // ---------------------------------------------------------------------------- |
|
435 // |
|
436 TInt CIpsSetUiBaseArray::MdcaCount() const |
|
437 { |
|
438 FUNC_LOG; |
|
439 return iActiveCount; |
|
440 } |
|
441 |
|
442 // ---------------------------------------------------------------------------- |
|
443 // CIpsSetUiBaseArray::MdcaPoint() |
|
444 // ---------------------------------------------------------------------------- |
|
445 // |
|
446 TPtrC16 CIpsSetUiBaseArray::MdcaPoint( TInt aIndex ) const |
|
447 { |
|
448 FUNC_LOG; |
|
449 // First search the currently active resource to array and check |
|
450 // the given index is in the current array |
|
451 IPS_ASSERT_DEBUG( aIndex < StackCountItems(), KErrOverflow, EBaseArray ); |
|
452 |
|
453 // Temp text ptr |
|
454 TPtr tempText = iTempText->Des(); |
|
455 |
|
456 // Do a sanity check for index and return null text if out of range |
|
457 if ( !iFinder || aIndex < 0 || aIndex >= StackCountItems()) |
|
458 { |
|
459 tempText.Zero(); |
|
460 tempText.Append(KNullDesC); |
|
461 return tempText; |
|
462 } |
|
463 |
|
464 // Search for item from the active array |
|
465 CIpsSetUiItem* setting = iFinder->FinderArray()->At( aIndex ).iItem; // faulty CS warning |
|
466 IPS_ASSERT_DEBUG( setting , KErrNotFound, EBaseArray ); |
|
467 |
|
468 // Prepare strings |
|
469 // Send custom event and if not used, prepare default |
|
470 if ( !EventCustomMdcaPoint( setting->iItemId, tempText ) ) |
|
471 { |
|
472 // Initialize string |
|
473 tempText.Zero(); |
|
474 tempText.Append( KIpsSetUiStrSpace ); |
|
475 tempText.Append( KColumnListSeparator ); |
|
476 tempText.Append( *setting->iItemLabel ); |
|
477 |
|
478 // Submenus doesn't contain other information |
|
479 if ( !ItemSubArrayCheck( *setting ) ) |
|
480 { |
|
481 tempText.Append( KColumnListSeparator ); |
|
482 tempText.Append( KColumnListSeparator ); |
|
483 |
|
484 TIpsSetUtilsTextPlain tempSettingText; |
|
485 // Try to add the text |
|
486 TRAP_IGNORE( tempSettingText = |
|
487 ListboxItemLabelFillL( *setting ) ); |
|
488 |
|
489 // Fill the setting text with string |
|
490 if ( tempSettingText.Length() ) |
|
491 { |
|
492 tempText.Append( tempSettingText ); |
|
493 } |
|
494 else |
|
495 { |
|
496 tempText.Append( KIpsSetUiStrSpace ); |
|
497 } |
|
498 |
|
499 // Add the special string after compulsory fields |
|
500 if ( setting->iItemFlags.Flag32( KIpsSetUiFlagCompulsory ) ) |
|
501 { |
|
502 tempText.Append( KIpsSetUiStrCompulsory ); |
|
503 } |
|
504 |
|
505 // Do the number conversion, if allowed |
|
506 if ( setting->iItemFlags.Flag32( KIpsSetUiFlagLangSpecificNumConv ) ) |
|
507 { |
|
508 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( |
|
509 tempText ); |
|
510 } |
|
511 } |
|
512 } |
|
513 |
|
514 setting = NULL; |
|
515 return tempText; |
|
516 } |
|
517 |
|
518 /****************************************************************************** |
|
519 |
|
520 Resource loading functions |
|
521 |
|
522 ******************************************************************************/ |
|
523 |
|
524 // ---------------------------------------------------------------------------- |
|
525 // CIpsSetUiBaseArray::LoadDynamicSettingItemL() |
|
526 // ---------------------------------------------------------------------------- |
|
527 // |
|
528 void CIpsSetUiBaseArray::LoadDynamicSettingItemL( |
|
529 TResourceReader& aReader, |
|
530 CIpsSetUiItem& aBaseItem ) |
|
531 { |
|
532 FUNC_LOG; |
|
533 // Read rest of the settings first |
|
534 // STRUCT IPS_SET_ITEM : LTEXT itemlabel |
|
535 HBufC* txt = aReader.ReadHBufCL(); // message text |
|
536 |
|
537 if ( txt ) |
|
538 { |
|
539 aBaseItem.iItemLabel->Copy( *txt ); |
|
540 } |
|
541 |
|
542 delete txt; |
|
543 txt = NULL; |
|
544 |
|
545 // STRUCT IPS_SET_ITEM : LLINK itemmaxlength |
|
546 TInt maxLength = aReader.ReadInt32(); |
|
547 |
|
548 // STRUCT IPS_SET_ITEM : LONG itemflags |
|
549 aBaseItem.iItemFlags = MAKE_TUINT64( aReader.ReadInt32(), 0 ); |
|
550 |
|
551 // STRUCT IPS_SET_ITEM : LLINK itemarray |
|
552 TInt linkResourceId = aReader.ReadInt32(); |
|
553 |
|
554 // STRUCT IPS_SET_ITEM : WORD itemappereance |
|
555 TIpsSetUiSettingsType subtype = |
|
556 static_cast<TIpsSetUiSettingsType>( aReader.ReadInt16() ); |
|
557 |
|
558 // Finally add the item to list |
|
559 HandleDynamicSettingsItemL( |
|
560 aBaseItem, maxLength, subtype, linkResourceId ); |
|
561 |
|
562 // The basic data has been set, now init the userdata section |
|
563 InitUserData( aBaseItem ); |
|
564 } |
|
565 |
|
566 // ---------------------------------------------------------------------------- |
|
567 // CIpsSetUiBaseArray::UpdateItemEditTextL() |
|
568 // ---------------------------------------------------------------------------- |
|
569 // |
|
570 void CIpsSetUiBaseArray::UpdateItemEditTextL( |
|
571 CIpsSetUiItem& aBaseItem, |
|
572 const TInt aMaxLength ) |
|
573 { |
|
574 FUNC_LOG; |
|
575 CIpsSetUiItemsEditText* text = |
|
576 static_cast<CIpsSetUiItemsEditText*>( &aBaseItem ); |
|
577 text->iItemMaxLength = aMaxLength; |
|
578 text = NULL; |
|
579 } |
|
580 |
|
581 // ---------------------------------------------------------------------------- |
|
582 // CIpsSetUiBaseArray::UpdateItemEditValueL() |
|
583 // ---------------------------------------------------------------------------- |
|
584 // |
|
585 void CIpsSetUiBaseArray::UpdateItemEditValueL( |
|
586 CIpsSetUiItem& aBaseItem, |
|
587 const TInt aMaxLength ) |
|
588 { |
|
589 FUNC_LOG; |
|
590 CIpsSetUiItemValue* value = |
|
591 static_cast<CIpsSetUiItemValue*>( &aBaseItem ); |
|
592 value->iItemMaxLength = aMaxLength; |
|
593 value = NULL; |
|
594 } |
|
595 |
|
596 // ---------------------------------------------------------------------------- |
|
597 // CIpsSetUiBaseArray::HandleDynamicSettingsItemL() |
|
598 // ---------------------------------------------------------------------------- |
|
599 // |
|
600 void CIpsSetUiBaseArray::HandleDynamicSettingsItemL( |
|
601 CIpsSetUiItem& aBaseItem, |
|
602 const TInt aMaxLength, |
|
603 const TIpsSetUiSettingsType aSubType, |
|
604 const TInt aLinkResourceId ) |
|
605 { |
|
606 FUNC_LOG; |
|
607 switch ( aBaseItem.Type() ) |
|
608 { |
|
609 // Load dynamically linked items or submenus |
|
610 case EIpsSetUiMenuArray: |
|
611 case EIpsSetUiRadioButtonArray: |
|
612 case EIpsSetUiCheckBoxArray: |
|
613 case EIpsSetUiItemMultiLine: |
|
614 LoadDynamicSettingsItemLinkItemL( |
|
615 aBaseItem, aSubType, aLinkResourceId ); |
|
616 break; |
|
617 |
|
618 // Finish text item |
|
619 case EIpsSetUiItemText: |
|
620 UpdateItemEditTextL( aBaseItem, aMaxLength ); |
|
621 break; |
|
622 |
|
623 // Finish number item |
|
624 case EIpsSetUiItemValue: |
|
625 case EIpsSetUiItemTime: |
|
626 UpdateItemEditValueL( aBaseItem, aMaxLength ); |
|
627 break; |
|
628 |
|
629 // Other items are already finished |
|
630 case EIpsSetUiItemRadioButton: |
|
631 case EIpsSetUiItemCheckBox: |
|
632 default: |
|
633 break; |
|
634 } |
|
635 } |
|
636 |
|
637 // ---------------------------------------------------------------------------- |
|
638 // CIpsSetUiBaseArray::CreateItemToArrayL() |
|
639 // ---------------------------------------------------------------------------- |
|
640 // |
|
641 CIpsSetUiItem* CIpsSetUiBaseArray::CreateItemToArrayL( |
|
642 const TIpsSetUiSettingsType aType, |
|
643 const TUid& aId, |
|
644 CIpsSetUiBaseItemArray& aItemArray ) |
|
645 { |
|
646 FUNC_LOG; |
|
647 CIpsSetUiItem* base = NULL; |
|
648 |
|
649 switch ( aType ) |
|
650 { |
|
651 // Create array item |
|
652 case EIpsSetUiMenuArray: |
|
653 base = CIpsSetUiItemLink::NewLC(); |
|
654 break; |
|
655 |
|
656 // Force manual item creation |
|
657 case EIpsSetUiUndefined: |
|
658 base = CreateCustomItemToArrayLC( aId ); |
|
659 IPS_ASSERT_DEBUG( base , EUnidentifiedItem, EBaseArray ); |
|
660 break; |
|
661 |
|
662 // Create radiobutton array item |
|
663 case EIpsSetUiRadioButtonArray: |
|
664 case EIpsSetUiCheckBoxArray: |
|
665 case EIpsSetUiItemMultiLine: |
|
666 base = CIpsSetUiItemLinkExt::NewLC(); |
|
667 break; |
|
668 |
|
669 // Create edit text item |
|
670 case EIpsSetUiItemText: |
|
671 base = CIpsSetUiItemsEditText::NewLC(); |
|
672 break; |
|
673 |
|
674 // Create edit number item |
|
675 case EIpsSetUiItemValue: |
|
676 case EIpsSetUiItemTime: |
|
677 base = CIpsSetUiItemValue::NewLC(); |
|
678 break; |
|
679 |
|
680 // Create normal base item |
|
681 case EIpsSetUiItemRadioButton: |
|
682 case EIpsSetUiItemCheckBox: |
|
683 default: |
|
684 base = CIpsSetUiItem::NewLC(); |
|
685 break; |
|
686 } |
|
687 |
|
688 // Add to array |
|
689 aItemArray.AppendL( base ); |
|
690 CleanupStack::Pop( base ); |
|
691 |
|
692 return base; |
|
693 } |
|
694 |
|
695 // ---------------------------------------------------------------------------- |
|
696 // CIpsSetUiBaseArray::LoadDynamicSettingsItemLinkItemL() |
|
697 // ---------------------------------------------------------------------------- |
|
698 // |
|
699 void CIpsSetUiBaseArray::LoadDynamicSettingsItemLinkItemL( |
|
700 CIpsSetUiItem& aBaseItem, |
|
701 const TIpsSetUiSettingsType aSubType, |
|
702 const TInt aLinkResourceId ) |
|
703 { |
|
704 FUNC_LOG; |
|
705 // Prepare the item |
|
706 CIpsSetUiItemLink* linkItem = static_cast<CIpsSetUiItemLink*>( &aBaseItem ); |
|
707 linkItem->iItemAppereance = aSubType; |
|
708 linkItem->iItemFlags.SetFlag32( KIpsSetUiFlagUpdateOnChange ); |
|
709 |
|
710 // Start reading only if resource is provided |
|
711 if ( aLinkResourceId ) |
|
712 { |
|
713 linkItem->iItemLinkArray = |
|
714 new ( ELeave ) CIpsSetUiBaseItemArray( |
|
715 KIpsSetUiArrayGranularity ); |
|
716 |
|
717 // Start loading the settings |
|
718 LoadSettingItemsToArrayL( aLinkResourceId, *linkItem->iItemLinkArray ); |
|
719 } |
|
720 |
|
721 linkItem = NULL; |
|
722 } |
|
723 |
|
724 // ---------------------------------------------------------------------------- |
|
725 // CIpsSetUiBaseArray::LoadSettingArrayFromResource() |
|
726 // ---------------------------------------------------------------------------- |
|
727 // |
|
728 void CIpsSetUiBaseArray::LoadSettingArrayFromResourceL( |
|
729 const TInt aResourceId ) |
|
730 { |
|
731 FUNC_LOG; |
|
732 // Start reading only if resource is provided |
|
733 if ( aResourceId ) |
|
734 { |
|
735 iResourceStack->AppendL( aResourceId ); |
|
736 const TInt items = iItemArray->Count(); |
|
737 |
|
738 // Begin to read the items from the resource |
|
739 TInt count = LoadSettingItemsToArrayL( aResourceId, *iItemArray ); |
|
740 |
|
741 // Update the item count |
|
742 UpdateActiveItemsCount( count ); |
|
743 } |
|
744 } |
|
745 |
|
746 // ---------------------------------------------------------------------------- |
|
747 // CIpsSetUiBaseArray::LoadSettingItemsToArrayL() |
|
748 // ---------------------------------------------------------------------------- |
|
749 // |
|
750 TInt CIpsSetUiBaseArray::LoadSettingItemsToArrayL( |
|
751 const TInt aResourceId, |
|
752 CIpsSetUiBaseItemArray& aItemArray ) |
|
753 { |
|
754 FUNC_LOG; |
|
755 // Define new read based on last item |
|
756 TResourceReader reader; |
|
757 iEnv->CreateResourceReaderLC( |
|
758 reader, aResourceId ); |
|
759 |
|
760 // Get the count of items in resource |
|
761 TInt count = reader.ReadInt16(); |
|
762 for ( TInt loop = 0; loop < count; loop++ ) |
|
763 { |
|
764 // Read the settings from the resource |
|
765 |
|
766 // STRUCT IPS_SET_ITEM : WORD itemtype |
|
767 TIpsSetUiSettingsType type = |
|
768 static_cast<TIpsSetUiSettingsType>( reader.ReadInt16() ); |
|
769 |
|
770 // STRUCT IPS_SET_ITEM : WORD itemid |
|
771 TUid id = TUid::Uid( reader.ReadInt16() ); |
|
772 |
|
773 // Create the setting item |
|
774 CIpsSetUiItem* base = |
|
775 CreateItemToArrayL( type, id, aItemArray ); |
|
776 base->iItemId = id; |
|
777 base->iItemType = type; |
|
778 base->iItemResourceId = aResourceId; |
|
779 |
|
780 // Start loading the item, based on item type |
|
781 LoadDynamicSettingItemL( reader, *base ); |
|
782 base = NULL; |
|
783 } |
|
784 |
|
785 CleanupStack::PopAndDestroy(); // reader |
|
786 |
|
787 return count; |
|
788 } |
|
789 |
|
790 /****************************************************************************** |
|
791 |
|
792 Item hide functions |
|
793 |
|
794 ******************************************************************************/ |
|
795 |
|
796 // ---------------------------------------------------------------------------- |
|
797 // CIpsSetUiBaseArray::IsHidden() |
|
798 // ---------------------------------------------------------------------------- |
|
799 // |
|
800 TInt CIpsSetUiBaseArray::IsHidden( const TUid& aId ) const |
|
801 { |
|
802 FUNC_LOG; |
|
803 return IsHidden( *GetItem( aId ) ); |
|
804 } |
|
805 |
|
806 // ---------------------------------------------------------------------------- |
|
807 // CIpsSetUiBaseArray::IsHidden() |
|
808 // ---------------------------------------------------------------------------- |
|
809 // |
|
810 TInt CIpsSetUiBaseArray::IsHidden( |
|
811 const CIpsSetUiItem& aItem ) const |
|
812 { |
|
813 FUNC_LOG; |
|
814 if ( aItem.iItemFlags.Flag32( KIpsSetUiFlagPermanentlyHidden ) ) |
|
815 { |
|
816 return KErrNotSupported; |
|
817 } |
|
818 else if ( aItem.iItemFlags.Flag32( KIpsSetUiFlagHidden ) ) |
|
819 { |
|
820 return KErrNotFound; |
|
821 } |
|
822 else |
|
823 { |
|
824 return KErrNone; |
|
825 } |
|
826 } |
|
827 |
|
828 // ---------------------------------------------------------------------------- |
|
829 // CIpsSetUiBaseArray::IsHidden() |
|
830 // ---------------------------------------------------------------------------- |
|
831 // |
|
832 TInt CIpsSetUiBaseArray::IsHidden( const TInt aIndex ) const |
|
833 { |
|
834 FUNC_LOG; |
|
835 return IsHidden( *GetItem( aIndex ) ); |
|
836 } |
|
837 |
|
838 // ---------------------------------------------------------------------------- |
|
839 // CIpsSetUiBaseArray::DoHideItems() |
|
840 // ---------------------------------------------------------------------------- |
|
841 // |
|
842 void CIpsSetUiBaseArray::DoHideItems( const TBool aHide ) |
|
843 { |
|
844 FUNC_LOG; |
|
845 // All items collected, set their flags hidden flags |
|
846 CIpsSetUiFinderArray& array = *iFinder->FinderArray(); |
|
847 TInt item = array.Count(); |
|
848 while ( --item >= 0 ) |
|
849 { |
|
850 CIpsSetUiItem* base = array[item].iItem; |
|
851 if ( aHide ) |
|
852 { |
|
853 base->iItemFlags.SetFlag32( KIpsSetUiFlagHidden ); |
|
854 } |
|
855 else |
|
856 { |
|
857 base->iItemFlags.ClearFlag32( KIpsSetUiFlagHidden ); |
|
858 } |
|
859 } |
|
860 } |
|
861 |
|
862 // ---------------------------------------------------------------------------- |
|
863 // CIpsSetUiBaseArray::SetHideItem() |
|
864 // ---------------------------------------------------------------------------- |
|
865 // |
|
866 void CIpsSetUiBaseArray::SetHideItem( |
|
867 const TBool aHide, |
|
868 const TUid& aId, |
|
869 const TBool aUpdate ) |
|
870 { |
|
871 FUNC_LOG; |
|
872 if ( aHide ) |
|
873 { |
|
874 GetItem( aId )->iItemFlags.SetFlag32( KIpsSetUiFlagHidden ); |
|
875 } |
|
876 else |
|
877 { |
|
878 GetItem( aId )->iItemFlags.ClearFlag32( KIpsSetUiFlagHidden ); |
|
879 } |
|
880 |
|
881 // Handle the array change |
|
882 if ( aUpdate ) |
|
883 { |
|
884 Refresh(); |
|
885 } |
|
886 } |
|
887 |
|
888 // ---------------------------------------------------------------------------- |
|
889 // CIpsSetUiBaseArray::SetHideItem() |
|
890 // ---------------------------------------------------------------------------- |
|
891 // |
|
892 void CIpsSetUiBaseArray::SetHideItem( |
|
893 const TBool aHide, |
|
894 CIpsSetUiItem& aItem, |
|
895 const TBool aUpdate ) |
|
896 { |
|
897 FUNC_LOG; |
|
898 if ( aHide ) |
|
899 { |
|
900 aItem.iItemFlags.SetFlag32( KIpsSetUiFlagHidden ); |
|
901 } |
|
902 else |
|
903 { |
|
904 aItem.iItemFlags.ClearFlag32( KIpsSetUiFlagHidden ); |
|
905 } |
|
906 |
|
907 // Handle the array change |
|
908 if ( aUpdate ) |
|
909 { |
|
910 Refresh(); |
|
911 } |
|
912 } |
|
913 |
|
914 /****************************************************************************** |
|
915 |
|
916 Item search functions |
|
917 |
|
918 ******************************************************************************/ |
|
919 |
|
920 // ---------------------------------------------------------------------------- |
|
921 // CIpsSetUiBaseArray::InitDefaultSearch() |
|
922 // ---------------------------------------------------------------------------- |
|
923 // |
|
924 void CIpsSetUiBaseArray::InitDefaultSearch( |
|
925 const TBool aExcludeHidden ) const |
|
926 { |
|
927 FUNC_LOG; |
|
928 // In default search, subfolders are included and hidden items are not |
|
929 // included into the search |
|
930 TUint64 search = 0x00; |
|
931 search |= CIpsSetUiFinder::EFinderSearchSubFolders; |
|
932 if ( aExcludeHidden ) |
|
933 { |
|
934 search |= CIpsSetUiFinder::EFinderDoHideCheck; |
|
935 } |
|
936 else |
|
937 { |
|
938 search &= CIpsSetUiFinder::EFinderDoHideCheck; |
|
939 } |
|
940 iFinder->SetSearchFlags( search ); |
|
941 } |
|
942 |
|
943 // ---------------------------------------------------------------------------- |
|
944 // CIpsSetUiBaseArray::ItemIndex() |
|
945 // ---------------------------------------------------------------------------- |
|
946 // |
|
947 TInt CIpsSetUiBaseArray::ItemIndex( |
|
948 const TUid& aId, |
|
949 const TBool aExcludeHidden ) const |
|
950 { |
|
951 FUNC_LOG; |
|
952 InitDefaultSearch( aExcludeHidden ); |
|
953 |
|
954 // Try to make the search, but if the search fails, allow caller |
|
955 // to handle the result |
|
956 TRAP_IGNORE( iFinder->StartSearchL( *iItemArray, aId ) ); |
|
957 |
|
958 TInt ret( KErrNotFound ); |
|
959 if ( iFinder->FinderArray()->Count() ) |
|
960 { |
|
961 // Return the found item |
|
962 ret = iFinder->FinderArray()->At( 0 ).iIndex; |
|
963 } |
|
964 return ret; |
|
965 } |
|
966 |
|
967 // ---------------------------------------------------------------------------- |
|
968 // CIpsSetUiBaseArray::GetItem() |
|
969 // ---------------------------------------------------------------------------- |
|
970 // |
|
971 CIpsSetUiItem* CIpsSetUiBaseArray::GetItem( |
|
972 const TInt aIndex, |
|
973 const TBool aExcludeHidden ) const |
|
974 { |
|
975 FUNC_LOG; |
|
976 // First search the currently active resource to array and check |
|
977 // the given index is in the current array |
|
978 TBool ok = aIndex < StackCountItems( aExcludeHidden ); |
|
979 IPS_ASSERT_DEBUG( ok, KErrOverflow, EBaseArray ); |
|
980 IPS_ASSERT_DEBUG( aIndex >= 0, KErrUnderflow, EBaseArray ); |
|
981 |
|
982 // Return the found item |
|
983 return ok ? iFinder->FinderArray()->At( aIndex ).iItem : NULL; // CS warning |
|
984 } |
|
985 |
|
986 // ---------------------------------------------------------------------------- |
|
987 // CIpsSetUiBaseArray::GetItem() |
|
988 // ---------------------------------------------------------------------------- |
|
989 // |
|
990 CIpsSetUiItem* CIpsSetUiBaseArray::GetItem( |
|
991 const TUid& aId, |
|
992 const TBool aExcludeHidden ) const |
|
993 { |
|
994 FUNC_LOG; |
|
995 InitDefaultSearch( aExcludeHidden ); |
|
996 |
|
997 // Try to make the search, but if the search fails, allow caller |
|
998 // to handle the result |
|
999 TRAP_IGNORE( iFinder->StartSearchL( *iItemArray, aId ) ); |
|
1000 |
|
1001 // Return the found item |
|
1002 return iFinder->FinderArray()->At( 0 ).iItem; |
|
1003 } |
|
1004 |
|
1005 // ---------------------------------------------------------------------------- |
|
1006 // CIpsSetUiBaseArray::GetSubItem() |
|
1007 // ---------------------------------------------------------------------------- |
|
1008 // |
|
1009 CIpsSetUiItem* CIpsSetUiBaseArray::GetSubItem( |
|
1010 const CIpsSetUiItem& aBaseItem, |
|
1011 const TUid& aId, |
|
1012 const TBool aExcludeHidden ) const |
|
1013 { |
|
1014 FUNC_LOG; |
|
1015 // Make sure the item has subitems |
|
1016 if ( ItemSubItemCheck( aBaseItem ) ) |
|
1017 { |
|
1018 // Convert the item to link item |
|
1019 const CIpsSetUiItemLink* link = |
|
1020 static_cast<const CIpsSetUiItemLink*>( &aBaseItem ); |
|
1021 |
|
1022 // Get item count |
|
1023 TInt count = link->iItemLinkArray ? |
|
1024 link->iItemLinkArray->Count() : KErrNotFound; |
|
1025 |
|
1026 // Find the item from the array |
|
1027 while ( --count >= 0) |
|
1028 { |
|
1029 CIpsSetUiItem* base = ( *link->iItemLinkArray )[count]; |
|
1030 |
|
1031 if ( IsVisibleCheck( aBaseItem, aExcludeHidden ) && |
|
1032 base->iItemId == aId ) |
|
1033 { |
|
1034 return base; |
|
1035 } |
|
1036 } |
|
1037 } |
|
1038 |
|
1039 return NULL; |
|
1040 } |
|
1041 |
|
1042 // ---------------------------------------------------------------------------- |
|
1043 // CIpsSetUiBaseArray::GetSubItem() |
|
1044 // ---------------------------------------------------------------------------- |
|
1045 // |
|
1046 CIpsSetUiItem* CIpsSetUiBaseArray::GetSubItem( |
|
1047 const CIpsSetUiItem& aBaseItem, |
|
1048 const TInt aIndex, |
|
1049 const TBool aExcludeHidden ) const |
|
1050 { |
|
1051 FUNC_LOG; |
|
1052 CIpsSetUiItem* base = NULL; |
|
1053 |
|
1054 // Make sure the item has subitems |
|
1055 if ( ItemSubItemCheck( aBaseItem ) ) |
|
1056 { |
|
1057 // Convert the item to link item |
|
1058 const CIpsSetUiItemLink* link = |
|
1059 static_cast<const CIpsSetUiItemLink*>( &aBaseItem ); |
|
1060 |
|
1061 // Get the item count and make sure the required index is |
|
1062 // below the number of items |
|
1063 TInt count = link->iItemLinkArray ? |
|
1064 link->iItemLinkArray->Count() : KErrNotFound; |
|
1065 count = ( aIndex >= 0 && aIndex < count ) ? count : KErrNotFound; |
|
1066 TInt index = KErrNotFound; |
|
1067 TInt item = 0; |
|
1068 |
|
1069 for ( ; index != aIndex && item < count; item++ ) |
|
1070 { |
|
1071 base = ( *link->iItemLinkArray )[item]; |
|
1072 |
|
1073 if ( IsVisibleCheck( *base, aExcludeHidden ) ) |
|
1074 { |
|
1075 index++; |
|
1076 } |
|
1077 } |
|
1078 |
|
1079 // At the end of the items and still not found |
|
1080 if ( item == count && index != aIndex ) |
|
1081 { |
|
1082 base = NULL; |
|
1083 } |
|
1084 } |
|
1085 |
|
1086 return base; |
|
1087 } |
|
1088 |
|
1089 |
|
1090 // ---------------------------------------------------------------------------- |
|
1091 // CIpsSetUiBaseArray::GetSubItemByType() |
|
1092 // ---------------------------------------------------------------------------- |
|
1093 // |
|
1094 CIpsSetUiItem* CIpsSetUiBaseArray::GetSubItemByType( |
|
1095 const CIpsSetUiItem& aBaseItem, |
|
1096 const TInt aType ) const |
|
1097 { |
|
1098 FUNC_LOG; |
|
1099 CIpsSetUiItem* base = NULL; |
|
1100 |
|
1101 // Make sure the item has subitems |
|
1102 if ( ItemSubItemCheck( aBaseItem ) ) |
|
1103 { |
|
1104 // Convert the item to link item |
|
1105 const CIpsSetUiItemLink* link = |
|
1106 static_cast<const CIpsSetUiItemLink*>( &aBaseItem ); |
|
1107 |
|
1108 // Get the item count and make sure the required index is |
|
1109 // below the number of items |
|
1110 TInt count = link->iItemLinkArray ? |
|
1111 link->iItemLinkArray->Count() : KErrNotFound; |
|
1112 |
|
1113 for ( TInt item = 0 ; !base && item < count; item++ ) |
|
1114 { |
|
1115 base = ( *link->iItemLinkArray )[item]; |
|
1116 base = ( base && base->Type() == aType ) ? base : NULL; |
|
1117 } |
|
1118 } |
|
1119 |
|
1120 return base; |
|
1121 } |
|
1122 |
|
1123 // ---------------------------------------------------------------------------- |
|
1124 // CIpsSetUiBaseArray::GetSubItemIndex() |
|
1125 // ---------------------------------------------------------------------------- |
|
1126 // |
|
1127 TInt CIpsSetUiBaseArray::GetSubItemIndex( |
|
1128 const CIpsSetUiItemLink& aLinkItem, |
|
1129 const TUid& aId, |
|
1130 const TBool aExcludeHidden ) const |
|
1131 { |
|
1132 FUNC_LOG; |
|
1133 TBool found = EFalse; |
|
1134 TInt index = KErrNotFound; |
|
1135 |
|
1136 if ( aLinkItem.iItemLinkArray ) |
|
1137 { |
|
1138 CIpsSetUiItem* subItem = NULL; |
|
1139 |
|
1140 const TInt items = aLinkItem.iItemLinkArray->Count(); |
|
1141 TInt button = KErrNotFound; |
|
1142 |
|
1143 // Seek the item id and return its index |
|
1144 while ( !found && ++button < items ) |
|
1145 { |
|
1146 subItem = ( *aLinkItem.iItemLinkArray )[button]; |
|
1147 |
|
1148 // Ignore hidden items AND item is not hidden OR |
|
1149 // check all the items |
|
1150 if ( IsVisibleCheck( *subItem, aExcludeHidden ) ) |
|
1151 { |
|
1152 ++index; |
|
1153 |
|
1154 found = ( subItem->iItemId == aId ); |
|
1155 } |
|
1156 } |
|
1157 } |
|
1158 |
|
1159 return found ? index : KErrNotFound; |
|
1160 } |
|
1161 |
|
1162 // ---------------------------------------------------------------------------- |
|
1163 // CIpsSetUiBaseArray::GetSubItemIndex() |
|
1164 // ---------------------------------------------------------------------------- |
|
1165 // |
|
1166 TInt CIpsSetUiBaseArray::GetSubItemIndex( |
|
1167 const CIpsSetUiItemLink& aLinkItem, |
|
1168 const TInt aIndex, |
|
1169 const TBool aActualIndex ) const |
|
1170 { |
|
1171 FUNC_LOG; |
|
1172 TInt result = KErrNotFound; |
|
1173 |
|
1174 if ( aLinkItem.iItemLinkArray ) |
|
1175 { |
|
1176 CIpsSetUiItem* radioButton = NULL; |
|
1177 TInt visibleCount = KErrNotFound; |
|
1178 TInt resourceCount = KErrNotFound; |
|
1179 |
|
1180 TInt items = aLinkItem.iItemLinkArray->Count(); |
|
1181 |
|
1182 for ( TInt index = 0; result < 0 && index < items; index++ ) |
|
1183 { |
|
1184 radioButton = ( *aLinkItem.iItemLinkArray )[index]; |
|
1185 |
|
1186 resourceCount++; |
|
1187 if ( !IsHidden( *radioButton ) ) |
|
1188 { |
|
1189 visibleCount++; |
|
1190 } |
|
1191 |
|
1192 if ( aActualIndex ) |
|
1193 { |
|
1194 if ( aIndex == visibleCount ) |
|
1195 { |
|
1196 result = resourceCount; |
|
1197 } |
|
1198 } |
|
1199 else |
|
1200 { |
|
1201 if ( aIndex == resourceCount ) |
|
1202 { |
|
1203 result = visibleCount; |
|
1204 } |
|
1205 } |
|
1206 } |
|
1207 } |
|
1208 |
|
1209 return result; |
|
1210 } |
|
1211 |
|
1212 // ---------------------------------------------------------------------------- |
|
1213 // CIpsSetUiBaseArray::SearchResourceL() |
|
1214 // ---------------------------------------------------------------------------- |
|
1215 // |
|
1216 void CIpsSetUiBaseArray::SearchResourceL( |
|
1217 const TInt aResourceId, |
|
1218 const TBool aExcludeHidden ) const |
|
1219 { |
|
1220 FUNC_LOG; |
|
1221 // When hiding all, search through all subfolders and allow the state |
|
1222 // change |
|
1223 TUint64 search = 0x00; |
|
1224 search |= CIpsSetUiFinder::EFinderSearchSubFolders; |
|
1225 search |= CIpsSetUiFinder::EFinderResourceSearch; |
|
1226 if ( aExcludeHidden ) |
|
1227 { |
|
1228 search |= CIpsSetUiFinder::EFinderDoHideCheck; |
|
1229 } |
|
1230 else |
|
1231 { |
|
1232 search &= ~CIpsSetUiFinder::EFinderDoHideCheck; |
|
1233 } |
|
1234 iFinder->SetSearchFlags( search ); |
|
1235 |
|
1236 // Try to hide items and panic in any error |
|
1237 TRAPD( error, iFinder->StartSearchL( *iItemArray, aResourceId ) ); |
|
1238 if ( error != KErrNone ) |
|
1239 { |
|
1240 IPS_ASSERT_DEBUG( EFalse, error, EBaseArray ); |
|
1241 } |
|
1242 } |
|
1243 |
|
1244 // ---------------------------------------------------------------------------- |
|
1245 // CIpsSetUiBaseArray::GetResource() |
|
1246 // ---------------------------------------------------------------------------- |
|
1247 // |
|
1248 CIpsSetUiFinderArray* CIpsSetUiBaseArray::GetResourceL( |
|
1249 const TInt aResourceId, |
|
1250 const TBool aExcludeHidden ) const |
|
1251 { |
|
1252 FUNC_LOG; |
|
1253 // Start the resource search |
|
1254 SearchResourceL( aResourceId, aExcludeHidden ); |
|
1255 |
|
1256 // Return the pointer to array |
|
1257 return iFinder->FinderArray(); |
|
1258 } |
|
1259 |
|
1260 // ---------------------------------------------------------------------------- |
|
1261 // CIpsSetUiBaseArray::GetResourceLC() |
|
1262 // ---------------------------------------------------------------------------- |
|
1263 // |
|
1264 CIpsSetUiFinderArray* CIpsSetUiBaseArray::GetResourceLC( |
|
1265 const TInt aResourceId, |
|
1266 const TBool aExcludeHidden ) const |
|
1267 { |
|
1268 FUNC_LOG; |
|
1269 // Start the resource search |
|
1270 SearchResourceL( aResourceId, aExcludeHidden ); |
|
1271 TUint64 search = iFinder->SearchFlags(); |
|
1272 search |= CIpsSetUiFinder::EFinderMoveOwnership; |
|
1273 iFinder->SetSearchFlags( search ); |
|
1274 |
|
1275 // Return the copy of the array |
|
1276 return iFinder->FinderArrayLC(); |
|
1277 } |
|
1278 |
|
1279 // ---------------------------------------------------------------------------- |
|
1280 // CIpsSetUiBaseArray::ItemSubArrayCheck() |
|
1281 // ---------------------------------------------------------------------------- |
|
1282 // |
|
1283 TBool CIpsSetUiBaseArray::ItemSubArrayCheck( |
|
1284 const CIpsSetUiItem& aBaseItem ) const |
|
1285 { |
|
1286 FUNC_LOG; |
|
1287 // Check if the item type is menu array |
|
1288 return aBaseItem.Type() == EIpsSetUiMenuArray; |
|
1289 } |
|
1290 |
|
1291 // ---------------------------------------------------------------------------- |
|
1292 // CIpsSetUiBaseArray::ItemSubItemCheck() |
|
1293 // ---------------------------------------------------------------------------- |
|
1294 // |
|
1295 TBool CIpsSetUiBaseArray::ItemSubItemCheck( |
|
1296 const CIpsSetUiItem& aBaseItem ) const |
|
1297 { |
|
1298 FUNC_LOG; |
|
1299 // if item is not any of the following types it cannot contain subitems |
|
1300 if ( aBaseItem.iItemType != EIpsSetUiMenuArray && |
|
1301 aBaseItem.iItemType != EIpsSetUiRadioButtonArray && |
|
1302 aBaseItem.iItemType != EIpsSetUiCheckBoxArray && |
|
1303 aBaseItem.iItemType != EIpsSetUiUndefined && |
|
1304 aBaseItem.iItemType != EIpsSetUiItemMultiLine ) |
|
1305 { |
|
1306 return EFalse; |
|
1307 } |
|
1308 |
|
1309 const CIpsSetUiItemLink* link = |
|
1310 static_cast<const CIpsSetUiItemLink*>( &aBaseItem ); |
|
1311 |
|
1312 // If the item has an array and it contains items, return true |
|
1313 return ( link->iItemLinkArray && |
|
1314 link->iItemLinkArray->Count() > 0 ); |
|
1315 } |
|
1316 |
|
1317 // ---------------------------------------------------------------------------- |
|
1318 // CIpsSetUiBaseArray::SetBetweenValues() |
|
1319 // ---------------------------------------------------------------------------- |
|
1320 // |
|
1321 void CIpsSetUiBaseArray::SetBetweenValues( |
|
1322 TInt& aValue, |
|
1323 TInt aMin, |
|
1324 TInt aMax ) const |
|
1325 { |
|
1326 FUNC_LOG; |
|
1327 // Make a sanity check |
|
1328 if ( aMin > aMax ) |
|
1329 { |
|
1330 // Swap the values |
|
1331 TInt temp = aMin; |
|
1332 aMin = aMax; |
|
1333 aMax = temp; |
|
1334 } |
|
1335 |
|
1336 // Make sure that we are above the minimum |
|
1337 if ( aValue < aMin ) |
|
1338 { |
|
1339 aValue = aMin; |
|
1340 } |
|
1341 |
|
1342 // Make sure that we are below the maximum |
|
1343 if ( aValue > aMax ) |
|
1344 { |
|
1345 aValue = aMax; |
|
1346 } |
|
1347 } |
|
1348 |
|
1349 // ---------------------------------------------------------------------------- |
|
1350 // CIpsSetUiBaseArray::Refresh() |
|
1351 // ---------------------------------------------------------------------------- |
|
1352 // |
|
1353 void CIpsSetUiBaseArray::Refresh() |
|
1354 { |
|
1355 FUNC_LOG; |
|
1356 TRAP_IGNORE( RefreshL() ); |
|
1357 } |
|
1358 |
|
1359 // ---------------------------------------------------------------------------- |
|
1360 // CIpsSetUiBaseArray::RefreshL() |
|
1361 // ---------------------------------------------------------------------------- |
|
1362 // |
|
1363 void CIpsSetUiBaseArray::RefreshL() |
|
1364 { |
|
1365 FUNC_LOG; |
|
1366 if ( iArrayFlags.Flag( EIpsSetUiArrayAllowRefresh ) ) |
|
1367 { |
|
1368 UpdateActiveItemsCount(); |
|
1369 EventArrayChangedL( EIpsSetUiArrayChanged ); |
|
1370 } |
|
1371 } |
|
1372 |
|
1373 // ---------------------------------------------------------------------------- |
|
1374 // CIpsSetUiBaseArray::UpdateActiveItemsCount() |
|
1375 // ---------------------------------------------------------------------------- |
|
1376 // |
|
1377 void CIpsSetUiBaseArray::UpdateActiveItemsCount( |
|
1378 const TInt aNewCount ) |
|
1379 { |
|
1380 FUNC_LOG; |
|
1381 // If count not provided, update it manually |
|
1382 if ( aNewCount == KErrNotFound ) |
|
1383 { |
|
1384 iActiveCount = StackCountItems(); |
|
1385 } |
|
1386 // Just update the count |
|
1387 else |
|
1388 { |
|
1389 iActiveCount = aNewCount; |
|
1390 } |
|
1391 } |
|
1392 |
|
1393 // ---------------------------------------------------------------------------- |
|
1394 // CIpsSetUiBaseArray::HandleStackForwardL() |
|
1395 // ---------------------------------------------------------------------------- |
|
1396 // |
|
1397 TIpsSetUiStackResult CIpsSetUiBaseArray::HandleStackForwardL( |
|
1398 const CIpsSetUiItem& aBase ) |
|
1399 { |
|
1400 FUNC_LOG; |
|
1401 // Make sure the item is subarray item |
|
1402 if ( ItemSubArrayCheck( aBase ) ) |
|
1403 { |
|
1404 // Make sure the array exists and it contains items |
|
1405 const CIpsSetUiItemLink* link = |
|
1406 static_cast<const CIpsSetUiItemLink*>( &aBase ); |
|
1407 IPS_ASSERT_DEBUG( link->iItemLinkArray , |
|
1408 ENullPointer, EBaseArray ); |
|
1409 const CIpsSetUiItem* nextItem = link->iItemLinkArray->At( 0 ) ; |
|
1410 IPS_ASSERT_DEBUG( nextItem , ENullPointer, EBaseArray ); |
|
1411 |
|
1412 // new item has been found, check the resource is not same |
|
1413 IPS_ASSERT_DEBUG( nextItem->iItemResourceId != StackActiveResource(), |
|
1414 KErrNotFound, EBaseArray ); |
|
1415 |
|
1416 HandleStackChangeL( ETrue, nextItem->iItemResourceId ); |
|
1417 |
|
1418 return EIpsSetUiStackResultSubMenuOpen; |
|
1419 } |
|
1420 |
|
1421 return EIpsSetUiStackResultOk; |
|
1422 } |
|
1423 |
|
1424 // ---------------------------------------------------------------------------- |
|
1425 // CIpsSetUiBaseArray::HandleStackBackwardL() |
|
1426 // ---------------------------------------------------------------------------- |
|
1427 // |
|
1428 TIpsSetUiStackResult CIpsSetUiBaseArray::HandleStackBackwardL( TInt aCount ) |
|
1429 { |
|
1430 FUNC_LOG; |
|
1431 // Remove the last item from stack number of times |
|
1432 while ( aCount-- && iResourceStack->Count() ) |
|
1433 { |
|
1434 iResourceStack->Remove( iResourceStack->Count() - 1 ); |
|
1435 } |
|
1436 |
|
1437 return HandleStackChangeL( EFalse ); |
|
1438 } |
|
1439 |
|
1440 // ---------------------------------------------------------------------------- |
|
1441 // CIpsSetUiBaseArray::HandleStackChangeL() |
|
1442 // ---------------------------------------------------------------------------- |
|
1443 // |
|
1444 TIpsSetUiStackResult CIpsSetUiBaseArray::HandleStackChangeL( |
|
1445 const TInt aForward, |
|
1446 const TInt aResourceId ) |
|
1447 { |
|
1448 FUNC_LOG; |
|
1449 // If resource id not provided |
|
1450 if ( aResourceId != KErrNotFound ) |
|
1451 { |
|
1452 iResourceStack->AppendL( aResourceId ); |
|
1453 } |
|
1454 |
|
1455 // Update the active count |
|
1456 UpdateActiveItemsCount(); |
|
1457 |
|
1458 // Inform of the array change |
|
1459 EventArrayChangedL( |
|
1460 aForward ? EIpsSetUiArrayStackForward : EIpsSetUiArrayStackBackward ); |
|
1461 |
|
1462 return EIpsSetUiStackResultOk; |
|
1463 } |
|
1464 |
|
1465 // ---------------------------------------------------------------------------- |
|
1466 // CIpsSetUiBaseArray::StackCountItems() |
|
1467 // ---------------------------------------------------------------------------- |
|
1468 // |
|
1469 TInt CIpsSetUiBaseArray::StackCountItems( |
|
1470 const TBool aExcludeHidden ) const |
|
1471 { |
|
1472 FUNC_LOG; |
|
1473 // Set the array finder to contain the current resource in array |
|
1474 TRAP_IGNORE ( GetResourceL( StackActiveResource(), aExcludeHidden ) ); |
|
1475 |
|
1476 return iFinder->FinderArray()->Count(); |
|
1477 } |
|
1478 |
|
1479 // ---------------------------------------------------------------------------- |
|
1480 // CIpsSetUiBaseArray::StackActiveResource() |
|
1481 // ---------------------------------------------------------------------------- |
|
1482 // |
|
1483 TInt CIpsSetUiBaseArray::StackActiveResource() const |
|
1484 { |
|
1485 FUNC_LOG; |
|
1486 return ( *iResourceStack )[iResourceStack->Count() - 1]; |
|
1487 } |
|
1488 |
|
1489 // ---------------------------------------------------------------------------- |
|
1490 // CIpsSetUiBaseArray::IsVisibleCheck() |
|
1491 // ---------------------------------------------------------------------------- |
|
1492 // |
|
1493 TBool CIpsSetUiBaseArray::IsVisibleCheck( |
|
1494 const CIpsSetUiItem& aBaseItem, |
|
1495 const TBool aExcludeHidden ) const |
|
1496 { |
|
1497 FUNC_LOG; |
|
1498 return ( aExcludeHidden && !IsHidden( aBaseItem ) || !aExcludeHidden ); |
|
1499 } |
|
1500 |
|
1501 // End of File |
|
1502 |