|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This class is for first form view for msg settings |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "msgsettingsform.h" |
|
19 #include "msgsettingsdataformcustomitem.h" |
|
20 |
|
21 #include <hbdataformmodelitem.h> |
|
22 #include <hbdataformmodel.h> |
|
23 #include <hbcombobox.h> |
|
24 #include <hbpushbutton.h> |
|
25 |
|
26 #include "debugtraces.h" |
|
27 |
|
28 //Localized constants |
|
29 #define LOC_DELIVERY_REPORTS hbTrId("txt_messaging_setlabel_delivery_reports") |
|
30 #define LOC_ON hbTrId("txt_messaging_setlabel_val_on") |
|
31 #define LOC_OFF hbTrId("txt_messaging_setlabel_val_off") |
|
32 #define LOC_REDUCED_SUPPORT hbTrId("txt_messaging_setlabel_val_reduced_support") |
|
33 #define LOC_FULL_SUPPORT hbTrId("txt_messaging_setlabel_val_full_support") |
|
34 #define LOC_ADVANCED hbTrId("txt_messaging_button_advanced") |
|
35 #define LOC_CHAR_ENCODING hbTrId("txt_messaging_setlabel_character_encoding") |
|
36 |
|
37 |
|
38 MsgSettingsForm::MsgSettingsForm(MsgSettingsViewManager* settingsViewManager, |
|
39 QGraphicsItem *parent) |
|
40 :HbDataForm(parent), mSettingsViewManager(settingsViewManager) |
|
41 { |
|
42 this->setHeading(tr("Application settings: Messaging")); |
|
43 |
|
44 mSettingEngine = new MsgSettingEngine(); |
|
45 |
|
46 //initialize the form model |
|
47 initSettingModel(); |
|
48 } |
|
49 |
|
50 MsgSettingsForm::~MsgSettingsForm() |
|
51 { |
|
52 delete mSettingEngine; |
|
53 } |
|
54 |
|
55 void MsgSettingsForm::initSettingModel() |
|
56 { |
|
57 HbDataFormModel *model = new HbDataFormModel(0); |
|
58 |
|
59 bool deliveryReoprt = false; |
|
60 MsgSettingEngine::CharacterEncoding charEncoding = MsgSettingEngine::ReducedSupport; |
|
61 |
|
62 mSettingEngine->settingsDeliverReportAndCharEncoding(deliveryReoprt, charEncoding); |
|
63 |
|
64 QStringList deliveryReoprtList; |
|
65 deliveryReoprtList << LOC_OFF << LOC_ON; |
|
66 |
|
67 int index = int(deliveryReoprt); |
|
68 int otherIndex = (deliveryReoprt + 1) % deliveryReoprtList.count(); |
|
69 |
|
70 // 1. create the first item delivery reports |
|
71 HbDataFormModelItem *deliverReports = new HbDataFormModelItem( |
|
72 HbDataFormModelItem::ToggleValueItem, |
|
73 LOC_DELIVERY_REPORTS, 0); |
|
74 deliverReports->setContentWidgetData("text", deliveryReoprtList.at(index)); |
|
75 deliverReports->setContentWidgetData("additionalText", deliveryReoprtList.at(otherIndex)); |
|
76 |
|
77 model->appendDataFormItem(deliverReports, model->invisibleRootItem()); |
|
78 this->addConnection(deliverReports, SIGNAL(clicked()), |
|
79 this,SLOT(onPressedDelReports())); |
|
80 |
|
81 // 2. Character encoding |
|
82 HbDataFormModelItem *characterEncoding = new HbDataFormModelItem( |
|
83 HbDataFormModelItem::ComboBoxItem, |
|
84 LOC_CHAR_ENCODING, 0); |
|
85 QStringList charEncodingList; |
|
86 charEncodingList << LOC_REDUCED_SUPPORT << LOC_FULL_SUPPORT; |
|
87 |
|
88 index = int(charEncoding); |
|
89 |
|
90 characterEncoding->setContentWidgetData("items", charEncodingList); |
|
91 characterEncoding->setContentWidgetData("currentIndex", index); |
|
92 |
|
93 model->appendDataFormItem(characterEncoding, model->invisibleRootItem()); |
|
94 this->addConnection(characterEncoding, SIGNAL(currentIndexChanged(int)), |
|
95 this,SLOT(changeCharEncoding(int))); |
|
96 |
|
97 // 3. CUSTOM SETTING ITEM HbButton |
|
98 HbDataFormModelItem::DataItemType customItem = |
|
99 static_cast<HbDataFormModelItem::DataItemType> (HbDataFormModelItem::CustomItemBase + 1); |
|
100 |
|
101 HbDataFormModelItem *advancedSettings |
|
102 = model->appendDataFormItem(customItem, QString(), model->invisibleRootItem()); |
|
103 |
|
104 advancedSettings->setContentWidgetData("text", LOC_ADVANCED); |
|
105 this->addConnection(advancedSettings, SIGNAL(clicked()), |
|
106 this,SLOT(onPressedAdvanced())); |
|
107 |
|
108 this->setModel(model); |
|
109 } |
|
110 |
|
111 void MsgSettingsForm::onPressedAdvanced() |
|
112 { |
|
113 //tell view manager to open advanced view |
|
114 mSettingsViewManager->openAdvancedView(); |
|
115 } |
|
116 |
|
117 void MsgSettingsForm::onPressedDelReports() |
|
118 { |
|
119 HbPushButton *btn = qobject_cast<HbPushButton *> (sender()); |
|
120 |
|
121 if (btn) { |
|
122 QString btnText = btn->text(); |
|
123 |
|
124 //check if the button pressed was On or Off |
|
125 if (LOC_OFF == btnText) { |
|
126 mSettingEngine->setDeliveryReport(false); |
|
127 } |
|
128 else { |
|
129 mSettingEngine->setDeliveryReport(true); |
|
130 } |
|
131 } |
|
132 } |
|
133 |
|
134 void MsgSettingsForm::changeCharEncoding(int index) |
|
135 { |
|
136 //set the character encoding |
|
137 mSettingEngine->setCharacterEncoding(MsgSettingEngine::CharacterEncoding(index)); |
|
138 } |
|
139 |
|
140 |
|
141 //EOF |