24 #include <hbdataformmodel.h> |
24 #include <hbdataformmodel.h> |
25 #include <hblineedit.h> |
25 #include <hblineedit.h> |
26 #include <HbNotificationDialog> |
26 #include <HbNotificationDialog> |
27 #include <hbinputeditorinterface.h> |
27 #include <hbinputeditorinterface.h> |
28 #include <hbmessagebox.h> |
28 #include <hbmessagebox.h> |
|
29 #include <HbAction> |
29 #include "debugtraces.h" |
30 #include "debugtraces.h" |
30 |
31 |
31 //Localized constants |
32 //Localized constants |
32 #define LOC_NEW_SMS_CENTRE hbTrId("txt_messaging_title_new_sms_message_centre") |
|
33 #define LOC_EDIT_SMS_CENTRE hbTrId("txt_messaging_title_edit_sms_message_centre") |
|
34 #define LOC_SMS_CENTRE_NAME hbTrId("txt_messaging_setlabel_message_centre_name") |
33 #define LOC_SMS_CENTRE_NAME hbTrId("txt_messaging_setlabel_message_centre_name") |
35 #define LOC_SMS_CENTRE_NUMBER hbTrId("txt_messaging_setlabel_message_centre_number") |
34 #define LOC_SMS_CENTRE_NUMBER hbTrId("txt_messaging_setlabel_message_centre_number") |
36 #define LOC_SMS_CENTRE_DELETE hbTrId("txt_messaging_button_delete_message_centre") |
35 #define LOC_SMS_CENTRE_DELETE hbTrId("txt_messaging_button_delete_message_centre") |
37 #define LOC_MESSAGE_CENTER_SAVED hbTrId("txt_messaging_setlabel_message_centre_saved") |
36 #define LOC_MESSAGE_CENTER_SAVED hbTrId("txt_messaging_setlabel_message_centre_saved") |
38 #define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete") |
37 #define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete") |
41 MsgSMSCenterSettingsForm::MsgSMSCenterSettingsForm(int view, |
40 MsgSMSCenterSettingsForm::MsgSMSCenterSettingsForm(int view, |
42 QGraphicsItem *parent) : |
41 QGraphicsItem *parent) : |
43 HbDataForm(parent), mEdit1(0), mEdit2(0), mView(view) |
42 HbDataForm(parent), mEdit1(0), mEdit2(0), mView(view) |
44 { |
43 { |
45 QString heading; |
44 QString heading; |
46 if (mView == -1) |
45 if (mView > -1) |
47 { |
46 { |
48 heading = LOC_NEW_SMS_CENTRE; |
47 //add the custom prototype only for edit items |
49 } |
|
50 else |
|
51 { |
|
52 heading = LOC_EDIT_SMS_CENTRE; |
|
53 //custom prototype |
|
54 MsgSettingsDataFormCustomItem* customPrototype = |
48 MsgSettingsDataFormCustomItem* customPrototype = |
55 new MsgSettingsDataFormCustomItem(this); |
49 new MsgSettingsDataFormCustomItem(this); |
56 |
50 |
57 QList<HbAbstractViewItem*> protos = this->itemPrototypes(); |
51 QList<HbAbstractViewItem*> protos = this->itemPrototypes(); |
58 protos.append(customPrototype); |
52 protos.append(customPrototype); |
59 this->setItemPrototypes(protos); |
53 this->setItemPrototypes(protos); |
60 } |
54 } |
61 |
|
62 this->setHeading(heading); |
|
63 |
55 |
64 bool b = connect(this, |
56 bool b = connect(this, |
65 SIGNAL(itemShown(const QModelIndex&)), |
57 SIGNAL(itemShown(const QModelIndex&)), |
66 this, |
58 this, |
67 SLOT(onItemShown(const QModelIndex&))); |
59 SLOT(onItemShown(const QModelIndex&))); |
180 static_cast<HbDataFormModel *> (model())->itemFromIndex(topLeft); |
172 static_cast<HbDataFormModel *> (model())->itemFromIndex(topLeft); |
181 |
173 |
182 if (itemData && itemData == messageCenterName && !mEdit1) |
174 if (itemData && itemData == messageCenterName && !mEdit1) |
183 { |
175 { |
184 QDEBUG_WRITE("messageCenterName updated.."); |
176 QDEBUG_WRITE("messageCenterName updated.."); |
185 mEdit1 |
177 HbDataFormViewItem* item1 = |
186 = static_cast<HbLineEdit *> ( |
178 static_cast<HbDataFormViewItem*>(this->itemByIndex(topLeft)); |
187 this->dataFormViewItem( |
179 mEdit1 = static_cast<HbLineEdit*>(item1->dataItemContentWidget()); |
188 topLeft)->dataItemContentWidget()); |
|
189 } |
180 } |
190 else if (itemData && itemData == messageCenterNumber && !mEdit2) |
181 else if (itemData && itemData == messageCenterNumber && !mEdit2) |
191 { |
182 { |
192 QDEBUG_WRITE("messageCenterNumber updated.."); |
183 QDEBUG_WRITE("messageCenterNumber updated.."); |
193 mEdit2 |
184 HbDataFormViewItem* item1 = |
194 = static_cast<HbLineEdit *> ( |
185 static_cast<HbDataFormViewItem*>(this->itemByIndex(topLeft)); |
195 this->dataFormViewItem( |
186 mEdit2 = static_cast<HbLineEdit*>(item1->dataItemContentWidget()); |
196 topLeft)->dataItemContentWidget()); |
187 mEdit2->setInputMethodHints(Qt::ImhPreferNumbers); |
197 |
|
198 HbEditorInterface editorInterface(mEdit2); |
|
199 editorInterface.setUpAsPhoneNumberEditor(); |
|
200 |
188 |
201 } |
189 } |
202 } |
190 } |
203 |
191 |
204 void MsgSMSCenterSettingsForm::onPressedCustomButton() |
192 void MsgSMSCenterSettingsForm::onPressedCustomButton() |
205 { |
193 { |
206 bool result = HbMessageBox::question("Delete message centre ?", |
194 HbMessageBox::question(LOC_SMS_CENTRE_DELETE, this, SLOT(onDialogDeleteMsgCentre(HbAction*)), LOC_BUTTON_DELETE, LOC_BUTTON_CANCEL); |
207 LOC_BUTTON_DELETE, |
195 } |
208 LOC_BUTTON_CANCEL); |
196 |
209 |
197 void MsgSMSCenterSettingsForm::onDialogDeleteMsgCentre(HbAction* action) |
210 if (result) |
198 { |
211 { |
199 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
200 if (action == dlg->actions().at(0)) { |
212 //delete from m/w -- mView is the index to delete |
201 //delete from m/w -- mView is the index to delete |
213 mSettingEngine->deleteSmsMessageCenter(mView); |
202 mSettingEngine->deleteSmsMessageCenter(mView); |
214 emit deleteMessageCentreAndClose(); |
203 emit deleteMessageCentreAndClose(); |
215 } |
204 } |
216 } |
205 } |
217 |
206 |
218 //eof |
207 //eof |
219 |
208 |