summaryrefslogtreecommitdiffabout
path: root/kabc
authorulf69 <ulf69>2004-07-13 04:26:58 (UTC)
committer ulf69 <ulf69>2004-07-13 04:26:58 (UTC)
commit65b8479039ca52f3f7ad8a36c616f1d8a4ffbaec (patch) (unidiff)
tree31f96a3d85893100095025721ddd421cbcc0248d /kabc
parent6d9dac0811fa544e28d86e8aa2a20e553329a7fd (diff)
downloadkdepimpi-65b8479039ca52f3f7ad8a36c616f1d8a4ffbaec.zip
kdepimpi-65b8479039ca52f3f7ad8a36c616f1d8a4ffbaec.tar.gz
kdepimpi-65b8479039ca52f3f7ad8a36c616f1d8a4ffbaec.tar.bz2
removed dead code from opiconverter
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/converter/opie/opieconverter.cpp33
-rw-r--r--kabc/converter/opie/opieconverter.h2
2 files changed, 4 insertions, 31 deletions
diff --git a/kabc/converter/opie/opieconverter.cpp b/kabc/converter/opie/opieconverter.cpp
index b4e9f1c..0b6a55e 100644
--- a/kabc/converter/opie/opieconverter.cpp
+++ b/kabc/converter/opie/opieconverter.cpp
@@ -25,97 +25,97 @@ Copyright (c) 2004 Ulf Schenk
25$Id$ 25$Id$
26*/ 26*/
27 27
28//US 28//US
29#include "kglobal.h" 29#include "kglobal.h"
30 30
31 31
32#include "opieconverter.h" 32#include "opieconverter.h"
33 33
34#include <qpe/categories.h> 34#include <qpe/categories.h>
35#include <qpe/categoryselect.h> 35#include <qpe/categoryselect.h>
36 36
37 37
38using namespace KABC; 38using namespace KABC;
39 39
40OpieConverter::OpieConverter() : catDB(0) 40OpieConverter::OpieConverter() : catDB(0)
41{ 41{
42} 42}
43 43
44OpieConverter::~OpieConverter() 44OpieConverter::~OpieConverter()
45{ 45{
46 deinit(); 46 deinit();
47} 47}
48 48
49bool OpieConverter::init() 49bool OpieConverter::init()
50{ 50{
51 catDB = new Categories(); 51 catDB = new Categories();
52 if (catDB) 52 if (catDB)
53 { 53 {
54 catDB->load( categoryFileName() ); 54 catDB->load( categoryFileName() );
55 return true; 55 return true;
56 } 56 }
57 else 57 else
58 { 58 {
59 return false; 59 return false;
60 } 60 }
61 61
62} 62}
63 63
64void OpieConverter::deinit() 64void OpieConverter::deinit()
65{ 65{
66 if (catDB) 66 if (catDB)
67 { 67 {
68 delete catDB; 68 delete catDB;
69 catDB = 0; 69 catDB = 0;
70 } 70 }
71} 71}
72 72
73bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) 73bool OpieConverter::opieToAddressee( const OContact &contact, Addressee &addr )
74{ 74{
75 // name 75 // name
76 addr.setFormattedName(contact.fileAs()); 76 addr.setFormattedName(contact.fileAs());
77 addr.setFamilyName( contact.lastName() ); 77 addr.setFamilyName( contact.lastName() );
78 addr.setGivenName( contact.firstName() ); 78 addr.setGivenName( contact.firstName() );
79 addr.setAdditionalName( contact.middleName() ); 79 addr.setAdditionalName( contact.middleName() );
80 addr.setPrefix( contact.title() ); 80 addr.setPrefix( contact.title() );
81 addr.setSuffix( contact.suffix() ); 81 addr.setSuffix( contact.suffix() );
82 82
83 83
84 // email 84 // email
85 QStringList emails = contact.emailList(); 85 QStringList emails = contact.emailList();
86 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 86 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
87 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); 87 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
88 } 88 }
89 89
90 if (!contact.defaultEmail().isEmpty()) 90 if (!contact.defaultEmail().isEmpty())
91 addr.insertEmail(contact.defaultEmail(), true); 91 addr.insertEmail(contact.defaultEmail(), true);
92 92
93 // home 93 // home
94 if ((!contact.homeStreet().isEmpty()) || 94 if ((!contact.homeStreet().isEmpty()) ||
95 (!contact.homeCity().isEmpty()) || 95 (!contact.homeCity().isEmpty()) ||
96 (!contact.homeState().isEmpty()) || 96 (!contact.homeState().isEmpty()) ||
97 (!contact.homeZip().isEmpty()) || 97 (!contact.homeZip().isEmpty()) ||
98 (!contact.homeCountry().isEmpty())) 98 (!contact.homeCountry().isEmpty()))
99 { 99 {
100 Address homeaddress; 100 Address homeaddress;
101 homeaddress.setType(Address::Home); 101 homeaddress.setType(Address::Home);
102//US homeaddress.setPostOfficeBox( "" ); 102//US homeaddress.setPostOfficeBox( "" );
103//US homeaddress.setExtended( "" ); 103//US homeaddress.setExtended( "" );
104 homeaddress.setStreet( contact.homeStreet() ); 104 homeaddress.setStreet( contact.homeStreet() );
105 homeaddress.setLocality( contact.homeCity() ); 105 homeaddress.setLocality( contact.homeCity() );
106 homeaddress.setRegion( contact.homeState() ); 106 homeaddress.setRegion( contact.homeState() );
107 homeaddress.setPostalCode( contact.homeZip() ); 107 homeaddress.setPostalCode( contact.homeZip() );
108 homeaddress.setCountry( contact.homeCountry() ); 108 homeaddress.setCountry( contact.homeCountry() );
109 109
110 addr.insertAddress( homeaddress ); 110 addr.insertAddress( homeaddress );
111 } 111 }
112 112
113 if (!contact.homePhone().isEmpty()) 113 if (!contact.homePhone().isEmpty())
114 { 114 {
115 PhoneNumber homephone; 115 PhoneNumber homephone;
116 homephone.setType( PhoneNumber::Home ); 116 homephone.setType( PhoneNumber::Home );
117 homephone.setNumber( contact.homePhone() ); 117 homephone.setNumber( contact.homePhone() );
118 addr.insertPhoneNumber( homephone ); 118 addr.insertPhoneNumber( homephone );
119 } 119 }
120 120
121 if (!contact.homeFax().isEmpty()) 121 if (!contact.homeFax().isEmpty())
@@ -184,105 +184,101 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
184 184
185 if (!contact.businessPager().isEmpty()) 185 if (!contact.businessPager().isEmpty())
186 { 186 {
187 PhoneNumber businesspager; 187 PhoneNumber businesspager;
188 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); 188 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager );
189 businesspager.setNumber( contact.businessPager() ); 189 businesspager.setNumber( contact.businessPager() );
190 addr.insertPhoneNumber( businesspager ); 190 addr.insertPhoneNumber( businesspager );
191 } 191 }
192 192
193 addr.setRole( contact.jobTitle() ); //? 193 addr.setRole( contact.jobTitle() ); //?
194 addr.setOrganization( contact.company() ); 194 addr.setOrganization( contact.company() );
195 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); 195 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() );
196 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); 196 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() );
197 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); 197 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() );
198 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); 198 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() );
199 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); 199 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() );
200 200
201 //personal 201 //personal
202 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); 202 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() );
203 addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() ); 203 addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() );
204 204
205 if (contact.anniversary().isValid()) { 205 if (contact.anniversary().isValid()) {
206 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); 206 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate);
207//US 207//US
208 qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1()); 208 qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1());
209 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 209 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
210 } 210 }
211 211
212 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); 212 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() );
213 if (contact.birthday().isValid()) 213 if (contact.birthday().isValid())
214 addr.setBirthday( contact.birthday() ); 214 addr.setBirthday( contact.birthday() );
215 215
216 addr.setNickName( contact.nickname() ); 216 addr.setNickName( contact.nickname() );
217 217
218 // others 218 // others
219 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. 219 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available.
220 QString notes = contact.notes(); 220 QString notes = contact.notes();
221 notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; 221 notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n";
222 222
223 addr.setNote( contact.notes() ); 223 addr.setNote( contact.notes() );
224 224
225 225
226 226
227//US QString groups() const { return find( Qtopia::Groups ); } 227//US QString groups() const { return find( Qtopia::Groups ); }
228//US QStringList groupList() const; 228//US QStringList groupList() const;
229 229
230 230
231 QStringList cats = contact.categoryNames("Contacts"); 231 QStringList cats = contact.categoryNames("Contacts");
232 addr.setCategories( cats );
232// for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { 233// for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
233// qDebug("Cat: %s", (*it).latin1()); 234// qDebug("Cat: %s", (*it).latin1());
234// } 235// }
235
236 236
237 addr.setCategories( contact.categoryNames("Contacts") );
238// qDebug("Groups: %s", contact.groups().latin1());
239// addr.setCategories( contact.groupList() );
240
241 237
242 return true; 238 return true;
243} 239}
244 240
245bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact ) 241bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact )
246{ 242{
247 // name 243 // name
248 contact.setLastName(addr.familyName()); 244 contact.setLastName(addr.familyName());
249 contact.setFirstName(addr.givenName()); 245 contact.setFirstName(addr.givenName());
250 contact.setMiddleName(addr.additionalName()); 246 contact.setMiddleName(addr.additionalName());
251 contact.setTitle(addr.prefix()); 247 contact.setTitle(addr.prefix());
252 contact.setSuffix(addr.suffix()); 248 contact.setSuffix(addr.suffix());
253 contact.setFileAs(); 249 contact.setFileAs();
254 250
255 251
256 // email 252 // email
257 QStringList emails = addr.emails(); 253 QStringList emails = addr.emails();
258 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 254 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
259 contact.insertEmail(*it); 255 contact.insertEmail(*it);
260 } 256 }
261 contact.setDefaultEmail( addr.preferredEmail() ); 257 contact.setDefaultEmail( addr.preferredEmail() );
262 258
263 259
264 // home 260 // home
265 const Address homeaddress = addr.address(Address::Home); 261 const Address homeaddress = addr.address(Address::Home);
266 if (!homeaddress.isEmpty()) { 262 if (!homeaddress.isEmpty()) {
267 contact.setHomeStreet(homeaddress.street()); 263 contact.setHomeStreet(homeaddress.street());
268 contact.setHomeCity(homeaddress.locality()); 264 contact.setHomeCity(homeaddress.locality());
269 contact.setHomeState(homeaddress.region()); 265 contact.setHomeState(homeaddress.region());
270 contact.setHomeZip(homeaddress.postalCode()); 266 contact.setHomeZip(homeaddress.postalCode());
271 contact.setHomeCountry(homeaddress.country()); 267 contact.setHomeCountry(homeaddress.country());
272 } 268 }
273 269
274 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); 270 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
275 if (!homephone.number().isEmpty()) 271 if (!homephone.number().isEmpty())
276 contact.setHomePhone(homephone.number()); 272 contact.setHomePhone(homephone.number());
277 273
278 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); 274 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
279 if (!homefax.number().isEmpty()) 275 if (!homefax.number().isEmpty())
280 contact.setHomeFax(homefax.number()); 276 contact.setHomeFax(homefax.number());
281 277
282 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); 278 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
283 if (!homemobile.number().isEmpty()) 279 if (!homemobile.number().isEmpty())
284 contact.setHomeMobile(homemobile.number()); 280 contact.setHomeMobile(homemobile.number());
285 281
286 contact.setHomeWebpage(addr.url().url()); 282 contact.setHomeWebpage(addr.url().url());
287 283
288 284
@@ -295,81 +291,58 @@ bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact )
295 contact.setBusinessZip(businessaddress.postalCode()); 291 contact.setBusinessZip(businessaddress.postalCode());
296 contact.setBusinessCountry(businessaddress.country()); 292 contact.setBusinessCountry(businessaddress.country());
297 } 293 }
298 294
299 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); 295 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work );
300 if (!businessphone.number().isEmpty()) 296 if (!businessphone.number().isEmpty())
301 contact.setBusinessPhone(businessphone.number()); 297 contact.setBusinessPhone(businessphone.number());
302 298
303 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); 299 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax );
304 if (!businessfax.number().isEmpty()) 300 if (!businessfax.number().isEmpty())
305 contact.setBusinessFax(businessfax.number()); 301 contact.setBusinessFax(businessfax.number());
306 302
307 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); 303 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell );
308 if (!businessmobile.number().isEmpty()) 304 if (!businessmobile.number().isEmpty())
309 contact.setBusinessMobile(businessmobile.number()); 305 contact.setBusinessMobile(businessmobile.number());
310 306
311 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); 307 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
312 if (!businesspager.number().isEmpty()) 308 if (!businesspager.number().isEmpty())
313 contact.setBusinessPager(businesspager.number()); 309 contact.setBusinessPager(businesspager.number());
314 310
315 contact.setJobTitle(addr.role()); 311 contact.setJobTitle(addr.role());
316 contact.setCompany(addr.organization()); 312 contact.setCompany(addr.organization());
317 313
318 contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" )); 314 contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" ));
319 contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); 315 contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" ));
320 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" )); 316 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" ));
321 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" )); 317 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
322 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" )); 318 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" ));
323 319
324 //personal 320 //personal
325 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" )); 321 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" ));
326 contact.setGender(addr.custom( "KADDRESSBOOK", "X-Gender" )); 322 contact.setGender(addr.custom( "KADDRESSBOOK", "X-Gender" ));
327 323
328 QDate dt = KGlobal::locale()->readDate( 324 QDate dt = KGlobal::locale()->readDate(
329 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate 325 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate
330 contact.setAnniversary( dt ); 326 contact.setAnniversary( dt );
331 327
332 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); 328 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" ));
333 329
334 contact.setBirthday(addr.birthday().date()); 330 contact.setBirthday(addr.birthday().date());
335 contact.setNickname(addr.nickName()); 331 contact.setNickname(addr.nickName());
336 332
337 // other 333 // other
338 contact.setNotes(addr.note()); 334 contact.setNotes(addr.note());
339 335
340//US QString groups() const { return find( Qtopia::Groups ); } 336//US QString groups() const { return find( Qtopia::Groups ); }
341//US QStringList groupList() const; 337//US QStringList groupList() const;
342 338
343/*US
344 QStringList cats = contact.categoryNames("Contacts");
345 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
346 qDebug("Cat: %s", (*it).latin1());
347 }
348*/
349
350// addr.setCategories( contact.categoryNames("Contacts") );
351// contact.categoryNames("Contacts");
352// contact.setCategoryNames(addr.categories());
353
354/*US
355 QStringList cats = addr.categories();
356 QArray<int> cat(cats.count());
357 int counter = 0;
358 for ( QStringList::ConstIterator it = cats.begin(); it != cats.end(); ++it )
359 cat[counter] = (*it).toInt();
360
361 contact.setCategories( cat );
362*/
363
364 Categories catDB;
365 catDB.load( categoryFileName() );
366 QStringList cats = addr.categories(); 339 QStringList cats = addr.categories();
367 340
368 QArray<int> iar; 341 QArray<int> iar;
369 if ( !cats.isEmpty() ) { 342 if ( !cats.isEmpty() ) {
370 QArray<int> iar = catDB.ids("contact", cats); 343 QArray<int> iar = catDB->ids("contact", cats);
371 contact.setCategories(iar); 344 contact.setCategories(iar);
372 } 345 }
373 346
374 return true; 347 return true;
375} 348}
diff --git a/kabc/converter/opie/opieconverter.h b/kabc/converter/opie/opieconverter.h
index 7d2ad85..c7e691f 100644
--- a/kabc/converter/opie/opieconverter.h
+++ b/kabc/converter/opie/opieconverter.h
@@ -15,66 +15,66 @@
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_OPIECONVERTER_H 28#ifndef KABC_OPIECONVERTER_H
29#define KABC_OPIECONVERTER_H 29#define KABC_OPIECONVERTER_H
30 30
31#include <qstring.h> 31#include <qstring.h>
32 32
33#include "addressee.h" 33#include "addressee.h"
34#include <opie/ocontact.h> 34#include <opie/ocontact.h>
35 35
36class Categories; 36class Categories;
37 37
38namespace KABC { 38namespace KABC {
39 39
40class OpieConverter 40class OpieConverter
41{ 41{
42public: 42public:
43 43
44 /** 44 /**
45 * Constructor. 45 * Constructor.
46 */ 46 */
47 OpieConverter(); 47 OpieConverter();
48 48
49 /** 49 /**
50 * Destructor. 50 * Destructor.
51 */ 51 */
52 virtual ~OpieConverter(); 52 virtual ~OpieConverter();
53 53
54 virtual bool init(); 54 virtual bool init();
55 virtual void deinit(); 55 virtual void deinit();
56 56
57 /** 57 /**
58 * Converts a vcard string to an addressee. 58 * Converts a vcard string to an addressee.
59 * 59 *
60 * @param contact The opie contact. 60 * @param contact The opie contact.
61 * @param addr The addressee. 61 * @param addr The addressee.
62 */ 62 */
63 bool opieToAddressee( OContact &contact, Addressee &addr ); 63 bool opieToAddressee( const OContact &contact, Addressee &addr );
64 64
65 /** 65 /**
66 * Converts an addressee to a vcard string. 66 * Converts an addressee to a vcard string.
67 * 67 *
68 * @param addr The addressee. 68 * @param addr The addressee.
69 * @param contact The opie contact. 69 * @param contact The opie contact.
70 */ 70 */
71 bool addresseeToOpie( const Addressee &addr, OContact &contact ); 71 bool addresseeToOpie( const Addressee &addr, OContact &contact );
72 72
73 private: 73 private:
74 Categories* catDB; 74 Categories* catDB;
75 75
76 76
77}; 77};
78 78
79} 79}
80#endif 80#endif