23 #include <HbDataFormModel> |
23 #include <HbDataFormModel> |
24 #include <HbDataFormModelItem> |
24 #include <HbDataFormModelItem> |
25 #include <HbLabel> |
25 #include <HbLabel> |
26 #include <HbPushButton> |
26 #include <HbPushButton> |
27 #include <HbCheckBox> |
27 #include <HbCheckBox> |
28 #include <HbApplication> |
28 #include <HbTranslator> |
29 #include <QTranslator> |
|
30 #include <xqsettingsmanager.h> |
29 #include <xqsettingsmanager.h> |
31 #include <xqsettingskey.h> |
30 #include <xqsettingskey.h> |
32 #include <clockdomaincrkeys.h> |
31 #include <clockdomaincrkeys.h> |
33 |
32 |
34 // User includes |
33 // User includes |
53 \param parent The parent of type QGraphicsWidget. |
52 \param parent The parent of type QGraphicsWidget. |
54 */ |
53 */ |
55 ClockSettingsView::ClockSettingsView(QObject *parent) |
54 ClockSettingsView::ClockSettingsView(QObject *parent) |
56 :QObject(parent) |
55 :QObject(parent) |
57 { |
56 { |
58 qDebug("clock: ClockSettingsView::ClockSettingsView() -->"); |
|
59 |
57 |
60 // Load the translation file and install the editor specific translator |
58 // Load the translation file and install the editor specific translator |
61 mTranslator = new QTranslator; |
59 mTranslator = new HbTranslator("clocksettingsview"); |
62 //QString lang = QLocale::system().name(); |
60 mTranslator->loadCommon(); |
63 //QString path = "Z:/resource/qt/translations/"; |
|
64 mTranslator->load("clocksettingsview",":/translations"); |
|
65 // TODO: Load the appropriate .qm file based on locale |
|
66 //bool loaded = mTranslator->load("caleneditor_" + lang, path); |
|
67 HbApplication::instance()->installTranslator(mTranslator); |
|
68 |
61 |
69 // Construct the settings utility. |
62 // Construct the settings utility. |
70 mSettingsUtility = new SettingsUtility(); |
63 mSettingsUtility = new SettingsUtility(); |
71 |
64 |
72 // Construct the timezone client. |
65 // Construct the timezone client. |
119 if (mDocLoader) { |
112 if (mDocLoader) { |
120 delete mDocLoader; |
113 delete mDocLoader; |
121 } |
114 } |
122 |
115 |
123 // Remove the translator |
116 // Remove the translator |
124 HbApplication::instance()->removeTranslator(mTranslator); |
|
125 if (mTranslator) { |
117 if (mTranslator) { |
126 delete mTranslator; |
118 delete mTranslator; |
127 mTranslator = 0; |
119 mTranslator = 0; |
128 } |
120 } |
129 if(mSettingsUtility){ |
121 if(mSettingsUtility){ |
130 delete mSettingsUtility; |
122 delete mSettingsUtility; |
131 } |
123 } |
132 |
124 |
133 if (!mTimezoneClient->isNull()) { |
|
134 mTimezoneClient->deleteInstance(); |
|
135 } |
|
136 if(mSettingsModel){ |
125 if(mSettingsModel){ |
137 delete mSettingsModel; |
126 delete mSettingsModel; |
138 } |
127 } |
139 |
128 |
140 |
129 |
294 mSettingsForm = static_cast<HbDataForm *> ( |
283 mSettingsForm = static_cast<HbDataForm *> ( |
295 mDocLoader->findWidget(CLOCK_SETTINGS_DATA_FORM)); |
284 mDocLoader->findWidget(CLOCK_SETTINGS_DATA_FORM)); |
296 |
285 |
297 // Create the custom prototype. |
286 // Create the custom prototype. |
298 QList <HbAbstractViewItem*> prototypes = mSettingsForm->itemPrototypes(); |
287 QList <HbAbstractViewItem*> prototypes = mSettingsForm->itemPrototypes(); |
299 SettingsCustomItem *customPrototype = new SettingsCustomItem(); |
288 SettingsCustomItem *customPrototype = new SettingsCustomItem(mSettingsForm); |
300 prototypes.append(customPrototype); |
289 prototypes.append(customPrototype); |
301 mSettingsForm->setItemPrototypes(prototypes); |
290 mSettingsForm->setItemPrototypes(prototypes); |
302 |
291 |
303 // Create the model. |
292 // Create the model. |
304 createModel(); |
293 createModel(); |
397 // Add the regional settings item. |
386 // Add the regional settings item. |
398 HbDataFormModelItem::DataItemType regionalSettingsItem = |
387 HbDataFormModelItem::DataItemType regionalSettingsItem = |
399 static_cast<HbDataFormModelItem::DataItemType> |
388 static_cast<HbDataFormModelItem::DataItemType> |
400 (HbDataFormModelItem::CustomItemBase + RegionalSettingsItem); |
389 (HbDataFormModelItem::CustomItemBase + RegionalSettingsItem); |
401 mSettingsModel->appendDataFormItem(regionalSettingsItem); |
390 mSettingsModel->appendDataFormItem(regionalSettingsItem); |
402 |
391 |
403 // Add the alarm snooze time item. |
392 // Add the clock type item. |
|
393 HbDataFormModelItem::DataItemType clockTypeSettingsItem = |
|
394 static_cast<HbDataFormModelItem::DataItemType> |
|
395 (HbDataFormModelItem::ToggleValueItem); |
|
396 mClockTypeItem = mSettingsModel->appendDataFormItem( |
|
397 clockTypeSettingsItem,hbTrId("txt_clock_setlabel_clock_type")); |
|
398 QStringList clockTypeList; |
|
399 int clockType = mSettingsUtility->clockType(clockTypeList); |
|
400 int zeroIndex(0); |
|
401 if( zeroIndex == clockType ){ |
|
402 mClockTypeItem->setContentWidgetData("text", clockTypeList[0]); |
|
403 mClockTypeItem->setContentWidgetData("additionalText", clockTypeList[1]); |
|
404 } else { |
|
405 mClockTypeItem->setContentWidgetData("text", clockTypeList[1]); |
|
406 mClockTypeItem->setContentWidgetData("additionalText", clockTypeList[0]); |
|
407 } |
|
408 mSettingsForm->addConnection( |
|
409 mClockTypeItem, SIGNAL(clicked()), |
|
410 this, SLOT(handleClockTypeChanged())); |
|
411 |
|
412 // Add the alarm snooze time item. |
404 mAlarmSnoozeItem = mSettingsModel->appendDataFormItem( |
413 mAlarmSnoozeItem = mSettingsModel->appendDataFormItem( |
405 HbDataFormModelItem::ComboBoxItem, |
414 HbDataFormModelItem::ComboBoxItem, |
406 hbTrId("txt_clock_setlabel_alarm_snooze_time")); |
415 hbTrId("txt_clock_setlabel_alarm_snooze_time")); |
407 QStringList alramSnoozeTimes; |
416 QStringList alramSnoozeTimes; |
408 alramSnoozeTimes << hbTrId("txt_clock_set_ln_mins", 5) |
417 alramSnoozeTimes << hbTrId("txt_clock_set_ln_mins", 5) |
488 *mAlarmSnoozeTimeKey, mAlarmSnoozeTimeHash.value(index)); |
497 *mAlarmSnoozeTimeKey, mAlarmSnoozeTimeHash.value(index)); |
489 } |
498 } |
490 } |
499 } |
491 |
500 |
492 /*! |
501 /*! |
|
502 Slot which handles the clock type change.. |
|
503 */ |
|
504 void ClockSettingsView::handleClockTypeChanged() |
|
505 { |
|
506 mSettingsUtility->setClockType( |
|
507 mClockTypeItem->contentWidgetData("text").toString()); |
|
508 } |
|
509 |
|
510 /*! |
493 Slot which is called when the value changes in cenrep. |
511 Slot which is called when the value changes in cenrep. |
494 |
512 |
495 \param key The key which got changed in cenrep. |
513 \param key The key which got changed in cenrep. |
496 \param value The new value of that key. |
514 \param value The new value of that key. |
497 */ |
515 */ |