summaryrefslogtreecommitdiffabout
path: root/kabc
authorulf69 <ulf69>2004-07-01 01:40:51 (UTC)
committer ulf69 <ulf69>2004-07-01 01:40:51 (UTC)
commit574570db1963fd729bb40a778ae3fc6a71ffc221 (patch) (side-by-side diff)
tree470b49c7c1de2c415edcfb7f4962a23d848b5280 /kabc
parent94a34390c1c3f6554e171760aa250186e6c8cfc9 (diff)
downloadkdepimpi-574570db1963fd729bb40a778ae3fc6a71ffc221.zip
kdepimpi-574570db1963fd729bb40a778ae3fc6a71ffc221.tar.gz
kdepimpi-574570db1963fd729bb40a778ae3fc6a71ffc221.tar.bz2
converter also supports now export
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/converter/opie/opieconverter.cpp149
-rw-r--r--kabc/converter/opie/opieconverter.h3
2 files changed, 139 insertions, 13 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
@@ -22,52 +22,56 @@
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
//US
#include "kglobal.h"
#include "opieconverter.h"
+#include <qpe/categories.h>
+
+
using namespace KABC;
OpieConverter::OpieConverter()
{
}
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() );
addr.setPrefix( contact.title() );
addr.setSuffix( contact.suffix() );
// email
QStringList emails = contact.emailList();
for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
}
+ addr.insertEmail(contact.defaultEmail(), true);
+
// home
Address homeaddress;
homeaddress.setType(Address::Home);
//US homeaddress.setPostOfficeBox( "" );
//US homeaddress.setExtended( "" );
homeaddress.setStreet( contact.homeStreet() );
homeaddress.setLocality( contact.homeCity() );
homeaddress.setRegion( contact.homeState() );
homeaddress.setPostalCode( contact.homeZip() );
homeaddress.setCountry( contact.homeCountry() );
addr.insertAddress( homeaddress );
@@ -149,25 +153,31 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
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() );
- 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() );
// other
addr.setNote( contact.notes() );
//US QString groups() const { return find( Qtopia::Groups ); }
//US QStringList groupList() const;
/*US
QStringList cats = contact.categoryNames("Contacts");
@@ -176,21 +186,140 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
}
*/
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 )
{
- 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;
+}
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
@@ -56,19 +56,16 @@ public:
* @param addr The addressee.
*/
bool opieToAddressee( OContact &contact, Addressee &addr );
/**
* Converts an addressee to a vcard string.
*
* @param addr The addressee.
* @param contact The opie contact.
*/
bool addresseeToOpie( const Addressee &addr, OContact &contact );
- private:
- QString dateToAddresseeString( const QDate &date );
-
};
}
#endif