equal
deleted
inserted
replaced
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 #include "cnturleditormodel.h" |
17 #include "cnturleditormodel.h" |
18 #include "cntdetailmodelitem.h" |
18 #include "cntdetailmodelitem.h" |
|
19 #include "cntdetailorderinghelper.h" |
19 |
20 |
20 #include <qcontacturl.h> |
21 #include <qcontacturl.h> |
21 |
22 |
22 CntUrlEditorModel::CntUrlEditorModel(QContact* aContact) : |
23 CntUrlEditorModel::CntUrlEditorModel(QContact* aContact) : |
23 CntDetailEditorModel(aContact) |
24 CntDetailEditorModel(aContact) |
24 { |
25 { |
25 QList<QContactUrl> urlList = mContact->details<QContactUrl>(); |
26 mUrlList = CntDetailOrderingHelper::getOrderedUrls(*mContact); |
26 if (urlList.isEmpty()) { |
27 if (mUrlList.isEmpty()) { |
27 QContactUrl url; |
28 QContactUrl url; |
28 url.setSubType(QContactUrl::SubTypeHomePage); |
29 url.setSubType(QContactUrl::SubTypeHomePage); |
29 urlList.append(url); |
30 mUrlList.append(url); |
30 } |
31 } |
31 |
32 |
32 foreach( QContactUrl contactUrl, urlList ) { |
33 foreach( QContactUrl contactUrl, mUrlList ) { |
33 CntDetailModelItem* item = new CntDetailModelItem(contactUrl); |
34 CntDetailModelItem* item = new CntDetailModelItem(contactUrl); |
34 appendDataFormItem(item, invisibleRootItem()); |
35 appendDataFormItem(item, invisibleRootItem()); |
35 } |
36 } |
36 } |
37 } |
37 |
38 |
41 |
42 |
42 void CntUrlEditorModel::insertDetailField() |
43 void CntUrlEditorModel::insertDetailField() |
43 { |
44 { |
44 QContactUrl url; |
45 QContactUrl url; |
45 url.setSubType(QContactUrl::SubTypeHomePage); |
46 url.setSubType(QContactUrl::SubTypeHomePage); |
46 |
47 mUrlList.append( url ); |
47 appendDataFormItem( new CntDetailModelItem(url), invisibleRootItem() ); |
48 appendDataFormItem( new CntDetailModelItem(url), invisibleRootItem() ); |
48 } |
49 } |
49 |
50 |
50 void CntUrlEditorModel::saveContactDetails() |
51 void CntUrlEditorModel::saveContactDetails() |
51 { |
52 { |
53 |
54 |
54 int count(root->childCount()); |
55 int count(root->childCount()); |
55 for (int i(0); i < count; i++) { |
56 for (int i(0); i < count; i++) { |
56 CntDetailModelItem* detail = static_cast<CntDetailModelItem*> (root->childAt(i)); |
57 CntDetailModelItem* detail = static_cast<CntDetailModelItem*> (root->childAt(i)); |
57 QContactDetail url = detail->detail(); |
58 QContactDetail url = detail->detail(); |
58 mContact->saveDetail( &url ); |
59 |
|
60 if ( !mUrlList.contains(url) ) |
|
61 { |
|
62 mContact->saveDetail( &url ); |
|
63 } |
59 |
64 |
60 if ( url.value(QContactUrl::FieldUrl).isEmpty() ) |
65 if ( url.value(QContactUrl::FieldUrl).isEmpty() ) |
61 { |
66 { |
62 mContact->removeDetail( &url ); |
67 mContact->removeDetail( &url ); |
63 } |
68 } |