-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 @@ -135,77 +135,87 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) if (!contact.businessMobile().isEmpty()) { PhoneNumber businessmobile; businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); businessmobile.setNumber( contact.businessMobile() ); addr.insertPhoneNumber( businessmobile ); } if (!contact.businessPager().isEmpty()) { PhoneNumber businesspager; businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); businesspager.setNumber( contact.businessPager() ); addr.insertPhoneNumber( businesspager ); } addr.setRole( contact.jobTitle() ); //? addr.setOrganization( contact.company() ); addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); -//??? -//US QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } - //personal addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() ); - 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); + if (contact.anniversary().isValid()) { + int orgformat = KGlobal::locale()->getIntDateFormat(); + KGlobal::locale()->setIntDateFormat( 2 ); // = Qt::ISODate + QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true); +//US + qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1()); + KGlobal::locale()->setIntDateFormat(orgformat ); + addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); + } addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); - addr.setBirthday( contact.birthday() ); + if (contact.birthday().isValid()) + addr.setBirthday( contact.birthday() ); + addr.setNickName( contact.nickname() ); - // other + // others + //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. + QString notes = contact.notes(); + notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; + addr.setNote( contact.notes() ); + + //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") ); // qDebug("Groups: %s", contact.groups().latin1()); // addr.setCategories( contact.groupList() ); return true; } bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact ) { // 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); } @@ -290,36 +300,39 @@ bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact ) //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() ); + catDB.dump(); +//US catDB.load( contact.categoryFileName() ); + catDB.load( "contact" ); QStringList cats = addr.categories(); for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { - contact.setCategories(catDB.id(*it)); + qDebug("categories: %s", (*it).latin1()); +// contact.setCategories(catDB.id(*it)); } -*/ + return true; } |