summaryrefslogtreecommitdiffabout
path: root/kabc/converter
authorulf69 <ulf69>2004-07-01 01:40:51 (UTC)
committer ulf69 <ulf69>2004-07-01 01:40:51 (UTC)
commit574570db1963fd729bb40a778ae3fc6a71ffc221 (patch) (unidiff)
tree470b49c7c1de2c415edcfb7f4962a23d848b5280 /kabc/converter
parent94a34390c1c3f6554e171760aa250186e6c8cfc9 (diff)
downloadkdepimpi-574570db1963fd729bb40a778ae3fc6a71ffc221.zip
kdepimpi-574570db1963fd729bb40a778ae3fc6a71ffc221.tar.gz
kdepimpi-574570db1963fd729bb40a778ae3fc6a71ffc221.tar.bz2
converter also supports now export
Diffstat (limited to 'kabc/converter') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/converter/opie/opieconverter.cpp149
-rw-r--r--kabc/converter/opie/opieconverter.h3
2 files changed, 139 insertions, 13 deletions
diff --git a/kabc/converter/opie/opieconverter.cpp b/kabc/converter/opie/opieconverter.cpp
index fbb5817..cfbe5c0 100644
--- a/kabc/converter/opie/opieconverter.cpp
+++ b/kabc/converter/opie/opieconverter.cpp
@@ -30,8 +30,11 @@ $Id$
30 30
31 31
32#include "opieconverter.h" 32#include "opieconverter.h"
33 33
34#include <qpe/categories.h>
35
36
34using namespace KABC; 37using namespace KABC;
35 38
36OpieConverter::OpieConverter() 39OpieConverter::OpieConverter()
37{ 40{
@@ -43,10 +46,9 @@ OpieConverter::~OpieConverter()
43 46
44bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) 47bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
45{ 48{
46 // name 49 // name
47//US QString fileAs() const { return find( Qtopia::FileAs ); } 50 addr.setFormattedName(contact.fileAs());
48
49 addr.setFamilyName( contact.lastName() ); 51 addr.setFamilyName( contact.lastName() );
50 addr.setGivenName( contact.firstName() ); 52 addr.setGivenName( contact.firstName() );
51 addr.setAdditionalName( contact.middleName() ); 53 addr.setAdditionalName( contact.middleName() );
52 addr.setPrefix( contact.title() ); 54 addr.setPrefix( contact.title() );
@@ -58,8 +60,10 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
58 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 60 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
59 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); 61 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
60 } 62 }
61 63
64 addr.insertEmail(contact.defaultEmail(), true);
65
62 // home 66 // home
63 Address homeaddress; 67 Address homeaddress;
64 homeaddress.setType(Address::Home); 68 homeaddress.setType(Address::Home);
65//US homeaddress.setPostOfficeBox( "" ); 69//US homeaddress.setPostOfficeBox( "" );
@@ -157,9 +161,15 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
157 161
158 //personal 162 //personal
159 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); 163 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() );
160 addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() ); 164 addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() );
161 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dateToAddresseeString(contact.anniversary()) ); 165
166 int orgformat = KGlobal::locale()->getIntDateFormat();
167 KGlobal::locale()->setIntDateFormat( 2 ); // = Qt::ISODate
168 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true);
169 KGlobal::locale()->setIntDateFormat(orgformat );
170 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
171
162 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); 172 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() );
163 addr.setBirthday( contact.birthday() ); 173 addr.setBirthday( contact.birthday() );
164 addr.setNickName( contact.nickname() ); 174 addr.setNickName( contact.nickname() );
165 175
@@ -184,13 +194,132 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
184} 194}
185 195
186bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact ) 196bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact )
187{ 197{
188 return false; 198 // name
189} 199 contact.setLastName(addr.familyName());
200 contact.setFirstName(addr.givenName());
201 contact.setMiddleName(addr.additionalName());
202 contact.setTitle(addr.prefix());
203 contact.setSuffix(addr.suffix());
204 contact.setFileAs();
205
206
207 // email
208 QStringList emails = addr.emails();
209 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
210 contact.insertEmail(*it);
211 }
212 contact.setDefaultEmail( addr.preferredEmail() );
213
190 214
191QString OpieConverter::dateToAddresseeString( const QDate &date ) 215 // home
192{ 216 const Address homeaddress = addr.address(Address::Home);
193 return KGlobal::locale()->formatDate(date, true); 217 if (!homeaddress.isEmpty()) {
194//US return date.toString("yyyyMMdd"); 218 contact.setHomeStreet(homeaddress.street());
195} 219 contact.setHomeCity(homeaddress.locality());
220 contact.setHomeState(homeaddress.region());
221 contact.setHomeZip(homeaddress.postalCode());
222 contact.setHomeCountry(homeaddress.country());
223 }
224
225 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
226 if (!homephone.number().isEmpty())
227 contact.setHomePhone(homephone.number());
228
229 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
230 if (!homefax.number().isEmpty())
231 contact.setHomeFax(homefax.number());
232
233 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
234 if (!homemobile.number().isEmpty())
235 contact.setHomeMobile(homemobile.number());
236
237 contact.setHomeWebpage(addr.url().url());
238
239
240 // business
241 const Address businessaddress = addr.address(Address::Work);
242 if (!businessaddress.isEmpty()) {
243 contact.setBusinessStreet(businessaddress.street());
244 contact.setBusinessCity(businessaddress.locality());
245 contact.setBusinessState(businessaddress.region());
246 contact.setBusinessZip(businessaddress.postalCode());
247 contact.setBusinessCountry(businessaddress.country());
248 }
249
250 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work );
251 if (!businessphone.number().isEmpty())
252 contact.setBusinessPhone(businessphone.number());
253
254 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax );
255 if (!businessfax.number().isEmpty())
256 contact.setBusinessFax(businessfax.number());
257
258 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell );
259 if (!businessmobile.number().isEmpty())
260 contact.setBusinessMobile(businessmobile.number());
261
262 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
263 if (!businesspager.number().isEmpty())
264 contact.setBusinessPager(businesspager.number());
196 265
266 contact.setJobTitle(addr.role());
267 contact.setCompany(addr.organization());
268
269 contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" ));
270 contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" ));
271 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" ));
272 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
273 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" ));
274
275 //personal
276 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" ));
277 contact.setGender(addr.custom( "KADDRESSBOOK", "X-Gender" ));
278
279 QDate dt = KGlobal::locale()->readDate(
280 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate
281 contact.setAnniversary( dt );
282
283 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" ));
284
285 contact.setBirthday(addr.birthday().date());
286 contact.setNickname(addr.nickName());
287
288 // other
289 contact.setNotes(addr.note());
290
291//US QString groups() const { return find( Qtopia::Groups ); }
292//US QStringList groupList() const;
293
294/*US
295 QStringList cats = contact.categoryNames("Contacts");
296 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
297 qDebug("Cat: %s", (*it).latin1());
298 }
299*/
300
301// addr.setCategories( contact.categoryNames("Contacts") );
302// contact.categoryNames("Contacts");
303// contact.setCategoryNames(addr.categories());
304
305/*US
306 QStringList cats = addr.categories();
307 QArray<int> cat(cats.count());
308 int counter = 0;
309 for ( QStringList::ConstIterator it = cats.begin(); it != cats.end(); ++it )
310 cat[counter] = (*it).toInt();
311
312 contact.setCategories( cat );
313*/
314/*US
315 Categories catDB;
316 catDB.load( contact.categoryFileName() );
317
318 QStringList cats = addr.categories();
319 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
320 contact.setCategories(catDB.id(*it));
321 }
322*/
323
324 return true;
325}
diff --git a/kabc/converter/opie/opieconverter.h b/kabc/converter/opie/opieconverter.h
index 55a869a..ef7300b 100644
--- a/kabc/converter/opie/opieconverter.h
+++ b/kabc/converter/opie/opieconverter.h
@@ -64,11 +64,8 @@ public:
64 * @param contact The opie contact. 64 * @param contact The opie contact.
65 */ 65 */
66 bool addresseeToOpie( const Addressee &addr, OContact &contact ); 66 bool addresseeToOpie( const Addressee &addr, OContact &contact );
67 67
68 private:
69 QString dateToAddresseeString( const QDate &date );
70
71}; 68};
72 69
73} 70}
74#endif 71#endif