equal
deleted
inserted
replaced
20 #include <qcontacturl.h> |
20 #include <qcontacturl.h> |
21 |
21 |
22 CntUrlEditorModel::CntUrlEditorModel(QContact* aContact) : |
22 CntUrlEditorModel::CntUrlEditorModel(QContact* aContact) : |
23 CntDetailEditorModel(aContact) |
23 CntDetailEditorModel(aContact) |
24 { |
24 { |
25 QList<QContactUrl> urlList = mContact->details<QContactUrl> (); |
25 QList<QContactUrl> urlList = mContact->details<QContactUrl>(); |
26 if (urlList.isEmpty()) { |
26 if (urlList.isEmpty()) { |
27 QContactUrl url; |
27 QContactUrl url; |
28 url.setSubType(QContactUrl::SubTypeHomePage); |
28 url.setSubType(QContactUrl::SubTypeHomePage); |
29 urlList.append(url); |
29 urlList.append(url); |
30 } |
30 } |
41 |
41 |
42 void CntUrlEditorModel::insertDetailField() |
42 void CntUrlEditorModel::insertDetailField() |
43 { |
43 { |
44 QContactUrl url; |
44 QContactUrl url; |
45 url.setSubType(QContactUrl::SubTypeHomePage); |
45 url.setSubType(QContactUrl::SubTypeHomePage); |
46 |
46 |
47 appendDataFormItem( new CntDetailModelItem(url), invisibleRootItem() ); |
47 appendDataFormItem( new CntDetailModelItem(url), invisibleRootItem() ); |
48 } |
48 } |
49 |
49 |
50 void CntUrlEditorModel::saveContactDetails() |
50 void CntUrlEditorModel::saveContactDetails() |
51 { |
51 { |
52 HbDataFormModelItem* root = invisibleRootItem(); |
52 HbDataFormModelItem* root = invisibleRootItem(); |
53 |
53 |
54 int count(root->childCount()); |
54 int count(root->childCount()); |
55 for (int i(0); i < count; i++) { |
55 for (int i(0); i < count; i++) { |
56 CntDetailModelItem* detail = static_cast<CntDetailModelItem*> (root->childAt(i)); |
56 CntDetailModelItem* detail = static_cast<CntDetailModelItem*> (root->childAt(i)); |
57 QContactUrl url = detail->detail(); |
57 QContactDetail url = detail->detail(); |
58 if (url.url().length() > 0) { |
58 mContact->saveDetail( &url ); |
59 mContact->saveDetail(&url); |
59 |
|
60 if ( url.value(QContactUrl::FieldUrl).isEmpty() ) |
|
61 { |
|
62 mContact->removeDetail( &url ); |
60 } |
63 } |
61 } |
64 } |
62 } |
65 } |
63 // End of File |
66 // End of File |
64 |
67 |