27 QContactFamily family; |
27 QContactFamily family; |
28 familyList << family; |
28 familyList << family; |
29 } |
29 } |
30 |
30 |
31 mFamily = familyList.first(); |
31 mFamily = familyList.first(); |
32 QStringList children = mFamily.children(); |
32 |
33 |
|
34 HbDataFormModelItem* spouseItem = new HbDataFormModelItem(HbDataFormModelItem::TextItem, |
33 HbDataFormModelItem* spouseItem = new HbDataFormModelItem(HbDataFormModelItem::TextItem, |
35 hbTrId("txt_phob_formlabel_spouse")); |
34 hbTrId("txt_phob_formlabel_spouse")); |
36 spouseItem->setContentWidgetData("text", mFamily.spouse()); |
35 spouseItem->setContentWidgetData("text", mFamily.spouse()); |
37 spouseItem->setContentWidgetData("maxLength", CNT_SPOUSE_MAXLENGTH); |
36 spouseItem->setContentWidgetData("maxLength", CNT_SPOUSE_MAXLENGTH); |
38 |
37 |
39 HbDataFormModelItem* childrenItem = new HbDataFormModelItem(HbDataFormModelItem::TextItem, |
38 HbDataFormModelItem* childrenItem = new HbDataFormModelItem(HbDataFormModelItem::TextItem, |
40 hbTrId("txt_phob_formlabel_children")); |
39 hbTrId("txt_phob_formlabel_children")); |
41 childrenItem->setContentWidgetData("text", children.join(", ")); |
40 childrenItem->setContentWidgetData("text", mFamily.children().join(", ")); |
42 childrenItem->setContentWidgetData("maxLength", CNT_CHILDREN_MAXLENGTH); |
41 childrenItem->setContentWidgetData("maxLength", CNT_CHILDREN_MAXLENGTH); |
43 |
42 |
44 HbDataFormModelItem* root = invisibleRootItem(); |
43 HbDataFormModelItem* root = invisibleRootItem(); |
45 appendDataFormItem(spouseItem, root); |
44 appendDataFormItem(spouseItem, root); |
46 appendDataFormItem(childrenItem, root); |
45 appendDataFormItem(childrenItem, root); |
51 } |
50 } |
52 |
51 |
53 void CntFamilyEditorModel::saveContactDetails() |
52 void CntFamilyEditorModel::saveContactDetails() |
54 { |
53 { |
55 HbDataFormModelItem* root = invisibleRootItem(); |
54 HbDataFormModelItem* root = invisibleRootItem(); |
56 mFamily.setSpouse( root->childAt(0)->contentWidgetData("text").toString() ); |
55 QString spouse = root->childAt(0)->contentWidgetData("text").toString(); |
57 |
|
58 QString children = root->childAt(1)->contentWidgetData("text").toString(); |
56 QString children = root->childAt(1)->contentWidgetData("text").toString(); |
59 mFamily.setChildren( children.split(", ", QString::SkipEmptyParts) ); |
|
60 |
57 |
61 if ( !mFamily.isEmpty() ) { |
58 if ( spouse != mFamily.spouse() || children != mFamily.children().join(", ")) |
|
59 { |
|
60 mFamily.setSpouse( spouse ); |
|
61 QString children = root->childAt(1)->contentWidgetData("text").toString(); |
|
62 mFamily.setChildren( children.split(", ", QString::SkipEmptyParts) ); |
|
63 |
62 mContact->saveDetail( &mFamily ); |
64 mContact->saveDetail( &mFamily ); |
63 } |
65 } |
|
66 |
|
67 if ( mFamily.spouse().isEmpty() && mFamily.children().isEmpty() ) |
|
68 { |
|
69 mContact->removeDetail( &mFamily ); |
|
70 } |
|
71 |
64 } |
72 } |
65 |
73 |
66 QContactDetail CntFamilyEditorModel::detail() const |
74 QContactDetail CntFamilyEditorModel::detail() const |
67 { |
75 { |
68 return mFamily; |
76 return mFamily; |