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: Setting item type for CAknEnumeratedItems.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <barsread.h> |
|
21 |
|
22 #include <cameraapp.rsg> |
|
23 #include <vgacamsettings.rsg> |
|
24 |
|
25 #include "CamContextAwareSettingItem.h" |
|
26 #include "CamAppController.h" |
|
27 #include "CamContextAwareSettingPage.h" |
|
28 #include "camlogging.h" |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // CCamContextAwareSettingItem::CCamContextAwareSettingItem |
|
36 // C++ constructor |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 CCamContextAwareSettingItem::CCamContextAwareSettingItem( CCamAppController& aController, |
|
40 TInt aSettingItemId, |
|
41 TInt& aValue ) |
|
42 : CAknEnumeratedTextPopupSettingItem( aSettingItemId, aValue ), iController( aController ) |
|
43 { |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CCamContextAwareSettingItem::CreateSettingPageL |
|
48 // Creates setting page that switches cba depending on setting value |
|
49 // that user navigates to. |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CAknSettingPage* CCamContextAwareSettingItem::CreateSettingPageL() |
|
53 { |
|
54 TPtrC settingName = SettingName(); |
|
55 TInt editorControlType = EAknCtPopupSettingList; |
|
56 return new ( ELeave ) CCamContextAwareSettingPage( |
|
57 &settingName, SettingNumber(), editorControlType, |
|
58 SettingEditorResourceId(), SettingPageResourceId(), |
|
59 *QueryValue(), *this, iController ); |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CCamContextAwareSettingItem::CompleteConstructionL |
|
64 // Determines whether or not the value list is to be limited (visually) |
|
65 // and replaces the popup text array with a new array created from the |
|
66 // revised resource id. |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void CCamContextAwareSettingItem::CompleteConstructionL() |
|
70 { |
|
71 const TInt KSettingItemArrayGranularity = 5; |
|
72 |
|
73 CAknEnumeratedTextPopupSettingItem::CompleteConstructionL(); |
|
74 // Check if limitation applies |
|
75 TInt aRevisedResourceId; |
|
76 if ( !iController.AllOptionsVisibleForSettingItem( Identifier(), aRevisedResourceId ) ) |
|
77 { |
|
78 // Construct the array |
|
79 CArrayPtr<CAknEnumeratedText>* enumeratedTextArray; |
|
80 enumeratedTextArray = new( ELeave ) CArrayPtrFlat<CAknEnumeratedText>( KSettingItemArrayGranularity ); |
|
81 CleanupStack::PushL( enumeratedTextArray ); |
|
82 |
|
83 // Construct a dummy array for popup text, needed to avoid a panic |
|
84 CArrayPtr<HBufC>* popupTextArray; |
|
85 popupTextArray = new( ELeave ) CArrayPtrFlat<HBufC>( KSettingItemArrayGranularity ); |
|
86 CleanupStack::PushL( popupTextArray ); |
|
87 |
|
88 // Read in the texts to be used in the setting item list |
|
89 TResourceReader reader; |
|
90 CEikonEnv::Static()->CreateResourceReaderLC( reader, aRevisedResourceId ); |
|
91 TInt numberOfItems = reader.ReadInt16(); // item count |
|
92 |
|
93 TInt index = 0; |
|
94 // Loop through all the texts |
|
95 for ( index = 0; index < numberOfItems ; ++index ) |
|
96 { |
|
97 TInt value = reader.ReadInt16(); |
|
98 TPtrC text = reader.ReadTPtrC(); // LTEXT name; |
|
99 HBufC* thisText = text.AllocLC(); |
|
100 TPtr thisTextDes = thisText->Des(); |
|
101 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( thisTextDes ); |
|
102 CAknEnumeratedText* enumeratedText = new( ELeave ) CAknEnumeratedText( value, thisText ); |
|
103 CleanupStack::Pop( thisText ); |
|
104 CleanupStack::PushL( enumeratedText ); |
|
105 enumeratedTextArray->AppendL( enumeratedText ); |
|
106 CleanupStack::Pop( enumeratedText ); |
|
107 } |
|
108 |
|
109 CleanupStack::PopAndDestroy(); // reader |
|
110 SetEnumeratedTextArrays( enumeratedTextArray, popupTextArray ); |
|
111 CleanupStack::Pop( popupTextArray ); |
|
112 CleanupStack::Pop( enumeratedTextArray ); |
|
113 } |
|
114 } |
|
115 // End of File |
|