73 } |
73 } |
74 |
74 |
75 void CntNameEditorModel::saveContactDetails() |
75 void CntNameEditorModel::saveContactDetails() |
76 { |
76 { |
77 HbDataFormModelItem* root = invisibleRootItem(); |
77 HbDataFormModelItem* root = invisibleRootItem(); |
78 iName.setFirstName( root->childAt( 0 )->contentWidgetData("text").toString().trimmed() ); |
78 QString firstname = root->childAt( 0 )->contentWidgetData("text").toString().trimmed(); |
79 iName.setLastName( root->childAt( 1 )->contentWidgetData("text").toString().trimmed() ); |
79 QString lastname = root->childAt( 1 )->contentWidgetData("text").toString().trimmed(); |
80 iName.setMiddleName( root->childAt( 2 )->contentWidgetData("text").toString().trimmed() ); |
80 QString midname = root->childAt( 2 )->contentWidgetData("text").toString().trimmed(); |
81 iNick.setNickname( root->childAt( 3 )->contentWidgetData("text").toString().trimmed() ); |
81 QString nick = root->childAt( 3 )->contentWidgetData("text").toString().trimmed(); |
82 iName.setPrefix( root->childAt( 4 )->contentWidgetData("text").toString().trimmed() ); |
82 QString prefix = root->childAt( 4 )->contentWidgetData("text").toString().trimmed(); |
83 iName.setSuffix( root->childAt( 5 )->contentWidgetData("text").toString().trimmed() ); |
83 QString suffix = root->childAt( 5 )->contentWidgetData("text").toString().trimmed(); |
|
84 |
|
85 if ( firstname != iName.firstName() || |
|
86 lastname != iName.lastName() || |
|
87 midname != iName.middleName() || |
|
88 prefix != iName.prefix() || |
|
89 suffix != iName.suffix() ) |
|
90 { |
|
91 iName.setFirstName( firstname ); |
|
92 iName.setLastName( lastname ); |
|
93 iName.setMiddleName( midname ); |
|
94 iName.setPrefix( prefix ); |
|
95 iName.setSuffix( suffix ); |
|
96 mContact->saveDetail( &iName ); |
|
97 } |
84 |
98 |
85 mContact->saveDetail( &iName ); |
99 if ( nick != iNick.nickname() ) |
86 mContact->saveDetail( &iNick ); |
100 { |
|
101 iNick.setNickname( nick ); |
|
102 mContact->saveDetail( &iNick ); |
|
103 } |
87 |
104 |
88 // remove empty details |
105 // remove empty details |
89 if (iName.firstName().isEmpty() && |
106 if (firstname.isEmpty() && |
90 iName.lastName().isEmpty() && |
107 lastname.isEmpty() && |
91 iName.middleName().isEmpty() && |
108 midname.isEmpty() && |
92 iName.prefix().isEmpty() && |
109 prefix.isEmpty() && |
93 iName.suffix().isEmpty()) |
110 suffix.isEmpty()) |
94 { |
111 { |
95 mContact->removeDetail( &iName ); |
112 mContact->removeDetail( &iName ); |
96 } |
113 } |
97 |
114 |
98 if(iNick.nickname().isEmpty()) |
115 if( nick.isEmpty()) |
99 { |
116 { |
100 mContact->removeDetail( &iNick ); |
117 mContact->removeDetail( &iNick ); |
101 } |
118 } |
102 } |
119 } |
103 |
120 |
104 QContactDetail CntNameEditorModel::detail() const |
121 QContactDetail CntNameEditorModel::detail() const |
105 { |
122 { |
106 if (!iName.firstName().isEmpty() || |
123 if (!iName.firstName().isEmpty() || |