summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp12
-rw-r--r--libopie/pim/ocontact.h11
-rw-r--r--libopie2/opiepim/ocontact.cpp12
-rw-r--r--libopie2/opiepim/ocontact.h11
4 files changed, 26 insertions, 20 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index 66632f5..828a9de 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -1,1433 +1,1433 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define QTOPIA_INTERNAL_CONTACT_MRE 21#define QTOPIA_INTERNAL_CONTACT_MRE
22 22
23#include "ocontact.h" 23#include "ocontact.h"
24#include "vobject_p.h" 24#include "vobject_p.h"
25#include "qfiledirect_p.h" 25#include "qfiledirect_p.h"
26 26
27#include <qpe/stringutil.h> 27#include <qpe/stringutil.h>
28#include <qpe/timeconversion.h> 28#include <qpe/timeconversion.h>
29 29
30#include <qobject.h> 30#include <qobject.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qstylesheet.h> 32#include <qstylesheet.h>
33#include <qfileinfo.h> 33#include <qfileinfo.h>
34#include <qmap.h> 34#include <qmap.h>
35 35
36#include <stdio.h> 36#include <stdio.h>
37 37
38/*! 38/*!
39 \class Contact contact.h 39 \class Contact contact.h
40 \brief The Contact class holds the data of an address book entry. 40 \brief The Contact class holds the data of an address book entry.
41 41
42 This data includes information the name of the person, contact 42 This data includes information the name of the person, contact
43 information, and business information such as deparment and job title. 43 information, and business information such as deparment and job title.
44 44
45 \ingroup qtopiaemb 45 \ingroup qtopiaemb
46 \ingroup qtopiadesktop 46 \ingroup qtopiadesktop
47*/ 47*/
48 48
49Qtopia::UidGen OContact::sUidGen( Qtopia::UidGen::Qtopia ); 49Qtopia::UidGen OContact::sUidGen( Qtopia::UidGen::Qtopia );
50 50
51/*! 51/*!
52 Creates a new, empty contact. 52 Creates a new, empty contact.
53*/ 53*/
54OContact::OContact() 54OContact::OContact()
55 : OPimRecord(), mMap(), d( 0 ) 55 : OPimRecord(), mMap(), d( 0 )
56{ 56{
57} 57}
58 58
59/*! 59/*!
60 \internal 60 \internal
61 Creates a new contact. The properties of the contact are 61 Creates a new contact. The properties of the contact are
62 set from \a fromMap. 62 set from \a fromMap.
63*/ 63*/
64OContact::OContact( const QMap<int, QString> &fromMap ) : 64OContact::OContact( const QMap<int, QString> &fromMap ) :
65 OPimRecord(), mMap( fromMap ), d( 0 ) 65 OPimRecord(), mMap( fromMap ), d( 0 )
66{ 66{
67 QString cats = mMap[ Qtopia::AddressCategory ]; 67 QString cats = mMap[ Qtopia::AddressCategory ];
68 if ( !cats.isEmpty() ) 68 if ( !cats.isEmpty() )
69 setCategories( idsFromString( cats ) ); 69 setCategories( idsFromString( cats ) );
70 QString uidStr = find( Qtopia::AddressUid ); 70 QString uidStr = find( Qtopia::AddressUid );
71 71
72 if ( uidStr.isEmpty() ) 72 if ( uidStr.isEmpty() )
73 setUid( uidGen().generate() ); 73 setUid( uidGen().generate() );
74 else 74 else
75 setUid( uidStr.toInt() ); 75 setUid( uidStr.toInt() );
76 76
77 if ( !uidStr.isEmpty() ) 77 if ( !uidStr.isEmpty() )
78 setUid( uidStr.toInt() ); 78 setUid( uidStr.toInt() );
79} 79}
80 80
81/*! 81/*!
82 Destroys a contact. 82 Destroys a contact.
83*/ 83*/
84OContact::~OContact() 84OContact::~OContact()
85{ 85{
86} 86}
87 87
88/*! \fn void OContact::setTitle( const QString &str ) 88/*! \fn void OContact::setTitle( const QString &str )
89 Sets the title of the contact to \a str. 89 Sets the title of the contact to \a str.
90*/ 90*/
91 91
92/*! \fn void OContact::setFirstName( const QString &str ) 92/*! \fn void OContact::setFirstName( const QString &str )
93 Sets the first name of the contact to \a str. 93 Sets the first name of the contact to \a str.
94*/ 94*/
95 95
96/*! \fn void OContact::setMiddleName( const QString &str ) 96/*! \fn void OContact::setMiddleName( const QString &str )
97 Sets the middle name of the contact to \a str. 97 Sets the middle name of the contact to \a str.
98*/ 98*/
99 99
100/*! \fn void OContact::setLastName( const QString &str ) 100/*! \fn void OContact::setLastName( const QString &str )
101 Sets the last name of the contact to \a str. 101 Sets the last name of the contact to \a str.
102*/ 102*/
103 103
104/*! \fn void OContact::setSuffix( const QString &str ) 104/*! \fn void OContact::setSuffix( const QString &str )
105 Sets the suffix of the contact to \a str. 105 Sets the suffix of the contact to \a str.
106*/ 106*/
107 107
108/*! \fn void OContact::setFileAs( const QString &str ) 108/*! \fn void OContact::setFileAs( const QString &str )
109 Sets the contact to filed as \a str. 109 Sets the contact to filed as \a str.
110*/ 110*/
111 111
112/*! \fn void OContact::setDefaultEmail( const QString &str ) 112/*! \fn void OContact::setDefaultEmail( const QString &str )
113 Sets the default email of the contact to \a str. 113 Sets the default email of the contact to \a str.
114*/ 114*/
115 115
116/*! \fn void OContact::setHomeStreet( const QString &str ) 116/*! \fn void OContact::setHomeStreet( const QString &str )
117 Sets the home street address of the contact to \a str. 117 Sets the home street address of the contact to \a str.
118*/ 118*/
119 119
120/*! \fn void OContact::setHomeCity( const QString &str ) 120/*! \fn void OContact::setHomeCity( const QString &str )
121 Sets the home city of the contact to \a str. 121 Sets the home city of the contact to \a str.
122*/ 122*/
123 123
124/*! \fn void OContact::setHomeState( const QString &str ) 124/*! \fn void OContact::setHomeState( const QString &str )
125 Sets the home state of the contact to \a str. 125 Sets the home state of the contact to \a str.
126*/ 126*/
127 127
128/*! \fn void OContact::setHomeZip( const QString &str ) 128/*! \fn void OContact::setHomeZip( const QString &str )
129 Sets the home zip code of the contact to \a str. 129 Sets the home zip code of the contact to \a str.
130*/ 130*/
131 131
132/*! \fn void OContact::setHomeCountry( const QString &str ) 132/*! \fn void OContact::setHomeCountry( const QString &str )
133 Sets the home country of the contact to \a str. 133 Sets the home country of the contact to \a str.
134*/ 134*/
135 135
136/*! \fn void OContact::setHomePhone( const QString &str ) 136/*! \fn void OContact::setHomePhone( const QString &str )
137 Sets the home phone number of the contact to \a str. 137 Sets the home phone number of the contact to \a str.
138*/ 138*/
139 139
140/*! \fn void OContact::setHomeFax( const QString &str ) 140/*! \fn void OContact::setHomeFax( const QString &str )
141 Sets the home fax number of the contact to \a str. 141 Sets the home fax number of the contact to \a str.
142*/ 142*/
143 143
144/*! \fn void OContact::setHomeMobile( const QString &str ) 144/*! \fn void OContact::setHomeMobile( const QString &str )
145 Sets the home mobile phone number of the contact to \a str. 145 Sets the home mobile phone number of the contact to \a str.
146*/ 146*/
147 147
148/*! \fn void OContact::setHomeWebpage( const QString &str ) 148/*! \fn void OContact::setHomeWebpage( const QString &str )
149 Sets the home webpage of the contact to \a str. 149 Sets the home webpage of the contact to \a str.
150*/ 150*/
151 151
152/*! \fn void OContact::setCompany( const QString &str ) 152/*! \fn void OContact::setCompany( const QString &str )
153 Sets the company for contact to \a str. 153 Sets the company for contact to \a str.
154*/ 154*/
155 155
156/*! \fn void OContact::setJobTitle( const QString &str ) 156/*! \fn void OContact::setJobTitle( const QString &str )
157 Sets the job title of the contact to \a str. 157 Sets the job title of the contact to \a str.
158*/ 158*/
159 159
160/*! \fn void OContact::setDepartment( const QString &str ) 160/*! \fn void OContact::setDepartment( const QString &str )
161 Sets the department for contact to \a str. 161 Sets the department for contact to \a str.
162*/ 162*/
163 163
164/*! \fn void OContact::setOffice( const QString &str ) 164/*! \fn void OContact::setOffice( const QString &str )
165 Sets the office for contact to \a str. 165 Sets the office for contact to \a str.
166*/ 166*/
167 167
168/*! \fn void OContact::setBusinessStreet( const QString &str ) 168/*! \fn void OContact::setBusinessStreet( const QString &str )
169 Sets the business street address of the contact to \a str. 169 Sets the business street address of the contact to \a str.
170*/ 170*/
171 171
172/*! \fn void OContact::setBusinessCity( const QString &str ) 172/*! \fn void OContact::setBusinessCity( const QString &str )
173 Sets the business city of the contact to \a str. 173 Sets the business city of the contact to \a str.
174*/ 174*/
175 175
176/*! \fn void OContact::setBusinessState( const QString &str ) 176/*! \fn void OContact::setBusinessState( const QString &str )
177 Sets the business state of the contact to \a str. 177 Sets the business state of the contact to \a str.
178*/ 178*/
179 179
180/*! \fn void OContact::setBusinessZip( const QString &str ) 180/*! \fn void OContact::setBusinessZip( const QString &str )
181 Sets the business zip code of the contact to \a str. 181 Sets the business zip code of the contact to \a str.
182*/ 182*/
183 183
184/*! \fn void OContact::setBusinessCountry( const QString &str ) 184/*! \fn void OContact::setBusinessCountry( const QString &str )
185 Sets the business country of the contact to \a str. 185 Sets the business country of the contact to \a str.
186*/ 186*/
187 187
188/*! \fn void OContact::setBusinessPhone( const QString &str ) 188/*! \fn void OContact::setBusinessPhone( const QString &str )
189 Sets the business phone number of the contact to \a str. 189 Sets the business phone number of the contact to \a str.
190*/ 190*/
191 191
192/*! \fn void OContact::setBusinessFax( const QString &str ) 192/*! \fn void OContact::setBusinessFax( const QString &str )
193 Sets the business fax number of the contact to \a str. 193 Sets the business fax number of the contact to \a str.
194*/ 194*/
195 195
196/*! \fn void OContact::setBusinessMobile( const QString &str ) 196/*! \fn void OContact::setBusinessMobile( const QString &str )
197 Sets the business mobile phone number of the contact to \a str. 197 Sets the business mobile phone number of the contact to \a str.
198*/ 198*/
199 199
200/*! \fn void OContact::setBusinessPager( const QString &str ) 200/*! \fn void OContact::setBusinessPager( const QString &str )
201 Sets the business pager number of the contact to \a str. 201 Sets the business pager number of the contact to \a str.
202*/ 202*/
203 203
204/*! \fn void OContact::setBusinessWebpage( const QString &str ) 204/*! \fn void OContact::setBusinessWebpage( const QString &str )
205 Sets the business webpage of the contact to \a str. 205 Sets the business webpage of the contact to \a str.
206*/ 206*/
207 207
208/*! \fn void OContact::setProfession( const QString &str ) 208/*! \fn void OContact::setProfession( const QString &str )
209 Sets the profession of the contact to \a str. 209 Sets the profession of the contact to \a str.
210*/ 210*/
211 211
212/*! \fn void OContact::setAssistant( const QString &str ) 212/*! \fn void OContact::setAssistant( const QString &str )
213 Sets the assistant of the contact to \a str. 213 Sets the assistant of the contact to \a str.
214*/ 214*/
215 215
216/*! \fn void OContact::setManager( const QString &str ) 216/*! \fn void OContact::setManager( const QString &str )
217 Sets the manager of the contact to \a str. 217 Sets the manager of the contact to \a str.
218*/ 218*/
219 219
220/*! \fn void OContact::setSpouse( const QString &str ) 220/*! \fn void OContact::setSpouse( const QString &str )
221 Sets the spouse of the contact to \a str. 221 Sets the spouse of the contact to \a str.
222*/ 222*/
223 223
224/*! \fn void OContact::setGender( const QString &str ) 224/*! \fn void OContact::setGender( const QString &str )
225 Sets the gender of the contact to \a str. 225 Sets the gender of the contact to \a str.
226*/ 226*/
227 227
228/*! \fn void OContact::setBirthday( const QString &str ) 228/*! \fn void OContact::setBirthday( const QString &str )
229 Sets the birthday for the contact to \a str. 229 Sets the birthday for the contact to \a str.
230*/ 230*/
231 231
232/*! \fn void OContact::setAnniversary( const QString &str ) 232/*! \fn void OContact::setAnniversary( const QString &str )
233 Sets the anniversary of the contact to \a str. 233 Sets the anniversary of the contact to \a str.
234*/ 234*/
235 235
236/*! \fn void OContact::setNickname( const QString &str ) 236/*! \fn void OContact::setNickname( const QString &str )
237 Sets the nickname of the contact to \a str. 237 Sets the nickname of the contact to \a str.
238*/ 238*/
239 239
240/*! \fn void OContact::setNotes( const QString &str ) 240/*! \fn void OContact::setNotes( const QString &str )
241 Sets the notes about the contact to \a str. 241 Sets the notes about the contact to \a str.
242*/ 242*/
243 243
244/*! \fn QString OContact::title() const 244/*! \fn QString OContact::title() const
245 Returns the title of the contact. 245 Returns the title of the contact.
246*/ 246*/
247 247
248/*! \fn QString OContact::firstName() const 248/*! \fn QString OContact::firstName() const
249 Returns the first name of the contact. 249 Returns the first name of the contact.
250*/ 250*/
251 251
252/*! \fn QString OContact::middleName() const 252/*! \fn QString OContact::middleName() const
253 Returns the middle name of the contact. 253 Returns the middle name of the contact.
254*/ 254*/
255 255
256/*! \fn QString OContact::lastName() const 256/*! \fn QString OContact::lastName() const
257 Returns the last name of the contact. 257 Returns the last name of the contact.
258*/ 258*/
259 259
260/*! \fn QString OContact::suffix() const 260/*! \fn QString OContact::suffix() const
261 Returns the suffix of the contact. 261 Returns the suffix of the contact.
262*/ 262*/
263 263
264/*! \fn QString OContact::fileAs() const 264/*! \fn QString OContact::fileAs() const
265 Returns the string the contact is filed as. 265 Returns the string the contact is filed as.
266*/ 266*/
267 267
268/*! \fn QString OContact::defaultEmail() const 268/*! \fn QString OContact::defaultEmail() const
269 Returns the default email address of the contact. 269 Returns the default email address of the contact.
270*/ 270*/
271 271
272/*! \fn QString OContact::emails() const 272/*! \fn QString OContact::emails() const
273 Returns the list of email address for a contact separated by ';'s in a single 273 Returns the list of email address for a contact separated by ';'s in a single
274 string. 274 string.
275*/ 275*/
276 276
277/*! \fn QString OContact::homeStreet() const 277/*! \fn QString OContact::homeStreet() const
278 Returns the home street address of the contact. 278 Returns the home street address of the contact.
279*/ 279*/
280 280
281/*! \fn QString OContact::homeCity() const 281/*! \fn QString OContact::homeCity() const
282 Returns the home city of the contact. 282 Returns the home city of the contact.
283*/ 283*/
284 284
285/*! \fn QString OContact::homeState() const 285/*! \fn QString OContact::homeState() const
286 Returns the home state of the contact. 286 Returns the home state of the contact.
287*/ 287*/
288 288
289/*! \fn QString OContact::homeZip() const 289/*! \fn QString OContact::homeZip() const
290 Returns the home zip of the contact. 290 Returns the home zip of the contact.
291*/ 291*/
292 292
293/*! \fn QString OContact::homeCountry() const 293/*! \fn QString OContact::homeCountry() const
294 Returns the home country of the contact. 294 Returns the home country of the contact.
295*/ 295*/
296 296
297/*! \fn QString OContact::homePhone() const 297/*! \fn QString OContact::homePhone() const
298 Returns the home phone number of the contact. 298 Returns the home phone number of the contact.
299*/ 299*/
300 300
301/*! \fn QString OContact::homeFax() const 301/*! \fn QString OContact::homeFax() const
302 Returns the home fax number of the contact. 302 Returns the home fax number of the contact.
303*/ 303*/
304 304
305/*! \fn QString OContact::homeMobile() const 305/*! \fn QString OContact::homeMobile() const
306 Returns the home mobile number of the contact. 306 Returns the home mobile number of the contact.
307*/ 307*/
308 308
309/*! \fn QString OContact::homeWebpage() const 309/*! \fn QString OContact::homeWebpage() const
310 Returns the home webpage of the contact. 310 Returns the home webpage of the contact.
311*/ 311*/
312 312
313/*! \fn QString OContact::company() const 313/*! \fn QString OContact::company() const
314 Returns the company for the contact. 314 Returns the company for the contact.
315*/ 315*/
316 316
317/*! \fn QString OContact::department() const 317/*! \fn QString OContact::department() const
318 Returns the department for the contact. 318 Returns the department for the contact.
319*/ 319*/
320 320
321/*! \fn QString OContact::office() const 321/*! \fn QString OContact::office() const
322 Returns the office for the contact. 322 Returns the office for the contact.
323*/ 323*/
324 324
325/*! \fn QString OContact::jobTitle() const 325/*! \fn QString OContact::jobTitle() const
326 Returns the job title of the contact. 326 Returns the job title of the contact.
327*/ 327*/
328 328
329/*! \fn QString OContact::profession() const 329/*! \fn QString OContact::profession() const
330 Returns the profession of the contact. 330 Returns the profession of the contact.
331*/ 331*/
332 332
333/*! \fn QString OContact::assistant() const 333/*! \fn QString OContact::assistant() const
334 Returns the assistant of the contact. 334 Returns the assistant of the contact.
335*/ 335*/
336 336
337/*! \fn QString OContact::manager() const 337/*! \fn QString OContact::manager() const
338 Returns the manager of the contact. 338 Returns the manager of the contact.
339*/ 339*/
340 340
341/*! \fn QString OContact::businessStreet() const 341/*! \fn QString OContact::businessStreet() const
342 Returns the business street address of the contact. 342 Returns the business street address of the contact.
343*/ 343*/
344 344
345/*! \fn QString OContact::businessCity() const 345/*! \fn QString OContact::businessCity() const
346 Returns the business city of the contact. 346 Returns the business city of the contact.
347*/ 347*/
348 348
349/*! \fn QString OContact::businessState() const 349/*! \fn QString OContact::businessState() const
350 Returns the business state of the contact. 350 Returns the business state of the contact.
351*/ 351*/
352 352
353/*! \fn QString OContact::businessZip() const 353/*! \fn QString OContact::businessZip() const
354 Returns the business zip of the contact. 354 Returns the business zip of the contact.
355*/ 355*/
356 356
357/*! \fn QString OContact::businessCountry() const 357/*! \fn QString OContact::businessCountry() const
358 Returns the business country of the contact. 358 Returns the business country of the contact.
359*/ 359*/
360 360
361/*! \fn QString OContact::businessPhone() const 361/*! \fn QString OContact::businessPhone() const
362 Returns the business phone number of the contact. 362 Returns the business phone number of the contact.
363*/ 363*/
364 364
365/*! \fn QString OContact::businessFax() const 365/*! \fn QString OContact::businessFax() const
366 Returns the business fax number of the contact. 366 Returns the business fax number of the contact.
367*/ 367*/
368 368
369/*! \fn QString OContact::businessMobile() const 369/*! \fn QString OContact::businessMobile() const
370 Returns the business mobile number of the contact. 370 Returns the business mobile number of the contact.
371*/ 371*/
372 372
373/*! \fn QString OContact::businessPager() const 373/*! \fn QString OContact::businessPager() const
374 Returns the business pager number of the contact. 374 Returns the business pager number of the contact.
375*/ 375*/
376 376
377/*! \fn QString OContact::businessWebpage() const 377/*! \fn QString OContact::businessWebpage() const
378 Returns the business webpage of the contact. 378 Returns the business webpage of the contact.
379*/ 379*/
380 380
381/*! \fn QString OContact::spouse() const 381/*! \fn QString OContact::spouse() const
382 Returns the spouse of the contact. 382 Returns the spouse of the contact.
383*/ 383*/
384 384
385/*! \fn QString OContact::gender() const 385/*! \fn QString OContact::gender() const
386 Returns the gender of the contact. 386 Returns the gender of the contact.
387*/ 387*/
388 388
389/*! \fn QString OContact::birthday() const 389/*! \fn QString OContact::birthday() const
390 Returns the birthday of the contact. 390 Returns the birthday of the contact.
391*/ 391*/
392 392
393/*! \fn QString OContact::anniversary() const 393/*! \fn QString OContact::anniversary() const
394 Returns the anniversary of the contact. 394 Returns the anniversary of the contact.
395*/ 395*/
396 396
397/*! \fn QString OContact::nickname() const 397/*! \fn QString OContact::nickname() const
398 Returns the nickname of the contact. 398 Returns the nickname of the contact.
399*/ 399*/
400 400
401/*! \fn QString OContact::children() const 401/*! \fn QString OContact::children() const
402 Returns the children of the contact. 402 Returns the children of the contact.
403*/ 403*/
404 404
405/*! \fn QString OContact::notes() const 405/*! \fn QString OContact::notes() const
406 Returns the notes relating to the the contact. 406 Returns the notes relating to the the contact.
407*/ 407*/
408 408
409/*! \fn QString OContact::groups() const 409/*! \fn QString OContact::groups() const
410 \internal 410 \internal
411 Returns the groups for the contact. 411 Returns the groups for the contact.
412*/ 412*/
413 413
414/*! \fn QStringList OContact::groupList() const 414/*! \fn QStringList OContact::groupList() const
415 \internal 415 \internal
416*/ 416*/
417 417
418/*! \fn QString OContact::field(int) const 418/*! \fn QString OContact::field(int) const
419 \internal 419 \internal
420*/ 420*/
421 421
422/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) 422/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null )
423 \internal 423 \internal
424*/ 424*/
425 425
426/*! \fn void OContact::setUid( int id ) 426/*! \fn void OContact::setUid( int id )
427 \internal 427 \internal
428 Sets the uid for this record to \a id. 428 Sets the uid for this record to \a id.
429*/ 429*/
430 430
431/*! \enum OContact::journal_action 431/*! \enum OContact::journal_action
432 \internal 432 \internal
433*/ 433*/
434 434
435/*! 435/*!
436 \internal 436 \internal
437*/ 437*/
438QMap<int, QString> OContact::toMap() const 438QMap<int, QString> OContact::toMap() const
439{ 439{
440 QMap<int, QString> map = mMap; 440 QMap<int, QString> map = mMap;
441 QString cats = idsToString( categories() ); 441 QString cats = idsToString( categories() );
442 if ( !cats.isEmpty() ) 442 if ( !cats.isEmpty() )
443 map.insert( Qtopia::AddressCategory, cats ); 443 map.insert( Qtopia::AddressCategory, cats );
444 return map; 444 return map;
445} 445}
446 446
447/*! 447/*!
448 Returns a rich text formatted QString representing the contents the contact. 448 Returns a rich text formatted QString representing the contents the contact.
449*/ 449*/
450QString OContact::toRichText() const 450QString OContact::toRichText() const
451{ 451{
452 QString text; 452 QString text;
453 QString value, comp, state; 453 QString value, comp, state;
454 454
455 // name, jobtitle and company 455 // name, jobtitle and company
456 if ( !(value = fullName()).isEmpty() ) 456 if ( !(value = fullName()).isEmpty() )
457 text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; 457 text += "<b>" + Qtopia::escapeString(value) + "</b><br>";
458 if ( !(value = jobTitle()).isEmpty() ) 458 if ( !(value = jobTitle()).isEmpty() )
459 text += Qtopia::escapeString(value) + "<br>"; 459 text += Qtopia::escapeString(value) + "<br>";
460 460
461 comp = company(); 461 comp = company();
462 if ( !(value = department()).isEmpty() ) { 462 if ( !(value = department()).isEmpty() ) {
463 text += Qtopia::escapeString(value); 463 text += Qtopia::escapeString(value);
464 if ( comp ) 464 if ( comp )
465 text += ", "; 465 text += ", ";
466 else 466 else
467 text += "<br>"; 467 text += "<br>";
468 } 468 }
469 if ( !comp.isEmpty() ) 469 if ( !comp.isEmpty() )
470 text += Qtopia::escapeString(comp) + "<br>"; 470 text += Qtopia::escapeString(comp) + "<br>";
471 471
472 // business address 472 // business address
473 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 473 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
474 !businessZip().isEmpty() || !businessCountry().isEmpty() ) { 474 !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
475 text += "<br>"; 475 text += "<br>";
476 text += QObject::tr( "<b>Work Address:</b>" ); 476 text += QObject::tr( "<b>Work Address:</b>" );
477 text += "<br>"; 477 text += "<br>";
478 } 478 }
479 479
480 if ( !(value = businessStreet()).isEmpty() ) 480 if ( !(value = businessStreet()).isEmpty() )
481 text += Qtopia::escapeString(value) + "<br>"; 481 text += Qtopia::escapeString(value) + "<br>";
482 state = businessState(); 482 state = businessState();
483 if ( !(value = businessCity()).isEmpty() ) { 483 if ( !(value = businessCity()).isEmpty() ) {
484 text += Qtopia::escapeString(value); 484 text += Qtopia::escapeString(value);
485 if ( state ) 485 if ( state )
486 text += ", " + Qtopia::escapeString(state); 486 text += ", " + Qtopia::escapeString(state);
487 text += "<br>"; 487 text += "<br>";
488 } else if ( !state.isEmpty() ) 488 } else if ( !state.isEmpty() )
489 text += Qtopia::escapeString(state) + "<br>"; 489 text += Qtopia::escapeString(state) + "<br>";
490 if ( !(value = businessZip()).isEmpty() ) 490 if ( !(value = businessZip()).isEmpty() )
491 text += Qtopia::escapeString(value) + "<br>"; 491 text += Qtopia::escapeString(value) + "<br>";
492 if ( !(value = businessCountry()).isEmpty() ) 492 if ( !(value = businessCountry()).isEmpty() )
493 text += Qtopia::escapeString(value) + "<br>"; 493 text += Qtopia::escapeString(value) + "<br>";
494 494
495 // home address 495 // home address
496 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || 496 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
497 !homeZip().isEmpty() || !homeCountry().isEmpty() ) { 497 !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
498 text += "<br>"; 498 text += "<br>";
499 text += QObject::tr( "<b>Home Address:</b>" ); 499 text += QObject::tr( "<b>Home Address:</b>" );
500 text += "<br>"; 500 text += "<br>";
501 } 501 }
502 502
503 if ( !(value = homeStreet()).isEmpty() ) 503 if ( !(value = homeStreet()).isEmpty() )
504 text += Qtopia::escapeString(value) + "<br>"; 504 text += Qtopia::escapeString(value) + "<br>";
505 state = homeState(); 505 state = homeState();
506 if ( !(value = homeCity()).isEmpty() ) { 506 if ( !(value = homeCity()).isEmpty() ) {
507 text += Qtopia::escapeString(value); 507 text += Qtopia::escapeString(value);
508 if ( !state.isEmpty() ) 508 if ( !state.isEmpty() )
509 text += ", " + Qtopia::escapeString(state); 509 text += ", " + Qtopia::escapeString(state);
510 text += "<br>"; 510 text += "<br>";
511 } else if (!state.isEmpty()) 511 } else if (!state.isEmpty())
512 text += Qtopia::escapeString(state) + "<br>"; 512 text += Qtopia::escapeString(state) + "<br>";
513 if ( !(value = homeZip()).isEmpty() ) 513 if ( !(value = homeZip()).isEmpty() )
514 text += Qtopia::escapeString(value) + "<br>"; 514 text += Qtopia::escapeString(value) + "<br>";
515 if ( !(value = homeCountry()).isEmpty() ) 515 if ( !(value = homeCountry()).isEmpty() )
516 text += Qtopia::escapeString(value) + "<br>"; 516 text += Qtopia::escapeString(value) + "<br>";
517 517
518 // the others... 518 // the others...
519 QString str; 519 QString str;
520 str = emails(); 520 str = emails();
521 if ( !str.isEmpty() ) 521 if ( !str.isEmpty() )
522 text += "<b>" + QObject::tr("Email Addresses: ") + "</b>" 522 text += "<b>" + QObject::tr("Email Addresses: ") + "</b>"
523 + Qtopia::escapeString(str) + "<br>"; 523 + Qtopia::escapeString(str) + "<br>";
524 str = homePhone(); 524 str = homePhone();
525 if ( !str.isEmpty() ) 525 if ( !str.isEmpty() )
526 text += "<b>" + QObject::tr("Home Phone: ") + "</b>" 526 text += "<b>" + QObject::tr("Home Phone: ") + "</b>"
527 + Qtopia::escapeString(str) + "<br>"; 527 + Qtopia::escapeString(str) + "<br>";
528 str = homeFax(); 528 str = homeFax();
529 if ( !str.isEmpty() ) 529 if ( !str.isEmpty() )
530 text += "<b>" + QObject::tr("Home Fax: ") + "</b>" 530 text += "<b>" + QObject::tr("Home Fax: ") + "</b>"
531 + Qtopia::escapeString(str) + "<br>"; 531 + Qtopia::escapeString(str) + "<br>";
532 str = homeMobile(); 532 str = homeMobile();
533 if ( !str.isEmpty() ) 533 if ( !str.isEmpty() )
534 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" 534 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>"
535 + Qtopia::escapeString(str) + "<br>"; 535 + Qtopia::escapeString(str) + "<br>";
536 str = homeWebpage(); 536 str = homeWebpage();
537 if ( !str.isEmpty() ) 537 if ( !str.isEmpty() )
538 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" 538 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>"
539 + Qtopia::escapeString(str) + "<br>"; 539 + Qtopia::escapeString(str) + "<br>";
540 str = businessWebpage(); 540 str = businessWebpage();
541 if ( !str.isEmpty() ) 541 if ( !str.isEmpty() )
542 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" 542 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>"
543 + Qtopia::escapeString(str) + "<br>"; 543 + Qtopia::escapeString(str) + "<br>";
544 str = office(); 544 str = office();
545 if ( !str.isEmpty() ) 545 if ( !str.isEmpty() )
546 text += "<b>" + QObject::tr("Office: ") + "</b>" 546 text += "<b>" + QObject::tr("Office: ") + "</b>"
547 + Qtopia::escapeString(str) + "<br>"; 547 + Qtopia::escapeString(str) + "<br>";
548 str = businessPhone(); 548 str = businessPhone();
549 if ( !str.isEmpty() ) 549 if ( !str.isEmpty() )
550 text += "<b>" + QObject::tr("Business Phone: ") + "</b>" 550 text += "<b>" + QObject::tr("Business Phone: ") + "</b>"
551 + Qtopia::escapeString(str) + "<br>"; 551 + Qtopia::escapeString(str) + "<br>";
552 str = businessFax(); 552 str = businessFax();
553 if ( !str.isEmpty() ) 553 if ( !str.isEmpty() )
554 text += "<b>" + QObject::tr("Business Fax: ") + "</b>" 554 text += "<b>" + QObject::tr("Business Fax: ") + "</b>"
555 + Qtopia::escapeString(str) + "<br>"; 555 + Qtopia::escapeString(str) + "<br>";
556 str = businessMobile(); 556 str = businessMobile();
557 if ( !str.isEmpty() ) 557 if ( !str.isEmpty() )
558 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" 558 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>"
559 + Qtopia::escapeString(str) + "<br>"; 559 + Qtopia::escapeString(str) + "<br>";
560 str = businessPager(); 560 str = businessPager();
561 if ( !str.isEmpty() ) 561 if ( !str.isEmpty() )
562 text += "<b>" + QObject::tr("Business Pager: ") + "</b>" 562 text += "<b>" + QObject::tr("Business Pager: ") + "</b>"
563 + Qtopia::escapeString(str) + "<br>"; 563 + Qtopia::escapeString(str) + "<br>";
564 str = profession(); 564 str = profession();
565 if ( !str.isEmpty() ) 565 if ( !str.isEmpty() )
566 text += "<b>" + QObject::tr("Profession: ") + "</b>" 566 text += "<b>" + QObject::tr("Profession: ") + "</b>"
567 + Qtopia::escapeString(str) + "<br>"; 567 + Qtopia::escapeString(str) + "<br>";
568 str = assistant(); 568 str = assistant();
569 if ( !str.isEmpty() ) 569 if ( !str.isEmpty() )
570 text += "<b>" + QObject::tr("Assistant: ") + "</b>" 570 text += "<b>" + QObject::tr("Assistant: ") + "</b>"
571 + Qtopia::escapeString(str) + "<br>"; 571 + Qtopia::escapeString(str) + "<br>";
572 str = manager(); 572 str = manager();
573 if ( !str.isEmpty() ) 573 if ( !str.isEmpty() )
574 text += "<b>" + QObject::tr("Manager: ") + "</b>" 574 text += "<b>" + QObject::tr("Manager: ") + "</b>"
575 + Qtopia::escapeString(str) + "<br>"; 575 + Qtopia::escapeString(str) + "<br>";
576 str = gender(); 576 str = gender();
577 if ( !str.isEmpty() && str.toInt() != 0 ) { 577 if ( !str.isEmpty() && str.toInt() != 0 ) {
578 if ( str.toInt() == 1 ) 578 if ( str.toInt() == 1 )
579 str = QObject::tr( "Male" ); 579 str = QObject::tr( "Male" );
580 else if ( str.toInt() == 2 ) 580 else if ( str.toInt() == 2 )
581 str = QObject::tr( "Female" ); 581 str = QObject::tr( "Female" );
582 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; 582 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>";
583 } 583 }
584 str = spouse(); 584 str = spouse();
585 if ( !str.isEmpty() ) 585 if ( !str.isEmpty() )
586 text += "<b>" + QObject::tr("Spouse: ") + "</b>" 586 text += "<b>" + QObject::tr("Spouse: ") + "</b>"
587 + Qtopia::escapeString(str) + "<br>"; 587 + Qtopia::escapeString(str) + "<br>";
588 str = birthday(); 588 str = birthday();
589 if ( !str.isEmpty() ) 589 if ( !str.isEmpty() )
590 text += "<b>" + QObject::tr("Birthday: ") + "</b>" 590 text += "<b>" + QObject::tr("Birthday: ") + "</b>"
591 + Qtopia::escapeString(str) + "<br>"; 591 + Qtopia::escapeString(str) + "<br>";
592 str = anniversary(); 592 str = anniversary();
593 if ( !str.isEmpty() ) 593 if ( !str.isEmpty() )
594 text += "<b>" + QObject::tr("Anniversary: ") + "</b>" 594 text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
595 + Qtopia::escapeString(str) + "<br>"; 595 + Qtopia::escapeString(str) + "<br>";
596 str = nickname(); 596 str = nickname();
597 if ( !str.isEmpty() ) 597 if ( !str.isEmpty() )
598 text += "<b>" + QObject::tr("Nickname: ") + "</b>" 598 text += "<b>" + QObject::tr("Nickname: ") + "</b>"
599 + Qtopia::escapeString(str) + "<br>"; 599 + Qtopia::escapeString(str) + "<br>";
600 600
601 // notes last 601 // notes last
602 if ( (value = notes()) ) { 602 if ( (value = notes()) ) {
603 QRegExp reg("\n"); 603 QRegExp reg("\n");
604 604
605 //QString tmp = Qtopia::escapeString(value); 605 //QString tmp = Qtopia::escapeString(value);
606 QString tmp = QStyleSheet::convertFromPlainText(value); 606 QString tmp = QStyleSheet::convertFromPlainText(value);
607 //tmp.replace( reg, "<br>" ); 607 //tmp.replace( reg, "<br>" );
608 text += "<br>" + tmp + "<br>"; 608 text += "<br>" + tmp + "<br>";
609 } 609 }
610 return text; 610 return text;
611} 611}
612 612
613/*! 613/*!
614 \internal 614 \internal
615*/ 615*/
616void OContact::insert( int key, const QString &v ) 616void OContact::insert( int key, const QString &v )
617{ 617{
618 QString value = v.stripWhiteSpace(); 618 QString value = v.stripWhiteSpace();
619 if ( value.isEmpty() ) 619 if ( value.isEmpty() )
620 mMap.remove( key ); 620 mMap.remove( key );
621 else 621 else
622 mMap.insert( key, value ); 622 mMap.insert( key, value );
623} 623}
624 624
625/*! 625/*!
626 \internal 626 \internal
627*/ 627*/
628void OContact::replace( int key, const QString & v ) 628void OContact::replace( int key, const QString & v )
629{ 629{
630 QString value = v.stripWhiteSpace(); 630 QString value = v.stripWhiteSpace();
631 if ( value.isEmpty() ) 631 if ( value.isEmpty() )
632 mMap.remove( key ); 632 mMap.remove( key );
633 else 633 else
634 mMap.replace( key, value ); 634 mMap.replace( key, value );
635} 635}
636 636
637/*! 637/*!
638 \internal 638 \internal
639*/ 639*/
640QString OContact::find( int key ) const 640QString OContact::find( int key ) const
641{ 641{
642 return mMap[key]; 642 return mMap[key];
643} 643}
644 644
645/*! 645/*!
646 \internal 646 \internal
647*/ 647*/
648QString OContact::displayAddress( const QString &street, 648QString OContact::displayAddress( const QString &street,
649 const QString &city, 649 const QString &city,
650 const QString &state, 650 const QString &state,
651 const QString &zip, 651 const QString &zip,
652 const QString &country ) const 652 const QString &country ) const
653{ 653{
654 QString s = street; 654 QString s = street;
655 if ( !street.isEmpty() ) 655 if ( !street.isEmpty() )
656 s+= "\n"; 656 s+= "\n";
657 s += city; 657 s += city;
658 if ( !city.isEmpty() && !state.isEmpty() ) 658 if ( !city.isEmpty() && !state.isEmpty() )
659 s += ", "; 659 s += ", ";
660 s += state; 660 s += state;
661 if ( !state.isEmpty() && !zip.isEmpty() ) 661 if ( !state.isEmpty() && !zip.isEmpty() )
662 s += " "; 662 s += " ";
663 s += zip; 663 s += zip;
664 if ( !country.isEmpty() && !s.isEmpty() ) 664 if ( !country.isEmpty() && !s.isEmpty() )
665 s += "\n"; 665 s += "\n";
666 s += country; 666 s += country;
667 return s; 667 return s;
668} 668}
669 669
670/*! 670/*!
671 \internal 671 \internal
672*/ 672*/
673QString OContact::displayBusinessAddress() const 673QString OContact::displayBusinessAddress() const
674{ 674{
675 return displayAddress( businessStreet(), businessCity(), 675 return displayAddress( businessStreet(), businessCity(),
676 businessState(), businessZip(), 676 businessState(), businessZip(),
677 businessCountry() ); 677 businessCountry() );
678} 678}
679 679
680/*! 680/*!
681 \internal 681 \internal
682*/ 682*/
683QString OContact::displayHomeAddress() const 683QString OContact::displayHomeAddress() const
684{ 684{
685 return displayAddress( homeStreet(), homeCity(), 685 return displayAddress( homeStreet(), homeCity(),
686 homeState(), homeZip(), 686 homeState(), homeZip(),
687 homeCountry() ); 687 homeCountry() );
688} 688}
689 689
690/*! 690/*!
691 Returns the full name of the contact 691 Returns the full name of the contact
692*/ 692*/
693QString OContact::fullName() const 693QString OContact::fullName() const
694{ 694{
695 QString title = find( Qtopia::Title ); 695 QString title = find( Qtopia::Title );
696 QString firstName = find( Qtopia::FirstName ); 696 QString firstName = find( Qtopia::FirstName );
697 QString middleName = find( Qtopia::MiddleName ); 697 QString middleName = find( Qtopia::MiddleName );
698 QString lastName = find( Qtopia::LastName ); 698 QString lastName = find( Qtopia::LastName );
699 QString suffix = find( Qtopia::Suffix ); 699 QString suffix = find( Qtopia::Suffix );
700 700
701 QString name = title; 701 QString name = title;
702 if ( !firstName.isEmpty() ) { 702 if ( !firstName.isEmpty() ) {
703 if ( !name.isEmpty() ) 703 if ( !name.isEmpty() )
704 name += " "; 704 name += " ";
705 name += firstName; 705 name += firstName;
706 } 706 }
707 if ( !middleName.isEmpty() ) { 707 if ( !middleName.isEmpty() ) {
708 if ( !name.isEmpty() ) 708 if ( !name.isEmpty() )
709 name += " "; 709 name += " ";
710 name += middleName; 710 name += middleName;
711 } 711 }
712 if ( !lastName.isEmpty() ) { 712 if ( !lastName.isEmpty() ) {
713 if ( !name.isEmpty() ) 713 if ( !name.isEmpty() )
714 name += " "; 714 name += " ";
715 name += lastName; 715 name += lastName;
716 } 716 }
717 if ( !suffix.isEmpty() ) { 717 if ( !suffix.isEmpty() ) {
718 if ( !name.isEmpty() ) 718 if ( !name.isEmpty() )
719 name += " "; 719 name += " ";
720 name += suffix; 720 name += suffix;
721 } 721 }
722 return name.simplifyWhiteSpace(); 722 return name.simplifyWhiteSpace();
723} 723}
724 724
725/*! 725/*!
726 Returns a list of the names of the children of the contact. 726 Returns a list of the names of the children of the contact.
727*/ 727*/
728QStringList OContact::childrenList() const 728QStringList OContact::childrenList() const
729{ 729{
730 return QStringList::split( " ", find( Qtopia::Children ) ); 730 return QStringList::split( " ", find( Qtopia::Children ) );
731} 731}
732 732
733/*! \fn void OContact::insertEmail( const QString &email ) 733/*! \fn void OContact::insertEmail( const QString &email )
734 734
735 Insert \a email into the email list. Ensures \a email can only be added 735 Insert \a email into the email list. Ensures \a email can only be added
736 once. If there is no default email address set, it sets it to the \a email. 736 once. If there is no default email address set, it sets it to the \a email.
737*/ 737*/
738 738
739/*! \fn void OContact::removeEmail( const QString &email ) 739/*! \fn void OContact::removeEmail( const QString &email )
740 740
741 Removes the \a email from the email list. If the default email was \a email, 741 Removes the \a email from the email list. If the default email was \a email,
742 then the default email address is assigned to the first email in the 742 then the default email address is assigned to the first email in the
743 email list 743 email list
744*/ 744*/
745 745
746/*! \fn void OContact::clearEmails() 746/*! \fn void OContact::clearEmails()
747 747
748 Clears the email list. 748 Clears the email list.
749 */ 749 */
750 750
751/*! \fn void OContact::insertEmails( const QStringList &emailList ) 751/*! \fn void OContact::insertEmails( const QStringList &emailList )
752 752
753 Appends the \a emailList to the exiting email list 753 Appends the \a emailList to the exiting email list
754 */ 754 */
755 755
756/*! 756/*!
757 Returns a list of email addresses belonging to the contact, including 757 Returns a list of email addresses belonging to the contact, including
758 the default email address. 758 the default email address.
759*/ 759*/
760QStringList OContact::emailList() const 760QStringList OContact::emailList() const
761{ 761{
762 QString emailStr = emails(); 762 QString emailStr = emails();
763 763
764 QStringList r; 764 QStringList r;
765 if ( !emailStr.isEmpty() ) { 765 if ( !emailStr.isEmpty() ) {
766 qDebug(" emailstr "); 766 qDebug(" emailstr ");
767 QStringList l = QStringList::split( emailSeparator(), emailStr ); 767 QStringList l = QStringList::split( emailSeparator(), emailStr );
768 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) 768 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
769 r += (*it).simplifyWhiteSpace(); 769 r += (*it).simplifyWhiteSpace();
770 } 770 }
771 771
772 return r; 772 return r;
773} 773}
774 774
775/*! 775/*!
776 \overload 776 \overload
777 777
778 Generates the string for the contact to be filed as from the first, 778 Generates the string for the contact to be filed as from the first,
779 middle and last name of the contact. 779 middle and last name of the contact.
780*/ 780*/
781void OContact::setFileAs() 781void OContact::setFileAs()
782{ 782{
783 QString lastName, firstName, middleName, fileas; 783 QString lastName, firstName, middleName, fileas;
784 784
785 lastName = find( Qtopia::LastName ); 785 lastName = find( Qtopia::LastName );
786 firstName = find( Qtopia::FirstName ); 786 firstName = find( Qtopia::FirstName );
787 middleName = find( Qtopia::MiddleName ); 787 middleName = find( Qtopia::MiddleName );
788 if ( !lastName.isEmpty() && !firstName.isEmpty() 788 if ( !lastName.isEmpty() && !firstName.isEmpty()
789 && !middleName.isEmpty() ) 789 && !middleName.isEmpty() )
790 fileas = lastName + ", " + firstName + " " + middleName; 790 fileas = lastName + ", " + firstName + " " + middleName;
791 else if ( !lastName.isEmpty() && !firstName.isEmpty() ) 791 else if ( !lastName.isEmpty() && !firstName.isEmpty() )
792 fileas = lastName + ", " + firstName; 792 fileas = lastName + ", " + firstName;
793 else if ( !lastName.isEmpty() || !firstName.isEmpty() || 793 else if ( !lastName.isEmpty() || !firstName.isEmpty() ||
794 !middleName.isEmpty() ) 794 !middleName.isEmpty() )
795 fileas = firstName + ( firstName.isEmpty() ? "" : " " ) 795 fileas = firstName + ( firstName.isEmpty() ? "" : " " )
796 + middleName + ( middleName.isEmpty() ? "" : " " ) 796 + middleName + ( middleName.isEmpty() ? "" : " " )
797 + lastName; 797 + lastName;
798 798
799 replace( Qtopia::FileAs, fileas ); 799 replace( Qtopia::FileAs, fileas );
800} 800}
801 801
802/*! 802/*!
803 \internal 803 \internal
804 Appends the contact information to \a buf. 804 Appends the contact information to \a buf.
805*/ 805*/
806void OContact::save( QString &buf ) const 806void OContact::save( QString &buf ) const
807{ 807{
808 static const QStringList SLFIELDS = fields(); 808 static const QStringList SLFIELDS = fields();
809 // I'm expecting "<Contact " in front of this... 809 // I'm expecting "<Contact " in front of this...
810 for ( QMap<int, QString>::ConstIterator it = mMap.begin(); 810 for ( QMap<int, QString>::ConstIterator it = mMap.begin();
811 it != mMap.end(); ++it ) { 811 it != mMap.end(); ++it ) {
812 const QString &value = it.data(); 812 const QString &value = it.data();
813 int key = it.key(); 813 int key = it.key();
814 if ( !value.isEmpty() ) { 814 if ( !value.isEmpty() ) {
815 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) 815 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)
816 continue; 816 continue;
817 817
818 key -= Qtopia::AddressCategory+1; 818 key -= Qtopia::AddressCategory+1;
819 buf += SLFIELDS[key]; 819 buf += SLFIELDS[key];
820 buf += "=\"" + Qtopia::escapeString(value) + "\" "; 820 buf += "=\"" + Qtopia::escapeString(value) + "\" ";
821 } 821 }
822 } 822 }
823 buf += customToXml(); 823 buf += customToXml();
824 if ( categories().count() > 0 ) 824 if ( categories().count() > 0 )
825 buf += "Categories=\"" + idsToString( categories() ) + "\" "; 825 buf += "Categories=\"" + idsToString( categories() ) + "\" ";
826 buf += "Uid=\"" + QString::number( uid() ) + "\" "; 826 buf += "Uid=\"" + QString::number( uid() ) + "\" ";
827 // You need to close this yourself 827 // You need to close this yourself
828} 828}
829 829
830/*! 830/*!
831 \internal 831 \internal
832 Returns the list of fields belonging to a contact 832 Returns the list of fields belonging to a contact
833*/ 833*/
834QStringList OContact::fields() 834QStringList OContact::fields()
835{ 835{
836 QStringList list; 836 QStringList list;
837 837
838 list.append( "Title" ); // Not Used! 838 list.append( "Title" ); // Not Used!
839 list.append( "FirstName" ); 839 list.append( "FirstName" );
840 list.append( "MiddleName" ); 840 list.append( "MiddleName" );
841 list.append( "LastName" ); 841 list.append( "LastName" );
842 list.append( "Suffix" ); 842 list.append( "Suffix" );
843 list.append( "FileAs" ); 843 list.append( "FileAs" );
844 844
845 list.append( "JobTitle" ); 845 list.append( "JobTitle" );
846 list.append( "Department" ); 846 list.append( "Department" );
847 list.append( "Company" ); 847 list.append( "Company" );
848 list.append( "BusinessPhone" ); 848 list.append( "BusinessPhone" );
849 list.append( "BusinessFax" ); 849 list.append( "BusinessFax" );
850 list.append( "BusinessMobile" ); 850 list.append( "BusinessMobile" );
851 851
852 list.append( "DefaultEmail" ); 852 list.append( "DefaultEmail" );
853 list.append( "Emails" ); 853 list.append( "Emails" );
854 854
855 list.append( "HomePhone" ); 855 list.append( "HomePhone" );
856 list.append( "HomeFax" ); 856 list.append( "HomeFax" );
857 list.append( "HomeMobile" ); 857 list.append( "HomeMobile" );
858 858
859 list.append( "BusinessStreet" ); 859 list.append( "BusinessStreet" );
860 list.append( "BusinessCity" ); 860 list.append( "BusinessCity" );
861 list.append( "BusinessState" ); 861 list.append( "BusinessState" );
862 list.append( "BusinessZip" ); 862 list.append( "BusinessZip" );
863 list.append( "BusinessCountry" ); 863 list.append( "BusinessCountry" );
864 list.append( "BusinessPager" ); 864 list.append( "BusinessPager" );
865 list.append( "BusinessWebPage" ); 865 list.append( "BusinessWebPage" );
866 866
867 list.append( "Office" ); 867 list.append( "Office" );
868 list.append( "Profession" ); 868 list.append( "Profession" );
869 list.append( "Assistant" ); 869 list.append( "Assistant" );
870 list.append( "Manager" ); 870 list.append( "Manager" );
871 871
872 list.append( "HomeStreet" ); 872 list.append( "HomeStreet" );
873 list.append( "HomeCity" ); 873 list.append( "HomeCity" );
874 list.append( "HomeState" ); 874 list.append( "HomeState" );
875 list.append( "HomeZip" ); 875 list.append( "HomeZip" );
876 list.append( "HomeCountry" ); 876 list.append( "HomeCountry" );
877 list.append( "HomeWebPage" ); 877 list.append( "HomeWebPage" );
878 878
879 list.append( "Spouse" ); 879 list.append( "Spouse" );
880 list.append( "Gender" ); 880 list.append( "Gender" );
881 list.append( "Birthday" ); 881 list.append( "Birthday" );
882 list.append( "Anniversary" ); 882 list.append( "Anniversary" );
883 list.append( "Nickname" ); 883 list.append( "Nickname" );
884 list.append( "Children" ); 884 list.append( "Children" );
885 885
886 list.append( "Notes" ); 886 list.append( "Notes" );
887 list.append( "Groups" ); 887 list.append( "Groups" );
888 888
889 return list; 889 return list;
890} 890}
891 891
892/*! 892/*!
893 \internal 893 \internal
894 Returns a translated list of field names for a contact. 894 Returns a translated list of field names for a contact.
895*/ 895*/
896QStringList OContact::trfields() 896QStringList OContact::trfields()
897{ 897{
898 QStringList list; 898 QStringList list;
899 899
900 list.append( QObject::tr( "Name Title") ); 900 list.append( QObject::tr( "Name Title") );
901 list.append( QObject::tr( "First Name" ) ); 901 list.append( QObject::tr( "First Name" ) );
902 list.append( QObject::tr( "Middle Name" ) ); 902 list.append( QObject::tr( "Middle Name" ) );
903 list.append( QObject::tr( "Last Name" ) ); 903 list.append( QObject::tr( "Last Name" ) );
904 list.append( QObject::tr( "Suffix" ) ); 904 list.append( QObject::tr( "Suffix" ) );
905 list.append( QObject::tr( "File As" ) ); 905 list.append( QObject::tr( "File As" ) );
906 906
907 list.append( QObject::tr( "Job Title" ) ); 907 list.append( QObject::tr( "Job Title" ) );
908 list.append( QObject::tr( "Department" ) ); 908 list.append( QObject::tr( "Department" ) );
909 list.append( QObject::tr( "Company" ) ); 909 list.append( QObject::tr( "Company" ) );
910 list.append( QObject::tr( "Business Phone" ) ); 910 list.append( QObject::tr( "Business Phone" ) );
911 list.append( QObject::tr( "Business Fax" ) ); 911 list.append( QObject::tr( "Business Fax" ) );
912 list.append( QObject::tr( "Business Mobile" ) ); 912 list.append( QObject::tr( "Business Mobile" ) );
913 913
914 list.append( QObject::tr( "Default Email" ) ); 914 list.append( QObject::tr( "Default Email" ) );
915 list.append( QObject::tr( "Emails" ) ); 915 list.append( QObject::tr( "Emails" ) );
916 916
917 list.append( QObject::tr( "Home Phone" ) ); 917 list.append( QObject::tr( "Home Phone" ) );
918 list.append( QObject::tr( "Home Fax" ) ); 918 list.append( QObject::tr( "Home Fax" ) );
919 list.append( QObject::tr( "Home Mobile" ) ); 919 list.append( QObject::tr( "Home Mobile" ) );
920 920
921 list.append( QObject::tr( "Business Street" ) ); 921 list.append( QObject::tr( "Business Street" ) );
922 list.append( QObject::tr( "Business City" ) ); 922 list.append( QObject::tr( "Business City" ) );
923 list.append( QObject::tr( "Business State" ) ); 923 list.append( QObject::tr( "Business State" ) );
924 list.append( QObject::tr( "Business Zip" ) ); 924 list.append( QObject::tr( "Business Zip" ) );
925 list.append( QObject::tr( "Business Country" ) ); 925 list.append( QObject::tr( "Business Country" ) );
926 list.append( QObject::tr( "Business Pager" ) ); 926 list.append( QObject::tr( "Business Pager" ) );
927 list.append( QObject::tr( "Business WebPage" ) ); 927 list.append( QObject::tr( "Business WebPage" ) );
928 928
929 list.append( QObject::tr( "Office" ) ); 929 list.append( QObject::tr( "Office" ) );
930 list.append( QObject::tr( "Profession" ) ); 930 list.append( QObject::tr( "Profession" ) );
931 list.append( QObject::tr( "Assistant" ) ); 931 list.append( QObject::tr( "Assistant" ) );
932 list.append( QObject::tr( "Manager" ) ); 932 list.append( QObject::tr( "Manager" ) );
933 933
934 list.append( QObject::tr( "Home Street" ) ); 934 list.append( QObject::tr( "Home Street" ) );
935 list.append( QObject::tr( "Home City" ) ); 935 list.append( QObject::tr( "Home City" ) );
936 list.append( QObject::tr( "Home State" ) ); 936 list.append( QObject::tr( "Home State" ) );
937 list.append( QObject::tr( "Home Zip" ) ); 937 list.append( QObject::tr( "Home Zip" ) );
938 list.append( QObject::tr( "Home Country" ) ); 938 list.append( QObject::tr( "Home Country" ) );
939 list.append( QObject::tr( "Home Web Page" ) ); 939 list.append( QObject::tr( "Home Web Page" ) );
940 940
941 list.append( QObject::tr( "Spouse" ) ); 941 list.append( QObject::tr( "Spouse" ) );
942 list.append( QObject::tr( "Gender" ) ); 942 list.append( QObject::tr( "Gender" ) );
943 list.append( QObject::tr( "Birthday" ) ); 943 list.append( QObject::tr( "Birthday" ) );
944 list.append( QObject::tr( "Anniversary" ) ); 944 list.append( QObject::tr( "Anniversary" ) );
945 list.append( QObject::tr( "Nickname" ) ); 945 list.append( QObject::tr( "Nickname" ) );
946 list.append( QObject::tr( "Children" ) ); 946 list.append( QObject::tr( "Children" ) );
947 947
948 list.append( QObject::tr( "Notes" ) ); 948 list.append( QObject::tr( "Notes" ) );
949 list.append( QObject::tr( "Groups" ) ); 949 list.append( QObject::tr( "Groups" ) );
950 950
951 return list; 951 return list;
952} 952}
953 953
954/*! 954/*!
955 Sets the list of email address for contact to those contained in \a str. 955 Sets the list of email address for contact to those contained in \a str.
956 Email address should be separated by ';'s. 956 Email address should be separated by ';'s.
957*/ 957*/
958void OContact::setEmails( const QString &str ) 958void OContact::setEmails( const QString &str )
959{ 959{
960 replace( Qtopia::Emails, str ); 960 replace( Qtopia::Emails, str );
961 if ( str.isEmpty() ) 961 if ( str.isEmpty() )
962 setDefaultEmail( QString::null ); 962 setDefaultEmail( QString::null );
963} 963}
964 964
965/*! 965/*!
966 Sets the list of children for the contact to those contained in \a str. 966 Sets the list of children for the contact to those contained in \a str.
967*/ 967*/
968void OContact::setChildren( const QString &str ) 968void OContact::setChildren( const QString &str )
969{ 969{
970 replace( Qtopia::Children, str ); 970 replace( Qtopia::Children, str );
971} 971}
972 972
973// vcard conversion code 973// vcard conversion code
974/*! 974/*!
975 \internal 975 \internal
976*/ 976*/
977static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) 977static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value )
978{ 978{
979 VObject *ret = 0; 979 VObject *ret = 0;
980 if ( o && !value.isEmpty() ) 980 if ( o && !value.isEmpty() )
981 ret = addPropValue( o, prop, value.latin1() ); 981 ret = addPropValue( o, prop, value.latin1() );
982 return ret; 982 return ret;
983} 983}
984 984
985/*! 985/*!
986 \internal 986 \internal
987*/ 987*/
988static inline VObject *safeAddProp( VObject *o, const char *prop) 988static inline VObject *safeAddProp( VObject *o, const char *prop)
989{ 989{
990 VObject *ret = 0; 990 VObject *ret = 0;
991 if ( o ) 991 if ( o )
992 ret = addProp( o, prop ); 992 ret = addProp( o, prop );
993 return ret; 993 return ret;
994} 994}
995 995
996/*! 996/*!
997 \internal 997 \internal
998*/ 998*/
999static VObject *createVObject( const OContact &c ) 999static VObject *createVObject( const OContact &c )
1000{ 1000{
1001 VObject *vcard = newVObject( VCCardProp ); 1001 VObject *vcard = newVObject( VCCardProp );
1002 safeAddPropValue( vcard, VCVersionProp, "2.1" ); 1002 safeAddPropValue( vcard, VCVersionProp, "2.1" );
1003 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); 1003 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
1004 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); 1004 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
1005 1005
1006 // full name 1006 // full name
1007 safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); 1007 safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
1008 1008
1009 // name properties 1009 // name properties
1010 VObject *name = safeAddProp( vcard, VCNameProp ); 1010 VObject *name = safeAddProp( vcard, VCNameProp );
1011 safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); 1011 safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
1012 safeAddPropValue( name, VCGivenNameProp, c.firstName() ); 1012 safeAddPropValue( name, VCGivenNameProp, c.firstName() );
1013 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); 1013 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() );
1014 safeAddPropValue( name, VCNamePrefixesProp, c.title() ); 1014 safeAddPropValue( name, VCNamePrefixesProp, c.title() );
1015 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); 1015 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() );
1016 1016
1017 // home properties 1017 // home properties
1018 VObject *home_adr= safeAddProp( vcard, VCAdrProp ); 1018 VObject *home_adr= safeAddProp( vcard, VCAdrProp );
1019 safeAddProp( home_adr, VCHomeProp ); 1019 safeAddProp( home_adr, VCHomeProp );
1020 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); 1020 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() );
1021 safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); 1021 safeAddPropValue( home_adr, VCCityProp, c.homeCity() );
1022 safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); 1022 safeAddPropValue( home_adr, VCRegionProp, c.homeState() );
1023 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); 1023 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() );
1024 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); 1024 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() );
1025 1025
1026 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); 1026 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() );
1027 safeAddProp( home_phone, VCHomeProp ); 1027 safeAddProp( home_phone, VCHomeProp );
1028 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); 1028 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() );
1029 safeAddProp( home_phone, VCHomeProp ); 1029 safeAddProp( home_phone, VCHomeProp );
1030 safeAddProp( home_phone, VCCellularProp ); 1030 safeAddProp( home_phone, VCCellularProp );
1031 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); 1031 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() );
1032 safeAddProp( home_phone, VCHomeProp ); 1032 safeAddProp( home_phone, VCHomeProp );
1033 safeAddProp( home_phone, VCFaxProp ); 1033 safeAddProp( home_phone, VCFaxProp );
1034 1034
1035 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); 1035 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() );
1036 safeAddProp( url, VCHomeProp ); 1036 safeAddProp( url, VCHomeProp );
1037 1037
1038 // work properties 1038 // work properties
1039 VObject *work_adr= safeAddProp( vcard, VCAdrProp ); 1039 VObject *work_adr= safeAddProp( vcard, VCAdrProp );
1040 safeAddProp( work_adr, VCWorkProp ); 1040 safeAddProp( work_adr, VCWorkProp );
1041 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); 1041 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() );
1042 safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); 1042 safeAddPropValue( work_adr, VCCityProp, c.businessCity() );
1043 safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); 1043 safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
1044 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); 1044 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
1045 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); 1045 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
1046 1046
1047 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); 1047 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
1048 safeAddProp( work_phone, VCWorkProp ); 1048 safeAddProp( work_phone, VCWorkProp );
1049 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); 1049 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
1050 safeAddProp( work_phone, VCWorkProp ); 1050 safeAddProp( work_phone, VCWorkProp );
1051 safeAddProp( work_phone, VCCellularProp ); 1051 safeAddProp( work_phone, VCCellularProp );
1052 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); 1052 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
1053 safeAddProp( work_phone, VCWorkProp ); 1053 safeAddProp( work_phone, VCWorkProp );
1054 safeAddProp( work_phone, VCFaxProp ); 1054 safeAddProp( work_phone, VCFaxProp );
1055 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); 1055 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
1056 safeAddProp( work_phone, VCWorkProp ); 1056 safeAddProp( work_phone, VCWorkProp );
1057 safeAddProp( work_phone, VCPagerProp ); 1057 safeAddProp( work_phone, VCPagerProp );
1058 1058
1059 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); 1059 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
1060 safeAddProp( url, VCWorkProp ); 1060 safeAddProp( url, VCWorkProp );
1061 1061
1062 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); 1062 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
1063 safeAddProp( title, VCWorkProp ); 1063 safeAddProp( title, VCWorkProp );
1064 1064
1065 1065
1066 QStringList emails = c.emailList(); 1066 QStringList emails = c.emailList();
1067 emails.prepend( c.defaultEmail() ); 1067 emails.prepend( c.defaultEmail() );
1068 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 1068 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
1069 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 1069 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
1070 safeAddProp( email, VCInternetProp ); 1070 safeAddProp( email, VCInternetProp );
1071 } 1071 }
1072 1072
1073 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 1073 safeAddPropValue( vcard, VCNoteProp, c.notes() );
1074 1074
1075 safeAddPropValue( vcard, VCBirthDateProp, c.birthday() ); 1075 safeAddPropValue( vcard, VCBirthDateProp, c.birthday() );
1076 1076
1077 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 1077 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
1078 VObject *org = safeAddProp( vcard, VCOrgProp ); 1078 VObject *org = safeAddProp( vcard, VCOrgProp );
1079 safeAddPropValue( org, VCOrgNameProp, c.company() ); 1079 safeAddPropValue( org, VCOrgNameProp, c.company() );
1080 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 1080 safeAddPropValue( org, VCOrgUnitProp, c.department() );
1081 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 1081 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
1082 } 1082 }
1083 1083
1084 // some values we have to export as custom fields 1084 // some values we have to export as custom fields
1085 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 1085 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
1086 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 1086 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
1087 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 1087 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
1088 1088
1089 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 1089 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
1090 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 1090 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
1091 safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); 1091 safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() );
1092 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 1092 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
1093 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); 1093 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
1094 1094
1095 return vcard; 1095 return vcard;
1096} 1096}
1097 1097
1098 1098
1099/*! 1099/*!
1100 \internal 1100 \internal
1101*/ 1101*/
1102static OContact parseVObject( VObject *obj ) 1102static OContact parseVObject( VObject *obj )
1103{ 1103{
1104 OContact c; 1104 OContact c;
1105 1105
1106 VObjectIterator it; 1106 VObjectIterator it;
1107 initPropIterator( &it, obj ); 1107 initPropIterator( &it, obj );
1108 while( moreIteration( &it ) ) { 1108 while( moreIteration( &it ) ) {
1109 VObject *o = nextVObject( &it ); 1109 VObject *o = nextVObject( &it );
1110 QCString name = vObjectName( o ); 1110 QCString name = vObjectName( o );
1111 QCString value = vObjectStringZValue( o ); 1111 QCString value = vObjectStringZValue( o );
1112 if ( name == VCNameProp ) { 1112 if ( name == VCNameProp ) {
1113 VObjectIterator nit; 1113 VObjectIterator nit;
1114 initPropIterator( &nit, o ); 1114 initPropIterator( &nit, o );
1115 while( moreIteration( &nit ) ) { 1115 while( moreIteration( &nit ) ) {
1116 VObject *o = nextVObject( &nit ); 1116 VObject *o = nextVObject( &nit );
1117 QCString name = vObjectTypeInfo( o ); 1117 QCString name = vObjectTypeInfo( o );
1118 QString value = vObjectStringZValue( o ); 1118 QString value = vObjectStringZValue( o );
1119 if ( name == VCNamePrefixesProp ) 1119 if ( name == VCNamePrefixesProp )
1120 c.setTitle( value ); 1120 c.setTitle( value );
1121 else if ( name == VCNameSuffixesProp ) 1121 else if ( name == VCNameSuffixesProp )
1122 c.setSuffix( value ); 1122 c.setSuffix( value );
1123 else if ( name == VCFamilyNameProp ) 1123 else if ( name == VCFamilyNameProp )
1124 c.setLastName( value ); 1124 c.setLastName( value );
1125 else if ( name == VCGivenNameProp ) 1125 else if ( name == VCGivenNameProp )
1126 c.setFirstName( value ); 1126 c.setFirstName( value );
1127 else if ( name == VCAdditionalNamesProp ) 1127 else if ( name == VCAdditionalNamesProp )
1128 c.setMiddleName( value ); 1128 c.setMiddleName( value );
1129 } 1129 }
1130 } 1130 }
1131 else if ( name == VCAdrProp ) { 1131 else if ( name == VCAdrProp ) {
1132 bool work = TRUE; // default address is work address 1132 bool work = TRUE; // default address is work address
1133 QString street; 1133 QString street;
1134 QString city; 1134 QString city;
1135 QString region; 1135 QString region;
1136 QString postal; 1136 QString postal;
1137 QString country; 1137 QString country;
1138 1138
1139 VObjectIterator nit; 1139 VObjectIterator nit;
1140 initPropIterator( &nit, o ); 1140 initPropIterator( &nit, o );
1141 while( moreIteration( &nit ) ) { 1141 while( moreIteration( &nit ) ) {
1142 VObject *o = nextVObject( &nit ); 1142 VObject *o = nextVObject( &nit );
1143 QCString name = vObjectName( o ); 1143 QCString name = vObjectName( o );
1144 QString value = vObjectStringZValue( o ); 1144 QString value = vObjectStringZValue( o );
1145 if ( name == VCHomeProp ) 1145 if ( name == VCHomeProp )
1146 work = FALSE; 1146 work = FALSE;
1147 else if ( name == VCWorkProp ) 1147 else if ( name == VCWorkProp )
1148 work = TRUE; 1148 work = TRUE;
1149 else if ( name == VCStreetAddressProp ) 1149 else if ( name == VCStreetAddressProp )
1150 street = value; 1150 street = value;
1151 else if ( name == VCCityProp ) 1151 else if ( name == VCCityProp )
1152 city = value; 1152 city = value;
1153 else if ( name == VCRegionProp ) 1153 else if ( name == VCRegionProp )
1154 region = value; 1154 region = value;
1155 else if ( name == VCPostalCodeProp ) 1155 else if ( name == VCPostalCodeProp )
1156 postal = value; 1156 postal = value;
1157 else if ( name == VCCountryNameProp ) 1157 else if ( name == VCCountryNameProp )
1158 country = value; 1158 country = value;
1159 } 1159 }
1160 if ( work ) { 1160 if ( work ) {
1161 c.setBusinessStreet( street ); 1161 c.setBusinessStreet( street );
1162 c.setBusinessCity( city ); 1162 c.setBusinessCity( city );
1163 c.setBusinessCountry( country ); 1163 c.setBusinessCountry( country );
1164 c.setBusinessZip( postal ); 1164 c.setBusinessZip( postal );
1165 c.setBusinessState( region ); 1165 c.setBusinessState( region );
1166 } else { 1166 } else {
1167 c.setHomeStreet( street ); 1167 c.setHomeStreet( street );
1168 c.setHomeCity( city ); 1168 c.setHomeCity( city );
1169 c.setHomeCountry( country ); 1169 c.setHomeCountry( country );
1170 c.setHomeZip( postal ); 1170 c.setHomeZip( postal );
1171 c.setHomeState( region ); 1171 c.setHomeState( region );
1172 } 1172 }
1173 } 1173 }
1174 else if ( name == VCTelephoneProp ) { 1174 else if ( name == VCTelephoneProp ) {
1175 enum { 1175 enum {
1176 HOME = 0x01, 1176 HOME = 0x01,
1177 WORK = 0x02, 1177 WORK = 0x02,
1178 VOICE = 0x04, 1178 VOICE = 0x04,
1179 CELL = 0x08, 1179 CELL = 0x08,
1180 FAX = 0x10, 1180 FAX = 0x10,
1181 PAGER = 0x20, 1181 PAGER = 0x20,
1182 UNKNOWN = 0x80 1182 UNKNOWN = 0x80
1183 }; 1183 };
1184 int type = 0; 1184 int type = 0;
1185 1185
1186 VObjectIterator nit; 1186 VObjectIterator nit;
1187 initPropIterator( &nit, o ); 1187 initPropIterator( &nit, o );
1188 while( moreIteration( &nit ) ) { 1188 while( moreIteration( &nit ) ) {
1189 VObject *o = nextVObject( &nit ); 1189 VObject *o = nextVObject( &nit );
1190 QCString name = vObjectTypeInfo( o ); 1190 QCString name = vObjectTypeInfo( o );
1191 if ( name == VCHomeProp ) 1191 if ( name == VCHomeProp )
1192 type |= HOME; 1192 type |= HOME;
1193 else if ( name == VCWorkProp ) 1193 else if ( name == VCWorkProp )
1194 type |= WORK; 1194 type |= WORK;
1195 else if ( name == VCVoiceProp ) 1195 else if ( name == VCVoiceProp )
1196 type |= VOICE; 1196 type |= VOICE;
1197 else if ( name == VCCellularProp ) 1197 else if ( name == VCCellularProp )
1198 type |= CELL; 1198 type |= CELL;
1199 else if ( name == VCFaxProp ) 1199 else if ( name == VCFaxProp )
1200 type |= FAX; 1200 type |= FAX;
1201 else if ( name == VCPagerProp ) 1201 else if ( name == VCPagerProp )
1202 type |= PAGER; 1202 type |= PAGER;
1203 else if ( name == VCPreferredProp ) 1203 else if ( name == VCPreferredProp )
1204 ; 1204 ;
1205 else 1205 else
1206 type |= UNKNOWN; 1206 type |= UNKNOWN;
1207 } 1207 }
1208 if ( (type & UNKNOWN) != UNKNOWN ) { 1208 if ( (type & UNKNOWN) != UNKNOWN ) {
1209 if ( ( type & (HOME|WORK) ) == 0 ) // default 1209 if ( ( type & (HOME|WORK) ) == 0 ) // default
1210 type |= HOME; 1210 type |= HOME;
1211 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default 1211 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
1212 type |= VOICE; 1212 type |= VOICE;
1213 1213
1214 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) 1214 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) )
1215 c.setHomePhone( value ); 1215 c.setHomePhone( value );
1216 if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) 1216 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
1217 c.setHomeFax( value ); 1217 c.setHomeFax( value );
1218 if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) 1218 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
1219 c.setHomeMobile( value ); 1219 c.setHomeMobile( value );
1220 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) 1220 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) )
1221 c.setBusinessPhone( value ); 1221 c.setBusinessPhone( value );
1222 if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) 1222 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
1223 c.setBusinessFax( value ); 1223 c.setBusinessFax( value );
1224 if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) 1224 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
1225 c.setBusinessMobile( value ); 1225 c.setBusinessMobile( value );
1226 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) 1226 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
1227 c.setBusinessPager( value ); 1227 c.setBusinessPager( value );
1228 } 1228 }
1229 } 1229 }
1230 else if ( name == VCEmailAddressProp ) { 1230 else if ( name == VCEmailAddressProp ) {
1231 QString email = vObjectStringZValue( o ); 1231 QString email = vObjectStringZValue( o );
1232 bool valid = TRUE; 1232 bool valid = TRUE;
1233 VObjectIterator nit; 1233 VObjectIterator nit;
1234 initPropIterator( &nit, o ); 1234 initPropIterator( &nit, o );
1235 while( moreIteration( &nit ) ) { 1235 while( moreIteration( &nit ) ) {
1236 VObject *o = nextVObject( &nit ); 1236 VObject *o = nextVObject( &nit );
1237 QCString name = vObjectTypeInfo( o ); 1237 QCString name = vObjectTypeInfo( o );
1238 if ( name != VCInternetProp && name != VCHomeProp && 1238 if ( name != VCInternetProp && name != VCHomeProp &&
1239 name != VCWorkProp && 1239 name != VCWorkProp &&
1240 name != VCPreferredProp ) 1240 name != VCPreferredProp )
1241 // ### preffered should map to default email 1241 // ### preffered should map to default email
1242 valid = FALSE; 1242 valid = FALSE;
1243 } 1243 }
1244 if ( valid ) { 1244 if ( valid ) {
1245 c.insertEmail( email ); 1245 c.insertEmail( email );
1246 } 1246 }
1247 } 1247 }
1248 else if ( name == VCURLProp ) { 1248 else if ( name == VCURLProp ) {
1249 VObjectIterator nit; 1249 VObjectIterator nit;
1250 initPropIterator( &nit, o ); 1250 initPropIterator( &nit, o );
1251 while( moreIteration( &nit ) ) { 1251 while( moreIteration( &nit ) ) {
1252 VObject *o = nextVObject( &nit ); 1252 VObject *o = nextVObject( &nit );
1253 QCString name = vObjectTypeInfo( o ); 1253 QCString name = vObjectTypeInfo( o );
1254 if ( name == VCHomeProp ) 1254 if ( name == VCHomeProp )
1255 c.setHomeWebpage( value ); 1255 c.setHomeWebpage( value );
1256 else if ( name == VCWorkProp ) 1256 else if ( name == VCWorkProp )
1257 c.setBusinessWebpage( value ); 1257 c.setBusinessWebpage( value );
1258 } 1258 }
1259 } 1259 }
1260 else if ( name == VCOrgProp ) { 1260 else if ( name == VCOrgProp ) {
1261 VObjectIterator nit; 1261 VObjectIterator nit;
1262 initPropIterator( &nit, o ); 1262 initPropIterator( &nit, o );
1263 while( moreIteration( &nit ) ) { 1263 while( moreIteration( &nit ) ) {
1264 VObject *o = nextVObject( &nit ); 1264 VObject *o = nextVObject( &nit );
1265 QCString name = vObjectName( o ); 1265 QCString name = vObjectName( o );
1266 QString value = vObjectStringZValue( o ); 1266 QString value = vObjectStringZValue( o );
1267 if ( name == VCOrgNameProp ) 1267 if ( name == VCOrgNameProp )
1268 c.setCompany( value ); 1268 c.setCompany( value );
1269 else if ( name == VCOrgUnitProp ) 1269 else if ( name == VCOrgUnitProp )
1270 c.setDepartment( value ); 1270 c.setDepartment( value );
1271 else if ( name == VCOrgUnit2Prop ) 1271 else if ( name == VCOrgUnit2Prop )
1272 c.setOffice( value ); 1272 c.setOffice( value );
1273 } 1273 }
1274 } 1274 }
1275 else if ( name == VCTitleProp ) { 1275 else if ( name == VCTitleProp ) {
1276 c.setJobTitle( value ); 1276 c.setJobTitle( value );
1277 } 1277 }
1278 else if ( name == "X-Qtopia-Profession" ) { 1278 else if ( name == "X-Qtopia-Profession" ) {
1279 c.setProfession( value ); 1279 c.setProfession( value );
1280 } 1280 }
1281 else if ( name == "X-Qtopia-Manager" ) { 1281 else if ( name == "X-Qtopia-Manager" ) {
1282 c.setManager( value ); 1282 c.setManager( value );
1283 } 1283 }
1284 else if ( name == "X-Qtopia-Assistant" ) { 1284 else if ( name == "X-Qtopia-Assistant" ) {
1285 c.setAssistant( value ); 1285 c.setAssistant( value );
1286 } 1286 }
1287 else if ( name == "X-Qtopia-Spouse" ) { 1287 else if ( name == "X-Qtopia-Spouse" ) {
1288 c.setSpouse( value ); 1288 c.setSpouse( value );
1289 } 1289 }
1290 else if ( name == "X-Qtopia-Gender" ) { 1290 else if ( name == "X-Qtopia-Gender" ) {
1291 c.setGender( value ); 1291 c.setGender( value );
1292 } 1292 }
1293 else if ( name == "X-Qtopia-Anniversary" ) { 1293 else if ( name == "X-Qtopia-Anniversary" ) {
1294 c.setAnniversary( value ); 1294 c.setAnniversary( value );
1295 } 1295 }
1296 else if ( name == "X-Qtopia-Nickname" ) { 1296 else if ( name == "X-Qtopia-Nickname" ) {
1297 c.setNickname( value ); 1297 c.setNickname( value );
1298 } 1298 }
1299 else if ( name == "X-Qtopia-Children" ) { 1299 else if ( name == "X-Qtopia-Children" ) {
1300 c.setChildren( value ); 1300 c.setChildren( value );
1301 } 1301 }
1302 1302
1303 1303
1304#if 0 1304#if 0
1305 else { 1305 else {
1306 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 1306 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
1307 VObjectIterator nit; 1307 VObjectIterator nit;
1308 initPropIterator( &nit, o ); 1308 initPropIterator( &nit, o );
1309 while( moreIteration( &nit ) ) { 1309 while( moreIteration( &nit ) ) {
1310 VObject *o = nextVObject( &nit ); 1310 VObject *o = nextVObject( &nit );
1311 QCString name = vObjectName( o ); 1311 QCString name = vObjectName( o );
1312 QString value = vObjectStringZValue( o ); 1312 QString value = vObjectStringZValue( o );
1313 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 1313 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
1314 } 1314 }
1315 } 1315 }
1316#endif 1316#endif
1317 } 1317 }
1318 c.setFileAs(); 1318 c.setFileAs();
1319 return c; 1319 return c;
1320} 1320}
1321 1321
1322/*! 1322/*!
1323 Writes the list of \a contacts as a set of VCards to the file \a filename. 1323 Writes the list of \a contacts as a set of VCards to the file \a filename.
1324*/ 1324*/
1325void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) 1325void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts)
1326{ 1326{
1327 QFileDirect f( filename.utf8().data() ); 1327 QFileDirect f( filename.utf8().data() );
1328 if ( !f.open( IO_WriteOnly ) ) { 1328 if ( !f.open( IO_WriteOnly ) ) {
1329 qWarning("Unable to open vcard write"); 1329 qWarning("Unable to open vcard write");
1330 return; 1330 return;
1331 } 1331 }
1332 1332
1333 QValueList<OContact>::ConstIterator it; 1333 QValueList<OContact>::ConstIterator it;
1334 for( it = contacts.begin(); it != contacts.end(); ++it ) { 1334 for( it = contacts.begin(); it != contacts.end(); ++it ) {
1335 VObject *obj = createVObject( *it ); 1335 VObject *obj = createVObject( *it );
1336 writeVObject(f.directHandle() , obj ); 1336 writeVObject(f.directHandle() , obj );
1337 cleanVObject( obj ); 1337 cleanVObject( obj );
1338 } 1338 }
1339 cleanStrTbl(); 1339 cleanStrTbl();
1340} 1340}
1341 1341
1342/*! 1342/*!
1343 writes \a contact as a VCard to the file \a filename. 1343 writes \a contact as a VCard to the file \a filename.
1344*/ 1344*/
1345void OContact::writeVCard( const QString &filename, const OContact &contact) 1345void OContact::writeVCard( const QString &filename, const OContact &contact)
1346{ 1346{
1347 QFileDirect f( filename.utf8().data() ); 1347 QFileDirect f( filename.utf8().data() );
1348 if ( !f.open( IO_WriteOnly ) ) { 1348 if ( !f.open( IO_WriteOnly ) ) {
1349 qWarning("Unable to open vcard write"); 1349 qWarning("Unable to open vcard write");
1350 return; 1350 return;
1351 } 1351 }
1352 1352
1353 VObject *obj = createVObject( contact ); 1353 VObject *obj = createVObject( contact );
1354 writeVObject( f.directHandle() , obj ); 1354 writeVObject( f.directHandle() , obj );
1355 cleanVObject( obj ); 1355 cleanVObject( obj );
1356 1356
1357 cleanStrTbl(); 1357 cleanStrTbl();
1358} 1358}
1359 1359
1360/*! 1360/*!
1361 Returns the set of contacts read as VCards from the file \a filename. 1361 Returns the set of contacts read as VCards from the file \a filename.
1362*/ 1362*/
1363QValueList<OContact> OContact::readVCard( const QString &filename ) 1363QValueList<OContact> OContact::readVCard( const QString &filename )
1364{ 1364{
1365 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); 1365 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() );
1366 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); 1366 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() );
1367 1367
1368 qDebug("vobject = %p", obj ); 1368 qDebug("vobject = %p", obj );
1369 1369
1370 QValueList<OContact> contacts; 1370 QValueList<OContact> contacts;
1371 1371
1372 while ( obj ) { 1372 while ( obj ) {
1373 contacts.append( parseVObject( obj ) ); 1373 contacts.append( parseVObject( obj ) );
1374 1374
1375 VObject *t = obj; 1375 VObject *t = obj;
1376 obj = nextVObjectInList(obj); 1376 obj = nextVObjectInList(obj);
1377 cleanVObject( t ); 1377 cleanVObject( t );
1378 } 1378 }
1379 1379
1380 return contacts; 1380 return contacts;
1381} 1381}
1382 1382
1383/*! 1383/*!
1384 Returns TRUE if the contact matches the regular expression \a regexp. 1384 Returns TRUE if the contact matches the regular expression \a regexp.
1385 Otherwise returns FALSE. 1385 Otherwise returns FALSE.
1386*/ 1386*/
1387bool OContact::match( const QString &regexp ) const 1387bool OContact::match( const QString &regexp ) const
1388{ 1388{
1389 return match(QRegExp(regexp)); 1389 return match(QRegExp(regexp));
1390} 1390}
1391 1391
1392/*! 1392/*!
1393 \overload 1393 \overload
1394 Returns TRUE if the contact matches the regular expression \a regexp. 1394 Returns TRUE if the contact matches the regular expression \a regexp.
1395 Otherwise returns FALSE. 1395 Otherwise returns FALSE.
1396*/ 1396*/
1397bool OContact::match( const QRegExp &r ) const 1397bool OContact::match( const QRegExp &r ) const
1398{ 1398{
1399 bool match; 1399 bool match;
1400 match = false; 1400 match = false;
1401 QMap<int, QString>::ConstIterator it; 1401 QMap<int, QString>::ConstIterator it;
1402 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 1402 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
1403 if ( (*it).find( r ) > -1 ) { 1403 if ( (*it).find( r ) > -1 ) {
1404 match = true; 1404 match = true;
1405 break; 1405 break;
1406 } 1406 }
1407 } 1407 }
1408 return match; 1408 return match;
1409} 1409}
1410 1410
1411 1411
1412// Noch nicht definiert ! :SX
1413QString OContact::toShortText() const 1412QString OContact::toShortText() const
1414{ 1413{
1415 return ( QString::fromLatin1( "Not defined!") ); 1414 return ( fullName() );
1416} 1415}
1417QString OContact::type() const 1416QString OContact::type() const
1418{ 1417{
1419 return QString::fromLatin1( "OContact" ); 1418 return QString::fromLatin1( "OContact" );
1420} 1419}
1421 1420
1422// Noch nicht definiert ! :SX 1421// Definition is missing ! (se)
1423QMap<QString,QString> OContact::toExtraMap() const 1422QMap<QString,QString> OContact::toExtraMap() const
1424{ 1423{
1424 qWarning ("Function not implemented: OContact::toExtraMap()");
1425 QMap <QString,QString> useless; 1425 QMap <QString,QString> useless;
1426 return useless; 1426 return useless;
1427} 1427}
1428 1428
1429// Noch nicht definiert ! :SX 1429class QString OContact::recordField( int pos ) const
1430class QString OContact::recordField(int) const
1431{ 1430{
1432 return QString::fromLatin1( "Noch nicht implementiert !" ); 1431 QStringList SLFIELDS = fields(); // ?? why this ? (se)
1432 return SLFIELDS[pos];
1433} 1433}
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h
index e0555c8..756c87d 100644
--- a/libopie/pim/ocontact.h
+++ b/libopie/pim/ocontact.h
@@ -1,311 +1,314 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef __OCONTACT_H__ 21#ifndef __OCONTACT_H__
22#define __OCONTACT_H__ 22#define __OCONTACT_H__
23 23
24#include <opie/opimrecord.h> 24#include <opie/opimrecord.h>
25#include <qpe/recordfields.h> 25#include <qpe/recordfields.h>
26 26
27#include <qstringlist.h> 27#include <qstringlist.h>
28 28
29#if defined(QPC_TEMPLATEDLL) 29#if defined(QPC_TEMPLATEDLL)
30// MOC_SKIP_BEGIN 30// MOC_SKIP_BEGIN
31QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; 31QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
32// MOC_SKIP_END 32// MOC_SKIP_END
33#endif 33#endif
34 34
35class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se) 35class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se)
36class QPC_EXPORT OContact : public OPimRecord 36class QPC_EXPORT OContact : public OPimRecord
37{ 37{
38 friend class DataSet; 38 friend class DataSet;
39public: 39public:
40 OContact(); 40 OContact();
41 OContact( const QMap<int, QString> &fromMap ); 41 OContact( const QMap<int, QString> &fromMap );
42 virtual ~OContact(); 42 virtual ~OContact();
43 43
44 static void writeVCard( const QString &filename, const QValueList<OContact> &contacts); 44 static void writeVCard( const QString &filename, const QValueList<OContact> &contacts);
45 static void writeVCard( const QString &filename, const OContact &c ); 45 static void writeVCard( const QString &filename, const OContact &c );
46 static QValueList<OContact> readVCard( const QString &filename ); 46 static QValueList<OContact> readVCard( const QString &filename );
47 47
48 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; 48 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
49 49
50 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } 50 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); }
51 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } 51 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); }
52 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } 52 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); }
53 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } 53 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); }
54 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } 54 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); }
55 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } 55 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); }
56 void setFileAs(); 56 void setFileAs();
57 57
58 // default email address 58 // default email address
59 void setDefaultEmail( const QString &v ); 59 void setDefaultEmail( const QString &v );
60 // inserts email to list and ensure's doesn't already exist 60 // inserts email to list and ensure's doesn't already exist
61 void insertEmail( const QString &v ); 61 void insertEmail( const QString &v );
62 void removeEmail( const QString &v ); 62 void removeEmail( const QString &v );
63 void clearEmails(); 63 void clearEmails();
64 void insertEmails( const QStringList &v ); 64 void insertEmails( const QStringList &v );
65 65
66 // home 66 // home
67 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } 67 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); }
68 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } 68 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); }
69 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } 69 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); }
70 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } 70 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); }
71 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } 71 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); }
72 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } 72 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); }
73 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } 73 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); }
74 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } 74 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); }
75 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } 75 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); }
76 76
77 // business 77 // business
78 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } 78 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); }
79 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } 79 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); }
80 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } 80 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); }
81 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } 81 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); }
82 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } 82 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); }
83 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } 83 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); }
84 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } 84 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); }
85 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } 85 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); }
86 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } 86 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); }
87 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } 87 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); }
88 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } 88 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); }
89 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } 89 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); }
90 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } 90 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); }
91 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } 91 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); }
92 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } 92 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); }
93 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } 93 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); }
94 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } 94 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); }
95 95
96 // personal 96 // personal
97 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } 97 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); }
98 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } 98 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); }
99 void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } 99 void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); }
100 void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } 100 void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); }
101 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } 101 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
102 void setChildren( const QString &v ); 102 void setChildren( const QString &v );
103 103
104 // other 104 // other
105 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } 105 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
106 106
107 bool match( const QString &regexp ) const; 107 bool match( const QString &regexp ) const;
108 108
109// DON'T ATTEMPT TO USE THIS 109// DON'T ATTEMPT TO USE THIS
110#ifdef QTOPIA_INTERNAL_CONTACT_MRE 110#ifdef QTOPIA_INTERNAL_CONTACT_MRE
111 bool match( const QRegExp &regexp ) const; 111 bool match( const QRegExp &regexp ) const;
112#endif 112#endif
113 113
114// // custom 114// // custom
115// void setCustomField( const QString &key, const QString &v ) 115// void setCustomField( const QString &key, const QString &v )
116// { replace(Custom- + key, v ); } 116// { replace(Custom- + key, v ); }
117 117
118 // name 118 // name
119 QString fullName() const; 119 QString fullName() const;
120 QString title() const { return find( Qtopia::Title ); } 120 QString title() const { return find( Qtopia::Title ); }
121 QString firstName() const { return find( Qtopia::FirstName ); } 121 QString firstName() const { return find( Qtopia::FirstName ); }
122 QString middleName() const { return find( Qtopia::MiddleName ); } 122 QString middleName() const { return find( Qtopia::MiddleName ); }
123 QString lastName() const { return find( Qtopia::LastName ); } 123 QString lastName() const { return find( Qtopia::LastName ); }
124 QString suffix() const { return find( Qtopia::Suffix ); } 124 QString suffix() const { return find( Qtopia::Suffix ); }
125 QString fileAs() const { return find( Qtopia::FileAs ); } 125 QString fileAs() const { return find( Qtopia::FileAs ); }
126 126
127 // email 127 // email
128 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } 128 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); }
129 QStringList emailList() const; 129 QStringList emailList() const;
130 130
131 // home 131 // home
132 QString homeStreet() const { return find( Qtopia::HomeStreet ); } 132 QString homeStreet() const { return find( Qtopia::HomeStreet ); }
133 QString homeCity() const { return find( Qtopia::HomeCity ); } 133 QString homeCity() const { return find( Qtopia::HomeCity ); }
134 QString homeState() const { return find( Qtopia::HomeState ); } 134 QString homeState() const { return find( Qtopia::HomeState ); }
135 QString homeZip() const { return find( Qtopia::HomeZip ); } 135 QString homeZip() const { return find( Qtopia::HomeZip ); }
136 QString homeCountry() const { return find( Qtopia::HomeCountry ); } 136 QString homeCountry() const { return find( Qtopia::HomeCountry ); }
137 QString homePhone() const { return find( Qtopia::HomePhone ); } 137 QString homePhone() const { return find( Qtopia::HomePhone ); }
138 QString homeFax() const { return find( Qtopia::HomeFax ); } 138 QString homeFax() const { return find( Qtopia::HomeFax ); }
139 QString homeMobile() const { return find( Qtopia::HomeMobile ); } 139 QString homeMobile() const { return find( Qtopia::HomeMobile ); }
140 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } 140 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); }
141 /** Multi line string containing all non-empty address info in the form 141 /** Multi line string containing all non-empty address info in the form
142 * Street 142 * Street
143 * City, State Zip 143 * City, State Zip
144 * Country 144 * Country
145 */ 145 */
146 QString displayHomeAddress() const; 146 QString displayHomeAddress() const;
147 147
148 // business 148 // business
149 QString company() const { return find( Qtopia::Company ); } 149 QString company() const { return find( Qtopia::Company ); }
150 QString businessStreet() const { return find( Qtopia::BusinessStreet ); } 150 QString businessStreet() const { return find( Qtopia::BusinessStreet ); }
151 QString businessCity() const { return find( Qtopia::BusinessCity ); } 151 QString businessCity() const { return find( Qtopia::BusinessCity ); }
152 QString businessState() const { return find( Qtopia::BusinessState ); } 152 QString businessState() const { return find( Qtopia::BusinessState ); }
153 QString businessZip() const { return find( Qtopia::BusinessZip ); } 153 QString businessZip() const { return find( Qtopia::BusinessZip ); }
154 QString businessCountry() const { return find( Qtopia::BusinessCountry ); } 154 QString businessCountry() const { return find( Qtopia::BusinessCountry ); }
155 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } 155 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
156 QString jobTitle() const { return find( Qtopia::JobTitle ); } 156 QString jobTitle() const { return find( Qtopia::JobTitle ); }
157 QString department() const { return find( Qtopia::Department ); } 157 QString department() const { return find( Qtopia::Department ); }
158 QString office() const { return find( Qtopia::Office ); } 158 QString office() const { return find( Qtopia::Office ); }
159 QString businessPhone() const { return find( Qtopia::BusinessPhone ); } 159 QString businessPhone() const { return find( Qtopia::BusinessPhone ); }
160 QString businessFax() const { return find( Qtopia::BusinessFax ); } 160 QString businessFax() const { return find( Qtopia::BusinessFax ); }
161 QString businessMobile() const { return find( Qtopia::BusinessMobile ); } 161 QString businessMobile() const { return find( Qtopia::BusinessMobile ); }
162 QString businessPager() const { return find( Qtopia::BusinessPager ); } 162 QString businessPager() const { return find( Qtopia::BusinessPager ); }
163 QString profession() const { return find( Qtopia::Profession ); } 163 QString profession() const { return find( Qtopia::Profession ); }
164 QString assistant() const { return find( Qtopia::Assistant ); } 164 QString assistant() const { return find( Qtopia::Assistant ); }
165 QString manager() const { return find( Qtopia::Manager ); } 165 QString manager() const { return find( Qtopia::Manager ); }
166 /** Multi line string containing all non-empty address info in the form 166 /** Multi line string containing all non-empty address info in the form
167 * Street 167 * Street
168 * City, State Zip 168 * City, State Zip
169 * Country 169 * Country
170 */ 170 */
171 QString displayBusinessAddress() const; 171 QString displayBusinessAddress() const;
172 172
173 //personal 173 //personal
174 QString spouse() const { return find( Qtopia::Spouse ); } 174 QString spouse() const { return find( Qtopia::Spouse ); }
175 QString gender() const { return find( Qtopia::Gender ); } 175 QString gender() const { return find( Qtopia::Gender ); }
176 QString birthday() const { return find( Qtopia::Birthday ); } 176 QString birthday() const { return find( Qtopia::Birthday ); }
177 QString anniversary() const { return find( Qtopia::Anniversary ); } 177 QString anniversary() const { return find( Qtopia::Anniversary ); }
178 QString nickname() const { return find( Qtopia::Nickname ); } 178 QString nickname() const { return find( Qtopia::Nickname ); }
179 QString children() const { return find( Qtopia::Children ); } 179 QString children() const { return find( Qtopia::Children ); }
180 QStringList childrenList() const; 180 QStringList childrenList() const;
181 181
182 // other 182 // other
183 QString notes() const { return find( Qtopia::Notes ); } 183 QString notes() const { return find( Qtopia::Notes ); }
184 QString groups() const { return find( Qtopia::Groups ); } 184 QString groups() const { return find( Qtopia::Groups ); }
185 QStringList groupList() const; 185 QStringList groupList() const;
186 186
187// // custom 187// // custom
188// const QString &customField( const QString &key ) 188// const QString &customField( const QString &key )
189// { return find( Custom- + key ); } 189// { return find( Custom- + key ); }
190 190
191 static QStringList fields(); 191 static QStringList fields();
192 static QStringList trfields(); 192 static QStringList trfields();
193 193
194 QString toRichText() const; 194 QString toRichText() const;
195 QMap<int, QString> toMap() const; 195 QMap<int, QString> toMap() const;
196 QString field( int key ) const { return find( key ); } 196 QString field( int key ) const { return find( key ); }
197 197
198 198
199 // journaling... 199 // journaling...
200 void saveJournal( journal_action action, const QString &key = QString::null ); 200 void saveJournal( journal_action action, const QString &key = QString::null );
201 void save( QString &buf ) const; 201 void save( QString &buf ) const;
202 202
203 void setUid( int i ) 203 void setUid( int i )
204{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } 204{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); }
205 205
206 QString toShortText()const; 206 QString toShortText()const;
207 QString OContact::type()const; 207 QString OContact::type()const;
208 QMap<QString,QString> OContact::toExtraMap() const; 208 QMap<QString,QString> OContact::toExtraMap() const;
209 class QString OContact::recordField(int) const; 209 class QString OContact::recordField(int) const;
210 210
211 // Why private ? (eilers,se)
212 QString emailSeparator() const { return " "; }
213 // the emails should be seperated by a comma
214 void setEmails( const QString &v );
215 QString emails() const { return find( Qtopia::Emails ); }
216
217
211private: 218private:
212 friend class AbEditor; 219 friend class AbEditor;
213 friend class AbTable; 220 friend class AbTable;
214 friend class AddressBookAccessPrivate; 221 friend class AddressBookAccessPrivate;
215 friend class XMLIO; 222 friend class XMLIO;
216 223
217 QString emailSeparator() const { return " "; }
218 // the emails should be seperated by a comma
219 void setEmails( const QString &v );
220 QString emails() const { return find( Qtopia::Emails ); }
221 224
222 void insert( int key, const QString &value ); 225 void insert( int key, const QString &value );
223 void replace( int key, const QString &value ); 226 void replace( int key, const QString &value );
224 QString find( int key ) const; 227 QString find( int key ) const;
225 228
226 QString displayAddress( const QString &street, 229 QString displayAddress( const QString &street,
227 const QString &city, 230 const QString &city,
228 const QString &state, 231 const QString &state,
229 const QString &zip, 232 const QString &zip,
230 const QString &country ) const; 233 const QString &country ) const;
231 234
232 Qtopia::UidGen &uidGen() { return sUidGen; } 235 Qtopia::UidGen &uidGen() { return sUidGen; }
233 static Qtopia::UidGen sUidGen; 236 static Qtopia::UidGen sUidGen;
234 QMap<int, QString> mMap; 237 QMap<int, QString> mMap;
235 ContactPrivate *d; 238 ContactPrivate *d;
236}; 239};
237 240
238// these methods are inlined to keep binary compatability with Qtopia 1.5 241// these methods are inlined to keep binary compatability with Qtopia 1.5
239inline void OContact::insertEmail( const QString &v ) 242inline void OContact::insertEmail( const QString &v )
240{ 243{
241 //qDebug("insertEmail %s", v.latin1()); 244 //qDebug("insertEmail %s", v.latin1());
242 QString e = v.simplifyWhiteSpace(); 245 QString e = v.simplifyWhiteSpace();
243 QString def = defaultEmail(); 246 QString def = defaultEmail();
244 247
245 // if no default, set it as the default email and don't insert 248 // if no default, set it as the default email and don't insert
246 if ( def.isEmpty() ) { 249 if ( def.isEmpty() ) {
247 setDefaultEmail( e ); // will insert into the list for us 250 setDefaultEmail( e ); // will insert into the list for us
248 return; 251 return;
249 } 252 }
250 253
251 // otherwise, insert assuming doesn't already exist 254 // otherwise, insert assuming doesn't already exist
252 QString emailsStr = find( Qtopia::Emails ); 255 QString emailsStr = find( Qtopia::Emails );
253 if ( emailsStr.contains( e )) 256 if ( emailsStr.contains( e ))
254 return; 257 return;
255 if ( !emailsStr.isEmpty() ) 258 if ( !emailsStr.isEmpty() )
256 emailsStr += emailSeparator(); 259 emailsStr += emailSeparator();
257 emailsStr += e; 260 emailsStr += e;
258 replace( Qtopia::Emails, emailsStr ); 261 replace( Qtopia::Emails, emailsStr );
259} 262}
260 263
261inline void OContact::removeEmail( const QString &v ) 264inline void OContact::removeEmail( const QString &v )
262{ 265{
263 QString e = v.simplifyWhiteSpace(); 266 QString e = v.simplifyWhiteSpace();
264 QString def = defaultEmail(); 267 QString def = defaultEmail();
265 QString emailsStr = find( Qtopia::Emails ); 268 QString emailsStr = find( Qtopia::Emails );
266 QStringList emails = emailList(); 269 QStringList emails = emailList();
267 270
268 // otherwise, must first contain it 271 // otherwise, must first contain it
269 if ( !emailsStr.contains( e ) ) 272 if ( !emailsStr.contains( e ) )
270 return; 273 return;
271 274
272 // remove it 275 // remove it
273 //qDebug(" removing email from list %s", e.latin1()); 276 //qDebug(" removing email from list %s", e.latin1());
274 emails.remove( e ); 277 emails.remove( e );
275 // reset the string 278 // reset the string
276 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator 279 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
277 replace( Qtopia::Emails, emailsStr ); 280 replace( Qtopia::Emails, emailsStr );
278 281
279 // if default, then replace the default email with the first one 282 // if default, then replace the default email with the first one
280 if ( def == e ) { 283 if ( def == e ) {
281 //qDebug("removeEmail is default; setting new default"); 284 //qDebug("removeEmail is default; setting new default");
282 if ( !emails.count() ) 285 if ( !emails.count() )
283 clearEmails(); 286 clearEmails();
284 else // setDefaultEmail will remove e from the list 287 else // setDefaultEmail will remove e from the list
285 setDefaultEmail( emails.first() ); 288 setDefaultEmail( emails.first() );
286 } 289 }
287} 290}
288inline void OContact::clearEmails() 291inline void OContact::clearEmails()
289{ 292{
290 mMap.remove( Qtopia::DefaultEmail ); 293 mMap.remove( Qtopia::DefaultEmail );
291 mMap.remove( Qtopia::Emails ); 294 mMap.remove( Qtopia::Emails );
292} 295}
293inline void OContact::setDefaultEmail( const QString &v ) 296inline void OContact::setDefaultEmail( const QString &v )
294{ 297{
295 QString e = v.simplifyWhiteSpace(); 298 QString e = v.simplifyWhiteSpace();
296 299
297 //qDebug("OContact::setDefaultEmail %s", e.latin1()); 300 //qDebug("OContact::setDefaultEmail %s", e.latin1());
298 replace( Qtopia::DefaultEmail, e ); 301 replace( Qtopia::DefaultEmail, e );
299 302
300 if ( !e.isEmpty() ) 303 if ( !e.isEmpty() )
301 insertEmail( e ); 304 insertEmail( e );
302 305
303} 306}
304 307
305inline void OContact::insertEmails( const QStringList &v ) 308inline void OContact::insertEmails( const QStringList &v )
306{ 309{
307 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 310 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
308 insertEmail( *it ); 311 insertEmail( *it );
309} 312}
310 313
311#endif 314#endif
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index 66632f5..828a9de 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -1,1433 +1,1433 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define QTOPIA_INTERNAL_CONTACT_MRE 21#define QTOPIA_INTERNAL_CONTACT_MRE
22 22
23#include "ocontact.h" 23#include "ocontact.h"
24#include "vobject_p.h" 24#include "vobject_p.h"
25#include "qfiledirect_p.h" 25#include "qfiledirect_p.h"
26 26
27#include <qpe/stringutil.h> 27#include <qpe/stringutil.h>
28#include <qpe/timeconversion.h> 28#include <qpe/timeconversion.h>
29 29
30#include <qobject.h> 30#include <qobject.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qstylesheet.h> 32#include <qstylesheet.h>
33#include <qfileinfo.h> 33#include <qfileinfo.h>
34#include <qmap.h> 34#include <qmap.h>
35 35
36#include <stdio.h> 36#include <stdio.h>
37 37
38/*! 38/*!
39 \class Contact contact.h 39 \class Contact contact.h
40 \brief The Contact class holds the data of an address book entry. 40 \brief The Contact class holds the data of an address book entry.
41 41
42 This data includes information the name of the person, contact 42 This data includes information the name of the person, contact
43 information, and business information such as deparment and job title. 43 information, and business information such as deparment and job title.
44 44
45 \ingroup qtopiaemb 45 \ingroup qtopiaemb
46 \ingroup qtopiadesktop 46 \ingroup qtopiadesktop
47*/ 47*/
48 48
49Qtopia::UidGen OContact::sUidGen( Qtopia::UidGen::Qtopia ); 49Qtopia::UidGen OContact::sUidGen( Qtopia::UidGen::Qtopia );
50 50
51/*! 51/*!
52 Creates a new, empty contact. 52 Creates a new, empty contact.
53*/ 53*/
54OContact::OContact() 54OContact::OContact()
55 : OPimRecord(), mMap(), d( 0 ) 55 : OPimRecord(), mMap(), d( 0 )
56{ 56{
57} 57}
58 58
59/*! 59/*!
60 \internal 60 \internal
61 Creates a new contact. The properties of the contact are 61 Creates a new contact. The properties of the contact are
62 set from \a fromMap. 62 set from \a fromMap.
63*/ 63*/
64OContact::OContact( const QMap<int, QString> &fromMap ) : 64OContact::OContact( const QMap<int, QString> &fromMap ) :
65 OPimRecord(), mMap( fromMap ), d( 0 ) 65 OPimRecord(), mMap( fromMap ), d( 0 )
66{ 66{
67 QString cats = mMap[ Qtopia::AddressCategory ]; 67 QString cats = mMap[ Qtopia::AddressCategory ];
68 if ( !cats.isEmpty() ) 68 if ( !cats.isEmpty() )
69 setCategories( idsFromString( cats ) ); 69 setCategories( idsFromString( cats ) );
70 QString uidStr = find( Qtopia::AddressUid ); 70 QString uidStr = find( Qtopia::AddressUid );
71 71
72 if ( uidStr.isEmpty() ) 72 if ( uidStr.isEmpty() )
73 setUid( uidGen().generate() ); 73 setUid( uidGen().generate() );
74 else 74 else
75 setUid( uidStr.toInt() ); 75 setUid( uidStr.toInt() );
76 76
77 if ( !uidStr.isEmpty() ) 77 if ( !uidStr.isEmpty() )
78 setUid( uidStr.toInt() ); 78 setUid( uidStr.toInt() );
79} 79}
80 80
81/*! 81/*!
82 Destroys a contact. 82 Destroys a contact.
83*/ 83*/
84OContact::~OContact() 84OContact::~OContact()
85{ 85{
86} 86}
87 87
88/*! \fn void OContact::setTitle( const QString &str ) 88/*! \fn void OContact::setTitle( const QString &str )
89 Sets the title of the contact to \a str. 89 Sets the title of the contact to \a str.
90*/ 90*/
91 91
92/*! \fn void OContact::setFirstName( const QString &str ) 92/*! \fn void OContact::setFirstName( const QString &str )
93 Sets the first name of the contact to \a str. 93 Sets the first name of the contact to \a str.
94*/ 94*/
95 95
96/*! \fn void OContact::setMiddleName( const QString &str ) 96/*! \fn void OContact::setMiddleName( const QString &str )
97 Sets the middle name of the contact to \a str. 97 Sets the middle name of the contact to \a str.
98*/ 98*/
99 99
100/*! \fn void OContact::setLastName( const QString &str ) 100/*! \fn void OContact::setLastName( const QString &str )
101 Sets the last name of the contact to \a str. 101 Sets the last name of the contact to \a str.
102*/ 102*/
103 103
104/*! \fn void OContact::setSuffix( const QString &str ) 104/*! \fn void OContact::setSuffix( const QString &str )
105 Sets the suffix of the contact to \a str. 105 Sets the suffix of the contact to \a str.
106*/ 106*/
107 107
108/*! \fn void OContact::setFileAs( const QString &str ) 108/*! \fn void OContact::setFileAs( const QString &str )
109 Sets the contact to filed as \a str. 109 Sets the contact to filed as \a str.
110*/ 110*/
111 111
112/*! \fn void OContact::setDefaultEmail( const QString &str ) 112/*! \fn void OContact::setDefaultEmail( const QString &str )
113 Sets the default email of the contact to \a str. 113 Sets the default email of the contact to \a str.
114*/ 114*/
115 115
116/*! \fn void OContact::setHomeStreet( const QString &str ) 116/*! \fn void OContact::setHomeStreet( const QString &str )
117 Sets the home street address of the contact to \a str. 117 Sets the home street address of the contact to \a str.
118*/ 118*/
119 119
120/*! \fn void OContact::setHomeCity( const QString &str ) 120/*! \fn void OContact::setHomeCity( const QString &str )
121 Sets the home city of the contact to \a str. 121 Sets the home city of the contact to \a str.
122*/ 122*/
123 123
124/*! \fn void OContact::setHomeState( const QString &str ) 124/*! \fn void OContact::setHomeState( const QString &str )
125 Sets the home state of the contact to \a str. 125 Sets the home state of the contact to \a str.
126*/ 126*/
127 127
128/*! \fn void OContact::setHomeZip( const QString &str ) 128/*! \fn void OContact::setHomeZip( const QString &str )
129 Sets the home zip code of the contact to \a str. 129 Sets the home zip code of the contact to \a str.
130*/ 130*/
131 131
132/*! \fn void OContact::setHomeCountry( const QString &str ) 132/*! \fn void OContact::setHomeCountry( const QString &str )
133 Sets the home country of the contact to \a str. 133 Sets the home country of the contact to \a str.
134*/ 134*/
135 135
136/*! \fn void OContact::setHomePhone( const QString &str ) 136/*! \fn void OContact::setHomePhone( const QString &str )
137 Sets the home phone number of the contact to \a str. 137 Sets the home phone number of the contact to \a str.
138*/ 138*/
139 139
140/*! \fn void OContact::setHomeFax( const QString &str ) 140/*! \fn void OContact::setHomeFax( const QString &str )
141 Sets the home fax number of the contact to \a str. 141 Sets the home fax number of the contact to \a str.
142*/ 142*/
143 143
144/*! \fn void OContact::setHomeMobile( const QString &str ) 144/*! \fn void OContact::setHomeMobile( const QString &str )
145 Sets the home mobile phone number of the contact to \a str. 145 Sets the home mobile phone number of the contact to \a str.
146*/ 146*/
147 147
148/*! \fn void OContact::setHomeWebpage( const QString &str ) 148/*! \fn void OContact::setHomeWebpage( const QString &str )
149 Sets the home webpage of the contact to \a str. 149 Sets the home webpage of the contact to \a str.
150*/ 150*/
151 151
152/*! \fn void OContact::setCompany( const QString &str ) 152/*! \fn void OContact::setCompany( const QString &str )
153 Sets the company for contact to \a str. 153 Sets the company for contact to \a str.
154*/ 154*/
155 155
156/*! \fn void OContact::setJobTitle( const QString &str ) 156/*! \fn void OContact::setJobTitle( const QString &str )
157 Sets the job title of the contact to \a str. 157 Sets the job title of the contact to \a str.
158*/ 158*/
159 159
160/*! \fn void OContact::setDepartment( const QString &str ) 160/*! \fn void OContact::setDepartment( const QString &str )
161 Sets the department for contact to \a str. 161 Sets the department for contact to \a str.
162*/ 162*/
163 163
164/*! \fn void OContact::setOffice( const QString &str ) 164/*! \fn void OContact::setOffice( const QString &str )
165 Sets the office for contact to \a str. 165 Sets the office for contact to \a str.
166*/ 166*/
167 167
168/*! \fn void OContact::setBusinessStreet( const QString &str ) 168/*! \fn void OContact::setBusinessStreet( const QString &str )
169 Sets the business street address of the contact to \a str. 169 Sets the business street address of the contact to \a str.
170*/ 170*/
171 171
172/*! \fn void OContact::setBusinessCity( const QString &str ) 172/*! \fn void OContact::setBusinessCity( const QString &str )
173 Sets the business city of the contact to \a str. 173 Sets the business city of the contact to \a str.
174*/ 174*/
175 175
176/*! \fn void OContact::setBusinessState( const QString &str ) 176/*! \fn void OContact::setBusinessState( const QString &str )
177 Sets the business state of the contact to \a str. 177 Sets the business state of the contact to \a str.
178*/ 178*/
179 179
180/*! \fn void OContact::setBusinessZip( const QString &str ) 180/*! \fn void OContact::setBusinessZip( const QString &str )
181 Sets the business zip code of the contact to \a str. 181 Sets the business zip code of the contact to \a str.
182*/ 182*/
183 183
184/*! \fn void OContact::setBusinessCountry( const QString &str ) 184/*! \fn void OContact::setBusinessCountry( const QString &str )
185 Sets the business country of the contact to \a str. 185 Sets the business country of the contact to \a str.
186*/ 186*/
187 187
188/*! \fn void OContact::setBusinessPhone( const QString &str ) 188/*! \fn void OContact::setBusinessPhone( const QString &str )
189 Sets the business phone number of the contact to \a str. 189 Sets the business phone number of the contact to \a str.
190*/ 190*/
191 191
192/*! \fn void OContact::setBusinessFax( const QString &str ) 192/*! \fn void OContact::setBusinessFax( const QString &str )
193 Sets the business fax number of the contact to \a str. 193 Sets the business fax number of the contact to \a str.
194*/ 194*/
195 195
196/*! \fn void OContact::setBusinessMobile( const QString &str ) 196/*! \fn void OContact::setBusinessMobile( const QString &str )
197 Sets the business mobile phone number of the contact to \a str. 197 Sets the business mobile phone number of the contact to \a str.
198*/ 198*/
199 199
200/*! \fn void OContact::setBusinessPager( const QString &str ) 200/*! \fn void OContact::setBusinessPager( const QString &str )
201 Sets the business pager number of the contact to \a str. 201 Sets the business pager number of the contact to \a str.
202*/ 202*/
203 203
204/*! \fn void OContact::setBusinessWebpage( const QString &str ) 204/*! \fn void OContact::setBusinessWebpage( const QString &str )
205 Sets the business webpage of the contact to \a str. 205 Sets the business webpage of the contact to \a str.
206*/ 206*/
207 207
208/*! \fn void OContact::setProfession( const QString &str ) 208/*! \fn void OContact::setProfession( const QString &str )
209 Sets the profession of the contact to \a str. 209 Sets the profession of the contact to \a str.
210*/ 210*/
211 211
212/*! \fn void OContact::setAssistant( const QString &str ) 212/*! \fn void OContact::setAssistant( const QString &str )
213 Sets the assistant of the contact to \a str. 213 Sets the assistant of the contact to \a str.
214*/ 214*/
215 215
216/*! \fn void OContact::setManager( const QString &str ) 216/*! \fn void OContact::setManager( const QString &str )
217 Sets the manager of the contact to \a str. 217 Sets the manager of the contact to \a str.
218*/ 218*/
219 219
220/*! \fn void OContact::setSpouse( const QString &str ) 220/*! \fn void OContact::setSpouse( const QString &str )
221 Sets the spouse of the contact to \a str. 221 Sets the spouse of the contact to \a str.
222*/ 222*/
223 223
224/*! \fn void OContact::setGender( const QString &str ) 224/*! \fn void OContact::setGender( const QString &str )
225 Sets the gender of the contact to \a str. 225 Sets the gender of the contact to \a str.
226*/ 226*/
227 227
228/*! \fn void OContact::setBirthday( const QString &str ) 228/*! \fn void OContact::setBirthday( const QString &str )
229 Sets the birthday for the contact to \a str. 229 Sets the birthday for the contact to \a str.
230*/ 230*/
231 231
232/*! \fn void OContact::setAnniversary( const QString &str ) 232/*! \fn void OContact::setAnniversary( const QString &str )
233 Sets the anniversary of the contact to \a str. 233 Sets the anniversary of the contact to \a str.
234*/ 234*/
235 235
236/*! \fn void OContact::setNickname( const QString &str ) 236/*! \fn void OContact::setNickname( const QString &str )
237 Sets the nickname of the contact to \a str. 237 Sets the nickname of the contact to \a str.
238*/ 238*/
239 239
240/*! \fn void OContact::setNotes( const QString &str ) 240/*! \fn void OContact::setNotes( const QString &str )
241 Sets the notes about the contact to \a str. 241 Sets the notes about the contact to \a str.
242*/ 242*/
243 243
244/*! \fn QString OContact::title() const 244/*! \fn QString OContact::title() const
245 Returns the title of the contact. 245 Returns the title of the contact.
246*/ 246*/
247 247
248/*! \fn QString OContact::firstName() const 248/*! \fn QString OContact::firstName() const
249 Returns the first name of the contact. 249 Returns the first name of the contact.
250*/ 250*/
251 251
252/*! \fn QString OContact::middleName() const 252/*! \fn QString OContact::middleName() const
253 Returns the middle name of the contact. 253 Returns the middle name of the contact.
254*/ 254*/
255 255
256/*! \fn QString OContact::lastName() const 256/*! \fn QString OContact::lastName() const
257 Returns the last name of the contact. 257 Returns the last name of the contact.
258*/ 258*/
259 259
260/*! \fn QString OContact::suffix() const 260/*! \fn QString OContact::suffix() const
261 Returns the suffix of the contact. 261 Returns the suffix of the contact.
262*/ 262*/
263 263
264/*! \fn QString OContact::fileAs() const 264/*! \fn QString OContact::fileAs() const
265 Returns the string the contact is filed as. 265 Returns the string the contact is filed as.
266*/ 266*/
267 267
268/*! \fn QString OContact::defaultEmail() const 268/*! \fn QString OContact::defaultEmail() const
269 Returns the default email address of the contact. 269 Returns the default email address of the contact.
270*/ 270*/
271 271
272/*! \fn QString OContact::emails() const 272/*! \fn QString OContact::emails() const
273 Returns the list of email address for a contact separated by ';'s in a single 273 Returns the list of email address for a contact separated by ';'s in a single
274 string. 274 string.
275*/ 275*/
276 276
277/*! \fn QString OContact::homeStreet() const 277/*! \fn QString OContact::homeStreet() const
278 Returns the home street address of the contact. 278 Returns the home street address of the contact.
279*/ 279*/
280 280
281/*! \fn QString OContact::homeCity() const 281/*! \fn QString OContact::homeCity() const
282 Returns the home city of the contact. 282 Returns the home city of the contact.
283*/ 283*/
284 284
285/*! \fn QString OContact::homeState() const 285/*! \fn QString OContact::homeState() const
286 Returns the home state of the contact. 286 Returns the home state of the contact.
287*/ 287*/
288 288
289/*! \fn QString OContact::homeZip() const 289/*! \fn QString OContact::homeZip() const
290 Returns the home zip of the contact. 290 Returns the home zip of the contact.
291*/ 291*/
292 292
293/*! \fn QString OContact::homeCountry() const 293/*! \fn QString OContact::homeCountry() const
294 Returns the home country of the contact. 294 Returns the home country of the contact.
295*/ 295*/
296 296
297/*! \fn QString OContact::homePhone() const 297/*! \fn QString OContact::homePhone() const
298 Returns the home phone number of the contact. 298 Returns the home phone number of the contact.
299*/ 299*/
300 300
301/*! \fn QString OContact::homeFax() const 301/*! \fn QString OContact::homeFax() const
302 Returns the home fax number of the contact. 302 Returns the home fax number of the contact.
303*/ 303*/
304 304
305/*! \fn QString OContact::homeMobile() const 305/*! \fn QString OContact::homeMobile() const
306 Returns the home mobile number of the contact. 306 Returns the home mobile number of the contact.
307*/ 307*/
308 308
309/*! \fn QString OContact::homeWebpage() const 309/*! \fn QString OContact::homeWebpage() const
310 Returns the home webpage of the contact. 310 Returns the home webpage of the contact.
311*/ 311*/
312 312
313/*! \fn QString OContact::company() const 313/*! \fn QString OContact::company() const
314 Returns the company for the contact. 314 Returns the company for the contact.
315*/ 315*/
316 316
317/*! \fn QString OContact::department() const 317/*! \fn QString OContact::department() const
318 Returns the department for the contact. 318 Returns the department for the contact.
319*/ 319*/
320 320
321/*! \fn QString OContact::office() const 321/*! \fn QString OContact::office() const
322 Returns the office for the contact. 322 Returns the office for the contact.
323*/ 323*/
324 324
325/*! \fn QString OContact::jobTitle() const 325/*! \fn QString OContact::jobTitle() const
326 Returns the job title of the contact. 326 Returns the job title of the contact.
327*/ 327*/
328 328
329/*! \fn QString OContact::profession() const 329/*! \fn QString OContact::profession() const
330 Returns the profession of the contact. 330 Returns the profession of the contact.
331*/ 331*/
332 332
333/*! \fn QString OContact::assistant() const 333/*! \fn QString OContact::assistant() const
334 Returns the assistant of the contact. 334 Returns the assistant of the contact.
335*/ 335*/
336 336
337/*! \fn QString OContact::manager() const 337/*! \fn QString OContact::manager() const
338 Returns the manager of the contact. 338 Returns the manager of the contact.
339*/ 339*/
340 340
341/*! \fn QString OContact::businessStreet() const 341/*! \fn QString OContact::businessStreet() const
342 Returns the business street address of the contact. 342 Returns the business street address of the contact.
343*/ 343*/
344 344
345/*! \fn QString OContact::businessCity() const 345/*! \fn QString OContact::businessCity() const
346 Returns the business city of the contact. 346 Returns the business city of the contact.
347*/ 347*/
348 348
349/*! \fn QString OContact::businessState() const 349/*! \fn QString OContact::businessState() const
350 Returns the business state of the contact. 350 Returns the business state of the contact.
351*/ 351*/
352 352
353/*! \fn QString OContact::businessZip() const 353/*! \fn QString OContact::businessZip() const
354 Returns the business zip of the contact. 354 Returns the business zip of the contact.
355*/ 355*/
356 356
357/*! \fn QString OContact::businessCountry() const 357/*! \fn QString OContact::businessCountry() const
358 Returns the business country of the contact. 358 Returns the business country of the contact.
359*/ 359*/
360 360
361/*! \fn QString OContact::businessPhone() const 361/*! \fn QString OContact::businessPhone() const
362 Returns the business phone number of the contact. 362 Returns the business phone number of the contact.
363*/ 363*/
364 364
365/*! \fn QString OContact::businessFax() const 365/*! \fn QString OContact::businessFax() const
366 Returns the business fax number of the contact. 366 Returns the business fax number of the contact.
367*/ 367*/
368 368
369/*! \fn QString OContact::businessMobile() const 369/*! \fn QString OContact::businessMobile() const
370 Returns the business mobile number of the contact. 370 Returns the business mobile number of the contact.
371*/ 371*/
372 372
373/*! \fn QString OContact::businessPager() const 373/*! \fn QString OContact::businessPager() const
374 Returns the business pager number of the contact. 374 Returns the business pager number of the contact.
375*/ 375*/
376 376
377/*! \fn QString OContact::businessWebpage() const 377/*! \fn QString OContact::businessWebpage() const
378 Returns the business webpage of the contact. 378 Returns the business webpage of the contact.
379*/ 379*/
380 380
381/*! \fn QString OContact::spouse() const 381/*! \fn QString OContact::spouse() const
382 Returns the spouse of the contact. 382 Returns the spouse of the contact.
383*/ 383*/
384 384
385/*! \fn QString OContact::gender() const 385/*! \fn QString OContact::gender() const
386 Returns the gender of the contact. 386 Returns the gender of the contact.
387*/ 387*/
388 388
389/*! \fn QString OContact::birthday() const 389/*! \fn QString OContact::birthday() const
390 Returns the birthday of the contact. 390 Returns the birthday of the contact.
391*/ 391*/
392 392
393/*! \fn QString OContact::anniversary() const 393/*! \fn QString OContact::anniversary() const
394 Returns the anniversary of the contact. 394 Returns the anniversary of the contact.
395*/ 395*/
396 396
397/*! \fn QString OContact::nickname() const 397/*! \fn QString OContact::nickname() const
398 Returns the nickname of the contact. 398 Returns the nickname of the contact.
399*/ 399*/
400 400
401/*! \fn QString OContact::children() const 401/*! \fn QString OContact::children() const
402 Returns the children of the contact. 402 Returns the children of the contact.
403*/ 403*/
404 404
405/*! \fn QString OContact::notes() const 405/*! \fn QString OContact::notes() const
406 Returns the notes relating to the the contact. 406 Returns the notes relating to the the contact.
407*/ 407*/
408 408
409/*! \fn QString OContact::groups() const 409/*! \fn QString OContact::groups() const
410 \internal 410 \internal
411 Returns the groups for the contact. 411 Returns the groups for the contact.
412*/ 412*/
413 413
414/*! \fn QStringList OContact::groupList() const 414/*! \fn QStringList OContact::groupList() const
415 \internal 415 \internal
416*/ 416*/
417 417
418/*! \fn QString OContact::field(int) const 418/*! \fn QString OContact::field(int) const
419 \internal 419 \internal
420*/ 420*/
421 421
422/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) 422/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null )
423 \internal 423 \internal
424*/ 424*/
425 425
426/*! \fn void OContact::setUid( int id ) 426/*! \fn void OContact::setUid( int id )
427 \internal 427 \internal
428 Sets the uid for this record to \a id. 428 Sets the uid for this record to \a id.
429*/ 429*/
430 430
431/*! \enum OContact::journal_action 431/*! \enum OContact::journal_action
432 \internal 432 \internal
433*/ 433*/
434 434
435/*! 435/*!
436 \internal 436 \internal
437*/ 437*/
438QMap<int, QString> OContact::toMap() const 438QMap<int, QString> OContact::toMap() const
439{ 439{
440 QMap<int, QString> map = mMap; 440 QMap<int, QString> map = mMap;
441 QString cats = idsToString( categories() ); 441 QString cats = idsToString( categories() );
442 if ( !cats.isEmpty() ) 442 if ( !cats.isEmpty() )
443 map.insert( Qtopia::AddressCategory, cats ); 443 map.insert( Qtopia::AddressCategory, cats );
444 return map; 444 return map;
445} 445}
446 446
447/*! 447/*!
448 Returns a rich text formatted QString representing the contents the contact. 448 Returns a rich text formatted QString representing the contents the contact.
449*/ 449*/
450QString OContact::toRichText() const 450QString OContact::toRichText() const
451{ 451{
452 QString text; 452 QString text;
453 QString value, comp, state; 453 QString value, comp, state;
454 454
455 // name, jobtitle and company 455 // name, jobtitle and company
456 if ( !(value = fullName()).isEmpty() ) 456 if ( !(value = fullName()).isEmpty() )
457 text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; 457 text += "<b>" + Qtopia::escapeString(value) + "</b><br>";
458 if ( !(value = jobTitle()).isEmpty() ) 458 if ( !(value = jobTitle()).isEmpty() )
459 text += Qtopia::escapeString(value) + "<br>"; 459 text += Qtopia::escapeString(value) + "<br>";
460 460
461 comp = company(); 461 comp = company();
462 if ( !(value = department()).isEmpty() ) { 462 if ( !(value = department()).isEmpty() ) {
463 text += Qtopia::escapeString(value); 463 text += Qtopia::escapeString(value);
464 if ( comp ) 464 if ( comp )
465 text += ", "; 465 text += ", ";
466 else 466 else
467 text += "<br>"; 467 text += "<br>";
468 } 468 }
469 if ( !comp.isEmpty() ) 469 if ( !comp.isEmpty() )
470 text += Qtopia::escapeString(comp) + "<br>"; 470 text += Qtopia::escapeString(comp) + "<br>";
471 471
472 // business address 472 // business address
473 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 473 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
474 !businessZip().isEmpty() || !businessCountry().isEmpty() ) { 474 !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
475 text += "<br>"; 475 text += "<br>";
476 text += QObject::tr( "<b>Work Address:</b>" ); 476 text += QObject::tr( "<b>Work Address:</b>" );
477 text += "<br>"; 477 text += "<br>";
478 } 478 }
479 479
480 if ( !(value = businessStreet()).isEmpty() ) 480 if ( !(value = businessStreet()).isEmpty() )
481 text += Qtopia::escapeString(value) + "<br>"; 481 text += Qtopia::escapeString(value) + "<br>";
482 state = businessState(); 482 state = businessState();
483 if ( !(value = businessCity()).isEmpty() ) { 483 if ( !(value = businessCity()).isEmpty() ) {
484 text += Qtopia::escapeString(value); 484 text += Qtopia::escapeString(value);
485 if ( state ) 485 if ( state )
486 text += ", " + Qtopia::escapeString(state); 486 text += ", " + Qtopia::escapeString(state);
487 text += "<br>"; 487 text += "<br>";
488 } else if ( !state.isEmpty() ) 488 } else if ( !state.isEmpty() )
489 text += Qtopia::escapeString(state) + "<br>"; 489 text += Qtopia::escapeString(state) + "<br>";
490 if ( !(value = businessZip()).isEmpty() ) 490 if ( !(value = businessZip()).isEmpty() )
491 text += Qtopia::escapeString(value) + "<br>"; 491 text += Qtopia::escapeString(value) + "<br>";
492 if ( !(value = businessCountry()).isEmpty() ) 492 if ( !(value = businessCountry()).isEmpty() )
493 text += Qtopia::escapeString(value) + "<br>"; 493 text += Qtopia::escapeString(value) + "<br>";
494 494
495 // home address 495 // home address
496 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || 496 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
497 !homeZip().isEmpty() || !homeCountry().isEmpty() ) { 497 !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
498 text += "<br>"; 498 text += "<br>";
499 text += QObject::tr( "<b>Home Address:</b>" ); 499 text += QObject::tr( "<b>Home Address:</b>" );
500 text += "<br>"; 500 text += "<br>";
501 } 501 }
502 502
503 if ( !(value = homeStreet()).isEmpty() ) 503 if ( !(value = homeStreet()).isEmpty() )
504 text += Qtopia::escapeString(value) + "<br>"; 504 text += Qtopia::escapeString(value) + "<br>";
505 state = homeState(); 505 state = homeState();
506 if ( !(value = homeCity()).isEmpty() ) { 506 if ( !(value = homeCity()).isEmpty() ) {
507 text += Qtopia::escapeString(value); 507 text += Qtopia::escapeString(value);
508 if ( !state.isEmpty() ) 508 if ( !state.isEmpty() )
509 text += ", " + Qtopia::escapeString(state); 509 text += ", " + Qtopia::escapeString(state);
510 text += "<br>"; 510 text += "<br>";
511 } else if (!state.isEmpty()) 511 } else if (!state.isEmpty())
512 text += Qtopia::escapeString(state) + "<br>"; 512 text += Qtopia::escapeString(state) + "<br>";
513 if ( !(value = homeZip()).isEmpty() ) 513 if ( !(value = homeZip()).isEmpty() )
514 text += Qtopia::escapeString(value) + "<br>"; 514 text += Qtopia::escapeString(value) + "<br>";
515 if ( !(value = homeCountry()).isEmpty() ) 515 if ( !(value = homeCountry()).isEmpty() )
516 text += Qtopia::escapeString(value) + "<br>"; 516 text += Qtopia::escapeString(value) + "<br>";
517 517
518 // the others... 518 // the others...
519 QString str; 519 QString str;
520 str = emails(); 520 str = emails();
521 if ( !str.isEmpty() ) 521 if ( !str.isEmpty() )
522 text += "<b>" + QObject::tr("Email Addresses: ") + "</b>" 522 text += "<b>" + QObject::tr("Email Addresses: ") + "</b>"
523 + Qtopia::escapeString(str) + "<br>"; 523 + Qtopia::escapeString(str) + "<br>";
524 str = homePhone(); 524 str = homePhone();
525 if ( !str.isEmpty() ) 525 if ( !str.isEmpty() )
526 text += "<b>" + QObject::tr("Home Phone: ") + "</b>" 526 text += "<b>" + QObject::tr("Home Phone: ") + "</b>"
527 + Qtopia::escapeString(str) + "<br>"; 527 + Qtopia::escapeString(str) + "<br>";
528 str = homeFax(); 528 str = homeFax();
529 if ( !str.isEmpty() ) 529 if ( !str.isEmpty() )
530 text += "<b>" + QObject::tr("Home Fax: ") + "</b>" 530 text += "<b>" + QObject::tr("Home Fax: ") + "</b>"
531 + Qtopia::escapeString(str) + "<br>"; 531 + Qtopia::escapeString(str) + "<br>";
532 str = homeMobile(); 532 str = homeMobile();
533 if ( !str.isEmpty() ) 533 if ( !str.isEmpty() )
534 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" 534 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>"
535 + Qtopia::escapeString(str) + "<br>"; 535 + Qtopia::escapeString(str) + "<br>";
536 str = homeWebpage(); 536 str = homeWebpage();
537 if ( !str.isEmpty() ) 537 if ( !str.isEmpty() )
538 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" 538 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>"
539 + Qtopia::escapeString(str) + "<br>"; 539 + Qtopia::escapeString(str) + "<br>";
540 str = businessWebpage(); 540 str = businessWebpage();
541 if ( !str.isEmpty() ) 541 if ( !str.isEmpty() )
542 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" 542 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>"
543 + Qtopia::escapeString(str) + "<br>"; 543 + Qtopia::escapeString(str) + "<br>";
544 str = office(); 544 str = office();
545 if ( !str.isEmpty() ) 545 if ( !str.isEmpty() )
546 text += "<b>" + QObject::tr("Office: ") + "</b>" 546 text += "<b>" + QObject::tr("Office: ") + "</b>"
547 + Qtopia::escapeString(str) + "<br>"; 547 + Qtopia::escapeString(str) + "<br>";
548 str = businessPhone(); 548 str = businessPhone();
549 if ( !str.isEmpty() ) 549 if ( !str.isEmpty() )
550 text += "<b>" + QObject::tr("Business Phone: ") + "</b>" 550 text += "<b>" + QObject::tr("Business Phone: ") + "</b>"
551 + Qtopia::escapeString(str) + "<br>"; 551 + Qtopia::escapeString(str) + "<br>";
552 str = businessFax(); 552 str = businessFax();
553 if ( !str.isEmpty() ) 553 if ( !str.isEmpty() )
554 text += "<b>" + QObject::tr("Business Fax: ") + "</b>" 554 text += "<b>" + QObject::tr("Business Fax: ") + "</b>"
555 + Qtopia::escapeString(str) + "<br>"; 555 + Qtopia::escapeString(str) + "<br>";
556 str = businessMobile(); 556 str = businessMobile();
557 if ( !str.isEmpty() ) 557 if ( !str.isEmpty() )
558 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" 558 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>"
559 + Qtopia::escapeString(str) + "<br>"; 559 + Qtopia::escapeString(str) + "<br>";
560 str = businessPager(); 560 str = businessPager();
561 if ( !str.isEmpty() ) 561 if ( !str.isEmpty() )
562 text += "<b>" + QObject::tr("Business Pager: ") + "</b>" 562 text += "<b>" + QObject::tr("Business Pager: ") + "</b>"
563 + Qtopia::escapeString(str) + "<br>"; 563 + Qtopia::escapeString(str) + "<br>";
564 str = profession(); 564 str = profession();
565 if ( !str.isEmpty() ) 565 if ( !str.isEmpty() )
566 text += "<b>" + QObject::tr("Profession: ") + "</b>" 566 text += "<b>" + QObject::tr("Profession: ") + "</b>"
567 + Qtopia::escapeString(str) + "<br>"; 567 + Qtopia::escapeString(str) + "<br>";
568 str = assistant(); 568 str = assistant();
569 if ( !str.isEmpty() ) 569 if ( !str.isEmpty() )
570 text += "<b>" + QObject::tr("Assistant: ") + "</b>" 570 text += "<b>" + QObject::tr("Assistant: ") + "</b>"
571 + Qtopia::escapeString(str) + "<br>"; 571 + Qtopia::escapeString(str) + "<br>";
572 str = manager(); 572 str = manager();
573 if ( !str.isEmpty() ) 573 if ( !str.isEmpty() )
574 text += "<b>" + QObject::tr("Manager: ") + "</b>" 574 text += "<b>" + QObject::tr("Manager: ") + "</b>"
575 + Qtopia::escapeString(str) + "<br>"; 575 + Qtopia::escapeString(str) + "<br>";
576 str = gender(); 576 str = gender();
577 if ( !str.isEmpty() && str.toInt() != 0 ) { 577 if ( !str.isEmpty() && str.toInt() != 0 ) {
578 if ( str.toInt() == 1 ) 578 if ( str.toInt() == 1 )
579 str = QObject::tr( "Male" ); 579 str = QObject::tr( "Male" );
580 else if ( str.toInt() == 2 ) 580 else if ( str.toInt() == 2 )
581 str = QObject::tr( "Female" ); 581 str = QObject::tr( "Female" );
582 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; 582 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>";
583 } 583 }
584 str = spouse(); 584 str = spouse();
585 if ( !str.isEmpty() ) 585 if ( !str.isEmpty() )
586 text += "<b>" + QObject::tr("Spouse: ") + "</b>" 586 text += "<b>" + QObject::tr("Spouse: ") + "</b>"
587 + Qtopia::escapeString(str) + "<br>"; 587 + Qtopia::escapeString(str) + "<br>";
588 str = birthday(); 588 str = birthday();
589 if ( !str.isEmpty() ) 589 if ( !str.isEmpty() )
590 text += "<b>" + QObject::tr("Birthday: ") + "</b>" 590 text += "<b>" + QObject::tr("Birthday: ") + "</b>"
591 + Qtopia::escapeString(str) + "<br>"; 591 + Qtopia::escapeString(str) + "<br>";
592 str = anniversary(); 592 str = anniversary();
593 if ( !str.isEmpty() ) 593 if ( !str.isEmpty() )
594 text += "<b>" + QObject::tr("Anniversary: ") + "</b>" 594 text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
595 + Qtopia::escapeString(str) + "<br>"; 595 + Qtopia::escapeString(str) + "<br>";
596 str = nickname(); 596 str = nickname();
597 if ( !str.isEmpty() ) 597 if ( !str.isEmpty() )
598 text += "<b>" + QObject::tr("Nickname: ") + "</b>" 598 text += "<b>" + QObject::tr("Nickname: ") + "</b>"
599 + Qtopia::escapeString(str) + "<br>"; 599 + Qtopia::escapeString(str) + "<br>";
600 600
601 // notes last 601 // notes last
602 if ( (value = notes()) ) { 602 if ( (value = notes()) ) {
603 QRegExp reg("\n"); 603 QRegExp reg("\n");
604 604
605 //QString tmp = Qtopia::escapeString(value); 605 //QString tmp = Qtopia::escapeString(value);
606 QString tmp = QStyleSheet::convertFromPlainText(value); 606 QString tmp = QStyleSheet::convertFromPlainText(value);
607 //tmp.replace( reg, "<br>" ); 607 //tmp.replace( reg, "<br>" );
608 text += "<br>" + tmp + "<br>"; 608 text += "<br>" + tmp + "<br>";
609 } 609 }
610 return text; 610 return text;
611} 611}
612 612
613/*! 613/*!
614 \internal 614 \internal
615*/ 615*/
616void OContact::insert( int key, const QString &v ) 616void OContact::insert( int key, const QString &v )
617{ 617{
618 QString value = v.stripWhiteSpace(); 618 QString value = v.stripWhiteSpace();
619 if ( value.isEmpty() ) 619 if ( value.isEmpty() )
620 mMap.remove( key ); 620 mMap.remove( key );
621 else 621 else
622 mMap.insert( key, value ); 622 mMap.insert( key, value );
623} 623}
624 624
625/*! 625/*!
626 \internal 626 \internal
627*/ 627*/
628void OContact::replace( int key, const QString & v ) 628void OContact::replace( int key, const QString & v )
629{ 629{
630 QString value = v.stripWhiteSpace(); 630 QString value = v.stripWhiteSpace();
631 if ( value.isEmpty() ) 631 if ( value.isEmpty() )
632 mMap.remove( key ); 632 mMap.remove( key );
633 else 633 else
634 mMap.replace( key, value ); 634 mMap.replace( key, value );
635} 635}
636 636
637/*! 637/*!
638 \internal 638 \internal
639*/ 639*/
640QString OContact::find( int key ) const 640QString OContact::find( int key ) const
641{ 641{
642 return mMap[key]; 642 return mMap[key];
643} 643}
644 644
645/*! 645/*!
646 \internal 646 \internal
647*/ 647*/
648QString OContact::displayAddress( const QString &street, 648QString OContact::displayAddress( const QString &street,
649 const QString &city, 649 const QString &city,
650 const QString &state, 650 const QString &state,
651 const QString &zip, 651 const QString &zip,
652 const QString &country ) const 652 const QString &country ) const
653{ 653{
654 QString s = street; 654 QString s = street;
655 if ( !street.isEmpty() ) 655 if ( !street.isEmpty() )
656 s+= "\n"; 656 s+= "\n";
657 s += city; 657 s += city;
658 if ( !city.isEmpty() && !state.isEmpty() ) 658 if ( !city.isEmpty() && !state.isEmpty() )
659 s += ", "; 659 s += ", ";
660 s += state; 660 s += state;
661 if ( !state.isEmpty() && !zip.isEmpty() ) 661 if ( !state.isEmpty() && !zip.isEmpty() )
662 s += " "; 662 s += " ";
663 s += zip; 663 s += zip;
664 if ( !country.isEmpty() && !s.isEmpty() ) 664 if ( !country.isEmpty() && !s.isEmpty() )
665 s += "\n"; 665 s += "\n";
666 s += country; 666 s += country;
667 return s; 667 return s;
668} 668}
669 669
670/*! 670/*!
671 \internal 671 \internal
672*/ 672*/
673QString OContact::displayBusinessAddress() const 673QString OContact::displayBusinessAddress() const
674{ 674{
675 return displayAddress( businessStreet(), businessCity(), 675 return displayAddress( businessStreet(), businessCity(),
676 businessState(), businessZip(), 676 businessState(), businessZip(),
677 businessCountry() ); 677 businessCountry() );
678} 678}
679 679
680/*! 680/*!
681 \internal 681 \internal
682*/ 682*/
683QString OContact::displayHomeAddress() const 683QString OContact::displayHomeAddress() const
684{ 684{
685 return displayAddress( homeStreet(), homeCity(), 685 return displayAddress( homeStreet(), homeCity(),
686 homeState(), homeZip(), 686 homeState(), homeZip(),
687 homeCountry() ); 687 homeCountry() );
688} 688}
689 689
690/*! 690/*!
691 Returns the full name of the contact 691 Returns the full name of the contact
692*/ 692*/
693QString OContact::fullName() const 693QString OContact::fullName() const
694{ 694{
695 QString title = find( Qtopia::Title ); 695 QString title = find( Qtopia::Title );
696 QString firstName = find( Qtopia::FirstName ); 696 QString firstName = find( Qtopia::FirstName );
697 QString middleName = find( Qtopia::MiddleName ); 697 QString middleName = find( Qtopia::MiddleName );
698 QString lastName = find( Qtopia::LastName ); 698 QString lastName = find( Qtopia::LastName );
699 QString suffix = find( Qtopia::Suffix ); 699 QString suffix = find( Qtopia::Suffix );
700 700
701 QString name = title; 701 QString name = title;
702 if ( !firstName.isEmpty() ) { 702 if ( !firstName.isEmpty() ) {
703 if ( !name.isEmpty() ) 703 if ( !name.isEmpty() )
704 name += " "; 704 name += " ";
705 name += firstName; 705 name += firstName;
706 } 706 }
707 if ( !middleName.isEmpty() ) { 707 if ( !middleName.isEmpty() ) {
708 if ( !name.isEmpty() ) 708 if ( !name.isEmpty() )
709 name += " "; 709 name += " ";
710 name += middleName; 710 name += middleName;
711 } 711 }
712 if ( !lastName.isEmpty() ) { 712 if ( !lastName.isEmpty() ) {
713 if ( !name.isEmpty() ) 713 if ( !name.isEmpty() )
714 name += " "; 714 name += " ";
715 name += lastName; 715 name += lastName;
716 } 716 }
717 if ( !suffix.isEmpty() ) { 717 if ( !suffix.isEmpty() ) {
718 if ( !name.isEmpty() ) 718 if ( !name.isEmpty() )
719 name += " "; 719 name += " ";
720 name += suffix; 720 name += suffix;
721 } 721 }
722 return name.simplifyWhiteSpace(); 722 return name.simplifyWhiteSpace();
723} 723}
724 724
725/*! 725/*!
726 Returns a list of the names of the children of the contact. 726 Returns a list of the names of the children of the contact.
727*/ 727*/
728QStringList OContact::childrenList() const 728QStringList OContact::childrenList() const
729{ 729{
730 return QStringList::split( " ", find( Qtopia::Children ) ); 730 return QStringList::split( " ", find( Qtopia::Children ) );
731} 731}
732 732
733/*! \fn void OContact::insertEmail( const QString &email ) 733/*! \fn void OContact::insertEmail( const QString &email )
734 734
735 Insert \a email into the email list. Ensures \a email can only be added 735 Insert \a email into the email list. Ensures \a email can only be added
736 once. If there is no default email address set, it sets it to the \a email. 736 once. If there is no default email address set, it sets it to the \a email.
737*/ 737*/
738 738
739/*! \fn void OContact::removeEmail( const QString &email ) 739/*! \fn void OContact::removeEmail( const QString &email )
740 740
741 Removes the \a email from the email list. If the default email was \a email, 741 Removes the \a email from the email list. If the default email was \a email,
742 then the default email address is assigned to the first email in the 742 then the default email address is assigned to the first email in the
743 email list 743 email list
744*/ 744*/
745 745
746/*! \fn void OContact::clearEmails() 746/*! \fn void OContact::clearEmails()
747 747
748 Clears the email list. 748 Clears the email list.
749 */ 749 */
750 750
751/*! \fn void OContact::insertEmails( const QStringList &emailList ) 751/*! \fn void OContact::insertEmails( const QStringList &emailList )
752 752
753 Appends the \a emailList to the exiting email list 753 Appends the \a emailList to the exiting email list
754 */ 754 */
755 755
756/*! 756/*!
757 Returns a list of email addresses belonging to the contact, including 757 Returns a list of email addresses belonging to the contact, including
758 the default email address. 758 the default email address.
759*/ 759*/
760QStringList OContact::emailList() const 760QStringList OContact::emailList() const
761{ 761{
762 QString emailStr = emails(); 762 QString emailStr = emails();
763 763
764 QStringList r; 764 QStringList r;
765 if ( !emailStr.isEmpty() ) { 765 if ( !emailStr.isEmpty() ) {
766 qDebug(" emailstr "); 766 qDebug(" emailstr ");
767 QStringList l = QStringList::split( emailSeparator(), emailStr ); 767 QStringList l = QStringList::split( emailSeparator(), emailStr );
768 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) 768 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
769 r += (*it).simplifyWhiteSpace(); 769 r += (*it).simplifyWhiteSpace();
770 } 770 }
771 771
772 return r; 772 return r;
773} 773}
774 774
775/*! 775/*!
776 \overload 776 \overload
777 777
778 Generates the string for the contact to be filed as from the first, 778 Generates the string for the contact to be filed as from the first,
779 middle and last name of the contact. 779 middle and last name of the contact.
780*/ 780*/
781void OContact::setFileAs() 781void OContact::setFileAs()
782{ 782{
783 QString lastName, firstName, middleName, fileas; 783 QString lastName, firstName, middleName, fileas;
784 784
785 lastName = find( Qtopia::LastName ); 785 lastName = find( Qtopia::LastName );
786 firstName = find( Qtopia::FirstName ); 786 firstName = find( Qtopia::FirstName );
787 middleName = find( Qtopia::MiddleName ); 787 middleName = find( Qtopia::MiddleName );
788 if ( !lastName.isEmpty() && !firstName.isEmpty() 788 if ( !lastName.isEmpty() && !firstName.isEmpty()
789 && !middleName.isEmpty() ) 789 && !middleName.isEmpty() )
790 fileas = lastName + ", " + firstName + " " + middleName; 790 fileas = lastName + ", " + firstName + " " + middleName;
791 else if ( !lastName.isEmpty() && !firstName.isEmpty() ) 791 else if ( !lastName.isEmpty() && !firstName.isEmpty() )
792 fileas = lastName + ", " + firstName; 792 fileas = lastName + ", " + firstName;
793 else if ( !lastName.isEmpty() || !firstName.isEmpty() || 793 else if ( !lastName.isEmpty() || !firstName.isEmpty() ||
794 !middleName.isEmpty() ) 794 !middleName.isEmpty() )
795 fileas = firstName + ( firstName.isEmpty() ? "" : " " ) 795 fileas = firstName + ( firstName.isEmpty() ? "" : " " )
796 + middleName + ( middleName.isEmpty() ? "" : " " ) 796 + middleName + ( middleName.isEmpty() ? "" : " " )
797 + lastName; 797 + lastName;
798 798
799 replace( Qtopia::FileAs, fileas ); 799 replace( Qtopia::FileAs, fileas );
800} 800}
801 801
802/*! 802/*!
803 \internal 803 \internal
804 Appends the contact information to \a buf. 804 Appends the contact information to \a buf.
805*/ 805*/
806void OContact::save( QString &buf ) const 806void OContact::save( QString &buf ) const
807{ 807{
808 static const QStringList SLFIELDS = fields(); 808 static const QStringList SLFIELDS = fields();
809 // I'm expecting "<Contact " in front of this... 809 // I'm expecting "<Contact " in front of this...
810 for ( QMap<int, QString>::ConstIterator it = mMap.begin(); 810 for ( QMap<int, QString>::ConstIterator it = mMap.begin();
811 it != mMap.end(); ++it ) { 811 it != mMap.end(); ++it ) {
812 const QString &value = it.data(); 812 const QString &value = it.data();
813 int key = it.key(); 813 int key = it.key();
814 if ( !value.isEmpty() ) { 814 if ( !value.isEmpty() ) {
815 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) 815 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)
816 continue; 816 continue;
817 817
818 key -= Qtopia::AddressCategory+1; 818 key -= Qtopia::AddressCategory+1;
819 buf += SLFIELDS[key]; 819 buf += SLFIELDS[key];
820 buf += "=\"" + Qtopia::escapeString(value) + "\" "; 820 buf += "=\"" + Qtopia::escapeString(value) + "\" ";
821 } 821 }
822 } 822 }
823 buf += customToXml(); 823 buf += customToXml();
824 if ( categories().count() > 0 ) 824 if ( categories().count() > 0 )
825 buf += "Categories=\"" + idsToString( categories() ) + "\" "; 825 buf += "Categories=\"" + idsToString( categories() ) + "\" ";
826 buf += "Uid=\"" + QString::number( uid() ) + "\" "; 826 buf += "Uid=\"" + QString::number( uid() ) + "\" ";
827 // You need to close this yourself 827 // You need to close this yourself
828} 828}
829 829
830/*! 830/*!
831 \internal 831 \internal
832 Returns the list of fields belonging to a contact 832 Returns the list of fields belonging to a contact
833*/ 833*/
834QStringList OContact::fields() 834QStringList OContact::fields()
835{ 835{
836 QStringList list; 836 QStringList list;
837 837
838 list.append( "Title" ); // Not Used! 838 list.append( "Title" ); // Not Used!
839 list.append( "FirstName" ); 839 list.append( "FirstName" );
840 list.append( "MiddleName" ); 840 list.append( "MiddleName" );
841 list.append( "LastName" ); 841 list.append( "LastName" );
842 list.append( "Suffix" ); 842 list.append( "Suffix" );
843 list.append( "FileAs" ); 843 list.append( "FileAs" );
844 844
845 list.append( "JobTitle" ); 845 list.append( "JobTitle" );
846 list.append( "Department" ); 846 list.append( "Department" );
847 list.append( "Company" ); 847 list.append( "Company" );
848 list.append( "BusinessPhone" ); 848 list.append( "BusinessPhone" );
849 list.append( "BusinessFax" ); 849 list.append( "BusinessFax" );
850 list.append( "BusinessMobile" ); 850 list.append( "BusinessMobile" );
851 851
852 list.append( "DefaultEmail" ); 852 list.append( "DefaultEmail" );
853 list.append( "Emails" ); 853 list.append( "Emails" );
854 854
855 list.append( "HomePhone" ); 855 list.append( "HomePhone" );
856 list.append( "HomeFax" ); 856 list.append( "HomeFax" );
857 list.append( "HomeMobile" ); 857 list.append( "HomeMobile" );
858 858
859 list.append( "BusinessStreet" ); 859 list.append( "BusinessStreet" );
860 list.append( "BusinessCity" ); 860 list.append( "BusinessCity" );
861 list.append( "BusinessState" ); 861 list.append( "BusinessState" );
862 list.append( "BusinessZip" ); 862 list.append( "BusinessZip" );
863 list.append( "BusinessCountry" ); 863 list.append( "BusinessCountry" );
864 list.append( "BusinessPager" ); 864 list.append( "BusinessPager" );
865 list.append( "BusinessWebPage" ); 865 list.append( "BusinessWebPage" );
866 866
867 list.append( "Office" ); 867 list.append( "Office" );
868 list.append( "Profession" ); 868 list.append( "Profession" );
869 list.append( "Assistant" ); 869 list.append( "Assistant" );
870 list.append( "Manager" ); 870 list.append( "Manager" );
871 871
872 list.append( "HomeStreet" ); 872 list.append( "HomeStreet" );
873 list.append( "HomeCity" ); 873 list.append( "HomeCity" );
874 list.append( "HomeState" ); 874 list.append( "HomeState" );
875 list.append( "HomeZip" ); 875 list.append( "HomeZip" );
876 list.append( "HomeCountry" ); 876 list.append( "HomeCountry" );
877 list.append( "HomeWebPage" ); 877 list.append( "HomeWebPage" );
878 878
879 list.append( "Spouse" ); 879 list.append( "Spouse" );
880 list.append( "Gender" ); 880 list.append( "Gender" );
881 list.append( "Birthday" ); 881 list.append( "Birthday" );
882 list.append( "Anniversary" ); 882 list.append( "Anniversary" );
883 list.append( "Nickname" ); 883 list.append( "Nickname" );
884 list.append( "Children" ); 884 list.append( "Children" );
885 885
886 list.append( "Notes" ); 886 list.append( "Notes" );
887 list.append( "Groups" ); 887 list.append( "Groups" );
888 888
889 return list; 889 return list;
890} 890}
891 891
892/*! 892/*!
893 \internal 893 \internal
894 Returns a translated list of field names for a contact. 894 Returns a translated list of field names for a contact.
895*/ 895*/
896QStringList OContact::trfields() 896QStringList OContact::trfields()
897{ 897{
898 QStringList list; 898 QStringList list;
899 899
900 list.append( QObject::tr( "Name Title") ); 900 list.append( QObject::tr( "Name Title") );
901 list.append( QObject::tr( "First Name" ) ); 901 list.append( QObject::tr( "First Name" ) );
902 list.append( QObject::tr( "Middle Name" ) ); 902 list.append( QObject::tr( "Middle Name" ) );
903 list.append( QObject::tr( "Last Name" ) ); 903 list.append( QObject::tr( "Last Name" ) );
904 list.append( QObject::tr( "Suffix" ) ); 904 list.append( QObject::tr( "Suffix" ) );
905 list.append( QObject::tr( "File As" ) ); 905 list.append( QObject::tr( "File As" ) );
906 906
907 list.append( QObject::tr( "Job Title" ) ); 907 list.append( QObject::tr( "Job Title" ) );
908 list.append( QObject::tr( "Department" ) ); 908 list.append( QObject::tr( "Department" ) );
909 list.append( QObject::tr( "Company" ) ); 909 list.append( QObject::tr( "Company" ) );
910 list.append( QObject::tr( "Business Phone" ) ); 910 list.append( QObject::tr( "Business Phone" ) );
911 list.append( QObject::tr( "Business Fax" ) ); 911 list.append( QObject::tr( "Business Fax" ) );
912 list.append( QObject::tr( "Business Mobile" ) ); 912 list.append( QObject::tr( "Business Mobile" ) );
913 913
914 list.append( QObject::tr( "Default Email" ) ); 914 list.append( QObject::tr( "Default Email" ) );
915 list.append( QObject::tr( "Emails" ) ); 915 list.append( QObject::tr( "Emails" ) );
916 916
917 list.append( QObject::tr( "Home Phone" ) ); 917 list.append( QObject::tr( "Home Phone" ) );
918 list.append( QObject::tr( "Home Fax" ) ); 918 list.append( QObject::tr( "Home Fax" ) );
919 list.append( QObject::tr( "Home Mobile" ) ); 919 list.append( QObject::tr( "Home Mobile" ) );
920 920
921 list.append( QObject::tr( "Business Street" ) ); 921 list.append( QObject::tr( "Business Street" ) );
922 list.append( QObject::tr( "Business City" ) ); 922 list.append( QObject::tr( "Business City" ) );
923 list.append( QObject::tr( "Business State" ) ); 923 list.append( QObject::tr( "Business State" ) );
924 list.append( QObject::tr( "Business Zip" ) ); 924 list.append( QObject::tr( "Business Zip" ) );
925 list.append( QObject::tr( "Business Country" ) ); 925 list.append( QObject::tr( "Business Country" ) );
926 list.append( QObject::tr( "Business Pager" ) ); 926 list.append( QObject::tr( "Business Pager" ) );
927 list.append( QObject::tr( "Business WebPage" ) ); 927 list.append( QObject::tr( "Business WebPage" ) );
928 928
929 list.append( QObject::tr( "Office" ) ); 929 list.append( QObject::tr( "Office" ) );
930 list.append( QObject::tr( "Profession" ) ); 930 list.append( QObject::tr( "Profession" ) );
931 list.append( QObject::tr( "Assistant" ) ); 931 list.append( QObject::tr( "Assistant" ) );
932 list.append( QObject::tr( "Manager" ) ); 932 list.append( QObject::tr( "Manager" ) );
933 933
934 list.append( QObject::tr( "Home Street" ) ); 934 list.append( QObject::tr( "Home Street" ) );
935 list.append( QObject::tr( "Home City" ) ); 935 list.append( QObject::tr( "Home City" ) );
936 list.append( QObject::tr( "Home State" ) ); 936 list.append( QObject::tr( "Home State" ) );
937 list.append( QObject::tr( "Home Zip" ) ); 937 list.append( QObject::tr( "Home Zip" ) );
938 list.append( QObject::tr( "Home Country" ) ); 938 list.append( QObject::tr( "Home Country" ) );
939 list.append( QObject::tr( "Home Web Page" ) ); 939 list.append( QObject::tr( "Home Web Page" ) );
940 940
941 list.append( QObject::tr( "Spouse" ) ); 941 list.append( QObject::tr( "Spouse" ) );
942 list.append( QObject::tr( "Gender" ) ); 942 list.append( QObject::tr( "Gender" ) );
943 list.append( QObject::tr( "Birthday" ) ); 943 list.append( QObject::tr( "Birthday" ) );
944 list.append( QObject::tr( "Anniversary" ) ); 944 list.append( QObject::tr( "Anniversary" ) );
945 list.append( QObject::tr( "Nickname" ) ); 945 list.append( QObject::tr( "Nickname" ) );
946 list.append( QObject::tr( "Children" ) ); 946 list.append( QObject::tr( "Children" ) );
947 947
948 list.append( QObject::tr( "Notes" ) ); 948 list.append( QObject::tr( "Notes" ) );
949 list.append( QObject::tr( "Groups" ) ); 949 list.append( QObject::tr( "Groups" ) );
950 950
951 return list; 951 return list;
952} 952}
953 953
954/*! 954/*!
955 Sets the list of email address for contact to those contained in \a str. 955 Sets the list of email address for contact to those contained in \a str.
956 Email address should be separated by ';'s. 956 Email address should be separated by ';'s.
957*/ 957*/
958void OContact::setEmails( const QString &str ) 958void OContact::setEmails( const QString &str )
959{ 959{
960 replace( Qtopia::Emails, str ); 960 replace( Qtopia::Emails, str );
961 if ( str.isEmpty() ) 961 if ( str.isEmpty() )
962 setDefaultEmail( QString::null ); 962 setDefaultEmail( QString::null );
963} 963}
964 964
965/*! 965/*!
966 Sets the list of children for the contact to those contained in \a str. 966 Sets the list of children for the contact to those contained in \a str.
967*/ 967*/
968void OContact::setChildren( const QString &str ) 968void OContact::setChildren( const QString &str )
969{ 969{
970 replace( Qtopia::Children, str ); 970 replace( Qtopia::Children, str );
971} 971}
972 972
973// vcard conversion code 973// vcard conversion code
974/*! 974/*!
975 \internal 975 \internal
976*/ 976*/
977static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) 977static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value )
978{ 978{
979 VObject *ret = 0; 979 VObject *ret = 0;
980 if ( o && !value.isEmpty() ) 980 if ( o && !value.isEmpty() )
981 ret = addPropValue( o, prop, value.latin1() ); 981 ret = addPropValue( o, prop, value.latin1() );
982 return ret; 982 return ret;
983} 983}
984 984
985/*! 985/*!
986 \internal 986 \internal
987*/ 987*/
988static inline VObject *safeAddProp( VObject *o, const char *prop) 988static inline VObject *safeAddProp( VObject *o, const char *prop)
989{ 989{
990 VObject *ret = 0; 990 VObject *ret = 0;
991 if ( o ) 991 if ( o )
992 ret = addProp( o, prop ); 992 ret = addProp( o, prop );
993 return ret; 993 return ret;
994} 994}
995 995
996/*! 996/*!
997 \internal 997 \internal
998*/ 998*/
999static VObject *createVObject( const OContact &c ) 999static VObject *createVObject( const OContact &c )
1000{ 1000{
1001 VObject *vcard = newVObject( VCCardProp ); 1001 VObject *vcard = newVObject( VCCardProp );
1002 safeAddPropValue( vcard, VCVersionProp, "2.1" ); 1002 safeAddPropValue( vcard, VCVersionProp, "2.1" );
1003 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); 1003 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
1004 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); 1004 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
1005 1005
1006 // full name 1006 // full name
1007 safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); 1007 safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
1008 1008
1009 // name properties 1009 // name properties
1010 VObject *name = safeAddProp( vcard, VCNameProp ); 1010 VObject *name = safeAddProp( vcard, VCNameProp );
1011 safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); 1011 safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
1012 safeAddPropValue( name, VCGivenNameProp, c.firstName() ); 1012 safeAddPropValue( name, VCGivenNameProp, c.firstName() );
1013 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); 1013 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() );
1014 safeAddPropValue( name, VCNamePrefixesProp, c.title() ); 1014 safeAddPropValue( name, VCNamePrefixesProp, c.title() );
1015 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); 1015 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() );
1016 1016
1017 // home properties 1017 // home properties
1018 VObject *home_adr= safeAddProp( vcard, VCAdrProp ); 1018 VObject *home_adr= safeAddProp( vcard, VCAdrProp );
1019 safeAddProp( home_adr, VCHomeProp ); 1019 safeAddProp( home_adr, VCHomeProp );
1020 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); 1020 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() );
1021 safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); 1021 safeAddPropValue( home_adr, VCCityProp, c.homeCity() );
1022 safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); 1022 safeAddPropValue( home_adr, VCRegionProp, c.homeState() );
1023 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); 1023 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() );
1024 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); 1024 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() );
1025 1025
1026 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); 1026 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() );
1027 safeAddProp( home_phone, VCHomeProp ); 1027 safeAddProp( home_phone, VCHomeProp );
1028 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); 1028 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() );
1029 safeAddProp( home_phone, VCHomeProp ); 1029 safeAddProp( home_phone, VCHomeProp );
1030 safeAddProp( home_phone, VCCellularProp ); 1030 safeAddProp( home_phone, VCCellularProp );
1031 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); 1031 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() );
1032 safeAddProp( home_phone, VCHomeProp ); 1032 safeAddProp( home_phone, VCHomeProp );
1033 safeAddProp( home_phone, VCFaxProp ); 1033 safeAddProp( home_phone, VCFaxProp );
1034 1034
1035 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); 1035 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() );
1036 safeAddProp( url, VCHomeProp ); 1036 safeAddProp( url, VCHomeProp );
1037 1037
1038 // work properties 1038 // work properties
1039 VObject *work_adr= safeAddProp( vcard, VCAdrProp ); 1039 VObject *work_adr= safeAddProp( vcard, VCAdrProp );
1040 safeAddProp( work_adr, VCWorkProp ); 1040 safeAddProp( work_adr, VCWorkProp );
1041 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); 1041 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() );
1042 safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); 1042 safeAddPropValue( work_adr, VCCityProp, c.businessCity() );
1043 safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); 1043 safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
1044 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); 1044 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
1045 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); 1045 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
1046 1046
1047 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); 1047 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
1048 safeAddProp( work_phone, VCWorkProp ); 1048 safeAddProp( work_phone, VCWorkProp );
1049 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); 1049 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
1050 safeAddProp( work_phone, VCWorkProp ); 1050 safeAddProp( work_phone, VCWorkProp );
1051 safeAddProp( work_phone, VCCellularProp ); 1051 safeAddProp( work_phone, VCCellularProp );
1052 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); 1052 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
1053 safeAddProp( work_phone, VCWorkProp ); 1053 safeAddProp( work_phone, VCWorkProp );
1054 safeAddProp( work_phone, VCFaxProp ); 1054 safeAddProp( work_phone, VCFaxProp );
1055 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); 1055 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
1056 safeAddProp( work_phone, VCWorkProp ); 1056 safeAddProp( work_phone, VCWorkProp );
1057 safeAddProp( work_phone, VCPagerProp ); 1057 safeAddProp( work_phone, VCPagerProp );
1058 1058
1059 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); 1059 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
1060 safeAddProp( url, VCWorkProp ); 1060 safeAddProp( url, VCWorkProp );
1061 1061
1062 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); 1062 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
1063 safeAddProp( title, VCWorkProp ); 1063 safeAddProp( title, VCWorkProp );
1064 1064
1065 1065
1066 QStringList emails = c.emailList(); 1066 QStringList emails = c.emailList();
1067 emails.prepend( c.defaultEmail() ); 1067 emails.prepend( c.defaultEmail() );
1068 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 1068 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
1069 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 1069 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
1070 safeAddProp( email, VCInternetProp ); 1070 safeAddProp( email, VCInternetProp );
1071 } 1071 }
1072 1072
1073 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 1073 safeAddPropValue( vcard, VCNoteProp, c.notes() );
1074 1074
1075 safeAddPropValue( vcard, VCBirthDateProp, c.birthday() ); 1075 safeAddPropValue( vcard, VCBirthDateProp, c.birthday() );
1076 1076
1077 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 1077 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
1078 VObject *org = safeAddProp( vcard, VCOrgProp ); 1078 VObject *org = safeAddProp( vcard, VCOrgProp );
1079 safeAddPropValue( org, VCOrgNameProp, c.company() ); 1079 safeAddPropValue( org, VCOrgNameProp, c.company() );
1080 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 1080 safeAddPropValue( org, VCOrgUnitProp, c.department() );
1081 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 1081 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
1082 } 1082 }
1083 1083
1084 // some values we have to export as custom fields 1084 // some values we have to export as custom fields
1085 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 1085 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
1086 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 1086 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
1087 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 1087 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
1088 1088
1089 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 1089 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
1090 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 1090 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
1091 safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); 1091 safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() );
1092 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 1092 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
1093 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); 1093 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
1094 1094
1095 return vcard; 1095 return vcard;
1096} 1096}
1097 1097
1098 1098
1099/*! 1099/*!
1100 \internal 1100 \internal
1101*/ 1101*/
1102static OContact parseVObject( VObject *obj ) 1102static OContact parseVObject( VObject *obj )
1103{ 1103{
1104 OContact c; 1104 OContact c;
1105 1105
1106 VObjectIterator it; 1106 VObjectIterator it;
1107 initPropIterator( &it, obj ); 1107 initPropIterator( &it, obj );
1108 while( moreIteration( &it ) ) { 1108 while( moreIteration( &it ) ) {
1109 VObject *o = nextVObject( &it ); 1109 VObject *o = nextVObject( &it );
1110 QCString name = vObjectName( o ); 1110 QCString name = vObjectName( o );
1111 QCString value = vObjectStringZValue( o ); 1111 QCString value = vObjectStringZValue( o );
1112 if ( name == VCNameProp ) { 1112 if ( name == VCNameProp ) {
1113 VObjectIterator nit; 1113 VObjectIterator nit;
1114 initPropIterator( &nit, o ); 1114 initPropIterator( &nit, o );
1115 while( moreIteration( &nit ) ) { 1115 while( moreIteration( &nit ) ) {
1116 VObject *o = nextVObject( &nit ); 1116 VObject *o = nextVObject( &nit );
1117 QCString name = vObjectTypeInfo( o ); 1117 QCString name = vObjectTypeInfo( o );
1118 QString value = vObjectStringZValue( o ); 1118 QString value = vObjectStringZValue( o );
1119 if ( name == VCNamePrefixesProp ) 1119 if ( name == VCNamePrefixesProp )
1120 c.setTitle( value ); 1120 c.setTitle( value );
1121 else if ( name == VCNameSuffixesProp ) 1121 else if ( name == VCNameSuffixesProp )
1122 c.setSuffix( value ); 1122 c.setSuffix( value );
1123 else if ( name == VCFamilyNameProp ) 1123 else if ( name == VCFamilyNameProp )
1124 c.setLastName( value ); 1124 c.setLastName( value );
1125 else if ( name == VCGivenNameProp ) 1125 else if ( name == VCGivenNameProp )
1126 c.setFirstName( value ); 1126 c.setFirstName( value );
1127 else if ( name == VCAdditionalNamesProp ) 1127 else if ( name == VCAdditionalNamesProp )
1128 c.setMiddleName( value ); 1128 c.setMiddleName( value );
1129 } 1129 }
1130 } 1130 }
1131 else if ( name == VCAdrProp ) { 1131 else if ( name == VCAdrProp ) {
1132 bool work = TRUE; // default address is work address 1132 bool work = TRUE; // default address is work address
1133 QString street; 1133 QString street;
1134 QString city; 1134 QString city;
1135 QString region; 1135 QString region;
1136 QString postal; 1136 QString postal;
1137 QString country; 1137 QString country;
1138 1138
1139 VObjectIterator nit; 1139 VObjectIterator nit;
1140 initPropIterator( &nit, o ); 1140 initPropIterator( &nit, o );
1141 while( moreIteration( &nit ) ) { 1141 while( moreIteration( &nit ) ) {
1142 VObject *o = nextVObject( &nit ); 1142 VObject *o = nextVObject( &nit );
1143 QCString name = vObjectName( o ); 1143 QCString name = vObjectName( o );
1144 QString value = vObjectStringZValue( o ); 1144 QString value = vObjectStringZValue( o );
1145 if ( name == VCHomeProp ) 1145 if ( name == VCHomeProp )
1146 work = FALSE; 1146 work = FALSE;
1147 else if ( name == VCWorkProp ) 1147 else if ( name == VCWorkProp )
1148 work = TRUE; 1148 work = TRUE;
1149 else if ( name == VCStreetAddressProp ) 1149 else if ( name == VCStreetAddressProp )
1150 street = value; 1150 street = value;
1151 else if ( name == VCCityProp ) 1151 else if ( name == VCCityProp )
1152 city = value; 1152 city = value;
1153 else if ( name == VCRegionProp ) 1153 else if ( name == VCRegionProp )
1154 region = value; 1154 region = value;
1155 else if ( name == VCPostalCodeProp ) 1155 else if ( name == VCPostalCodeProp )
1156 postal = value; 1156 postal = value;
1157 else if ( name == VCCountryNameProp ) 1157 else if ( name == VCCountryNameProp )
1158 country = value; 1158 country = value;
1159 } 1159 }
1160 if ( work ) { 1160 if ( work ) {
1161 c.setBusinessStreet( street ); 1161 c.setBusinessStreet( street );
1162 c.setBusinessCity( city ); 1162 c.setBusinessCity( city );
1163 c.setBusinessCountry( country ); 1163 c.setBusinessCountry( country );
1164 c.setBusinessZip( postal ); 1164 c.setBusinessZip( postal );
1165 c.setBusinessState( region ); 1165 c.setBusinessState( region );
1166 } else { 1166 } else {
1167 c.setHomeStreet( street ); 1167 c.setHomeStreet( street );
1168 c.setHomeCity( city ); 1168 c.setHomeCity( city );
1169 c.setHomeCountry( country ); 1169 c.setHomeCountry( country );
1170 c.setHomeZip( postal ); 1170 c.setHomeZip( postal );
1171 c.setHomeState( region ); 1171 c.setHomeState( region );
1172 } 1172 }
1173 } 1173 }
1174 else if ( name == VCTelephoneProp ) { 1174 else if ( name == VCTelephoneProp ) {
1175 enum { 1175 enum {
1176 HOME = 0x01, 1176 HOME = 0x01,
1177 WORK = 0x02, 1177 WORK = 0x02,
1178 VOICE = 0x04, 1178 VOICE = 0x04,
1179 CELL = 0x08, 1179 CELL = 0x08,
1180 FAX = 0x10, 1180 FAX = 0x10,
1181 PAGER = 0x20, 1181 PAGER = 0x20,
1182 UNKNOWN = 0x80 1182 UNKNOWN = 0x80
1183 }; 1183 };
1184 int type = 0; 1184 int type = 0;
1185 1185
1186 VObjectIterator nit; 1186 VObjectIterator nit;
1187 initPropIterator( &nit, o ); 1187 initPropIterator( &nit, o );
1188 while( moreIteration( &nit ) ) { 1188 while( moreIteration( &nit ) ) {
1189 VObject *o = nextVObject( &nit ); 1189 VObject *o = nextVObject( &nit );
1190 QCString name = vObjectTypeInfo( o ); 1190 QCString name = vObjectTypeInfo( o );
1191 if ( name == VCHomeProp ) 1191 if ( name == VCHomeProp )
1192 type |= HOME; 1192 type |= HOME;
1193 else if ( name == VCWorkProp ) 1193 else if ( name == VCWorkProp )
1194 type |= WORK; 1194 type |= WORK;
1195 else if ( name == VCVoiceProp ) 1195 else if ( name == VCVoiceProp )
1196 type |= VOICE; 1196 type |= VOICE;
1197 else if ( name == VCCellularProp ) 1197 else if ( name == VCCellularProp )
1198 type |= CELL; 1198 type |= CELL;
1199 else if ( name == VCFaxProp ) 1199 else if ( name == VCFaxProp )
1200 type |= FAX; 1200 type |= FAX;
1201 else if ( name == VCPagerProp ) 1201 else if ( name == VCPagerProp )
1202 type |= PAGER; 1202 type |= PAGER;
1203 else if ( name == VCPreferredProp ) 1203 else if ( name == VCPreferredProp )
1204 ; 1204 ;
1205 else 1205 else
1206 type |= UNKNOWN; 1206 type |= UNKNOWN;
1207 } 1207 }
1208 if ( (type & UNKNOWN) != UNKNOWN ) { 1208 if ( (type & UNKNOWN) != UNKNOWN ) {
1209 if ( ( type & (HOME|WORK) ) == 0 ) // default 1209 if ( ( type & (HOME|WORK) ) == 0 ) // default
1210 type |= HOME; 1210 type |= HOME;
1211 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default 1211 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
1212 type |= VOICE; 1212 type |= VOICE;
1213 1213
1214 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) 1214 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) )
1215 c.setHomePhone( value ); 1215 c.setHomePhone( value );
1216 if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) 1216 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
1217 c.setHomeFax( value ); 1217 c.setHomeFax( value );
1218 if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) 1218 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
1219 c.setHomeMobile( value ); 1219 c.setHomeMobile( value );
1220 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) 1220 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) )
1221 c.setBusinessPhone( value ); 1221 c.setBusinessPhone( value );
1222 if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) 1222 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
1223 c.setBusinessFax( value ); 1223 c.setBusinessFax( value );
1224 if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) 1224 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
1225 c.setBusinessMobile( value ); 1225 c.setBusinessMobile( value );
1226 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) 1226 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
1227 c.setBusinessPager( value ); 1227 c.setBusinessPager( value );
1228 } 1228 }
1229 } 1229 }
1230 else if ( name == VCEmailAddressProp ) { 1230 else if ( name == VCEmailAddressProp ) {
1231 QString email = vObjectStringZValue( o ); 1231 QString email = vObjectStringZValue( o );
1232 bool valid = TRUE; 1232 bool valid = TRUE;
1233 VObjectIterator nit; 1233 VObjectIterator nit;
1234 initPropIterator( &nit, o ); 1234 initPropIterator( &nit, o );
1235 while( moreIteration( &nit ) ) { 1235 while( moreIteration( &nit ) ) {
1236 VObject *o = nextVObject( &nit ); 1236 VObject *o = nextVObject( &nit );
1237 QCString name = vObjectTypeInfo( o ); 1237 QCString name = vObjectTypeInfo( o );
1238 if ( name != VCInternetProp && name != VCHomeProp && 1238 if ( name != VCInternetProp && name != VCHomeProp &&
1239 name != VCWorkProp && 1239 name != VCWorkProp &&
1240 name != VCPreferredProp ) 1240 name != VCPreferredProp )
1241 // ### preffered should map to default email 1241 // ### preffered should map to default email
1242 valid = FALSE; 1242 valid = FALSE;
1243 } 1243 }
1244 if ( valid ) { 1244 if ( valid ) {
1245 c.insertEmail( email ); 1245 c.insertEmail( email );
1246 } 1246 }
1247 } 1247 }
1248 else if ( name == VCURLProp ) { 1248 else if ( name == VCURLProp ) {
1249 VObjectIterator nit; 1249 VObjectIterator nit;
1250 initPropIterator( &nit, o ); 1250 initPropIterator( &nit, o );
1251 while( moreIteration( &nit ) ) { 1251 while( moreIteration( &nit ) ) {
1252 VObject *o = nextVObject( &nit ); 1252 VObject *o = nextVObject( &nit );
1253 QCString name = vObjectTypeInfo( o ); 1253 QCString name = vObjectTypeInfo( o );
1254 if ( name == VCHomeProp ) 1254 if ( name == VCHomeProp )
1255 c.setHomeWebpage( value ); 1255 c.setHomeWebpage( value );
1256 else if ( name == VCWorkProp ) 1256 else if ( name == VCWorkProp )
1257 c.setBusinessWebpage( value ); 1257 c.setBusinessWebpage( value );
1258 } 1258 }
1259 } 1259 }
1260 else if ( name == VCOrgProp ) { 1260 else if ( name == VCOrgProp ) {
1261 VObjectIterator nit; 1261 VObjectIterator nit;
1262 initPropIterator( &nit, o ); 1262 initPropIterator( &nit, o );
1263 while( moreIteration( &nit ) ) { 1263 while( moreIteration( &nit ) ) {
1264 VObject *o = nextVObject( &nit ); 1264 VObject *o = nextVObject( &nit );
1265 QCString name = vObjectName( o ); 1265 QCString name = vObjectName( o );
1266 QString value = vObjectStringZValue( o ); 1266 QString value = vObjectStringZValue( o );
1267 if ( name == VCOrgNameProp ) 1267 if ( name == VCOrgNameProp )
1268 c.setCompany( value ); 1268 c.setCompany( value );
1269 else if ( name == VCOrgUnitProp ) 1269 else if ( name == VCOrgUnitProp )
1270 c.setDepartment( value ); 1270 c.setDepartment( value );
1271 else if ( name == VCOrgUnit2Prop ) 1271 else if ( name == VCOrgUnit2Prop )
1272 c.setOffice( value ); 1272 c.setOffice( value );
1273 } 1273 }
1274 } 1274 }
1275 else if ( name == VCTitleProp ) { 1275 else if ( name == VCTitleProp ) {
1276 c.setJobTitle( value ); 1276 c.setJobTitle( value );
1277 } 1277 }
1278 else if ( name == "X-Qtopia-Profession" ) { 1278 else if ( name == "X-Qtopia-Profession" ) {
1279 c.setProfession( value ); 1279 c.setProfession( value );
1280 } 1280 }
1281 else if ( name == "X-Qtopia-Manager" ) { 1281 else if ( name == "X-Qtopia-Manager" ) {
1282 c.setManager( value ); 1282 c.setManager( value );
1283 } 1283 }
1284 else if ( name == "X-Qtopia-Assistant" ) { 1284 else if ( name == "X-Qtopia-Assistant" ) {
1285 c.setAssistant( value ); 1285 c.setAssistant( value );
1286 } 1286 }
1287 else if ( name == "X-Qtopia-Spouse" ) { 1287 else if ( name == "X-Qtopia-Spouse" ) {
1288 c.setSpouse( value ); 1288 c.setSpouse( value );
1289 } 1289 }
1290 else if ( name == "X-Qtopia-Gender" ) { 1290 else if ( name == "X-Qtopia-Gender" ) {
1291 c.setGender( value ); 1291 c.setGender( value );
1292 } 1292 }
1293 else if ( name == "X-Qtopia-Anniversary" ) { 1293 else if ( name == "X-Qtopia-Anniversary" ) {
1294 c.setAnniversary( value ); 1294 c.setAnniversary( value );
1295 } 1295 }
1296 else if ( name == "X-Qtopia-Nickname" ) { 1296 else if ( name == "X-Qtopia-Nickname" ) {
1297 c.setNickname( value ); 1297 c.setNickname( value );
1298 } 1298 }
1299 else if ( name == "X-Qtopia-Children" ) { 1299 else if ( name == "X-Qtopia-Children" ) {
1300 c.setChildren( value ); 1300 c.setChildren( value );
1301 } 1301 }
1302 1302
1303 1303
1304#if 0 1304#if 0
1305 else { 1305 else {
1306 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 1306 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
1307 VObjectIterator nit; 1307 VObjectIterator nit;
1308 initPropIterator( &nit, o ); 1308 initPropIterator( &nit, o );
1309 while( moreIteration( &nit ) ) { 1309 while( moreIteration( &nit ) ) {
1310 VObject *o = nextVObject( &nit ); 1310 VObject *o = nextVObject( &nit );
1311 QCString name = vObjectName( o ); 1311 QCString name = vObjectName( o );
1312 QString value = vObjectStringZValue( o ); 1312 QString value = vObjectStringZValue( o );
1313 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 1313 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
1314 } 1314 }
1315 } 1315 }
1316#endif 1316#endif
1317 } 1317 }
1318 c.setFileAs(); 1318 c.setFileAs();
1319 return c; 1319 return c;
1320} 1320}
1321 1321
1322/*! 1322/*!
1323 Writes the list of \a contacts as a set of VCards to the file \a filename. 1323 Writes the list of \a contacts as a set of VCards to the file \a filename.
1324*/ 1324*/
1325void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) 1325void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts)
1326{ 1326{
1327 QFileDirect f( filename.utf8().data() ); 1327 QFileDirect f( filename.utf8().data() );
1328 if ( !f.open( IO_WriteOnly ) ) { 1328 if ( !f.open( IO_WriteOnly ) ) {
1329 qWarning("Unable to open vcard write"); 1329 qWarning("Unable to open vcard write");
1330 return; 1330 return;
1331 } 1331 }
1332 1332
1333 QValueList<OContact>::ConstIterator it; 1333 QValueList<OContact>::ConstIterator it;
1334 for( it = contacts.begin(); it != contacts.end(); ++it ) { 1334 for( it = contacts.begin(); it != contacts.end(); ++it ) {
1335 VObject *obj = createVObject( *it ); 1335 VObject *obj = createVObject( *it );
1336 writeVObject(f.directHandle() , obj ); 1336 writeVObject(f.directHandle() , obj );
1337 cleanVObject( obj ); 1337 cleanVObject( obj );
1338 } 1338 }
1339 cleanStrTbl(); 1339 cleanStrTbl();
1340} 1340}
1341 1341
1342/*! 1342/*!
1343 writes \a contact as a VCard to the file \a filename. 1343 writes \a contact as a VCard to the file \a filename.
1344*/ 1344*/
1345void OContact::writeVCard( const QString &filename, const OContact &contact) 1345void OContact::writeVCard( const QString &filename, const OContact &contact)
1346{ 1346{
1347 QFileDirect f( filename.utf8().data() ); 1347 QFileDirect f( filename.utf8().data() );
1348 if ( !f.open( IO_WriteOnly ) ) { 1348 if ( !f.open( IO_WriteOnly ) ) {
1349 qWarning("Unable to open vcard write"); 1349 qWarning("Unable to open vcard write");
1350 return; 1350 return;
1351 } 1351 }
1352 1352
1353 VObject *obj = createVObject( contact ); 1353 VObject *obj = createVObject( contact );
1354 writeVObject( f.directHandle() , obj ); 1354 writeVObject( f.directHandle() , obj );
1355 cleanVObject( obj ); 1355 cleanVObject( obj );
1356 1356
1357 cleanStrTbl(); 1357 cleanStrTbl();
1358} 1358}
1359 1359
1360/*! 1360/*!
1361 Returns the set of contacts read as VCards from the file \a filename. 1361 Returns the set of contacts read as VCards from the file \a filename.
1362*/ 1362*/
1363QValueList<OContact> OContact::readVCard( const QString &filename ) 1363QValueList<OContact> OContact::readVCard( const QString &filename )
1364{ 1364{
1365 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); 1365 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() );
1366 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); 1366 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() );
1367 1367
1368 qDebug("vobject = %p", obj ); 1368 qDebug("vobject = %p", obj );
1369 1369
1370 QValueList<OContact> contacts; 1370 QValueList<OContact> contacts;
1371 1371
1372 while ( obj ) { 1372 while ( obj ) {
1373 contacts.append( parseVObject( obj ) ); 1373 contacts.append( parseVObject( obj ) );
1374 1374
1375 VObject *t = obj; 1375 VObject *t = obj;
1376 obj = nextVObjectInList(obj); 1376 obj = nextVObjectInList(obj);
1377 cleanVObject( t ); 1377 cleanVObject( t );
1378 } 1378 }
1379 1379
1380 return contacts; 1380 return contacts;
1381} 1381}
1382 1382
1383/*! 1383/*!
1384 Returns TRUE if the contact matches the regular expression \a regexp. 1384 Returns TRUE if the contact matches the regular expression \a regexp.
1385 Otherwise returns FALSE. 1385 Otherwise returns FALSE.
1386*/ 1386*/
1387bool OContact::match( const QString &regexp ) const 1387bool OContact::match( const QString &regexp ) const
1388{ 1388{
1389 return match(QRegExp(regexp)); 1389 return match(QRegExp(regexp));
1390} 1390}
1391 1391
1392/*! 1392/*!
1393 \overload 1393 \overload
1394 Returns TRUE if the contact matches the regular expression \a regexp. 1394 Returns TRUE if the contact matches the regular expression \a regexp.
1395 Otherwise returns FALSE. 1395 Otherwise returns FALSE.
1396*/ 1396*/
1397bool OContact::match( const QRegExp &r ) const 1397bool OContact::match( const QRegExp &r ) const
1398{ 1398{
1399 bool match; 1399 bool match;
1400 match = false; 1400 match = false;
1401 QMap<int, QString>::ConstIterator it; 1401 QMap<int, QString>::ConstIterator it;
1402 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 1402 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
1403 if ( (*it).find( r ) > -1 ) { 1403 if ( (*it).find( r ) > -1 ) {
1404 match = true; 1404 match = true;
1405 break; 1405 break;
1406 } 1406 }
1407 } 1407 }
1408 return match; 1408 return match;
1409} 1409}
1410 1410
1411 1411
1412// Noch nicht definiert ! :SX
1413QString OContact::toShortText() const 1412QString OContact::toShortText() const
1414{ 1413{
1415 return ( QString::fromLatin1( "Not defined!") ); 1414 return ( fullName() );
1416} 1415}
1417QString OContact::type() const 1416QString OContact::type() const
1418{ 1417{
1419 return QString::fromLatin1( "OContact" ); 1418 return QString::fromLatin1( "OContact" );
1420} 1419}
1421 1420
1422// Noch nicht definiert ! :SX 1421// Definition is missing ! (se)
1423QMap<QString,QString> OContact::toExtraMap() const 1422QMap<QString,QString> OContact::toExtraMap() const
1424{ 1423{
1424 qWarning ("Function not implemented: OContact::toExtraMap()");
1425 QMap <QString,QString> useless; 1425 QMap <QString,QString> useless;
1426 return useless; 1426 return useless;
1427} 1427}
1428 1428
1429// Noch nicht definiert ! :SX 1429class QString OContact::recordField( int pos ) const
1430class QString OContact::recordField(int) const
1431{ 1430{
1432 return QString::fromLatin1( "Noch nicht implementiert !" ); 1431 QStringList SLFIELDS = fields(); // ?? why this ? (se)
1432 return SLFIELDS[pos];
1433} 1433}
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h
index e0555c8..756c87d 100644
--- a/libopie2/opiepim/ocontact.h
+++ b/libopie2/opiepim/ocontact.h
@@ -1,311 +1,314 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef __OCONTACT_H__ 21#ifndef __OCONTACT_H__
22#define __OCONTACT_H__ 22#define __OCONTACT_H__
23 23
24#include <opie/opimrecord.h> 24#include <opie/opimrecord.h>
25#include <qpe/recordfields.h> 25#include <qpe/recordfields.h>
26 26
27#include <qstringlist.h> 27#include <qstringlist.h>
28 28
29#if defined(QPC_TEMPLATEDLL) 29#if defined(QPC_TEMPLATEDLL)
30// MOC_SKIP_BEGIN 30// MOC_SKIP_BEGIN
31QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; 31QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
32// MOC_SKIP_END 32// MOC_SKIP_END
33#endif 33#endif
34 34
35class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se) 35class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se)
36class QPC_EXPORT OContact : public OPimRecord 36class QPC_EXPORT OContact : public OPimRecord
37{ 37{
38 friend class DataSet; 38 friend class DataSet;
39public: 39public:
40 OContact(); 40 OContact();
41 OContact( const QMap<int, QString> &fromMap ); 41 OContact( const QMap<int, QString> &fromMap );
42 virtual ~OContact(); 42 virtual ~OContact();
43 43
44 static void writeVCard( const QString &filename, const QValueList<OContact> &contacts); 44 static void writeVCard( const QString &filename, const QValueList<OContact> &contacts);
45 static void writeVCard( const QString &filename, const OContact &c ); 45 static void writeVCard( const QString &filename, const OContact &c );
46 static QValueList<OContact> readVCard( const QString &filename ); 46 static QValueList<OContact> readVCard( const QString &filename );
47 47
48 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; 48 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
49 49
50 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } 50 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); }
51 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } 51 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); }
52 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } 52 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); }
53 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } 53 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); }
54 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } 54 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); }
55 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } 55 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); }
56 void setFileAs(); 56 void setFileAs();
57 57
58 // default email address 58 // default email address
59 void setDefaultEmail( const QString &v ); 59 void setDefaultEmail( const QString &v );
60 // inserts email to list and ensure's doesn't already exist 60 // inserts email to list and ensure's doesn't already exist
61 void insertEmail( const QString &v ); 61 void insertEmail( const QString &v );
62 void removeEmail( const QString &v ); 62 void removeEmail( const QString &v );
63 void clearEmails(); 63 void clearEmails();
64 void insertEmails( const QStringList &v ); 64 void insertEmails( const QStringList &v );
65 65
66 // home 66 // home
67 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } 67 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); }
68 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } 68 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); }
69 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } 69 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); }
70 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } 70 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); }
71 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } 71 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); }
72 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } 72 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); }
73 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } 73 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); }
74 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } 74 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); }
75 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } 75 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); }
76 76
77 // business 77 // business
78 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } 78 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); }
79 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } 79 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); }
80 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } 80 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); }
81 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } 81 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); }
82 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } 82 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); }
83 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } 83 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); }
84 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } 84 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); }
85 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } 85 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); }
86 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } 86 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); }
87 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } 87 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); }
88 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } 88 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); }
89 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } 89 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); }
90 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } 90 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); }
91 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } 91 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); }
92 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } 92 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); }
93 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } 93 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); }
94 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } 94 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); }
95 95
96 // personal 96 // personal
97 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } 97 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); }
98 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } 98 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); }
99 void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } 99 void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); }
100 void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } 100 void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); }
101 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } 101 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
102 void setChildren( const QString &v ); 102 void setChildren( const QString &v );
103 103
104 // other 104 // other
105 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } 105 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
106 106
107 bool match( const QString &regexp ) const; 107 bool match( const QString &regexp ) const;
108 108
109// DON'T ATTEMPT TO USE THIS 109// DON'T ATTEMPT TO USE THIS
110#ifdef QTOPIA_INTERNAL_CONTACT_MRE 110#ifdef QTOPIA_INTERNAL_CONTACT_MRE
111 bool match( const QRegExp &regexp ) const; 111 bool match( const QRegExp &regexp ) const;
112#endif 112#endif
113 113
114// // custom 114// // custom
115// void setCustomField( const QString &key, const QString &v ) 115// void setCustomField( const QString &key, const QString &v )
116// { replace(Custom- + key, v ); } 116// { replace(Custom- + key, v ); }
117 117
118 // name 118 // name
119 QString fullName() const; 119 QString fullName() const;
120 QString title() const { return find( Qtopia::Title ); } 120 QString title() const { return find( Qtopia::Title ); }
121 QString firstName() const { return find( Qtopia::FirstName ); } 121 QString firstName() const { return find( Qtopia::FirstName ); }
122 QString middleName() const { return find( Qtopia::MiddleName ); } 122 QString middleName() const { return find( Qtopia::MiddleName ); }
123 QString lastName() const { return find( Qtopia::LastName ); } 123 QString lastName() const { return find( Qtopia::LastName ); }
124 QString suffix() const { return find( Qtopia::Suffix ); } 124 QString suffix() const { return find( Qtopia::Suffix ); }
125 QString fileAs() const { return find( Qtopia::FileAs ); } 125 QString fileAs() const { return find( Qtopia::FileAs ); }
126 126
127 // email 127 // email
128 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } 128 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); }
129 QStringList emailList() const; 129 QStringList emailList() const;
130 130
131 // home 131 // home
132 QString homeStreet() const { return find( Qtopia::HomeStreet ); } 132 QString homeStreet() const { return find( Qtopia::HomeStreet ); }
133 QString homeCity() const { return find( Qtopia::HomeCity ); } 133 QString homeCity() const { return find( Qtopia::HomeCity ); }
134 QString homeState() const { return find( Qtopia::HomeState ); } 134 QString homeState() const { return find( Qtopia::HomeState ); }
135 QString homeZip() const { return find( Qtopia::HomeZip ); } 135 QString homeZip() const { return find( Qtopia::HomeZip ); }
136 QString homeCountry() const { return find( Qtopia::HomeCountry ); } 136 QString homeCountry() const { return find( Qtopia::HomeCountry ); }
137 QString homePhone() const { return find( Qtopia::HomePhone ); } 137 QString homePhone() const { return find( Qtopia::HomePhone ); }
138 QString homeFax() const { return find( Qtopia::HomeFax ); } 138 QString homeFax() const { return find( Qtopia::HomeFax ); }
139 QString homeMobile() const { return find( Qtopia::HomeMobile ); } 139 QString homeMobile() const { return find( Qtopia::HomeMobile ); }
140 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } 140 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); }
141 /** Multi line string containing all non-empty address info in the form 141 /** Multi line string containing all non-empty address info in the form
142 * Street 142 * Street
143 * City, State Zip 143 * City, State Zip
144 * Country 144 * Country
145 */ 145 */
146 QString displayHomeAddress() const; 146 QString displayHomeAddress() const;
147 147
148 // business 148 // business
149 QString company() const { return find( Qtopia::Company ); } 149 QString company() const { return find( Qtopia::Company ); }
150 QString businessStreet() const { return find( Qtopia::BusinessStreet ); } 150 QString businessStreet() const { return find( Qtopia::BusinessStreet ); }
151 QString businessCity() const { return find( Qtopia::BusinessCity ); } 151 QString businessCity() const { return find( Qtopia::BusinessCity ); }
152 QString businessState() const { return find( Qtopia::BusinessState ); } 152 QString businessState() const { return find( Qtopia::BusinessState ); }
153 QString businessZip() const { return find( Qtopia::BusinessZip ); } 153 QString businessZip() const { return find( Qtopia::BusinessZip ); }
154 QString businessCountry() const { return find( Qtopia::BusinessCountry ); } 154 QString businessCountry() const { return find( Qtopia::BusinessCountry ); }
155 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } 155 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
156 QString jobTitle() const { return find( Qtopia::JobTitle ); } 156 QString jobTitle() const { return find( Qtopia::JobTitle ); }
157 QString department() const { return find( Qtopia::Department ); } 157 QString department() const { return find( Qtopia::Department ); }
158 QString office() const { return find( Qtopia::Office ); } 158 QString office() const { return find( Qtopia::Office ); }
159 QString businessPhone() const { return find( Qtopia::BusinessPhone ); } 159 QString businessPhone() const { return find( Qtopia::BusinessPhone ); }
160 QString businessFax() const { return find( Qtopia::BusinessFax ); } 160 QString businessFax() const { return find( Qtopia::BusinessFax ); }
161 QString businessMobile() const { return find( Qtopia::BusinessMobile ); } 161 QString businessMobile() const { return find( Qtopia::BusinessMobile ); }
162 QString businessPager() const { return find( Qtopia::BusinessPager ); } 162 QString businessPager() const { return find( Qtopia::BusinessPager ); }
163 QString profession() const { return find( Qtopia::Profession ); } 163 QString profession() const { return find( Qtopia::Profession ); }
164 QString assistant() const { return find( Qtopia::Assistant ); } 164 QString assistant() const { return find( Qtopia::Assistant ); }
165 QString manager() const { return find( Qtopia::Manager ); } 165 QString manager() const { return find( Qtopia::Manager ); }
166 /** Multi line string containing all non-empty address info in the form 166 /** Multi line string containing all non-empty address info in the form
167 * Street 167 * Street
168 * City, State Zip 168 * City, State Zip
169 * Country 169 * Country
170 */ 170 */
171 QString displayBusinessAddress() const; 171 QString displayBusinessAddress() const;
172 172
173 //personal 173 //personal
174 QString spouse() const { return find( Qtopia::Spouse ); } 174 QString spouse() const { return find( Qtopia::Spouse ); }
175 QString gender() const { return find( Qtopia::Gender ); } 175 QString gender() const { return find( Qtopia::Gender ); }
176 QString birthday() const { return find( Qtopia::Birthday ); } 176 QString birthday() const { return find( Qtopia::Birthday ); }
177 QString anniversary() const { return find( Qtopia::Anniversary ); } 177 QString anniversary() const { return find( Qtopia::Anniversary ); }
178 QString nickname() const { return find( Qtopia::Nickname ); } 178 QString nickname() const { return find( Qtopia::Nickname ); }
179 QString children() const { return find( Qtopia::Children ); } 179 QString children() const { return find( Qtopia::Children ); }
180 QStringList childrenList() const; 180 QStringList childrenList() const;
181 181
182 // other 182 // other
183 QString notes() const { return find( Qtopia::Notes ); } 183 QString notes() const { return find( Qtopia::Notes ); }
184 QString groups() const { return find( Qtopia::Groups ); } 184 QString groups() const { return find( Qtopia::Groups ); }
185 QStringList groupList() const; 185 QStringList groupList() const;
186 186
187// // custom 187// // custom
188// const QString &customField( const QString &key ) 188// const QString &customField( const QString &key )
189// { return find( Custom- + key ); } 189// { return find( Custom- + key ); }
190 190
191 static QStringList fields(); 191 static QStringList fields();
192 static QStringList trfields(); 192 static QStringList trfields();
193 193
194 QString toRichText() const; 194 QString toRichText() const;
195 QMap<int, QString> toMap() const; 195 QMap<int, QString> toMap() const;
196 QString field( int key ) const { return find( key ); } 196 QString field( int key ) const { return find( key ); }
197 197
198 198
199 // journaling... 199 // journaling...
200 void saveJournal( journal_action action, const QString &key = QString::null ); 200 void saveJournal( journal_action action, const QString &key = QString::null );
201 void save( QString &buf ) const; 201 void save( QString &buf ) const;
202 202
203 void setUid( int i ) 203 void setUid( int i )
204{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } 204{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); }
205 205
206 QString toShortText()const; 206 QString toShortText()const;
207 QString OContact::type()const; 207 QString OContact::type()const;
208 QMap<QString,QString> OContact::toExtraMap() const; 208 QMap<QString,QString> OContact::toExtraMap() const;
209 class QString OContact::recordField(int) const; 209 class QString OContact::recordField(int) const;
210 210
211 // Why private ? (eilers,se)
212 QString emailSeparator() const { return " "; }
213 // the emails should be seperated by a comma
214 void setEmails( const QString &v );
215 QString emails() const { return find( Qtopia::Emails ); }
216
217
211private: 218private:
212 friend class AbEditor; 219 friend class AbEditor;
213 friend class AbTable; 220 friend class AbTable;
214 friend class AddressBookAccessPrivate; 221 friend class AddressBookAccessPrivate;
215 friend class XMLIO; 222 friend class XMLIO;
216 223
217 QString emailSeparator() const { return " "; }
218 // the emails should be seperated by a comma
219 void setEmails( const QString &v );
220 QString emails() const { return find( Qtopia::Emails ); }
221 224
222 void insert( int key, const QString &value ); 225 void insert( int key, const QString &value );
223 void replace( int key, const QString &value ); 226 void replace( int key, const QString &value );
224 QString find( int key ) const; 227 QString find( int key ) const;
225 228
226 QString displayAddress( const QString &street, 229 QString displayAddress( const QString &street,
227 const QString &city, 230 const QString &city,
228 const QString &state, 231 const QString &state,
229 const QString &zip, 232 const QString &zip,
230 const QString &country ) const; 233 const QString &country ) const;
231 234
232 Qtopia::UidGen &uidGen() { return sUidGen; } 235 Qtopia::UidGen &uidGen() { return sUidGen; }
233 static Qtopia::UidGen sUidGen; 236 static Qtopia::UidGen sUidGen;
234 QMap<int, QString> mMap; 237 QMap<int, QString> mMap;
235 ContactPrivate *d; 238 ContactPrivate *d;
236}; 239};
237 240
238// these methods are inlined to keep binary compatability with Qtopia 1.5 241// these methods are inlined to keep binary compatability with Qtopia 1.5
239inline void OContact::insertEmail( const QString &v ) 242inline void OContact::insertEmail( const QString &v )
240{ 243{
241 //qDebug("insertEmail %s", v.latin1()); 244 //qDebug("insertEmail %s", v.latin1());
242 QString e = v.simplifyWhiteSpace(); 245 QString e = v.simplifyWhiteSpace();
243 QString def = defaultEmail(); 246 QString def = defaultEmail();
244 247
245 // if no default, set it as the default email and don't insert 248 // if no default, set it as the default email and don't insert
246 if ( def.isEmpty() ) { 249 if ( def.isEmpty() ) {
247 setDefaultEmail( e ); // will insert into the list for us 250 setDefaultEmail( e ); // will insert into the list for us
248 return; 251 return;
249 } 252 }
250 253
251 // otherwise, insert assuming doesn't already exist 254 // otherwise, insert assuming doesn't already exist
252 QString emailsStr = find( Qtopia::Emails ); 255 QString emailsStr = find( Qtopia::Emails );
253 if ( emailsStr.contains( e )) 256 if ( emailsStr.contains( e ))
254 return; 257 return;
255 if ( !emailsStr.isEmpty() ) 258 if ( !emailsStr.isEmpty() )
256 emailsStr += emailSeparator(); 259 emailsStr += emailSeparator();
257 emailsStr += e; 260 emailsStr += e;
258 replace( Qtopia::Emails, emailsStr ); 261 replace( Qtopia::Emails, emailsStr );
259} 262}
260 263
261inline void OContact::removeEmail( const QString &v ) 264inline void OContact::removeEmail( const QString &v )
262{ 265{
263 QString e = v.simplifyWhiteSpace(); 266 QString e = v.simplifyWhiteSpace();
264 QString def = defaultEmail(); 267 QString def = defaultEmail();
265 QString emailsStr = find( Qtopia::Emails ); 268 QString emailsStr = find( Qtopia::Emails );
266 QStringList emails = emailList(); 269 QStringList emails = emailList();
267 270
268 // otherwise, must first contain it 271 // otherwise, must first contain it
269 if ( !emailsStr.contains( e ) ) 272 if ( !emailsStr.contains( e ) )
270 return; 273 return;
271 274
272 // remove it 275 // remove it
273 //qDebug(" removing email from list %s", e.latin1()); 276 //qDebug(" removing email from list %s", e.latin1());
274 emails.remove( e ); 277 emails.remove( e );
275 // reset the string 278 // reset the string
276 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator 279 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
277 replace( Qtopia::Emails, emailsStr ); 280 replace( Qtopia::Emails, emailsStr );
278 281
279 // if default, then replace the default email with the first one 282 // if default, then replace the default email with the first one
280 if ( def == e ) { 283 if ( def == e ) {
281 //qDebug("removeEmail is default; setting new default"); 284 //qDebug("removeEmail is default; setting new default");
282 if ( !emails.count() ) 285 if ( !emails.count() )
283 clearEmails(); 286 clearEmails();
284 else // setDefaultEmail will remove e from the list 287 else // setDefaultEmail will remove e from the list
285 setDefaultEmail( emails.first() ); 288 setDefaultEmail( emails.first() );
286 } 289 }
287} 290}
288inline void OContact::clearEmails() 291inline void OContact::clearEmails()
289{ 292{
290 mMap.remove( Qtopia::DefaultEmail ); 293 mMap.remove( Qtopia::DefaultEmail );
291 mMap.remove( Qtopia::Emails ); 294 mMap.remove( Qtopia::Emails );
292} 295}
293inline void OContact::setDefaultEmail( const QString &v ) 296inline void OContact::setDefaultEmail( const QString &v )
294{ 297{
295 QString e = v.simplifyWhiteSpace(); 298 QString e = v.simplifyWhiteSpace();
296 299
297 //qDebug("OContact::setDefaultEmail %s", e.latin1()); 300 //qDebug("OContact::setDefaultEmail %s", e.latin1());
298 replace( Qtopia::DefaultEmail, e ); 301 replace( Qtopia::DefaultEmail, e );
299 302
300 if ( !e.isEmpty() ) 303 if ( !e.isEmpty() )
301 insertEmail( e ); 304 insertEmail( e );
302 305
303} 306}
304 307
305inline void OContact::insertEmails( const QStringList &v ) 308inline void OContact::insertEmails( const QStringList &v )
306{ 309{
307 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 310 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
308 insertEmail( *it ); 311 insertEmail( *it );
309} 312}
310 313
311#endif 314#endif