summaryrefslogtreecommitdiffabout
path: root/kabc
authorulf69 <ulf69>2004-07-09 08:05:25 (UTC)
committer ulf69 <ulf69>2004-07-09 08:05:25 (UTC)
commit259a7a50e4f8138cedfc2004fbde3b37cedcc49f (patch) (unidiff)
treedfd2e89f169ba65ffd250f9b52f8f4efcd62d8b3 /kabc
parentd91c533ffc42d7bf48fa1326754894b2c30b6831 (diff)
downloadkdepimpi-259a7a50e4f8138cedfc2004fbde3b37cedcc49f.zip
kdepimpi-259a7a50e4f8138cedfc2004fbde3b37cedcc49f.tar.gz
kdepimpi-259a7a50e4f8138cedfc2004fbde3b37cedcc49f.tar.bz2
support for export of categories und supression of empty fields
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/converter/opie/opieconverter.cpp105
-rw-r--r--kabc/converter/opie/opieconverter.h11
2 files changed, 81 insertions, 35 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$
34#include <qpe/categories.h> 34#include <qpe/categories.h>
35#include <qpe/categoryselect.h>
35 36
@@ -38,3 +39,3 @@ using namespace KABC;
38 39
39OpieConverter::OpieConverter() 40OpieConverter::OpieConverter() : catDB(0)
40{ 41{
@@ -44,2 +45,27 @@ OpieConverter::~OpieConverter()
44{ 45{
46 deinit();
47}
48
49bool OpieConverter::init()
50{
51 catDB = new Categories();
52 if (catDB)
53 {
54 catDB->load( categoryFileName() );
55 return true;
56 }
57 else
58 {
59 return false;
60 }
61
62}
63
64void OpieConverter::deinit()
65{
66 if (catDB)
67 {
68 delete catDB;
69 catDB = 0;
70 }
45} 71}
@@ -63,16 +89,24 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
63 89
64 addr.insertEmail(contact.defaultEmail(), true); 90 if (!contact.defaultEmail().isEmpty())
91 addr.insertEmail(contact.defaultEmail(), true);
65 92
66 // home 93 // home
67 Address homeaddress; 94 if ((!contact.homeStreet().isEmpty()) ||
68 homeaddress.setType(Address::Home); 95 (!contact.homeCity().isEmpty()) ||
96 (!contact.homeState().isEmpty()) ||
97 (!contact.homeZip().isEmpty()) ||
98 (!contact.homeCountry().isEmpty()))
99 {
100 Address homeaddress;
101 homeaddress.setType(Address::Home);
69//US homeaddress.setPostOfficeBox( "" ); 102//US homeaddress.setPostOfficeBox( "" );
70//US homeaddress.setExtended( "" ); 103//US homeaddress.setExtended( "" );
71 homeaddress.setStreet( contact.homeStreet() ); 104 homeaddress.setStreet( contact.homeStreet() );
72 homeaddress.setLocality( contact.homeCity() ); 105 homeaddress.setLocality( contact.homeCity() );
73 homeaddress.setRegion( contact.homeState() ); 106 homeaddress.setRegion( contact.homeState() );
74 homeaddress.setPostalCode( contact.homeZip() ); 107 homeaddress.setPostalCode( contact.homeZip() );
75 homeaddress.setCountry( contact.homeCountry() ); 108 homeaddress.setCountry( contact.homeCountry() );
76 109
77 addr.insertAddress( homeaddress ); 110 addr.insertAddress( homeaddress );
111 }
78 112
@@ -106,14 +140,22 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
106 // business 140 // business
107 Address businessaddress; 141 if ((!contact.businessStreet().isEmpty()) ||
108 businessaddress.setType(Address::Work); 142 (!contact.businessCity().isEmpty()) ||
143 (!contact.businessState().isEmpty()) ||
144 (!contact.businessZip().isEmpty()) ||
145 (!contact.businessCountry().isEmpty()))
146 {
147 Address businessaddress;
148 businessaddress.setType(Address::Work);
109//US businessaddress.setPostOfficeBox( "" ); 149//US businessaddress.setPostOfficeBox( "" );
110//US businessaddress.setExtended( "" ); 150//US businessaddress.setExtended( "" );
111 businessaddress.setStreet( contact.businessStreet() ); 151 businessaddress.setStreet( contact.businessStreet() );
112 businessaddress.setLocality( contact.businessCity() ); 152 businessaddress.setLocality( contact.businessCity() );
113 businessaddress.setRegion( contact.businessState() ); 153 businessaddress.setRegion( contact.businessState() );
114 businessaddress.setPostalCode( contact.businessZip() ); 154 businessaddress.setPostalCode( contact.businessZip() );
115 businessaddress.setCountry( contact.businessCountry() ); 155 businessaddress.setCountry( contact.businessCountry() );
156
157 addr.insertAddress( businessaddress );
158 }
159
116 160
117 addr.insertAddress( businessaddress );
118
119 if (!contact.businessPhone().isEmpty()) 161 if (!contact.businessPhone().isEmpty())
@@ -163,8 +205,5 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
163 if (contact.anniversary().isValid()) { 205 if (contact.anniversary().isValid()) {
164 int orgformat = KGlobal::locale()->getIntDateFormat(); 206 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate);
165 KGlobal::locale()->setIntDateFormat( 2 ); // = Qt::ISODate
166 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true);
167//US 207//US
168 qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1()); 208 qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1());
169 KGlobal::locale()->setIntDateFormat(orgformat );
170 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 209 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
@@ -192,5 +231,5 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
192 QStringList cats = contact.categoryNames("Contacts"); 231 QStringList cats = contact.categoryNames("Contacts");
193 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { 232// for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
194 qDebug("Cat: %s", (*it).latin1()); 233// qDebug("Cat: %s", (*it).latin1());
195 } 234// }
196 235
@@ -325,12 +364,10 @@ bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact )
325 Categories catDB; 364 Categories catDB;
326 catDB.dump(); 365 catDB.load( categoryFileName() );
327//US catDB.load( contact.categoryFileName() );
328 catDB.load( "contact" );
329
330 QStringList cats = addr.categories(); 366 QStringList cats = addr.categories();
331 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
332 qDebug("categories: %s", (*it).latin1());
333// contact.setCategories(catDB.id(*it));
334 }
335 367
368 QArray<int> iar;
369 if ( !cats.isEmpty() ) {
370 QArray<int> iar = catDB.ids("contact", cats);
371 contact.setCategories(iar);
372 }
336 373
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$
35 35
36class Categories;
37
36namespace KABC { 38namespace KABC {
@@ -49,3 +51,6 @@ public:
49 */ 51 */
50 ~OpieConverter(); 52 virtual ~OpieConverter();
53
54 virtual bool init();
55 virtual void deinit();
51 56
@@ -66,3 +71,7 @@ public:
66 bool addresseeToOpie( const Addressee &addr, OContact &contact ); 71 bool addresseeToOpie( const Addressee &addr, OContact &contact );
72
73 private:
74 Categories* catDB;
67 75
76
68}; 77};