1 /* |
|
2 * Copyright (c) 2003-2005 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: Class declaration for CGSListboxEntry & CGSItemTextArray. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDES |
|
19 #include "gslistbox.h" |
|
20 #include "gscommon.hrh" |
|
21 |
|
22 #include <eiklbx.h> |
|
23 #include <aknradiobuttonsettingpage.h> |
|
24 |
|
25 |
|
26 // CONSTANTS |
|
27 const TInt KGSListboxModelGranularity = 5; |
|
28 _LIT(KGSEngineItemArrayPanic, "GSEngItemArray"); |
|
29 |
|
30 // Panic enum |
|
31 enum TGSEngineItemArrayPanic |
|
32 { |
|
33 EGSEngineItemArrayPanicNoRadioSettingsPage = 0, |
|
34 }; |
|
35 |
|
36 /*================================================ |
|
37 * |
|
38 * class declaration for CGSListboxEntry |
|
39 * |
|
40 *================================================*/ |
|
41 |
|
42 |
|
43 //------------------------------------------------------------------------------ |
|
44 // CGSListboxEntry::NewLC() |
|
45 // Symbian OS two-phased constructor |
|
46 //------------------------------------------------------------------------------ |
|
47 EXPORT_C CGSListboxEntry* CGSListboxEntry::NewLC( TResourceReader& aReader ) |
|
48 { |
|
49 CGSListboxEntry* self = new (ELeave) CGSListboxEntry; |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL( aReader ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 //------------------------------------------------------------------------------ |
|
56 // CGSListboxEntry::NewLC() |
|
57 // Symbian OS two-phased constructor |
|
58 //------------------------------------------------------------------------------ |
|
59 EXPORT_C CGSListboxEntry* CGSListboxEntry::NewLC( TInt aFeatureId ) |
|
60 { |
|
61 CGSListboxEntry* self = new (ELeave) CGSListboxEntry; |
|
62 CleanupStack::PushL( self ); |
|
63 self->iFeatureId = aFeatureId; |
|
64 return self; |
|
65 } |
|
66 |
|
67 //------------------------------------------------ |
|
68 // CGSListboxEntry::NewLC() |
|
69 // Symbian OS two-phased constructor |
|
70 //------------------------------------------------ |
|
71 EXPORT_C CGSListboxEntry* CGSListboxEntry::NewLC( |
|
72 TUint32 aResId, CCoeEnv& aEnv, TInt aFeatureId ) |
|
73 { |
|
74 CGSListboxEntry* self = new (ELeave) CGSListboxEntry; |
|
75 CleanupStack::PushL( self ); |
|
76 self->ConstructL( aResId, aEnv, aFeatureId ); |
|
77 return self; |
|
78 } |
|
79 |
|
80 //------------------------------------------------ |
|
81 // CGSListboxEntry::ConstructL() |
|
82 // Symbian OS 2nd phase constructor |
|
83 //------------------------------------------------ |
|
84 void CGSListboxEntry::ConstructL( |
|
85 TUint32 aResId, CCoeEnv& aEnv, TInt aFeatureId ) |
|
86 { |
|
87 // Create resource reader |
|
88 TResourceReader reader; |
|
89 aEnv.CreateResourceReaderLC( reader, aResId ); |
|
90 |
|
91 // Just read, not actually needed anywhere |
|
92 reader.ReadInt16(); |
|
93 |
|
94 // Take base settings from resources |
|
95 iCaption = reader.ReadHBufCL(); |
|
96 iStaticTextLength = iCaption->Length(); |
|
97 iFeatureId = aFeatureId + reader.ReadInt16(); |
|
98 iType = reader.ReadInt8(); |
|
99 |
|
100 CleanupStack::PopAndDestroy(); //reader |
|
101 } |
|
102 |
|
103 //------------------------------------------------------------------------------ |
|
104 // CGSListboxEntry::ConstructL() |
|
105 // Symbian OS 2nd phase constructor |
|
106 //------------------------------------------------------------------------------ |
|
107 void CGSListboxEntry::ConstructL( TResourceReader& aReader ) |
|
108 { |
|
109 iCaption = aReader.ReadHBufCL(); |
|
110 iStaticTextLength = iCaption->Length(); |
|
111 iFeatureId = aReader.ReadInt16(); |
|
112 iType = aReader.ReadInt8(); |
|
113 } |
|
114 |
|
115 //------------------------------------------------------------------------------ |
|
116 // CGSListboxEntry() |
|
117 // c++ default constructor |
|
118 //------------------------------------------------------------------------------ |
|
119 CGSListboxEntry::CGSListboxEntry() |
|
120 { |
|
121 } |
|
122 |
|
123 //------------------------------------------------------------------------------ |
|
124 // ~CGSListboxEntry() |
|
125 // destructor |
|
126 //------------------------------------------------------------------------------ |
|
127 EXPORT_C CGSListboxEntry::~CGSListboxEntry() |
|
128 { |
|
129 delete iCaption; |
|
130 } |
|
131 |
|
132 //------------------------------------------------------------------------------ |
|
133 // CGSListboxEntry::Feature() |
|
134 // Provides feature for the selected entry |
|
135 // @return feature |
|
136 //------------------------------------------------------------------------------ |
|
137 EXPORT_C TInt CGSListboxEntry::FeatureId() const |
|
138 { |
|
139 return iFeatureId; |
|
140 } |
|
141 |
|
142 //------------------------------------------------------------------------------ |
|
143 // CGSListboxEntry::Caption |
|
144 // Provides caption for the selected entry |
|
145 // @return caption |
|
146 //------------------------------------------------------------------------------ |
|
147 EXPORT_C const TDesC& CGSListboxEntry::Caption() const |
|
148 { |
|
149 return *iCaption; |
|
150 } |
|
151 |
|
152 //------------------------------------------------------------------------------ |
|
153 // CGSListboxEntry::Type |
|
154 // Provides type for the selected entry |
|
155 // @return type |
|
156 //------------------------------------------------------------------------------ |
|
157 EXPORT_C TInt CGSListboxEntry::Type() const |
|
158 { |
|
159 return iType; |
|
160 } |
|
161 |
|
162 //------------------------------------------------------------------------------ |
|
163 // CGSListboxEntry::SetDynamicTextL |
|
164 // Appends dynamic text to the static text read |
|
165 // from the resource. |
|
166 //------------------------------------------------------------------------------ |
|
167 EXPORT_C void CGSListboxEntry::SetDynamicTextL( const TDesC& aText ) |
|
168 { |
|
169 const TInt requiredLength = StaticTextLength() + aText.Length(); |
|
170 // |
|
171 TPtr pCaption( iCaption->Des() ); |
|
172 const TInt maxLength = pCaption.MaxLength(); |
|
173 // |
|
174 if( requiredLength >= maxLength ) |
|
175 { |
|
176 // Make enough room for static text + new dynamic text |
|
177 iCaption = iCaption->ReAllocL( requiredLength ); |
|
178 } |
|
179 |
|
180 // Have to re-get a new modifiable descriptor for the HBufC* since the |
|
181 // memory address may have changed after the realloc. |
|
182 pCaption.Set( iCaption->Des() ); |
|
183 |
|
184 // Set the length back to only the static part |
|
185 pCaption.SetLength( StaticTextLength() ); |
|
186 pCaption.Append( aText ); |
|
187 } |
|
188 |
|
189 |
|
190 //------------------------------------------------------------------------------ |
|
191 // CGSListboxEntry::SetDynamicTextDoublePaneL |
|
192 // Appends dynamic text to the static text read |
|
193 // from the resource. |
|
194 //------------------------------------------------------------------------------ |
|
195 EXPORT_C void CGSListboxEntry::SetDynamicTextDoublePaneL( const TDesC& aText ) |
|
196 { |
|
197 const TInt requiredLength = StaticTextLength() + aText.Length(); |
|
198 // |
|
199 TPtr pCaption( iCaption->Des() ); |
|
200 const TInt maxLength = pCaption.MaxLength(); |
|
201 const TInt textSize = aText.Length(); |
|
202 TInt location; |
|
203 |
|
204 // Here if it is the NULL string then we track of the |
|
205 // Default text size in iDynamicTextSize |
|
206 if ( textSize > 0 ) |
|
207 { |
|
208 iDynamicTextSize = textSize; |
|
209 // this location is also preserved for the same purpose |
|
210 location = aText.Locate( aText[0] ); |
|
211 } |
|
212 else |
|
213 { |
|
214 location = KErrNotFound; |
|
215 } |
|
216 // |
|
217 if ( location == KErrNotFound ) |
|
218 { |
|
219 // We take the value from the end of the string |
|
220 location = pCaption.LocateReverse('\t'); |
|
221 // We then delete the string; |
|
222 // iDynamicTextSize is the size of the "Default" text i.e. 7 |
|
223 // 1 is added bcos \tText\t\t for the last tab |
|
224 pCaption.Delete( location - ( iDynamicTextSize + 1 ), iDynamicTextSize ); |
|
225 } |
|
226 else |
|
227 { |
|
228 if( requiredLength >= maxLength ) |
|
229 { |
|
230 // Make enough room for static text + new dynamic text |
|
231 iCaption = iCaption->ReAllocL( requiredLength ); |
|
232 } |
|
233 |
|
234 // Have to re-get a new modifiable descriptor for the HBufC* since the |
|
235 // memory address may have changed after the realloc. |
|
236 pCaption.Set( iCaption->Des() ); |
|
237 location = pCaption.LocateReverse('\t'); |
|
238 pCaption.Insert( ( location - 1 ), aText ); |
|
239 } |
|
240 } |
|
241 //... HERE IT ENDS |
|
242 /*================================================ |
|
243 * |
|
244 * class declaration for CGSItemTextArray |
|
245 * |
|
246 *================================================*/ |
|
247 |
|
248 //------------------------------------------------------------------------------ |
|
249 // CGSItemTextArray::NewLC() |
|
250 // Symbian OS two-phased constructor |
|
251 //------------------------------------------------------------------------------ |
|
252 EXPORT_C CGSItemTextArray* CGSItemTextArray::NewL( TUint32 aResId, |
|
253 CCoeEnv& aEnv ) |
|
254 { |
|
255 CGSItemTextArray* self = |
|
256 new (ELeave) CGSItemTextArray( ); |
|
257 CleanupStack::PushL( self ); |
|
258 self->ConstructL( aResId, aEnv ); |
|
259 CleanupStack::Pop( self ); |
|
260 |
|
261 return self; |
|
262 } |
|
263 |
|
264 |
|
265 //------------------------------------------------------------------------------ |
|
266 // CGSItemTextArray() |
|
267 // constructor |
|
268 //------------------------------------------------------------------------------ |
|
269 CGSItemTextArray::CGSItemTextArray() |
|
270 : iAllEntries( KGSListboxModelGranularity ), |
|
271 iCurrentlyDisplayedEntries( KGSListboxModelGranularity ) |
|
272 { |
|
273 } |
|
274 |
|
275 |
|
276 //------------------------------------------------------------------------------ |
|
277 // ~CGSItemTextArray() |
|
278 // destructor |
|
279 //------------------------------------------------------------------------------ |
|
280 CGSItemTextArray::~CGSItemTextArray() |
|
281 { |
|
282 iCurrentlyDisplayedEntries.Close(); |
|
283 iAllEntries.ResetAndDestroy(); |
|
284 iAllEntries.Close(); |
|
285 } |
|
286 |
|
287 |
|
288 //------------------------------------------------------------------------------ |
|
289 // CGSItemTextArray::ConstructL() |
|
290 // Symbian OS two-phased constructor |
|
291 //------------------------------------------------------------------------------ |
|
292 void CGSItemTextArray::ConstructL( TUint32 aResId, CCoeEnv& aEnv ) |
|
293 { |
|
294 TResourceReader reader; |
|
295 aEnv.CreateResourceReaderLC( reader, aResId ); |
|
296 // |
|
297 const TInt count = reader.ReadInt16(); |
|
298 for( TInt i = 0; i < count; i++ ) |
|
299 { |
|
300 CGSListboxEntry* entry = CGSListboxEntry::NewLC( reader ); |
|
301 User::LeaveIfError( iAllEntries.Append( entry ) ); |
|
302 |
|
303 // Always visible items are added here and never removed |
|
304 if ( entry->Type() == EGSListBoxItemTypeIsAlwaysVisible ) |
|
305 { |
|
306 User::LeaveIfError( iCurrentlyDisplayedEntries.Append( entry ) ); |
|
307 } |
|
308 // |
|
309 CleanupStack::Pop( entry ); |
|
310 } |
|
311 |
|
312 CleanupStack::PopAndDestroy(); //reader |
|
313 } |
|
314 |
|
315 //------------------------------------------------ |
|
316 // CGSItemTextArray::ConstructL() |
|
317 // Symbian OS two-phased constructor |
|
318 //------------------------------------------------ |
|
319 void CGSItemTextArray::ConstructL( |
|
320 TUint32 aResId, CCoeEnv& aEnv, TInt aCount ) |
|
321 { |
|
322 // Create entries and append them to entrylist. |
|
323 for( TInt i = 0; i < aCount; i++ ) |
|
324 { |
|
325 CGSListboxEntry* entry = CGSListboxEntry::NewLC( aResId, aEnv, i ); |
|
326 User::LeaveIfError( iAllEntries.Append( entry ) ); |
|
327 CleanupStack::Pop( entry ); |
|
328 } |
|
329 } |
|
330 |
|
331 //------------------------------------------------------------------------------ |
|
332 // CGSItemTextArray::MdcaCount() |
|
333 // from MDesCArray |
|
334 // @return count |
|
335 //------------------------------------------------------------------------------ |
|
336 EXPORT_C TInt CGSItemTextArray::MdcaCount() const |
|
337 { |
|
338 const TInt count = iCurrentlyDisplayedEntries.Count(); |
|
339 return count; |
|
340 } |
|
341 |
|
342 //------------------------------------------------------------------------------ |
|
343 // CGSItemTextArray::MdcaPoint() |
|
344 // from MDesCArray |
|
345 // @return item text |
|
346 //------------------------------------------------------------------------------ |
|
347 EXPORT_C TPtrC CGSItemTextArray::MdcaPoint( TInt aIndex ) const |
|
348 { |
|
349 const TPtrC ret( iCurrentlyDisplayedEntries[aIndex]->Caption() ); |
|
350 return ret; |
|
351 } |
|
352 |
|
353 |
|
354 //------------------------------------------------------------------------------ |
|
355 // CGSItemTextArray::SetDynamicTextL() |
|
356 // Appends dynamic text to a selected listbox item |
|
357 // |
|
358 //------------------------------------------------------------------------------ |
|
359 EXPORT_C void CGSItemTextArray::SetDynamicTextL( TInt aFeatureId, |
|
360 const TDesC& aAdditionalText ) |
|
361 { |
|
362 TIdentityRelation<CGSListboxEntry> relation(CompareEntries); |
|
363 // |
|
364 CGSListboxEntry* entryToSearchFor = CGSListboxEntry::NewLC( aFeatureId ); |
|
365 const TInt index = iAllEntries.Find( entryToSearchFor, relation ); |
|
366 CleanupStack::PopAndDestroy( entryToSearchFor ); |
|
367 User::LeaveIfError( index ); |
|
368 // |
|
369 CGSListboxEntry* entry = iAllEntries[index]; |
|
370 entry->SetDynamicTextL( aAdditionalText ); |
|
371 } |
|
372 |
|
373 //------------------------------------------------------------------------------ |
|
374 // CGSItemTextArray::SetDynamicTextDoublePaneL() |
|
375 // Appends dynamic text to a selected listbox item |
|
376 // |
|
377 //------------------------------------------------------------------------------ |
|
378 EXPORT_C void CGSItemTextArray::SetDynamicTextDoublePaneL( TInt aFeatureId, |
|
379 const TDesC& aAdditionalText ) |
|
380 { |
|
381 TIdentityRelation<CGSListboxEntry> relation(CompareEntries); |
|
382 // |
|
383 CGSListboxEntry* entryToSearchFor = CGSListboxEntry::NewLC( aFeatureId ); |
|
384 const TInt index = iAllEntries.Find( entryToSearchFor, relation ); |
|
385 CleanupStack::PopAndDestroy( entryToSearchFor ); |
|
386 User::LeaveIfError( index ); |
|
387 // |
|
388 CGSListboxEntry* entry = iAllEntries[index]; |
|
389 entry->SetDynamicTextDoublePaneL( aAdditionalText ); |
|
390 } |
|
391 //*****ENDS HERE |
|
392 |
|
393 //------------------------------------------------------------------------------ |
|
394 // CGSItemTextArray::SetItemVisibilityL() |
|
395 // Indicates whether an item is to be shown/hidden |
|
396 // |
|
397 //------------------------------------------------------------------------------ |
|
398 EXPORT_C void CGSItemTextArray::SetItemVisibilityL( TInt aFeatureId, |
|
399 TVisibility aVisibility ) |
|
400 { |
|
401 TIdentityRelation<CGSListboxEntry> relation( CompareEntries ); |
|
402 CGSListboxEntry* entryToSearchFor = CGSListboxEntry::NewLC( aFeatureId ); |
|
403 // |
|
404 if ( aVisibility == EInvisible ) |
|
405 { |
|
406 const TInt index = iCurrentlyDisplayedEntries.Find( entryToSearchFor, |
|
407 relation ); |
|
408 if ( index != KErrNotFound ) |
|
409 { |
|
410 // Remove the item from the currently visible items array |
|
411 iCurrentlyDisplayedEntries.Remove( index ); |
|
412 } |
|
413 } |
|
414 else if ( aVisibility == EVisible ) |
|
415 { |
|
416 // Check its not already visible |
|
417 const TInt alreadyVisibleIndex = iCurrentlyDisplayedEntries.Find( |
|
418 entryToSearchFor, relation ); |
|
419 if ( alreadyVisibleIndex == KErrNotFound ) |
|
420 { |
|
421 const TInt index = iAllEntries.Find( entryToSearchFor, relation ); |
|
422 User::LeaveIfError( index ); |
|
423 |
|
424 // This is the entry we are going to make visible |
|
425 CGSListboxEntry* entry = iAllEntries[index]; |
|
426 |
|
427 // Now insert it at the correct location. |
|
428 TBool foundInsertionPoint = EFalse; |
|
429 const TInt currentEntriesCount = iCurrentlyDisplayedEntries.Count(); |
|
430 for( TInt allEntriesIndex=index-1; allEntriesIndex>=0 && |
|
431 !foundInsertionPoint; allEntriesIndex-- ) |
|
432 { |
|
433 // We are going to try and insert the new entry after the entry |
|
434 // specified as the previous item in the 'all entries' array, |
|
435 // in the iCurrentlyDisplayedEntries array. |
|
436 const TInt featureIdOfPreviousItem = |
|
437 iAllEntries[allEntriesIndex]->FeatureId(); |
|
438 |
|
439 for( TInt currentEntriesIndex=0; !foundInsertionPoint && |
|
440 currentEntriesIndex<currentEntriesCount; |
|
441 currentEntriesIndex++ ) |
|
442 { |
|
443 CGSListboxEntry* visibleEntry = iCurrentlyDisplayedEntries[ |
|
444 currentEntriesIndex]; |
|
445 if ( visibleEntry->FeatureId() == featureIdOfPreviousItem ) |
|
446 { |
|
447 foundInsertionPoint = ETrue; |
|
448 // Insert after this item |
|
449 User::LeaveIfError( iCurrentlyDisplayedEntries.Insert( |
|
450 entry, currentEntriesIndex+1 ) ); |
|
451 } |
|
452 } |
|
453 |
|
454 } |
|
455 |
|
456 if (!foundInsertionPoint) |
|
457 { |
|
458 // Just insert the item at the top of the list |
|
459 User::LeaveIfError( |
|
460 iCurrentlyDisplayedEntries.Insert( entry, 0 ) ); |
|
461 } |
|
462 } |
|
463 } |
|
464 CleanupStack::PopAndDestroy( entryToSearchFor ); |
|
465 } |
|
466 |
|
467 |
|
468 //------------------------------------------------------------------------------ |
|
469 // CGSItemTextArray::CurrentFeature() |
|
470 // Obtains feature id for a selected listbox item (feature) |
|
471 // @return feature id |
|
472 //------------------------------------------------------------------------------ |
|
473 EXPORT_C TInt CGSItemTextArray::CurrentFeature() const |
|
474 { |
|
475 return KErrNotFound; |
|
476 } |
|
477 |
|
478 |
|
479 //------------------------------------------------------------------------------ |
|
480 // CGSItemTextArray::IndexForFeatureId() |
|
481 // |
|
482 // @return index |
|
483 //------------------------------------------------------------------------------ |
|
484 EXPORT_C TInt CGSItemTextArray::IndexForFeatureIdL(TInt aFeatureId) const |
|
485 { |
|
486 TIdentityRelation<CGSListboxEntry> relation( CompareEntries ); |
|
487 CGSListboxEntry* entryToSearchFor = CGSListboxEntry::NewLC( aFeatureId ); |
|
488 // |
|
489 const TInt index = iCurrentlyDisplayedEntries.Find( entryToSearchFor, |
|
490 relation ); |
|
491 CleanupStack::PopAndDestroy( entryToSearchFor ); |
|
492 // |
|
493 return index; |
|
494 } |
|
495 |
|
496 |
|
497 //------------------------------------------------------------------------------ |
|
498 // CGSItemTextArray::FeatureIdByIndexL() |
|
499 // |
|
500 // @return index |
|
501 //------------------------------------------------------------------------------ |
|
502 EXPORT_C TInt CGSItemTextArray::FeatureIdByIndex(TInt aIndex) const |
|
503 { |
|
504 TInt featureId = KErrNotFound; |
|
505 // |
|
506 const TInt currentEntriesCount = iCurrentlyDisplayedEntries.Count(); |
|
507 if (aIndex >= 0 && aIndex < currentEntriesCount) |
|
508 { |
|
509 featureId = iCurrentlyDisplayedEntries[ aIndex ]->FeatureId(); |
|
510 } |
|
511 // |
|
512 return featureId; |
|
513 } |
|
514 |
|
515 |
|
516 //------------------------------------------------------------------------------ |
|
517 // CGSItemTextArray::FeatureById() |
|
518 // |
|
519 // @return feature |
|
520 //------------------------------------------------------------------------------ |
|
521 EXPORT_C const CGSListboxEntry* CGSItemTextArray::FeatureByIdL( |
|
522 TInt aFeatureId ) const |
|
523 { |
|
524 const CGSListboxEntry* locatedEntry = NULL; |
|
525 // |
|
526 TIdentityRelation<CGSListboxEntry> relation( CompareEntries ); |
|
527 CGSListboxEntry* entryToSearchFor = CGSListboxEntry::NewLC( aFeatureId ); |
|
528 // |
|
529 const TInt index = iAllEntries.Find( entryToSearchFor, |
|
530 relation ); |
|
531 if ( index != KErrNotFound ) |
|
532 { |
|
533 locatedEntry = iAllEntries[ index ]; |
|
534 } |
|
535 CleanupStack::PopAndDestroy( entryToSearchFor ); |
|
536 // |
|
537 return locatedEntry; |
|
538 } |
|
539 |
|
540 |
|
541 //------------------------------------------------------------------------------ |
|
542 // CGSItemTextArray::GetItemCaptionFromFeatureIdLC() |
|
543 // |
|
544 // @return feature's caption |
|
545 //------------------------------------------------------------------------------ |
|
546 EXPORT_C HBufC* CGSItemTextArray::GetItemCaptionFromFeatureIdLC( |
|
547 TUint32 aResourceId, |
|
548 TInt aFeatureId, |
|
549 CCoeEnv& aCone ) |
|
550 { |
|
551 HBufC* caption = NULL; |
|
552 // |
|
553 CGSItemTextArray* items = CGSItemTextArray::NewL( aResourceId, aCone ); |
|
554 CleanupStack::PushL( items ); |
|
555 const CGSListboxEntry* entry = items->FeatureByIdL( aFeatureId ); |
|
556 // |
|
557 if ( entry ) |
|
558 { |
|
559 caption = entry->Caption().AllocL(); |
|
560 } |
|
561 else |
|
562 { |
|
563 caption = KNullDesC().AllocL(); |
|
564 } |
|
565 // |
|
566 CleanupStack::PopAndDestroy( items ); |
|
567 CleanupStack::PushL( caption ); |
|
568 return caption; |
|
569 } |
|
570 |
|
571 |
|
572 //------------------------------------------------------------------------------ |
|
573 // CGSItemTextArray::CompareEntries() |
|
574 // Compares feature id's to check if they are the same |
|
575 // @return boolean |
|
576 //------------------------------------------------------------------------------ |
|
577 TBool CGSItemTextArray::CompareEntries(const CGSListboxEntry& aLeft, |
|
578 const CGSListboxEntry& aRight) |
|
579 { |
|
580 return aLeft.FeatureId() == aRight.FeatureId(); |
|
581 } |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 /*================================================ |
|
590 * |
|
591 * class declaration for CGSListBoxItemTextArray |
|
592 * |
|
593 *================================================*/ |
|
594 |
|
595 //------------------------------------------------------------------------------ |
|
596 // CGSListBoxItemTextArray::NewLC() |
|
597 // Symbian OS two-phased constructor |
|
598 //------------------------------------------------------------------------------ |
|
599 EXPORT_C CGSListBoxItemTextArray* CGSListBoxItemTextArray::NewL( TUint32 aResId, |
|
600 CEikListBox& aListBox, |
|
601 CCoeEnv& aEnv ) |
|
602 { |
|
603 CGSListBoxItemTextArray* self = |
|
604 new (ELeave) CGSListBoxItemTextArray( aListBox ); |
|
605 CleanupStack::PushL( self ); |
|
606 self->ConstructL( aResId, aEnv ); |
|
607 CleanupStack::Pop( self ); |
|
608 |
|
609 return self; |
|
610 } |
|
611 |
|
612 //------------------------------------------------ |
|
613 // CGSListBoxItemTextArray::NewL() |
|
614 // Symbian OS two-phased constructor |
|
615 //------------------------------------------------ |
|
616 EXPORT_C CGSListBoxItemTextArray* CGSListBoxItemTextArray::NewL( |
|
617 TUint32 aResId, CEikListBox& aListBox, CCoeEnv& aEnv, TInt aCount ) |
|
618 { |
|
619 CGSListBoxItemTextArray* self = |
|
620 new (ELeave) CGSListBoxItemTextArray( aListBox ); |
|
621 CleanupStack::PushL( self ); |
|
622 self->ConstructL( aResId, aEnv, aCount ); |
|
623 CleanupStack::Pop( self ); |
|
624 |
|
625 return self; |
|
626 } |
|
627 |
|
628 //------------------------------------------------------------------------------ |
|
629 // CGSListBoxItemTextArray() |
|
630 // constructor |
|
631 //------------------------------------------------------------------------------ |
|
632 CGSListBoxItemTextArray::CGSListBoxItemTextArray( CEikListBox& aListBox ) |
|
633 : iListBox( aListBox ) |
|
634 { |
|
635 } |
|
636 |
|
637 |
|
638 //------------------------------------------------------------------------------ |
|
639 // CGSListBoxItemTextArray::CurrentFeature() |
|
640 // |
|
641 // Obtains feature id for a selected listbox item (feature) |
|
642 // @return feature id |
|
643 //------------------------------------------------------------------------------ |
|
644 EXPORT_C TInt CGSListBoxItemTextArray::CurrentFeature() const |
|
645 { |
|
646 TInt featureId = KErrNotFound; |
|
647 const TInt listBoxCurrentItemIndex = iListBox.CurrentItemIndex(); |
|
648 const TInt count = iCurrentlyDisplayedEntries.Count(); |
|
649 if ( listBoxCurrentItemIndex >= 0 && listBoxCurrentItemIndex < count ) |
|
650 { |
|
651 const CGSListboxEntry* entry = |
|
652 iCurrentlyDisplayedEntries[ listBoxCurrentItemIndex ]; |
|
653 featureId = entry->FeatureId(); |
|
654 } |
|
655 return featureId; |
|
656 } |
|
657 |
|
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 |
|
664 |
|
665 |
|
666 /*================================================ |
|
667 * |
|
668 * class declaration for CGSRadioButtonSettingPageItemTextArray |
|
669 * |
|
670 *================================================*/ |
|
671 |
|
672 //------------------------------------------------------------------------------ |
|
673 // CGSRadioButtonSettingPageItemTextArray::NewL() |
|
674 // |
|
675 // Symbian OS two-phased constructor |
|
676 //------------------------------------------------------------------------------ |
|
677 EXPORT_C CGSRadioButtonSettingPageItemTextArray* |
|
678 CGSRadioButtonSettingPageItemTextArray::NewL( TUint32 aResId, |
|
679 CCoeEnv& aEnv, |
|
680 CAknRadioButtonSettingPage* aSettingPage ) |
|
681 { |
|
682 CGSRadioButtonSettingPageItemTextArray* self = |
|
683 new (ELeave) CGSRadioButtonSettingPageItemTextArray( aSettingPage ); |
|
684 CleanupStack::PushL( self ); |
|
685 self->ConstructL( aResId, aEnv ); |
|
686 CleanupStack::Pop( self ); |
|
687 |
|
688 return self; |
|
689 } |
|
690 |
|
691 |
|
692 //------------------------------------------------------------------------------ |
|
693 // CGSRadioButtonSettingPageItemTextArray() |
|
694 // |
|
695 // constructor |
|
696 //------------------------------------------------------------------------------ |
|
697 CGSRadioButtonSettingPageItemTextArray::CGSRadioButtonSettingPageItemTextArray ( |
|
698 CAknRadioButtonSettingPage* aSettingPage ) |
|
699 : iSettingPage( aSettingPage ) |
|
700 { |
|
701 } |
|
702 |
|
703 |
|
704 //------------------------------------------------------------------------------ |
|
705 // CGSRadioButtonSettingPageItemTextArray::SetRadioButtonSettingPage() |
|
706 // |
|
707 // |
|
708 //------------------------------------------------------------------------------ |
|
709 EXPORT_C void CGSRadioButtonSettingPageItemTextArray::SetRadioButtonSettingPage ( |
|
710 CAknRadioButtonSettingPage& aSettingPage ) |
|
711 { |
|
712 iSettingPage = &aSettingPage; |
|
713 } |
|
714 |
|
715 |
|
716 //------------------------------------------------------------------------------ |
|
717 // CGSRadioButtonSettingPageItemTextArray::CurrentFeature() |
|
718 // Obtains feature id for a selected listbox item (feature) |
|
719 // @return feature id |
|
720 //------------------------------------------------------------------------------ |
|
721 EXPORT_C TInt CGSRadioButtonSettingPageItemTextArray::CurrentFeature() const |
|
722 { |
|
723 __ASSERT_ALWAYS(iSettingPage, User::Panic( KGSEngineItemArrayPanic, |
|
724 EGSEngineItemArrayPanicNoRadioSettingsPage ) ); |
|
725 |
|
726 TInt featureId = KErrNotFound; |
|
727 |
|
728 const TInt listBoxCurrentItemIndex = |
|
729 iSettingPage->ListBoxControl()->CurrentItemIndex(); |
|
730 const TInt count = iCurrentlyDisplayedEntries.Count(); |
|
731 if ( listBoxCurrentItemIndex >= 0 && listBoxCurrentItemIndex < count ) |
|
732 { |
|
733 const CGSListboxEntry* entry = |
|
734 iCurrentlyDisplayedEntries[ listBoxCurrentItemIndex ]; |
|
735 featureId = entry->FeatureId(); |
|
736 } |
|
737 return featureId; |
|
738 } |
|
739 |
|
740 //End of File |
|