clock/clockmw/clocksettingsutility/src/settingsutility.cpp
changeset 75 7ac58b2aae6f
parent 57 bb2d3e476f29
equal deleted inserted replaced
72:27feeedec790 75:7ac58b2aae6f
    18 
    18 
    19 // System includes
    19 // System includes
    20 #include <e32std.h>
    20 #include <e32std.h>
    21 #include <QTime>
    21 #include <QTime>
    22 #include <QDateTime>
    22 #include <QDateTime>
       
    23 #include <xqsettingsmanager.h>
       
    24 #include <xqsettingskey.h>
    23 #include <HbGlobal>
    25 #include <HbGlobal>
       
    26 #include <clockdomaincrkeys.h>
    24 
    27 
    25 // User includes
    28 // User includes
    26 #include "settingsutility.h"
    29 #include "settingsutility.h"
    27 #include "timezoneclient.h"
    30 #include "timezoneclient.h"
    28 #include "clockdatatypes.h"
    31 #include "clockdatatypes.h"
    42 SettingsUtility::SettingsUtility(QObject *parent)
    45 SettingsUtility::SettingsUtility(QObject *parent)
    43 :QObject(parent)
    46 :QObject(parent)
    44 {
    47 {
    45 	OstTraceFunctionEntry0( SETTINGSUTILITY_SETTINGSUTILITY_ENTRY );
    48 	OstTraceFunctionEntry0( SETTINGSUTILITY_SETTINGSUTILITY_ENTRY );
    46 	mTimeSeparatorList << tr(".") << tr(":");
    49 	mTimeSeparatorList << tr(".") << tr(":");
    47 	mClockTypeList << hbTrId("txt_clock_button_digital") << hbTrId("txt_clock_button_analog");
    50 	mClockTypeList << hbTrId("txt_clock_button_analog") << hbTrId("txt_clock_button_digital");
    48 	mTimeFormatList << hbTrId("txt_clk_setlabel_val_24_hour") << hbTrId("txt_clk_setlabel_val_12_hour");
    51 	mTimeFormatList << hbTrId("txt_clk_setlabel_val_24_hour") << hbTrId("txt_clk_setlabel_val_12_hour");
    49 	mDateFormatList << hbTrId("txt_clk_setlabel_val_dd_mm_yyyy") << hbTrId("txt_clk_setlabel_val_mm_dd_yyyy") << hbTrId("txt_clk_setlabel_val_yyyy_mm_dd");
    52 	mDisplayDateFormatList << hbTrId("txt_clk_setlabel_val_dd_mm_yyyy") << hbTrId("txt_clk_setlabel_val_mm_dd_yyyy") << hbTrId("txt_clk_setlabel_val_yyyy_mm_dd");
       
    53 	mDateFormatList << tr("dd mm yyyy") << tr("mm dd yyyy") << tr("yyyy mm dd");
    50 	mDateSeparatorList << tr(".") << tr(":") << tr("/") << tr("-");
    54 	mDateSeparatorList << tr(".") << tr(":") << tr("/") << tr("-");
    51 	mAutoUpdateValueList << tr("ON") << tr("OFF");
    55 	mAutoUpdateValueList << tr("ON") << tr("OFF");
    52 	mSnoozeValueList << tr("5 minutes") << tr("15 minutes") << tr(" 30 minutes") << tr("1 hour");
    56 	mSnoozeValueList << tr("5 minutes") << tr("15 minutes") << tr(" 30 minutes") << tr("1 hour");
       
    57 	
       
    58 	mSettingsManager = new XQSettingsManager(this);
       
    59 	mClockTypeSettingsKey = new XQSettingsKey(
       
    60 							XQSettingsKey::TargetCentralRepository,
       
    61 							KCRUidClockApp,
       
    62 							KClockType);
       
    63 		
    53 	OstTraceFunctionExit0( SETTINGSUTILITY_SETTINGSUTILITY_EXIT );
    64 	OstTraceFunctionExit0( SETTINGSUTILITY_SETTINGSUTILITY_EXIT );
    54 }
    65 }
    55 
    66 
    56 /*!
    67 /*!
    57 	Destructor.
    68 	Destructor.
    58  */
    69  */
    59 SettingsUtility::~SettingsUtility()
    70 SettingsUtility::~SettingsUtility()
    60 {
    71 {
    61 	OstTraceFunctionEntry0( DUP1_SETTINGSUTILITY_SETTINGSUTILITY_ENTRY );
    72 	OstTraceFunctionEntry0( DUP1_SETTINGSUTILITY_SETTINGSUTILITY_ENTRY );
    62 	// Nothing.
    73 	if(mSettingsManager) {
       
    74 		delete mSettingsManager;
       
    75 	}
       
    76 	// Delete the cenrep key
       
    77 	delete mClockTypeSettingsKey;
    63 	OstTraceFunctionExit0( DUP1_SETTINGSUTILITY_SETTINGSUTILITY_EXIT );
    78 	OstTraceFunctionExit0( DUP1_SETTINGSUTILITY_SETTINGSUTILITY_EXIT );
    64 }
    79 }
    65 
    80 
    66 /*!
    81 /*!
    67 	Returns the current time in the device.
    82 	Returns the current time in the device.
   116 
   131 
   117  */
   132  */
   118 void SettingsUtility::setClockType(const QString &type)
   133 void SettingsUtility::setClockType(const QString &type)
   119 {
   134 {
   120 	OstTraceFunctionEntry0( SETTINGSUTILITY_SETCLOCKTYPE_ENTRY );
   135 	OstTraceFunctionEntry0( SETTINGSUTILITY_SETCLOCKTYPE_ENTRY );
   121 	TLocale locale;
   136 	// Check the type and set the cenrep value
   122 
       
   123 	if (type == mClockTypeList.at(0)) {
   137 	if (type == mClockTypeList.at(0)) {
   124 	    locale.SetClockFormat(EClockDigital);
   138 		// The value set for Analogue type is 0
   125     } else if (type == mClockTypeList.at(1)) {
   139 		mSettingsManager->writeItemValue(*mClockTypeSettingsKey, 0);
   126 	    locale.SetClockFormat(EClockAnalog);
   140 	} else if (type == mClockTypeList.at(1)) {
   127     } else {
   141 		// The value set for Digital type is 1
       
   142 		mSettingsManager->writeItemValue(*mClockTypeSettingsKey, 1);
       
   143 	} else {
   128     	// Nothing to do.
   144     	// Nothing to do.
   129     }
   145     }
   130 	locale.Set();
       
   131 	OstTraceFunctionExit0( SETTINGSUTILITY_SETCLOCKTYPE_EXIT );
   146 	OstTraceFunctionExit0( SETTINGSUTILITY_SETCLOCKTYPE_EXIT );
   132 }
   147 }
   133 
   148 
   134 /*!
   149 /*!
   135 
   150 
   136  */
   151  */
   137 int SettingsUtility::clockType(QStringList &list)
   152 int SettingsUtility::clockType(QStringList &list)
   138 {
   153 {
   139 	OstTraceFunctionEntry0( SETTINGSUTILITY_CLOCKTYPE_ENTRY );
   154 	OstTraceFunctionEntry0( SETTINGSUTILITY_CLOCKTYPE_ENTRY );
   140 	TLocale locale;
   155 
   141 	int value = -1;
   156 	int clockType = -1;
   142 
   157 	// Read the clocktype value from the cenrep
   143 	if (EClockAnalog == locale.ClockFormat()) {
   158 	// 0 is for Analogue type and 1 for Digital
   144 	    value = 1;
   159 	QVariant value = mSettingsManager->readItemValue(*mClockTypeSettingsKey);
   145     } else if (EClockDigital == locale.ClockFormat()){
   160 	clockType = value.toInt();
   146     	value = 0;
   161 	
   147     } else {
       
   148     	// Nothing to do.
       
   149     }
       
   150 
       
   151 	list = mClockTypeList;
   162 	list = mClockTypeList;
   152 
       
   153 	OstTraceFunctionExit0( SETTINGSUTILITY_CLOCKTYPE_EXIT );
   163 	OstTraceFunctionExit0( SETTINGSUTILITY_CLOCKTYPE_EXIT );
   154 	return value;
   164 	
       
   165 	return clockType;
   155 }
   166 }
   156 
   167 
   157 /*!
   168 /*!
   158 
   169 
   159  */
   170  */
   210 {
   221 {
   211 	OstTraceFunctionEntry0( SETTINGSUTILITY_SETDATEFORMAT_ENTRY );
   222 	OstTraceFunctionEntry0( SETTINGSUTILITY_SETDATEFORMAT_ENTRY );
   212 	TLocale locale;
   223 	TLocale locale;
   213 	int index;
   224 	int index;
   214 
   225 
   215 	for (index = 0; index < mDateFormatList.count(); ++index) {
   226 	for (index = 0; index < mDisplayDateFormatList.count(); ++index) {
   216 		if (format == mDateFormatList.at(index)) {
   227 		if (format == mDisplayDateFormatList.at(index)) {
   217 			break;
   228 			break;
   218 		}
   229 		}
   219 	}
   230 	}
   220 
   231 
   221 	switch (index) {
   232 	switch (index) {
   259 		default:
   270 		default:
   260 			// Nothing yet.
   271 			// Nothing yet.
   261 			break;
   272 			break;
   262 	}
   273 	}
   263 
   274 
   264 	format = mDateFormatList;
   275 	format = mDisplayDateFormatList;
   265 
   276 
   266 	OstTraceFunctionExit0( SETTINGSUTILITY_DATEFORMAT_EXIT );
   277 	OstTraceFunctionExit0( SETTINGSUTILITY_DATEFORMAT_EXIT );
   267 	return index;
   278 	return index;
   268 }
   279 }
   269 
   280