36 #include "clocksettingsdocloader.h" |
36 #include "clocksettingsdocloader.h" |
37 #include "settingsutility.h" |
37 #include "settingsutility.h" |
38 #include "timezoneclient.h" |
38 #include "timezoneclient.h" |
39 #include "settingsdatatypes.h" |
39 #include "settingsdatatypes.h" |
40 #include "settingscustomitem.h" |
40 #include "settingscustomitem.h" |
|
41 #include "OstTraceDefinitions.h" |
|
42 #ifdef OST_TRACE_COMPILER_IN_USE |
|
43 #include "clocksettingsviewTraces.h" |
|
44 #endif |
|
45 |
41 |
46 |
42 /*! |
47 /*! |
43 \class ClockSettingsView |
48 \class ClockSettingsView |
44 |
49 |
45 This implements the clock settings which allows user to set the |
50 This implements the clock settings which allows user to set the |
52 \param parent The parent of type QGraphicsWidget. |
57 \param parent The parent of type QGraphicsWidget. |
53 */ |
58 */ |
54 ClockSettingsView::ClockSettingsView(QObject *parent) |
59 ClockSettingsView::ClockSettingsView(QObject *parent) |
55 :QObject(parent) |
60 :QObject(parent) |
56 { |
61 { |
|
62 OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_CLOCKSETTINGSVIEW_ENTRY ); |
57 |
63 |
58 // Load the translation file and install the editor specific translator |
64 // Load the translation file and install the editor specific translator |
59 mTranslator = new HbTranslator("clocksettingsview"); |
65 mTranslator = new HbTranslator("clocksettingsview"); |
60 mTranslator->loadCommon(); |
66 mTranslator->loadCommon(); |
61 |
67 |
100 |
106 |
101 // Listen to the key value changes. |
107 // Listen to the key value changes. |
102 connect( |
108 connect( |
103 mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)), |
109 mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)), |
104 this, SLOT(eventMonitor(XQSettingsKey, QVariant))); |
110 this, SLOT(eventMonitor(XQSettingsKey, QVariant))); |
|
111 OstTraceFunctionExit0( CLOCKSETTINGSVIEW_CLOCKSETTINGSVIEW_EXIT ); |
105 } |
112 } |
106 |
113 |
107 /*! |
114 /*! |
108 Destructor. |
115 Destructor. |
109 */ |
116 */ |
110 ClockSettingsView::~ClockSettingsView() |
117 ClockSettingsView::~ClockSettingsView() |
111 { |
118 { |
|
119 OstTraceFunctionEntry0( DUP1_CLOCKSETTINGSVIEW_CLOCKSETTINGSVIEW_ENTRY ); |
112 if (mDocLoader) { |
120 if (mDocLoader) { |
113 delete mDocLoader; |
121 delete mDocLoader; |
114 } |
122 } |
115 |
123 |
116 // Remove the translator |
124 // Remove the translator |
125 if(mSettingsModel){ |
133 if(mSettingsModel){ |
126 delete mSettingsModel; |
134 delete mSettingsModel; |
127 } |
135 } |
128 |
136 |
129 |
137 |
|
138 OstTraceFunctionExit0( DUP1_CLOCKSETTINGSVIEW_CLOCKSETTINGSVIEW_EXIT ); |
130 } |
139 } |
131 |
140 |
132 /*! |
141 /*! |
133 Loads the settings view from the docml. |
142 Loads the settings view from the docml. |
134 */ |
143 */ |
135 void ClockSettingsView::loadSettingsView() |
144 void ClockSettingsView::loadSettingsView() |
136 { |
145 { |
|
146 OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_LOADSETTINGSVIEW_ENTRY ); |
137 bool loadSuccess; |
147 bool loadSuccess; |
138 |
148 |
139 // Construct the document loader instance |
149 // Construct the document loader instance |
140 mDocLoader = new ClockSettingsDocLoader(); |
150 mDocLoader = new ClockSettingsDocLoader(); |
141 |
151 |
170 mDocLoader->findWidget(CLOCK_SETTINGS_VIEW)); |
180 mDocLoader->findWidget(CLOCK_SETTINGS_VIEW)); |
171 |
181 |
172 // Setup the view. |
182 // Setup the view. |
173 setupView(); |
183 setupView(); |
174 |
184 |
|
185 OstTraceFunctionExit0( CLOCKSETTINGSVIEW_LOADSETTINGSVIEW_EXIT ); |
175 } |
186 } |
176 |
187 |
177 /*! |
188 /*! |
178 Slot to handle the back action of the view. |
189 Slot to handle the back action of the view. |
179 */ |
190 */ |
180 void ClockSettingsView::handleBackAction() |
191 void ClockSettingsView::handleBackAction() |
181 { |
192 { |
|
193 OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLEBACKACTION_ENTRY ); |
182 HbMainWindow *window = hbInstance->allMainWindows().first(); |
194 HbMainWindow *window = hbInstance->allMainWindows().first(); |
183 window->removeView(mSettingsView); |
195 window->removeView(mSettingsView); |
184 deleteLater(); |
196 deleteLater(); |
|
197 OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLEBACKACTION_EXIT ); |
185 } |
198 } |
186 |
199 |
187 /*! |
200 /*! |
188 Updates the zone info in the place item field. |
201 Updates the zone info in the place item field. |
189 */ |
202 */ |
190 void ClockSettingsView::updatePlaceItem() |
203 void ClockSettingsView::updatePlaceItem() |
191 { |
204 { |
|
205 OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_UPDATEPLACEITEM_ENTRY ); |
192 // Get the current zone info. |
206 // Get the current zone info. |
193 LocationInfo currentZoneInfo = mTimezoneClient->getCurrentZoneInfoL(); |
207 LocationInfo currentZoneInfo = mTimezoneClient->getCurrentZoneInfoL(); |
194 |
208 |
195 if (mTimezoneClient->timeUpdateOn()) { |
209 if (mTimezoneClient->timeUpdateOn()) { |
196 mPlaceDataFormItem->setContentWidgetData( |
210 mPlaceDataFormItem->setContentWidgetData( |
198 } else { |
212 } else { |
199 QString placeInfo = currentZoneInfo.cityName |
213 QString placeInfo = currentZoneInfo.cityName |
200 + tr(", ") + currentZoneInfo.countryName; |
214 + tr(", ") + currentZoneInfo.countryName; |
201 mPlaceDataFormItem->setContentWidgetData("text", placeInfo); |
215 mPlaceDataFormItem->setContentWidgetData("text", placeInfo); |
202 } |
216 } |
|
217 OstTraceFunctionExit0( CLOCKSETTINGSVIEW_UPDATEPLACEITEM_EXIT ); |
203 } |
218 } |
204 |
219 |
205 /*! |
220 /*! |
206 Slot to update the display of the date settings item field. |
221 Slot to update the display of the date settings item field. |
207 */ |
222 */ |
208 void ClockSettingsView::updateDateItem() |
223 void ClockSettingsView::updateDateItem() |
209 { |
224 { |
|
225 OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_UPDATEDATEITEM_ENTRY ); |
210 mDateDataFormItem->setContentWidgetData("text", mSettingsUtility->date()); |
226 mDateDataFormItem->setContentWidgetData("text", mSettingsUtility->date()); |
|
227 OstTraceFunctionExit0( CLOCKSETTINGSVIEW_UPDATEDATEITEM_EXIT ); |
211 } |
228 } |
212 |
229 |
213 /*! |
230 /*! |
214 Slot to update the display of the time settings item field. |
231 Slot to update the display of the time settings item field. |
215 */ |
232 */ |
216 void ClockSettingsView::updateTimeItem() |
233 void ClockSettingsView::updateTimeItem() |
217 { |
234 { |
|
235 OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_UPDATETIMEITEM_ENTRY ); |
218 if (!mTickTimer->isActive()) { |
236 if (!mTickTimer->isActive()) { |
219 mTickTimer->stop(); |
237 mTickTimer->stop(); |
220 } |
238 } |
221 mTimeDataFormItem->setContentWidgetData("text", mSettingsUtility->time()); |
239 mTimeDataFormItem->setContentWidgetData("text", mSettingsUtility->time()); |
222 |
240 |
223 // Start the timer again. |
241 // Start the timer again. |
224 mTickTimer->start(60000 - 1000 * QTime::currentTime().second()); |
242 mTickTimer->start(60000 - 1000 * QTime::currentTime().second()); |
|
243 OstTraceFunctionExit0( CLOCKSETTINGSVIEW_UPDATETIMEITEM_EXIT ); |
225 } |
244 } |
226 |
245 |
227 /*! |
246 /*! |
228 This slot is called whenever orientattion of the view changes. |
247 This slot is called whenever orientattion of the view changes. |
229 */ |
248 */ |
230 void ClockSettingsView::handleOrientationChanged(Qt::Orientation orientation) |
249 void ClockSettingsView::handleOrientationChanged(Qt::Orientation orientation) |
231 { |
250 { |
|
251 OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLEORIENTATIONCHANGED_ENTRY ); |
232 bool success; |
252 bool success; |
233 // If horizontal, load the landscape section. |
253 // If horizontal, load the landscape section. |
234 if (Qt::Horizontal == orientation) { |
254 if (Qt::Horizontal == orientation) { |
235 mDocLoader->load( |
255 mDocLoader->load( |
236 CLOCK_SETTINGS_VIEW_DOCML, |
256 CLOCK_SETTINGS_VIEW_DOCML, |
240 mDocLoader->load( |
260 mDocLoader->load( |
241 CLOCK_SETTINGS_VIEW_DOCML, |
261 CLOCK_SETTINGS_VIEW_DOCML, |
242 CLOCK_SETTINGS_VIEW_PORTRAIT_SECTION, |
262 CLOCK_SETTINGS_VIEW_PORTRAIT_SECTION, |
243 &success); |
263 &success); |
244 } |
264 } |
|
265 OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLEORIENTATIONCHANGED_EXIT ); |
245 } |
266 } |
246 |
267 |
247 void ClockSettingsView::handleNetworkTimeStateChange(int state) |
268 void ClockSettingsView::handleNetworkTimeStateChange(int state) |
248 { |
269 { |
|
270 OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLENETWORKTIMESTATECHANGE_ENTRY ); |
249 bool cenrepValue = mTimezoneClient->timeUpdateOn(); |
271 bool cenrepValue = mTimezoneClient->timeUpdateOn(); |
250 if ((Qt::Checked == state && !cenrepValue) |
272 if ((Qt::Checked == state && !cenrepValue) |
251 || (Qt::Unchecked == state && cenrepValue)) { |
273 || (Qt::Unchecked == state && cenrepValue)) { |
252 if (Qt::Checked == state) { |
274 if (Qt::Checked == state) { |
253 // Update the cenrep value. |
275 // Update the cenrep value. |
256 } else if (Qt::Unchecked == state) { |
278 } else if (Qt::Unchecked == state) { |
257 // Update the cenrep value. |
279 // Update the cenrep value. |
258 mTimezoneClient->setTimeUpdateOn(false); |
280 mTimezoneClient->setTimeUpdateOn(false); |
259 } |
281 } |
260 } |
282 } |
|
283 OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLENETWORKTIMESTATECHANGE_EXIT ); |
261 } |
284 } |
262 |
285 |
263 /*! |
286 /*! |
264 Called after loading the view from the docml. |
287 Called after loading the view from the docml. |
265 The initializaion/setup of the view is done here. |
288 The initializaion/setup of the view is done here. |
266 |
289 |
267 \param docLoader Pointer to ClockSettingsDocLoader object. |
290 \param docLoader Pointer to ClockSettingsDocLoader object. |
268 */ |
291 */ |
269 void ClockSettingsView::setupView() |
292 void ClockSettingsView::setupView() |
270 { |
293 { |
|
294 OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_SETUPVIEW_ENTRY ); |
271 HbMainWindow *window = hbInstance->allMainWindows().first(); |
295 HbMainWindow *window = hbInstance->allMainWindows().first(); |
272 window->addView(mSettingsView); |
296 window->addView(mSettingsView); |
273 window->setCurrentView(mSettingsView); |
297 window->setCurrentView(mSettingsView); |
274 |
298 |
275 // Add the back softkey. |
299 // Add the back softkey. |
292 // Create the model. |
316 // Create the model. |
293 createModel(); |
317 createModel(); |
294 updatePlaceItem(); |
318 updatePlaceItem(); |
295 |
319 |
296 mTickTimer->start(60000 - 1000 * QTime::currentTime().second()); |
320 mTickTimer->start(60000 - 1000 * QTime::currentTime().second()); |
|
321 OstTraceFunctionExit0( CLOCKSETTINGSVIEW_SETUPVIEW_EXIT ); |
297 } |
322 } |
298 |
323 |
299 /*! |
324 /*! |
300 Creates the model for the settings form. |
325 Creates the model for the settings form. |
301 */ |
326 */ |
302 void ClockSettingsView::createModel() |
327 void ClockSettingsView::createModel() |
303 { |
328 { |
|
329 OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_CREATEMODEL_ENTRY ); |
304 // Remove the model. |
330 // Remove the model. |
305 if (mSettingsForm->model()) { |
331 if (mSettingsForm->model()) { |
306 delete mSettingsForm->model(); |
332 delete mSettingsForm->model(); |
307 mSettingsForm->setModel(0); |
333 mSettingsForm->setModel(0); |
308 } |
334 } |
310 // Create a model and set it. |
336 // Create a model and set it. |
311 mSettingsModel = new HbDataFormModel(); |
337 mSettingsModel = new HbDataFormModel(); |
312 // Add the items to the view. |
338 // Add the items to the view. |
313 populateModel(); |
339 populateModel(); |
314 mSettingsForm->setModel(mSettingsModel); |
340 mSettingsForm->setModel(mSettingsModel); |
|
341 OstTraceFunctionExit0( CLOCKSETTINGSVIEW_CREATEMODEL_EXIT ); |
315 } |
342 } |
316 |
343 |
317 /*! |
344 /*! |
318 Poplulates the item in the model. |
345 Poplulates the item in the model. |
319 */ |
346 */ |
320 void ClockSettingsView::populateModel() |
347 void ClockSettingsView::populateModel() |
321 { |
348 { |
|
349 OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_POPULATEMODEL_ENTRY ); |
322 if (!mSettingsModel) { |
350 if (!mSettingsModel) { |
323 createModel(); |
351 createModel(); |
324 } |
352 } |
325 |
353 |
326 // Add the network time update item. |
354 // Add the network time update item. |
449 mAlarmSnoozeItem->setContentWidgetData("objectName", "alarmSnooze"); |
477 mAlarmSnoozeItem->setContentWidgetData("objectName", "alarmSnooze"); |
450 mSettingsForm->addConnection( |
478 mSettingsForm->addConnection( |
451 mAlarmSnoozeItem, SIGNAL(currentIndexChanged(int)), |
479 mAlarmSnoozeItem, SIGNAL(currentIndexChanged(int)), |
452 this, SLOT(handleAlarmSnoozeTimeChanged(int))); |
480 this, SLOT(handleAlarmSnoozeTimeChanged(int))); |
453 |
481 |
|
482 OstTraceFunctionExit0( CLOCKSETTINGSVIEW_POPULATEMODEL_EXIT ); |
454 } |
483 } |
455 |
484 |
456 /*! |
485 /*! |
457 Slot which handles the auto time update value changes in cenrep. |
486 Slot which handles the auto time update value changes in cenrep. |
458 |
487 |
459 /param value New value of the auto time update. |
488 /param value New value of the auto time update. |
460 */ |
489 */ |
461 void ClockSettingsView::handleAutoTimeUpdateChange(int value) |
490 void ClockSettingsView::handleAutoTimeUpdateChange(int value) |
462 { |
491 { |
|
492 OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLEAUTOTIMEUPDATECHANGE_ENTRY ); |
463 int state = (mNetworkTimeItem->contentWidgetData("checkState")).toInt(); |
493 int state = (mNetworkTimeItem->contentWidgetData("checkState")).toInt(); |
464 |
494 |
465 if (value) { |
495 if (value) { |
466 // Disable the time, date and place item. |
496 // Disable the time, date and place item. |
467 if (mTimeDataFormItem) { |
497 if (mTimeDataFormItem) { |
492 mNetworkTimeItem->setContentWidgetData( |
522 mNetworkTimeItem->setContentWidgetData( |
493 "checkState", Qt::Unchecked); |
523 "checkState", Qt::Unchecked); |
494 } |
524 } |
495 } |
525 } |
496 updatePlaceItem(); |
526 updatePlaceItem(); |
|
527 OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLEAUTOTIMEUPDATECHANGE_EXIT ); |
497 } |
528 } |
498 |
529 |
499 /*! |
530 /*! |
500 Slot which handles the alarm snooze time changes. |
531 Slot which handles the alarm snooze time changes. |
501 |
532 |
502 /param value New index of the alarm snooze time. |
533 /param value New index of the alarm snooze time. |
503 */ |
534 */ |
504 void ClockSettingsView::handleAlarmSnoozeTimeChanged(int index) |
535 void ClockSettingsView::handleAlarmSnoozeTimeChanged(int index) |
505 { |
536 { |
|
537 OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLEALARMSNOOZETIMECHANGED_ENTRY ); |
506 if (mAlarmSnoozeTimeHash.value(index)) { |
538 if (mAlarmSnoozeTimeHash.value(index)) { |
507 mSettingsManager->writeItemValue( |
539 mSettingsManager->writeItemValue( |
508 *mAlarmSnoozeTimeKey, mAlarmSnoozeTimeHash.value(index)); |
540 *mAlarmSnoozeTimeKey, mAlarmSnoozeTimeHash.value(index)); |
509 } |
541 } |
|
542 OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLEALARMSNOOZETIMECHANGED_EXIT ); |
510 } |
543 } |
511 |
544 |
512 /*! |
545 /*! |
513 Slot which handles the clock type change.. |
546 Slot which handles the clock type change.. |
514 */ |
547 */ |
515 void ClockSettingsView::handleClockTypeChanged() |
548 void ClockSettingsView::handleClockTypeChanged() |
516 { |
549 { |
517 mSettingsUtility->setClockType( |
550 OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_HANDLECLOCKTYPECHANGED_ENTRY ); |
518 mClockTypeItem->contentWidgetData("text").toString()); |
551 mSettingsUtility->setClockType( |
|
552 mClockTypeItem->contentWidgetData("text").toString()); |
|
553 OstTraceFunctionExit0( CLOCKSETTINGSVIEW_HANDLECLOCKTYPECHANGED_EXIT ); |
519 } |
554 } |
520 |
555 |
521 /*! |
556 /*! |
522 Slot which is called when the value changes in cenrep. |
557 Slot which is called when the value changes in cenrep. |
523 |
558 |
525 \param value The new value of that key. |
560 \param value The new value of that key. |
526 */ |
561 */ |
527 void ClockSettingsView::eventMonitor( |
562 void ClockSettingsView::eventMonitor( |
528 const XQSettingsKey& key, const QVariant& value) |
563 const XQSettingsKey& key, const QVariant& value) |
529 { |
564 { |
|
565 OstTraceFunctionEntry0( CLOCKSETTINGSVIEW_EVENTMONITOR_ENTRY ); |
530 if (key.uid() == KCRUidClockApp && key.key() == KClockAppSnoozeTime) { |
566 if (key.uid() == KCRUidClockApp && key.key() == KClockAppSnoozeTime) { |
531 if (mSettingsManager->error() == XQSettingsManager::NoError) { |
567 if (mSettingsManager->error() == XQSettingsManager::NoError) { |
532 |
568 |
533 bool success; |
569 bool success; |
534 int alarmSnoozeTime = value.toInt(&success); |
570 int alarmSnoozeTime = value.toInt(&success); |