summaryrefslogtreecommitdiffabout
path: root/kabc
authorulf69 <ulf69>2004-07-01 01:40:51 (UTC)
committer ulf69 <ulf69>2004-07-01 01:40:51 (UTC)
commit574570db1963fd729bb40a778ae3fc6a71ffc221 (patch) (unidiff)
tree470b49c7c1de2c415edcfb7f4962a23d848b5280 /kabc
parent94a34390c1c3f6554e171760aa250186e6c8cfc9 (diff)
downloadkdepimpi-574570db1963fd729bb40a778ae3fc6a71ffc221.zip
kdepimpi-574570db1963fd729bb40a778ae3fc6a71ffc221.tar.gz
kdepimpi-574570db1963fd729bb40a778ae3fc6a71ffc221.tar.bz2
converter also supports now export
Diffstat (limited to 'kabc') (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
@@ -33,2 +33,5 @@ $Id$
33 33
34#include <qpe/categories.h>
35
36
34using namespace KABC; 37using namespace KABC;
@@ -46,4 +49,3 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
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() );
@@ -61,2 +63,4 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
61 63
64 addr.insertEmail(contact.defaultEmail(), true);
65
62 // home 66 // home
@@ -160,3 +164,9 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
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() );
@@ -187,10 +197,129 @@ bool 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
@@ -67,5 +67,2 @@ public:
67 67
68 private:
69 QString dateToAddresseeString( const QDate &date );
70
71}; 68};