|
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: A model class for CCamCaptureSetupListBox* |
|
15 */ |
|
16 |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <barsread.h> |
|
20 #include <eikenv.h> |
|
21 |
|
22 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
23 #include <cameraapp.rsg> |
|
24 #include <vgacamsettings.rsg> |
|
25 #else |
|
26 #include <gscamerapluginrsc.rsg> |
|
27 #endif //CAMERAAPP_PLUGIN_BUILD |
|
28 |
|
29 #include "CamProductSpecificSettings.hrh" |
|
30 #include "CamUtility.h" |
|
31 #include "camlayoututils.h" |
|
32 #include "CamCaptureSetupListItem.h" |
|
33 #include "CamCaptureSetupListBoxModel.h" |
|
34 #include "CameraUiConfigManager.h" |
|
35 |
|
36 #include <aknlayoutscalable_apps.cdl.h> |
|
37 |
|
38 |
|
39 // ================= MEMBER FUNCTIONS ======================= |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CCamCaptureSetupListBoxModel::NewLC |
|
43 // Two-phased constructor. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CCamCaptureSetupListBoxModel* CCamCaptureSetupListBoxModel::NewLC( |
|
47 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
48 CCamAppController& aController, |
|
49 #else // location setting will be moved to the plugin |
|
50 MCamAppController& aController, |
|
51 #endif |
|
52 TInt aArrayResourceId, |
|
53 TInt aSettingItem, |
|
54 TBool aShootingModeListBox, |
|
55 TBool aLocationSettingListBox, |
|
56 TRect aListBoxRect |
|
57 ) |
|
58 { |
|
59 CCamCaptureSetupListBoxModel* self = new( ELeave ) CCamCaptureSetupListBoxModel( aController, |
|
60 aShootingModeListBox, |
|
61 aLocationSettingListBox |
|
62 ); |
|
63 |
|
64 CleanupStack::PushL( self ); |
|
65 self->ConstructL( aArrayResourceId, aSettingItem, aListBoxRect ); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CCamCaptureSetupListBoxModel destructor |
|
71 // |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CCamCaptureSetupListBoxModel::~CCamCaptureSetupListBoxModel() |
|
75 { |
|
76 PRINT( _L("Camera => ~CCamCaptureSetupListBoxModel") ); |
|
77 iItemArray.ResetAndDestroy(); |
|
78 iItemArray.Close(); |
|
79 PRINT( _L("Camera <= ~CCamCaptureSetupListBoxModel") ); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------- |
|
83 // CCamCaptureSetupListBoxModel::NumberOfItems |
|
84 // Returns number of items that are in array |
|
85 // --------------------------------------------------------- |
|
86 // |
|
87 TInt CCamCaptureSetupListBoxModel::NumberOfItems() const |
|
88 { |
|
89 return iItemArray.Count(); |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------- |
|
93 // CCamCaptureSetupListBoxModel::MatchableTextArray |
|
94 // Returns null, no support for incremental matching |
|
95 // --------------------------------------------------------- |
|
96 // |
|
97 const MDesCArray* CCamCaptureSetupListBoxModel::MatchableTextArray() const |
|
98 { |
|
99 return NULL; |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------- |
|
103 // CCamCaptureSetupListBoxModel::ItemText |
|
104 // Returns a pointer to the item text |
|
105 // --------------------------------------------------------- |
|
106 // |
|
107 TPtrC CCamCaptureSetupListBoxModel::ItemText( TInt aItemIndex ) const |
|
108 { |
|
109 return iItemArray[ aItemIndex ]->ItemText(); |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------- |
|
113 // CCamCaptureSetupListBoxModel::ItemValue |
|
114 // Returns the value id of the specified item |
|
115 // --------------------------------------------------------- |
|
116 // |
|
117 TInt CCamCaptureSetupListBoxModel::ItemValue( TInt aItemIndex ) const |
|
118 { |
|
119 return iItemArray[aItemIndex]->ItemValue(); |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------- |
|
123 // CCamCaptureSetupListBoxModel::Bitmap |
|
124 // Returns a pointer to the bitmap of the specified item |
|
125 // --------------------------------------------------------- |
|
126 // |
|
127 CFbsBitmap* CCamCaptureSetupListBoxModel::Bitmap( TInt aItemIndex ) const |
|
128 { |
|
129 return iItemArray[ aItemIndex ]->Bitmap(); |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------- |
|
133 // CCamCaptureSetupListBoxModel::BitmapMask |
|
134 // Returns a pointer to the mask of the specified item |
|
135 // --------------------------------------------------------- |
|
136 // |
|
137 CFbsBitmap* CCamCaptureSetupListBoxModel::BitmapMask( TInt aItemIndex ) const |
|
138 { |
|
139 return iItemArray[ aItemIndex ]->BitmapMask(); |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------- |
|
143 // CCamCaptureSetupListBoxModel::ItemIndexFromValueId |
|
144 // Returns the index of the item with a matching value id |
|
145 // --------------------------------------------------------- |
|
146 // |
|
147 TInt CCamCaptureSetupListBoxModel::ValueIndex( TInt aValueId ) const |
|
148 { |
|
149 return iItemArray.Find( aValueId, CCamInfoListboxItemBase::EqualIds ); |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------- |
|
153 // CCamCaptureSetupListBoxModel::ShootingModeListBox |
|
154 // Returns whether the model represents a shooting mode listbox |
|
155 // --------------------------------------------------------- |
|
156 // |
|
157 TBool CCamCaptureSetupListBoxModel::ShootingModeListBox() const |
|
158 { |
|
159 return iShootingModeListBox; |
|
160 } |
|
161 |
|
162 |
|
163 TAknLayoutRect CCamCaptureSetupListBoxModel::IconLayoutData() const |
|
164 { |
|
165 return iIconLayoutData; |
|
166 } |
|
167 TAknLayoutRect CCamCaptureSetupListBoxModel::RadioButtonLayoutData() const |
|
168 { |
|
169 return iRadioButtonLayoutData; |
|
170 } |
|
171 TAknLayoutText CCamCaptureSetupListBoxModel::TextLayoutData() const |
|
172 { |
|
173 return iTextLayoutData; |
|
174 } |
|
175 TAknLayoutRect CCamCaptureSetupListBoxModel::ListItemLayoutData() const |
|
176 { |
|
177 return iListItemLayoutData; |
|
178 } |
|
179 // --------------------------------------------------------------------------- |
|
180 // CCamCaptureSetupListBoxModel::CCamCaptureSetupListBoxModel |
|
181 // C++ constructor |
|
182 // --------------------------------------------------------------------------- |
|
183 // |
|
184 |
|
185 CCamCaptureSetupListBoxModel::CCamCaptureSetupListBoxModel( |
|
186 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
187 CCamAppController& aController, |
|
188 #else // location setting will be moved to the plugin |
|
189 MCamAppController& aController, |
|
190 #endif |
|
191 TBool aShootingModeListBox, |
|
192 TBool aLocationSettingListBox |
|
193 ) |
|
194 : iController( aController ), iShootingModeListBox ( aShootingModeListBox ), |
|
195 iLocationSettingListBox ( aLocationSettingListBox ) |
|
196 { |
|
197 } |
|
198 |
|
199 // --------------------------------------------------------------------------- |
|
200 // CCamCaptureSetupListBoxModel::ConstructL |
|
201 // 2nd phase construction |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 void CCamCaptureSetupListBoxModel::ConstructL( TInt aArrayResourceId, TInt aSettingItem, TRect aListBoxRect ) |
|
205 { |
|
206 ReadLayoutData( aListBoxRect ); |
|
207 |
|
208 // create array from resource |
|
209 TResourceReader reader; |
|
210 CEikonEnv::Static()->CreateResourceReaderLC( reader, aArrayResourceId ); |
|
211 const TInt count = reader.ReadInt16(); |
|
212 |
|
213 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
214 iSupportedFlashModes = iController.SupportedFlashModes(); |
|
215 iSupportedWBModes = iController.SupportedWBModes(); |
|
216 #endif //CAMERAAPP_PLUGIN_BUILD |
|
217 |
|
218 // for each entry in the resource array, create a new list item |
|
219 for ( TInt i = 0; i < count; i++ ) |
|
220 { |
|
221 CCamCaptureSetupListItem* listItem = |
|
222 CCamCaptureSetupListItem::NewLC( reader, iIconLayoutData ); |
|
223 |
|
224 if( SettingValueSupportedL( listItem, aSettingItem ) ) |
|
225 { |
|
226 iItemArray.AppendL( listItem ); |
|
227 } |
|
228 |
|
229 CleanupStack::Pop( listItem ); |
|
230 } |
|
231 CleanupStack::PopAndDestroy(); // reader |
|
232 } |
|
233 |
|
234 // --------------------------------------------------------------------------- |
|
235 // CCamCaptureSetupListBoxModel::ReadLayoutData |
|
236 // Read in layout data from resource |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 void CCamCaptureSetupListBoxModel::ReadLayoutData( TRect aListBoxRect ) |
|
240 { |
|
241 if ( CamUtility::IsNhdDevice() ) |
|
242 { |
|
243 iIconLayoutData.LayoutRect( aListBoxRect, |
|
244 AknLayoutScalable_Apps::cset_list_set_pane_g3( 0 ) ); |
|
245 iRadioButtonLayoutData.LayoutRect( aListBoxRect, |
|
246 AknLayoutScalable_Apps::cset_list_set_pane_g1( 0 ) ); |
|
247 iListItemLayoutData.LayoutRect( aListBoxRect, |
|
248 AknLayoutScalable_Apps::cset_list_set_pane( 0 ) ); |
|
249 } |
|
250 else |
|
251 { |
|
252 TRect mnPane; |
|
253 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mnPane ); |
|
254 TAknLayoutRect listLayoutRect; |
|
255 listLayoutRect.LayoutRect( mnPane, |
|
256 AknLayoutScalable_Apps::main_cset6_listscroll_pane( 4 ) ); |
|
257 iIconLayoutData.LayoutRect( listLayoutRect.Rect(), |
|
258 AknLayoutScalable_Apps::cset_list_set_pane_g3_copy1( 0 ) ); |
|
259 iRadioButtonLayoutData.LayoutRect( listLayoutRect.Rect(), |
|
260 AknLayoutScalable_Apps::cset_list_set_pane_g1_copy1( 0 ) ); |
|
261 TAknWindowLineLayout l = AknLayoutScalable_Apps::cset_list_set_pane_copy1( 0 ); |
|
262 if( !l.iH ) |
|
263 { |
|
264 l.iH = 73; // TODO Temporarily defined! |
|
265 } |
|
266 iListItemLayoutData.LayoutRect( listLayoutRect.Rect(), l ); |
|
267 } |
|
268 } |
|
269 |
|
270 // --------------------------------------------------------------------------- |
|
271 // CCamCaptureSetupListBoxModel::SettingValueSupportedL |
|
272 // --------------------------------------------------------------------------- |
|
273 // |
|
274 TBool |
|
275 CCamCaptureSetupListBoxModel::SettingValueSupportedL( CCamInfoListboxItemBase* aItem, TInt aSettingItem ) |
|
276 { |
|
277 TBool supported = EFalse; |
|
278 TBool checkConfiguredItems = ETrue; |
|
279 TInt val = aItem->ItemValue(); |
|
280 |
|
281 CCameraUiConfigManager* dynamicSettings = iController.UiConfigManagerPtr(); |
|
282 RArray<TInt> supportedItems; |
|
283 CleanupClosePushL( supportedItems ); |
|
284 supportedItems.Reset(); |
|
285 |
|
286 // just for flash to start with |
|
287 if( aSettingItem == ECamSettingItemDynamicPhotoFlash ) |
|
288 { |
|
289 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
290 if ( dynamicSettings ) |
|
291 { |
|
292 dynamicSettings->SupportedFlashModeSettingsL( supportedItems ); |
|
293 } |
|
294 #endif //CAMERAAPP_PLUGIN_BUILD |
|
295 } |
|
296 else if( ECamSettingItemDynamicPhotoWhiteBalance == aSettingItem || |
|
297 ECamSettingItemDynamicVideoWhiteBalance == aSettingItem ) |
|
298 { |
|
299 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
300 if ( dynamicSettings ) |
|
301 { |
|
302 dynamicSettings->SupportedWhiteBalanceSettingsL( supportedItems ); |
|
303 } |
|
304 #endif //CAMERAAPP_PLUGIN_BUILD |
|
305 } |
|
306 else if ( ECamSettingItemDynamicPhotoColourFilter == aSettingItem || |
|
307 ECamSettingItemDynamicVideoColourFilter == aSettingItem ) |
|
308 { |
|
309 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
310 if ( dynamicSettings ) |
|
311 { |
|
312 dynamicSettings->SupportedColorToneSettingsL( supportedItems ); |
|
313 } |
|
314 #endif //CAMERAAPP_PLUGIN_BUILD |
|
315 } |
|
316 else |
|
317 { |
|
318 checkConfiguredItems = EFalse; |
|
319 supported = ETrue; |
|
320 } |
|
321 |
|
322 if ( checkConfiguredItems && supportedItems.Count() > 0 ) |
|
323 { |
|
324 supported = KErrNotFound != supportedItems.Find( val ); |
|
325 } |
|
326 |
|
327 CleanupStack::PopAndDestroy( &supportedItems ); |
|
328 return supported; |
|
329 } |
|
330 // End of File |
|
331 |