-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index 38cba72..c9084ad 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp | |||
@@ -332,512 +332,517 @@ OContact::~OContact() | |||
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 | */ |
424 | QMap<int, QString> OContact::toMap() const | 424 | QMap<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 | */ |
436 | QString OContact::toRichText() const | 436 | QString OContact::toRichText() const |
437 | { | 437 | { |
438 | QString text; | 438 | QString text; |
439 | QString value, comp, state; | 439 | QString value, comp, state; |
440 | 440 | ||
441 | // name, jobtitle and company | 441 | // name, jobtitle and company |
442 | if ( !(value = fullName()).isEmpty() ) | 442 | if ( !(value = fullName()).isEmpty() ) |
443 | text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; | 443 | text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; |
444 | if ( !(value = jobTitle()).isEmpty() ) | 444 | if ( !(value = jobTitle()).isEmpty() ) |
445 | text += Qtopia::escapeString(value) + "<br>"; | 445 | text += Qtopia::escapeString(value) + "<br>"; |
446 | 446 | ||
447 | comp = company(); | 447 | comp = company(); |
448 | if ( !(value = department()).isEmpty() ) { | 448 | if ( !(value = department()).isEmpty() ) { |
449 | text += Qtopia::escapeString(value); | 449 | text += Qtopia::escapeString(value); |
450 | if ( comp ) | 450 | if ( comp ) |
451 | text += ", "; | 451 | text += ", "; |
452 | else | 452 | else |
453 | text += "<br>"; | 453 | text += "<br>"; |
454 | } | 454 | } |
455 | if ( !comp.isEmpty() ) | 455 | if ( !comp.isEmpty() ) |
456 | text += Qtopia::escapeString(comp) + "<br>"; | 456 | text += Qtopia::escapeString(comp) + "<br>"; |
457 | 457 | ||
458 | // business address | 458 | // business address |
459 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || | 459 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || |
460 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { | 460 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { |
461 | text += "<br>"; | 461 | text += "<br>"; |
462 | text += QObject::tr( "<b>Work Address:</b>" ); | 462 | text += QObject::tr( "<b>Work Address:</b>" ); |
463 | text += "<br>"; | 463 | text += "<br>"; |
464 | } | 464 | } |
465 | 465 | ||
466 | if ( !(value = businessStreet()).isEmpty() ) | 466 | if ( !(value = businessStreet()).isEmpty() ) |
467 | text += Qtopia::escapeString(value) + "<br>"; | 467 | text += Qtopia::escapeString(value) + "<br>"; |
468 | state = businessState(); | 468 | state = businessState(); |
469 | if ( !(value = businessCity()).isEmpty() ) { | 469 | if ( !(value = businessCity()).isEmpty() ) { |
470 | text += Qtopia::escapeString(value); | 470 | text += Qtopia::escapeString(value); |
471 | if ( state ) | 471 | if ( state ) |
472 | text += ", " + Qtopia::escapeString(state); | 472 | text += ", " + Qtopia::escapeString(state); |
473 | text += "<br>"; | 473 | text += "<br>"; |
474 | } else if ( !state.isEmpty() ) | 474 | } else if ( !state.isEmpty() ) |
475 | text += Qtopia::escapeString(state) + "<br>"; | 475 | text += Qtopia::escapeString(state) + "<br>"; |
476 | if ( !(value = businessZip()).isEmpty() ) | 476 | if ( !(value = businessZip()).isEmpty() ) |
477 | text += Qtopia::escapeString(value) + "<br>"; | 477 | text += Qtopia::escapeString(value) + "<br>"; |
478 | if ( !(value = businessCountry()).isEmpty() ) | 478 | if ( !(value = businessCountry()).isEmpty() ) |
479 | text += Qtopia::escapeString(value) + "<br>"; | 479 | text += Qtopia::escapeString(value) + "<br>"; |
480 | 480 | ||
481 | // home address | 481 | // home address |
482 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || | 482 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || |
483 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { | 483 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { |
484 | text += "<br>"; | 484 | text += "<br>"; |
485 | text += QObject::tr( "<b>Home Address:</b>" ); | 485 | text += QObject::tr( "<b>Home Address:</b>" ); |
486 | text += "<br>"; | 486 | text += "<br>"; |
487 | } | 487 | } |
488 | 488 | ||
489 | if ( !(value = homeStreet()).isEmpty() ) | 489 | if ( !(value = homeStreet()).isEmpty() ) |
490 | text += Qtopia::escapeString(value) + "<br>"; | 490 | text += Qtopia::escapeString(value) + "<br>"; |
491 | state = homeState(); | 491 | state = homeState(); |
492 | if ( !(value = homeCity()).isEmpty() ) { | 492 | if ( !(value = homeCity()).isEmpty() ) { |
493 | text += Qtopia::escapeString(value); | 493 | text += Qtopia::escapeString(value); |
494 | if ( !state.isEmpty() ) | 494 | if ( !state.isEmpty() ) |
495 | text += ", " + Qtopia::escapeString(state); | 495 | text += ", " + Qtopia::escapeString(state); |
496 | text += "<br>"; | 496 | text += "<br>"; |
497 | } else if (!state.isEmpty()) | 497 | } else if (!state.isEmpty()) |
498 | text += Qtopia::escapeString(state) + "<br>"; | 498 | text += Qtopia::escapeString(state) + "<br>"; |
499 | if ( !(value = homeZip()).isEmpty() ) | 499 | if ( !(value = homeZip()).isEmpty() ) |
500 | text += Qtopia::escapeString(value) + "<br>"; | 500 | text += Qtopia::escapeString(value) + "<br>"; |
501 | if ( !(value = homeCountry()).isEmpty() ) | 501 | if ( !(value = homeCountry()).isEmpty() ) |
502 | text += Qtopia::escapeString(value) + "<br>"; | 502 | text += Qtopia::escapeString(value) + "<br>"; |
503 | 503 | ||
504 | // the others... | 504 | // the others... |
505 | QString str; | 505 | QString str; |
506 | QString defEmail = defaultEmail(); | 506 | QString defEmail = defaultEmail(); |
507 | if ( !defEmail.isEmpty() ) | 507 | if ( !defEmail.isEmpty() ) |
508 | text += "<b>" + QObject::tr("Default Email: ") + "</b>" | 508 | text += "<b>" + QObject::tr("Default Email: ") + "</b>" |
509 | + Qtopia::escapeString(defEmail) + "<br>"; | 509 | + Qtopia::escapeString(defEmail) + "<br>"; |
510 | str = emails(); | 510 | str = emails(); |
511 | if ( !str.isEmpty() && ( str != defEmail ) ) | 511 | if ( !str.isEmpty() && ( str != defEmail ) ) |
512 | text += "<b>" + QObject::tr("All Emails: ") + "</b>" | 512 | text += "<b>" + QObject::tr("All Emails: ") + "</b>" |
513 | + Qtopia::escapeString(str) + "<br>"; | 513 | + Qtopia::escapeString(str) + "<br>"; |
514 | str = homePhone(); | 514 | str = homePhone(); |
515 | if ( !str.isEmpty() ) | 515 | if ( !str.isEmpty() ) |
516 | text += "<b>" + QObject::tr("Home Phone: ") + "</b>" | 516 | text += "<b>" + QObject::tr("Home Phone: ") + "</b>" |
517 | + Qtopia::escapeString(str) + "<br>"; | 517 | + Qtopia::escapeString(str) + "<br>"; |
518 | str = homeFax(); | 518 | str = homeFax(); |
519 | if ( !str.isEmpty() ) | 519 | if ( !str.isEmpty() ) |
520 | text += "<b>" + QObject::tr("Home Fax: ") + "</b>" | 520 | text += "<b>" + QObject::tr("Home Fax: ") + "</b>" |
521 | + Qtopia::escapeString(str) + "<br>"; | 521 | + Qtopia::escapeString(str) + "<br>"; |
522 | str = homeMobile(); | 522 | str = homeMobile(); |
523 | if ( !str.isEmpty() ) | 523 | if ( !str.isEmpty() ) |
524 | text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" | 524 | text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" |
525 | + Qtopia::escapeString(str) + "<br>"; | 525 | + Qtopia::escapeString(str) + "<br>"; |
526 | str = homeWebpage(); | 526 | str = homeWebpage(); |
527 | if ( !str.isEmpty() ) | 527 | if ( !str.isEmpty() ) |
528 | text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" | 528 | text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" |
529 | + Qtopia::escapeString(str) + "<br>"; | 529 | + Qtopia::escapeString(str) + "<br>"; |
530 | str = businessWebpage(); | 530 | str = businessWebpage(); |
531 | if ( !str.isEmpty() ) | 531 | if ( !str.isEmpty() ) |
532 | text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" | 532 | text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" |
533 | + Qtopia::escapeString(str) + "<br>"; | 533 | + Qtopia::escapeString(str) + "<br>"; |
534 | str = office(); | 534 | str = office(); |
535 | if ( !str.isEmpty() ) | 535 | if ( !str.isEmpty() ) |
536 | text += "<b>" + QObject::tr("Office: ") + "</b>" | 536 | text += "<b>" + QObject::tr("Office: ") + "</b>" |
537 | + Qtopia::escapeString(str) + "<br>"; | 537 | + Qtopia::escapeString(str) + "<br>"; |
538 | str = businessPhone(); | 538 | str = businessPhone(); |
539 | if ( !str.isEmpty() ) | 539 | if ( !str.isEmpty() ) |
540 | text += "<b>" + QObject::tr("Business Phone: ") + "</b>" | 540 | text += "<b>" + QObject::tr("Business Phone: ") + "</b>" |
541 | + Qtopia::escapeString(str) + "<br>"; | 541 | + Qtopia::escapeString(str) + "<br>"; |
542 | str = businessFax(); | 542 | str = businessFax(); |
543 | if ( !str.isEmpty() ) | 543 | if ( !str.isEmpty() ) |
544 | text += "<b>" + QObject::tr("Business Fax: ") + "</b>" | 544 | text += "<b>" + QObject::tr("Business Fax: ") + "</b>" |
545 | + Qtopia::escapeString(str) + "<br>"; | 545 | + Qtopia::escapeString(str) + "<br>"; |
546 | str = businessMobile(); | 546 | str = businessMobile(); |
547 | if ( !str.isEmpty() ) | 547 | if ( !str.isEmpty() ) |
548 | text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" | 548 | text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" |
549 | + Qtopia::escapeString(str) + "<br>"; | 549 | + Qtopia::escapeString(str) + "<br>"; |
550 | str = businessPager(); | 550 | str = businessPager(); |
551 | if ( !str.isEmpty() ) | 551 | if ( !str.isEmpty() ) |
552 | text += "<b>" + QObject::tr("Business Pager: ") + "</b>" | 552 | text += "<b>" + QObject::tr("Business Pager: ") + "</b>" |
553 | + Qtopia::escapeString(str) + "<br>"; | 553 | + Qtopia::escapeString(str) + "<br>"; |
554 | str = profession(); | 554 | str = profession(); |
555 | if ( !str.isEmpty() ) | 555 | if ( !str.isEmpty() ) |
556 | text += "<b>" + QObject::tr("Profession: ") + "</b>" | 556 | text += "<b>" + QObject::tr("Profession: ") + "</b>" |
557 | + Qtopia::escapeString(str) + "<br>"; | 557 | + Qtopia::escapeString(str) + "<br>"; |
558 | str = assistant(); | 558 | str = assistant(); |
559 | if ( !str.isEmpty() ) | 559 | if ( !str.isEmpty() ) |
560 | text += "<b>" + QObject::tr("Assistant: ") + "</b>" | 560 | text += "<b>" + QObject::tr("Assistant: ") + "</b>" |
561 | + Qtopia::escapeString(str) + "<br>"; | 561 | + Qtopia::escapeString(str) + "<br>"; |
562 | str = manager(); | 562 | str = manager(); |
563 | if ( !str.isEmpty() ) | 563 | if ( !str.isEmpty() ) |
564 | text += "<b>" + QObject::tr("Manager: ") + "</b>" | 564 | text += "<b>" + QObject::tr("Manager: ") + "</b>" |
565 | + Qtopia::escapeString(str) + "<br>"; | 565 | + Qtopia::escapeString(str) + "<br>"; |
566 | str = gender(); | 566 | str = gender(); |
567 | if ( !str.isEmpty() && str.toInt() != 0 ) { | 567 | if ( !str.isEmpty() && str.toInt() != 0 ) { |
568 | if ( str.toInt() == 1 ) | 568 | if ( str.toInt() == 1 ) |
569 | str = QObject::tr( "Male" ); | 569 | str = QObject::tr( "Male" ); |
570 | else if ( str.toInt() == 2 ) | 570 | else if ( str.toInt() == 2 ) |
571 | str = QObject::tr( "Female" ); | 571 | str = QObject::tr( "Female" ); |
572 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; | 572 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; |
573 | } | 573 | } |
574 | str = spouse(); | 574 | str = spouse(); |
575 | if ( !str.isEmpty() ) | 575 | if ( !str.isEmpty() ) |
576 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" | 576 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" |
577 | + Qtopia::escapeString(str) + "<br>"; | 577 | + Qtopia::escapeString(str) + "<br>"; |
578 | if ( birthday().isValid() ){ | 578 | if ( birthday().isValid() ){ |
579 | str = TimeString::numberDateString( birthday() ); | 579 | str = TimeString::numberDateString( birthday() ); |
580 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" | 580 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" |
581 | + Qtopia::escapeString(str) + "<br>"; | 581 | + Qtopia::escapeString(str) + "<br>"; |
582 | } | 582 | } |
583 | if ( anniversary().isValid() ){ | 583 | if ( anniversary().isValid() ){ |
584 | str = TimeString::numberDateString( anniversary() ); | 584 | str = TimeString::numberDateString( anniversary() ); |
585 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" | 585 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" |
586 | + Qtopia::escapeString(str) + "<br>"; | 586 | + Qtopia::escapeString(str) + "<br>"; |
587 | } | 587 | } |
588 | str = children(); | ||
589 | if ( !str.isEmpty() ) | ||
590 | text += "<b>" + QObject::tr("Children: ") + "</b>" | ||
591 | + Qtopia::escapeString(str) + "<br>"; | ||
592 | |||
588 | str = nickname(); | 593 | str = nickname(); |
589 | if ( !str.isEmpty() ) | 594 | if ( !str.isEmpty() ) |
590 | text += "<b>" + QObject::tr("Nickname: ") + "</b>" | 595 | text += "<b>" + QObject::tr("Nickname: ") + "</b>" |
591 | + Qtopia::escapeString(str) + "<br>"; | 596 | + Qtopia::escapeString(str) + "<br>"; |
592 | 597 | ||
593 | if ( categoryNames().count() ){ | 598 | if ( categoryNames().count() ){ |
594 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 599 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
595 | text += categoryNames().join(", "); | 600 | text += categoryNames().join(", "); |
596 | text += "<br>"; | 601 | text += "<br>"; |
597 | } | 602 | } |
598 | 603 | ||
599 | // notes last | 604 | // notes last |
600 | if ( (value = notes()) ) { | 605 | if ( (value = notes()) ) { |
601 | QRegExp reg("\n"); | 606 | QRegExp reg("\n"); |
602 | 607 | ||
603 | //QString tmp = Qtopia::escapeString(value); | 608 | //QString tmp = Qtopia::escapeString(value); |
604 | QString tmp = QStyleSheet::convertFromPlainText(value); | 609 | QString tmp = QStyleSheet::convertFromPlainText(value); |
605 | //tmp.replace( reg, "<br>" ); | 610 | //tmp.replace( reg, "<br>" ); |
606 | text += "<br>" + tmp + "<br>"; | 611 | text += "<br>" + tmp + "<br>"; |
607 | } | 612 | } |
608 | return text; | 613 | return text; |
609 | } | 614 | } |
610 | 615 | ||
611 | /*! | 616 | /*! |
612 | \internal | 617 | \internal |
613 | */ | 618 | */ |
614 | void OContact::insert( int key, const QString &v ) | 619 | void OContact::insert( int key, const QString &v ) |
615 | { | 620 | { |
616 | QString value = v.stripWhiteSpace(); | 621 | QString value = v.stripWhiteSpace(); |
617 | if ( value.isEmpty() ) | 622 | if ( value.isEmpty() ) |
618 | mMap.remove( key ); | 623 | mMap.remove( key ); |
619 | else | 624 | else |
620 | mMap.insert( key, value ); | 625 | mMap.insert( key, value ); |
621 | } | 626 | } |
622 | 627 | ||
623 | /*! | 628 | /*! |
624 | \internal | 629 | \internal |
625 | */ | 630 | */ |
626 | void OContact::replace( int key, const QString & v ) | 631 | void OContact::replace( int key, const QString & v ) |
627 | { | 632 | { |
628 | QString value = v.stripWhiteSpace(); | 633 | QString value = v.stripWhiteSpace(); |
629 | if ( value.isEmpty() ) | 634 | if ( value.isEmpty() ) |
630 | mMap.remove( key ); | 635 | mMap.remove( key ); |
631 | else | 636 | else |
632 | mMap.replace( key, value ); | 637 | mMap.replace( key, value ); |
633 | } | 638 | } |
634 | 639 | ||
635 | /*! | 640 | /*! |
636 | \internal | 641 | \internal |
637 | */ | 642 | */ |
638 | QString OContact::find( int key ) const | 643 | QString OContact::find( int key ) const |
639 | { | 644 | { |
640 | return mMap[key]; | 645 | return mMap[key]; |
641 | } | 646 | } |
642 | 647 | ||
643 | /*! | 648 | /*! |
644 | \internal | 649 | \internal |
645 | */ | 650 | */ |
646 | QString OContact::displayAddress( const QString &street, | 651 | QString OContact::displayAddress( const QString &street, |
647 | const QString &city, | 652 | const QString &city, |
648 | const QString &state, | 653 | const QString &state, |
649 | const QString &zip, | 654 | const QString &zip, |
650 | const QString &country ) const | 655 | const QString &country ) const |
651 | { | 656 | { |
652 | QString s = street; | 657 | QString s = street; |
653 | if ( !street.isEmpty() ) | 658 | if ( !street.isEmpty() ) |
654 | s+= "\n"; | 659 | s+= "\n"; |
655 | s += city; | 660 | s += city; |
656 | if ( !city.isEmpty() && !state.isEmpty() ) | 661 | if ( !city.isEmpty() && !state.isEmpty() ) |
657 | s += ", "; | 662 | s += ", "; |
658 | s += state; | 663 | s += state; |
659 | if ( !state.isEmpty() && !zip.isEmpty() ) | 664 | if ( !state.isEmpty() && !zip.isEmpty() ) |
660 | s += " "; | 665 | s += " "; |
661 | s += zip; | 666 | s += zip; |
662 | if ( !country.isEmpty() && !s.isEmpty() ) | 667 | if ( !country.isEmpty() && !s.isEmpty() ) |
663 | s += "\n"; | 668 | s += "\n"; |
664 | s += country; | 669 | s += country; |
665 | return s; | 670 | return s; |
666 | } | 671 | } |
667 | 672 | ||
668 | /*! | 673 | /*! |
669 | \internal | 674 | \internal |
670 | */ | 675 | */ |
671 | QString OContact::displayBusinessAddress() const | 676 | QString OContact::displayBusinessAddress() const |
672 | { | 677 | { |
673 | return displayAddress( businessStreet(), businessCity(), | 678 | return displayAddress( businessStreet(), businessCity(), |
674 | businessState(), businessZip(), | 679 | businessState(), businessZip(), |
675 | businessCountry() ); | 680 | businessCountry() ); |
676 | } | 681 | } |
677 | 682 | ||
678 | /*! | 683 | /*! |
679 | \internal | 684 | \internal |
680 | */ | 685 | */ |
681 | QString OContact::displayHomeAddress() const | 686 | QString OContact::displayHomeAddress() const |
682 | { | 687 | { |
683 | return displayAddress( homeStreet(), homeCity(), | 688 | return displayAddress( homeStreet(), homeCity(), |
684 | homeState(), homeZip(), | 689 | homeState(), homeZip(), |
685 | homeCountry() ); | 690 | homeCountry() ); |
686 | } | 691 | } |
687 | 692 | ||
688 | /*! | 693 | /*! |
689 | Returns the full name of the contact | 694 | Returns the full name of the contact |
690 | */ | 695 | */ |
691 | QString OContact::fullName() const | 696 | QString OContact::fullName() const |
692 | { | 697 | { |
693 | QString title = find( Qtopia::Title ); | 698 | QString title = find( Qtopia::Title ); |
694 | QString firstName = find( Qtopia::FirstName ); | 699 | QString firstName = find( Qtopia::FirstName ); |
695 | QString middleName = find( Qtopia::MiddleName ); | 700 | QString middleName = find( Qtopia::MiddleName ); |
696 | QString lastName = find( Qtopia::LastName ); | 701 | QString lastName = find( Qtopia::LastName ); |
697 | QString suffix = find( Qtopia::Suffix ); | 702 | QString suffix = find( Qtopia::Suffix ); |
698 | 703 | ||
699 | QString name = title; | 704 | QString name = title; |
700 | if ( !firstName.isEmpty() ) { | 705 | if ( !firstName.isEmpty() ) { |
701 | if ( !name.isEmpty() ) | 706 | if ( !name.isEmpty() ) |
702 | name += " "; | 707 | name += " "; |
703 | name += firstName; | 708 | name += firstName; |
704 | } | 709 | } |
705 | if ( !middleName.isEmpty() ) { | 710 | if ( !middleName.isEmpty() ) { |
706 | if ( !name.isEmpty() ) | 711 | if ( !name.isEmpty() ) |
707 | name += " "; | 712 | name += " "; |
708 | name += middleName; | 713 | name += middleName; |
709 | } | 714 | } |
710 | if ( !lastName.isEmpty() ) { | 715 | if ( !lastName.isEmpty() ) { |
711 | if ( !name.isEmpty() ) | 716 | if ( !name.isEmpty() ) |
712 | name += " "; | 717 | name += " "; |
713 | name += lastName; | 718 | name += lastName; |
714 | } | 719 | } |
715 | if ( !suffix.isEmpty() ) { | 720 | if ( !suffix.isEmpty() ) { |
716 | if ( !name.isEmpty() ) | 721 | if ( !name.isEmpty() ) |
717 | name += " "; | 722 | name += " "; |
718 | name += suffix; | 723 | name += suffix; |
719 | } | 724 | } |
720 | return name.simplifyWhiteSpace(); | 725 | return name.simplifyWhiteSpace(); |
721 | } | 726 | } |
722 | 727 | ||
723 | /*! | 728 | /*! |
724 | Returns a list of the names of the children of the contact. | 729 | Returns a list of the names of the children of the contact. |
725 | */ | 730 | */ |
726 | QStringList OContact::childrenList() const | 731 | QStringList OContact::childrenList() const |
727 | { | 732 | { |
728 | return QStringList::split( " ", find( Qtopia::Children ) ); | 733 | return QStringList::split( " ", find( Qtopia::Children ) ); |
729 | } | 734 | } |
730 | 735 | ||
731 | /*! \fn void OContact::insertEmail( const QString &email ) | 736 | /*! \fn void OContact::insertEmail( const QString &email ) |
732 | 737 | ||
733 | Insert \a email into the email list. Ensures \a email can only be added | 738 | Insert \a email into the email list. Ensures \a email can only be added |
734 | once. If there is no default email address set, it sets it to the \a email. | 739 | once. If there is no default email address set, it sets it to the \a email. |
735 | */ | 740 | */ |
736 | 741 | ||
737 | /*! \fn void OContact::removeEmail( const QString &email ) | 742 | /*! \fn void OContact::removeEmail( const QString &email ) |
738 | 743 | ||
739 | Removes the \a email from the email list. If the default email was \a email, | 744 | Removes the \a email from the email list. If the default email was \a email, |
740 | then the default email address is assigned to the first email in the | 745 | then the default email address is assigned to the first email in the |
741 | email list | 746 | email list |
742 | */ | 747 | */ |
743 | 748 | ||
744 | /*! \fn void OContact::clearEmails() | 749 | /*! \fn void OContact::clearEmails() |
745 | 750 | ||
746 | Clears the email list. | 751 | Clears the email list. |
747 | */ | 752 | */ |
748 | 753 | ||
749 | /*! \fn void OContact::insertEmails( const QStringList &emailList ) | 754 | /*! \fn void OContact::insertEmails( const QStringList &emailList ) |
750 | 755 | ||
751 | Appends the \a emailList to the exiting email list | 756 | Appends the \a emailList to the exiting email list |
752 | */ | 757 | */ |
753 | 758 | ||
754 | /*! | 759 | /*! |
755 | Returns a list of email addresses belonging to the contact, including | 760 | Returns a list of email addresses belonging to the contact, including |
756 | the default email address. | 761 | the default email address. |
757 | */ | 762 | */ |
758 | QStringList OContact::emailList() const | 763 | QStringList OContact::emailList() const |
759 | { | 764 | { |
760 | QString emailStr = emails(); | 765 | QString emailStr = emails(); |
761 | 766 | ||
762 | QStringList r; | 767 | QStringList r; |
763 | if ( !emailStr.isEmpty() ) { | 768 | if ( !emailStr.isEmpty() ) { |
764 | qDebug(" emailstr "); | 769 | qDebug(" emailstr "); |
765 | QStringList l = QStringList::split( emailSeparator(), emailStr ); | 770 | QStringList l = QStringList::split( emailSeparator(), emailStr ); |
766 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) | 771 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) |
767 | r += (*it).simplifyWhiteSpace(); | 772 | r += (*it).simplifyWhiteSpace(); |
768 | } | 773 | } |
769 | 774 | ||
770 | return r; | 775 | return r; |
771 | } | 776 | } |
772 | 777 | ||
773 | /*! | 778 | /*! |
774 | \overload | 779 | \overload |
775 | 780 | ||
776 | Generates the string for the contact to be filed as from the first, | 781 | Generates the string for the contact to be filed as from the first, |
777 | middle and last name of the contact. | 782 | middle and last name of the contact. |
778 | */ | 783 | */ |
779 | void OContact::setFileAs() | 784 | void OContact::setFileAs() |
780 | { | 785 | { |
781 | QString lastName, firstName, middleName, fileas; | 786 | QString lastName, firstName, middleName, fileas; |
782 | 787 | ||
783 | lastName = find( Qtopia::LastName ); | 788 | lastName = find( Qtopia::LastName ); |
784 | firstName = find( Qtopia::FirstName ); | 789 | firstName = find( Qtopia::FirstName ); |
785 | middleName = find( Qtopia::MiddleName ); | 790 | middleName = find( Qtopia::MiddleName ); |
786 | if ( !lastName.isEmpty() && !firstName.isEmpty() | 791 | if ( !lastName.isEmpty() && !firstName.isEmpty() |
787 | && !middleName.isEmpty() ) | 792 | && !middleName.isEmpty() ) |
788 | fileas = lastName + ", " + firstName + " " + middleName; | 793 | fileas = lastName + ", " + firstName + " " + middleName; |
789 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) | 794 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) |
790 | fileas = lastName + ", " + firstName; | 795 | fileas = lastName + ", " + firstName; |
791 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || | 796 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || |
792 | !middleName.isEmpty() ) | 797 | !middleName.isEmpty() ) |
793 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) | 798 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) |
794 | + middleName + ( middleName.isEmpty() ? "" : " " ) | 799 | + middleName + ( middleName.isEmpty() ? "" : " " ) |
795 | + lastName; | 800 | + lastName; |
796 | 801 | ||
797 | replace( Qtopia::FileAs, fileas ); | 802 | replace( Qtopia::FileAs, fileas ); |
798 | } | 803 | } |
799 | 804 | ||
800 | /*! | 805 | /*! |
801 | \internal | 806 | \internal |
802 | Appends the contact information to \a buf. | 807 | Appends the contact information to \a buf. |
803 | */ | 808 | */ |
804 | void OContact::save( QString &buf ) const | 809 | void OContact::save( QString &buf ) const |
805 | { | 810 | { |
806 | static const QStringList SLFIELDS = fields(); | 811 | static const QStringList SLFIELDS = fields(); |
807 | // I'm expecting "<Contact " in front of this... | 812 | // I'm expecting "<Contact " in front of this... |
808 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); | 813 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); |
809 | it != mMap.end(); ++it ) { | 814 | it != mMap.end(); ++it ) { |
810 | const QString &value = it.data(); | 815 | const QString &value = it.data(); |
811 | int key = it.key(); | 816 | int key = it.key(); |
812 | if ( !value.isEmpty() ) { | 817 | if ( !value.isEmpty() ) { |
813 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) | 818 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) |
814 | continue; | 819 | continue; |
815 | 820 | ||
816 | key -= Qtopia::AddressCategory+1; | 821 | key -= Qtopia::AddressCategory+1; |
817 | buf += SLFIELDS[key]; | 822 | buf += SLFIELDS[key]; |
818 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 823 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; |
819 | } | 824 | } |
820 | } | 825 | } |
821 | buf += customToXml(); | 826 | buf += customToXml(); |
822 | if ( categories().count() > 0 ) | 827 | if ( categories().count() > 0 ) |
823 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 828 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
824 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 829 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
825 | // You need to close this yourself | 830 | // You need to close this yourself |
826 | } | 831 | } |
827 | 832 | ||
828 | 833 | ||
829 | /*! | 834 | /*! |
830 | \internal | 835 | \internal |
831 | Returns the list of fields belonging to a contact | 836 | Returns the list of fields belonging to a contact |
832 | Never change order of this list ! It has to be regarding | 837 | Never change order of this list ! It has to be regarding |
833 | enum AddressBookFields !! | 838 | enum AddressBookFields !! |
834 | */ | 839 | */ |
835 | QStringList OContact::fields() | 840 | QStringList OContact::fields() |
836 | { | 841 | { |
837 | QStringList list; | 842 | QStringList list; |
838 | 843 | ||
839 | list.append( "Title" ); // Not Used! | 844 | list.append( "Title" ); // Not Used! |
840 | list.append( "FirstName" ); | 845 | list.append( "FirstName" ); |
841 | list.append( "MiddleName" ); | 846 | list.append( "MiddleName" ); |
842 | list.append( "LastName" ); | 847 | list.append( "LastName" ); |
843 | list.append( "Suffix" ); | 848 | list.append( "Suffix" ); |