-rw-r--r-- | kabc/converter/qtopia/qtopiaconverter.cpp | 98 |
1 files changed, 50 insertions, 48 deletions
diff --git a/kabc/converter/qtopia/qtopiaconverter.cpp b/kabc/converter/qtopia/qtopiaconverter.cpp index 498e89e..ac513b6 100644 --- a/kabc/converter/qtopia/qtopiaconverter.cpp +++ b/kabc/converter/qtopia/qtopiaconverter.cpp | |||
@@ -50,8 +50,8 @@ bool QtopiaConverter::init() | |||
50 | { | 50 | { |
51 | catDB = new Categories(); | 51 | catDB = new Categories(); |
52 | 52 | ||
53 | if (!catDB) | 53 | if (!catDB) |
54 | return false; | 54 | return false; |
55 | 55 | ||
56 | catDB->load( categoryFileName() ); | 56 | catDB->load( categoryFileName() ); |
57 | return true; | 57 | return true; |
@@ -60,5 +60,5 @@ bool QtopiaConverter::init() | |||
60 | void QtopiaConverter::deinit() | 60 | void QtopiaConverter::deinit() |
61 | { | 61 | { |
62 | if (catDB) | 62 | if (catDB) |
63 | { | 63 | { |
64 | delete catDB; | 64 | delete catDB; |
@@ -66,5 +66,5 @@ void QtopiaConverter::deinit() | |||
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) | 69 | bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) |
70 | { | 70 | { |
@@ -76,6 +76,6 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
76 | addr.setPrefix( contact.nameTitle() ); | 76 | addr.setPrefix( contact.nameTitle() ); |
77 | addr.setSuffix( contact.suffix() ); | 77 | addr.setSuffix( contact.suffix() ); |
78 | 78 | ||
79 | 79 | ||
80 | 80 | ||
81 | QStringList emails = contact.emailList(); | 81 | QStringList emails = contact.emailList(); |
@@ -84,7 +84,7 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
84 | } | 84 | } |
85 | 85 | ||
86 | if (!contact.defaultEmail().isEmpty()) | 86 | if (!contact.defaultEmail().isEmpty()) |
87 | addr.insertEmail(contact.defaultEmail(), true); | 87 | addr.insertEmail(contact.defaultEmail(), true); |
88 | 88 | ||
89 | // home | 89 | // home |
90 | if ((!contact.homeStreet().isEmpty()) || | 90 | if ((!contact.homeStreet().isEmpty()) || |
@@ -103,8 +103,8 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
103 | homeaddress.setPostalCode( contact.homeZip() ); | 103 | homeaddress.setPostalCode( contact.homeZip() ); |
104 | homeaddress.setCountry( contact.homeCountry() ); | 104 | homeaddress.setCountry( contact.homeCountry() ); |
105 | 105 | ||
106 | addr.insertAddress( homeaddress ); | 106 | addr.insertAddress( homeaddress ); |
107 | } | 107 | } |
108 | 108 | ||
109 | if (!contact.homePhone().isEmpty()) | 109 | if (!contact.homePhone().isEmpty()) |
110 | { | 110 | { |
@@ -114,5 +114,5 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
114 | addr.insertPhoneNumber( homephone ); | 114 | addr.insertPhoneNumber( homephone ); |
115 | } | 115 | } |
116 | 116 | ||
117 | if (!contact.homeFax().isEmpty()) | 117 | if (!contact.homeFax().isEmpty()) |
118 | { | 118 | { |
@@ -122,5 +122,5 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
122 | addr.insertPhoneNumber( homefax ); | 122 | addr.insertPhoneNumber( homefax ); |
123 | } | 123 | } |
124 | 124 | ||
125 | if (!contact.homeMobile().isEmpty()) | 125 | if (!contact.homeMobile().isEmpty()) |
126 | { | 126 | { |
@@ -130,7 +130,7 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
130 | addr.insertPhoneNumber( homemobile ); | 130 | addr.insertPhoneNumber( homemobile ); |
131 | } | 131 | } |
132 | 132 | ||
133 | addr.setUrl( contact.homeWebpage() ); | 133 | addr.setUrl( contact.homeWebpage() ); |
134 | 134 | ||
135 | 135 | ||
136 | // business | 136 | // business |
@@ -150,9 +150,9 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
150 | businessaddress.setPostalCode( contact.businessZip() ); | 150 | businessaddress.setPostalCode( contact.businessZip() ); |
151 | businessaddress.setCountry( contact.businessCountry() ); | 151 | businessaddress.setCountry( contact.businessCountry() ); |
152 | 152 | ||
153 | addr.insertAddress( businessaddress ); | 153 | addr.insertAddress( businessaddress ); |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | if (!contact.businessPhone().isEmpty()) | 157 | if (!contact.businessPhone().isEmpty()) |
158 | { | 158 | { |
@@ -162,5 +162,5 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
162 | addr.insertPhoneNumber( businessphone ); | 162 | addr.insertPhoneNumber( businessphone ); |
163 | } | 163 | } |
164 | 164 | ||
165 | if (!contact.businessFax().isEmpty()) | 165 | if (!contact.businessFax().isEmpty()) |
166 | { | 166 | { |
@@ -170,5 +170,5 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
170 | addr.insertPhoneNumber( businessfax ); | 170 | addr.insertPhoneNumber( businessfax ); |
171 | } | 171 | } |
172 | 172 | ||
173 | if (!contact.businessMobile().isEmpty()) | 173 | if (!contact.businessMobile().isEmpty()) |
174 | { | 174 | { |
@@ -186,5 +186,5 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
186 | addr.insertPhoneNumber( businesspager ); | 186 | addr.insertPhoneNumber( businesspager ); |
187 | } | 187 | } |
188 | 188 | ||
189 | addr.setRole( contact.jobTitle() ); //? | 189 | addr.setRole( contact.jobTitle() ); //? |
190 | addr.setOrganization( contact.company() ); | 190 | addr.setOrganization( contact.company() ); |
@@ -203,16 +203,16 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
203 | else if (contact.gender() == PimContact::Female) | 203 | else if (contact.gender() == PimContact::Female) |
204 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); | 204 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); |
205 | 205 | ||
206 | if (contact.anniversary().isValid()) { | 206 | if (contact.anniversary().isValid()) { |
207 | QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); | 207 | QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); |
208 | //US | 208 | //US |
209 | // qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1()); | 209 | // qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1()); |
210 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 210 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
211 | } | 211 | } |
212 | 212 | ||
213 | addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); | 213 | addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); |
214 | if (contact.birthday().isValid()) | 214 | if (contact.birthday().isValid()) |
215 | addr.setBirthday( contact.birthday() ); | 215 | addr.setBirthday( contact.birthday() ); |
216 | 216 | ||
217 | addr.setNickName( contact.nickname() ); | 217 | addr.setNickName( contact.nickname() ); |
218 | 218 | ||
@@ -221,12 +221,12 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
221 | QString notes = contact.notes(); | 221 | QString notes = contact.notes(); |
222 | notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; | 222 | notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; |
223 | 223 | ||
224 | addr.setNote( contact.notes() ); | 224 | addr.setNote( contact.notes() ); |
225 | 225 | ||
226 | 226 | ||
227 | 227 | ||
228 | //US QString groups() const { return find( Qtopia::Groups ); } | 228 | //US QString groups() const { return find( Qtopia::Groups ); } |
229 | //US QStringList groupList() const; | 229 | //US QStringList groupList() const; |
230 | 230 | ||
231 | QArray<int> catArray = contact.categories(); | 231 | QArray<int> catArray = contact.categories(); |
232 | QString cat; | 232 | QString cat; |
@@ -234,8 +234,10 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
234 | for ( unsigned int i=0; i < catArray.size(); i++ ) { | 234 | for ( unsigned int i=0; i < catArray.size(); i++ ) { |
235 | cat = catDB->label("contact", catArray[i]); | 235 | cat = catDB->label("contact", catArray[i]); |
236 | if ( !cat.isEmpty() ) | 236 | if ( cat.isEmpty() ) |
237 | addr.insertCategory(QString::number(catArray[i])); | ||
238 | else | ||
237 | addr.insertCategory( cat ); | 239 | addr.insertCategory( cat ); |
238 | } | 240 | } |
239 | 241 | ||
240 | return true; | 242 | return true; |
241 | } | 243 | } |
@@ -250,6 +252,6 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &cont | |||
250 | contact.setSuffix(addr.suffix()); | 252 | contact.setSuffix(addr.suffix()); |
251 | contact.setFileAs(); | 253 | contact.setFileAs(); |
252 | 254 | ||
253 | 255 | ||
254 | 256 | ||
255 | QStringList emails = addr.emails(); | 257 | QStringList emails = addr.emails(); |
@@ -258,5 +260,5 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &cont | |||
258 | } | 260 | } |
259 | contact.setDefaultEmail( addr.preferredEmail() ); | 261 | contact.setDefaultEmail( addr.preferredEmail() ); |
260 | 262 | ||
261 | 263 | ||
262 | // home | 264 | // home |
@@ -273,15 +275,15 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &cont | |||
273 | if (!homephone.number().isEmpty()) | 275 | if (!homephone.number().isEmpty()) |
274 | contact.setHomePhone(homephone.number()); | 276 | contact.setHomePhone(homephone.number()); |
275 | 277 | ||
276 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); | 278 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); |
277 | if (!homefax.number().isEmpty()) | 279 | if (!homefax.number().isEmpty()) |
278 | contact.setHomeFax(homefax.number()); | 280 | contact.setHomeFax(homefax.number()); |
279 | 281 | ||
280 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); | 282 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); |
281 | if (!homemobile.number().isEmpty()) | 283 | if (!homemobile.number().isEmpty()) |
282 | contact.setHomeMobile(homemobile.number()); | 284 | contact.setHomeMobile(homemobile.number()); |
283 | 285 | ||
284 | contact.setHomeWebpage(addr.url().url()); | 286 | contact.setHomeWebpage(addr.url().url()); |
285 | 287 | ||
286 | 288 | ||
287 | // business | 289 | // business |
@@ -298,13 +300,13 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &cont | |||
298 | if (!businessphone.number().isEmpty()) | 300 | if (!businessphone.number().isEmpty()) |
299 | contact.setBusinessPhone(businessphone.number()); | 301 | contact.setBusinessPhone(businessphone.number()); |
300 | 302 | ||
301 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); | 303 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); |
302 | if (!businessfax.number().isEmpty()) | 304 | if (!businessfax.number().isEmpty()) |
303 | contact.setBusinessFax(businessfax.number()); | 305 | contact.setBusinessFax(businessfax.number()); |
304 | 306 | ||
305 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); | 307 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); |
306 | if (!businessmobile.number().isEmpty()) | 308 | if (!businessmobile.number().isEmpty()) |
307 | contact.setBusinessMobile(businessmobile.number()); | 309 | contact.setBusinessMobile(businessmobile.number()); |
308 | 310 | ||
309 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); | 311 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); |
310 | if (!businesspager.number().isEmpty()) | 312 | if (!businesspager.number().isEmpty()) |
@@ -332,11 +334,11 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &cont | |||
332 | contact.setGender(PimContact::UnspecifiedGender); | 334 | contact.setGender(PimContact::UnspecifiedGender); |
333 | 335 | ||
334 | 336 | ||
335 | QDate dt = KGlobal::locale()->readDate( | 337 | QDate dt = KGlobal::locale()->readDate( |
336 | addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate | 338 | addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate |
337 | contact.setAnniversary( dt ); | 339 | contact.setAnniversary( dt ); |
338 | 340 | ||
339 | contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); | 341 | contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); |
340 | 342 | ||
341 | contact.setBirthday(addr.birthday().date()); | 343 | contact.setBirthday(addr.birthday().date()); |
342 | contact.setNickname(addr.nickName()); | 344 | contact.setNickname(addr.nickName()); |
@@ -344,5 +346,5 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &cont | |||
344 | // other | 346 | // other |
345 | contact.setNotes(addr.note()); | 347 | contact.setNotes(addr.note()); |
346 | 348 | ||
347 | //US QString groups() const { return find( Qtopia::Groups ); } | 349 | //US QString groups() const { return find( Qtopia::Groups ); } |
348 | //US QStringList groupList() const; | 350 | //US QStringList groupList() const; |
@@ -350,5 +352,5 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &cont | |||
350 | 352 | ||
351 | QStringList cats = addr.categories(); | 353 | QStringList cats = addr.categories(); |
352 | 354 | ||
353 | QArray<int> iar; | 355 | QArray<int> iar; |
354 | if ( !cats.isEmpty() ) { | 356 | if ( !cats.isEmpty() ) { |
@@ -356,5 +358,5 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &cont | |||
356 | contact.setCategories(iar); | 358 | contact.setCategories(iar); |
357 | } | 359 | } |
358 | 360 | ||
359 | return true; | 361 | return true; |
360 | } | 362 | } |