-rw-r--r-- | kabc/converter/opie/opieconverter.cpp | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/kabc/converter/opie/opieconverter.cpp b/kabc/converter/opie/opieconverter.cpp index cfbe5c0..d785fbc 100644 --- a/kabc/converter/opie/opieconverter.cpp +++ b/kabc/converter/opie/opieconverter.cpp | |||
@@ -1,325 +1,338 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | //US | 28 | //US |
29 | #include "kglobal.h" | 29 | #include "kglobal.h" |
30 | 30 | ||
31 | 31 | ||
32 | #include "opieconverter.h" | 32 | #include "opieconverter.h" |
33 | 33 | ||
34 | #include <qpe/categories.h> | 34 | #include <qpe/categories.h> |
35 | 35 | ||
36 | 36 | ||
37 | using namespace KABC; | 37 | using namespace KABC; |
38 | 38 | ||
39 | OpieConverter::OpieConverter() | 39 | OpieConverter::OpieConverter() |
40 | { | 40 | { |
41 | } | 41 | } |
42 | 42 | ||
43 | OpieConverter::~OpieConverter() | 43 | OpieConverter::~OpieConverter() |
44 | { | 44 | { |
45 | } | 45 | } |
46 | 46 | ||
47 | bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) | 47 | bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) |
48 | { | 48 | { |
49 | // name | 49 | // name |
50 | addr.setFormattedName(contact.fileAs()); | 50 | addr.setFormattedName(contact.fileAs()); |
51 | addr.setFamilyName( contact.lastName() ); | 51 | addr.setFamilyName( contact.lastName() ); |
52 | addr.setGivenName( contact.firstName() ); | 52 | addr.setGivenName( contact.firstName() ); |
53 | addr.setAdditionalName( contact.middleName() ); | 53 | addr.setAdditionalName( contact.middleName() ); |
54 | addr.setPrefix( contact.title() ); | 54 | addr.setPrefix( contact.title() ); |
55 | addr.setSuffix( contact.suffix() ); | 55 | addr.setSuffix( contact.suffix() ); |
56 | 56 | ||
57 | 57 | ||
58 | 58 | ||
59 | QStringList emails = contact.emailList(); | 59 | QStringList emails = contact.emailList(); |
60 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 60 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
61 | addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); | 61 | addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); |
62 | } | 62 | } |
63 | 63 | ||
64 | addr.insertEmail(contact.defaultEmail(), true); | 64 | addr.insertEmail(contact.defaultEmail(), true); |
65 | 65 | ||
66 | // home | 66 | // home |
67 | Address homeaddress; | 67 | Address homeaddress; |
68 | homeaddress.setType(Address::Home); | 68 | homeaddress.setType(Address::Home); |
69 | //US homeaddress.setPostOfficeBox( "" ); | 69 | //US homeaddress.setPostOfficeBox( "" ); |
70 | //US homeaddress.setExtended( "" ); | 70 | //US homeaddress.setExtended( "" ); |
71 | homeaddress.setStreet( contact.homeStreet() ); | 71 | homeaddress.setStreet( contact.homeStreet() ); |
72 | homeaddress.setLocality( contact.homeCity() ); | 72 | homeaddress.setLocality( contact.homeCity() ); |
73 | homeaddress.setRegion( contact.homeState() ); | 73 | homeaddress.setRegion( contact.homeState() ); |
74 | homeaddress.setPostalCode( contact.homeZip() ); | 74 | homeaddress.setPostalCode( contact.homeZip() ); |
75 | homeaddress.setCountry( contact.homeCountry() ); | 75 | homeaddress.setCountry( contact.homeCountry() ); |
76 | 76 | ||
77 | addr.insertAddress( homeaddress ); | 77 | addr.insertAddress( homeaddress ); |
78 | 78 | ||
79 | if (!contact.homePhone().isEmpty()) | 79 | if (!contact.homePhone().isEmpty()) |
80 | { | 80 | { |
81 | PhoneNumber homephone; | 81 | PhoneNumber homephone; |
82 | homephone.setType( PhoneNumber::Home ); | 82 | homephone.setType( PhoneNumber::Home ); |
83 | homephone.setNumber( contact.homePhone() ); | 83 | homephone.setNumber( contact.homePhone() ); |
84 | addr.insertPhoneNumber( homephone ); | 84 | addr.insertPhoneNumber( homephone ); |
85 | } | 85 | } |
86 | 86 | ||
87 | if (!contact.homeFax().isEmpty()) | 87 | if (!contact.homeFax().isEmpty()) |
88 | { | 88 | { |
89 | PhoneNumber homefax; | 89 | PhoneNumber homefax; |
90 | homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); | 90 | homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); |
91 | homefax.setNumber( contact.homeFax() ); | 91 | homefax.setNumber( contact.homeFax() ); |
92 | addr.insertPhoneNumber( homefax ); | 92 | addr.insertPhoneNumber( homefax ); |
93 | } | 93 | } |
94 | 94 | ||
95 | if (!contact.homeMobile().isEmpty()) | 95 | if (!contact.homeMobile().isEmpty()) |
96 | { | 96 | { |
97 | PhoneNumber homemobile; | 97 | PhoneNumber homemobile; |
98 | homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); | 98 | homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); |
99 | homemobile.setNumber( contact.homeMobile() ); | 99 | homemobile.setNumber( contact.homeMobile() ); |
100 | addr.insertPhoneNumber( homemobile ); | 100 | addr.insertPhoneNumber( homemobile ); |
101 | } | 101 | } |
102 | 102 | ||
103 | addr.setUrl( contact.homeWebpage() ); | 103 | addr.setUrl( contact.homeWebpage() ); |
104 | 104 | ||
105 | 105 | ||
106 | // business | 106 | // business |
107 | Address businessaddress; | 107 | Address businessaddress; |
108 | businessaddress.setType(Address::Work); | 108 | businessaddress.setType(Address::Work); |
109 | //US businessaddress.setPostOfficeBox( "" ); | 109 | //US businessaddress.setPostOfficeBox( "" ); |
110 | //US businessaddress.setExtended( "" ); | 110 | //US businessaddress.setExtended( "" ); |
111 | businessaddress.setStreet( contact.businessStreet() ); | 111 | businessaddress.setStreet( contact.businessStreet() ); |
112 | businessaddress.setLocality( contact.businessCity() ); | 112 | businessaddress.setLocality( contact.businessCity() ); |
113 | businessaddress.setRegion( contact.businessState() ); | 113 | businessaddress.setRegion( contact.businessState() ); |
114 | businessaddress.setPostalCode( contact.businessZip() ); | 114 | businessaddress.setPostalCode( contact.businessZip() ); |
115 | businessaddress.setCountry( contact.businessCountry() ); | 115 | businessaddress.setCountry( contact.businessCountry() ); |
116 | 116 | ||
117 | addr.insertAddress( businessaddress ); | 117 | addr.insertAddress( businessaddress ); |
118 | 118 | ||
119 | if (!contact.businessPhone().isEmpty()) | 119 | if (!contact.businessPhone().isEmpty()) |
120 | { | 120 | { |
121 | PhoneNumber businessphone; | 121 | PhoneNumber businessphone; |
122 | businessphone.setType( PhoneNumber::Work ); | 122 | businessphone.setType( PhoneNumber::Work ); |
123 | businessphone.setNumber( contact.businessPhone() ); | 123 | businessphone.setNumber( contact.businessPhone() ); |
124 | addr.insertPhoneNumber( businessphone ); | 124 | addr.insertPhoneNumber( businessphone ); |
125 | } | 125 | } |
126 | 126 | ||
127 | if (!contact.businessFax().isEmpty()) | 127 | if (!contact.businessFax().isEmpty()) |
128 | { | 128 | { |
129 | PhoneNumber businessfax; | 129 | PhoneNumber businessfax; |
130 | businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); | 130 | businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); |
131 | businessfax.setNumber( contact.businessFax() ); | 131 | businessfax.setNumber( contact.businessFax() ); |
132 | addr.insertPhoneNumber( businessfax ); | 132 | addr.insertPhoneNumber( businessfax ); |
133 | } | 133 | } |
134 | 134 | ||
135 | if (!contact.businessMobile().isEmpty()) | 135 | if (!contact.businessMobile().isEmpty()) |
136 | { | 136 | { |
137 | PhoneNumber businessmobile; | 137 | PhoneNumber businessmobile; |
138 | businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); | 138 | businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); |
139 | businessmobile.setNumber( contact.businessMobile() ); | 139 | businessmobile.setNumber( contact.businessMobile() ); |
140 | addr.insertPhoneNumber( businessmobile ); | 140 | addr.insertPhoneNumber( businessmobile ); |
141 | } | 141 | } |
142 | 142 | ||
143 | if (!contact.businessPager().isEmpty()) | 143 | if (!contact.businessPager().isEmpty()) |
144 | { | 144 | { |
145 | PhoneNumber businesspager; | 145 | PhoneNumber businesspager; |
146 | businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); | 146 | businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); |
147 | businesspager.setNumber( contact.businessPager() ); | 147 | businesspager.setNumber( contact.businessPager() ); |
148 | addr.insertPhoneNumber( businesspager ); | 148 | addr.insertPhoneNumber( businesspager ); |
149 | } | 149 | } |
150 | 150 | ||
151 | addr.setRole( contact.jobTitle() ); //? | 151 | addr.setRole( contact.jobTitle() ); //? |
152 | addr.setOrganization( contact.company() ); | 152 | addr.setOrganization( contact.company() ); |
153 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); | 153 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); |
154 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); | 154 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); |
155 | addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); | 155 | addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); |
156 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); | 156 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); |
157 | addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); | 157 | addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); |
158 | 158 | ||
159 | //??? | ||
160 | //US QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | ||
161 | |||
162 | //personal | 159 | //personal |
163 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); | 160 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); |
164 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() ); | 161 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() ); |
165 | 162 | ||
166 | int orgformat = KGlobal::locale()->getIntDateFormat(); | 163 | if (contact.anniversary().isValid()) { |
167 | KGlobal::locale()->setIntDateFormat( 2 ); // = Qt::ISODate | 164 | int orgformat = KGlobal::locale()->getIntDateFormat(); |
168 | QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true); | 165 | KGlobal::locale()->setIntDateFormat( 2 ); // = Qt::ISODate |
169 | KGlobal::locale()->setIntDateFormat(orgformat ); | 166 | QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true); |
170 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 167 | //US |
168 | qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1()); | ||
169 | KGlobal::locale()->setIntDateFormat(orgformat ); | ||
170 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | ||
171 | } | ||
171 | 172 | ||
172 | addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); | 173 | addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); |
173 | addr.setBirthday( contact.birthday() ); | 174 | if (contact.birthday().isValid()) |
175 | addr.setBirthday( contact.birthday() ); | ||
176 | |||
174 | addr.setNickName( contact.nickname() ); | 177 | addr.setNickName( contact.nickname() ); |
175 | 178 | ||
176 | // other | 179 | // others |
180 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. | ||
181 | QString notes = contact.notes(); | ||
182 | notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; | ||
183 | |||
177 | addr.setNote( contact.notes() ); | 184 | addr.setNote( contact.notes() ); |
185 | |||
178 | 186 | ||
187 | |||
179 | //US QString groups() const { return find( Qtopia::Groups ); } | 188 | //US QString groups() const { return find( Qtopia::Groups ); } |
180 | //US QStringList groupList() const; | 189 | //US QStringList groupList() const; |
181 | 190 | ||
182 | /*US | 191 | |
183 | QStringList cats = contact.categoryNames("Contacts"); | 192 | QStringList cats = contact.categoryNames("Contacts"); |
184 | for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { | 193 | for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { |
185 | qDebug("Cat: %s", (*it).latin1()); | 194 | qDebug("Cat: %s", (*it).latin1()); |
186 | } | 195 | } |
187 | */ | 196 | |
197 | |||
188 | addr.setCategories( contact.categoryNames("Contacts") ); | 198 | addr.setCategories( contact.categoryNames("Contacts") ); |
189 | // qDebug("Groups: %s", contact.groups().latin1()); | 199 | // qDebug("Groups: %s", contact.groups().latin1()); |
190 | // addr.setCategories( contact.groupList() ); | 200 | // addr.setCategories( contact.groupList() ); |
191 | 201 | ||
192 | 202 | ||
193 | return true; | 203 | return true; |
194 | } | 204 | } |
195 | 205 | ||
196 | bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact ) | 206 | bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact ) |
197 | { | 207 | { |
198 | // name | 208 | // name |
199 | contact.setLastName(addr.familyName()); | 209 | contact.setLastName(addr.familyName()); |
200 | contact.setFirstName(addr.givenName()); | 210 | contact.setFirstName(addr.givenName()); |
201 | contact.setMiddleName(addr.additionalName()); | 211 | contact.setMiddleName(addr.additionalName()); |
202 | contact.setTitle(addr.prefix()); | 212 | contact.setTitle(addr.prefix()); |
203 | contact.setSuffix(addr.suffix()); | 213 | contact.setSuffix(addr.suffix()); |
204 | contact.setFileAs(); | 214 | contact.setFileAs(); |
205 | 215 | ||
206 | 216 | ||
207 | 217 | ||
208 | QStringList emails = addr.emails(); | 218 | QStringList emails = addr.emails(); |
209 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 219 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
210 | contact.insertEmail(*it); | 220 | contact.insertEmail(*it); |
211 | } | 221 | } |
212 | contact.setDefaultEmail( addr.preferredEmail() ); | 222 | contact.setDefaultEmail( addr.preferredEmail() ); |
213 | 223 | ||
214 | 224 | ||
215 | // home | 225 | // home |
216 | const Address homeaddress = addr.address(Address::Home); | 226 | const Address homeaddress = addr.address(Address::Home); |
217 | if (!homeaddress.isEmpty()) { | 227 | if (!homeaddress.isEmpty()) { |
218 | contact.setHomeStreet(homeaddress.street()); | 228 | contact.setHomeStreet(homeaddress.street()); |
219 | contact.setHomeCity(homeaddress.locality()); | 229 | contact.setHomeCity(homeaddress.locality()); |
220 | contact.setHomeState(homeaddress.region()); | 230 | contact.setHomeState(homeaddress.region()); |
221 | contact.setHomeZip(homeaddress.postalCode()); | 231 | contact.setHomeZip(homeaddress.postalCode()); |
222 | contact.setHomeCountry(homeaddress.country()); | 232 | contact.setHomeCountry(homeaddress.country()); |
223 | } | 233 | } |
224 | 234 | ||
225 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); | 235 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); |
226 | if (!homephone.number().isEmpty()) | 236 | if (!homephone.number().isEmpty()) |
227 | contact.setHomePhone(homephone.number()); | 237 | contact.setHomePhone(homephone.number()); |
228 | 238 | ||
229 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); | 239 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); |
230 | if (!homefax.number().isEmpty()) | 240 | if (!homefax.number().isEmpty()) |
231 | contact.setHomeFax(homefax.number()); | 241 | contact.setHomeFax(homefax.number()); |
232 | 242 | ||
233 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); | 243 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); |
234 | if (!homemobile.number().isEmpty()) | 244 | if (!homemobile.number().isEmpty()) |
235 | contact.setHomeMobile(homemobile.number()); | 245 | contact.setHomeMobile(homemobile.number()); |
236 | 246 | ||
237 | contact.setHomeWebpage(addr.url().url()); | 247 | contact.setHomeWebpage(addr.url().url()); |
238 | 248 | ||
239 | 249 | ||
240 | // business | 250 | // business |
241 | const Address businessaddress = addr.address(Address::Work); | 251 | const Address businessaddress = addr.address(Address::Work); |
242 | if (!businessaddress.isEmpty()) { | 252 | if (!businessaddress.isEmpty()) { |
243 | contact.setBusinessStreet(businessaddress.street()); | 253 | contact.setBusinessStreet(businessaddress.street()); |
244 | contact.setBusinessCity(businessaddress.locality()); | 254 | contact.setBusinessCity(businessaddress.locality()); |
245 | contact.setBusinessState(businessaddress.region()); | 255 | contact.setBusinessState(businessaddress.region()); |
246 | contact.setBusinessZip(businessaddress.postalCode()); | 256 | contact.setBusinessZip(businessaddress.postalCode()); |
247 | contact.setBusinessCountry(businessaddress.country()); | 257 | contact.setBusinessCountry(businessaddress.country()); |
248 | } | 258 | } |
249 | 259 | ||
250 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); | 260 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); |
251 | if (!businessphone.number().isEmpty()) | 261 | if (!businessphone.number().isEmpty()) |
252 | contact.setBusinessPhone(businessphone.number()); | 262 | contact.setBusinessPhone(businessphone.number()); |
253 | 263 | ||
254 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); | 264 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); |
255 | if (!businessfax.number().isEmpty()) | 265 | if (!businessfax.number().isEmpty()) |
256 | contact.setBusinessFax(businessfax.number()); | 266 | contact.setBusinessFax(businessfax.number()); |
257 | 267 | ||
258 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); | 268 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); |
259 | if (!businessmobile.number().isEmpty()) | 269 | if (!businessmobile.number().isEmpty()) |
260 | contact.setBusinessMobile(businessmobile.number()); | 270 | contact.setBusinessMobile(businessmobile.number()); |
261 | 271 | ||
262 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); | 272 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); |
263 | if (!businesspager.number().isEmpty()) | 273 | if (!businesspager.number().isEmpty()) |
264 | contact.setBusinessPager(businesspager.number()); | 274 | contact.setBusinessPager(businesspager.number()); |
265 | 275 | ||
266 | contact.setJobTitle(addr.role()); | 276 | contact.setJobTitle(addr.role()); |
267 | contact.setCompany(addr.organization()); | 277 | contact.setCompany(addr.organization()); |
268 | 278 | ||
269 | contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" )); | 279 | contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" )); |
270 | contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); | 280 | contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); |
271 | contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" )); | 281 | contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" )); |
272 | contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" )); | 282 | contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" )); |
273 | contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" )); | 283 | contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" )); |
274 | 284 | ||
275 | //personal | 285 | //personal |
276 | contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" )); | 286 | contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" )); |
277 | contact.setGender(addr.custom( "KADDRESSBOOK", "X-Gender" )); | 287 | contact.setGender(addr.custom( "KADDRESSBOOK", "X-Gender" )); |
278 | 288 | ||
279 | QDate dt = KGlobal::locale()->readDate( | 289 | QDate dt = KGlobal::locale()->readDate( |
280 | addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate | 290 | addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate |
281 | contact.setAnniversary( dt ); | 291 | contact.setAnniversary( dt ); |
282 | 292 | ||
283 | contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); | 293 | contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); |
284 | 294 | ||
285 | contact.setBirthday(addr.birthday().date()); | 295 | contact.setBirthday(addr.birthday().date()); |
286 | contact.setNickname(addr.nickName()); | 296 | contact.setNickname(addr.nickName()); |
287 | 297 | ||
288 | // other | 298 | // other |
289 | contact.setNotes(addr.note()); | 299 | contact.setNotes(addr.note()); |
290 | 300 | ||
291 | //US QString groups() const { return find( Qtopia::Groups ); } | 301 | //US QString groups() const { return find( Qtopia::Groups ); } |
292 | //US QStringList groupList() const; | 302 | //US QStringList groupList() const; |
293 | 303 | ||
294 | /*US | 304 | /*US |
295 | QStringList cats = contact.categoryNames("Contacts"); | 305 | QStringList cats = contact.categoryNames("Contacts"); |
296 | for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { | 306 | for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { |
297 | qDebug("Cat: %s", (*it).latin1()); | 307 | qDebug("Cat: %s", (*it).latin1()); |
298 | } | 308 | } |
299 | */ | 309 | */ |
300 | 310 | ||
301 | // addr.setCategories( contact.categoryNames("Contacts") ); | 311 | // addr.setCategories( contact.categoryNames("Contacts") ); |
302 | // contact.categoryNames("Contacts"); | 312 | // contact.categoryNames("Contacts"); |
303 | // contact.setCategoryNames(addr.categories()); | 313 | // contact.setCategoryNames(addr.categories()); |
304 | 314 | ||
305 | /*US | 315 | /*US |
306 | QStringList cats = addr.categories(); | 316 | QStringList cats = addr.categories(); |
307 | QArray<int> cat(cats.count()); | 317 | QArray<int> cat(cats.count()); |
308 | int counter = 0; | 318 | int counter = 0; |
309 | for ( QStringList::ConstIterator it = cats.begin(); it != cats.end(); ++it ) | 319 | for ( QStringList::ConstIterator it = cats.begin(); it != cats.end(); ++it ) |
310 | cat[counter] = (*it).toInt(); | 320 | cat[counter] = (*it).toInt(); |
311 | 321 | ||
312 | contact.setCategories( cat ); | 322 | contact.setCategories( cat ); |
313 | */ | 323 | */ |
314 | /*US | 324 | |
315 | Categories catDB; | 325 | Categories catDB; |
316 | catDB.load( contact.categoryFileName() ); | 326 | catDB.dump(); |
327 | //US catDB.load( contact.categoryFileName() ); | ||
328 | catDB.load( "contact" ); | ||
317 | 329 | ||
318 | QStringList cats = addr.categories(); | 330 | QStringList cats = addr.categories(); |
319 | for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { | 331 | for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { |
320 | contact.setCategories(catDB.id(*it)); | 332 | qDebug("categories: %s", (*it).latin1()); |
333 | // contact.setCategories(catDB.id(*it)); | ||
321 | } | 334 | } |
322 | */ | 335 | |
323 | 336 | ||
324 | return true; | 337 | return true; |
325 | } | 338 | } |