1 /* |
|
2 * Copyright (c) 2009-2010 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cxefakesettingsmodel.h" |
|
19 #include "cxutils.h" |
|
20 |
|
21 CxeFakeSettingsModel::CxeFakeSettingsModel() |
|
22 { |
|
23 CX_DEBUG_ENTER_FUNCTION(); |
|
24 |
|
25 initDefaultCameraSettings(); |
|
26 initRuntimeSettings(); |
|
27 |
|
28 CX_DEBUG_EXIT_FUNCTION(); |
|
29 } |
|
30 |
|
31 CxeFakeSettingsModel::~CxeFakeSettingsModel() |
|
32 { |
|
33 CX_DEBUG_IN_FUNCTION(); |
|
34 } |
|
35 |
|
36 CxeError::Id CxeFakeSettingsModel::getRuntimeValue( const QString &key, QVariant &value) |
|
37 { |
|
38 CX_DEBUG_ENTER_FUNCTION(); |
|
39 CxeError::Id err = CxeError::None; |
|
40 |
|
41 // read run-time configuration value |
|
42 if (mRuntimeSettings.contains(key)) { |
|
43 value = qVariantFromValue<QVariantList > (mRuntimeSettings.value(key)); |
|
44 } else { |
|
45 err = CxeError::NotFound; |
|
46 } |
|
47 |
|
48 CX_DEBUG_EXIT_FUNCTION(); |
|
49 return err; |
|
50 } |
|
51 |
|
52 CxeError::Id CxeFakeSettingsModel::getSettingValue( const QString &key, QVariant &value) |
|
53 { |
|
54 CX_DEBUG_ENTER_FUNCTION(); |
|
55 CxeError::Id err = CxeError::None; |
|
56 |
|
57 // read run-time configuration value |
|
58 if (mSettingStore.contains(key)) { |
|
59 value = mSettingStore[key]; |
|
60 } else { |
|
61 err = CxeError::NotFound; |
|
62 } |
|
63 |
|
64 CX_DEBUG_EXIT_FUNCTION(); |
|
65 return err; |
|
66 } |
|
67 |
|
68 void CxeFakeSettingsModel::getSettingValue(long int uid, unsigned long int key, Cxe::SettingKeyType type, QVariant &value) |
|
69 { |
|
70 Q_UNUSED(uid); |
|
71 Q_UNUSED(key); |
|
72 Q_UNUSED(type); |
|
73 Q_UNUSED(value); |
|
74 |
|
75 // no support yet |
|
76 CX_DEBUG_IN_FUNCTION(); |
|
77 } |
|
78 |
|
79 |
|
80 /*! This is a helper method for this fake class that can be used to set key-value pairs |
|
81 * to local mStore database. Key-value pairs don't have to refer any real values used |
|
82 * in camera application as the fake class is used only for testing purposes |
|
83 */ |
|
84 CxeError::Id CxeFakeSettingsModel::set(const QString &key, QVariant value) |
|
85 { |
|
86 CX_DEBUG_ENTER_FUNCTION(); |
|
87 CxeError::Id error = CxeError::None; |
|
88 |
|
89 if(mSettingStore.contains(key)) { |
|
90 mSettingStore.insert(key, value); |
|
91 } else { |
|
92 error = CxeError::NotFound; |
|
93 } |
|
94 |
|
95 |
|
96 |
|
97 CX_DEBUG_EXIT_FUNCTION(); |
|
98 return error; |
|
99 } |
|
100 |
|
101 CxeError::Id CxeFakeSettingsModel::setImageScene(const QString &newScene) |
|
102 { |
|
103 mDummyImageScene.clear(); |
|
104 |
|
105 // image scene mode key values |
|
106 if(newScene == Cxe::IMAGE_SCENE_AUTO) { |
|
107 mDummyImageScene.insert(CxeSettingIds::SCENE_ID, Cxe::IMAGE_SCENE_AUTO); |
|
108 } |
|
109 else if(newScene == Cxe::IMAGE_SCENE_PORTRAIT) { |
|
110 mDummyImageScene.insert(CxeSettingIds::SCENE_ID, Cxe::IMAGE_SCENE_PORTRAIT); |
|
111 } |
|
112 else if(newScene == Cxe::IMAGE_SCENE_SCENERY) { |
|
113 mDummyImageScene.insert(CxeSettingIds::SCENE_ID, Cxe::IMAGE_SCENE_SCENERY); |
|
114 } |
|
115 else if(newScene == Cxe::IMAGE_SCENE_MACRO) { |
|
116 mDummyImageScene.insert(CxeSettingIds::SCENE_ID, Cxe::IMAGE_SCENE_MACRO); |
|
117 } |
|
118 else if(newScene == Cxe::IMAGE_SCENE_SPORTS) { |
|
119 mDummyImageScene.insert(CxeSettingIds::SCENE_ID, Cxe::IMAGE_SCENE_SPORTS); |
|
120 } |
|
121 else if(newScene == Cxe::IMAGE_SCENE_NIGHT) { |
|
122 mDummyImageScene.insert(CxeSettingIds::SCENE_ID, Cxe::IMAGE_SCENE_NIGHT); |
|
123 } |
|
124 else if(newScene == Cxe::IMAGE_SCENE_NIGHTPORTRAIT) { |
|
125 mDummyImageScene.insert(CxeSettingIds::SCENE_ID, Cxe::IMAGE_SCENE_NIGHTPORTRAIT); |
|
126 } |
|
127 else { |
|
128 return CxeError::NotFound; |
|
129 } |
|
130 |
|
131 return CxeError::None; |
|
132 } |
|
133 |
|
134 CxeError::Id CxeFakeSettingsModel::setVideoScene(const QString &newScene) |
|
135 { |
|
136 mDummyVideoScene.clear(); |
|
137 |
|
138 // image scene mode key values |
|
139 if(newScene == Cxe::VIDEO_SCENE_AUTO) { |
|
140 mDummyVideoScene.insert(CxeSettingIds::SCENE_ID, Cxe::VIDEO_SCENE_AUTO); |
|
141 } |
|
142 else if(newScene == Cxe::VIDEO_SCENE_NIGHTPORTRAIT) { |
|
143 mDummyVideoScene.insert(CxeSettingIds::SCENE_ID, Cxe::VIDEO_SCENE_NIGHTPORTRAIT); |
|
144 } |
|
145 else if(newScene == Cxe::VIDEO_SCENE_LOWLIGHT) { |
|
146 mDummyVideoScene.insert(CxeSettingIds::SCENE_ID, Cxe::VIDEO_SCENE_LOWLIGHT); |
|
147 } |
|
148 else if(newScene == Cxe::VIDEO_SCENE_NIGHT) { |
|
149 mDummyVideoScene.insert(CxeSettingIds::SCENE_ID, Cxe::VIDEO_SCENE_NIGHT); |
|
150 } |
|
151 else { |
|
152 return CxeError::NotFound; |
|
153 } |
|
154 |
|
155 return CxeError::None; |
|
156 } |
|
157 |
|
158 |
|
159 CxeScene& CxeFakeSettingsModel::currentImageScene() |
|
160 { |
|
161 return mDummyImageScene; |
|
162 } |
|
163 |
|
164 |
|
165 CxeScene& CxeFakeSettingsModel::currentVideoScene() |
|
166 { |
|
167 return mDummyVideoScene; |
|
168 } |
|
169 |
|
170 |
|
171 void CxeFakeSettingsModel::cameraModeChanged(Cxe::CameraMode newMode) |
|
172 { |
|
173 mDummyCameraMode = newMode; |
|
174 } |
|
175 |
|
176 |
|
177 /* This helper method initializes fake store for default camera settings |
|
178 */ |
|
179 void CxeFakeSettingsModel::initDefaultCameraSettings() |
|
180 { |
|
181 CX_DEBUG_ENTER_FUNCTION(); |
|
182 mSettingStore.insert(CxeSettingIds::FNAME_FOLDER_SUFFIX, QVariant(1)); |
|
183 mSettingStore.insert(CxeSettingIds::FNAME_MONTH_FOLDER, QVariant(1)); |
|
184 mSettingStore.insert(CxeSettingIds::FNAME_IMAGE_COUNTER, QVariant(1)); |
|
185 mSettingStore.insert(CxeSettingIds::FNAME_VIDEO_COUNTER, QVariant(1)); |
|
186 mSettingStore.insert(CxeSettingIds::COLOR_TONE, QVariant(1)); |
|
187 mSettingStore.insert(CxeSettingIds::SHARPNESS, QVariant(1)); |
|
188 mSettingStore.insert(CxeSettingIds::CONTRAST, QVariant(1)); |
|
189 mSettingStore.insert(CxeSettingIds::BRIGHTNESS, QVariant(1)); |
|
190 mSettingStore.insert(CxeSettingIds::EV_COMPENSATION_VALUE, QVariant(1)); |
|
191 mSettingStore.insert(CxeSettingIds::EXPOSURE_MODE, QVariant(1)); |
|
192 mSettingStore.insert(CxeSettingIds::FLASH_MODE, QVariant(1)); |
|
193 mSettingStore.insert(CxeSettingIds::FOCAL_RANGE, QVariant(1)); |
|
194 mSettingStore.insert(CxeSettingIds::FRAME_RATE, QVariant(1)); |
|
195 mSettingStore.insert(CxeSettingIds::IMAGE_QUALITY, QVariant(1)); |
|
196 mSettingStore.insert(CxeSettingIds::IMAGE_SCENE, QVariant(1)); |
|
197 mSettingStore.insert(CxeSettingIds::LIGHT_SENSITIVITY, QVariant(1)); |
|
198 mSettingStore.insert(CxeSettingIds::SCENE_ID, QVariant(1)); |
|
199 mSettingStore.insert(CxeSettingIds::SECONDARY_CAMERA, QVariant(1)); |
|
200 mSettingStore.insert(CxeSettingIds::SELF_TIMER, QVariant(1)); |
|
201 mSettingStore.insert(CxeSettingIds::VIDEO_SCENE, QVariant(1)); |
|
202 mSettingStore.insert(CxeSettingIds::WHITE_BALANCE, QVariant(1)); |
|
203 |
|
204 // default scene |
|
205 setImageScene(Cxe::IMAGE_SCENE_AUTO); |
|
206 setVideoScene(Cxe::VIDEO_SCENE_AUTO); |
|
207 |
|
208 CX_DEBUG_EXIT_FUNCTION(); |
|
209 } |
|
210 |
|
211 |
|
212 |
|
213 /* This helper method initializes fake runtime setting values for the keys |
|
214 */ |
|
215 void CxeFakeSettingsModel::initRuntimeSettings() |
|
216 { |
|
217 CX_DEBUG_ENTER_FUNCTION(); |
|
218 |
|
219 QVariantList supported; |
|
220 supported.append(QVariant(1)); |
|
221 |
|
222 QVariantList notSupported; |
|
223 notSupported.append(QVariant(0)); |
|
224 |
|
225 QVariantList values; |
|
226 values.append(QVariant(1)); |
|
227 values.append(QVariant(2)); |
|
228 values.append(QVariant(3)); |
|
229 |
|
230 mRuntimeSettings.insert(CxeRuntimeKeys::PRIMARY_CAMERA_CAPTURE_KEYS, supported); |
|
231 mRuntimeSettings.insert(CxeRuntimeKeys::PRIMARY_CAMERA_AUTOFOCUS_KEYS, supported); |
|
232 mRuntimeSettings.insert(CxeRuntimeKeys::SECONDARY_CAMERA_CAPTURE_KEYS, notSupported); |
|
233 mRuntimeSettings.insert(CxeRuntimeKeys::FREE_MEMORY_LEVELS, notSupported); |
|
234 mRuntimeSettings.insert(CxeRuntimeKeys::STILL_MAX_ZOOM_LIMITS, values); |
|
235 mRuntimeSettings.insert(CxeRuntimeKeys::VIDEO_MAX_ZOOM_LIMITS, values); |
|
236 |
|
237 CX_DEBUG_EXIT_FUNCTION(); |
|
238 } |
|
239 |
|
240 |
|
241 // end of file |
|