35 Default constructor. |
40 Default constructor. |
36 */ |
41 */ |
37 SettingsUtility::SettingsUtility(QObject *parent) |
42 SettingsUtility::SettingsUtility(QObject *parent) |
38 :QObject(parent) |
43 :QObject(parent) |
39 { |
44 { |
|
45 OstTraceFunctionEntry0( SETTINGSUTILITY_SETTINGSUTILITY_ENTRY ); |
40 mTimeSeparatorList << tr(".") << tr(":"); |
46 mTimeSeparatorList << tr(".") << tr(":"); |
41 mClockTypeList << hbTrId("txt_clock_button_digital") << hbTrId("txt_clock_button_analog"); |
47 mClockTypeList << hbTrId("txt_clock_button_digital") << hbTrId("txt_clock_button_analog"); |
42 mTimeFormatList << hbTrId("txt_clk_setlabel_val_24_hour") << hbTrId("txt_clk_setlabel_val_12_hour"); |
48 mTimeFormatList << hbTrId("txt_clk_setlabel_val_24_hour") << hbTrId("txt_clk_setlabel_val_12_hour"); |
43 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"); |
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"); |
44 mDateSeparatorList << tr(".") << tr(":") << tr("/") << tr("-"); |
50 mDateSeparatorList << tr(".") << tr(":") << tr("/") << tr("-"); |
45 mAutoUpdateValueList << tr("ON") << tr("OFF"); |
51 mAutoUpdateValueList << tr("ON") << tr("OFF"); |
46 mSnoozeValueList << tr("5 minutes") << tr("15 minutes") << tr(" 30 minutes") << tr("1 hour"); |
52 mSnoozeValueList << tr("5 minutes") << tr("15 minutes") << tr(" 30 minutes") << tr("1 hour"); |
|
53 OstTraceFunctionExit0( SETTINGSUTILITY_SETTINGSUTILITY_EXIT ); |
47 } |
54 } |
48 |
55 |
49 /*! |
56 /*! |
50 Destructor. |
57 Destructor. |
51 */ |
58 */ |
52 SettingsUtility::~SettingsUtility() |
59 SettingsUtility::~SettingsUtility() |
53 { |
60 { |
|
61 OstTraceFunctionEntry0( DUP1_SETTINGSUTILITY_SETTINGSUTILITY_ENTRY ); |
54 // Nothing. |
62 // Nothing. |
|
63 OstTraceFunctionExit0( DUP1_SETTINGSUTILITY_SETTINGSUTILITY_EXIT ); |
55 } |
64 } |
56 |
65 |
57 /*! |
66 /*! |
58 Returns the current time in the device. |
67 Returns the current time in the device. |
59 */ |
68 */ |
60 QString SettingsUtility::time() |
69 QString SettingsUtility::time() |
61 { |
70 { |
|
71 OstTraceFunctionEntry0( SETTINGSUTILITY_TIME_ENTRY ); |
62 return QTime::currentTime().toString(timeFormatString()); |
72 return QTime::currentTime().toString(timeFormatString()); |
63 } |
73 } |
64 |
74 |
65 /*! |
75 /*! |
66 |
76 |
67 */ |
77 */ |
68 void SettingsUtility::setTimeFormat(const QString& format) |
78 void SettingsUtility::setTimeFormat(const QString& format) |
69 { |
79 { |
|
80 OstTraceFunctionEntry0( SETTINGSUTILITY_SETTIMEFORMAT_ENTRY ); |
70 TLocale locale; |
81 TLocale locale; |
71 |
82 |
72 if (format == mTimeFormatList.at(0)) { |
83 if (format == mTimeFormatList.at(0)) { |
73 locale.SetTimeFormat(ETime24); |
84 locale.SetTimeFormat(ETime24); |
74 } else if (format == mTimeFormatList.at(1)) { |
85 } else if (format == mTimeFormatList.at(1)) { |
75 locale.SetTimeFormat(ETime12); |
86 locale.SetTimeFormat(ETime12); |
76 } else { |
87 } else { |
77 // Nothing to do. |
88 // Nothing to do. |
78 } |
89 } |
79 locale.Set(); |
90 locale.Set(); |
|
91 OstTraceFunctionExit0( SETTINGSUTILITY_SETTIMEFORMAT_EXIT ); |
80 } |
92 } |
81 |
93 |
82 /*! |
94 /*! |
83 |
95 |
84 */ |
96 */ |
85 int SettingsUtility::timeFormat(QStringList &format) |
97 int SettingsUtility::timeFormat(QStringList &format) |
86 { |
98 { |
|
99 OstTraceFunctionEntry0( SETTINGSUTILITY_TIMEFORMAT_ENTRY ); |
87 TLocale locale; |
100 TLocale locale; |
88 int value = -1; |
101 int value = -1; |
89 |
102 |
90 if (ETime24 == locale.TimeFormat()) { |
103 if (ETime24 == locale.TimeFormat()) { |
91 value = 0; |
104 value = 0; |
93 value = 1; |
106 value = 1; |
94 } |
107 } |
95 |
108 |
96 format = mTimeFormatList; |
109 format = mTimeFormatList; |
97 |
110 |
|
111 OstTraceFunctionExit0( SETTINGSUTILITY_TIMEFORMAT_EXIT ); |
98 return value; |
112 return value; |
99 } |
113 } |
100 |
114 |
101 /*! |
115 /*! |
102 |
116 |
103 */ |
117 */ |
104 void SettingsUtility::setClockType(const QString &type) |
118 void SettingsUtility::setClockType(const QString &type) |
105 { |
119 { |
|
120 OstTraceFunctionEntry0( SETTINGSUTILITY_SETCLOCKTYPE_ENTRY ); |
106 TLocale locale; |
121 TLocale locale; |
107 |
122 |
108 if (type == mClockTypeList.at(0)) { |
123 if (type == mClockTypeList.at(0)) { |
109 locale.SetClockFormat(EClockDigital); |
124 locale.SetClockFormat(EClockDigital); |
110 } else if (type == mClockTypeList.at(1)) { |
125 } else if (type == mClockTypeList.at(1)) { |
111 locale.SetClockFormat(EClockAnalog); |
126 locale.SetClockFormat(EClockAnalog); |
112 } else { |
127 } else { |
113 // Nothing to do. |
128 // Nothing to do. |
114 } |
129 } |
115 locale.Set(); |
130 locale.Set(); |
|
131 OstTraceFunctionExit0( SETTINGSUTILITY_SETCLOCKTYPE_EXIT ); |
116 } |
132 } |
117 |
133 |
118 /*! |
134 /*! |
119 |
135 |
120 */ |
136 */ |
121 int SettingsUtility::clockType(QStringList &list) |
137 int SettingsUtility::clockType(QStringList &list) |
122 { |
138 { |
|
139 OstTraceFunctionEntry0( SETTINGSUTILITY_CLOCKTYPE_ENTRY ); |
123 TLocale locale; |
140 TLocale locale; |
124 int value = -1; |
141 int value = -1; |
125 |
142 |
126 if (EClockAnalog == locale.ClockFormat()) { |
143 if (EClockAnalog == locale.ClockFormat()) { |
127 value = 1; |
144 value = 1; |
131 // Nothing to do. |
148 // Nothing to do. |
132 } |
149 } |
133 |
150 |
134 list = mClockTypeList; |
151 list = mClockTypeList; |
135 |
152 |
|
153 OstTraceFunctionExit0( SETTINGSUTILITY_CLOCKTYPE_EXIT ); |
136 return value; |
154 return value; |
137 } |
155 } |
138 |
156 |
139 /*! |
157 /*! |
140 |
158 |
141 */ |
159 */ |
142 void SettingsUtility::setTimeSeparator(const QString &separator) |
160 void SettingsUtility::setTimeSeparator(const QString &separator) |
143 { |
161 { |
|
162 OstTraceFunctionEntry0( SETTINGSUTILITY_SETTIMESEPARATOR_ENTRY ); |
144 if (mTimeSeparatorList.contains(separator)) { |
163 if (mTimeSeparatorList.contains(separator)) { |
145 TLocale locale; |
164 TLocale locale; |
146 |
165 |
147 locale.SetTimeSeparator(TChar(separator.unicode()->unicode()), 1); |
166 locale.SetTimeSeparator(TChar(separator.unicode()->unicode()), 1); |
148 locale.SetTimeSeparator(TChar(separator.unicode()->unicode()), 2); |
167 locale.SetTimeSeparator(TChar(separator.unicode()->unicode()), 2); |
149 |
168 |
150 locale.Set(); |
169 locale.Set(); |
151 } |
170 } |
|
171 OstTraceFunctionExit0( SETTINGSUTILITY_SETTIMESEPARATOR_EXIT ); |
152 } |
172 } |
153 |
173 |
154 /*! |
174 /*! |
155 |
175 |
156 */ |
176 */ |
157 int SettingsUtility::timeSeparator(QStringList &list) |
177 int SettingsUtility::timeSeparator(QStringList &list) |
158 { |
178 { |
|
179 OstTraceFunctionEntry0( SETTINGSUTILITY_TIMESEPARATOR_ENTRY ); |
159 TLocale locale; |
180 TLocale locale; |
160 TChar separatorChar = locale.TimeSeparator(1); |
181 TChar separatorChar = locale.TimeSeparator(1); |
161 int value = -1; |
182 int value = -1; |
162 |
183 |
163 if (separatorChar == (mTimeSeparatorList.at(0).unicode())->unicode()) { |
184 if (separatorChar == (mTimeSeparatorList.at(0).unicode())->unicode()) { |
167 } else { |
188 } else { |
168 // Nothing to do. |
189 // Nothing to do. |
169 } |
190 } |
170 |
191 |
171 list = mTimeSeparatorList; |
192 list = mTimeSeparatorList; |
|
193 OstTraceFunctionExit0( SETTINGSUTILITY_TIMESEPARATOR_EXIT ); |
172 return value; |
194 return value; |
173 } |
195 } |
174 |
196 |
175 /*! |
197 /*! |
176 |
198 |
177 */ |
199 */ |
178 QString SettingsUtility::date() |
200 QString SettingsUtility::date() |
179 { |
201 { |
|
202 OstTraceFunctionEntry0( SETTINGSUTILITY_DATE_ENTRY ); |
180 return QDate::currentDate().toString(dateFormatString()); |
203 return QDate::currentDate().toString(dateFormatString()); |
181 } |
204 } |
182 |
205 |
183 /*! |
206 /*! |
184 |
207 |
185 */ |
208 */ |
186 void SettingsUtility::setDateFormat(const QString &format) |
209 void SettingsUtility::setDateFormat(const QString &format) |
187 { |
210 { |
|
211 OstTraceFunctionEntry0( SETTINGSUTILITY_SETDATEFORMAT_ENTRY ); |
188 TLocale locale; |
212 TLocale locale; |
189 int index; |
213 int index; |
190 |
214 |
191 for (index = 0; index < mDateFormatList.count(); ++index) { |
215 for (index = 0; index < mDateFormatList.count(); ++index) { |
192 if (format == mDateFormatList.at(index)) { |
216 if (format == mDateFormatList.at(index)) { |
235 break; |
261 break; |
236 } |
262 } |
237 |
263 |
238 format = mDateFormatList; |
264 format = mDateFormatList; |
239 |
265 |
|
266 OstTraceFunctionExit0( SETTINGSUTILITY_DATEFORMAT_EXIT ); |
240 return index; |
267 return index; |
241 } |
268 } |
242 |
269 |
243 /*! |
270 /*! |
244 |
271 |
245 */ |
272 */ |
246 void SettingsUtility::setDateSeparator(const QString &separator) |
273 void SettingsUtility::setDateSeparator(const QString &separator) |
247 { |
274 { |
|
275 OstTraceFunctionEntry0( SETTINGSUTILITY_SETDATESEPARATOR_ENTRY ); |
248 TLocale locale; |
276 TLocale locale; |
249 locale.SetDateSeparator( |
277 locale.SetDateSeparator( |
250 TChar(separator.unicode()->unicode()), 1); |
278 TChar(separator.unicode()->unicode()), 1); |
251 locale.SetDateSeparator( |
279 locale.SetDateSeparator( |
252 TChar(separator.unicode()->unicode()), 2); |
280 TChar(separator.unicode()->unicode()), 2); |
253 locale.Set(); |
281 locale.Set(); |
|
282 OstTraceFunctionExit0( SETTINGSUTILITY_SETDATESEPARATOR_EXIT ); |
254 } |
283 } |
255 |
284 |
256 /*! |
285 /*! |
257 |
286 |
258 */ |
287 */ |
259 int SettingsUtility::dateSeparator(QStringList &separator) |
288 int SettingsUtility::dateSeparator(QStringList &separator) |
260 { |
289 { |
|
290 OstTraceFunctionEntry0( SETTINGSUTILITY_DATESEPARATOR_ENTRY ); |
261 TLocale locale; |
291 TLocale locale; |
262 TChar separatorChar = locale.DateSeparator(1); |
292 TChar separatorChar = locale.DateSeparator(1); |
263 |
293 |
264 const int at0 = (mDateSeparatorList.at(0).unicode())->unicode(); |
294 const int at0 = (mDateSeparatorList.at(0).unicode())->unicode(); |
265 int at1 = (mDateSeparatorList.at(1).unicode())->unicode(); |
295 int at1 = (mDateSeparatorList.at(1).unicode())->unicode(); |
280 value = 3; |
310 value = 3; |
281 } |
311 } |
282 |
312 |
283 separator = mDateSeparatorList; |
313 separator = mDateSeparatorList; |
284 |
314 |
|
315 OstTraceFunctionExit0( SETTINGSUTILITY_DATESEPARATOR_EXIT ); |
285 return value; |
316 return value; |
286 } |
317 } |
287 |
318 |
288 /*! |
319 /*! |
289 Sets a new list of workdays. |
320 Sets a new list of workdays. |
290 |
321 |
291 \param workdays The new list of workdays selected. |
322 \param workdays The new list of workdays selected. |
292 */ |
323 */ |
293 void SettingsUtility::setWorkdays(const QString &workdays) |
324 void SettingsUtility::setWorkdays(const QString &workdays) |
294 { |
325 { |
|
326 OstTraceFunctionEntry0( SETTINGSUTILITY_SETWORKDAYS_ENTRY ); |
295 Q_UNUSED(workdays) |
327 Q_UNUSED(workdays) |
|
328 OstTraceFunctionExit0( SETTINGSUTILITY_SETWORKDAYS_EXIT ); |
296 } |
329 } |
297 |
330 |
298 /*! |
331 /*! |
299 Returns the workdays list selected by the user. |
332 Returns the workdays list selected by the user. |
300 |
333 |
301 \param workdaysList A string list of workdays selected in the locale. |
334 \param workdaysList A string list of workdays selected in the locale. |
302 \return int Index of the item selected. |
335 \return int Index of the item selected. |
303 */ |
336 */ |
304 int SettingsUtility::workdays(QStringList &workdaysList) |
337 int SettingsUtility::workdays(QStringList &workdaysList) |
305 { |
338 { |
|
339 OstTraceFunctionEntry0( SETTINGSUTILITY_WORKDAYS_ENTRY ); |
306 Q_UNUSED(workdaysList) |
340 Q_UNUSED(workdaysList) |
307 |
341 |
308 return 0; |
342 return 0; |
309 } |
343 } |
310 |
344 |
327 |
362 |
328 QString separator = mTimeSeparatorList.at(timeSeparator(dummyList)); |
363 QString separator = mTimeSeparatorList.at(timeSeparator(dummyList)); |
329 |
364 |
330 format.replace(QString(":"), separator); |
365 format.replace(QString(":"), separator); |
331 |
366 |
|
367 OstTraceFunctionExit0( SETTINGSUTILITY_TIMEFORMATSTRING_EXIT ); |
332 return format; |
368 return format; |
333 } |
369 } |
334 |
370 |
335 /*! |
371 /*! |
336 Returns a string based on the locale set, to format date. |
372 Returns a string based on the locale set, to format date. |
337 |
373 |
338 \return QString String to be used to format date. |
374 \return QString String to be used to format date. |
339 */ |
375 */ |
340 QString SettingsUtility::dateFormatString() |
376 QString SettingsUtility::dateFormatString() |
341 { |
377 { |
|
378 OstTraceFunctionEntry0( SETTINGSUTILITY_DATEFORMATSTRING_ENTRY ); |
342 QStringList dummyList; |
379 QStringList dummyList; |
343 QString format(mDateFormatList.at(dateFormat(dummyList))); |
380 QString format(mDateFormatList.at(dateFormat(dummyList))); |
344 QString separator = mDateSeparatorList.at(dateSeparator(dummyList)); |
381 QString separator = mDateSeparatorList.at(dateSeparator(dummyList)); |
345 |
382 |
346 format.replace(QString(" "), separator); |
383 format.replace(QString(" "), separator); |
347 format.replace(QString("mm"), QString("MM")); |
384 format.replace(QString("mm"), QString("MM")); |
348 |
385 |
|
386 OstTraceFunctionExit0( SETTINGSUTILITY_DATEFORMATSTRING_EXIT ); |
349 return format; |
387 return format; |
350 } |
388 } |
351 |
389 |
352 /*! |
390 /*! |
353 Sets the snooze time value selected by the user. |
391 Sets the snooze time value selected by the user. |
354 |
392 |
355 \param index The index of the preset snooze time values. |
393 \param index The index of the preset snooze time values. |
356 */ |
394 */ |
357 void SettingsUtility::setSnoozeTime(int index) |
395 void SettingsUtility::setSnoozeTime(int index) |
358 { |
396 { |
|
397 OstTraceFunctionEntry0( SETTINGSUTILITY_SETSNOOZETIME_ENTRY ); |
359 Q_UNUSED(index) |
398 Q_UNUSED(index) |
|
399 OstTraceFunctionExit0( SETTINGSUTILITY_SETSNOOZETIME_EXIT ); |
360 } |
400 } |
361 |
401 |
362 /*! |
402 /*! |
363 Returns a list of default snooze time values. |
403 Returns a list of default snooze time values. |
364 |
404 |
365 \param snoozeValueList A string list of preset values. |
405 \param snoozeValueList A string list of preset values. |
366 \return int The index of the item in the list to be focused. |
406 \return int The index of the item in the list to be focused. |
367 */ |
407 */ |
368 int SettingsUtility::snoozeTime(QStringList &snoozeValueList) |
408 int SettingsUtility::snoozeTime(QStringList &snoozeValueList) |
369 { |
409 { |
|
410 OstTraceFunctionEntry0( SETTINGSUTILITY_SNOOZETIME_ENTRY ); |
370 int index = -1; |
411 int index = -1; |
371 |
412 |
372 snoozeValueList = mSnoozeValueList; |
413 snoozeValueList = mSnoozeValueList; |
|
414 OstTraceFunctionExit0( SETTINGSUTILITY_SNOOZETIME_EXIT ); |
373 return index; |
415 return index; |
374 } |
416 } |
375 |
417 |
376 /*! |
418 /*! |
377 Sets the start of week value selected by the user. |
419 Sets the start of week value selected by the user. |
378 |
420 |
379 \param index The index of the selected value. |
421 \param index The index of the selected value. |
380 */ |
422 */ |
381 void SettingsUtility::setStartOfWeek(int index) |
423 void SettingsUtility::setStartOfWeek(int index) |
382 { |
424 { |
|
425 OstTraceFunctionEntry0( SETTINGSUTILITY_SETSTARTOFWEEK_ENTRY ); |
383 TLocale locale; |
426 TLocale locale; |
384 TDay day = (TDay)index; |
427 TDay day = (TDay)index; |
385 locale.SetStartOfWeek(day); |
428 locale.SetStartOfWeek(day); |
386 locale.Set(); |
429 locale.Set(); |
|
430 OstTraceFunctionExit0( SETTINGSUTILITY_SETSTARTOFWEEK_EXIT ); |
387 } |
431 } |
388 // End of file --Don't remove this. |
432 // End of file --Don't remove this. |