summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp122
-rw-r--r--libopie2/opiepim/ocontact.cpp122
2 files changed, 154 insertions, 90 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index c9084ad..9230b8b 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -56,940 +56,972 @@ OContact::OContact()
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 70
71 QString uidStr = find( Qtopia::AddressUid ); 71 QString uidStr = find( Qtopia::AddressUid );
72 72
73 if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ 73 if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){
74 qWarning( "Invalid UID found. Generate new one.." ); 74 qWarning( "Invalid UID found. Generate new one.." );
75 setUid( uidGen().generate() ); 75 setUid( uidGen().generate() );
76 }else 76 }else
77 setUid( uidStr.toInt() ); 77 setUid( uidStr.toInt() );
78 78
79// if ( !uidStr.isEmpty() ) 79// if ( !uidStr.isEmpty() )
80 // setUid( uidStr.toInt() ); 80 // setUid( uidStr.toInt() );
81} 81}
82 82
83/*! 83/*!
84 Destroys a contact. 84 Destroys a contact.
85*/ 85*/
86OContact::~OContact() 86OContact::~OContact()
87{ 87{
88} 88}
89 89
90/*! \fn void OContact::setTitle( const QString &str ) 90/*! \fn void OContact::setTitle( const QString &str )
91 Sets the title of the contact to \a str. 91 Sets the title of the contact to \a str.
92*/ 92*/
93 93
94/*! \fn void OContact::setFirstName( const QString &str ) 94/*! \fn void OContact::setFirstName( const QString &str )
95 Sets the first name of the contact to \a str. 95 Sets the first name of the contact to \a str.
96*/ 96*/
97 97
98/*! \fn void OContact::setMiddleName( const QString &str ) 98/*! \fn void OContact::setMiddleName( const QString &str )
99 Sets the middle name of the contact to \a str. 99 Sets the middle name of the contact to \a str.
100*/ 100*/
101 101
102/*! \fn void OContact::setLastName( const QString &str ) 102/*! \fn void OContact::setLastName( const QString &str )
103 Sets the last name of the contact to \a str. 103 Sets the last name of the contact to \a str.
104*/ 104*/
105 105
106/*! \fn void OContact::setSuffix( const QString &str ) 106/*! \fn void OContact::setSuffix( const QString &str )
107 Sets the suffix of the contact to \a str. 107 Sets the suffix of the contact to \a str.
108*/ 108*/
109 109
110/*! \fn void OContact::setFileAs( const QString &str ) 110/*! \fn void OContact::setFileAs( const QString &str )
111 Sets the contact to filed as \a str. 111 Sets the contact to filed as \a str.
112*/ 112*/
113 113
114/*! \fn void OContact::setDefaultEmail( const QString &str ) 114/*! \fn void OContact::setDefaultEmail( const QString &str )
115 Sets the default email of the contact to \a str. 115 Sets the default email of the contact to \a str.
116*/ 116*/
117 117
118/*! \fn void OContact::setHomeStreet( const QString &str ) 118/*! \fn void OContact::setHomeStreet( const QString &str )
119 Sets the home street address of the contact to \a str. 119 Sets the home street address of the contact to \a str.
120*/ 120*/
121 121
122/*! \fn void OContact::setHomeCity( const QString &str ) 122/*! \fn void OContact::setHomeCity( const QString &str )
123 Sets the home city of the contact to \a str. 123 Sets the home city of the contact to \a str.
124*/ 124*/
125 125
126/*! \fn void OContact::setHomeState( const QString &str ) 126/*! \fn void OContact::setHomeState( const QString &str )
127 Sets the home state of the contact to \a str. 127 Sets the home state of the contact to \a str.
128*/ 128*/
129 129
130/*! \fn void OContact::setHomeZip( const QString &str ) 130/*! \fn void OContact::setHomeZip( const QString &str )
131 Sets the home zip code of the contact to \a str. 131 Sets the home zip code of the contact to \a str.
132*/ 132*/
133 133
134/*! \fn void OContact::setHomeCountry( const QString &str ) 134/*! \fn void OContact::setHomeCountry( const QString &str )
135 Sets the home country of the contact to \a str. 135 Sets the home country of the contact to \a str.
136*/ 136*/
137 137
138/*! \fn void OContact::setHomePhone( const QString &str ) 138/*! \fn void OContact::setHomePhone( const QString &str )
139 Sets the home phone number of the contact to \a str. 139 Sets the home phone number of the contact to \a str.
140*/ 140*/
141 141
142/*! \fn void OContact::setHomeFax( const QString &str ) 142/*! \fn void OContact::setHomeFax( const QString &str )
143 Sets the home fax number of the contact to \a str. 143 Sets the home fax number of the contact to \a str.
144*/ 144*/
145 145
146/*! \fn void OContact::setHomeMobile( const QString &str ) 146/*! \fn void OContact::setHomeMobile( const QString &str )
147 Sets the home mobile phone number of the contact to \a str. 147 Sets the home mobile phone number of the contact to \a str.
148*/ 148*/
149 149
150/*! \fn void OContact::setHomeWebpage( const QString &str ) 150/*! \fn void OContact::setHomeWebpage( const QString &str )
151 Sets the home webpage of the contact to \a str. 151 Sets the home webpage of the contact to \a str.
152*/ 152*/
153 153
154/*! \fn void OContact::setCompany( const QString &str ) 154/*! \fn void OContact::setCompany( const QString &str )
155 Sets the company for contact to \a str. 155 Sets the company for contact to \a str.
156*/ 156*/
157 157
158/*! \fn void OContact::setJobTitle( const QString &str ) 158/*! \fn void OContact::setJobTitle( const QString &str )
159 Sets the job title of the contact to \a str. 159 Sets the job title of the contact to \a str.
160*/ 160*/
161 161
162/*! \fn void OContact::setDepartment( const QString &str ) 162/*! \fn void OContact::setDepartment( const QString &str )
163 Sets the department for contact to \a str. 163 Sets the department for contact to \a str.
164*/ 164*/
165 165
166/*! \fn void OContact::setOffice( const QString &str ) 166/*! \fn void OContact::setOffice( const QString &str )
167 Sets the office for contact to \a str. 167 Sets the office for contact to \a str.
168*/ 168*/
169 169
170/*! \fn void OContact::setBusinessStreet( const QString &str ) 170/*! \fn void OContact::setBusinessStreet( const QString &str )
171 Sets the business street address of the contact to \a str. 171 Sets the business street address of the contact to \a str.
172*/ 172*/
173 173
174/*! \fn void OContact::setBusinessCity( const QString &str ) 174/*! \fn void OContact::setBusinessCity( const QString &str )
175 Sets the business city of the contact to \a str. 175 Sets the business city of the contact to \a str.
176*/ 176*/
177 177
178/*! \fn void OContact::setBusinessState( const QString &str ) 178/*! \fn void OContact::setBusinessState( const QString &str )
179 Sets the business state of the contact to \a str. 179 Sets the business state of the contact to \a str.
180*/ 180*/
181 181
182/*! \fn void OContact::setBusinessZip( const QString &str ) 182/*! \fn void OContact::setBusinessZip( const QString &str )
183 Sets the business zip code of the contact to \a str. 183 Sets the business zip code of the contact to \a str.
184*/ 184*/
185 185
186/*! \fn void OContact::setBusinessCountry( const QString &str ) 186/*! \fn void OContact::setBusinessCountry( const QString &str )
187 Sets the business country of the contact to \a str. 187 Sets the business country of the contact to \a str.
188*/ 188*/
189 189
190/*! \fn void OContact::setBusinessPhone( const QString &str ) 190/*! \fn void OContact::setBusinessPhone( const QString &str )
191 Sets the business phone number of the contact to \a str. 191 Sets the business phone number of the contact to \a str.
192*/ 192*/
193 193
194/*! \fn void OContact::setBusinessFax( const QString &str ) 194/*! \fn void OContact::setBusinessFax( const QString &str )
195 Sets the business fax number of the contact to \a str. 195 Sets the business fax number of the contact to \a str.
196*/ 196*/
197 197
198/*! \fn void OContact::setBusinessMobile( const QString &str ) 198/*! \fn void OContact::setBusinessMobile( const QString &str )
199 Sets the business mobile phone number of the contact to \a str. 199 Sets the business mobile phone number of the contact to \a str.
200*/ 200*/
201 201
202/*! \fn void OContact::setBusinessPager( const QString &str ) 202/*! \fn void OContact::setBusinessPager( const QString &str )
203 Sets the business pager number of the contact to \a str. 203 Sets the business pager number of the contact to \a str.
204*/ 204*/
205 205
206/*! \fn void OContact::setBusinessWebpage( const QString &str ) 206/*! \fn void OContact::setBusinessWebpage( const QString &str )
207 Sets the business webpage of the contact to \a str. 207 Sets the business webpage of the contact to \a str.
208*/ 208*/
209 209
210/*! \fn void OContact::setProfession( const QString &str ) 210/*! \fn void OContact::setProfession( const QString &str )
211 Sets the profession of the contact to \a str. 211 Sets the profession of the contact to \a str.
212*/ 212*/
213 213
214/*! \fn void OContact::setAssistant( const QString &str ) 214/*! \fn void OContact::setAssistant( const QString &str )
215 Sets the assistant of the contact to \a str. 215 Sets the assistant of the contact to \a str.
216*/ 216*/
217 217
218/*! \fn void OContact::setManager( const QString &str ) 218/*! \fn void OContact::setManager( const QString &str )
219 Sets the manager of the contact to \a str. 219 Sets the manager of the contact to \a str.
220*/ 220*/
221 221
222/*! \fn void OContact::setSpouse( const QString &str ) 222/*! \fn void OContact::setSpouse( const QString &str )
223 Sets the spouse of the contact to \a str. 223 Sets the spouse of the contact to \a str.
224*/ 224*/
225 225
226/*! \fn void OContact::setGender( const QString &str ) 226/*! \fn void OContact::setGender( const QString &str )
227 Sets the gender of the contact to \a str. 227 Sets the gender of the contact to \a str.
228*/ 228*/
229 229
230/*! \fn void OContact::setNickname( const QString &str ) 230/*! \fn void OContact::setNickname( const QString &str )
231 Sets the nickname of the contact to \a str. 231 Sets the nickname of the contact to \a str.
232*/ 232*/
233 233
234/*! \fn void OContact::setNotes( const QString &str ) 234/*! \fn void OContact::setNotes( const QString &str )
235 Sets the notes about the contact to \a str. 235 Sets the notes about the contact to \a str.
236*/ 236*/
237 237
238/*! \fn QString OContact::title() const 238/*! \fn QString OContact::title() const
239 Returns the title of the contact. 239 Returns the title of the contact.
240*/ 240*/
241 241
242/*! \fn QString OContact::firstName() const 242/*! \fn QString OContact::firstName() const
243 Returns the first name of the contact. 243 Returns the first name of the contact.
244*/ 244*/
245 245
246/*! \fn QString OContact::middleName() const 246/*! \fn QString OContact::middleName() const
247 Returns the middle name of the contact. 247 Returns the middle name of the contact.
248*/ 248*/
249 249
250/*! \fn QString OContact::lastName() const 250/*! \fn QString OContact::lastName() const
251 Returns the last name of the contact. 251 Returns the last name of the contact.
252*/ 252*/
253 253
254/*! \fn QString OContact::suffix() const 254/*! \fn QString OContact::suffix() const
255 Returns the suffix of the contact. 255 Returns the suffix of the contact.
256*/ 256*/
257 257
258/*! \fn QString OContact::fileAs() const 258/*! \fn QString OContact::fileAs() const
259 Returns the string the contact is filed as. 259 Returns the string the contact is filed as.
260*/ 260*/
261 261
262/*! \fn QString OContact::defaultEmail() const 262/*! \fn QString OContact::defaultEmail() const
263 Returns the default email address of the contact. 263 Returns the default email address of the contact.
264*/ 264*/
265 265
266/*! \fn QString OContact::emails() const 266/*! \fn QString OContact::emails() const
267 Returns the list of email address for a contact separated by ';'s in a single 267 Returns the list of email address for a contact separated by ';'s in a single
268 string. 268 string.
269*/ 269*/
270 270
271/*! \fn QString OContact::homeStreet() const 271/*! \fn QString OContact::homeStreet() const
272 Returns the home street address of the contact. 272 Returns the home street address of the contact.
273*/ 273*/
274 274
275/*! \fn QString OContact::homeCity() const 275/*! \fn QString OContact::homeCity() const
276 Returns the home city of the contact. 276 Returns the home city of the contact.
277*/ 277*/
278 278
279/*! \fn QString OContact::homeState() const 279/*! \fn QString OContact::homeState() const
280 Returns the home state of the contact. 280 Returns the home state of the contact.
281*/ 281*/
282 282
283/*! \fn QString OContact::homeZip() const 283/*! \fn QString OContact::homeZip() const
284 Returns the home zip of the contact. 284 Returns the home zip of the contact.
285*/ 285*/
286 286
287/*! \fn QString OContact::homeCountry() const 287/*! \fn QString OContact::homeCountry() const
288 Returns the home country of the contact. 288 Returns the home country of the contact.
289*/ 289*/
290 290
291/*! \fn QString OContact::homePhone() const 291/*! \fn QString OContact::homePhone() const
292 Returns the home phone number of the contact. 292 Returns the home phone number of the contact.
293*/ 293*/
294 294
295/*! \fn QString OContact::homeFax() const 295/*! \fn QString OContact::homeFax() const
296 Returns the home fax number of the contact. 296 Returns the home fax number of the contact.
297*/ 297*/
298 298
299/*! \fn QString OContact::homeMobile() const 299/*! \fn QString OContact::homeMobile() const
300 Returns the home mobile number of the contact. 300 Returns the home mobile number of the contact.
301*/ 301*/
302 302
303/*! \fn QString OContact::homeWebpage() const 303/*! \fn QString OContact::homeWebpage() const
304 Returns the home webpage of the contact. 304 Returns the home webpage of the contact.
305*/ 305*/
306 306
307/*! \fn QString OContact::company() const 307/*! \fn QString OContact::company() const
308 Returns the company for the contact. 308 Returns the company for the contact.
309*/ 309*/
310 310
311/*! \fn QString OContact::department() const 311/*! \fn QString OContact::department() const
312 Returns the department for the contact. 312 Returns the department for the contact.
313*/ 313*/
314 314
315/*! \fn QString OContact::office() const 315/*! \fn QString OContact::office() const
316 Returns the office for the contact. 316 Returns the office for the contact.
317*/ 317*/
318 318
319/*! \fn QString OContact::jobTitle() const 319/*! \fn QString OContact::jobTitle() const
320 Returns the job title of the contact. 320 Returns the job title of the contact.
321*/ 321*/
322 322
323/*! \fn QString OContact::profession() const 323/*! \fn QString OContact::profession() const
324 Returns the profession of the contact. 324 Returns the profession of the contact.
325*/ 325*/
326 326
327/*! \fn QString OContact::assistant() const 327/*! \fn QString OContact::assistant() const
328 Returns the assistant of the contact. 328 Returns the assistant of the contact.
329*/ 329*/
330 330
331/*! \fn QString OContact::manager() const 331/*! \fn QString OContact::manager() const
332 Returns the manager of the contact. 332 Returns the manager of the contact.
333*/ 333*/
334 334
335/*! \fn QString OContact::businessStreet() const 335/*! \fn QString OContact::businessStreet() const
336 Returns the business street address of the contact. 336 Returns the business street address of the contact.
337*/ 337*/
338 338
339/*! \fn QString OContact::businessCity() const 339/*! \fn QString OContact::businessCity() const
340 Returns the business city of the contact. 340 Returns the business city of the contact.
341*/ 341*/
342 342
343/*! \fn QString OContact::businessState() const 343/*! \fn QString OContact::businessState() const
344 Returns the business state of the contact. 344 Returns the business state of the contact.
345*/ 345*/
346 346
347/*! \fn QString OContact::businessZip() const 347/*! \fn QString OContact::businessZip() const
348 Returns the business zip of the contact. 348 Returns the business zip of the contact.
349*/ 349*/
350 350
351/*! \fn QString OContact::businessCountry() const 351/*! \fn QString OContact::businessCountry() const
352 Returns the business country of the contact. 352 Returns the business country of the contact.
353*/ 353*/
354 354
355/*! \fn QString OContact::businessPhone() const 355/*! \fn QString OContact::businessPhone() const
356 Returns the business phone number of the contact. 356 Returns the business phone number of the contact.
357*/ 357*/
358 358
359/*! \fn QString OContact::businessFax() const 359/*! \fn QString OContact::businessFax() const
360 Returns the business fax number of the contact. 360 Returns the business fax number of the contact.
361*/ 361*/
362 362
363/*! \fn QString OContact::businessMobile() const 363/*! \fn QString OContact::businessMobile() const
364 Returns the business mobile number of the contact. 364 Returns the business mobile number of the contact.
365*/ 365*/
366 366
367/*! \fn QString OContact::businessPager() const 367/*! \fn QString OContact::businessPager() const
368 Returns the business pager number of the contact. 368 Returns the business pager number of the contact.
369*/ 369*/
370 370
371/*! \fn QString OContact::businessWebpage() const 371/*! \fn QString OContact::businessWebpage() const
372 Returns the business webpage of the contact. 372 Returns the business webpage of the contact.
373*/ 373*/
374 374
375/*! \fn QString OContact::spouse() const 375/*! \fn QString OContact::spouse() const
376 Returns the spouse of the contact. 376 Returns the spouse of the contact.
377*/ 377*/
378 378
379/*! \fn QString OContact::gender() const 379/*! \fn QString OContact::gender() const
380 Returns the gender of the contact. 380 Returns the gender of the contact.
381*/ 381*/
382 382
383/*! \fn QString OContact::nickname() const 383/*! \fn QString OContact::nickname() const
384 Returns the nickname of the contact. 384 Returns the nickname of the contact.
385*/ 385*/
386 386
387/*! \fn QString OContact::children() const 387/*! \fn QString OContact::children() const
388 Returns the children of the contact. 388 Returns the children of the contact.
389*/ 389*/
390 390
391/*! \fn QString OContact::notes() const 391/*! \fn QString OContact::notes() const
392 Returns the notes relating to the the contact. 392 Returns the notes relating to the the contact.
393*/ 393*/
394 394
395/*! \fn QString OContact::groups() const 395/*! \fn QString OContact::groups() const
396 \internal 396 \internal
397 Returns the groups for the contact. 397 Returns the groups for the contact.
398*/ 398*/
399 399
400/*! \fn QStringList OContact::groupList() const 400/*! \fn QStringList OContact::groupList() const
401 \internal 401 \internal
402*/ 402*/
403 403
404/*! \fn QString OContact::field(int) const 404/*! \fn QString OContact::field(int) const
405 \internal 405 \internal
406*/ 406*/
407 407
408/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) 408/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null )
409 \internal 409 \internal
410*/ 410*/
411 411
412/*! \fn void OContact::setUid( int id ) 412/*! \fn void OContact::setUid( int id )
413 \internal 413 \internal
414 Sets the uid for this record to \a id. 414 Sets the uid for this record to \a id.
415*/ 415*/
416 416
417/*! \enum OContact::journal_action 417/*! \enum OContact::journal_action
418 \internal 418 \internal
419*/ 419*/
420 420
421/*! 421/*!
422 \internal 422 \internal
423*/ 423*/
424QMap<int, QString> OContact::toMap() const 424QMap<int, QString> OContact::toMap() const
425{ 425{
426 QMap<int, QString> map = mMap; 426 QMap<int, QString> map = mMap;
427 QString cats = idsToString( categories() ); 427 QString cats = idsToString( categories() );
428 if ( !cats.isEmpty() ) 428 if ( !cats.isEmpty() )
429 map.insert( Qtopia::AddressCategory, cats ); 429 map.insert( Qtopia::AddressCategory, cats );
430 return map; 430 return map;
431} 431}
432 432
433/*! 433/*!
434 Returns a rich text formatted QString representing the contents the contact. 434 Returns a rich text formatted QString representing the contents the contact.
435*/ 435*/
436QString OContact::toRichText() const 436QString OContact::toRichText() const
437{ 437{
438 QString text; 438 QString text;
439 QString value, comp, state; 439 QString value, comp, state;
440 QString str;
441 bool marker = false;
440 442
441 // name, jobtitle and company 443 // name, jobtitle and company
442 if ( !(value = fullName()).isEmpty() ) 444 if ( !(value = fullName()).isEmpty() )
443 text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; 445 text += "<b><h3>" + Qtopia::escapeString(value) + "</h3></b><br>";
444 if ( !(value = jobTitle()).isEmpty() ) 446 if ( !(value = jobTitle()).isEmpty() )
445 text += Qtopia::escapeString(value) + "<br>"; 447 text += Qtopia::escapeString(value) + "<br>";
446 448
447 comp = company(); 449 comp = company();
448 if ( !(value = department()).isEmpty() ) { 450 if ( !(value = department()).isEmpty() ) {
449 text += Qtopia::escapeString(value); 451 text += Qtopia::escapeString(value);
450 if ( comp ) 452 if ( comp )
451 text += ", "; 453 text += ", ";
452 else 454 else
453 text += "<br>"; 455 text += "<br>";
454 } 456 }
455 if ( !comp.isEmpty() ) 457 if ( !comp.isEmpty() )
456 text += Qtopia::escapeString(comp) + "<br>"; 458 text += Qtopia::escapeString(comp) + "<br>";
457 459
460 QString defEmail = defaultEmail();
461 if ( !defEmail.isEmpty() )
462 text += "<b>" + QObject::tr("Default Email: ") + "</b>"
463 + Qtopia::escapeString(defEmail) + "<br>";
464
465 text += "<hr>";
466
458 // business address 467 // business address
459 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 468 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
460 !businessZip().isEmpty() || !businessCountry().isEmpty() ) { 469 !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
461 text += "<br>"; 470 text += "<br>";
462 text += QObject::tr( "<b>Work Address:</b>" ); 471 text += QObject::tr( "<b>Work Address:</b>" );
463 text += "<br>"; 472 text += "<br>";
473 marker = true;
464 } 474 }
465 475
466 if ( !(value = businessStreet()).isEmpty() ) 476 if ( !(value = businessStreet()).isEmpty() )
467 text += Qtopia::escapeString(value) + "<br>"; 477 text += Qtopia::escapeString(value) + "<br>";
468 state = businessState(); 478 state = businessState();
469 if ( !(value = businessCity()).isEmpty() ) { 479 if ( !(value = businessCity()).isEmpty() ) {
470 text += Qtopia::escapeString(value); 480 text += Qtopia::escapeString(value);
471 if ( state ) 481 if ( state )
472 text += ", " + Qtopia::escapeString(state); 482 text += ", " + Qtopia::escapeString(state);
473 text += "<br>"; 483 text += "<br>";
474 } else if ( !state.isEmpty() ) 484 } else if ( !state.isEmpty() )
475 text += Qtopia::escapeString(state) + "<br>"; 485 text += Qtopia::escapeString(state) + "<br>";
476 if ( !(value = businessZip()).isEmpty() ) 486 if ( !(value = businessZip()).isEmpty() )
477 text += Qtopia::escapeString(value) + "<br>"; 487 text += Qtopia::escapeString(value) + "<br>";
478 if ( !(value = businessCountry()).isEmpty() ) 488 if ( !(value = businessCountry()).isEmpty() )
479 text += Qtopia::escapeString(value) + "<br>"; 489 text += Qtopia::escapeString(value) + "<br>";
480 490
491 // rest of Business data
492 str = office();
493 if ( !str.isEmpty() ){
494 text += "<b>" + QObject::tr("Office: ") + "</b>"
495 + Qtopia::escapeString(str) + "<br>";
496 marker = true;
497 }
498 str = businessWebpage();
499 if ( !str.isEmpty() ){
500 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>"
501 + Qtopia::escapeString(str) + "<br>";
502 marker = true;
503 }
504 str = businessPhone();
505 if ( !str.isEmpty() ){
506 text += "<b>" + QObject::tr("Business Phone: ") + "</b>"
507 + Qtopia::escapeString(str) + "<br>";
508 marker = true;
509 }
510 str = businessFax();
511 if ( !str.isEmpty() ){
512 text += "<b>" + QObject::tr("Business Fax: ") + "</b>"
513 + Qtopia::escapeString(str) + "<br>";
514 marker = true;
515 }
516 str = businessMobile();
517 if ( !str.isEmpty() ){
518 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>"
519 + Qtopia::escapeString(str) + "<br>";
520 marker = true;
521 }
522 str = businessPager();
523 if ( !str.isEmpty() ){
524 text += "<b>" + QObject::tr("Business Pager: ") + "</b>"
525 + Qtopia::escapeString(str) + "<br>";
526 marker = true;
527 }
528
481 // home address 529 // home address
482 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || 530 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
483 !homeZip().isEmpty() || !homeCountry().isEmpty() ) { 531 !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
484 text += "<br>"; 532 text += "<br>";
485 text += QObject::tr( "<b>Home Address:</b>" ); 533 text += QObject::tr( "<b>Home Address:</b>" );
486 text += "<br>"; 534 text += "<br>";
487 } 535 }
488 536
489 if ( !(value = homeStreet()).isEmpty() ) 537 if ( !(value = homeStreet()).isEmpty() )
490 text += Qtopia::escapeString(value) + "<br>"; 538 text += Qtopia::escapeString(value) + "<br>";
491 state = homeState(); 539 state = homeState();
492 if ( !(value = homeCity()).isEmpty() ) { 540 if ( !(value = homeCity()).isEmpty() ) {
493 text += Qtopia::escapeString(value); 541 text += Qtopia::escapeString(value);
494 if ( !state.isEmpty() ) 542 if ( !state.isEmpty() )
495 text += ", " + Qtopia::escapeString(state); 543 text += ", " + Qtopia::escapeString(state);
496 text += "<br>"; 544 text += "<br>";
497 } else if (!state.isEmpty()) 545 } else if (!state.isEmpty())
498 text += Qtopia::escapeString(state) + "<br>"; 546 text += Qtopia::escapeString(state) + "<br>";
499 if ( !(value = homeZip()).isEmpty() ) 547 if ( !(value = homeZip()).isEmpty() )
500 text += Qtopia::escapeString(value) + "<br>"; 548 text += Qtopia::escapeString(value) + "<br>";
501 if ( !(value = homeCountry()).isEmpty() ) 549 if ( !(value = homeCountry()).isEmpty() )
502 text += Qtopia::escapeString(value) + "<br>"; 550 text += Qtopia::escapeString(value) + "<br>";
503 551
504 // the others... 552 // rest of Home data
505 QString str; 553 str = homeWebpage();
506 QString defEmail = defaultEmail(); 554 if ( !str.isEmpty() ){
507 if ( !defEmail.isEmpty() ) 555 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>"
508 text += "<b>" + QObject::tr("Default Email: ") + "</b>"
509 + Qtopia::escapeString(defEmail) + "<br>";
510 str = emails();
511 if ( !str.isEmpty() && ( str != defEmail ) )
512 text += "<b>" + QObject::tr("All Emails: ") + "</b>"
513 + Qtopia::escapeString(str) + "<br>"; 556 + Qtopia::escapeString(str) + "<br>";
557 marker = true;
558 }
514 str = homePhone(); 559 str = homePhone();
515 if ( !str.isEmpty() ) 560 if ( !str.isEmpty() ){
516 text += "<b>" + QObject::tr("Home Phone: ") + "</b>" 561 text += "<b>" + QObject::tr("Home Phone: ") + "</b>"
517 + Qtopia::escapeString(str) + "<br>"; 562 + Qtopia::escapeString(str) + "<br>";
563 marker = true;
564 }
518 str = homeFax(); 565 str = homeFax();
519 if ( !str.isEmpty() ) 566 if ( !str.isEmpty() ){
520 text += "<b>" + QObject::tr("Home Fax: ") + "</b>" 567 text += "<b>" + QObject::tr("Home Fax: ") + "</b>"
521 + Qtopia::escapeString(str) + "<br>"; 568 + Qtopia::escapeString(str) + "<br>";
569 marker = true;
570 }
522 str = homeMobile(); 571 str = homeMobile();
523 if ( !str.isEmpty() ) 572 if ( !str.isEmpty() ){
524 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" 573 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>"
525 + Qtopia::escapeString(str) + "<br>"; 574 + Qtopia::escapeString(str) + "<br>";
526 str = homeWebpage(); 575 marker = true;
527 if ( !str.isEmpty() ) 576 }
528 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" 577
529 + Qtopia::escapeString(str) + "<br>"; 578 if ( marker )
530 str = businessWebpage(); 579 text += "<br><hr><br>";
531 if ( !str.isEmpty() ) 580 // the others...
532 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" 581 str = emails();
533 + Qtopia::escapeString(str) + "<br>"; 582 if ( !str.isEmpty() && ( str != defEmail ) )
534 str = office(); 583 text += "<b>" + QObject::tr("All Emails: ") + "</b>"
535 if ( !str.isEmpty() )
536 text += "<b>" + QObject::tr("Office: ") + "</b>"
537 + Qtopia::escapeString(str) + "<br>";
538 str = businessPhone();
539 if ( !str.isEmpty() )
540 text += "<b>" + QObject::tr("Business Phone: ") + "</b>"
541 + Qtopia::escapeString(str) + "<br>";
542 str = businessFax();
543 if ( !str.isEmpty() )
544 text += "<b>" + QObject::tr("Business Fax: ") + "</b>"
545 + Qtopia::escapeString(str) + "<br>";
546 str = businessMobile();
547 if ( !str.isEmpty() )
548 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>"
549 + Qtopia::escapeString(str) + "<br>";
550 str = businessPager();
551 if ( !str.isEmpty() )
552 text += "<b>" + QObject::tr("Business Pager: ") + "</b>"
553 + Qtopia::escapeString(str) + "<br>"; 584 + Qtopia::escapeString(str) + "<br>";
554 str = profession(); 585 str = profession();
555 if ( !str.isEmpty() ) 586 if ( !str.isEmpty() )
556 text += "<b>" + QObject::tr("Profession: ") + "</b>" 587 text += "<b>" + QObject::tr("Profession: ") + "</b>"
557 + Qtopia::escapeString(str) + "<br>"; 588 + Qtopia::escapeString(str) + "<br>";
558 str = assistant(); 589 str = assistant();
559 if ( !str.isEmpty() ) 590 if ( !str.isEmpty() )
560 text += "<b>" + QObject::tr("Assistant: ") + "</b>" 591 text += "<b>" + QObject::tr("Assistant: ") + "</b>"
561 + Qtopia::escapeString(str) + "<br>"; 592 + Qtopia::escapeString(str) + "<br>";
562 str = manager(); 593 str = manager();
563 if ( !str.isEmpty() ) 594 if ( !str.isEmpty() )
564 text += "<b>" + QObject::tr("Manager: ") + "</b>" 595 text += "<b>" + QObject::tr("Manager: ") + "</b>"
565 + Qtopia::escapeString(str) + "<br>"; 596 + Qtopia::escapeString(str) + "<br>";
566 str = gender(); 597 str = gender();
567 if ( !str.isEmpty() && str.toInt() != 0 ) { 598 if ( !str.isEmpty() && str.toInt() != 0 ) {
568 if ( str.toInt() == 1 ) 599 if ( str.toInt() == 1 )
569 str = QObject::tr( "Male" ); 600 str = QObject::tr( "Male" );
570 else if ( str.toInt() == 2 ) 601 else if ( str.toInt() == 2 )
571 str = QObject::tr( "Female" ); 602 str = QObject::tr( "Female" );
572 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; 603 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>";
573 } 604 }
574 str = spouse(); 605 str = spouse();
575 if ( !str.isEmpty() ) 606 if ( !str.isEmpty() )
576 text += "<b>" + QObject::tr("Spouse: ") + "</b>" 607 text += "<b>" + QObject::tr("Spouse: ") + "</b>"
577 + Qtopia::escapeString(str) + "<br>"; 608 + Qtopia::escapeString(str) + "<br>";
578 if ( birthday().isValid() ){ 609 if ( birthday().isValid() ){
579 str = TimeString::numberDateString( birthday() ); 610 str = TimeString::numberDateString( birthday() );
580 text += "<b>" + QObject::tr("Birthday: ") + "</b>" 611 text += "<b>" + QObject::tr("Birthday: ") + "</b>"
581 + Qtopia::escapeString(str) + "<br>"; 612 + Qtopia::escapeString(str) + "<br>";
582 } 613 }
583 if ( anniversary().isValid() ){ 614 if ( anniversary().isValid() ){
584 str = TimeString::numberDateString( anniversary() ); 615 str = TimeString::numberDateString( anniversary() );
585 text += "<b>" + QObject::tr("Anniversary: ") + "</b>" 616 text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
586 + Qtopia::escapeString(str) + "<br>"; 617 + Qtopia::escapeString(str) + "<br>";
587 } 618 }
588 str = children(); 619 str = children();
589 if ( !str.isEmpty() ) 620 if ( !str.isEmpty() )
590 text += "<b>" + QObject::tr("Children: ") + "</b>" 621 text += "<b>" + QObject::tr("Children: ") + "</b>"
591 + Qtopia::escapeString(str) + "<br>"; 622 + Qtopia::escapeString(str) + "<br>";
592 623
593 str = nickname(); 624 str = nickname();
594 if ( !str.isEmpty() ) 625 if ( !str.isEmpty() )
595 text += "<b>" + QObject::tr("Nickname: ") + "</b>" 626 text += "<b>" + QObject::tr("Nickname: ") + "</b>"
596 + Qtopia::escapeString(str) + "<br>"; 627 + Qtopia::escapeString(str) + "<br>";
597 628
598 if ( categoryNames().count() ){ 629 if ( categoryNames().count() ){
599 text += "<b>" + QObject::tr( "Category:") + "</b> "; 630 text += "<b>" + QObject::tr( "Category:") + "</b> ";
600 text += categoryNames().join(", "); 631 text += categoryNames().join(", ");
601 text += "<br>"; 632 text += "<br>";
602 } 633 }
603 634
604 // notes last 635 // notes last
605 if ( (value = notes()) ) { 636 if ( (value = notes()) ) {
606 QRegExp reg("\n"); 637 text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> ";
638 QRegExp reg("\n");
607 639
608 //QString tmp = Qtopia::escapeString(value); 640 //QString tmp = Qtopia::escapeString(value);
609 QString tmp = QStyleSheet::convertFromPlainText(value); 641 QString tmp = QStyleSheet::convertFromPlainText(value);
610 //tmp.replace( reg, "<br>" ); 642 //tmp.replace( reg, "<br>" );
611 text += "<br>" + tmp + "<br>"; 643 text += "<br>" + tmp + "<br>";
612 } 644 }
613 return text; 645 return text;
614} 646}
615 647
616/*! 648/*!
617 \internal 649 \internal
618*/ 650*/
619void OContact::insert( int key, const QString &v ) 651void OContact::insert( int key, const QString &v )
620{ 652{
621 QString value = v.stripWhiteSpace(); 653 QString value = v.stripWhiteSpace();
622 if ( value.isEmpty() ) 654 if ( value.isEmpty() )
623 mMap.remove( key ); 655 mMap.remove( key );
624 else 656 else
625 mMap.insert( key, value ); 657 mMap.insert( key, value );
626} 658}
627 659
628/*! 660/*!
629 \internal 661 \internal
630*/ 662*/
631void OContact::replace( int key, const QString & v ) 663void OContact::replace( int key, const QString & v )
632{ 664{
633 QString value = v.stripWhiteSpace(); 665 QString value = v.stripWhiteSpace();
634 if ( value.isEmpty() ) 666 if ( value.isEmpty() )
635 mMap.remove( key ); 667 mMap.remove( key );
636 else 668 else
637 mMap.replace( key, value ); 669 mMap.replace( key, value );
638} 670}
639 671
640/*! 672/*!
641 \internal 673 \internal
642*/ 674*/
643QString OContact::find( int key ) const 675QString OContact::find( int key ) const
644{ 676{
645 return mMap[key]; 677 return mMap[key];
646} 678}
647 679
648/*! 680/*!
649 \internal 681 \internal
650*/ 682*/
651QString OContact::displayAddress( const QString &street, 683QString OContact::displayAddress( const QString &street,
652 const QString &city, 684 const QString &city,
653 const QString &state, 685 const QString &state,
654 const QString &zip, 686 const QString &zip,
655 const QString &country ) const 687 const QString &country ) const
656{ 688{
657 QString s = street; 689 QString s = street;
658 if ( !street.isEmpty() ) 690 if ( !street.isEmpty() )
659 s+= "\n"; 691 s+= "\n";
660 s += city; 692 s += city;
661 if ( !city.isEmpty() && !state.isEmpty() ) 693 if ( !city.isEmpty() && !state.isEmpty() )
662 s += ", "; 694 s += ", ";
663 s += state; 695 s += state;
664 if ( !state.isEmpty() && !zip.isEmpty() ) 696 if ( !state.isEmpty() && !zip.isEmpty() )
665 s += " "; 697 s += " ";
666 s += zip; 698 s += zip;
667 if ( !country.isEmpty() && !s.isEmpty() ) 699 if ( !country.isEmpty() && !s.isEmpty() )
668 s += "\n"; 700 s += "\n";
669 s += country; 701 s += country;
670 return s; 702 return s;
671} 703}
672 704
673/*! 705/*!
674 \internal 706 \internal
675*/ 707*/
676QString OContact::displayBusinessAddress() const 708QString OContact::displayBusinessAddress() const
677{ 709{
678 return displayAddress( businessStreet(), businessCity(), 710 return displayAddress( businessStreet(), businessCity(),
679 businessState(), businessZip(), 711 businessState(), businessZip(),
680 businessCountry() ); 712 businessCountry() );
681} 713}
682 714
683/*! 715/*!
684 \internal 716 \internal
685*/ 717*/
686QString OContact::displayHomeAddress() const 718QString OContact::displayHomeAddress() const
687{ 719{
688 return displayAddress( homeStreet(), homeCity(), 720 return displayAddress( homeStreet(), homeCity(),
689 homeState(), homeZip(), 721 homeState(), homeZip(),
690 homeCountry() ); 722 homeCountry() );
691} 723}
692 724
693/*! 725/*!
694 Returns the full name of the contact 726 Returns the full name of the contact
695*/ 727*/
696QString OContact::fullName() const 728QString OContact::fullName() const
697{ 729{
698 QString title = find( Qtopia::Title ); 730 QString title = find( Qtopia::Title );
699 QString firstName = find( Qtopia::FirstName ); 731 QString firstName = find( Qtopia::FirstName );
700 QString middleName = find( Qtopia::MiddleName ); 732 QString middleName = find( Qtopia::MiddleName );
701 QString lastName = find( Qtopia::LastName ); 733 QString lastName = find( Qtopia::LastName );
702 QString suffix = find( Qtopia::Suffix ); 734 QString suffix = find( Qtopia::Suffix );
703 735
704 QString name = title; 736 QString name = title;
705 if ( !firstName.isEmpty() ) { 737 if ( !firstName.isEmpty() ) {
706 if ( !name.isEmpty() ) 738 if ( !name.isEmpty() )
707 name += " "; 739 name += " ";
708 name += firstName; 740 name += firstName;
709 } 741 }
710 if ( !middleName.isEmpty() ) { 742 if ( !middleName.isEmpty() ) {
711 if ( !name.isEmpty() ) 743 if ( !name.isEmpty() )
712 name += " "; 744 name += " ";
713 name += middleName; 745 name += middleName;
714 } 746 }
715 if ( !lastName.isEmpty() ) { 747 if ( !lastName.isEmpty() ) {
716 if ( !name.isEmpty() ) 748 if ( !name.isEmpty() )
717 name += " "; 749 name += " ";
718 name += lastName; 750 name += lastName;
719 } 751 }
720 if ( !suffix.isEmpty() ) { 752 if ( !suffix.isEmpty() ) {
721 if ( !name.isEmpty() ) 753 if ( !name.isEmpty() )
722 name += " "; 754 name += " ";
723 name += suffix; 755 name += suffix;
724 } 756 }
725 return name.simplifyWhiteSpace(); 757 return name.simplifyWhiteSpace();
726} 758}
727 759
728/*! 760/*!
729 Returns a list of the names of the children of the contact. 761 Returns a list of the names of the children of the contact.
730*/ 762*/
731QStringList OContact::childrenList() const 763QStringList OContact::childrenList() const
732{ 764{
733 return QStringList::split( " ", find( Qtopia::Children ) ); 765 return QStringList::split( " ", find( Qtopia::Children ) );
734} 766}
735 767
736/*! \fn void OContact::insertEmail( const QString &email ) 768/*! \fn void OContact::insertEmail( const QString &email )
737 769
738 Insert \a email into the email list. Ensures \a email can only be added 770 Insert \a email into the email list. Ensures \a email can only be added
739 once. If there is no default email address set, it sets it to the \a email. 771 once. If there is no default email address set, it sets it to the \a email.
740*/ 772*/
741 773
742/*! \fn void OContact::removeEmail( const QString &email ) 774/*! \fn void OContact::removeEmail( const QString &email )
743 775
744 Removes the \a email from the email list. If the default email was \a email, 776 Removes the \a email from the email list. If the default email was \a email,
745 then the default email address is assigned to the first email in the 777 then the default email address is assigned to the first email in the
746 email list 778 email list
747*/ 779*/
748 780
749/*! \fn void OContact::clearEmails() 781/*! \fn void OContact::clearEmails()
750 782
751 Clears the email list. 783 Clears the email list.
752 */ 784 */
753 785
754/*! \fn void OContact::insertEmails( const QStringList &emailList ) 786/*! \fn void OContact::insertEmails( const QStringList &emailList )
755 787
756 Appends the \a emailList to the exiting email list 788 Appends the \a emailList to the exiting email list
757 */ 789 */
758 790
759/*! 791/*!
760 Returns a list of email addresses belonging to the contact, including 792 Returns a list of email addresses belonging to the contact, including
761 the default email address. 793 the default email address.
762*/ 794*/
763QStringList OContact::emailList() const 795QStringList OContact::emailList() const
764{ 796{
765 QString emailStr = emails(); 797 QString emailStr = emails();
766 798
767 QStringList r; 799 QStringList r;
768 if ( !emailStr.isEmpty() ) { 800 if ( !emailStr.isEmpty() ) {
769 qDebug(" emailstr "); 801 qDebug(" emailstr ");
770 QStringList l = QStringList::split( emailSeparator(), emailStr ); 802 QStringList l = QStringList::split( emailSeparator(), emailStr );
771 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) 803 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
772 r += (*it).simplifyWhiteSpace(); 804 r += (*it).simplifyWhiteSpace();
773 } 805 }
774 806
775 return r; 807 return r;
776} 808}
777 809
778/*! 810/*!
779 \overload 811 \overload
780 812
781 Generates the string for the contact to be filed as from the first, 813 Generates the string for the contact to be filed as from the first,
782 middle and last name of the contact. 814 middle and last name of the contact.
783*/ 815*/
784void OContact::setFileAs() 816void OContact::setFileAs()
785{ 817{
786 QString lastName, firstName, middleName, fileas; 818 QString lastName, firstName, middleName, fileas;
787 819
788 lastName = find( Qtopia::LastName ); 820 lastName = find( Qtopia::LastName );
789 firstName = find( Qtopia::FirstName ); 821 firstName = find( Qtopia::FirstName );
790 middleName = find( Qtopia::MiddleName ); 822 middleName = find( Qtopia::MiddleName );
791 if ( !lastName.isEmpty() && !firstName.isEmpty() 823 if ( !lastName.isEmpty() && !firstName.isEmpty()
792 && !middleName.isEmpty() ) 824 && !middleName.isEmpty() )
793 fileas = lastName + ", " + firstName + " " + middleName; 825 fileas = lastName + ", " + firstName + " " + middleName;
794 else if ( !lastName.isEmpty() && !firstName.isEmpty() ) 826 else if ( !lastName.isEmpty() && !firstName.isEmpty() )
795 fileas = lastName + ", " + firstName; 827 fileas = lastName + ", " + firstName;
796 else if ( !lastName.isEmpty() || !firstName.isEmpty() || 828 else if ( !lastName.isEmpty() || !firstName.isEmpty() ||
797 !middleName.isEmpty() ) 829 !middleName.isEmpty() )
798 fileas = firstName + ( firstName.isEmpty() ? "" : " " ) 830 fileas = firstName + ( firstName.isEmpty() ? "" : " " )
799 + middleName + ( middleName.isEmpty() ? "" : " " ) 831 + middleName + ( middleName.isEmpty() ? "" : " " )
800 + lastName; 832 + lastName;
801 833
802 replace( Qtopia::FileAs, fileas ); 834 replace( Qtopia::FileAs, fileas );
803} 835}
804 836
805/*! 837/*!
806 \internal 838 \internal
807 Appends the contact information to \a buf. 839 Appends the contact information to \a buf.
808*/ 840*/
809void OContact::save( QString &buf ) const 841void OContact::save( QString &buf ) const
810{ 842{
811 static const QStringList SLFIELDS = fields(); 843 static const QStringList SLFIELDS = fields();
812 // I'm expecting "<Contact " in front of this... 844 // I'm expecting "<Contact " in front of this...
813 for ( QMap<int, QString>::ConstIterator it = mMap.begin(); 845 for ( QMap<int, QString>::ConstIterator it = mMap.begin();
814 it != mMap.end(); ++it ) { 846 it != mMap.end(); ++it ) {
815 const QString &value = it.data(); 847 const QString &value = it.data();
816 int key = it.key(); 848 int key = it.key();
817 if ( !value.isEmpty() ) { 849 if ( !value.isEmpty() ) {
818 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) 850 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)
819 continue; 851 continue;
820 852
821 key -= Qtopia::AddressCategory+1; 853 key -= Qtopia::AddressCategory+1;
822 buf += SLFIELDS[key]; 854 buf += SLFIELDS[key];
823 buf += "=\"" + Qtopia::escapeString(value) + "\" "; 855 buf += "=\"" + Qtopia::escapeString(value) + "\" ";
824 } 856 }
825 } 857 }
826 buf += customToXml(); 858 buf += customToXml();
827 if ( categories().count() > 0 ) 859 if ( categories().count() > 0 )
828 buf += "Categories=\"" + idsToString( categories() ) + "\" "; 860 buf += "Categories=\"" + idsToString( categories() ) + "\" ";
829 buf += "Uid=\"" + QString::number( uid() ) + "\" "; 861 buf += "Uid=\"" + QString::number( uid() ) + "\" ";
830 // You need to close this yourself 862 // You need to close this yourself
831} 863}
832 864
833 865
834/*! 866/*!
835 \internal 867 \internal
836 Returns the list of fields belonging to a contact 868 Returns the list of fields belonging to a contact
837 Never change order of this list ! It has to be regarding 869 Never change order of this list ! It has to be regarding
838 enum AddressBookFields !! 870 enum AddressBookFields !!
839*/ 871*/
840QStringList OContact::fields() 872QStringList OContact::fields()
841{ 873{
842 QStringList list; 874 QStringList list;
843 875
844 list.append( "Title" ); // Not Used! 876 list.append( "Title" ); // Not Used!
845 list.append( "FirstName" ); 877 list.append( "FirstName" );
846 list.append( "MiddleName" ); 878 list.append( "MiddleName" );
847 list.append( "LastName" ); 879 list.append( "LastName" );
848 list.append( "Suffix" ); 880 list.append( "Suffix" );
849 list.append( "FileAs" ); 881 list.append( "FileAs" );
850 882
851 list.append( "JobTitle" ); 883 list.append( "JobTitle" );
852 list.append( "Department" ); 884 list.append( "Department" );
853 list.append( "Company" ); 885 list.append( "Company" );
854 list.append( "BusinessPhone" ); 886 list.append( "BusinessPhone" );
855 list.append( "BusinessFax" ); 887 list.append( "BusinessFax" );
856 list.append( "BusinessMobile" ); 888 list.append( "BusinessMobile" );
857 889
858 list.append( "DefaultEmail" ); 890 list.append( "DefaultEmail" );
859 list.append( "Emails" ); 891 list.append( "Emails" );
860 892
861 list.append( "HomePhone" ); 893 list.append( "HomePhone" );
862 list.append( "HomeFax" ); 894 list.append( "HomeFax" );
863 list.append( "HomeMobile" ); 895 list.append( "HomeMobile" );
864 896
865 list.append( "BusinessStreet" ); 897 list.append( "BusinessStreet" );
866 list.append( "BusinessCity" ); 898 list.append( "BusinessCity" );
867 list.append( "BusinessState" ); 899 list.append( "BusinessState" );
868 list.append( "BusinessZip" ); 900 list.append( "BusinessZip" );
869 list.append( "BusinessCountry" ); 901 list.append( "BusinessCountry" );
870 list.append( "BusinessPager" ); 902 list.append( "BusinessPager" );
871 list.append( "BusinessWebPage" ); 903 list.append( "BusinessWebPage" );
872 904
873 list.append( "Office" ); 905 list.append( "Office" );
874 list.append( "Profession" ); 906 list.append( "Profession" );
875 list.append( "Assistant" ); 907 list.append( "Assistant" );
876 list.append( "Manager" ); 908 list.append( "Manager" );
877 909
878 list.append( "HomeStreet" ); 910 list.append( "HomeStreet" );
879 list.append( "HomeCity" ); 911 list.append( "HomeCity" );
880 list.append( "HomeState" ); 912 list.append( "HomeState" );
881 list.append( "HomeZip" ); 913 list.append( "HomeZip" );
882 list.append( "HomeCountry" ); 914 list.append( "HomeCountry" );
883 list.append( "HomeWebPage" ); 915 list.append( "HomeWebPage" );
884 916
885 list.append( "Spouse" ); 917 list.append( "Spouse" );
886 list.append( "Gender" ); 918 list.append( "Gender" );
887 list.append( "Birthday" ); 919 list.append( "Birthday" );
888 list.append( "Anniversary" ); 920 list.append( "Anniversary" );
889 list.append( "Nickname" ); 921 list.append( "Nickname" );
890 list.append( "Children" ); 922 list.append( "Children" );
891 923
892 list.append( "Notes" ); 924 list.append( "Notes" );
893 list.append( "Groups" ); 925 list.append( "Groups" );
894 926
895 return list; 927 return list;
896} 928}
897 929
898 930
899/*! 931/*!
900 Sets the list of email address for contact to those contained in \a str. 932 Sets the list of email address for contact to those contained in \a str.
901 Email address should be separated by ';'s. 933 Email address should be separated by ';'s.
902*/ 934*/
903void OContact::setEmails( const QString &str ) 935void OContact::setEmails( const QString &str )
904{ 936{
905 replace( Qtopia::Emails, str ); 937 replace( Qtopia::Emails, str );
906 if ( str.isEmpty() ) 938 if ( str.isEmpty() )
907 setDefaultEmail( QString::null ); 939 setDefaultEmail( QString::null );
908} 940}
909 941
910/*! 942/*!
911 Sets the list of children for the contact to those contained in \a str. 943 Sets the list of children for the contact to those contained in \a str.
912*/ 944*/
913void OContact::setChildren( const QString &str ) 945void OContact::setChildren( const QString &str )
914{ 946{
915 replace( Qtopia::Children, str ); 947 replace( Qtopia::Children, str );
916} 948}
917 949
918/*! 950/*!
919 Returns TRUE if the contact matches the regular expression \a regexp. 951 Returns TRUE if the contact matches the regular expression \a regexp.
920 Otherwise returns FALSE. 952 Otherwise returns FALSE.
921*/ 953*/
922bool OContact::match( const QString &regexp ) const 954bool OContact::match( const QString &regexp ) const
923{ 955{
924 return match(QRegExp(regexp)); 956 return match(QRegExp(regexp));
925} 957}
926 958
927/*! 959/*!
928 \overload 960 \overload
929 Returns TRUE if the contact matches the regular expression \a regexp. 961 Returns TRUE if the contact matches the regular expression \a regexp.
930 Otherwise returns FALSE. 962 Otherwise returns FALSE.
931*/ 963*/
932bool OContact::match( const QRegExp &r ) const 964bool OContact::match( const QRegExp &r ) const
933{ 965{
934 bool match; 966 bool match;
935 match = false; 967 match = false;
936 QMap<int, QString>::ConstIterator it; 968 QMap<int, QString>::ConstIterator it;
937 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 969 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
938 if ( (*it).find( r ) > -1 ) { 970 if ( (*it).find( r ) > -1 ) {
939 match = true; 971 match = true;
940 break; 972 break;
941 } 973 }
942 } 974 }
943 return match; 975 return match;
944} 976}
945 977
946 978
947QString OContact::toShortText() const 979QString OContact::toShortText() const
948{ 980{
949 return ( fullName() ); 981 return ( fullName() );
950} 982}
951QString OContact::type() const 983QString OContact::type() const
952{ 984{
953 return QString::fromLatin1( "OContact" ); 985 return QString::fromLatin1( "OContact" );
954} 986}
955 987
956// Definition is missing ! (se) 988// Definition is missing ! (se)
957QMap<QString,QString> OContact::toExtraMap() const 989QMap<QString,QString> OContact::toExtraMap() const
958{ 990{
959 qWarning ("Function not implemented: OContact::toExtraMap()"); 991 qWarning ("Function not implemented: OContact::toExtraMap()");
960 QMap <QString,QString> useless; 992 QMap <QString,QString> useless;
961 return useless; 993 return useless;
962} 994}
963 995
964class QString OContact::recordField( int pos ) const 996class QString OContact::recordField( int pos ) const
965{ 997{
966 QStringList SLFIELDS = fields(); // ?? why this ? (se) 998 QStringList SLFIELDS = fields(); // ?? why this ? (se)
967 return SLFIELDS[pos]; 999 return SLFIELDS[pos];
968} 1000}
969 1001
970// In future releases, we should store birthday and anniversary 1002// In future releases, we should store birthday and anniversary
971// internally as QDate instead of QString ! 1003// internally as QDate instead of QString !
972// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) 1004// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
973 1005
974/*! \fn void OContact::setBirthday( const QDate& date ) 1006/*! \fn void OContact::setBirthday( const QDate& date )
975 Sets the birthday for the contact to \a date. If date is null 1007 Sets the birthday for the contact to \a date. If date is null
976 the current stored date will be removed. 1008 the current stored date will be removed.
977*/ 1009*/
978void OContact::setBirthday( const QDate &v ) 1010void OContact::setBirthday( const QDate &v )
979{ 1011{
980 if ( v.isNull() ){ 1012 if ( v.isNull() ){
981 qWarning( "Remove Birthday"); 1013 qWarning( "Remove Birthday");
982 replace( Qtopia::Birthday, QString::null ); 1014 replace( Qtopia::Birthday, QString::null );
983 return; 1015 return;
984 } 1016 }
985 1017
986 if ( v.isValid() ) 1018 if ( v.isValid() )
987 replace( Qtopia::Birthday, TimeConversion::toString( v ) ); 1019 replace( Qtopia::Birthday, TimeConversion::toString( v ) );
988 1020
989} 1021}
990 1022
991 1023
992/*! \fn void OContact::setAnniversary( const QDate &date ) 1024/*! \fn void OContact::setAnniversary( const QDate &date )
993 Sets the anniversary of the contact to \a date. If date is 1025 Sets the anniversary of the contact to \a date. If date is
994 null, the current stored date will be removed. 1026 null, the current stored date will be removed.
995*/ 1027*/
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index c9084ad..9230b8b 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -56,940 +56,972 @@ OContact::OContact()
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 70
71 QString uidStr = find( Qtopia::AddressUid ); 71 QString uidStr = find( Qtopia::AddressUid );
72 72
73 if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ 73 if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){
74 qWarning( "Invalid UID found. Generate new one.." ); 74 qWarning( "Invalid UID found. Generate new one.." );
75 setUid( uidGen().generate() ); 75 setUid( uidGen().generate() );
76 }else 76 }else
77 setUid( uidStr.toInt() ); 77 setUid( uidStr.toInt() );
78 78
79// if ( !uidStr.isEmpty() ) 79// if ( !uidStr.isEmpty() )
80 // setUid( uidStr.toInt() ); 80 // setUid( uidStr.toInt() );
81} 81}
82 82
83/*! 83/*!
84 Destroys a contact. 84 Destroys a contact.
85*/ 85*/
86OContact::~OContact() 86OContact::~OContact()
87{ 87{
88} 88}
89 89
90/*! \fn void OContact::setTitle( const QString &str ) 90/*! \fn void OContact::setTitle( const QString &str )
91 Sets the title of the contact to \a str. 91 Sets the title of the contact to \a str.
92*/ 92*/
93 93
94/*! \fn void OContact::setFirstName( const QString &str ) 94/*! \fn void OContact::setFirstName( const QString &str )
95 Sets the first name of the contact to \a str. 95 Sets the first name of the contact to \a str.
96*/ 96*/
97 97
98/*! \fn void OContact::setMiddleName( const QString &str ) 98/*! \fn void OContact::setMiddleName( const QString &str )
99 Sets the middle name of the contact to \a str. 99 Sets the middle name of the contact to \a str.
100*/ 100*/
101 101
102/*! \fn void OContact::setLastName( const QString &str ) 102/*! \fn void OContact::setLastName( const QString &str )
103 Sets the last name of the contact to \a str. 103 Sets the last name of the contact to \a str.
104*/ 104*/
105 105
106/*! \fn void OContact::setSuffix( const QString &str ) 106/*! \fn void OContact::setSuffix( const QString &str )
107 Sets the suffix of the contact to \a str. 107 Sets the suffix of the contact to \a str.
108*/ 108*/
109 109
110/*! \fn void OContact::setFileAs( const QString &str ) 110/*! \fn void OContact::setFileAs( const QString &str )
111 Sets the contact to filed as \a str. 111 Sets the contact to filed as \a str.
112*/ 112*/
113 113
114/*! \fn void OContact::setDefaultEmail( const QString &str ) 114/*! \fn void OContact::setDefaultEmail( const QString &str )
115 Sets the default email of the contact to \a str. 115 Sets the default email of the contact to \a str.
116*/ 116*/
117 117
118/*! \fn void OContact::setHomeStreet( const QString &str ) 118/*! \fn void OContact::setHomeStreet( const QString &str )
119 Sets the home street address of the contact to \a str. 119 Sets the home street address of the contact to \a str.
120*/ 120*/
121 121
122/*! \fn void OContact::setHomeCity( const QString &str ) 122/*! \fn void OContact::setHomeCity( const QString &str )
123 Sets the home city of the contact to \a str. 123 Sets the home city of the contact to \a str.
124*/ 124*/
125 125
126/*! \fn void OContact::setHomeState( const QString &str ) 126/*! \fn void OContact::setHomeState( const QString &str )
127 Sets the home state of the contact to \a str. 127 Sets the home state of the contact to \a str.
128*/ 128*/
129 129
130/*! \fn void OContact::setHomeZip( const QString &str ) 130/*! \fn void OContact::setHomeZip( const QString &str )
131 Sets the home zip code of the contact to \a str. 131 Sets the home zip code of the contact to \a str.
132*/ 132*/
133 133
134/*! \fn void OContact::setHomeCountry( const QString &str ) 134/*! \fn void OContact::setHomeCountry( const QString &str )
135 Sets the home country of the contact to \a str. 135 Sets the home country of the contact to \a str.
136*/ 136*/
137 137
138/*! \fn void OContact::setHomePhone( const QString &str ) 138/*! \fn void OContact::setHomePhone( const QString &str )
139 Sets the home phone number of the contact to \a str. 139 Sets the home phone number of the contact to \a str.
140*/ 140*/
141 141
142/*! \fn void OContact::setHomeFax( const QString &str ) 142/*! \fn void OContact::setHomeFax( const QString &str )
143 Sets the home fax number of the contact to \a str. 143 Sets the home fax number of the contact to \a str.
144*/ 144*/
145 145
146/*! \fn void OContact::setHomeMobile( const QString &str ) 146/*! \fn void OContact::setHomeMobile( const QString &str )
147 Sets the home mobile phone number of the contact to \a str. 147 Sets the home mobile phone number of the contact to \a str.
148*/ 148*/
149 149
150/*! \fn void OContact::setHomeWebpage( const QString &str ) 150/*! \fn void OContact::setHomeWebpage( const QString &str )
151 Sets the home webpage of the contact to \a str. 151 Sets the home webpage of the contact to \a str.
152*/ 152*/
153 153
154/*! \fn void OContact::setCompany( const QString &str ) 154/*! \fn void OContact::setCompany( const QString &str )
155 Sets the company for contact to \a str. 155 Sets the company for contact to \a str.
156*/ 156*/
157 157
158/*! \fn void OContact::setJobTitle( const QString &str ) 158/*! \fn void OContact::setJobTitle( const QString &str )
159 Sets the job title of the contact to \a str. 159 Sets the job title of the contact to \a str.
160*/ 160*/
161 161
162/*! \fn void OContact::setDepartment( const QString &str ) 162/*! \fn void OContact::setDepartment( const QString &str )
163 Sets the department for contact to \a str. 163 Sets the department for contact to \a str.
164*/ 164*/
165 165
166/*! \fn void OContact::setOffice( const QString &str ) 166/*! \fn void OContact::setOffice( const QString &str )
167 Sets the office for contact to \a str. 167 Sets the office for contact to \a str.
168*/ 168*/
169 169
170/*! \fn void OContact::setBusinessStreet( const QString &str ) 170/*! \fn void OContact::setBusinessStreet( const QString &str )
171 Sets the business street address of the contact to \a str. 171 Sets the business street address of the contact to \a str.
172*/ 172*/
173 173
174/*! \fn void OContact::setBusinessCity( const QString &str ) 174/*! \fn void OContact::setBusinessCity( const QString &str )
175 Sets the business city of the contact to \a str. 175 Sets the business city of the contact to \a str.
176*/ 176*/
177 177
178/*! \fn void OContact::setBusinessState( const QString &str ) 178/*! \fn void OContact::setBusinessState( const QString &str )
179 Sets the business state of the contact to \a str. 179 Sets the business state of the contact to \a str.
180*/ 180*/
181 181
182/*! \fn void OContact::setBusinessZip( const QString &str ) 182/*! \fn void OContact::setBusinessZip( const QString &str )
183 Sets the business zip code of the contact to \a str. 183 Sets the business zip code of the contact to \a str.
184*/ 184*/
185 185
186/*! \fn void OContact::setBusinessCountry( const QString &str ) 186/*! \fn void OContact::setBusinessCountry( const QString &str )
187 Sets the business country of the contact to \a str. 187 Sets the business country of the contact to \a str.
188*/ 188*/
189 189
190/*! \fn void OContact::setBusinessPhone( const QString &str ) 190/*! \fn void OContact::setBusinessPhone( const QString &str )
191 Sets the business phone number of the contact to \a str. 191 Sets the business phone number of the contact to \a str.
192*/ 192*/
193 193
194/*! \fn void OContact::setBusinessFax( const QString &str ) 194/*! \fn void OContact::setBusinessFax( const QString &str )
195 Sets the business fax number of the contact to \a str. 195 Sets the business fax number of the contact to \a str.
196*/ 196*/
197 197
198/*! \fn void OContact::setBusinessMobile( const QString &str ) 198/*! \fn void OContact::setBusinessMobile( const QString &str )
199 Sets the business mobile phone number of the contact to \a str. 199 Sets the business mobile phone number of the contact to \a str.
200*/ 200*/
201 201
202/*! \fn void OContact::setBusinessPager( const QString &str ) 202/*! \fn void OContact::setBusinessPager( const QString &str )
203 Sets the business pager number of the contact to \a str. 203 Sets the business pager number of the contact to \a str.
204*/ 204*/
205 205
206/*! \fn void OContact::setBusinessWebpage( const QString &str ) 206/*! \fn void OContact::setBusinessWebpage( const QString &str )
207 Sets the business webpage of the contact to \a str. 207 Sets the business webpage of the contact to \a str.
208*/ 208*/
209 209
210/*! \fn void OContact::setProfession( const QString &str ) 210/*! \fn void OContact::setProfession( const QString &str )
211 Sets the profession of the contact to \a str. 211 Sets the profession of the contact to \a str.
212*/ 212*/
213 213
214/*! \fn void OContact::setAssistant( const QString &str ) 214/*! \fn void OContact::setAssistant( const QString &str )
215 Sets the assistant of the contact to \a str. 215 Sets the assistant of the contact to \a str.
216*/ 216*/
217 217
218/*! \fn void OContact::setManager( const QString &str ) 218/*! \fn void OContact::setManager( const QString &str )
219 Sets the manager of the contact to \a str. 219 Sets the manager of the contact to \a str.
220*/ 220*/
221 221
222/*! \fn void OContact::setSpouse( const QString &str ) 222/*! \fn void OContact::setSpouse( const QString &str )
223 Sets the spouse of the contact to \a str. 223 Sets the spouse of the contact to \a str.
224*/ 224*/
225 225
226/*! \fn void OContact::setGender( const QString &str ) 226/*! \fn void OContact::setGender( const QString &str )
227 Sets the gender of the contact to \a str. 227 Sets the gender of the contact to \a str.
228*/ 228*/
229 229
230/*! \fn void OContact::setNickname( const QString &str ) 230/*! \fn void OContact::setNickname( const QString &str )
231 Sets the nickname of the contact to \a str. 231 Sets the nickname of the contact to \a str.
232*/ 232*/
233 233
234/*! \fn void OContact::setNotes( const QString &str ) 234/*! \fn void OContact::setNotes( const QString &str )
235 Sets the notes about the contact to \a str. 235 Sets the notes about the contact to \a str.
236*/ 236*/
237 237
238/*! \fn QString OContact::title() const 238/*! \fn QString OContact::title() const
239 Returns the title of the contact. 239 Returns the title of the contact.
240*/ 240*/
241 241
242/*! \fn QString OContact::firstName() const 242/*! \fn QString OContact::firstName() const
243 Returns the first name of the contact. 243 Returns the first name of the contact.
244*/ 244*/
245 245
246/*! \fn QString OContact::middleName() const 246/*! \fn QString OContact::middleName() const
247 Returns the middle name of the contact. 247 Returns the middle name of the contact.
248*/ 248*/
249 249
250/*! \fn QString OContact::lastName() const 250/*! \fn QString OContact::lastName() const
251 Returns the last name of the contact. 251 Returns the last name of the contact.
252*/ 252*/
253 253
254/*! \fn QString OContact::suffix() const 254/*! \fn QString OContact::suffix() const
255 Returns the suffix of the contact. 255 Returns the suffix of the contact.
256*/ 256*/
257 257
258/*! \fn QString OContact::fileAs() const 258/*! \fn QString OContact::fileAs() const
259 Returns the string the contact is filed as. 259 Returns the string the contact is filed as.
260*/ 260*/
261 261
262/*! \fn QString OContact::defaultEmail() const 262/*! \fn QString OContact::defaultEmail() const
263 Returns the default email address of the contact. 263 Returns the default email address of the contact.
264*/ 264*/
265 265
266/*! \fn QString OContact::emails() const 266/*! \fn QString OContact::emails() const
267 Returns the list of email address for a contact separated by ';'s in a single 267 Returns the list of email address for a contact separated by ';'s in a single
268 string. 268 string.
269*/ 269*/
270 270
271/*! \fn QString OContact::homeStreet() const 271/*! \fn QString OContact::homeStreet() const
272 Returns the home street address of the contact. 272 Returns the home street address of the contact.
273*/ 273*/
274 274
275/*! \fn QString OContact::homeCity() const 275/*! \fn QString OContact::homeCity() const
276 Returns the home city of the contact. 276 Returns the home city of the contact.
277*/ 277*/
278 278
279/*! \fn QString OContact::homeState() const 279/*! \fn QString OContact::homeState() const
280 Returns the home state of the contact. 280 Returns the home state of the contact.
281*/ 281*/
282 282
283/*! \fn QString OContact::homeZip() const 283/*! \fn QString OContact::homeZip() const
284 Returns the home zip of the contact. 284 Returns the home zip of the contact.
285*/ 285*/
286 286
287/*! \fn QString OContact::homeCountry() const 287/*! \fn QString OContact::homeCountry() const
288 Returns the home country of the contact. 288 Returns the home country of the contact.
289*/ 289*/
290 290
291/*! \fn QString OContact::homePhone() const 291/*! \fn QString OContact::homePhone() const
292 Returns the home phone number of the contact. 292 Returns the home phone number of the contact.
293*/ 293*/
294 294
295/*! \fn QString OContact::homeFax() const 295/*! \fn QString OContact::homeFax() const
296 Returns the home fax number of the contact. 296 Returns the home fax number of the contact.
297*/ 297*/
298 298
299/*! \fn QString OContact::homeMobile() const 299/*! \fn QString OContact::homeMobile() const
300 Returns the home mobile number of the contact. 300 Returns the home mobile number of the contact.
301*/ 301*/
302 302
303/*! \fn QString OContact::homeWebpage() const 303/*! \fn QString OContact::homeWebpage() const
304 Returns the home webpage of the contact. 304 Returns the home webpage of the contact.
305*/ 305*/
306 306
307/*! \fn QString OContact::company() const 307/*! \fn QString OContact::company() const
308 Returns the company for the contact. 308 Returns the company for the contact.
309*/ 309*/
310 310
311/*! \fn QString OContact::department() const 311/*! \fn QString OContact::department() const
312 Returns the department for the contact. 312 Returns the department for the contact.
313*/ 313*/
314 314
315/*! \fn QString OContact::office() const 315/*! \fn QString OContact::office() const
316 Returns the office for the contact. 316 Returns the office for the contact.
317*/ 317*/
318 318
319/*! \fn QString OContact::jobTitle() const 319/*! \fn QString OContact::jobTitle() const
320 Returns the job title of the contact. 320 Returns the job title of the contact.
321*/ 321*/
322 322
323/*! \fn QString OContact::profession() const 323/*! \fn QString OContact::profession() const
324 Returns the profession of the contact. 324 Returns the profession of the contact.
325*/ 325*/
326 326
327/*! \fn QString OContact::assistant() const 327/*! \fn QString OContact::assistant() const
328 Returns the assistant of the contact. 328 Returns the assistant of the contact.
329*/ 329*/
330 330
331/*! \fn QString OContact::manager() const 331/*! \fn QString OContact::manager() const
332 Returns the manager of the contact. 332 Returns the manager of the contact.
333*/ 333*/
334 334
335/*! \fn QString OContact::businessStreet() const 335/*! \fn QString OContact::businessStreet() const
336 Returns the business street address of the contact. 336 Returns the business street address of the contact.
337*/ 337*/
338 338
339/*! \fn QString OContact::businessCity() const 339/*! \fn QString OContact::businessCity() const
340 Returns the business city of the contact. 340 Returns the business city of the contact.
341*/ 341*/
342 342
343/*! \fn QString OContact::businessState() const 343/*! \fn QString OContact::businessState() const
344 Returns the business state of the contact. 344 Returns the business state of the contact.
345*/ 345*/
346 346
347/*! \fn QString OContact::businessZip() const 347/*! \fn QString OContact::businessZip() const
348 Returns the business zip of the contact. 348 Returns the business zip of the contact.
349*/ 349*/
350 350
351/*! \fn QString OContact::businessCountry() const 351/*! \fn QString OContact::businessCountry() const
352 Returns the business country of the contact. 352 Returns the business country of the contact.
353*/ 353*/
354 354
355/*! \fn QString OContact::businessPhone() const 355/*! \fn QString OContact::businessPhone() const
356 Returns the business phone number of the contact. 356 Returns the business phone number of the contact.
357*/ 357*/
358 358
359/*! \fn QString OContact::businessFax() const 359/*! \fn QString OContact::businessFax() const
360 Returns the business fax number of the contact. 360 Returns the business fax number of the contact.
361*/ 361*/
362 362
363/*! \fn QString OContact::businessMobile() const 363/*! \fn QString OContact::businessMobile() const
364 Returns the business mobile number of the contact. 364 Returns the business mobile number of the contact.
365*/ 365*/
366 366
367/*! \fn QString OContact::businessPager() const 367/*! \fn QString OContact::businessPager() const
368 Returns the business pager number of the contact. 368 Returns the business pager number of the contact.
369*/ 369*/
370 370
371/*! \fn QString OContact::businessWebpage() const 371/*! \fn QString OContact::businessWebpage() const
372 Returns the business webpage of the contact. 372 Returns the business webpage of the contact.
373*/ 373*/
374 374
375/*! \fn QString OContact::spouse() const 375/*! \fn QString OContact::spouse() const
376 Returns the spouse of the contact. 376 Returns the spouse of the contact.
377*/ 377*/
378 378
379/*! \fn QString OContact::gender() const 379/*! \fn QString OContact::gender() const
380 Returns the gender of the contact. 380 Returns the gender of the contact.
381*/ 381*/
382 382
383/*! \fn QString OContact::nickname() const 383/*! \fn QString OContact::nickname() const
384 Returns the nickname of the contact. 384 Returns the nickname of the contact.
385*/ 385*/
386 386
387/*! \fn QString OContact::children() const 387/*! \fn QString OContact::children() const
388 Returns the children of the contact. 388 Returns the children of the contact.
389*/ 389*/
390 390
391/*! \fn QString OContact::notes() const 391/*! \fn QString OContact::notes() const
392 Returns the notes relating to the the contact. 392 Returns the notes relating to the the contact.
393*/ 393*/
394 394
395/*! \fn QString OContact::groups() const 395/*! \fn QString OContact::groups() const
396 \internal 396 \internal
397 Returns the groups for the contact. 397 Returns the groups for the contact.
398*/ 398*/
399 399
400/*! \fn QStringList OContact::groupList() const 400/*! \fn QStringList OContact::groupList() const
401 \internal 401 \internal
402*/ 402*/
403 403
404/*! \fn QString OContact::field(int) const 404/*! \fn QString OContact::field(int) const
405 \internal 405 \internal
406*/ 406*/
407 407
408/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) 408/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null )
409 \internal 409 \internal
410*/ 410*/
411 411
412/*! \fn void OContact::setUid( int id ) 412/*! \fn void OContact::setUid( int id )
413 \internal 413 \internal
414 Sets the uid for this record to \a id. 414 Sets the uid for this record to \a id.
415*/ 415*/
416 416
417/*! \enum OContact::journal_action 417/*! \enum OContact::journal_action
418 \internal 418 \internal
419*/ 419*/
420 420
421/*! 421/*!
422 \internal 422 \internal
423*/ 423*/
424QMap<int, QString> OContact::toMap() const 424QMap<int, QString> OContact::toMap() const
425{ 425{
426 QMap<int, QString> map = mMap; 426 QMap<int, QString> map = mMap;
427 QString cats = idsToString( categories() ); 427 QString cats = idsToString( categories() );
428 if ( !cats.isEmpty() ) 428 if ( !cats.isEmpty() )
429 map.insert( Qtopia::AddressCategory, cats ); 429 map.insert( Qtopia::AddressCategory, cats );
430 return map; 430 return map;
431} 431}
432 432
433/*! 433/*!
434 Returns a rich text formatted QString representing the contents the contact. 434 Returns a rich text formatted QString representing the contents the contact.
435*/ 435*/
436QString OContact::toRichText() const 436QString OContact::toRichText() const
437{ 437{
438 QString text; 438 QString text;
439 QString value, comp, state; 439 QString value, comp, state;
440 QString str;
441 bool marker = false;
440 442
441 // name, jobtitle and company 443 // name, jobtitle and company
442 if ( !(value = fullName()).isEmpty() ) 444 if ( !(value = fullName()).isEmpty() )
443 text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; 445 text += "<b><h3>" + Qtopia::escapeString(value) + "</h3></b><br>";
444 if ( !(value = jobTitle()).isEmpty() ) 446 if ( !(value = jobTitle()).isEmpty() )
445 text += Qtopia::escapeString(value) + "<br>"; 447 text += Qtopia::escapeString(value) + "<br>";
446 448
447 comp = company(); 449 comp = company();
448 if ( !(value = department()).isEmpty() ) { 450 if ( !(value = department()).isEmpty() ) {
449 text += Qtopia::escapeString(value); 451 text += Qtopia::escapeString(value);
450 if ( comp ) 452 if ( comp )
451 text += ", "; 453 text += ", ";
452 else 454 else
453 text += "<br>"; 455 text += "<br>";
454 } 456 }
455 if ( !comp.isEmpty() ) 457 if ( !comp.isEmpty() )
456 text += Qtopia::escapeString(comp) + "<br>"; 458 text += Qtopia::escapeString(comp) + "<br>";
457 459
460 QString defEmail = defaultEmail();
461 if ( !defEmail.isEmpty() )
462 text += "<b>" + QObject::tr("Default Email: ") + "</b>"
463 + Qtopia::escapeString(defEmail) + "<br>";
464
465 text += "<hr>";
466
458 // business address 467 // business address
459 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 468 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
460 !businessZip().isEmpty() || !businessCountry().isEmpty() ) { 469 !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
461 text += "<br>"; 470 text += "<br>";
462 text += QObject::tr( "<b>Work Address:</b>" ); 471 text += QObject::tr( "<b>Work Address:</b>" );
463 text += "<br>"; 472 text += "<br>";
473 marker = true;
464 } 474 }
465 475
466 if ( !(value = businessStreet()).isEmpty() ) 476 if ( !(value = businessStreet()).isEmpty() )
467 text += Qtopia::escapeString(value) + "<br>"; 477 text += Qtopia::escapeString(value) + "<br>";
468 state = businessState(); 478 state = businessState();
469 if ( !(value = businessCity()).isEmpty() ) { 479 if ( !(value = businessCity()).isEmpty() ) {
470 text += Qtopia::escapeString(value); 480 text += Qtopia::escapeString(value);
471 if ( state ) 481 if ( state )
472 text += ", " + Qtopia::escapeString(state); 482 text += ", " + Qtopia::escapeString(state);
473 text += "<br>"; 483 text += "<br>";
474 } else if ( !state.isEmpty() ) 484 } else if ( !state.isEmpty() )
475 text += Qtopia::escapeString(state) + "<br>"; 485 text += Qtopia::escapeString(state) + "<br>";
476 if ( !(value = businessZip()).isEmpty() ) 486 if ( !(value = businessZip()).isEmpty() )
477 text += Qtopia::escapeString(value) + "<br>"; 487 text += Qtopia::escapeString(value) + "<br>";
478 if ( !(value = businessCountry()).isEmpty() ) 488 if ( !(value = businessCountry()).isEmpty() )
479 text += Qtopia::escapeString(value) + "<br>"; 489 text += Qtopia::escapeString(value) + "<br>";
480 490
491 // rest of Business data
492 str = office();
493 if ( !str.isEmpty() ){
494 text += "<b>" + QObject::tr("Office: ") + "</b>"
495 + Qtopia::escapeString(str) + "<br>";
496 marker = true;
497 }
498 str = businessWebpage();
499 if ( !str.isEmpty() ){
500 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>"
501 + Qtopia::escapeString(str) + "<br>";
502 marker = true;
503 }
504 str = businessPhone();
505 if ( !str.isEmpty() ){
506 text += "<b>" + QObject::tr("Business Phone: ") + "</b>"
507 + Qtopia::escapeString(str) + "<br>";
508 marker = true;
509 }
510 str = businessFax();
511 if ( !str.isEmpty() ){
512 text += "<b>" + QObject::tr("Business Fax: ") + "</b>"
513 + Qtopia::escapeString(str) + "<br>";
514 marker = true;
515 }
516 str = businessMobile();
517 if ( !str.isEmpty() ){
518 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>"
519 + Qtopia::escapeString(str) + "<br>";
520 marker = true;
521 }
522 str = businessPager();
523 if ( !str.isEmpty() ){
524 text += "<b>" + QObject::tr("Business Pager: ") + "</b>"
525 + Qtopia::escapeString(str) + "<br>";
526 marker = true;
527 }
528
481 // home address 529 // home address
482 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || 530 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
483 !homeZip().isEmpty() || !homeCountry().isEmpty() ) { 531 !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
484 text += "<br>"; 532 text += "<br>";
485 text += QObject::tr( "<b>Home Address:</b>" ); 533 text += QObject::tr( "<b>Home Address:</b>" );
486 text += "<br>"; 534 text += "<br>";
487 } 535 }
488 536
489 if ( !(value = homeStreet()).isEmpty() ) 537 if ( !(value = homeStreet()).isEmpty() )
490 text += Qtopia::escapeString(value) + "<br>"; 538 text += Qtopia::escapeString(value) + "<br>";
491 state = homeState(); 539 state = homeState();
492 if ( !(value = homeCity()).isEmpty() ) { 540 if ( !(value = homeCity()).isEmpty() ) {
493 text += Qtopia::escapeString(value); 541 text += Qtopia::escapeString(value);
494 if ( !state.isEmpty() ) 542 if ( !state.isEmpty() )
495 text += ", " + Qtopia::escapeString(state); 543 text += ", " + Qtopia::escapeString(state);
496 text += "<br>"; 544 text += "<br>";
497 } else if (!state.isEmpty()) 545 } else if (!state.isEmpty())
498 text += Qtopia::escapeString(state) + "<br>"; 546 text += Qtopia::escapeString(state) + "<br>";
499 if ( !(value = homeZip()).isEmpty() ) 547 if ( !(value = homeZip()).isEmpty() )
500 text += Qtopia::escapeString(value) + "<br>"; 548 text += Qtopia::escapeString(value) + "<br>";
501 if ( !(value = homeCountry()).isEmpty() ) 549 if ( !(value = homeCountry()).isEmpty() )
502 text += Qtopia::escapeString(value) + "<br>"; 550 text += Qtopia::escapeString(value) + "<br>";
503 551
504 // the others... 552 // rest of Home data
505 QString str; 553 str = homeWebpage();
506 QString defEmail = defaultEmail(); 554 if ( !str.isEmpty() ){
507 if ( !defEmail.isEmpty() ) 555 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>"
508 text += "<b>" + QObject::tr("Default Email: ") + "</b>"
509 + Qtopia::escapeString(defEmail) + "<br>";
510 str = emails();
511 if ( !str.isEmpty() && ( str != defEmail ) )
512 text += "<b>" + QObject::tr("All Emails: ") + "</b>"
513 + Qtopia::escapeString(str) + "<br>"; 556 + Qtopia::escapeString(str) + "<br>";
557 marker = true;
558 }
514 str = homePhone(); 559 str = homePhone();
515 if ( !str.isEmpty() ) 560 if ( !str.isEmpty() ){
516 text += "<b>" + QObject::tr("Home Phone: ") + "</b>" 561 text += "<b>" + QObject::tr("Home Phone: ") + "</b>"
517 + Qtopia::escapeString(str) + "<br>"; 562 + Qtopia::escapeString(str) + "<br>";
563 marker = true;
564 }
518 str = homeFax(); 565 str = homeFax();
519 if ( !str.isEmpty() ) 566 if ( !str.isEmpty() ){
520 text += "<b>" + QObject::tr("Home Fax: ") + "</b>" 567 text += "<b>" + QObject::tr("Home Fax: ") + "</b>"
521 + Qtopia::escapeString(str) + "<br>"; 568 + Qtopia::escapeString(str) + "<br>";
569 marker = true;
570 }
522 str = homeMobile(); 571 str = homeMobile();
523 if ( !str.isEmpty() ) 572 if ( !str.isEmpty() ){
524 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" 573 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>"
525 + Qtopia::escapeString(str) + "<br>"; 574 + Qtopia::escapeString(str) + "<br>";
526 str = homeWebpage(); 575 marker = true;
527 if ( !str.isEmpty() ) 576 }
528 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" 577
529 + Qtopia::escapeString(str) + "<br>"; 578 if ( marker )
530 str = businessWebpage(); 579 text += "<br><hr><br>";
531 if ( !str.isEmpty() ) 580 // the others...
532 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" 581 str = emails();
533 + Qtopia::escapeString(str) + "<br>"; 582 if ( !str.isEmpty() && ( str != defEmail ) )
534 str = office(); 583 text += "<b>" + QObject::tr("All Emails: ") + "</b>"
535 if ( !str.isEmpty() )
536 text += "<b>" + QObject::tr("Office: ") + "</b>"
537 + Qtopia::escapeString(str) + "<br>";
538 str = businessPhone();
539 if ( !str.isEmpty() )
540 text += "<b>" + QObject::tr("Business Phone: ") + "</b>"
541 + Qtopia::escapeString(str) + "<br>";
542 str = businessFax();
543 if ( !str.isEmpty() )
544 text += "<b>" + QObject::tr("Business Fax: ") + "</b>"
545 + Qtopia::escapeString(str) + "<br>";
546 str = businessMobile();
547 if ( !str.isEmpty() )
548 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>"
549 + Qtopia::escapeString(str) + "<br>";
550 str = businessPager();
551 if ( !str.isEmpty() )
552 text += "<b>" + QObject::tr("Business Pager: ") + "</b>"
553 + Qtopia::escapeString(str) + "<br>"; 584 + Qtopia::escapeString(str) + "<br>";
554 str = profession(); 585 str = profession();
555 if ( !str.isEmpty() ) 586 if ( !str.isEmpty() )
556 text += "<b>" + QObject::tr("Profession: ") + "</b>" 587 text += "<b>" + QObject::tr("Profession: ") + "</b>"
557 + Qtopia::escapeString(str) + "<br>"; 588 + Qtopia::escapeString(str) + "<br>";
558 str = assistant(); 589 str = assistant();
559 if ( !str.isEmpty() ) 590 if ( !str.isEmpty() )
560 text += "<b>" + QObject::tr("Assistant: ") + "</b>" 591 text += "<b>" + QObject::tr("Assistant: ") + "</b>"
561 + Qtopia::escapeString(str) + "<br>"; 592 + Qtopia::escapeString(str) + "<br>";
562 str = manager(); 593 str = manager();
563 if ( !str.isEmpty() ) 594 if ( !str.isEmpty() )
564 text += "<b>" + QObject::tr("Manager: ") + "</b>" 595 text += "<b>" + QObject::tr("Manager: ") + "</b>"
565 + Qtopia::escapeString(str) + "<br>"; 596 + Qtopia::escapeString(str) + "<br>";
566 str = gender(); 597 str = gender();
567 if ( !str.isEmpty() && str.toInt() != 0 ) { 598 if ( !str.isEmpty() && str.toInt() != 0 ) {
568 if ( str.toInt() == 1 ) 599 if ( str.toInt() == 1 )
569 str = QObject::tr( "Male" ); 600 str = QObject::tr( "Male" );
570 else if ( str.toInt() == 2 ) 601 else if ( str.toInt() == 2 )
571 str = QObject::tr( "Female" ); 602 str = QObject::tr( "Female" );
572 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; 603 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>";
573 } 604 }
574 str = spouse(); 605 str = spouse();
575 if ( !str.isEmpty() ) 606 if ( !str.isEmpty() )
576 text += "<b>" + QObject::tr("Spouse: ") + "</b>" 607 text += "<b>" + QObject::tr("Spouse: ") + "</b>"
577 + Qtopia::escapeString(str) + "<br>"; 608 + Qtopia::escapeString(str) + "<br>";
578 if ( birthday().isValid() ){ 609 if ( birthday().isValid() ){
579 str = TimeString::numberDateString( birthday() ); 610 str = TimeString::numberDateString( birthday() );
580 text += "<b>" + QObject::tr("Birthday: ") + "</b>" 611 text += "<b>" + QObject::tr("Birthday: ") + "</b>"
581 + Qtopia::escapeString(str) + "<br>"; 612 + Qtopia::escapeString(str) + "<br>";
582 } 613 }
583 if ( anniversary().isValid() ){ 614 if ( anniversary().isValid() ){
584 str = TimeString::numberDateString( anniversary() ); 615 str = TimeString::numberDateString( anniversary() );
585 text += "<b>" + QObject::tr("Anniversary: ") + "</b>" 616 text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
586 + Qtopia::escapeString(str) + "<br>"; 617 + Qtopia::escapeString(str) + "<br>";
587 } 618 }
588 str = children(); 619 str = children();
589 if ( !str.isEmpty() ) 620 if ( !str.isEmpty() )
590 text += "<b>" + QObject::tr("Children: ") + "</b>" 621 text += "<b>" + QObject::tr("Children: ") + "</b>"
591 + Qtopia::escapeString(str) + "<br>"; 622 + Qtopia::escapeString(str) + "<br>";
592 623
593 str = nickname(); 624 str = nickname();
594 if ( !str.isEmpty() ) 625 if ( !str.isEmpty() )
595 text += "<b>" + QObject::tr("Nickname: ") + "</b>" 626 text += "<b>" + QObject::tr("Nickname: ") + "</b>"
596 + Qtopia::escapeString(str) + "<br>"; 627 + Qtopia::escapeString(str) + "<br>";
597 628
598 if ( categoryNames().count() ){ 629 if ( categoryNames().count() ){
599 text += "<b>" + QObject::tr( "Category:") + "</b> "; 630 text += "<b>" + QObject::tr( "Category:") + "</b> ";
600 text += categoryNames().join(", "); 631 text += categoryNames().join(", ");
601 text += "<br>"; 632 text += "<br>";
602 } 633 }
603 634
604 // notes last 635 // notes last
605 if ( (value = notes()) ) { 636 if ( (value = notes()) ) {
606 QRegExp reg("\n"); 637 text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> ";
638 QRegExp reg("\n");
607 639
608 //QString tmp = Qtopia::escapeString(value); 640 //QString tmp = Qtopia::escapeString(value);
609 QString tmp = QStyleSheet::convertFromPlainText(value); 641 QString tmp = QStyleSheet::convertFromPlainText(value);
610 //tmp.replace( reg, "<br>" ); 642 //tmp.replace( reg, "<br>" );
611 text += "<br>" + tmp + "<br>"; 643 text += "<br>" + tmp + "<br>";
612 } 644 }
613 return text; 645 return text;
614} 646}
615 647
616/*! 648/*!
617 \internal 649 \internal
618*/ 650*/
619void OContact::insert( int key, const QString &v ) 651void OContact::insert( int key, const QString &v )
620{ 652{
621 QString value = v.stripWhiteSpace(); 653 QString value = v.stripWhiteSpace();
622 if ( value.isEmpty() ) 654 if ( value.isEmpty() )
623 mMap.remove( key ); 655 mMap.remove( key );
624 else 656 else
625 mMap.insert( key, value ); 657 mMap.insert( key, value );
626} 658}
627 659
628/*! 660/*!
629 \internal 661 \internal
630*/ 662*/
631void OContact::replace( int key, const QString & v ) 663void OContact::replace( int key, const QString & v )
632{ 664{
633 QString value = v.stripWhiteSpace(); 665 QString value = v.stripWhiteSpace();
634 if ( value.isEmpty() ) 666 if ( value.isEmpty() )
635 mMap.remove( key ); 667 mMap.remove( key );
636 else 668 else
637 mMap.replace( key, value ); 669 mMap.replace( key, value );
638} 670}
639 671
640/*! 672/*!
641 \internal 673 \internal
642*/ 674*/
643QString OContact::find( int key ) const 675QString OContact::find( int key ) const
644{ 676{
645 return mMap[key]; 677 return mMap[key];
646} 678}
647 679
648/*! 680/*!
649 \internal 681 \internal
650*/ 682*/
651QString OContact::displayAddress( const QString &street, 683QString OContact::displayAddress( const QString &street,
652 const QString &city, 684 const QString &city,
653 const QString &state, 685 const QString &state,
654 const QString &zip, 686 const QString &zip,
655 const QString &country ) const 687 const QString &country ) const
656{ 688{
657 QString s = street; 689 QString s = street;
658 if ( !street.isEmpty() ) 690 if ( !street.isEmpty() )
659 s+= "\n"; 691 s+= "\n";
660 s += city; 692 s += city;
661 if ( !city.isEmpty() && !state.isEmpty() ) 693 if ( !city.isEmpty() && !state.isEmpty() )
662 s += ", "; 694 s += ", ";
663 s += state; 695 s += state;
664 if ( !state.isEmpty() && !zip.isEmpty() ) 696 if ( !state.isEmpty() && !zip.isEmpty() )
665 s += " "; 697 s += " ";
666 s += zip; 698 s += zip;
667 if ( !country.isEmpty() && !s.isEmpty() ) 699 if ( !country.isEmpty() && !s.isEmpty() )
668 s += "\n"; 700 s += "\n";
669 s += country; 701 s += country;
670 return s; 702 return s;
671} 703}
672 704
673/*! 705/*!
674 \internal 706 \internal
675*/ 707*/
676QString OContact::displayBusinessAddress() const 708QString OContact::displayBusinessAddress() const
677{ 709{
678 return displayAddress( businessStreet(), businessCity(), 710 return displayAddress( businessStreet(), businessCity(),
679 businessState(), businessZip(), 711 businessState(), businessZip(),
680 businessCountry() ); 712 businessCountry() );
681} 713}
682 714
683/*! 715/*!
684 \internal 716 \internal
685*/ 717*/
686QString OContact::displayHomeAddress() const 718QString OContact::displayHomeAddress() const
687{ 719{
688 return displayAddress( homeStreet(), homeCity(), 720 return displayAddress( homeStreet(), homeCity(),
689 homeState(), homeZip(), 721 homeState(), homeZip(),
690 homeCountry() ); 722 homeCountry() );
691} 723}
692 724
693/*! 725/*!
694 Returns the full name of the contact 726 Returns the full name of the contact
695*/ 727*/
696QString OContact::fullName() const 728QString OContact::fullName() const
697{ 729{
698 QString title = find( Qtopia::Title ); 730 QString title = find( Qtopia::Title );
699 QString firstName = find( Qtopia::FirstName ); 731 QString firstName = find( Qtopia::FirstName );
700 QString middleName = find( Qtopia::MiddleName ); 732 QString middleName = find( Qtopia::MiddleName );
701 QString lastName = find( Qtopia::LastName ); 733 QString lastName = find( Qtopia::LastName );
702 QString suffix = find( Qtopia::Suffix ); 734 QString suffix = find( Qtopia::Suffix );
703 735
704 QString name = title; 736 QString name = title;
705 if ( !firstName.isEmpty() ) { 737 if ( !firstName.isEmpty() ) {
706 if ( !name.isEmpty() ) 738 if ( !name.isEmpty() )
707 name += " "; 739 name += " ";
708 name += firstName; 740 name += firstName;
709 } 741 }
710 if ( !middleName.isEmpty() ) { 742 if ( !middleName.isEmpty() ) {
711 if ( !name.isEmpty() ) 743 if ( !name.isEmpty() )
712 name += " "; 744 name += " ";
713 name += middleName; 745 name += middleName;
714 } 746 }
715 if ( !lastName.isEmpty() ) { 747 if ( !lastName.isEmpty() ) {
716 if ( !name.isEmpty() ) 748 if ( !name.isEmpty() )
717 name += " "; 749 name += " ";
718 name += lastName; 750 name += lastName;
719 } 751 }
720 if ( !suffix.isEmpty() ) { 752 if ( !suffix.isEmpty() ) {
721 if ( !name.isEmpty() ) 753 if ( !name.isEmpty() )
722 name += " "; 754 name += " ";
723 name += suffix; 755 name += suffix;
724 } 756 }
725 return name.simplifyWhiteSpace(); 757 return name.simplifyWhiteSpace();
726} 758}
727 759
728/*! 760/*!
729 Returns a list of the names of the children of the contact. 761 Returns a list of the names of the children of the contact.
730*/ 762*/
731QStringList OContact::childrenList() const 763QStringList OContact::childrenList() const
732{ 764{
733 return QStringList::split( " ", find( Qtopia::Children ) ); 765 return QStringList::split( " ", find( Qtopia::Children ) );
734} 766}
735 767
736/*! \fn void OContact::insertEmail( const QString &email ) 768/*! \fn void OContact::insertEmail( const QString &email )
737 769
738 Insert \a email into the email list. Ensures \a email can only be added 770 Insert \a email into the email list. Ensures \a email can only be added
739 once. If there is no default email address set, it sets it to the \a email. 771 once. If there is no default email address set, it sets it to the \a email.
740*/ 772*/
741 773
742/*! \fn void OContact::removeEmail( const QString &email ) 774/*! \fn void OContact::removeEmail( const QString &email )
743 775
744 Removes the \a email from the email list. If the default email was \a email, 776 Removes the \a email from the email list. If the default email was \a email,
745 then the default email address is assigned to the first email in the 777 then the default email address is assigned to the first email in the
746 email list 778 email list
747*/ 779*/
748 780
749/*! \fn void OContact::clearEmails() 781/*! \fn void OContact::clearEmails()
750 782
751 Clears the email list. 783 Clears the email list.
752 */ 784 */
753 785
754/*! \fn void OContact::insertEmails( const QStringList &emailList ) 786/*! \fn void OContact::insertEmails( const QStringList &emailList )
755 787
756 Appends the \a emailList to the exiting email list 788 Appends the \a emailList to the exiting email list
757 */ 789 */
758 790
759/*! 791/*!
760 Returns a list of email addresses belonging to the contact, including 792 Returns a list of email addresses belonging to the contact, including
761 the default email address. 793 the default email address.
762*/ 794*/
763QStringList OContact::emailList() const 795QStringList OContact::emailList() const
764{ 796{
765 QString emailStr = emails(); 797 QString emailStr = emails();
766 798
767 QStringList r; 799 QStringList r;
768 if ( !emailStr.isEmpty() ) { 800 if ( !emailStr.isEmpty() ) {
769 qDebug(" emailstr "); 801 qDebug(" emailstr ");
770 QStringList l = QStringList::split( emailSeparator(), emailStr ); 802 QStringList l = QStringList::split( emailSeparator(), emailStr );
771 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) 803 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
772 r += (*it).simplifyWhiteSpace(); 804 r += (*it).simplifyWhiteSpace();
773 } 805 }
774 806
775 return r; 807 return r;
776} 808}
777 809
778/*! 810/*!
779 \overload 811 \overload
780 812
781 Generates the string for the contact to be filed as from the first, 813 Generates the string for the contact to be filed as from the first,
782 middle and last name of the contact. 814 middle and last name of the contact.
783*/ 815*/
784void OContact::setFileAs() 816void OContact::setFileAs()
785{ 817{
786 QString lastName, firstName, middleName, fileas; 818 QString lastName, firstName, middleName, fileas;
787 819
788 lastName = find( Qtopia::LastName ); 820 lastName = find( Qtopia::LastName );
789 firstName = find( Qtopia::FirstName ); 821 firstName = find( Qtopia::FirstName );
790 middleName = find( Qtopia::MiddleName ); 822 middleName = find( Qtopia::MiddleName );
791 if ( !lastName.isEmpty() && !firstName.isEmpty() 823 if ( !lastName.isEmpty() && !firstName.isEmpty()
792 && !middleName.isEmpty() ) 824 && !middleName.isEmpty() )
793 fileas = lastName + ", " + firstName + " " + middleName; 825 fileas = lastName + ", " + firstName + " " + middleName;
794 else if ( !lastName.isEmpty() && !firstName.isEmpty() ) 826 else if ( !lastName.isEmpty() && !firstName.isEmpty() )
795 fileas = lastName + ", " + firstName; 827 fileas = lastName + ", " + firstName;
796 else if ( !lastName.isEmpty() || !firstName.isEmpty() || 828 else if ( !lastName.isEmpty() || !firstName.isEmpty() ||
797 !middleName.isEmpty() ) 829 !middleName.isEmpty() )
798 fileas = firstName + ( firstName.isEmpty() ? "" : " " ) 830 fileas = firstName + ( firstName.isEmpty() ? "" : " " )
799 + middleName + ( middleName.isEmpty() ? "" : " " ) 831 + middleName + ( middleName.isEmpty() ? "" : " " )
800 + lastName; 832 + lastName;
801 833
802 replace( Qtopia::FileAs, fileas ); 834 replace( Qtopia::FileAs, fileas );
803} 835}
804 836
805/*! 837/*!
806 \internal 838 \internal
807 Appends the contact information to \a buf. 839 Appends the contact information to \a buf.
808*/ 840*/
809void OContact::save( QString &buf ) const 841void OContact::save( QString &buf ) const
810{ 842{
811 static const QStringList SLFIELDS = fields(); 843 static const QStringList SLFIELDS = fields();
812 // I'm expecting "<Contact " in front of this... 844 // I'm expecting "<Contact " in front of this...
813 for ( QMap<int, QString>::ConstIterator it = mMap.begin(); 845 for ( QMap<int, QString>::ConstIterator it = mMap.begin();
814 it != mMap.end(); ++it ) { 846 it != mMap.end(); ++it ) {
815 const QString &value = it.data(); 847 const QString &value = it.data();
816 int key = it.key(); 848 int key = it.key();
817 if ( !value.isEmpty() ) { 849 if ( !value.isEmpty() ) {
818 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) 850 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)
819 continue; 851 continue;
820 852
821 key -= Qtopia::AddressCategory+1; 853 key -= Qtopia::AddressCategory+1;
822 buf += SLFIELDS[key]; 854 buf += SLFIELDS[key];
823 buf += "=\"" + Qtopia::escapeString(value) + "\" "; 855 buf += "=\"" + Qtopia::escapeString(value) + "\" ";
824 } 856 }
825 } 857 }
826 buf += customToXml(); 858 buf += customToXml();
827 if ( categories().count() > 0 ) 859 if ( categories().count() > 0 )
828 buf += "Categories=\"" + idsToString( categories() ) + "\" "; 860 buf += "Categories=\"" + idsToString( categories() ) + "\" ";
829 buf += "Uid=\"" + QString::number( uid() ) + "\" "; 861 buf += "Uid=\"" + QString::number( uid() ) + "\" ";
830 // You need to close this yourself 862 // You need to close this yourself
831} 863}
832 864
833 865
834/*! 866/*!
835 \internal 867 \internal
836 Returns the list of fields belonging to a contact 868 Returns the list of fields belonging to a contact
837 Never change order of this list ! It has to be regarding 869 Never change order of this list ! It has to be regarding
838 enum AddressBookFields !! 870 enum AddressBookFields !!
839*/ 871*/
840QStringList OContact::fields() 872QStringList OContact::fields()
841{ 873{
842 QStringList list; 874 QStringList list;
843 875
844 list.append( "Title" ); // Not Used! 876 list.append( "Title" ); // Not Used!
845 list.append( "FirstName" ); 877 list.append( "FirstName" );
846 list.append( "MiddleName" ); 878 list.append( "MiddleName" );
847 list.append( "LastName" ); 879 list.append( "LastName" );
848 list.append( "Suffix" ); 880 list.append( "Suffix" );
849 list.append( "FileAs" ); 881 list.append( "FileAs" );
850 882
851 list.append( "JobTitle" ); 883 list.append( "JobTitle" );
852 list.append( "Department" ); 884 list.append( "Department" );
853 list.append( "Company" ); 885 list.append( "Company" );
854 list.append( "BusinessPhone" ); 886 list.append( "BusinessPhone" );
855 list.append( "BusinessFax" ); 887 list.append( "BusinessFax" );
856 list.append( "BusinessMobile" ); 888 list.append( "BusinessMobile" );
857 889
858 list.append( "DefaultEmail" ); 890 list.append( "DefaultEmail" );
859 list.append( "Emails" ); 891 list.append( "Emails" );
860 892
861 list.append( "HomePhone" ); 893 list.append( "HomePhone" );
862 list.append( "HomeFax" ); 894 list.append( "HomeFax" );
863 list.append( "HomeMobile" ); 895 list.append( "HomeMobile" );
864 896
865 list.append( "BusinessStreet" ); 897 list.append( "BusinessStreet" );
866 list.append( "BusinessCity" ); 898 list.append( "BusinessCity" );
867 list.append( "BusinessState" ); 899 list.append( "BusinessState" );
868 list.append( "BusinessZip" ); 900 list.append( "BusinessZip" );
869 list.append( "BusinessCountry" ); 901 list.append( "BusinessCountry" );
870 list.append( "BusinessPager" ); 902 list.append( "BusinessPager" );
871 list.append( "BusinessWebPage" ); 903 list.append( "BusinessWebPage" );
872 904
873 list.append( "Office" ); 905 list.append( "Office" );
874 list.append( "Profession" ); 906 list.append( "Profession" );
875 list.append( "Assistant" ); 907 list.append( "Assistant" );
876 list.append( "Manager" ); 908 list.append( "Manager" );
877 909
878 list.append( "HomeStreet" ); 910 list.append( "HomeStreet" );
879 list.append( "HomeCity" ); 911 list.append( "HomeCity" );
880 list.append( "HomeState" ); 912 list.append( "HomeState" );
881 list.append( "HomeZip" ); 913 list.append( "HomeZip" );
882 list.append( "HomeCountry" ); 914 list.append( "HomeCountry" );
883 list.append( "HomeWebPage" ); 915 list.append( "HomeWebPage" );
884 916
885 list.append( "Spouse" ); 917 list.append( "Spouse" );
886 list.append( "Gender" ); 918 list.append( "Gender" );
887 list.append( "Birthday" ); 919 list.append( "Birthday" );
888 list.append( "Anniversary" ); 920 list.append( "Anniversary" );
889 list.append( "Nickname" ); 921 list.append( "Nickname" );
890 list.append( "Children" ); 922 list.append( "Children" );
891 923
892 list.append( "Notes" ); 924 list.append( "Notes" );
893 list.append( "Groups" ); 925 list.append( "Groups" );
894 926
895 return list; 927 return list;
896} 928}
897 929
898 930
899/*! 931/*!
900 Sets the list of email address for contact to those contained in \a str. 932 Sets the list of email address for contact to those contained in \a str.
901 Email address should be separated by ';'s. 933 Email address should be separated by ';'s.
902*/ 934*/
903void OContact::setEmails( const QString &str ) 935void OContact::setEmails( const QString &str )
904{ 936{
905 replace( Qtopia::Emails, str ); 937 replace( Qtopia::Emails, str );
906 if ( str.isEmpty() ) 938 if ( str.isEmpty() )
907 setDefaultEmail( QString::null ); 939 setDefaultEmail( QString::null );
908} 940}
909 941
910/*! 942/*!
911 Sets the list of children for the contact to those contained in \a str. 943 Sets the list of children for the contact to those contained in \a str.
912*/ 944*/
913void OContact::setChildren( const QString &str ) 945void OContact::setChildren( const QString &str )
914{ 946{
915 replace( Qtopia::Children, str ); 947 replace( Qtopia::Children, str );
916} 948}
917 949
918/*! 950/*!
919 Returns TRUE if the contact matches the regular expression \a regexp. 951 Returns TRUE if the contact matches the regular expression \a regexp.
920 Otherwise returns FALSE. 952 Otherwise returns FALSE.
921*/ 953*/
922bool OContact::match( const QString &regexp ) const 954bool OContact::match( const QString &regexp ) const
923{ 955{
924 return match(QRegExp(regexp)); 956 return match(QRegExp(regexp));
925} 957}
926 958
927/*! 959/*!
928 \overload 960 \overload
929 Returns TRUE if the contact matches the regular expression \a regexp. 961 Returns TRUE if the contact matches the regular expression \a regexp.
930 Otherwise returns FALSE. 962 Otherwise returns FALSE.
931*/ 963*/
932bool OContact::match( const QRegExp &r ) const 964bool OContact::match( const QRegExp &r ) const
933{ 965{
934 bool match; 966 bool match;
935 match = false; 967 match = false;
936 QMap<int, QString>::ConstIterator it; 968 QMap<int, QString>::ConstIterator it;
937 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 969 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
938 if ( (*it).find( r ) > -1 ) { 970 if ( (*it).find( r ) > -1 ) {
939 match = true; 971 match = true;
940 break; 972 break;
941 } 973 }
942 } 974 }
943 return match; 975 return match;
944} 976}
945 977
946 978
947QString OContact::toShortText() const 979QString OContact::toShortText() const
948{ 980{
949 return ( fullName() ); 981 return ( fullName() );
950} 982}
951QString OContact::type() const 983QString OContact::type() const
952{ 984{
953 return QString::fromLatin1( "OContact" ); 985 return QString::fromLatin1( "OContact" );
954} 986}
955 987
956// Definition is missing ! (se) 988// Definition is missing ! (se)
957QMap<QString,QString> OContact::toExtraMap() const 989QMap<QString,QString> OContact::toExtraMap() const
958{ 990{
959 qWarning ("Function not implemented: OContact::toExtraMap()"); 991 qWarning ("Function not implemented: OContact::toExtraMap()");
960 QMap <QString,QString> useless; 992 QMap <QString,QString> useless;
961 return useless; 993 return useless;
962} 994}
963 995
964class QString OContact::recordField( int pos ) const 996class QString OContact::recordField( int pos ) const
965{ 997{
966 QStringList SLFIELDS = fields(); // ?? why this ? (se) 998 QStringList SLFIELDS = fields(); // ?? why this ? (se)
967 return SLFIELDS[pos]; 999 return SLFIELDS[pos];
968} 1000}
969 1001
970// In future releases, we should store birthday and anniversary 1002// In future releases, we should store birthday and anniversary
971// internally as QDate instead of QString ! 1003// internally as QDate instead of QString !
972// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) 1004// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
973 1005
974/*! \fn void OContact::setBirthday( const QDate& date ) 1006/*! \fn void OContact::setBirthday( const QDate& date )
975 Sets the birthday for the contact to \a date. If date is null 1007 Sets the birthday for the contact to \a date. If date is null
976 the current stored date will be removed. 1008 the current stored date will be removed.
977*/ 1009*/
978void OContact::setBirthday( const QDate &v ) 1010void OContact::setBirthday( const QDate &v )
979{ 1011{
980 if ( v.isNull() ){ 1012 if ( v.isNull() ){
981 qWarning( "Remove Birthday"); 1013 qWarning( "Remove Birthday");
982 replace( Qtopia::Birthday, QString::null ); 1014 replace( Qtopia::Birthday, QString::null );
983 return; 1015 return;
984 } 1016 }
985 1017
986 if ( v.isValid() ) 1018 if ( v.isValid() )
987 replace( Qtopia::Birthday, TimeConversion::toString( v ) ); 1019 replace( Qtopia::Birthday, TimeConversion::toString( v ) );
988 1020
989} 1021}
990 1022
991 1023
992/*! \fn void OContact::setAnniversary( const QDate &date ) 1024/*! \fn void OContact::setAnniversary( const QDate &date )
993 Sets the anniversary of the contact to \a date. If date is 1025 Sets the anniversary of the contact to \a date. If date is
994 null, the current stored date will be removed. 1026 null, the current stored date will be removed.
995*/ 1027*/