1 /* |
|
2 * Copyright (c) 2008 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: CMSRuleAmountSetting class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <mediaservant.rsg> |
|
20 #include <AknQueryDialog.h> |
|
21 #include <StringLoader.h> |
|
22 |
|
23 #include "cmcommontypes.h" |
|
24 #include "msruleamountsetting.h" |
|
25 #include "mediaservant.hrh" |
|
26 #include "msdebug.h" |
|
27 |
|
28 |
|
29 // CONSTANTS |
|
30 const TInt KArrayGranularity = 3; |
|
31 |
|
32 |
|
33 // -------------------------------------------------------------------------- |
|
34 // CMSRuleAmountSetting::~CMSRuleAmountSetting() |
|
35 // -------------------------------------------------------------------------- |
|
36 // |
|
37 CMSRuleAmountSetting::~CMSRuleAmountSetting() |
|
38 { |
|
39 } |
|
40 |
|
41 // -------------------------------------------------------------------------- |
|
42 // CMSRuleAmountSetting::EditItemL( TBool aCalledFromMenu ) |
|
43 // -------------------------------------------------------------------------- |
|
44 // |
|
45 void CMSRuleAmountSetting::EditItemL( TBool aCalledFromMenu ) |
|
46 { |
|
47 LOG(_L("[MediaServant]\t CMSRuleAmountSetting::EditItemL")); |
|
48 |
|
49 // Launches setting page |
|
50 CMSEnumeratedTextPopupSettingItem::EditItemL(aCalledFromMenu); |
|
51 StoreL(); |
|
52 |
|
53 // selected item index |
|
54 TInt selected = QueryValue()->CurrentValueIndex(); |
|
55 |
|
56 if ( SettingAccepted() && |
|
57 selected != EUnlimited ) |
|
58 { |
|
59 // Construct Integer query |
|
60 CAknNumberQueryDialog* query = CAknNumberQueryDialog::NewL( iValue ); |
|
61 |
|
62 // set query heading |
|
63 if ( selected == EPieces) |
|
64 { |
|
65 HBufC* heading = |
|
66 StringLoader::LoadLC( R_MS_AMOUNT_QUERY_HEADING ); |
|
67 query->SetPromptL( *heading ); |
|
68 CleanupStack::PopAndDestroy( heading ); |
|
69 } |
|
70 else // EMbits |
|
71 { |
|
72 HBufC* heading = |
|
73 StringLoader::LoadLC( R_MS_SIZE_QUERY_HEADING ); |
|
74 query->SetPromptL( *heading ); |
|
75 CleanupStack::PopAndDestroy( heading ); |
|
76 } |
|
77 |
|
78 // run query |
|
79 if ( query->ExecuteLD( R_MSERV_DATA_QUERY ) ) |
|
80 { |
|
81 HBufC* itemText = NULL; |
|
82 |
|
83 CArrayPtr< CAknEnumeratedText >* enumeratedTextArray = |
|
84 EnumeratedTextArray (); |
|
85 // delete object |
|
86 delete (*enumeratedTextArray)[selected]; |
|
87 // delete pointer |
|
88 enumeratedTextArray->Delete( selected ); |
|
89 |
|
90 if ( selected == EPieces ) |
|
91 { |
|
92 |
|
93 switch ( iValue ) |
|
94 { |
|
95 case 0: // 0 items |
|
96 { |
|
97 itemText = |
|
98 StringLoader::LoadLC( R_MS_VALUE_AMOUNT_0_ITEMS ); |
|
99 break; |
|
100 } |
|
101 case 1: // 1 item |
|
102 { |
|
103 itemText = |
|
104 StringLoader::LoadLC( R_MS_VALUE_AMOUNT_ONE_ITEM ); |
|
105 break; |
|
106 } |
|
107 default: // many items |
|
108 { |
|
109 itemText = StringLoader::LoadLC( |
|
110 R_MS_VALUE_AMOUNT_COUNT_NUMBER, |
|
111 iValue ); |
|
112 break; |
|
113 } |
|
114 } |
|
115 } |
|
116 else // EMbits |
|
117 { |
|
118 itemText = StringLoader::LoadLC( R_MS_VALUE_AMOUNT_MB_NUMBER, |
|
119 iValue ); |
|
120 } |
|
121 |
|
122 // do number conversion |
|
123 TPtr ptr = itemText->Des(); |
|
124 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
|
125 |
|
126 CAknEnumeratedText* enumeratedText = |
|
127 new (ELeave) CAknEnumeratedText( selected, itemText); |
|
128 CleanupStack::PushL( enumeratedText ); |
|
129 // insert new text to array |
|
130 enumeratedTextArray->InsertL( selected, enumeratedText ); |
|
131 CleanupStack::Pop( enumeratedText ); |
|
132 if ( itemText ) |
|
133 { |
|
134 CleanupStack::Pop( itemText ); |
|
135 } |
|
136 |
|
137 UpdateListBoxTextL(); |
|
138 } |
|
139 else |
|
140 { |
|
141 EditItemL( aCalledFromMenu ); |
|
142 } |
|
143 } |
|
144 } |
|
145 |
|
146 // -------------------------------------------------------------------------- |
|
147 // CMSRuleAmountSetting::CMSRuleAmountSetting |
|
148 // -------------------------------------------------------------------------- |
|
149 // |
|
150 CMSRuleAmountSetting::CMSRuleAmountSetting( |
|
151 TInt aIdentifier, |
|
152 TInt &aLimitType, |
|
153 TInt &aValue |
|
154 ) : |
|
155 CMSEnumeratedTextPopupSettingItem( aIdentifier, aLimitType ), |
|
156 iLimitType( aLimitType ), |
|
157 iValue( aValue ) |
|
158 { |
|
159 } |
|
160 |
|
161 // -------------------------------------------------------------------------- |
|
162 // CMSRuleAmountSetting::CompleteConstructionL |
|
163 // -------------------------------------------------------------------------- |
|
164 // |
|
165 void CMSRuleAmountSetting::CompleteConstructionL() |
|
166 { |
|
167 LOG(_L("[MediaServant]\t CMSRuleAmountSetting::CompleteConstructionL")); |
|
168 |
|
169 CArrayPtr< CAknEnumeratedText > * enumeratedTextArray = |
|
170 new (ELeave) CArrayPtrFlat<CAknEnumeratedText>(KArrayGranularity); |
|
171 CleanupStack::PushL( enumeratedTextArray ); |
|
172 |
|
173 CArrayPtr< HBufC > * poppedUpTextArray = |
|
174 new (ELeave) CArrayPtrFlat<HBufC> (KArrayGranularity); |
|
175 CleanupStack::PushL( poppedUpTextArray ); |
|
176 |
|
177 |
|
178 // "UNLIMITED" setting item text |
|
179 HBufC* itemText = StringLoader::LoadLC( R_MS_VALUE_AMOUNT_UNLIMITED ); |
|
180 CAknEnumeratedText* enumeratedText = |
|
181 new (ELeave) CAknEnumeratedText( EUnlimited, itemText ); |
|
182 CleanupStack::PushL( enumeratedText ); |
|
183 enumeratedTextArray->AppendL( enumeratedText ); |
|
184 CleanupStack::Pop( 2, itemText ); |
|
185 |
|
186 // "XX items" setting item text |
|
187 switch( iValue ) |
|
188 { |
|
189 case 0: // 0 items |
|
190 { |
|
191 itemText = StringLoader::LoadLC( R_MS_VALUE_AMOUNT_0_ITEMS ); |
|
192 break; |
|
193 } |
|
194 case 1: // 1 item |
|
195 { |
|
196 itemText = StringLoader::LoadLC( R_MS_VALUE_AMOUNT_ONE_ITEM ); |
|
197 break; |
|
198 } |
|
199 default: // many items |
|
200 { |
|
201 itemText = StringLoader::LoadLC( R_MS_VALUE_AMOUNT_COUNT_NUMBER, |
|
202 iValue); |
|
203 // do number conversion |
|
204 TPtr ptr = itemText->Des(); |
|
205 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
|
206 |
|
207 break; |
|
208 } |
|
209 } |
|
210 |
|
211 enumeratedText = new (ELeave) CAknEnumeratedText(EPieces, itemText); |
|
212 CleanupStack::PushL( enumeratedText ); |
|
213 enumeratedTextArray->AppendL( enumeratedText ); |
|
214 CleanupStack::Pop( 2, itemText ); |
|
215 |
|
216 // "XX MB" setting item text |
|
217 itemText = StringLoader::LoadLC( |
|
218 R_MS_VALUE_AMOUNT_MB_NUMBER, iValue ); |
|
219 // do number conversion |
|
220 TPtr ptr = itemText->Des(); |
|
221 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
|
222 |
|
223 enumeratedText = new (ELeave) CAknEnumeratedText(EMbits, itemText); |
|
224 CleanupStack::PushL( enumeratedText ); |
|
225 enumeratedTextArray->AppendL( enumeratedText ); |
|
226 CleanupStack::Pop( 2, itemText ); |
|
227 |
|
228 // "UNLIMITED" popup text |
|
229 HBufC* popupText = StringLoader::LoadLC( R_MS_VALUE_AMOUNT_UNLIMITED ); |
|
230 poppedUpTextArray->AppendL(popupText); |
|
231 CleanupStack::Pop( popupText ); |
|
232 |
|
233 // "SET MB" popup text |
|
234 HBufC* popupText2 = StringLoader::LoadLC( R_MS_VALUE_AMOUNT_COUNT_PAGE ); |
|
235 poppedUpTextArray->AppendL(popupText2); |
|
236 CleanupStack::Pop( popupText2 ); |
|
237 |
|
238 // "SET COUNT" popup text |
|
239 HBufC* popupText3 = StringLoader::LoadLC( R_MS_VALUE_AMOUNT_MB_PAGE ); |
|
240 poppedUpTextArray->AppendL(popupText3); |
|
241 CleanupStack::Pop( popupText3 ); |
|
242 |
|
243 // set arrays |
|
244 SetEnumeratedTextArrays(enumeratedTextArray, poppedUpTextArray); |
|
245 CleanupStack::Pop( 2, enumeratedTextArray ); |
|
246 |
|
247 HandleTextArrayUpdateL(); |
|
248 } |
|
249 |
|
250 // End of File |
|
251 |
|