author | ulf69 <ulf69> | 2004-07-14 14:55:56 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-07-14 14:55:56 (UTC) |
commit | f2779e5e7742103ce848ab11e6b9fe3661587f0b (patch) (side-by-side diff) | |
tree | f858743398b61aa21eca09abc6d85a34a7d3f436 /kabc | |
parent | cf7175c9a6b96cd11fb7f3cba459f5223aa4aacb (diff) | |
download | kdepimpi-f2779e5e7742103ce848ab11e6b9fe3661587f0b.zip kdepimpi-f2779e5e7742103ce848ab11e6b9fe3661587f0b.tar.gz kdepimpi-f2779e5e7742103ce848ab11e6b9fe3661587f0b.tar.bz2 |
added changes to support qtopia import/export and improved resource support
-rw-r--r-- | kabc/converter/opie/opieconverter.h | 4 | ||||
-rw-r--r-- | kabc/converter/qtopia/qtopiaconverter.cpp | 19 | ||||
-rw-r--r-- | kabc/converter/qtopia/qtopiaconverter.h | 4 |
3 files changed, 12 insertions, 15 deletions
diff --git a/kabc/converter/opie/opieconverter.h b/kabc/converter/opie/opieconverter.h index c7e691f..d251a24 100644 --- a/kabc/converter/opie/opieconverter.h +++ b/kabc/converter/opie/opieconverter.h @@ -30,50 +30,50 @@ $Id$ #include <qstring.h> #include "addressee.h" #include <opie/ocontact.h> class Categories; namespace KABC { class OpieConverter { public: /** * Constructor. */ OpieConverter(); /** * Destructor. */ virtual ~OpieConverter(); - virtual bool init(); - virtual void deinit(); + bool init(); + void deinit(); /** * Converts a vcard string to an addressee. * * @param contact The opie contact. * @param addr The addressee. */ bool opieToAddressee( const 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: Categories* catDB; }; } diff --git a/kabc/converter/qtopia/qtopiaconverter.cpp b/kabc/converter/qtopia/qtopiaconverter.cpp index e3dd3e6..f451b8b 100644 --- a/kabc/converter/qtopia/qtopiaconverter.cpp +++ b/kabc/converter/qtopia/qtopiaconverter.cpp @@ -28,57 +28,54 @@ $Id$ //US #include "kglobal.h" #include "qtopiaconverter.h" #include <qpe/categories.h> //US #include <qpe/categoryselect.h> using namespace KABC; QtopiaConverter::QtopiaConverter() : catDB(0) { } QtopiaConverter::~QtopiaConverter() { deinit(); } bool QtopiaConverter::init() { catDB = new Categories(); - if (catDB) - { - catDB->load( categoryFileName() ); - return true; - } - else - { + + if (!catDB) return false; - } + + catDB->load( categoryFileName() ); + return true; } void QtopiaConverter::deinit() { if (catDB) { delete catDB; catDB = 0; } } bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) { // name addr.setFormattedName(contact.fileAs()); addr.setFamilyName( contact.lastName() ); addr.setGivenName( contact.firstName() ); addr.setAdditionalName( contact.middleName() ); addr.setPrefix( contact.nameTitle() ); addr.setSuffix( contact.suffix() ); // email QStringList emails = contact.emailList(); @@ -188,79 +185,79 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a 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() ); //personal addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); // qtopia uses this categorization: // enum GenderType { UnspecifiedGender=0, Male, Female }; if (contact.gender() == PimContact::Male) addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); else if (contact.gender() == PimContact::Female) addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); if (contact.anniversary().isValid()) { QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); //US - qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1()); + qDebug("OpieConverter::qtopiaToAddressee found:%s", dt.latin1()); addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); } addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); if (contact.birthday().isValid()) addr.setBirthday( contact.birthday() ); addr.setNickName( contact.nickname() ); // 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; - + QArray<int> catArray = contact.categories(); QString cat; for ( unsigned int i=0; i < catArray.size(); i++ ) { cat = catDB->label("contact", catArray[i]); if ( !cat.isEmpty() ) addr.insertCategory( cat ); } - + return true; } bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact ) { // name contact.setLastName(addr.familyName()); contact.setFirstName(addr.givenName()); contact.setMiddleName(addr.additionalName()); contact.setNameTitle(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() ); // home const Address homeaddress = addr.address(Address::Home); diff --git a/kabc/converter/qtopia/qtopiaconverter.h b/kabc/converter/qtopia/qtopiaconverter.h index 7397113..8f4c698 100644 --- a/kabc/converter/qtopia/qtopiaconverter.h +++ b/kabc/converter/qtopia/qtopiaconverter.h @@ -29,50 +29,50 @@ $Id$ #include <qstring.h> #include "addressee.h" #include <qpe/pim/contact.h> class Categories; namespace KABC { class QtopiaConverter { public: /** * Constructor. */ QtopiaConverter(); /** * Destructor. */ virtual ~QtopiaConverter(); - virtual bool init(); - virtual void deinit(); + bool init(); + void deinit(); /** * Converts a vcard string to an addressee. * * @param contact The qtopia contact. * @param addr The addressee. */ bool qtopiaToAddressee( const PimContact &contact, Addressee &addr ); /** * Converts an addressee to a vcard string. * * @param addr The addressee. * @param contact The qtopia contact. */ bool addresseeToQtopia( const Addressee &addr, PimContact &contact ); private: Categories* catDB; }; } |