Diffstat (limited to 'kabc/converter/opie/opieconverter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/converter/opie/opieconverter.cpp | 149 |
1 files changed, 139 insertions, 10 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$ #include "opieconverter.h" +#include <qpe/categories.h> + + using namespace KABC; OpieConverter::OpieConverter() @@ -44,8 +47,7 @@ OpieConverter::~OpieConverter() bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) { // name -//US QString fileAs() const { return find( Qtopia::FileAs ); } - + addr.setFormattedName(contact.fileAs()); addr.setFamilyName( contact.lastName() ); addr.setGivenName( contact.firstName() ); addr.setAdditionalName( contact.middleName() ); @@ -59,6 +61,8 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); } + addr.insertEmail(contact.defaultEmail(), true); + // home Address homeaddress; homeaddress.setType(Address::Home); @@ -158,7 +162,13 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) //personal addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() ); - addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dateToAddresseeString(contact.anniversary()) ); + + int orgformat = KGlobal::locale()->getIntDateFormat(); + KGlobal::locale()->setIntDateFormat( 2 ); // = Qt::ISODate + QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true); + KGlobal::locale()->setIntDateFormat(orgformat ); + addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); + addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); addr.setBirthday( contact.birthday() ); addr.setNickName( contact.nickname() ); @@ -185,12 +195,131 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact ) { - return false; -} + // name + contact.setLastName(addr.familyName()); + contact.setFirstName(addr.givenName()); + contact.setMiddleName(addr.additionalName()); + contact.setTitle(addr.prefix()); + contact.setSuffix(addr.suffix()); + contact.setFileAs(); + + + // email + QStringList emails = addr.emails(); + for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { + contact.insertEmail(*it); + } + contact.setDefaultEmail( addr.preferredEmail() ); + -QString OpieConverter::dateToAddresseeString( const QDate &date ) -{ - return KGlobal::locale()->formatDate(date, true); -//US return date.toString("yyyyMMdd"); -} + // home + const Address homeaddress = addr.address(Address::Home); + if (!homeaddress.isEmpty()) { + contact.setHomeStreet(homeaddress.street()); + contact.setHomeCity(homeaddress.locality()); + contact.setHomeState(homeaddress.region()); + contact.setHomeZip(homeaddress.postalCode()); + contact.setHomeCountry(homeaddress.country()); + } + + PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); + if (!homephone.number().isEmpty()) + contact.setHomePhone(homephone.number()); + + PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); + if (!homefax.number().isEmpty()) + contact.setHomeFax(homefax.number()); + + PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); + if (!homemobile.number().isEmpty()) + contact.setHomeMobile(homemobile.number()); + + contact.setHomeWebpage(addr.url().url()); + + + // business + const Address businessaddress = addr.address(Address::Work); + if (!businessaddress.isEmpty()) { + contact.setBusinessStreet(businessaddress.street()); + contact.setBusinessCity(businessaddress.locality()); + contact.setBusinessState(businessaddress.region()); + contact.setBusinessZip(businessaddress.postalCode()); + contact.setBusinessCountry(businessaddress.country()); + } + + PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); + if (!businessphone.number().isEmpty()) + contact.setBusinessPhone(businessphone.number()); + + PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); + if (!businessfax.number().isEmpty()) + contact.setBusinessFax(businessfax.number()); + + PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); + if (!businessmobile.number().isEmpty()) + contact.setBusinessMobile(businessmobile.number()); + + PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); + if (!businesspager.number().isEmpty()) + contact.setBusinessPager(businesspager.number()); + contact.setJobTitle(addr.role()); + contact.setCompany(addr.organization()); + + contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" )); + contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); + contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" )); + contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" )); + contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" )); + + //personal + contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" )); + contact.setGender(addr.custom( "KADDRESSBOOK", "X-Gender" )); + + QDate dt = KGlobal::locale()->readDate( + addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate + contact.setAnniversary( dt ); + + contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); + + contact.setBirthday(addr.birthday().date()); + contact.setNickname(addr.nickName()); + + // other + contact.setNotes(addr.note()); + +//US QString groups() const { return find( Qtopia::Groups ); } +//US QStringList groupList() const; + +/*US + QStringList cats = contact.categoryNames("Contacts"); + for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { + qDebug("Cat: %s", (*it).latin1()); + } +*/ + +// addr.setCategories( contact.categoryNames("Contacts") ); +// contact.categoryNames("Contacts"); +// contact.setCategoryNames(addr.categories()); + +/*US + QStringList cats = addr.categories(); + QArray<int> cat(cats.count()); + int counter = 0; + for ( QStringList::ConstIterator it = cats.begin(); it != cats.end(); ++it ) + cat[counter] = (*it).toInt(); + + contact.setCategories( cat ); +*/ +/*US + Categories catDB; + catDB.load( contact.categoryFileName() ); + + QStringList cats = addr.categories(); + for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { + contact.setCategories(catDB.id(*it)); + } +*/ + + return true; +} |