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. |
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: |
341 mTimeFormatItem->setContentWidgetData("additionalText", mTimeFormatStringList[1]); |
369 mTimeFormatItem->setContentWidgetData("additionalText", mTimeFormatStringList[1]); |
342 } else { |
370 } else { |
343 mTimeFormatItem->setContentWidgetData("text", mTimeFormatStringList[1]); |
371 mTimeFormatItem->setContentWidgetData("text", mTimeFormatStringList[1]); |
344 mTimeFormatItem->setContentWidgetData("additionalText", mTimeFormatStringList[0]); |
372 mTimeFormatItem->setContentWidgetData("additionalText", mTimeFormatStringList[0]); |
345 } |
373 } |
|
374 mTimeFormatItem->setContentWidgetData("objectName", "timeFormat"); |
346 mForm->addConnection( |
375 mForm->addConnection( |
347 mTimeFormatItem, SIGNAL(clicked()), |
376 mTimeFormatItem, SIGNAL(clicked()), |
348 this, SLOT(handleTimeFormatChange())); |
377 this, SLOT(handleTimeFormatChange())); |
349 |
378 |
350 // Time separator item. |
379 // Time separator item. |
371 hbTrId("txt_clock_setlabel_date_format")); |
401 hbTrId("txt_clock_setlabel_date_format")); |
372 index = mSettingsUtility->dateFormat(mDateFormatStringList); |
402 index = mSettingsUtility->dateFormat(mDateFormatStringList); |
373 |
403 |
374 mDateFormatItem->setContentWidgetData("items", mDateFormatStringList); |
404 mDateFormatItem->setContentWidgetData("items", mDateFormatStringList); |
375 mDateFormatItem->setContentWidgetData("currentIndex",index); |
405 mDateFormatItem->setContentWidgetData("currentIndex",index); |
|
406 mDateFormatItem->setContentWidgetData("objectName", "dateFormat"); |
376 mForm->addConnection( |
407 mForm->addConnection( |
377 mDateFormatItem, SIGNAL(currentIndexChanged(QString)), |
408 mDateFormatItem, SIGNAL(currentIndexChanged(QString)), |
378 this, SLOT(handleDateFormatChange(QString))); |
409 this, SLOT(handleDateFormatChange(QString))); |
379 |
410 |
380 // Date separator. |
411 // Date separator. |
383 hbTrId("txt_clock_setlabel_date_separator")); |
414 hbTrId("txt_clock_setlabel_date_separator")); |
384 index = mSettingsUtility->dateSeparator(mDateSeparatorStringList); |
415 index = mSettingsUtility->dateSeparator(mDateSeparatorStringList); |
385 |
416 |
386 mDateSeparatorItem->setContentWidgetData("items", mDateSeparatorStringList); |
417 mDateSeparatorItem->setContentWidgetData("items", mDateSeparatorStringList); |
387 mDateSeparatorItem->setContentWidgetData("currentIndex",index); |
418 mDateSeparatorItem->setContentWidgetData("currentIndex",index); |
|
419 mDateSeparatorItem->setContentWidgetData("objectName", "dateSeparator"); |
388 mForm->addConnection( |
420 mForm->addConnection( |
389 mDateSeparatorItem, SIGNAL(currentIndexChanged(QString)), |
421 mDateSeparatorItem, SIGNAL(currentIndexChanged(QString)), |
390 this, SLOT(handleDateSeparatorChange(QString))); |
422 this, SLOT(handleDateSeparatorChange(QString))); |
391 |
423 |
392 // Workdays. |
424 // Workdays. |
393 HbDataFormModelItem *item = 0; |
425 HbDataFormModelItem *item = 0; |
394 // Create the weekday list based on start of week. |
426 // Create the weekday list based on start of week. |
395 QStringList weekdaysList; |
427 QStringList weekdaysList; |
|
428 QLocale qLocale; |
396 weekdaysList |
429 weekdaysList |
397 << hbTrId("txt_clk_setlabel_val_monday") |
430 << qLocale.dayName(1) |
398 << hbTrId("txt_clk_setlabel_val_tuesday") |
431 << qLocale.dayName(2) |
399 << hbTrId("txt_clk_setlabel_val_wednesday") |
432 << qLocale.dayName(3) |
400 << hbTrId("txt_clk_setlabel_val_thursday") |
433 << qLocale.dayName(4) |
401 << hbTrId("txt_clk_setlabel_val_friday") |
434 << qLocale.dayName(5) |
402 << hbTrId("txt_clk_setlabel_val_saturday") |
435 << qLocale.dayName(6) |
403 << hbTrId("txt_clk_setlabel_val_sunday"); |
436 << qLocale.dayName(7); |
404 |
437 |
405 HbDataFormModelItem::DataItemType workdaysItemType = |
438 HbDataFormModelItem::DataItemType workdaysItemType = |
406 static_cast<HbDataFormModelItem::DataItemType> |
439 static_cast<HbDataFormModelItem::DataItemType> |
407 (HbDataFormModelItem::CustomItemBase + 50); |
440 (HbDataFormModelItem::CustomItemBase + 50); |
408 item = new HbDataFormModelItem(workdaysItemType, |
441 item = new HbDataFormModelItem(workdaysItemType, |
409 hbTrId("txt_clock_setlabel_workdays")); |
442 hbTrId("txt_clock_setlabel_workdays")); |
410 mFormModel->appendDataFormItem(item); |
443 mFormModel->appendDataFormItem(item); |
|
444 item->setContentWidgetData("objectName", "workdays"); |
411 |
445 |
412 // Start of week item. |
446 // Start of week item. |
413 item = 0; |
447 item = 0; |
414 item = mFormModel->appendDataFormItem(HbDataFormModelItem::ComboBoxItem, |
448 item = mFormModel->appendDataFormItem(HbDataFormModelItem::ComboBoxItem, |
415 hbTrId("txt_clock_setlabel_week_starts_on")); |
449 hbTrId("txt_clock_setlabel_week_starts_on")); |
416 HbExtendedLocale::WeekDay startOfWeek = locale.startOfWeek(); |
450 HbExtendedLocale::WeekDay startOfWeek = locale.startOfWeek(); |
417 item->setContentWidgetData("items", weekdaysList); |
451 item->setContentWidgetData("items", weekdaysList); |
418 item->setContentWidgetData("currentIndex", startOfWeek); |
452 item->setContentWidgetData("currentIndex", startOfWeek); |
|
453 item->setContentWidgetData("objectName", "startOfWeek"); |
|
454 OstTraceFunctionExit0( CLOCKREGIONALSETTINGSVIEW_POPULATEFORMMODEL_EXIT ); |
419 } |
455 } |
420 |
456 |
421 /*! |
457 /*! |
422 Returns the weekday list ordered based on start of week. |
458 Returns the weekday list ordered based on start of week. |
423 */ |
459 */ |
424 |
460 |
425 QStringList ClockRegionalSettingsView::weekdayList() |
461 QStringList ClockRegionalSettingsView::weekdayList() |
426 { |
462 { |
|
463 OstTraceFunctionEntry0( CLOCKREGIONALSETTINGSVIEW_WEEKDAYLIST_ENTRY ); |
427 QStringList weekDays; |
464 QStringList weekDays; |
428 QStringList daysList; |
465 QStringList daysList; |
|
466 QLocale qLocale; |
429 daysList |
467 daysList |
430 << hbTrId("txt_clk_setlabel_val_monday") |
468 << qLocale.dayName(1) |
431 << hbTrId("txt_clk_setlabel_val_tuesday") |
469 << qLocale.dayName(2) |
432 << hbTrId("txt_clk_setlabel_val_wednesday") |
470 << qLocale.dayName(3) |
433 << hbTrId("txt_clk_setlabel_val_thursday") |
471 << qLocale.dayName(4) |
434 << hbTrId("txt_clk_setlabel_val_friday") |
472 << qLocale.dayName(5) |
435 << hbTrId("txt_clk_setlabel_val_saturday") |
473 << qLocale.dayName(6) |
436 << hbTrId("txt_clk_setlabel_val_sunday"); |
474 << qLocale.dayName(7); |
437 |
475 |
438 HbExtendedLocale::WeekDay startOfWeekIndex = |
476 HbExtendedLocale::WeekDay startOfWeekIndex = |
439 HbExtendedLocale::system().startOfWeek(); |
477 HbExtendedLocale::system().startOfWeek(); |
440 |
478 |
441 for (int i = 0, index = startOfWeekIndex; i < daysList.count(); ++i) { |
479 for (int i = 0, index = startOfWeekIndex; i < daysList.count(); ++i) { |
445 } else { |
483 } else { |
446 index++; |
484 index++; |
447 } |
485 } |
448 } |
486 } |
449 |
487 |
|
488 OstTraceFunctionExit0( CLOCKREGIONALSETTINGSVIEW_WEEKDAYLIST_EXIT ); |
450 return weekDays; |
489 return weekDays; |
451 } |
490 } |
452 |
491 |
453 |
492 |
454 /*! |
493 /*! |
455 update the start week on . |
494 update the start week on . |
456 */ |
495 */ |
457 |
496 |
458 void ClockRegionalSettingsView::updateWeekStartOn() |
497 void ClockRegionalSettingsView::updateWeekStartOn() |
459 { |
498 { |
460 if (mStartOfWeekItem != 0) |
499 OstTraceFunctionEntry0( CLOCKREGIONALSETTINGSVIEW_UPDATEWEEKSTARTON_ENTRY ); |
461 { |
500 if (mStartOfWeekItem != 0) |
462 HbExtendedLocale locale; |
501 { |
463 HbExtendedLocale::WeekDay weekdDayStart = locale.startOfWeek(); |
502 HbExtendedLocale locale; |
464 int currentDay = mStartOfWeekItem->currentIndex(); |
503 HbExtendedLocale::WeekDay weekdDayStart = locale.startOfWeek(); |
465 if(currentDay == weekdDayStart ) |
504 int currentDay = mStartOfWeekItem->currentIndex(); |
466 { |
505 if(currentDay == weekdDayStart ) |
467 return; |
506 { |
468 } |
507 OstTraceFunctionExit0( |
469 else |
508 CLOCKREGIONALSETTINGSVIEW_UPDATEWEEKSTARTON_EXIT ); |
470 { |
509 return; |
471 mStartOfWeekItem->setCurrentIndex(weekdDayStart); |
510 } |
472 updateWeekDays(); |
511 else |
473 } |
512 { |
474 } |
513 mStartOfWeekItem->setCurrentIndex(weekdDayStart); |
|
514 updateWeekDays(); |
|
515 } |
|
516 } |
|
517 OstTraceFunctionExit0( |
|
518 DUP1_CLOCKREGIONALSETTINGSVIEW_UPDATEWEEKSTARTON_EXIT ); |
475 } |
519 } |
476 |
520 |
477 /*! |
521 /*! |
478 update the week days . |
522 update the week days . |
479 */ |
523 */ |
480 void ClockRegionalSettingsView::updateWeekDays() |
524 void ClockRegionalSettingsView::updateWeekDays() |
481 { |
525 { |
482 QStringList weekdays = weekdayList(); |
526 OstTraceFunctionEntry0( CLOCKREGIONALSETTINGSVIEW_UPDATEWEEKDAYS_ENTRY ); |
483 QString workdays = mCustomPrototype->workdaysSetting(); |
527 QStringList weekdays = weekdayList(); |
484 QItemSelectionModel *model = 0; |
528 QString workdays = mCustomPrototype->workdaysSetting(); |
485 model = mWorkdaysItem->selectionModel(); |
529 QItemSelectionModel *model = 0; |
486 |
530 model = mWorkdaysItem->selectionModel(); |
487 for (int i = 0, index = workdays.size() - 1; |
531 |
488 i < mWorkdaysItem->count(); ++i, index--) |
532 for (int i = 0, index = workdays.size() - 1; |
489 { |
533 i < mWorkdaysItem->count(); ++i, index--) |
490 QString str = weekdays[i]; |
534 { |
491 mWorkdaysItem->item(i)->setText(str); |
535 QString str = weekdays[i]; |
492 |
536 mWorkdaysItem->item(i)->setText(str); |
493 QChar ch = workdays.at(index); |
537 |
494 if ( ch == QChar('0')) |
538 QChar ch = workdays.at(index); |
495 { |
539 if ( ch == QChar('0')) |
496 // Not a workday. |
540 { |
497 model->select( |
541 // Not a workday. |
498 model->model()->index(i,0), |
542 model->select( |
499 QItemSelectionModel::Deselect); |
543 model->model()->index(i,0), |
500 } |
544 QItemSelectionModel::Deselect); |
501 else |
545 } |
502 { |
546 else |
503 // Workday. |
547 { |
504 model->select( |
548 // Workday. |
505 model->model()->index(i,0), |
549 model->select( |
506 QItemSelectionModel::Select);} |
550 model->model()->index(i,0), |
507 } |
551 QItemSelectionModel::Select);} |
|
552 } |
|
553 OstTraceFunctionExit0( CLOCKREGIONALSETTINGSVIEW_UPDATEWEEKDAYS_EXIT ); |
508 } |
554 } |
509 // End of file --Don't remove this. |
555 // End of file --Don't remove this. |