summaryrefslogtreecommitdiffabout
path: root/kabc/converter
authorulf69 <ulf69>2004-07-13 15:04:53 (UTC)
committer ulf69 <ulf69>2004-07-13 15:04:53 (UTC)
commitf88d48384d2c012fbaa3ffaa613d6eaa3694fab7 (patch) (unidiff)
treec96af4b67257a2a2021ba0601042ce77aff9d69d /kabc/converter
parent2450dd81505b6212ec5bf59c168b53c52bd08f53 (diff)
downloadkdepimpi-f88d48384d2c012fbaa3ffaa613d6eaa3694fab7.zip
kdepimpi-f88d48384d2c012fbaa3ffaa613d6eaa3694fab7.tar.gz
kdepimpi-f88d48384d2c012fbaa3ffaa613d6eaa3694fab7.tar.bz2
intial implementation of the qtopia converter
Diffstat (limited to 'kabc/converter') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/converter/qtopia/qtopiaE.pro12
-rw-r--r--kabc/converter/qtopia/qtopiaconverter.cpp52
-rw-r--r--kabc/converter/qtopia/qtopiaconverter.h4
3 files changed, 38 insertions, 30 deletions
diff --git a/kabc/converter/qtopia/qtopiaE.pro b/kabc/converter/qtopia/qtopiaE.pro
index e026f2a..4241b8b 100644
--- a/kabc/converter/qtopia/qtopiaE.pro
+++ b/kabc/converter/qtopia/qtopiaE.pro
@@ -1,8 +1,8 @@
1TEMPLATE = lib 1TEMPLATE = lib
2INCLUDEPATH += . ../.. ../../../microkde ../../../microkde/kdecore $(OPIEDIR)/include $(OPEDIR)/include 2INCLUDEPATH += . ../.. ../../../microkde ../../../microkde/kdecore $(QPEDIR)/include
3#CONFIG += staticlib 3#CONFIG += staticlib
4OBJECTS_DIR = obj/$(PLATFORM) 4OBJECTS_DIR = obj/$(PLATFORM)
5MOC_DIR = moc/$(PLATFORM) 5MOC_DIR = moc/$(PLATFORM)
6 6
7#for static linkage, put it here 7#for static linkage, put it here
8#DESTDIR=../../lib/$(PLATFORM) 8#DESTDIR=../../lib/$(PLATFORM)
@@ -11,22 +11,20 @@ MOC_DIR = moc/$(PLATFORM)
11DESTDIR=$(QPEDIR)/lib 11DESTDIR=$(QPEDIR)/lib
12 12
13LIBS += -lmicrokde 13LIBS += -lmicrokde
14LIBS += -lmicrokabc 14LIBS += -lmicrokabc
15LIBS += -L$(QPEDIR)/lib 15LIBS += -L$(QPEDIR)/lib
16LIBS += -L$(OPIEDIR)/lib 16LIBS += -L$(OPIEDIR)/lib
17LIBS += -lopie 17LIBS += -lqpepim
18LIBS += -lqpe 18LIBS += -lqpe
19LIBS += -lqte
20 19
21 20TARGET = microkabc_qtopiaconverter
22TARGET = microkabc_opieconverter
23 21
24# Input 22# Input
25 23
26HEADERS += \ 24HEADERS += \
27 opieconverter.h \ 25 qtopiaconverter.h \
28 26
29 27
30SOURCES += \ 28SOURCES += \
31 opieconverter.cpp \ 29 qtopiaconverter.cpp \
32 30
diff --git a/kabc/converter/qtopia/qtopiaconverter.cpp b/kabc/converter/qtopia/qtopiaconverter.cpp
index 7aa76fe..e3dd3e6 100644
--- a/kabc/converter/qtopia/qtopiaconverter.cpp
+++ b/kabc/converter/qtopia/qtopiaconverter.cpp
@@ -28,13 +28,13 @@ $Id$
28//US 28//US
29#include "kglobal.h" 29#include "kglobal.h"
30 30
31 31
32#include "qtopiaconverter.h" 32#include "qtopiaconverter.h"
33 33
34//US #include <qpe/categories.h> 34#include <qpe/categories.h>
35//US #include <qpe/categoryselect.h> 35//US #include <qpe/categoryselect.h>
36 36
37 37
38using namespace KABC; 38using namespace KABC;
39 39
40QtopiaConverter::QtopiaConverter() : catDB(0) 40QtopiaConverter::QtopiaConverter() : catDB(0)
@@ -45,46 +45,41 @@ QtopiaConverter::~QtopiaConverter()
45{ 45{
46 deinit(); 46 deinit();
47} 47}
48 48
49bool QtopiaConverter::init() 49bool QtopiaConverter::init()
50{ 50{
51/*US
52 catDB = new Categories(); 51 catDB = new Categories();
53 if (catDB) 52 if (catDB)
54 { 53 {
55 catDB->load( categoryFileName() ); 54 catDB->load( categoryFileName() );
56 return true; 55 return true;
57 } 56 }
58 else 57 else
59 { 58 {
60 return false; 59 return false;
61 } 60 }
62*/
63return true;
64} 61}
65 62
66void QtopiaConverter::deinit() 63void QtopiaConverter::deinit()
67{ 64{
68/*US
69 if (catDB) 65 if (catDB)
70 { 66 {
71 delete catDB; 67 delete catDB;
72 catDB = 0; 68 catDB = 0;
73 } 69 }
74*/
75} 70}
76 71
77bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) 72bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr )
78{ 73{
79 // name 74 // name
80 addr.setFormattedName(contact.fileAs()); 75 addr.setFormattedName(contact.fileAs());
81 addr.setFamilyName( contact.lastName() ); 76 addr.setFamilyName( contact.lastName() );
82 addr.setGivenName( contact.firstName() ); 77 addr.setGivenName( contact.firstName() );
83 addr.setAdditionalName( contact.middleName() ); 78 addr.setAdditionalName( contact.middleName() );
84 addr.setPrefix( contact.title() ); 79 addr.setPrefix( contact.nameTitle() );
85 addr.setSuffix( contact.suffix() ); 80 addr.setSuffix( contact.suffix() );
86 81
87 82
88 // email 83 // email
89 QStringList emails = contact.emailList(); 84 QStringList emails = contact.emailList();
90 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 85 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
@@ -201,14 +196,19 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a
201 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); 196 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() );
202 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); 197 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() );
203 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); 198 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() );
204 199
205 //personal 200 //personal
206 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); 201 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() );
207 addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() ); 202 // qtopia uses this categorization:
208 203 // enum GenderType { UnspecifiedGender=0, Male, Female };
204 if (contact.gender() == PimContact::Male)
205 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
206 else if (contact.gender() == PimContact::Female)
207 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
208
209 if (contact.anniversary().isValid()) { 209 if (contact.anniversary().isValid()) {
210 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); 210 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate);
211//US 211//US
212 qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1()); 212 qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1());
213 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 213 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
214 } 214 }
@@ -228,29 +228,31 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a
228 228
229 229
230 230
231//US QString groups() const { return find( Qtopia::Groups ); } 231//US QString groups() const { return find( Qtopia::Groups ); }
232//US QStringList groupList() const; 232//US QStringList groupList() const;
233 233
234 234 QArray<int> catArray = contact.categories();
235 QStringList cats = contact.categoryNames("Contacts"); 235 QString cat;
236 addr.setCategories( cats ); 236
237// for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { 237 for ( unsigned int i=0; i < catArray.size(); i++ ) {
238// qDebug("Cat: %s", (*it).latin1()); 238 cat = catDB->label("contact", catArray[i]);
239// } 239 if ( !cat.isEmpty() )
240 addr.insertCategory( cat );
241 }
240 242
241 return true; 243 return true;
242} 244}
243 245
244bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact ) 246bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact )
245{ 247{
246 // name 248 // name
247 contact.setLastName(addr.familyName()); 249 contact.setLastName(addr.familyName());
248 contact.setFirstName(addr.givenName()); 250 contact.setFirstName(addr.givenName());
249 contact.setMiddleName(addr.additionalName()); 251 contact.setMiddleName(addr.additionalName());
250 contact.setTitle(addr.prefix()); 252 contact.setNameTitle(addr.prefix());
251 contact.setSuffix(addr.suffix()); 253 contact.setSuffix(addr.suffix());
252 contact.setFileAs(); 254 contact.setFileAs();
253 255
254 256
255 // email 257 // email
256 QStringList emails = addr.emails(); 258 QStringList emails = addr.emails();
@@ -319,14 +321,23 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &cont
319 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" )); 321 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" ));
320 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" )); 322 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
321 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" )); 323 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" ));
322 324
323 //personal 325 //personal
324 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" )); 326 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" ));
325 contact.setGender(addr.custom( "KADDRESSBOOK", "X-Gender" )); 327 // qtopia uses this categorization:
326 328 // enum GenderType { UnspecifiedGender=0, Male, Female };
329 QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" );
330 if (gt = "male")
331 contact.setGender(PimContact::Male);
332 else if (gt = "female")
333 contact.setGender(PimContact::Female);
334 else
335 contact.setGender(PimContact::UnspecifiedGender);
336
337
327 QDate dt = KGlobal::locale()->readDate( 338 QDate dt = KGlobal::locale()->readDate(
328 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate 339 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate
329 contact.setAnniversary( dt ); 340 contact.setAnniversary( dt );
330 341
331 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); 342 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" ));
332 343
@@ -337,17 +348,16 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &cont
337 contact.setNotes(addr.note()); 348 contact.setNotes(addr.note());
338 349
339//US QString groups() const { return find( Qtopia::Groups ); } 350//US QString groups() const { return find( Qtopia::Groups ); }
340//US QStringList groupList() const; 351//US QStringList groupList() const;
341 352
342 353
343/*US
344 QStringList cats = addr.categories(); 354 QStringList cats = addr.categories();
345 355
346 QArray<int> iar; 356 QArray<int> iar;
347 if ( !cats.isEmpty() ) { 357 if ( !cats.isEmpty() ) {
348 QArray<int> iar = catDB.ids("contact", cats); 358 QArray<int> iar = catDB->ids("contact", cats);
349 contact.setCategories(iar); 359 contact.setCategories(iar);
350 } 360 }
351*/ 361
352 return true; 362 return true;
353} 363}
diff --git a/kabc/converter/qtopia/qtopiaconverter.h b/kabc/converter/qtopia/qtopiaconverter.h
index aaa267a..7397113 100644
--- a/kabc/converter/qtopia/qtopiaconverter.h
+++ b/kabc/converter/qtopia/qtopiaconverter.h
@@ -29,13 +29,13 @@ $Id$
29 29
30#include <qstring.h> 30#include <qstring.h>
31 31
32#include "addressee.h" 32#include "addressee.h"
33#include <qpe/pim/contact.h> 33#include <qpe/pim/contact.h>
34 34
35//US class Categories; 35class Categories;
36 36
37namespace KABC { 37namespace KABC {
38 38
39class QtopiaConverter 39class QtopiaConverter
40{ 40{
41public: 41public:
@@ -67,13 +67,13 @@ public:
67 * @param addr The addressee. 67 * @param addr The addressee.
68 * @param contact The qtopia contact. 68 * @param contact The qtopia contact.
69 */ 69 */
70 bool addresseeToQtopia( const Addressee &addr, PimContact &contact ); 70 bool addresseeToQtopia( const Addressee &addr, PimContact &contact );
71 71
72 private: 72 private:
73//US Categories* catDB; 73 Categories* catDB;
74 74
75 75
76}; 76};
77 77
78} 78}
79#endif 79#endif