summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-07-19 20:04:49 (UTC)
committer ulf69 <ulf69>2004-07-19 20:04:49 (UTC)
commit2389d07165786dc4d99cac043947b555fdd7d86e (patch) (unidiff)
tree1abe3227f3ee86a2159f72245465b65c748ce619
parentd498ea750239bffa7ec811aa3e60befc6bae9608 (diff)
downloadkdepimpi-2389d07165786dc4d99cac043947b555fdd7d86e.zip
kdepimpi-2389d07165786dc4d99cac043947b555fdd7d86e.tar.gz
kdepimpi-2389d07165786dc4d99cac043947b555fdd7d86e.tar.bz2
code cleanup
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/converter/qtopia/qtopiaconverter.cpp98
1 files changed, 50 insertions, 48 deletions
diff --git a/kabc/converter/qtopia/qtopiaconverter.cpp b/kabc/converter/qtopia/qtopiaconverter.cpp
index 498e89e..ac513b6 100644
--- a/kabc/converter/qtopia/qtopiaconverter.cpp
+++ b/kabc/converter/qtopia/qtopiaconverter.cpp
@@ -1,360 +1,362 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
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//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#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)
41{ 41{
42} 42}
43 43
44QtopiaConverter::~QtopiaConverter() 44QtopiaConverter::~QtopiaConverter()
45{ 45{
46 deinit(); 46 deinit();
47} 47}
48 48
49bool QtopiaConverter::init() 49bool QtopiaConverter::init()
50{ 50{
51 catDB = new Categories(); 51 catDB = new Categories();
52 52
53 if (!catDB) 53 if (!catDB)
54 return false; 54 return false;
55 55
56 catDB->load( categoryFileName() ); 56 catDB->load( categoryFileName() );
57 return true; 57 return true;
58} 58}
59 59
60void QtopiaConverter::deinit() 60void QtopiaConverter::deinit()
61{ 61{
62 if (catDB) 62 if (catDB)
63 { 63 {
64 delete catDB; 64 delete catDB;
65 catDB = 0; 65 catDB = 0;
66 } 66 }
67} 67}
68 68
69bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) 69bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr )
70{ 70{
71 // name 71 // name
72 addr.setFormattedName(contact.fileAs()); 72 addr.setFormattedName(contact.fileAs());
73 addr.setFamilyName( contact.lastName() ); 73 addr.setFamilyName( contact.lastName() );
74 addr.setGivenName( contact.firstName() ); 74 addr.setGivenName( contact.firstName() );
75 addr.setAdditionalName( contact.middleName() ); 75 addr.setAdditionalName( contact.middleName() );
76 addr.setPrefix( contact.nameTitle() ); 76 addr.setPrefix( contact.nameTitle() );
77 addr.setSuffix( contact.suffix() ); 77 addr.setSuffix( contact.suffix() );
78 78
79 79
80 // email 80 // email
81 QStringList emails = contact.emailList(); 81 QStringList emails = contact.emailList();
82 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 82 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
83 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); 83 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
84 } 84 }
85 85
86 if (!contact.defaultEmail().isEmpty()) 86 if (!contact.defaultEmail().isEmpty())
87 addr.insertEmail(contact.defaultEmail(), true); 87 addr.insertEmail(contact.defaultEmail(), true);
88 88
89 // home 89 // home
90 if ((!contact.homeStreet().isEmpty()) || 90 if ((!contact.homeStreet().isEmpty()) ||
91 (!contact.homeCity().isEmpty()) || 91 (!contact.homeCity().isEmpty()) ||
92 (!contact.homeState().isEmpty()) || 92 (!contact.homeState().isEmpty()) ||
93 (!contact.homeZip().isEmpty()) || 93 (!contact.homeZip().isEmpty()) ||
94 (!contact.homeCountry().isEmpty())) 94 (!contact.homeCountry().isEmpty()))
95 { 95 {
96 Address homeaddress; 96 Address homeaddress;
97 homeaddress.setType(Address::Home); 97 homeaddress.setType(Address::Home);
98//US homeaddress.setPostOfficeBox( "" ); 98//US homeaddress.setPostOfficeBox( "" );
99//US homeaddress.setExtended( "" ); 99//US homeaddress.setExtended( "" );
100 homeaddress.setStreet( contact.homeStreet() ); 100 homeaddress.setStreet( contact.homeStreet() );
101 homeaddress.setLocality( contact.homeCity() ); 101 homeaddress.setLocality( contact.homeCity() );
102 homeaddress.setRegion( contact.homeState() ); 102 homeaddress.setRegion( contact.homeState() );
103 homeaddress.setPostalCode( contact.homeZip() ); 103 homeaddress.setPostalCode( contact.homeZip() );
104 homeaddress.setCountry( contact.homeCountry() ); 104 homeaddress.setCountry( contact.homeCountry() );
105 105
106 addr.insertAddress( homeaddress ); 106 addr.insertAddress( homeaddress );
107 } 107 }
108 108
109 if (!contact.homePhone().isEmpty()) 109 if (!contact.homePhone().isEmpty())
110 { 110 {
111 PhoneNumber homephone; 111 PhoneNumber homephone;
112 homephone.setType( PhoneNumber::Home ); 112 homephone.setType( PhoneNumber::Home );
113 homephone.setNumber( contact.homePhone() ); 113 homephone.setNumber( contact.homePhone() );
114 addr.insertPhoneNumber( homephone ); 114 addr.insertPhoneNumber( homephone );
115 } 115 }
116 116
117 if (!contact.homeFax().isEmpty()) 117 if (!contact.homeFax().isEmpty())
118 { 118 {
119 PhoneNumber homefax; 119 PhoneNumber homefax;
120 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); 120 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax );
121 homefax.setNumber( contact.homeFax() ); 121 homefax.setNumber( contact.homeFax() );
122 addr.insertPhoneNumber( homefax ); 122 addr.insertPhoneNumber( homefax );
123 } 123 }
124 124
125 if (!contact.homeMobile().isEmpty()) 125 if (!contact.homeMobile().isEmpty())
126 { 126 {
127 PhoneNumber homemobile; 127 PhoneNumber homemobile;
128 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); 128 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell );
129 homemobile.setNumber( contact.homeMobile() ); 129 homemobile.setNumber( contact.homeMobile() );
130 addr.insertPhoneNumber( homemobile ); 130 addr.insertPhoneNumber( homemobile );
131 } 131 }
132 132
133 addr.setUrl( contact.homeWebpage() ); 133 addr.setUrl( contact.homeWebpage() );
134 134
135 135
136 // business 136 // business
137 if ((!contact.businessStreet().isEmpty()) || 137 if ((!contact.businessStreet().isEmpty()) ||
138 (!contact.businessCity().isEmpty()) || 138 (!contact.businessCity().isEmpty()) ||
139 (!contact.businessState().isEmpty()) || 139 (!contact.businessState().isEmpty()) ||
140 (!contact.businessZip().isEmpty()) || 140 (!contact.businessZip().isEmpty()) ||
141 (!contact.businessCountry().isEmpty())) 141 (!contact.businessCountry().isEmpty()))
142 { 142 {
143 Address businessaddress; 143 Address businessaddress;
144 businessaddress.setType(Address::Work); 144 businessaddress.setType(Address::Work);
145//US businessaddress.setPostOfficeBox( "" ); 145//US businessaddress.setPostOfficeBox( "" );
146//US businessaddress.setExtended( "" ); 146//US businessaddress.setExtended( "" );
147 businessaddress.setStreet( contact.businessStreet() ); 147 businessaddress.setStreet( contact.businessStreet() );
148 businessaddress.setLocality( contact.businessCity() ); 148 businessaddress.setLocality( contact.businessCity() );
149 businessaddress.setRegion( contact.businessState() ); 149 businessaddress.setRegion( contact.businessState() );
150 businessaddress.setPostalCode( contact.businessZip() ); 150 businessaddress.setPostalCode( contact.businessZip() );
151 businessaddress.setCountry( contact.businessCountry() ); 151 businessaddress.setCountry( contact.businessCountry() );
152 152
153 addr.insertAddress( businessaddress ); 153 addr.insertAddress( businessaddress );
154 } 154 }
155 155
156 156
157 if (!contact.businessPhone().isEmpty()) 157 if (!contact.businessPhone().isEmpty())
158 { 158 {
159 PhoneNumber businessphone; 159 PhoneNumber businessphone;
160 businessphone.setType( PhoneNumber::Work ); 160 businessphone.setType( PhoneNumber::Work );
161 businessphone.setNumber( contact.businessPhone() ); 161 businessphone.setNumber( contact.businessPhone() );
162 addr.insertPhoneNumber( businessphone ); 162 addr.insertPhoneNumber( businessphone );
163 } 163 }
164 164
165 if (!contact.businessFax().isEmpty()) 165 if (!contact.businessFax().isEmpty())
166 { 166 {
167 PhoneNumber businessfax; 167 PhoneNumber businessfax;
168 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); 168 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax );
169 businessfax.setNumber( contact.businessFax() ); 169 businessfax.setNumber( contact.businessFax() );
170 addr.insertPhoneNumber( businessfax ); 170 addr.insertPhoneNumber( businessfax );
171 } 171 }
172 172
173 if (!contact.businessMobile().isEmpty()) 173 if (!contact.businessMobile().isEmpty())
174 { 174 {
175 PhoneNumber businessmobile; 175 PhoneNumber businessmobile;
176 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); 176 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell );
177 businessmobile.setNumber( contact.businessMobile() ); 177 businessmobile.setNumber( contact.businessMobile() );
178 addr.insertPhoneNumber( businessmobile ); 178 addr.insertPhoneNumber( businessmobile );
179 } 179 }
180 180
181 if (!contact.businessPager().isEmpty()) 181 if (!contact.businessPager().isEmpty())
182 { 182 {
183 PhoneNumber businesspager; 183 PhoneNumber businesspager;
184 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); 184 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager );
185 businesspager.setNumber( contact.businessPager() ); 185 businesspager.setNumber( contact.businessPager() );
186 addr.insertPhoneNumber( businesspager ); 186 addr.insertPhoneNumber( businesspager );
187 } 187 }
188 188
189 addr.setRole( contact.jobTitle() ); //? 189 addr.setRole( contact.jobTitle() ); //?
190 addr.setOrganization( contact.company() ); 190 addr.setOrganization( contact.company() );
191 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); 191 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() );
192 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); 192 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() );
193 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); 193 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() );
194 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); 194 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() );
195 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); 195 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() );
196 196
197 //personal 197 //personal
198 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); 198 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() );
199 // qtopia uses this categorization: 199 // qtopia uses this categorization:
200 // enum GenderType { UnspecifiedGender=0, Male, Female }; 200 // enum GenderType { UnspecifiedGender=0, Male, Female };
201 if (contact.gender() == PimContact::Male) 201 if (contact.gender() == PimContact::Male)
202 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); 202 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
203 else if (contact.gender() == PimContact::Female) 203 else if (contact.gender() == PimContact::Female)
204 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); 204 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
205 205
206 if (contact.anniversary().isValid()) { 206 if (contact.anniversary().isValid()) {
207 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); 207 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate);
208//US 208//US
209// qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1()); 209// qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1());
210 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 210 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
211 } 211 }
212 212
213 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); 213 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() );
214 if (contact.birthday().isValid()) 214 if (contact.birthday().isValid())
215 addr.setBirthday( contact.birthday() ); 215 addr.setBirthday( contact.birthday() );
216 216
217 addr.setNickName( contact.nickname() ); 217 addr.setNickName( contact.nickname() );
218 218
219 // others 219 // others
220 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. 220 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available.
221 QString notes = contact.notes(); 221 QString notes = contact.notes();
222 notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; 222 notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n";
223 223
224 addr.setNote( contact.notes() ); 224 addr.setNote( contact.notes() );
225 225
226 226
227 227
228//US QString groups() const { return find( Qtopia::Groups ); } 228//US QString groups() const { return find( Qtopia::Groups ); }
229//US QStringList groupList() const; 229//US QStringList groupList() const;
230 230
231 QArray<int> catArray = contact.categories(); 231 QArray<int> catArray = contact.categories();
232 QString cat; 232 QString cat;
233 233
234 for ( unsigned int i=0; i < catArray.size(); i++ ) { 234 for ( unsigned int i=0; i < catArray.size(); i++ ) {
235 cat = catDB->label("contact", catArray[i]); 235 cat = catDB->label("contact", catArray[i]);
236 if ( !cat.isEmpty() ) 236 if ( cat.isEmpty() )
237 addr.insertCategory(QString::number(catArray[i]));
238 else
237 addr.insertCategory( cat ); 239 addr.insertCategory( cat );
238 } 240 }
239 241
240 return true; 242 return true;
241} 243}
242 244
243bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact ) 245bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact )
244{ 246{
245 // name 247 // name
246 contact.setLastName(addr.familyName()); 248 contact.setLastName(addr.familyName());
247 contact.setFirstName(addr.givenName()); 249 contact.setFirstName(addr.givenName());
248 contact.setMiddleName(addr.additionalName()); 250 contact.setMiddleName(addr.additionalName());
249 contact.setNameTitle(addr.prefix()); 251 contact.setNameTitle(addr.prefix());
250 contact.setSuffix(addr.suffix()); 252 contact.setSuffix(addr.suffix());
251 contact.setFileAs(); 253 contact.setFileAs();
252 254
253 255
254 // email 256 // email
255 QStringList emails = addr.emails(); 257 QStringList emails = addr.emails();
256 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 258 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
257 contact.insertEmail(*it); 259 contact.insertEmail(*it);
258 } 260 }
259 contact.setDefaultEmail( addr.preferredEmail() ); 261 contact.setDefaultEmail( addr.preferredEmail() );
260 262
261 263
262 // home 264 // home
263 const Address homeaddress = addr.address(Address::Home); 265 const Address homeaddress = addr.address(Address::Home);
264 if (!homeaddress.isEmpty()) { 266 if (!homeaddress.isEmpty()) {
265 contact.setHomeStreet(homeaddress.street()); 267 contact.setHomeStreet(homeaddress.street());
266 contact.setHomeCity(homeaddress.locality()); 268 contact.setHomeCity(homeaddress.locality());
267 contact.setHomeState(homeaddress.region()); 269 contact.setHomeState(homeaddress.region());
268 contact.setHomeZip(homeaddress.postalCode()); 270 contact.setHomeZip(homeaddress.postalCode());
269 contact.setHomeCountry(homeaddress.country()); 271 contact.setHomeCountry(homeaddress.country());
270 } 272 }
271 273
272 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); 274 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
273 if (!homephone.number().isEmpty()) 275 if (!homephone.number().isEmpty())
274 contact.setHomePhone(homephone.number()); 276 contact.setHomePhone(homephone.number());
275 277
276 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); 278 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
277 if (!homefax.number().isEmpty()) 279 if (!homefax.number().isEmpty())
278 contact.setHomeFax(homefax.number()); 280 contact.setHomeFax(homefax.number());
279 281
280 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); 282 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
281 if (!homemobile.number().isEmpty()) 283 if (!homemobile.number().isEmpty())
282 contact.setHomeMobile(homemobile.number()); 284 contact.setHomeMobile(homemobile.number());
283 285
284 contact.setHomeWebpage(addr.url().url()); 286 contact.setHomeWebpage(addr.url().url());
285 287
286 288
287 // business 289 // business
288 const Address businessaddress = addr.address(Address::Work); 290 const Address businessaddress = addr.address(Address::Work);
289 if (!businessaddress.isEmpty()) { 291 if (!businessaddress.isEmpty()) {
290 contact.setBusinessStreet(businessaddress.street()); 292 contact.setBusinessStreet(businessaddress.street());
291 contact.setBusinessCity(businessaddress.locality()); 293 contact.setBusinessCity(businessaddress.locality());
292 contact.setBusinessState(businessaddress.region()); 294 contact.setBusinessState(businessaddress.region());
293 contact.setBusinessZip(businessaddress.postalCode()); 295 contact.setBusinessZip(businessaddress.postalCode());
294 contact.setBusinessCountry(businessaddress.country()); 296 contact.setBusinessCountry(businessaddress.country());
295 } 297 }
296 298
297 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); 299 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work );
298 if (!businessphone.number().isEmpty()) 300 if (!businessphone.number().isEmpty())
299 contact.setBusinessPhone(businessphone.number()); 301 contact.setBusinessPhone(businessphone.number());
300 302
301 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); 303 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax );
302 if (!businessfax.number().isEmpty()) 304 if (!businessfax.number().isEmpty())
303 contact.setBusinessFax(businessfax.number()); 305 contact.setBusinessFax(businessfax.number());
304 306
305 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); 307 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell );
306 if (!businessmobile.number().isEmpty()) 308 if (!businessmobile.number().isEmpty())
307 contact.setBusinessMobile(businessmobile.number()); 309 contact.setBusinessMobile(businessmobile.number());
308 310
309 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); 311 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
310 if (!businesspager.number().isEmpty()) 312 if (!businesspager.number().isEmpty())
311 contact.setBusinessPager(businesspager.number()); 313 contact.setBusinessPager(businesspager.number());
312 314
313 contact.setJobTitle(addr.role()); 315 contact.setJobTitle(addr.role());
314 contact.setCompany(addr.organization()); 316 contact.setCompany(addr.organization());
315 317
316 contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" )); 318 contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" ));
317 contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); 319 contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" ));
318 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" )); 320 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" ));
319 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" )); 321 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
320 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" )); 322 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" ));
321 323
322 //personal 324 //personal
323 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" )); 325 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" ));
324 // qtopia uses this categorization: 326 // qtopia uses this categorization:
325 // enum GenderType { UnspecifiedGender=0, Male, Female }; 327 // enum GenderType { UnspecifiedGender=0, Male, Female };
326 QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); 328 QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" );
327 if (gt = "male") 329 if (gt = "male")
328 contact.setGender(PimContact::Male); 330 contact.setGender(PimContact::Male);
329 else if (gt = "female") 331 else if (gt = "female")
330 contact.setGender(PimContact::Female); 332 contact.setGender(PimContact::Female);
331 else 333 else
332 contact.setGender(PimContact::UnspecifiedGender); 334 contact.setGender(PimContact::UnspecifiedGender);
333 335
334 336
335 QDate dt = KGlobal::locale()->readDate( 337 QDate dt = KGlobal::locale()->readDate(
336 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate 338 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate
337 contact.setAnniversary( dt ); 339 contact.setAnniversary( dt );
338 340
339 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); 341 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" ));
340 342
341 contact.setBirthday(addr.birthday().date()); 343 contact.setBirthday(addr.birthday().date());
342 contact.setNickname(addr.nickName()); 344 contact.setNickname(addr.nickName());
343 345
344 // other 346 // other
345 contact.setNotes(addr.note()); 347 contact.setNotes(addr.note());
346 348
347//US QString groups() const { return find( Qtopia::Groups ); } 349//US QString groups() const { return find( Qtopia::Groups ); }
348//US QStringList groupList() const; 350//US QStringList groupList() const;
349 351
350 352
351 QStringList cats = addr.categories(); 353 QStringList cats = addr.categories();
352 354
353 QArray<int> iar; 355 QArray<int> iar;
354 if ( !cats.isEmpty() ) { 356 if ( !cats.isEmpty() ) {
355 QArray<int> iar = catDB->ids("contact", cats); 357 QArray<int> iar = catDB->ids("contact", cats);
356 contact.setCategories(iar); 358 contact.setCategories(iar);
357 } 359 }
358 360
359 return true; 361 return true;
360} 362}