29 #include <HbPushButton> |
29 #include <HbPushButton> |
30 #include <HbListWidget> |
30 #include <HbListWidget> |
31 #include <HbComboBox> |
31 #include <HbComboBox> |
32 #include <HbListWidgetItem> |
32 #include <HbListWidgetItem> |
33 #include <HbTranslator> |
33 #include <HbTranslator> |
|
34 #include <QLocale> |
34 |
35 |
35 // User includes |
36 // User includes |
36 #include "clockregionalsettingsview.h" |
37 #include "clockregionalsettingsview.h" |
37 #include "clocksettingsdocloader.h" |
38 #include "clocksettingsdocloader.h" |
38 #include "clocksettingsdefines.h" |
39 #include "clocksettingsdefines.h" |
39 #include "settingsdatatypes.h" |
40 #include "settingsdatatypes.h" |
40 #include "settingscustomitem.h" |
41 #include "settingscustomitem.h" |
|
42 #include "OstTraceDefinitions.h" |
|
43 #ifdef OST_TRACE_COMPILER_IN_USE |
|
44 #include "clockregionalsettingsviewTraces.h" |
|
45 #endif |
|
46 |
41 |
47 |
42 /*! |
48 /*! |
43 \class ClockRegionalSettingsView |
49 \class ClockRegionalSettingsView |
44 |
50 |
45 The view for regional setting items in clock applications settings. |
51 The view for regional setting items in clock applications settings. |
63 mTranslator = new HbTranslator("clocksettingsview"); |
70 mTranslator = new HbTranslator("clocksettingsview"); |
64 mTranslator->loadCommon(); |
71 mTranslator->loadCommon(); |
65 |
72 |
66 // Create the custom prototype. |
73 // Create the custom prototype. |
67 mCustomPrototype = new SettingsCustomItem(); |
74 mCustomPrototype = new SettingsCustomItem(); |
|
75 OstTraceFunctionExit0( CLOCKREGIONALSETTINGSVIEW_CLOCKREGIONALSETTINGSVIEW_EXIT ); |
68 } |
76 } |
69 |
77 |
70 /*! |
78 /*! |
71 Destructor. |
79 Destructor. |
72 */ |
80 */ |
73 ClockRegionalSettingsView::~ClockRegionalSettingsView() |
81 ClockRegionalSettingsView::~ClockRegionalSettingsView() |
74 { |
82 { |
|
83 OstTraceFunctionEntry0( DUP1_CLOCKREGIONALSETTINGSVIEW_CLOCKREGIONALSETTINGSVIEW_ENTRY ); |
75 if (mLoader) { |
84 if (mLoader) { |
76 delete mLoader; |
85 delete mLoader; |
77 mLoader = 0; |
86 mLoader = 0; |
78 } |
87 } |
79 |
88 |
87 // Remove the translator |
96 // Remove the translator |
88 if (mTranslator) { |
97 if (mTranslator) { |
89 delete mTranslator; |
98 delete mTranslator; |
90 mTranslator = 0; |
99 mTranslator = 0; |
91 } |
100 } |
|
101 OstTraceFunctionExit0( DUP1_CLOCKREGIONALSETTINGSVIEW_CLOCKREGIONALSETTINGSVIEW_EXIT ); |
92 } |
102 } |
93 |
103 |
94 /*! |
104 /*! |
95 Shows the regional settings view. |
105 Shows the regional settings view. |
96 */ |
106 */ |
97 void ClockRegionalSettingsView::showView() |
107 void ClockRegionalSettingsView::showView() |
98 { |
108 { |
|
109 OstTraceFunctionEntry0( CLOCKREGIONALSETTINGSVIEW_SHOWVIEW_ENTRY ); |
99 bool success; |
110 bool success; |
100 |
111 |
101 // Load the application xml. |
112 // Load the application xml. |
102 mLoader->load(CLOCK_REG_SETTINGS_VIEW_DOCML, &success); |
113 mLoader->load(CLOCK_REG_SETTINGS_VIEW_DOCML, &success); |
103 if (!success) { |
114 if (!success) { |
139 HbAction *backAction = new HbAction(Hb::BackNaviAction); |
150 HbAction *backAction = new HbAction(Hb::BackNaviAction); |
140 mView->setNavigationAction(backAction); |
151 mView->setNavigationAction(backAction); |
141 connect( |
152 connect( |
142 backAction, SIGNAL(triggered()), |
153 backAction, SIGNAL(triggered()), |
143 this, SLOT(handleBackAction())); |
154 this, SLOT(handleBackAction())); |
|
155 OstTraceFunctionExit0( CLOCKREGIONALSETTINGSVIEW_SHOWVIEW_EXIT ); |
144 } |
156 } |
145 |
157 |
146 /*! |
158 /*! |
147 The view is removed from main window and a deleteLater is called on `this'. |
159 The view is removed from main window and a deleteLater is called on `this'. |
148 */ |
160 */ |
149 void ClockRegionalSettingsView::handleBackAction() |
161 void ClockRegionalSettingsView::handleBackAction() |
150 { |
162 { |
|
163 OstTraceFunctionEntry0( CLOCKREGIONALSETTINGSVIEW_HANDLEBACKACTION_ENTRY ); |
151 HbExtendedLocale locale = HbExtendedLocale::system(); |
164 HbExtendedLocale locale = HbExtendedLocale::system(); |
152 HbExtendedLocale::WeekDay startOfWeekIndex = |
165 HbExtendedLocale::WeekDay startOfWeekIndex = |
153 HbExtendedLocale::system().startOfWeek(); |
166 HbExtendedLocale::system().startOfWeek(); |
154 // TODO: Save workdays settings. |
167 // Save workdays settings. |
155 QItemSelectionModel *model = 0; |
168 QItemSelectionModel *model = 0; |
156 model = mWorkdaysItem->selectionModel(); |
169 model = mWorkdaysItem->selectionModel(); |
157 QModelIndexList selectedModelIndex = model->selectedIndexes(); |
170 QModelIndexList selectedModelIndex = model->selectedIndexes(); |
158 int count = selectedModelIndex.count(); |
171 int count = selectedModelIndex.count(); |
159 QModelIndex index; |
172 QModelIndex index; |
183 |
196 |
184 HbMainWindow *window = hbInstance->allMainWindows().first(); |
197 HbMainWindow *window = hbInstance->allMainWindows().first(); |
185 // Cleanup. |
198 // Cleanup. |
186 window->removeView(mView); |
199 window->removeView(mView); |
187 deleteLater(); |
200 deleteLater(); |
|
201 OstTraceFunctionExit0( CLOCKREGIONALSETTINGSVIEW_HANDLEBACKACTION_EXIT ); |
188 } |
202 } |
189 |
203 |
190 /*! |
204 /*! |
191 Called when each of the form items are displayed. Using this slot, we |
205 Called when each of the form items are displayed. Using this slot, we |
192 connect to SIGNALS of the items that have been added to the form. |
206 connect to SIGNALS of the items that have been added to the form. |
193 |
207 |
194 \param index QModelIndex of the row that was just displayed. |
208 \param index QModelIndex of the row that was just displayed. |
195 */ |
209 */ |
196 void ClockRegionalSettingsView::handleItemDisplayed(const QModelIndex &index) |
210 void ClockRegionalSettingsView::handleItemDisplayed(const QModelIndex &index) |
197 { |
211 { |
|
212 OstTraceFunctionEntry0( CLOCKREGIONALSETTINGSVIEW_HANDLEITEMDISPLAYED_ENTRY ); |
198 if (!index.isValid()) { |
213 if (!index.isValid()) { |
|
214 OstTraceFunctionExit0( CLOCKREGIONALSETTINGSVIEW_HANDLEITEMDISPLAYED_EXIT ); |
199 return; |
215 return; |
200 } |
216 } |
201 |
217 |
202 HbDataFormViewItem *item = |
218 HbDataFormViewItem *item = |
203 static_cast<HbDataFormViewItem*>(mForm->itemByIndex(index)); |
219 static_cast<HbDataFormViewItem*>(mForm->itemByIndex(index)); |
225 mStartOfWeekItem = static_cast<HbComboBox *> (widget); |
241 mStartOfWeekItem = static_cast<HbComboBox *> (widget); |
226 break; |
242 break; |
227 default: |
243 default: |
228 break; |
244 break; |
229 } |
245 } |
|
246 OstTraceFunctionExit0( DUP1_CLOCKREGIONALSETTINGSVIEW_HANDLEITEMDISPLAYED_EXIT ); |
230 } |
247 } |
231 |
248 |
232 /*! |
249 /*! |
233 Called when the time format toggle item is clicked. Here we update the |
250 Called when the time format toggle item is clicked. Here we update the |
234 value in the locale. |
251 value in the locale. |
235 */ |
252 */ |
236 void ClockRegionalSettingsView::handleTimeFormatChange() |
253 void ClockRegionalSettingsView::handleTimeFormatChange() |
237 { |
254 { |
238 // mSettingsUtility->setTimeFormat(mTimeFormatItem->text()); |
255 OstTraceFunctionEntry0( CLOCKREGIONALSETTINGSVIEW_HANDLETIMEFORMATCHANGE_ENTRY ); |
239 mSettingsUtility->setTimeFormat( |
256 mSettingsUtility->setTimeFormat( |
240 mTimeFormatItem->contentWidgetData("text").toString()); |
257 mTimeFormatItem->contentWidgetData("text").toString()); |
|
258 OstTraceFunctionExit0( CLOCKREGIONALSETTINGSVIEW_HANDLETIMEFORMATCHANGE_EXIT ); |
241 } |
259 } |
242 |
260 |
243 /*! |
261 /*! |
244 Called when the time separator toggle item is clicked. Here we update the |
262 Called when the time separator toggle item is clicked. Here we update the |
245 value in the locale. |
263 value in the locale. |
246 */ |
264 */ |
247 void ClockRegionalSettingsView::handleTimeSeparatorChange() |
265 void ClockRegionalSettingsView::handleTimeSeparatorChange() |
248 { |
266 { |
249 // mSettingsUtility->setTimeSeparator(mTimeSeparatorItem->text()); |
267 OstTraceFunctionEntry0( CLOCKREGIONALSETTINGSVIEW_HANDLETIMESEPARATORCHANGE_ENTRY ); |
250 mSettingsUtility->setTimeSeparator( |
268 mSettingsUtility->setTimeSeparator( |
251 mTimeSeparatorItem->contentWidgetData("text").toString()); |
269 mTimeSeparatorItem->contentWidgetData("text").toString()); |
|
270 OstTraceFunctionExit0( CLOCKREGIONALSETTINGSVIEW_HANDLETIMESEPARATORCHANGE_EXIT ); |
252 } |
271 } |
253 |
272 |
254 /*! |
273 /*! |
255 */ |
274 */ |
256 void ClockRegionalSettingsView::handleDateFormatChange(QString text) |
275 void ClockRegionalSettingsView::handleDateFormatChange(QString text) |
257 { |
276 { |
|
277 OstTraceFunctionEntry0( CLOCKREGIONALSETTINGSVIEW_HANDLEDATEFORMATCHANGE_ENTRY ); |
258 mSettingsUtility->setDateFormat(text); |
278 mSettingsUtility->setDateFormat(text); |
|
279 OstTraceFunctionExit0( CLOCKREGIONALSETTINGSVIEW_HANDLEDATEFORMATCHANGE_EXIT ); |
259 } |
280 } |
260 |
281 |
261 /*! |
282 /*! |
262 Called when the date separator item is changed. Here we update the |
283 Called when the date separator item is changed. Here we update the |
263 value in the locale. |
284 value in the locale. |
264 */ |
285 */ |
265 void ClockRegionalSettingsView::handleDateSeparatorChange(QString text) |
286 void ClockRegionalSettingsView::handleDateSeparatorChange(QString text) |
266 { |
287 { |
|
288 OstTraceFunctionEntry0( CLOCKREGIONALSETTINGSVIEW_HANDLEDATESEPARATORCHANGE_ENTRY ); |
267 mSettingsUtility->setDateSeparator(text); |
289 mSettingsUtility->setDateSeparator(text); |
|
290 OstTraceFunctionExit0( CLOCKREGIONALSETTINGSVIEW_HANDLEDATESEPARATORCHANGE_EXIT ); |
268 } |
291 } |
269 |
292 |
270 /*! |
293 /*! |
271 This slot is called any item in the data form is changed. |
294 This slot is called any item in the data form is changed. |
272 */ |
295 */ |
273 void ClockRegionalSettingsView::handleDataChanged( |
296 void ClockRegionalSettingsView::handleDataChanged( |
274 const QModelIndex& topLeft, const QModelIndex& bottomRight) |
297 const QModelIndex& topLeft, const QModelIndex& bottomRight) |
275 { |
298 { |
|
299 OstTraceFunctionEntry0( CLOCKREGIONALSETTINGSVIEW_HANDLEDATACHANGED_ENTRY ); |
276 Q_UNUSED(bottomRight) |
300 Q_UNUSED(bottomRight) |
277 |
301 |
278 |
302 |
279 switch (topLeft.row()) { |
303 switch (topLeft.row()) { |
280 case 5: |
304 case 5: |
315 connect( |
341 connect( |
316 mFormModel, |
342 mFormModel, |
317 SIGNAL(dataChanged(const QModelIndex, const QModelIndex)), |
343 SIGNAL(dataChanged(const QModelIndex, const QModelIndex)), |
318 this, |
344 this, |
319 SLOT(handleDataChanged(const QModelIndex, const QModelIndex))); |
345 SLOT(handleDataChanged(const QModelIndex, const QModelIndex))); |
|
346 OstTraceFunctionExit0( CLOCKREGIONALSETTINGSVIEW_CREATEMODEL_EXIT ); |
320 } |
347 } |
321 |
348 |
322 /*! |
349 /*! |
323 Function in which we populate the form model. |
350 Function in which we populate the form model. |
324 */ |
351 */ |
325 void ClockRegionalSettingsView::populateFormModel() |
352 void ClockRegionalSettingsView::populateFormModel() |
326 { |
353 { |
|
354 OstTraceFunctionEntry0( CLOCKREGIONALSETTINGSVIEW_POPULATEFORMMODEL_ENTRY ); |
327 if (!mFormModel) { |
355 if (!mFormModel) { |
328 createModel(); |
356 createModel(); |
329 } |
357 } |
330 |
358 |
331 // Get the locale. |
359 // Get the locale. |
395 |
423 |
396 // Workdays. |
424 // Workdays. |
397 HbDataFormModelItem *item = 0; |
425 HbDataFormModelItem *item = 0; |
398 // Create the weekday list based on start of week. |
426 // Create the weekday list based on start of week. |
399 QStringList weekdaysList; |
427 QStringList weekdaysList; |
|
428 QLocale qLocale; |
400 weekdaysList |
429 weekdaysList |
401 << hbTrId("txt_clk_setlabel_val_monday") |
430 << qLocale.dayName(1) |
402 << hbTrId("txt_clk_setlabel_val_tuesday") |
431 << qLocale.dayName(2) |
403 << hbTrId("txt_clk_setlabel_val_wednesday") |
432 << qLocale.dayName(3) |
404 << hbTrId("txt_clk_setlabel_val_thursday") |
433 << qLocale.dayName(4) |
405 << hbTrId("txt_clk_setlabel_val_friday") |
434 << qLocale.dayName(5) |
406 << hbTrId("txt_clk_setlabel_val_saturday") |
435 << qLocale.dayName(6) |
407 << hbTrId("txt_clk_setlabel_val_sunday"); |
436 << qLocale.dayName(7); |
408 |
437 |
409 HbDataFormModelItem::DataItemType workdaysItemType = |
438 HbDataFormModelItem::DataItemType workdaysItemType = |
410 static_cast<HbDataFormModelItem::DataItemType> |
439 static_cast<HbDataFormModelItem::DataItemType> |
411 (HbDataFormModelItem::CustomItemBase + 50); |
440 (HbDataFormModelItem::CustomItemBase + 50); |
412 item = new HbDataFormModelItem(workdaysItemType, |
441 item = new HbDataFormModelItem(workdaysItemType, |
420 hbTrId("txt_clock_setlabel_week_starts_on")); |
449 hbTrId("txt_clock_setlabel_week_starts_on")); |
421 HbExtendedLocale::WeekDay startOfWeek = locale.startOfWeek(); |
450 HbExtendedLocale::WeekDay startOfWeek = locale.startOfWeek(); |
422 item->setContentWidgetData("items", weekdaysList); |
451 item->setContentWidgetData("items", weekdaysList); |
423 item->setContentWidgetData("currentIndex", startOfWeek); |
452 item->setContentWidgetData("currentIndex", startOfWeek); |
424 item->setContentWidgetData("objectName", "startOfWeek"); |
453 item->setContentWidgetData("objectName", "startOfWeek"); |
|
454 OstTraceFunctionExit0( CLOCKREGIONALSETTINGSVIEW_POPULATEFORMMODEL_EXIT ); |
425 } |
455 } |
426 |
456 |
427 /*! |
457 /*! |
428 Returns the weekday list ordered based on start of week. |
458 Returns the weekday list ordered based on start of week. |
429 */ |
459 */ |
430 |
460 |
431 QStringList ClockRegionalSettingsView::weekdayList() |
461 QStringList ClockRegionalSettingsView::weekdayList() |
432 { |
462 { |
|
463 OstTraceFunctionEntry0( CLOCKREGIONALSETTINGSVIEW_WEEKDAYLIST_ENTRY ); |
433 QStringList weekDays; |
464 QStringList weekDays; |
434 QStringList daysList; |
465 QStringList daysList; |
|
466 QLocale qLocale; |
435 daysList |
467 daysList |
436 << hbTrId("txt_clk_setlabel_val_monday") |
468 << qLocale.dayName(1) |
437 << hbTrId("txt_clk_setlabel_val_tuesday") |
469 << qLocale.dayName(2) |
438 << hbTrId("txt_clk_setlabel_val_wednesday") |
470 << qLocale.dayName(3) |
439 << hbTrId("txt_clk_setlabel_val_thursday") |
471 << qLocale.dayName(4) |
440 << hbTrId("txt_clk_setlabel_val_friday") |
472 << qLocale.dayName(5) |
441 << hbTrId("txt_clk_setlabel_val_saturday") |
473 << qLocale.dayName(6) |
442 << hbTrId("txt_clk_setlabel_val_sunday"); |
474 << qLocale.dayName(7); |
443 |
475 |
444 HbExtendedLocale::WeekDay startOfWeekIndex = |
476 HbExtendedLocale::WeekDay startOfWeekIndex = |
445 HbExtendedLocale::system().startOfWeek(); |
477 HbExtendedLocale::system().startOfWeek(); |
446 |
478 |
447 for (int i = 0, index = startOfWeekIndex; i < daysList.count(); ++i) { |
479 for (int i = 0, index = startOfWeekIndex; i < daysList.count(); ++i) { |
451 } else { |
483 } else { |
452 index++; |
484 index++; |
453 } |
485 } |
454 } |
486 } |
455 |
487 |
|
488 OstTraceFunctionExit0( CLOCKREGIONALSETTINGSVIEW_WEEKDAYLIST_EXIT ); |
456 return weekDays; |
489 return weekDays; |
457 } |
490 } |
458 |
491 |
459 |
492 |
460 /*! |
493 /*! |
461 update the start week on . |
494 update the start week on . |
462 */ |
495 */ |
463 |
496 |
464 void ClockRegionalSettingsView::updateWeekStartOn() |
497 void ClockRegionalSettingsView::updateWeekStartOn() |
465 { |
498 { |
466 if (mStartOfWeekItem != 0) |
499 OstTraceFunctionEntry0( CLOCKREGIONALSETTINGSVIEW_UPDATEWEEKSTARTON_ENTRY ); |
467 { |
500 if (mStartOfWeekItem != 0) |
468 HbExtendedLocale locale; |
501 { |
469 HbExtendedLocale::WeekDay weekdDayStart = locale.startOfWeek(); |
502 HbExtendedLocale locale; |
470 int currentDay = mStartOfWeekItem->currentIndex(); |
503 HbExtendedLocale::WeekDay weekdDayStart = locale.startOfWeek(); |
471 if(currentDay == weekdDayStart ) |
504 int currentDay = mStartOfWeekItem->currentIndex(); |
472 { |
505 if(currentDay == weekdDayStart ) |
473 return; |
506 { |
474 } |
507 OstTraceFunctionExit0( |
475 else |
508 CLOCKREGIONALSETTINGSVIEW_UPDATEWEEKSTARTON_EXIT ); |
476 { |
509 return; |
477 mStartOfWeekItem->setCurrentIndex(weekdDayStart); |
510 } |
478 updateWeekDays(); |
511 else |
479 } |
512 { |
480 } |
513 mStartOfWeekItem->setCurrentIndex(weekdDayStart); |
|
514 updateWeekDays(); |
|
515 } |
|
516 } |
|
517 OstTraceFunctionExit0( |
|
518 DUP1_CLOCKREGIONALSETTINGSVIEW_UPDATEWEEKSTARTON_EXIT ); |
481 } |
519 } |
482 |
520 |
483 /*! |
521 /*! |
484 update the week days . |
522 update the week days . |
485 */ |
523 */ |
486 void ClockRegionalSettingsView::updateWeekDays() |
524 void ClockRegionalSettingsView::updateWeekDays() |
487 { |
525 { |
488 QStringList weekdays = weekdayList(); |
526 OstTraceFunctionEntry0( CLOCKREGIONALSETTINGSVIEW_UPDATEWEEKDAYS_ENTRY ); |
489 QString workdays = mCustomPrototype->workdaysSetting(); |
527 QStringList weekdays = weekdayList(); |
490 QItemSelectionModel *model = 0; |
528 QString workdays = mCustomPrototype->workdaysSetting(); |
491 model = mWorkdaysItem->selectionModel(); |
529 QItemSelectionModel *model = 0; |
492 |
530 model = mWorkdaysItem->selectionModel(); |
493 for (int i = 0, index = workdays.size() - 1; |
531 |
494 i < mWorkdaysItem->count(); ++i, index--) |
532 for (int i = 0, index = workdays.size() - 1; |
495 { |
533 i < mWorkdaysItem->count(); ++i, index--) |
496 QString str = weekdays[i]; |
534 { |
497 mWorkdaysItem->item(i)->setText(str); |
535 QString str = weekdays[i]; |
498 |
536 mWorkdaysItem->item(i)->setText(str); |
499 QChar ch = workdays.at(index); |
537 |
500 if ( ch == QChar('0')) |
538 QChar ch = workdays.at(index); |
501 { |
539 if ( ch == QChar('0')) |
502 // Not a workday. |
540 { |
503 model->select( |
541 // Not a workday. |
504 model->model()->index(i,0), |
542 model->select( |
505 QItemSelectionModel::Deselect); |
543 model->model()->index(i,0), |
506 } |
544 QItemSelectionModel::Deselect); |
507 else |
545 } |
508 { |
546 else |
509 // Workday. |
547 { |
510 model->select( |
548 // Workday. |
511 model->model()->index(i,0), |
549 model->select( |
512 QItemSelectionModel::Select);} |
550 model->model()->index(i,0), |
513 } |
551 QItemSelectionModel::Select);} |
|
552 } |
|
553 OstTraceFunctionExit0( CLOCKREGIONALSETTINGSVIEW_UPDATEWEEKDAYS_EXIT ); |
514 } |
554 } |
515 // End of file --Don't remove this. |
555 // End of file --Don't remove this. |