summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kabc/converter/opie/opieconverter.cpp145
-rw-r--r--kabc/converter/opie/opieconverter.h3
2 files changed, 137 insertions, 11 deletions
diff --git a/kabc/converter/opie/opieconverter.cpp b/kabc/converter/opie/opieconverter.cpp
index fbb5817..cfbe5c0 100644
--- a/kabc/converter/opie/opieconverter.cpp
+++ b/kabc/converter/opie/opieconverter.cpp
@@ -31,6 +31,9 @@ $Id$
31 31
32#include "opieconverter.h" 32#include "opieconverter.h"
33 33
34#include <qpe/categories.h>
35
36
34using namespace KABC; 37using namespace KABC;
35 38
36OpieConverter::OpieConverter() 39OpieConverter::OpieConverter()
@@ -44,8 +47,7 @@ OpieConverter::~OpieConverter()
44bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) 47bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
45{ 48{
46 // name 49 // name
47//US QString fileAs() const { return find( Qtopia::FileAs ); } 50 addr.setFormattedName(contact.fileAs());
48
49 addr.setFamilyName( contact.lastName() ); 51 addr.setFamilyName( contact.lastName() );
50 addr.setGivenName( contact.firstName() ); 52 addr.setGivenName( contact.firstName() );
51 addr.setAdditionalName( contact.middleName() ); 53 addr.setAdditionalName( contact.middleName() );
@@ -59,6 +61,8 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
59 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); 61 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
60 } 62 }
61 63
64 addr.insertEmail(contact.defaultEmail(), true);
65
62 // home 66 // home
63 Address homeaddress; 67 Address homeaddress;
64 homeaddress.setType(Address::Home); 68 homeaddress.setType(Address::Home);
@@ -158,7 +162,13 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
158 //personal 162 //personal
159 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); 163 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() );
160 addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() ); 164 addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() );
161 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dateToAddresseeString(contact.anniversary()) ); 165
166 int orgformat = KGlobal::locale()->getIntDateFormat();
167 KGlobal::locale()->setIntDateFormat( 2 ); // = Qt::ISODate
168 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true);
169 KGlobal::locale()->setIntDateFormat(orgformat );
170 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
171
162 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); 172 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() );
163 addr.setBirthday( contact.birthday() ); 173 addr.setBirthday( contact.birthday() );
164 addr.setNickName( contact.nickname() ); 174 addr.setNickName( contact.nickname() );
@@ -185,12 +195,131 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
185 195
186bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact ) 196bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact )
187{ 197{
188 return false; 198 // name
199 contact.setLastName(addr.familyName());
200 contact.setFirstName(addr.givenName());
201 contact.setMiddleName(addr.additionalName());
202 contact.setTitle(addr.prefix());
203 contact.setSuffix(addr.suffix());
204 contact.setFileAs();
205
206
207 // email
208 QStringList emails = addr.emails();
209 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
210 contact.insertEmail(*it);
189} 211}
212 contact.setDefaultEmail( addr.preferredEmail() );
190 213
191QString OpieConverter::dateToAddresseeString( const QDate &date ) 214
192{ 215 // home
193 return KGlobal::locale()->formatDate(date, true); 216 const Address homeaddress = addr.address(Address::Home);
194//US return date.toString("yyyyMMdd"); 217 if (!homeaddress.isEmpty()) {
218 contact.setHomeStreet(homeaddress.street());
219 contact.setHomeCity(homeaddress.locality());
220 contact.setHomeState(homeaddress.region());
221 contact.setHomeZip(homeaddress.postalCode());
222 contact.setHomeCountry(homeaddress.country());
195} 223}
196 224
225 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
226 if (!homephone.number().isEmpty())
227 contact.setHomePhone(homephone.number());
228
229 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
230 if (!homefax.number().isEmpty())
231 contact.setHomeFax(homefax.number());
232
233 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
234 if (!homemobile.number().isEmpty())
235 contact.setHomeMobile(homemobile.number());
236
237 contact.setHomeWebpage(addr.url().url());
238
239
240 // business
241 const Address businessaddress = addr.address(Address::Work);
242 if (!businessaddress.isEmpty()) {
243 contact.setBusinessStreet(businessaddress.street());
244 contact.setBusinessCity(businessaddress.locality());
245 contact.setBusinessState(businessaddress.region());
246 contact.setBusinessZip(businessaddress.postalCode());
247 contact.setBusinessCountry(businessaddress.country());
248 }
249
250 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work );
251 if (!businessphone.number().isEmpty())
252 contact.setBusinessPhone(businessphone.number());
253
254 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax );
255 if (!businessfax.number().isEmpty())
256 contact.setBusinessFax(businessfax.number());
257
258 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell );
259 if (!businessmobile.number().isEmpty())
260 contact.setBusinessMobile(businessmobile.number());
261
262 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
263 if (!businesspager.number().isEmpty())
264 contact.setBusinessPager(businesspager.number());
265
266 contact.setJobTitle(addr.role());
267 contact.setCompany(addr.organization());
268
269 contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" ));
270 contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" ));
271 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" ));
272 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
273 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" ));
274
275 //personal
276 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" ));
277 contact.setGender(addr.custom( "KADDRESSBOOK", "X-Gender" ));
278
279 QDate dt = KGlobal::locale()->readDate(
280 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate
281 contact.setAnniversary( dt );
282
283 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" ));
284
285 contact.setBirthday(addr.birthday().date());
286 contact.setNickname(addr.nickName());
287
288 // other
289 contact.setNotes(addr.note());
290
291//US QString groups() const { return find( Qtopia::Groups ); }
292//US QStringList groupList() const;
293
294/*US
295 QStringList cats = contact.categoryNames("Contacts");
296 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
297 qDebug("Cat: %s", (*it).latin1());
298 }
299*/
300
301// addr.setCategories( contact.categoryNames("Contacts") );
302// contact.categoryNames("Contacts");
303// contact.setCategoryNames(addr.categories());
304
305/*US
306 QStringList cats = addr.categories();
307 QArray<int> cat(cats.count());
308 int counter = 0;
309 for ( QStringList::ConstIterator it = cats.begin(); it != cats.end(); ++it )
310 cat[counter] = (*it).toInt();
311
312 contact.setCategories( cat );
313*/
314/*US
315 Categories catDB;
316 catDB.load( contact.categoryFileName() );
317
318 QStringList cats = addr.categories();
319 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
320 contact.setCategories(catDB.id(*it));
321 }
322*/
323
324 return true;
325}
diff --git a/kabc/converter/opie/opieconverter.h b/kabc/converter/opie/opieconverter.h
index 55a869a..ef7300b 100644
--- a/kabc/converter/opie/opieconverter.h
+++ b/kabc/converter/opie/opieconverter.h
@@ -65,9 +65,6 @@ public:
65 */ 65 */
66 bool addresseeToOpie( const Addressee &addr, OContact &contact ); 66 bool addresseeToOpie( const Addressee &addr, OContact &contact );
67 67
68 private:
69 QString dateToAddresseeString( const QDate &date );
70
71}; 68};
72 69
73} 70}