summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kabc/converter/opie/opieconverter.cpp69
-rw-r--r--kabc/converter/opie/opieconverter.h11
-rw-r--r--kaddressbook/xxport/opie/opie_xxport.cpp14
-rw-r--r--kaddressbook/xxport/opie/opie_xxportE.pro3
4 files changed, 77 insertions, 20 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
@@ -33,9 +33,10 @@ $Id$
#include <qpe/categories.h>
+#include <qpe/categoryselect.h>
using namespace KABC;
-OpieConverter::OpieConverter()
+OpieConverter::OpieConverter() : catDB(0)
{
}
@@ -43,4 +44,29 @@ OpieConverter::OpieConverter()
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;
+ }
}
@@ -62,7 +88,14 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
}
+ if (!contact.defaultEmail().isEmpty())
addr.insertEmail(contact.defaultEmail(), true);
// home
+ if ((!contact.homeStreet().isEmpty()) ||
+ (!contact.homeCity().isEmpty()) ||
+ (!contact.homeState().isEmpty()) ||
+ (!contact.homeZip().isEmpty()) ||
+ (!contact.homeCountry().isEmpty()))
+ {
Address homeaddress;
homeaddress.setType(Address::Home);
@@ -76,4 +109,5 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
addr.insertAddress( homeaddress );
+ }
if (!contact.homePhone().isEmpty())
@@ -105,4 +139,10 @@ 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;
businessaddress.setType(Address::Work);
@@ -116,4 +156,6 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
addr.insertAddress( businessaddress );
+ }
+
if (!contact.businessPhone().isEmpty())
@@ -162,10 +204,7 @@ 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);
}
@@ -191,7 +230,7 @@ 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());
+// }
@@ -324,14 +363,12 @@ 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);
+ }
return true;
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
@@ -34,4 +34,6 @@ $Id$
#include <opie/ocontact.h>
+class Categories;
+
namespace KABC {
@@ -48,5 +50,8 @@ public:
* Destructor.
*/
- ~OpieConverter();
+ virtual ~OpieConverter();
+
+ virtual bool init();
+ virtual void deinit();
/**
@@ -66,4 +71,8 @@ public:
bool addresseeToOpie( const Addressee &addr, OContact &contact );
+ private:
+ Categories* catDB;
+
+
};
diff --git a/kaddressbook/xxport/opie/opie_xxport.cpp b/kaddressbook/xxport/opie/opie_xxport.cpp
index d1def18..8ee0725 100644
--- a/kaddressbook/xxport/opie/opie_xxport.cpp
+++ b/kaddressbook/xxport/opie/opie_xxport.cpp
@@ -108,4 +108,16 @@ bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString
}
+ KABC::OpieConverter mConverter;
+
+ bool res = mConverter.init();
+ if (!res)
+ {
+ QString text( i18n( "Unable to initialize opie converter.<br>Most likely a problem with the category file." ) );
+ qDebug(text);
+ KMessageBox::error( parentWidget(), text );
+ delete access;
+ return false;
+ }
+
//Now check if the file has already entries, and ask the user if he wants to delete them first.
OContactAccess::List contactList = access->allRecords();
@@ -119,6 +131,4 @@ bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString
}
- KABC::OpieConverter mConverter;
- bool res;
KABC::Addressee::List::ConstIterator it;
diff --git a/kaddressbook/xxport/opie/opie_xxportE.pro b/kaddressbook/xxport/opie/opie_xxportE.pro
index a660a48..c373e37 100644
--- a/kaddressbook/xxport/opie/opie_xxportE.pro
+++ b/kaddressbook/xxport/opie/opie_xxportE.pro
@@ -9,6 +9,7 @@ DESTDIR = $(QPEDIR)/lib
DEFINES += KAB_EMBEDDED
-INCLUDEPATH += ../.. ../../.. ../../../kabc ../../../kabc/converter/opie ../../../microkde ../../../microkde/kdeui ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(QPEDIR)/include
+INCLUDEPATH += ../.. ../../.. ../../../kabc ../../../kabc/converter/opie ../../../microkde ../../../microkde/kdeui ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(OPIEDIR)/include
LIBS += -L$(QPEDIR)/lib
+LIBS += -L$(OPIEDIR)/lib
LIBS += -lmicrokde
LIBS += -lmicrokabc