|
1 /* |
|
2 * Copyright (c) 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: Provides Blid request view listbox model. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <StringLoader.h> |
|
21 #include <AknUtils.h> |
|
22 #include <Blid.rsg> |
|
23 #include "CBlidSettingsLBModel.h" |
|
24 #include "MBlidSettings.h" |
|
25 #include "bliduiconsts.h" |
|
26 #include "Blidutils.h" |
|
27 #include "Blid.hrh" |
|
28 |
|
29 // ================= MEMBER FUNCTIONS ======================= |
|
30 // ---------------------------------------------------------------------------- |
|
31 // CBlidSettingsLBModel::NewLC |
|
32 // Two-phased constructor. |
|
33 // ---------------------------------------------------------------------------- |
|
34 // |
|
35 CBlidSettingsLBModel* CBlidSettingsLBModel::NewLC( |
|
36 MBlidSettings* aSettingsModel ) |
|
37 { |
|
38 CBlidSettingsLBModel* self = |
|
39 new (ELeave) CBlidSettingsLBModel( aSettingsModel ); |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(); |
|
42 return self; |
|
43 } |
|
44 |
|
45 // ---------------------------------------------------------------------------- |
|
46 // CBlidSettingsLBModel::CBlidSettingsLBModel |
|
47 // C++ default constructor can NOT contain any code, that |
|
48 // might leave. |
|
49 // ---------------------------------------------------------------------------- |
|
50 // |
|
51 CBlidSettingsLBModel::CBlidSettingsLBModel(MBlidSettings* aSettingsModel): |
|
52 iSettingsModel(aSettingsModel) |
|
53 { |
|
54 } |
|
55 |
|
56 // ---------------------------------------------------------------------------- |
|
57 // CBlidSettingsLBModel::ConstructL |
|
58 // Symbian 2nd phase constructor can leave. |
|
59 // ---------------------------------------------------------------------------- |
|
60 // |
|
61 void CBlidSettingsLBModel::ConstructL() |
|
62 { |
|
63 iLocale = new(ELeave)TLocale(); |
|
64 |
|
65 iEnv = CEikonEnv::Static(); |
|
66 iBuffer = HBufC::NewL( KBlidLBLineMaxLen ); |
|
67 |
|
68 iBlidArrivalToneName = HBufC::NewL( 257 ); |
|
69 |
|
70 iBlidAltitude = StringLoader::LoadL( R_BLID_ALTITUDE_CALIBRATION, iEnv); |
|
71 iAltitudeFormatM = iEnv->AllocReadResourceL( R_BLID_METRIC_METER ); |
|
72 iAltitudeFormatFt = iEnv->AllocReadResourceL( |
|
73 R_BLID_IMPERIAL_FOOT ); |
|
74 iBlidBacklight = iEnv->AllocReadResourceL( |
|
75 R_BLID_BACKLIGHT); |
|
76 iBlidBacklightNormal = iEnv->AllocReadResourceL( |
|
77 R_BLID_BACKLIGHT_NORMAL); |
|
78 iBlidBacklightOn = iEnv->AllocReadResourceL( |
|
79 R_BLID_BACKLIGHT_ON); |
|
80 iBlidArrivalTone = iEnv->AllocReadResourceL( |
|
81 R_BLID_ARRIVAL_RINGING_TONE ); |
|
82 iBlidResetOdom = iEnv->AllocReadResourceL( |
|
83 R_BLID_RESET_ODOMETER ); |
|
84 iBlidArrivalToneOff = iEnv->AllocReadResourceL( |
|
85 R_BLID_ARRIVAL_TONE_OFF ); |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------- |
|
89 // CBlidSettingsLBModel::~CBlidSettingsLBModel |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 CBlidSettingsLBModel::~CBlidSettingsLBModel() |
|
93 { |
|
94 delete iBlidAltitude; |
|
95 delete iAltitudeFormatM; |
|
96 delete iAltitudeFormatFt; |
|
97 delete iBuffer; |
|
98 delete iLocale; |
|
99 delete iBlidBacklight; |
|
100 delete iBlidBacklightNormal; |
|
101 delete iBlidBacklightOn; |
|
102 delete iBlidArrivalTone; |
|
103 delete iBlidResetOdom; |
|
104 delete iBlidArrivalToneOff; |
|
105 delete iBlidArrivalToneName; |
|
106 } |
|
107 |
|
108 // ---------------------------------------------------------------------------- |
|
109 // CBlidSettingsLBModel::MdcaCount |
|
110 // ---------------------------------------------------------------------------- |
|
111 // |
|
112 TInt CBlidSettingsLBModel::MdcaCount() const |
|
113 { |
|
114 return 4; |
|
115 } |
|
116 |
|
117 // ---------------------------------------------------------------------------- |
|
118 // CBlidSettingsLBModel::MdcaPoint |
|
119 // ---------------------------------------------------------------------------- |
|
120 // |
|
121 TPtrC16 CBlidSettingsLBModel::MdcaPoint(TInt aIndex) const |
|
122 { |
|
123 TPtr ptr( iBuffer->Des() ); |
|
124 ptr.Zero(); |
|
125 switch ( aIndex ) |
|
126 { |
|
127 case EBlidSettingsCalibration: |
|
128 { |
|
129 TBuf<KBlidLBItemMaxLen> altitudeString; |
|
130 CalibrationFormat( altitudeString ); |
|
131 |
|
132 ptr.Append( EKeyTab ); // EKeyTab is same as "\t" |
|
133 ptr.Append( *iBlidAltitude ); |
|
134 ptr.Append( EKeyTab ); |
|
135 ptr.Append( EKeyTab ); |
|
136 ptr.Append( altitudeString ); |
|
137 break; |
|
138 } |
|
139 case EBlidSettingsBacklight: |
|
140 { |
|
141 TBuf<KBlidLBItemMaxLen> backlightString; |
|
142 BacklightFormat( backlightString ); |
|
143 |
|
144 ptr.Append( EKeyTab ); // EKeyTab is same as "\t" |
|
145 ptr.Append( *iBlidBacklight ); |
|
146 ptr.Append( EKeyTab ); |
|
147 ptr.Append( EKeyTab ); |
|
148 ptr.Append( backlightString ); |
|
149 break; |
|
150 } |
|
151 case EBlidSettingsArrivalTone: |
|
152 { |
|
153 TBuf<KMaxFileName> arrivalTone; |
|
154 ArrivalToneFormat( arrivalTone ); |
|
155 |
|
156 ptr.Append( EKeyTab ); // EKeyTab is same as "\t" |
|
157 ptr.Append( *iBlidArrivalTone ); |
|
158 ptr.Append( EKeyTab ); |
|
159 ptr.Append( EKeyTab ); |
|
160 ptr.Append( arrivalTone ); |
|
161 break; |
|
162 } |
|
163 case EBlidSettingsResetOdometer: |
|
164 { |
|
165 ptr.Append( EKeyTab ); // EKeyTab is same as "\t" |
|
166 ptr.Append( *iBlidResetOdom ); |
|
167 ptr.Append( EKeyTab ); |
|
168 break; |
|
169 } |
|
170 default: |
|
171 { |
|
172 break; |
|
173 } |
|
174 } |
|
175 |
|
176 AknTextUtils::LanguageSpecificNumberConversion( ptr ); |
|
177 return iBuffer->Des(); |
|
178 } |
|
179 |
|
180 // ---------------------------------------------------------------------------- |
|
181 // CBlidSettingsLBModel::CalibrationFormat |
|
182 // ---------------------------------------------------------------------------- |
|
183 // |
|
184 void CBlidSettingsLBModel::CalibrationFormat( TDes& aCalibrationString ) const |
|
185 { |
|
186 TInt result(0); |
|
187 HBufC* formatter = NULL; |
|
188 TInt error( KErrNone ); |
|
189 if ( iSettingsModel->UnitOfMeasurement() == EUnitsMetric ) |
|
190 { |
|
191 formatter = iAltitudeFormatM; |
|
192 error = BlidUtils::TRealToTInt( |
|
193 iSettingsModel->AltCalibration(), result ); |
|
194 } |
|
195 else |
|
196 { |
|
197 formatter = iAltitudeFormatFt; |
|
198 TReal calibrationFt((iSettingsModel->AltCalibration()*KMetreToFoot)); |
|
199 error = BlidUtils::TRealToTInt( calibrationFt, result ); |
|
200 } |
|
201 if(error!=KErrNone) |
|
202 { |
|
203 iEnv->HandleError( error ); |
|
204 result = 0; |
|
205 } |
|
206 StringLoader::Format( aCalibrationString, *formatter, 0, result ); |
|
207 } |
|
208 |
|
209 // ---------------------------------------------------------------------------- |
|
210 // CBlidSettingsLBModel::BacklightFormat |
|
211 // ---------------------------------------------------------------------------- |
|
212 // |
|
213 void CBlidSettingsLBModel::BacklightFormat( TDes& aBacklightString ) const |
|
214 { |
|
215 |
|
216 if ( iSettingsModel->GetBacklightOption() == EBlidBackLightNormal ) |
|
217 { |
|
218 aBacklightString = *iBlidBacklightNormal; |
|
219 } |
|
220 else |
|
221 { |
|
222 aBacklightString = *iBlidBacklightOn; |
|
223 } |
|
224 |
|
225 } |
|
226 |
|
227 // ---------------------------------------------------------------------------- |
|
228 // CBlidSettingsLBModel::ArrivalToneFormat |
|
229 // ---------------------------------------------------------------------------- |
|
230 // |
|
231 void CBlidSettingsLBModel::ArrivalToneFormat( TDes& aRrivalTone ) const |
|
232 { |
|
233 if( iSettingsModel->GetArrivedToneName().Length() > 0 ) |
|
234 { |
|
235 TParse parseFile; |
|
236 TBuf<KMaxFileName> toneFileName; |
|
237 toneFileName.Copy( iSettingsModel->GetArrivedToneName() ); |
|
238 parseFile.Set( toneFileName, NULL, NULL ); |
|
239 |
|
240 iBlidArrivalToneName->Des().Copy( parseFile.NameAndExt() ); |
|
241 aRrivalTone = *iBlidArrivalToneName; |
|
242 } |
|
243 else |
|
244 { |
|
245 aRrivalTone = *iBlidArrivalToneOff; |
|
246 } |
|
247 } |
|
248 // End of File |