34 #include "settingsdatatypes.h" |
34 #include "settingsdatatypes.h" |
35 #include "settingsutility.h" |
35 #include "settingsutility.h" |
36 #include "clockcityselectionlist.h" |
36 #include "clockcityselectionlist.h" |
37 #include "timezoneclient.h" |
37 #include "timezoneclient.h" |
38 #include "clockregionalsettingsview.h" |
38 #include "clockregionalsettingsview.h" |
|
39 #include "OstTraceDefinitions.h" |
|
40 #ifdef OST_TRACE_COMPILER_IN_USE |
|
41 #include "settingscustomitemTraces.h" |
|
42 #endif |
|
43 |
39 |
44 |
40 /*! |
45 /*! |
41 \class SettingsCustomItem |
46 \class SettingsCustomItem |
42 |
47 |
43 This class is responsible for creating custom items for clock settings. |
48 This class is responsible for creating custom items for clock settings. |
50 */ |
55 */ |
51 |
56 |
52 SettingsCustomItem::SettingsCustomItem(QGraphicsItem *parent) |
57 SettingsCustomItem::SettingsCustomItem(QGraphicsItem *parent) |
53 :HbDataFormViewItem(parent) |
58 :HbDataFormViewItem(parent) |
54 { |
59 { |
|
60 OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_SETTINGSCUSTOMITEM_ENTRY ); |
55 // Construct the settignsutility. |
61 // Construct the settignsutility. |
56 mSettingsUtility = new SettingsUtility(); |
62 mSettingsUtility = new SettingsUtility(); |
57 // Construct the timezone client. |
63 // Construct the timezone client. |
58 mTimezoneClient = TimezoneClient::getInstance(); |
64 mTimezoneClient = TimezoneClient::getInstance(); |
|
65 OstTraceFunctionExit0( SETTINGSCUSTOMITEM_SETTINGSCUSTOMITEM_EXIT ); |
59 } |
66 } |
60 |
67 |
61 /*! |
68 /*! |
62 Destructor. |
69 Destructor. |
63 */ |
70 */ |
64 SettingsCustomItem::~SettingsCustomItem() |
71 SettingsCustomItem::~SettingsCustomItem() |
65 { |
72 { |
66 // Nothing yet. |
73 OstTraceFunctionEntry0( DUP1_SETTINGSCUSTOMITEM_SETTINGSCUSTOMITEM_ENTRY ); |
|
74 // Nothing yet. |
|
75 OstTraceFunctionExit0( DUP1_SETTINGSCUSTOMITEM_SETTINGSCUSTOMITEM_EXIT ); |
67 } |
76 } |
68 |
77 |
69 /*! |
78 /*! |
70 \reimp |
79 \reimp |
71 Creates SettingsCustomItem. |
80 Creates SettingsCustomItem. |
72 */ |
81 */ |
73 HbAbstractViewItem* SettingsCustomItem::createItem() |
82 HbAbstractViewItem* SettingsCustomItem::createItem() |
74 { |
83 { |
|
84 OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_CREATEITEM_ENTRY ); |
75 return new SettingsCustomItem(*this); |
85 return new SettingsCustomItem(*this); |
76 } |
86 } |
77 |
87 |
78 /*! |
88 /*! |
79 |
89 |
80 \sa |
90 \sa |
81 */ |
91 */ |
82 bool SettingsCustomItem::canSetModelIndex(const QModelIndex &index) const |
92 bool SettingsCustomItem::canSetModelIndex(const QModelIndex &index) const |
83 { |
93 { |
|
94 OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_CANSETMODELINDEX_ENTRY ); |
84 HbDataFormModelItem::DataItemType itemType = |
95 HbDataFormModelItem::DataItemType itemType = |
85 static_cast<HbDataFormModelItem::DataItemType>( |
96 static_cast<HbDataFormModelItem::DataItemType>( |
86 index.data(HbDataFormModelItem::ItemTypeRole).toInt()); |
97 index.data(HbDataFormModelItem::ItemTypeRole).toInt()); |
87 |
98 |
88 if(itemType >= HbDataFormModelItem::CustomItemBase && |
99 if(itemType >= HbDataFormModelItem::CustomItemBase && |
89 itemType <= (HbDataFormModelItem::CustomItemBase + 50)) { |
100 itemType <= (HbDataFormModelItem::CustomItemBase + 50)) { |
|
101 OstTraceFunctionExit0( SETTINGSCUSTOMITEM_CANSETMODELINDEX_EXIT ); |
90 return true; |
102 return true; |
91 } else { |
103 } else { |
|
104 OstTraceFunctionExit0( DUP1_SETTINGSCUSTOMITEM_CANSETMODELINDEX_EXIT ); |
92 return false; |
105 return false; |
93 } |
106 } |
94 |
107 |
95 } |
108 } |
96 |
109 |
97 void SettingsCustomItem::restore() |
110 void SettingsCustomItem::restore() |
98 { |
111 { |
|
112 OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_RESTORE_ENTRY ); |
99 HbDataFormModelItem::DataItemType itemType = |
113 HbDataFormModelItem::DataItemType itemType = |
100 static_cast<HbDataFormModelItem::DataItemType>( |
114 static_cast<HbDataFormModelItem::DataItemType>( |
101 modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt()); |
115 modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt()); |
102 |
116 |
103 HbDataFormModel* model = |
117 HbDataFormModel* model = |
145 break; |
159 break; |
146 } |
160 } |
147 default: |
161 default: |
148 break; |
162 break; |
149 } |
163 } |
|
164 OstTraceFunctionExit0( SETTINGSCUSTOMITEM_RESTORE_EXIT ); |
150 } |
165 } |
151 |
166 |
152 void SettingsCustomItem::setWeekdaysList(QStringList list) |
167 void SettingsCustomItem::setWeekdaysList(QStringList list) |
153 { |
168 { |
|
169 OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_SETWEEKDAYSLIST_ENTRY ); |
154 mWeekdaysList = list; |
170 mWeekdaysList = list; |
|
171 OstTraceFunctionExit0( SETTINGSCUSTOMITEM_SETWEEKDAYSLIST_EXIT ); |
155 } |
172 } |
156 |
173 |
157 /*! |
174 /*! |
158 \reimp |
175 \reimp |
159 Creates custom data form item. |
176 Creates custom data form item. |
160 */ |
177 */ |
161 HbWidget* SettingsCustomItem::createCustomWidget() |
178 HbWidget* SettingsCustomItem::createCustomWidget() |
162 { |
179 { |
|
180 OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_CREATECUSTOMWIDGET_ENTRY ); |
163 HbDataFormModelItem::DataItemType itemType = |
181 HbDataFormModelItem::DataItemType itemType = |
164 static_cast<HbDataFormModelItem::DataItemType>(modelIndex() |
182 static_cast<HbDataFormModelItem::DataItemType>(modelIndex() |
165 .data(HbDataFormModelItem::ItemTypeRole).toInt()); |
183 .data(HbDataFormModelItem::ItemTypeRole).toInt()); |
166 |
184 |
167 switch (itemType) { |
185 switch (itemType) { |
169 { |
187 { |
170 mTimeWidget = new HbPushButton(this); |
188 mTimeWidget = new HbPushButton(this); |
171 connect( |
189 connect( |
172 mTimeWidget, SIGNAL(clicked()), |
190 mTimeWidget, SIGNAL(clicked()), |
173 this, SLOT(launchTimePicker())); |
191 this, SLOT(launchTimePicker())); |
|
192 OstTraceFunctionExit0( SETTINGSCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
174 return mTimeWidget; |
193 return mTimeWidget; |
175 } |
194 } |
176 |
195 |
177 case (DateItemOffset + HbDataFormModelItem::CustomItemBase): |
196 case (DateItemOffset + HbDataFormModelItem::CustomItemBase): |
178 { |
197 { |
179 mDateWidget = new HbPushButton(this); |
198 mDateWidget = new HbPushButton(this); |
180 connect( |
199 connect( |
181 mDateWidget, SIGNAL(clicked()), |
200 mDateWidget, SIGNAL(clicked()), |
182 this, SLOT(launchDatePicker())); |
201 this, SLOT(launchDatePicker())); |
|
202 OstTraceFunctionExit0( DUP1_SETTINGSCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
183 return mDateWidget; |
203 return mDateWidget; |
184 } |
204 } |
185 |
205 |
186 case (PlaceItemOffset + HbDataFormModelItem::CustomItemBase): |
206 case (PlaceItemOffset + HbDataFormModelItem::CustomItemBase): |
187 { |
207 { |
188 mPlaceWidget = new HbPushButton(this); |
208 mPlaceWidget = new HbPushButton(this); |
189 connect( |
209 connect( |
190 mPlaceWidget, SIGNAL(clicked()), |
210 mPlaceWidget, SIGNAL(clicked()), |
191 this, SLOT(launchCitySelectionList())); |
211 this, SLOT(launchCitySelectionList())); |
|
212 OstTraceFunctionExit0( DUP2_SETTINGSCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
192 return mPlaceWidget; |
213 return mPlaceWidget; |
193 } |
214 } |
194 |
215 |
195 case (RegionalItemOffset + HbDataFormModelItem::CustomItemBase): |
216 case (RegionalItemOffset + HbDataFormModelItem::CustomItemBase): |
196 { |
217 { |
197 mRegSettingsWidget = new HbPushButton(this); |
218 mRegSettingsWidget = new HbPushButton(this); |
198 connect( |
219 connect( |
199 mRegSettingsWidget, SIGNAL(clicked()), |
220 mRegSettingsWidget, SIGNAL(clicked()), |
200 this, SLOT(launchRegSettingsView())); |
221 this, SLOT(launchRegSettingsView())); |
|
222 OstTraceFunctionExit0( DUP3_SETTINGSCUSTOMITEM_CREATECUSTOMWIDGET_EXIT ); |
201 return mRegSettingsWidget; |
223 return mRegSettingsWidget; |
202 } |
224 } |
203 |
225 |
204 case (50 + HbDataFormModelItem::CustomItemBase): |
226 case (50 + HbDataFormModelItem::CustomItemBase): |
205 { |
227 { |
277 |
301 |
278 mTimePickerDialog->addAction(mOkAction); |
302 mTimePickerDialog->addAction(mOkAction); |
279 mTimePickerDialog->addAction(mCancelAction); |
303 mTimePickerDialog->addAction(mCancelAction); |
280 |
304 |
281 mTimePickerDialog->open(this, SLOT(selectedAction(HbAction*))); |
305 mTimePickerDialog->open(this, SLOT(selectedAction(HbAction*))); |
|
306 OstTraceFunctionExit0( SETTINGSCUSTOMITEM_LAUNCHTIMEPICKER_EXIT ); |
282 } |
307 } |
283 |
308 |
284 /*! |
309 /*! |
285 Handles the ok action of time/date picker dialog. |
310 Handles the ok action of time/date picker dialog. |
286 */ |
311 */ |
287 void SettingsCustomItem::handleOkAction() |
312 void SettingsCustomItem::handleOkAction() |
288 { |
313 { |
|
314 OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_HANDLEOKACTION_ENTRY ); |
289 if (mTimePickerDialog) { |
315 if (mTimePickerDialog) { |
290 // Get the time from the time picker. |
316 // Get the time from the time picker. |
291 QTime newTime = static_cast<HbDateTimePicker *> ( |
317 QTime newTime = static_cast<HbDateTimePicker *> ( |
292 mTimePickerDialog->contentWidget())->time(); |
318 mTimePickerDialog->contentWidget())->time(); |
293 |
319 |
315 // Update the system date. |
341 // Update the system date. |
316 mTimezoneClient->setDateTime( |
342 mTimezoneClient->setDateTime( |
317 QDateTime(newDate, QTime::currentTime())); |
343 QDateTime(newDate, QTime::currentTime())); |
318 } |
344 } |
319 } |
345 } |
|
346 OstTraceFunctionExit0( SETTINGSCUSTOMITEM_HANDLEOKACTION_EXIT ); |
320 } |
347 } |
321 |
348 |
322 /*! |
349 /*! |
323 Launches the date picker dialog. |
350 Launches the date picker dialog. |
324 */ |
351 */ |
325 void SettingsCustomItem::launchDatePicker() |
352 void SettingsCustomItem::launchDatePicker() |
326 { |
353 { |
|
354 OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_LAUNCHDATEPICKER_ENTRY ); |
327 if (mDatePickerDialog) { |
355 if (mDatePickerDialog) { |
328 delete mDatePickerDialog; |
356 delete mDatePickerDialog; |
329 } |
357 } |
330 |
358 |
331 // Create the dialog. |
359 // Create the dialog. |
355 |
383 |
356 mDatePickerDialog->addAction(mOkAction); |
384 mDatePickerDialog->addAction(mOkAction); |
357 mDatePickerDialog->addAction(mCancelAction); |
385 mDatePickerDialog->addAction(mCancelAction); |
358 |
386 |
359 mDatePickerDialog->open(this, SLOT(selectedAction(HbAction*))); |
387 mDatePickerDialog->open(this, SLOT(selectedAction(HbAction*))); |
|
388 OstTraceFunctionExit0( SETTINGSCUSTOMITEM_LAUNCHDATEPICKER_EXIT ); |
360 } |
389 } |
361 |
390 |
362 /*! |
391 /*! |
363 Launches cityselectionlist for timezone selection. |
392 Launches cityselectionlist for timezone selection. |
364 */ |
393 */ |
365 void SettingsCustomItem::launchCitySelectionList() |
394 void SettingsCustomItem::launchCitySelectionList() |
366 { |
395 { |
|
396 OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_LAUNCHCITYSELECTIONLIST_ENTRY ); |
367 mCitySelectionList = new ClockCitySelectionList(mTimezoneClient, this); |
397 mCitySelectionList = new ClockCitySelectionList(mTimezoneClient, this); |
368 connect( |
398 connect( |
369 mCitySelectionList, SIGNAL(citySelected(LocationInfo)), |
399 mCitySelectionList, SIGNAL(citySelected(LocationInfo)), |
370 this, SLOT(updatePlaceItem(LocationInfo))); |
400 this, SLOT(updatePlaceItem(LocationInfo))); |
371 |
401 |
372 mCitySelectionList->showCityList(); |
402 mCitySelectionList->showCityList(); |
|
403 OstTraceFunctionExit0( SETTINGSCUSTOMITEM_LAUNCHCITYSELECTIONLIST_EXIT ); |
373 } |
404 } |
374 |
405 |
375 /*! |
406 /*! |
376 Launches cityselectionlist for timezone selection. |
407 Launches cityselectionlist for timezone selection. |
377 |
408 |
378 \param info Will contain the location info selected by the user. |
409 \param info Will contain the location info selected by the user. |
379 */ |
410 */ |
380 void SettingsCustomItem::updatePlaceItem(LocationInfo info) |
411 void SettingsCustomItem::updatePlaceItem(LocationInfo info) |
381 { |
412 { |
|
413 OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_UPDATEPLACEITEM_ENTRY ); |
382 if (-1 != info.timezoneId) { |
414 if (-1 != info.timezoneId) { |
383 mTimezoneClient->setAsCurrentLocationL(info); |
415 mTimezoneClient->setAsCurrentLocationL(info); |
384 } |
416 } |
|
417 OstTraceFunctionExit0( SETTINGSCUSTOMITEM_UPDATEPLACEITEM_EXIT ); |
385 } |
418 } |
386 |
419 |
387 /*! |
420 /*! |
388 Launches the regional settings view. |
421 Launches the regional settings view. |
389 */ |
422 */ |
390 void SettingsCustomItem::launchRegSettingsView() |
423 void SettingsCustomItem::launchRegSettingsView() |
391 { |
424 { |
|
425 OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_LAUNCHREGSETTINGSVIEW_ENTRY ); |
392 ClockRegionalSettingsView *view = |
426 ClockRegionalSettingsView *view = |
393 new ClockRegionalSettingsView(); |
427 new ClockRegionalSettingsView(); |
394 connect(mTimezoneClient, SIGNAL(timechanged()), |
428 connect(mTimezoneClient, SIGNAL(timechanged()), |
395 view, SLOT(updateWeekStartOn())); |
429 view, SLOT(updateWeekStartOn())); |
396 view->showView(); |
430 view->showView(); |
397 |
431 |
|
432 OstTraceFunctionExit0( SETTINGSCUSTOMITEM_LAUNCHREGSETTINGSVIEW_EXIT ); |
398 } |
433 } |
399 |
434 |
400 /*! |
435 /*! |
401 Slot to handle the selected action. |
436 Slot to handle the selected action. |
402 */ |
437 */ |
403 void SettingsCustomItem::selectedAction(HbAction *action) |
438 void SettingsCustomItem::selectedAction(HbAction *action) |
404 { |
439 { |
|
440 OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_SELECTEDACTION_ENTRY ); |
405 if (action==mOkAction) { |
441 if (action==mOkAction) { |
406 handleOkAction(); |
442 handleOkAction(); |
407 } |
443 } |
|
444 OstTraceFunctionExit0( SETTINGSCUSTOMITEM_SELECTEDACTION_EXIT ); |
408 } |
445 } |
409 |
446 |
410 /*! |
447 /*! |
411 Returns the workdays setting string based on start of week setting. |
448 Returns the workdays setting string based on start of week setting. |
412 */ |
449 */ |
413 QString SettingsCustomItem::workdaysSetting() |
450 QString SettingsCustomItem::workdaysSetting() |
414 { |
451 { |
|
452 OstTraceFunctionEntry0( SETTINGSCUSTOMITEM_WORKDAYSSETTING_ENTRY ); |
415 HbExtendedLocale locale = HbExtendedLocale::system(); |
453 HbExtendedLocale locale = HbExtendedLocale::system(); |
416 // 0(Sun)0(sat)1(Fri)1(Thu)1(Wed)1(Tue)1(Mon) |
454 // 0(Sun)0(sat)1(Fri)1(Thu)1(Wed)1(Tue)1(Mon) |
417 QString workdaysString = locale.workDays(); |
455 QString workdaysString = locale.workDays(); |
418 QString workdays = workdaysString; |
456 QString workdays = workdaysString; |
419 HbExtendedLocale::WeekDay startOfWeekIndex = |
457 HbExtendedLocale::WeekDay startOfWeekIndex = |