camerauis/cameraxui/cxengine/src/cxesettingsimp.cpp
changeset 41 67457b2ffb33
parent 28 3075d9b614e6
child 45 24fd82631616
equal deleted inserted replaced
40:2922f70fca82 41:67457b2ffb33
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    67 
    67 
    68 
    68 
    69 /*!
    69 /*!
    70     Return the current integer setting value for the given key
    70     Return the current integer setting value for the given key
    71 */
    71 */
    72 CxeError::Id CxeSettingsImp::get(const QString& key, int& value) const
    72 CxeError::Id CxeSettingsImp::get(const QString &key, int &value) const
    73 {
    73 {
    74     CX_DEBUG_ENTER_FUNCTION();
    74     CX_DEBUG_ENTER_FUNCTION();
    75 
    75 
    76     QVariant v;
    76     QVariant v;
    77     CxeError::Id err = mSettingsModel.getSettingValue(key, v);
    77     CxeError::Id err = mSettingsModel.getSettingValue(key, v);
   122 
   122 
   123 /*!
   123 /*!
   124     Return the current string setting value for the given key
   124     Return the current string setting value for the given key
   125 */
   125 */
   126 CxeError::Id CxeSettingsImp::get(
   126 CxeError::Id CxeSettingsImp::get(
   127         const QString& key, QString &stringValue) const
   127         const QString &key, QString &stringValue) const
   128 {
   128 {
   129     CX_DEBUG_ENTER_FUNCTION();
   129     CX_DEBUG_ENTER_FUNCTION();
   130 
   130 
   131     QVariant value;
   131     QVariant value;
   132     CxeError::Id err = getSceneMode(key, stringValue);
   132     CxeError::Id err = getSceneMode(key, stringValue);
   171 
   171 
   172 /*!
   172 /*!
   173     Get the current scene mode setting value for the given key
   173     Get the current scene mode setting value for the given key
   174 */
   174 */
   175 CxeError::Id CxeSettingsImp::getSceneMode(
   175 CxeError::Id CxeSettingsImp::getSceneMode(
   176         const QString& key, QString &stringValue) const
   176         const QString &key, QString &stringValue) const
   177 {
   177 {
   178     CX_DEBUG_ENTER_FUNCTION();
   178     CX_DEBUG_ENTER_FUNCTION();
   179 
   179 
   180     CxeError::Id err = CxeError::None;
   180     CxeError::Id err = CxeError::None;
   181     CxeScene scene;
   181     CxeScene scene;
   202 
   202 
   203 
   203 
   204 /*!
   204 /*!
   205     Set new int value for the given key
   205     Set new int value for the given key
   206 */
   206 */
   207 CxeError::Id CxeSettingsImp::set(const QString& key,int newValue)
   207 CxeError::Id CxeSettingsImp::set(const QString &key, int newValue)
   208 {
   208 {
   209     CX_DEBUG_ENTER_FUNCTION();
   209     CX_DEBUG_ENTER_FUNCTION();
   210 
   210 
   211     CX_DEBUG(("CxeSettingsImp::set - key: %s value: %d",
   211     CX_DEBUG(("CxeSettingsImp::set - key: %s value: %d",
   212               key.toAscii().data(), newValue));
   212               key.toAscii().data(), newValue));
   213 
   213 
   214     CxeError::Id err = mSettingsModel.set(key, newValue);
   214     CxeError::Id error = mSettingsModel.set(key, newValue);
   215     emit settingValueChanged(key, newValue);
   215     if (error == CxeError::None) {
   216 
   216         emit settingValueChanged(key, newValue);
   217     CX_DEBUG_EXIT_FUNCTION();
   217     }
   218 
   218 
   219     return err;
   219     CX_DEBUG_EXIT_FUNCTION();
       
   220 
       
   221     return error;
   220 }
   222 }
   221 
   223 
   222 
   224 
   223 
   225 
   224 /*!
   226 /*!
   225     Set new int value for the given key
   227     Set new int value for the given key
   226 */
   228 */
   227 CxeError::Id CxeSettingsImp::set(const QString& key,qreal newValue)
   229 CxeError::Id CxeSettingsImp::set(const QString &key, qreal newValue)
   228 {
   230 {
   229     CX_DEBUG_ENTER_FUNCTION();
   231     CX_DEBUG_ENTER_FUNCTION();
   230 
   232 
   231     CX_DEBUG(("CxeSettingsImp::set - key: %s value: %f",
   233     CX_DEBUG(("CxeSettingsImp::set - key: %s value: %f",
   232               key.toAscii().data(), newValue));
   234               key.toAscii().data(), newValue));
   233 
   235 
   234     CxeError::Id err = mSettingsModel.set(key, newValue);
   236     CxeError::Id error = mSettingsModel.set(key, newValue);
   235     emit settingValueChanged(key, newValue);
   237 
   236 
   238     if (error == CxeError::None) {
   237     CX_DEBUG_EXIT_FUNCTION();
   239         emit settingValueChanged(key, newValue);
   238 
   240     }
   239     return err;
   241 
       
   242     CX_DEBUG_EXIT_FUNCTION();
       
   243 
       
   244     return error;
   240 }
   245 }
   241 
   246 
   242 
   247 
   243 /*!
   248 /*!
   244     Set new string value for the given key
   249     Set new string value for the given key
   245 */
   250 */
   246 CxeError::Id CxeSettingsImp::set(const QString& key,const QString& newValue)
   251 CxeError::Id CxeSettingsImp::set(const QString &key, const QString &newValue)
   247 {
   252 {
   248     CX_DEBUG_ENTER_FUNCTION();
   253     CX_DEBUG_ENTER_FUNCTION();
   249 
   254 
   250     CX_DEBUG(("CxeSettingsImp::set - key: %s value: %s",
   255     CX_DEBUG(("CxeSettingsImp::set - key: %s value: %s",
   251               key.toAscii().data(), newValue.toAscii().data()));
   256               key.toAscii().data(), newValue.toAscii().data()));
   252 
   257 
   253     CxeError::Id err = setSceneMode(key, newValue);
   258     CxeError::Id error = setSceneMode(key, newValue);
   254 
   259 
   255     if (err == CxeError::NotFound) {
   260     if (error == CxeError::NotFound) {
   256         // not scene mode setting, try setting value to settings store
   261         // not scene mode setting, try setting value to settings store
   257         mSettingsModel.set(key, newValue);
   262         mSettingsModel.set(key, newValue);
   258         emit settingValueChanged(key, newValue);
   263         emit settingValueChanged(key, newValue);
   259     }
   264     }
   260 
   265 
   261     CX_DEBUG_EXIT_FUNCTION();
   266     CX_DEBUG_EXIT_FUNCTION();
   262 
   267 
   263     return err;
   268     return error;
   264 }
   269 }
   265 
   270 
   266 
   271 
   267 
   272 
   268 /*!
   273 /*!
   269     Set the current scene mode setting value for the given key
   274     Set the current scene mode setting value for the given key
   270 */
   275 */
   271 CxeError::Id CxeSettingsImp::setSceneMode(
   276 CxeError::Id CxeSettingsImp::setSceneMode(
   272         const QString& key,const QString& newValue)
   277         const QString &key,const QString &newValue)
   273 {
   278 {
   274     CX_DEBUG_ENTER_FUNCTION();
   279     CX_DEBUG_ENTER_FUNCTION();
   275 
   280 
   276     CX_DEBUG(("CxeSettingsImp::set - key: %s value: %s",
   281     CX_DEBUG(("CxeSettingsImp::set - key: %s value: %s",
   277               key.toAscii().data(), newValue.toAscii().data()));
   282               key.toAscii().data(), newValue.toAscii().data()));
   278 
   283 
   279     CxeError::Id err = CxeError::None;
   284     CxeError::Id error = CxeError::None;
   280     CxeScene scene;
   285     CxeScene scene;
   281 
   286 
   282     if(CxeSettingIds::IMAGE_SCENE == key) {
   287     if(CxeSettingIds::IMAGE_SCENE == key) {
   283         err = mSettingsModel.setImageScene(newValue);
   288         error = mSettingsModel.setImageScene(newValue);
   284         scene = mSettingsModel.currentImageScene();
   289         scene = mSettingsModel.currentImageScene();
   285     } else if(CxeSettingIds::VIDEO_SCENE == key) {
   290     } else if(CxeSettingIds::VIDEO_SCENE == key) {
   286         err = mSettingsModel.setVideoScene(newValue);
   291         error = mSettingsModel.setVideoScene(newValue);
   287         scene = mSettingsModel.currentVideoScene();
   292         scene = mSettingsModel.currentVideoScene();
   288     } else {
   293     } else {
   289         err = CxeError::NotFound;
   294         error = CxeError::NotFound;
   290     }
   295     }
   291 
   296 
   292     if (err == CxeError::None) {
   297     if (error == CxeError::None) {
   293         // scene mode set, inform clients about scene mode change
   298         // scene mode set, inform clients about scene mode change
   294         emit sceneChanged(scene);
   299         emit sceneChanged(scene);
   295     }
   300     }
   296 
   301 
   297     CX_DEBUG_EXIT_FUNCTION();
   302     CX_DEBUG_EXIT_FUNCTION();
   298 
   303 
   299     return err;
   304     return error;
   300 }
   305 }
   301 
   306 
   302 /*!
   307 /*!
   303     Reset static settings (persistent settings)
   308     Reset static settings (persistent settings)
   304 */
   309 */
   314 
   319 
   315 
   320 
   316 /*
   321 /*
   317 * CxeSettingsImp::CxeSettingsImp
   322 * CxeSettingsImp::CxeSettingsImp
   318 */
   323 */
   319 CxeSettingsImp::CxeSettingsImp(CxeSettingsModel& settingsModel)
   324 CxeSettingsImp::CxeSettingsImp(CxeSettingsModel &settingsModel)
   320 : mSettingsModel(settingsModel)
   325 : mSettingsModel(settingsModel)
   321 {
   326 {
   322     CX_DEBUG_IN_FUNCTION();
   327     CX_DEBUG_IN_FUNCTION();
   323 }
   328 }
   324 
   329