19 // System includes |
19 // System includes |
20 #include <HbView> |
20 #include <HbView> |
21 #include <HbAction> |
21 #include <HbAction> |
22 #include <HbDataForm> |
22 #include <HbDataForm> |
23 #include <HbDataFormModel> |
23 #include <HbDataFormModel> |
|
24 #include <HbExtendedLocale> |
24 #include <HbDataFormModelItem> |
25 #include <HbDataFormModelItem> |
25 #include <HbDataFormViewItem> |
26 #include <HbDataFormViewItem> |
26 #include <HbMainWindow> |
27 #include <HbMainWindow> |
27 #include <HbInstance> |
28 #include <HbInstance> |
28 #include <HbPushButton> |
29 #include <HbPushButton> |
29 #include <HbExtendedLocale> |
|
30 #include <HbListWidget> |
30 #include <HbListWidget> |
31 #include <HbComboBox> |
31 #include <HbComboBox> |
32 #include <HbListWidgetItem> |
32 #include <HbListWidgetItem> |
33 #include <HbApplication> |
33 #include <HbApplication> |
34 #include <QTranslator> |
34 #include <QTranslator> |
47 */ |
47 */ |
48 |
48 |
49 /*! |
49 /*! |
50 Default constructor. |
50 Default constructor. |
51 */ |
51 */ |
52 ClockRegionalSettingsView::ClockRegionalSettingsView( |
52 ClockRegionalSettingsView::ClockRegionalSettingsView(QObject *parent) |
53 SettingsUtility &utility, QObject *parent) |
|
54 :QObject(parent), |
53 :QObject(parent), |
55 mView(0), |
54 mView(0), |
56 mBackAction(0), |
55 mLoader(0) |
57 mLoader(0), |
|
58 mSettingsUtility(utility) |
|
59 { |
56 { |
60 // Construct the document loader. |
57 // Construct the document loader. |
61 mLoader = new ClockSettingsDocLoader; |
58 mLoader = new ClockSettingsDocLoader; |
|
59 |
|
60 // Construct the settignsutility. |
|
61 mSettingsUtility = new SettingsUtility(); |
62 |
62 |
63 // Load the translation file and install the editor specific translator |
63 // Load the translation file and install the editor specific translator |
64 mTranslator = new QTranslator; |
64 mTranslator = new QTranslator; |
65 //QString lang = QLocale::system().name(); |
65 //QString lang = QLocale::system().name(); |
66 //QString path = "Z:/resource/qt/translations/"; |
66 //QString path = "Z:/resource/qt/translations/"; |
132 HbMainWindow *window = hbInstance->allMainWindows().first(); |
140 HbMainWindow *window = hbInstance->allMainWindows().first(); |
133 window->addView(mView); |
141 window->addView(mView); |
134 window->setCurrentView(mView); |
142 window->setCurrentView(mView); |
135 |
143 |
136 // Add the back softkey. |
144 // Add the back softkey. |
137 mBackAction = new HbAction(Hb::BackNaviAction); |
145 HbAction *backAction = new HbAction(Hb::BackNaviAction); |
138 mView->setNavigationAction(mBackAction); |
146 mView->setNavigationAction(backAction); |
139 connect( |
147 connect( |
140 mBackAction, SIGNAL(triggered()), |
148 backAction, SIGNAL(triggered()), |
141 this, SLOT(handleBackAction())); |
149 this, SLOT(handleBackAction())); |
142 } |
150 } |
143 |
151 |
144 /*! |
152 /*! |
145 The view is removed from main window and a deleteLater is called on `this'. |
153 The view is removed from main window and a deleteLater is called on `this'. |
231 Called when the time format toggle item is clicked. Here we update the |
239 Called when the time format toggle item is clicked. Here we update the |
232 value in the locale. |
240 value in the locale. |
233 */ |
241 */ |
234 void ClockRegionalSettingsView::handleTimeFormatChange() |
242 void ClockRegionalSettingsView::handleTimeFormatChange() |
235 { |
243 { |
236 // mSettingsUtility.setTimeFormat(mTimeFormatItem->text()); |
244 // mSettingsUtility->setTimeFormat(mTimeFormatItem->text()); |
237 mSettingsUtility.setTimeFormat( |
245 mSettingsUtility->setTimeFormat( |
238 mTimeFormatItem->contentWidgetData("text").toString()); |
246 mTimeFormatItem->contentWidgetData("text").toString()); |
239 } |
247 } |
240 |
248 |
241 /*! |
249 /*! |
242 Called when the time separator toggle item is clicked. Here we update the |
250 Called when the time separator toggle item is clicked. Here we update the |
243 value in the locale. |
251 value in the locale. |
244 */ |
252 */ |
245 void ClockRegionalSettingsView::handleTimeSeparatorChange() |
253 void ClockRegionalSettingsView::handleTimeSeparatorChange() |
246 { |
254 { |
247 // mSettingsUtility.setTimeSeparator(mTimeSeparatorItem->text()); |
255 // mSettingsUtility->setTimeSeparator(mTimeSeparatorItem->text()); |
248 mSettingsUtility.setTimeSeparator( |
256 mSettingsUtility->setTimeSeparator( |
249 mTimeSeparatorItem->contentWidgetData("text").toString()); |
257 mTimeSeparatorItem->contentWidgetData("text").toString()); |
250 } |
258 } |
251 |
259 |
252 /*! |
260 /*! |
253 */ |
261 */ |
254 void ClockRegionalSettingsView::handleDateFormatChange(QString text) |
262 void ClockRegionalSettingsView::handleDateFormatChange(QString text) |
255 { |
263 { |
256 mSettingsUtility.setDateFormat(text); |
264 mSettingsUtility->setDateFormat(text); |
257 } |
265 } |
258 |
266 |
259 /*! |
267 /*! |
260 Called when the date separator item is changed. Here we update the |
268 Called when the date separator item is changed. Here we update the |
261 value in the locale. |
269 value in the locale. |
262 */ |
270 */ |
263 void ClockRegionalSettingsView::handleDateSeparatorChange(QString text) |
271 void ClockRegionalSettingsView::handleDateSeparatorChange(QString text) |
264 { |
272 { |
265 mSettingsUtility.setDateSeparator(text); |
273 mSettingsUtility->setDateSeparator(text); |
266 } |
274 } |
267 |
275 |
268 /*! |
276 /*! |
269 This slot is called any item in the data form is changed. |
277 This slot is called any item in the data form is changed. |
270 */ |
278 */ |
276 |
284 |
277 switch (topLeft.row()) { |
285 switch (topLeft.row()) { |
278 case 5: |
286 case 5: |
279 { |
287 { |
280 // The Start of week item. |
288 // The Start of week item. |
281 if (mStartOfWeekItem != 0) { |
289 if (mStartOfWeekItem != 0) |
|
290 { |
282 int index = mStartOfWeekItem->currentIndex(); |
291 int index = mStartOfWeekItem->currentIndex(); |
283 mSettingsUtility.setStartOfWeek(index); |
292 mSettingsUtility->setStartOfWeek(index); |
284 |
293 //update the week days |
285 QStringList weekdays = weekdayList(); |
294 updateWeekDays(); |
286 QString workdays = mCustomPrototype->workdaysSetting(); |
295 } |
287 QItemSelectionModel *model = 0; |
|
288 model = mWorkdaysItem->selectionModel(); |
|
289 |
|
290 for (int i = 0, index = workdays.size() - 1; |
|
291 i < mWorkdaysItem->count(); ++i, index--) { |
|
292 QString str = weekdays[i]; |
|
293 mWorkdaysItem->item(i)->setText(str); |
|
294 |
|
295 QChar ch = workdays.at(index); |
|
296 if ( ch == QChar('0')) { |
|
297 // Not a workday. |
|
298 model->select( |
|
299 model->model()->index(i,0), |
|
300 QItemSelectionModel::Deselect); |
|
301 } else { |
|
302 // Workday. |
|
303 model->select( |
|
304 model->model()->index(i,0), |
|
305 QItemSelectionModel::Select); |
|
306 } |
|
307 } |
|
308 } |
|
309 } |
296 } |
310 break; |
297 break; |
311 |
298 |
312 default: |
299 default: |
313 break; |
300 break; |
346 if (!mFormModel) { |
333 if (!mFormModel) { |
347 createModel(); |
334 createModel(); |
348 } |
335 } |
349 |
336 |
350 // Get the locale. |
337 // Get the locale. |
351 HbExtendedLocale locale = HbExtendedLocale::system(); |
338 HbExtendedLocale locale = HbExtendedLocale::system(); |
352 |
339 |
353 // Time format item. |
340 // Time format item. |
354 mTimeFormatItem = mFormModel->appendDataFormItem( |
341 mTimeFormatItem = mFormModel->appendDataFormItem( |
355 HbDataFormModelItem::ToggleValueItem, |
342 HbDataFormModelItem::ToggleValueItem, |
356 hbTrId("txt_clock_setlabel_time_format")); |
343 hbTrId("txt_clock_setlabel_time_format")); |
357 int index = mSettingsUtility.timeFormat(mTimeFormatStringList); |
344 int index = mSettingsUtility->timeFormat(mTimeFormatStringList); |
358 if (0 == index) { |
345 if (0 == index) { |
359 mTimeFormatItem->setContentWidgetData("text", mTimeFormatStringList[0]); |
346 mTimeFormatItem->setContentWidgetData("text", mTimeFormatStringList[0]); |
360 mTimeFormatItem->setContentWidgetData("additionalText", mTimeFormatStringList[1]); |
347 mTimeFormatItem->setContentWidgetData("additionalText", mTimeFormatStringList[1]); |
361 } else { |
348 } else { |
362 mTimeFormatItem->setContentWidgetData("text", mTimeFormatStringList[1]); |
349 mTimeFormatItem->setContentWidgetData("text", mTimeFormatStringList[1]); |
368 |
355 |
369 // Time separator item. |
356 // Time separator item. |
370 mTimeSeparatorItem = mFormModel->appendDataFormItem( |
357 mTimeSeparatorItem = mFormModel->appendDataFormItem( |
371 HbDataFormModelItem::ToggleValueItem, |
358 HbDataFormModelItem::ToggleValueItem, |
372 hbTrId("txt_clock_setlabel_time_separator")); |
359 hbTrId("txt_clock_setlabel_time_separator")); |
373 index = mSettingsUtility.timeSeparator(mTimeSeparatorStringList); |
360 index = mSettingsUtility->timeSeparator(mTimeSeparatorStringList); |
374 if (0 == index) { |
361 if (0 == index) { |
375 mTimeSeparatorItem->setContentWidgetData("text", mTimeSeparatorStringList[0]); |
362 mTimeSeparatorItem->setContentWidgetData("text", mTimeSeparatorStringList[0]); |
376 mTimeSeparatorItem->setContentWidgetData( |
363 mTimeSeparatorItem->setContentWidgetData( |
377 "additionalText", mTimeSeparatorStringList[1]); |
364 "additionalText", mTimeSeparatorStringList[1]); |
378 } else { |
365 } else { |
386 |
373 |
387 // Date format. |
374 // Date format. |
388 mDateFormatItem = mFormModel->appendDataFormItem( |
375 mDateFormatItem = mFormModel->appendDataFormItem( |
389 HbDataFormModelItem::ComboBoxItem, |
376 HbDataFormModelItem::ComboBoxItem, |
390 hbTrId("txt_clock_setlabel_date_format")); |
377 hbTrId("txt_clock_setlabel_date_format")); |
391 index = mSettingsUtility.dateFormat(mDateFormatStringList); |
378 index = mSettingsUtility->dateFormat(mDateFormatStringList); |
392 |
379 |
393 mDateFormatItem->setContentWidgetData("items", mDateFormatStringList); |
380 mDateFormatItem->setContentWidgetData("items", mDateFormatStringList); |
394 mDateFormatItem->setContentWidgetData("currentIndex",index); |
381 mDateFormatItem->setContentWidgetData("currentIndex",index); |
395 mForm->addConnection( |
382 mForm->addConnection( |
396 mDateFormatItem, SIGNAL(currentIndexChanged(QString)), |
383 mDateFormatItem, SIGNAL(currentIndexChanged(QString)), |
398 |
385 |
399 // Date separator. |
386 // Date separator. |
400 mDateSeparatorItem = mFormModel->appendDataFormItem( |
387 mDateSeparatorItem = mFormModel->appendDataFormItem( |
401 HbDataFormModelItem::ComboBoxItem, |
388 HbDataFormModelItem::ComboBoxItem, |
402 hbTrId("txt_clock_setlabel_date_separator")); |
389 hbTrId("txt_clock_setlabel_date_separator")); |
403 index = mSettingsUtility.dateSeparator(mDateSeparatorStringList); |
390 index = mSettingsUtility->dateSeparator(mDateSeparatorStringList); |
404 |
391 |
405 mDateSeparatorItem->setContentWidgetData("items", mDateSeparatorStringList); |
392 mDateSeparatorItem->setContentWidgetData("items", mDateSeparatorStringList); |
406 mDateSeparatorItem->setContentWidgetData("currentIndex",index); |
393 mDateSeparatorItem->setContentWidgetData("currentIndex",index); |
407 mForm->addConnection( |
394 mForm->addConnection( |
408 mDateSeparatorItem, SIGNAL(currentIndexChanged(QString)), |
395 mDateSeparatorItem, SIGNAL(currentIndexChanged(QString)), |
467 } |
454 } |
468 |
455 |
469 return weekDays; |
456 return weekDays; |
470 } |
457 } |
471 |
458 |
|
459 |
|
460 /*! |
|
461 update the start week on . |
|
462 */ |
|
463 |
|
464 void ClockRegionalSettingsView::updateWeekStartOn() |
|
465 { |
|
466 if (mStartOfWeekItem != 0) |
|
467 { |
|
468 HbExtendedLocale locale; |
|
469 HbExtendedLocale::WeekDay weekdDayStart = locale.startOfWeek(); |
|
470 int currentDay = mStartOfWeekItem->currentIndex(); |
|
471 if(currentDay == weekdDayStart ) |
|
472 { |
|
473 return; |
|
474 } |
|
475 else |
|
476 { |
|
477 mStartOfWeekItem->setCurrentIndex(weekdDayStart); |
|
478 updateWeekDays(); |
|
479 } |
|
480 } |
|
481 } |
|
482 |
|
483 /*! |
|
484 update the week days . |
|
485 */ |
|
486 void ClockRegionalSettingsView::updateWeekDays() |
|
487 { |
|
488 QStringList weekdays = weekdayList(); |
|
489 QString workdays = mCustomPrototype->workdaysSetting(); |
|
490 QItemSelectionModel *model = 0; |
|
491 model = mWorkdaysItem->selectionModel(); |
|
492 |
|
493 for (int i = 0, index = workdays.size() - 1; |
|
494 i < mWorkdaysItem->count(); ++i, index--) |
|
495 { |
|
496 QString str = weekdays[i]; |
|
497 mWorkdaysItem->item(i)->setText(str); |
|
498 |
|
499 QChar ch = workdays.at(index); |
|
500 if ( ch == QChar('0')) |
|
501 { |
|
502 // Not a workday. |
|
503 model->select( |
|
504 model->model()->index(i,0), |
|
505 QItemSelectionModel::Deselect); |
|
506 } |
|
507 else |
|
508 { |
|
509 // Workday. |
|
510 model->select( |
|
511 model->model()->index(i,0), |
|
512 QItemSelectionModel::Select);} |
|
513 } |
|
514 } |
472 // End of file --Don't remove this. |
515 // End of file --Don't remove this. |