-rw-r--r-- | kabc/converter/opie/opieconverter.cpp | 69 | ||||
-rw-r--r-- | kabc/converter/opie/opieconverter.h | 11 |
2 files changed, 63 insertions, 17 deletions
diff --git a/kabc/converter/opie/opieconverter.cpp b/kabc/converter/opie/opieconverter.cpp index d785fbc..b4e9f1c 100644 --- a/kabc/converter/opie/opieconverter.cpp +++ b/kabc/converter/opie/opieconverter.cpp @@ -34,2 +34,3 @@ $Id$ #include <qpe/categories.h> +#include <qpe/categoryselect.h> @@ -38,3 +39,3 @@ using namespace KABC; -OpieConverter::OpieConverter() +OpieConverter::OpieConverter() : catDB(0) { @@ -44,2 +45,27 @@ OpieConverter::~OpieConverter() { + deinit(); +} + +bool OpieConverter::init() +{ + catDB = new Categories(); + if (catDB) + { + catDB->load( categoryFileName() ); + return true; + } + else + { + return false; + } + +} + +void OpieConverter::deinit() +{ + if (catDB) + { + delete catDB; + catDB = 0; + } } @@ -63,2 +89,3 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) + if (!contact.defaultEmail().isEmpty()) addr.insertEmail(contact.defaultEmail(), true); @@ -66,2 +93,8 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) // home + if ((!contact.homeStreet().isEmpty()) || + (!contact.homeCity().isEmpty()) || + (!contact.homeState().isEmpty()) || + (!contact.homeZip().isEmpty()) || + (!contact.homeCountry().isEmpty())) + { Address homeaddress; @@ -77,2 +110,3 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) addr.insertAddress( homeaddress ); + } @@ -106,2 +140,8 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) // business + if ((!contact.businessStreet().isEmpty()) || + (!contact.businessCity().isEmpty()) || + (!contact.businessState().isEmpty()) || + (!contact.businessZip().isEmpty()) || + (!contact.businessCountry().isEmpty())) + { Address businessaddress; @@ -117,2 +157,4 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) addr.insertAddress( businessaddress ); + } + @@ -163,8 +205,5 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) if (contact.anniversary().isValid()) { - int orgformat = KGlobal::locale()->getIntDateFormat(); - KGlobal::locale()->setIntDateFormat( 2 ); // = Qt::ISODate - QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true); + QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); //US qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1()); - KGlobal::locale()->setIntDateFormat(orgformat ); addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); @@ -192,5 +231,5 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) QStringList cats = contact.categoryNames("Contacts"); - for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { - qDebug("Cat: %s", (*it).latin1()); - } +// for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { +// qDebug("Cat: %s", (*it).latin1()); +// } @@ -325,12 +364,10 @@ bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact ) Categories catDB; - catDB.dump(); -//US catDB.load( contact.categoryFileName() ); - catDB.load( "contact" ); - + catDB.load( categoryFileName() ); QStringList cats = addr.categories(); - for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { - qDebug("categories: %s", (*it).latin1()); -// contact.setCategories(catDB.id(*it)); - } + QArray<int> iar; + if ( !cats.isEmpty() ) { + QArray<int> iar = catDB.ids("contact", cats); + contact.setCategories(iar); + } diff --git a/kabc/converter/opie/opieconverter.h b/kabc/converter/opie/opieconverter.h index ef7300b..7d2ad85 100644 --- a/kabc/converter/opie/opieconverter.h +++ b/kabc/converter/opie/opieconverter.h @@ -35,2 +35,4 @@ $Id$ +class Categories; + namespace KABC { @@ -49,3 +51,6 @@ public: */ - ~OpieConverter(); + virtual ~OpieConverter(); + + virtual bool init(); + virtual void deinit(); @@ -67,2 +72,6 @@ public: + private: + Categories* catDB; + + }; |