author | ulf69 <ulf69> | 2004-07-02 15:36:32 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-07-02 15:36:32 (UTC) |
commit | ead0dcba2c607297137e2b47418eb17864e0caaa (patch) (unidiff) | |
tree | f222147cf9f591188853ba22adf981c7a6139ca1 | |
parent | b21b6754c93e5aaa53638a060e26f4efea755d37 (diff) | |
download | kdepimpi-ead0dcba2c607297137e2b47418eb17864e0caaa.zip kdepimpi-ead0dcba2c607297137e2b47418eb17864e0caaa.tar.gz kdepimpi-ead0dcba2c607297137e2b47418eb17864e0caaa.tar.bz2 |
improved conversion
-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 | |||
@@ -111,125 +111,135 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) | |||
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()); |
@@ -266,60 +276,63 @@ bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact ) | |||
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 | } |