equal
deleted
inserted
replaced
16 */ |
16 */ |
17 |
17 |
18 #include "cntaddressmodel.h" |
18 #include "cntaddressmodel.h" |
19 #include "cntdetailmodelitem.h" |
19 #include "cntdetailmodelitem.h" |
20 #include "cntdetailconst.h" |
20 #include "cntdetailconst.h" |
|
21 #include <cntmaptileservice.h> |
21 |
22 |
22 CntAddressModel::CntAddressModel( QContact* aContact ): |
23 CntAddressModel::CntAddressModel( QContact* aContact ): |
23 CntDetailEditorModel( aContact ), |
24 CntDetailEditorModel( aContact ), |
24 mAddress(NULL), |
25 mAddress(NULL), |
25 mAddressHome(NULL), |
26 mAddressHome(NULL), |
26 mAddressWork(NULL) |
27 mAddressWork(NULL), |
|
28 mIsLocationPickerEnabled( false ) |
27 { |
29 { |
28 HbDataFormModelItem* address = appendDataFormGroup(qtTrId("Address"), invisibleRootItem()); |
30 HbDataFormModelItem* address = appendDataFormGroup(qtTrId("Address"), invisibleRootItem()); |
29 HbDataFormModelItem* addressHome = appendDataFormGroup(qtTrId("Address (home)"), invisibleRootItem()); |
31 HbDataFormModelItem* addressHome = appendDataFormGroup(qtTrId("Address (home)"), invisibleRootItem()); |
30 HbDataFormModelItem* addressWork = appendDataFormGroup(qtTrId("Address (work)"), invisibleRootItem()); |
32 HbDataFormModelItem* addressWork = appendDataFormGroup(qtTrId("Address (work)"), invisibleRootItem()); |
31 |
33 |
84 delete mAddressWork; |
86 delete mAddressWork; |
85 } |
87 } |
86 |
88 |
87 void CntAddressModel::createAddressItems( HbDataFormModelItem* aGroup, QContactAddress* aAddress ) |
89 void CntAddressModel::createAddressItems( HbDataFormModelItem* aGroup, QContactAddress* aAddress ) |
88 { |
90 { |
89 // custom item for map button |
91 //Show the location picker button only if location feature enabled |
90 // HbDataFormModelItem* mapButton = new HbDataFormModelItem( HbDataFormModelItem::CustomItemBase ); |
92 if( CntMapTileService::isLocationFeatureEnabled() ) |
|
93 { |
|
94 // custom item for map button |
|
95 HbDataFormModelItem* mapButton = new HbDataFormModelItem( HbDataFormModelItem::CustomItemBase ); |
|
96 appendDataFormItem( mapButton, aGroup ); |
|
97 mIsLocationPickerEnabled = true; |
|
98 } |
91 |
99 |
92 // default items for rest of fields |
100 // default items for rest of fields |
93 HbDataFormModelItem* street = new HbDataFormModelItem( HbDataFormModelItem::TextItem, qtTrId("Street")); |
101 HbDataFormModelItem* street = new HbDataFormModelItem( HbDataFormModelItem::TextItem, qtTrId("Street")); |
94 street->setContentWidgetData( "text", aAddress->street() ); |
102 street->setContentWidgetData( "text", aAddress->street() ); |
95 street->setContentWidgetData( "maxLength", CNT_STREET_MAXLENGTH ); |
103 street->setContentWidgetData( "maxLength", CNT_STREET_MAXLENGTH ); |
108 |
116 |
109 HbDataFormModelItem* country = new HbDataFormModelItem( HbDataFormModelItem::TextItem, qtTrId("Country")); |
117 HbDataFormModelItem* country = new HbDataFormModelItem( HbDataFormModelItem::TextItem, qtTrId("Country")); |
110 country->setContentWidgetData( "text", aAddress->country() ); |
118 country->setContentWidgetData( "text", aAddress->country() ); |
111 country->setContentWidgetData( "maxLength", CNT_COUNTRY_MAXLENGTH ); |
119 country->setContentWidgetData( "maxLength", CNT_COUNTRY_MAXLENGTH ); |
112 |
120 |
113 //appendDataFormItem( mapButton, aGroup ); |
|
114 appendDataFormItem( street, aGroup ); |
121 appendDataFormItem( street, aGroup ); |
115 appendDataFormItem( postal, aGroup ); |
122 appendDataFormItem( postal, aGroup ); |
116 appendDataFormItem( city, aGroup ); |
123 appendDataFormItem( city, aGroup ); |
117 appendDataFormItem( region, aGroup ); |
124 appendDataFormItem( region, aGroup ); |
118 appendDataFormItem( country, aGroup ); |
125 appendDataFormItem( country, aGroup ); |
153 } |
160 } |
154 } |
161 } |
155 |
162 |
156 void CntAddressModel::saveAddressItems( HbDataFormModelItem* aGroup, QContactAddress* aAddress ) |
163 void CntAddressModel::saveAddressItems( HbDataFormModelItem* aGroup, QContactAddress* aAddress ) |
157 { |
164 { |
|
165 int offset = 0; |
|
166 if( CntMapTileService::isLocationFeatureEnabled() ) |
|
167 { |
|
168 offset = 1; |
|
169 } |
|
170 |
158 // first item (0) is the map button |
171 // first item (0) is the map button |
159 aAddress->setStreet( aGroup->childAt( 0 )->contentWidgetData("text").toString().trimmed() ); |
172 aAddress->setStreet( aGroup->childAt( 0 + offset )->contentWidgetData("text").toString().trimmed() ); |
160 aAddress->setPostcode( aGroup->childAt( 1 )->contentWidgetData("text").toString().trimmed() ); |
173 aAddress->setPostcode( aGroup->childAt( 1 + offset )->contentWidgetData("text").toString().trimmed() ); |
161 aAddress->setLocality( aGroup->childAt( 2 )->contentWidgetData("text").toString().trimmed() ); |
174 aAddress->setLocality( aGroup->childAt( 2 + offset )->contentWidgetData("text").toString().trimmed() ); |
162 aAddress->setRegion( aGroup->childAt( 3 )->contentWidgetData("text").toString().trimmed() ); |
175 aAddress->setRegion( aGroup->childAt( 3 + offset )->contentWidgetData("text").toString().trimmed() ); |
163 aAddress->setCountry( aGroup->childAt( 4 )->contentWidgetData("text").toString().trimmed() ); |
176 aAddress->setCountry( aGroup->childAt( 4 + offset )->contentWidgetData("text").toString().trimmed() ); |
164 } |
177 } |
165 |
178 |
166 bool CntAddressModel::isAddressEmpty( QContactAddress* aAddress ) |
179 bool CntAddressModel::isAddressEmpty( QContactAddress* aAddress ) |
167 { |
180 { |
168 return ( aAddress->street().length() == 0 && |
181 return ( aAddress->street().length() == 0 && |