summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp11
-rw-r--r--libopie2/opiepim/ocontact.cpp11
2 files changed, 12 insertions, 10 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index 9230b8b..178559b 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -383,350 +383,351 @@ OContact::~OContact()
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; 440 QString str;
441 bool marker = false; 441 bool marker = false;
442 442
443 // name, jobtitle and company 443 // name, jobtitle and company
444 if ( !(value = fullName()).isEmpty() ) 444 if ( !(value = fullName()).isEmpty() )
445 text += "<b><h3>" + Qtopia::escapeString(value) + "</h3></b><br>"; 445 text += "<b><h3>" + Qtopia::escapeString(value) + "</h3></b><br>";
446 if ( !(value = jobTitle()).isEmpty() ) 446 if ( !(value = jobTitle()).isEmpty() )
447 text += Qtopia::escapeString(value) + "<br>"; 447 text += Qtopia::escapeString(value) + "<br>";
448 448
449 comp = company(); 449 comp = company();
450 if ( !(value = department()).isEmpty() ) { 450 if ( !(value = department()).isEmpty() ) {
451 text += Qtopia::escapeString(value); 451 text += Qtopia::escapeString(value);
452 if ( comp ) 452 if ( comp )
453 text += ", "; 453 text += ", ";
454 else 454 else
455 text += "<br>"; 455 text += "<br>";
456 } 456 }
457 if ( !comp.isEmpty() ) 457 if ( !comp.isEmpty() )
458 text += Qtopia::escapeString(comp) + "<br>"; 458 text += Qtopia::escapeString(comp) + "<br>";
459 459
460 QString defEmail = defaultEmail(); 460 QString defEmail = defaultEmail();
461 if ( !defEmail.isEmpty() ) 461 if ( !defEmail.isEmpty() )
462 text += "<b>" + QObject::tr("Default Email: ") + "</b>" 462 text += "<b>" + QObject::tr("Default Email: ") + "</b>"
463 + Qtopia::escapeString(defEmail) + "<br>"; 463 + Qtopia::escapeString(defEmail) + "<br>";
464 464
465 text += "<hr>"; 465 text += "<hr>";
466 466
467 // business address 467 // business address
468 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 468 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
469 !businessZip().isEmpty() || !businessCountry().isEmpty() ) { 469 !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
470 text += "<br>"; 470 text += "<br>";
471 text += QObject::tr( "<b>Work Address:</b>" ); 471 text += QObject::tr( "<b>Work Address:</b>" );
472 text += "<br>"; 472 text += "<br>";
473 marker = true; 473 marker = true;
474 } 474 }
475 475
476 if ( !(value = businessStreet()).isEmpty() ) 476 if ( !(value = businessStreet()).isEmpty() )
477 text += Qtopia::escapeString(value) + "<br>"; 477 text += Qtopia::escapeString(value) + "<br>";
478 state = businessState(); 478 state = businessState();
479 if ( !(value = businessZip()).isEmpty() )
480 text += Qtopia::escapeString(value) + " ";
479 if ( !(value = businessCity()).isEmpty() ) { 481 if ( !(value = businessCity()).isEmpty() ) {
480 text += Qtopia::escapeString(value); 482 text += Qtopia::escapeString(value);
481 if ( state ) 483 if ( state )
482 text += ", " + Qtopia::escapeString(state); 484 text += ", " + Qtopia::escapeString(state);
483 text += "<br>"; 485 text += "<br>";
484 } else if ( !state.isEmpty() ) 486 } else if ( !state.isEmpty() )
485 text += Qtopia::escapeString(state) + "<br>"; 487 text += Qtopia::escapeString(state) + "<br>";
486 if ( !(value = businessZip()).isEmpty() ) 488
487 text += Qtopia::escapeString(value) + "<br>";
488 if ( !(value = businessCountry()).isEmpty() ) 489 if ( !(value = businessCountry()).isEmpty() )
489 text += Qtopia::escapeString(value) + "<br>"; 490 text += Qtopia::escapeString(value) + "<br>";
490 491
491 // rest of Business data 492 // rest of Business data
492 str = office(); 493 str = office();
493 if ( !str.isEmpty() ){ 494 if ( !str.isEmpty() ){
494 text += "<b>" + QObject::tr("Office: ") + "</b>" 495 text += "<b>" + QObject::tr("Office: ") + "</b>"
495 + Qtopia::escapeString(str) + "<br>"; 496 + Qtopia::escapeString(str) + "<br>";
496 marker = true; 497 marker = true;
497 } 498 }
498 str = businessWebpage(); 499 str = businessWebpage();
499 if ( !str.isEmpty() ){ 500 if ( !str.isEmpty() ){
500 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" 501 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>"
501 + Qtopia::escapeString(str) + "<br>"; 502 + Qtopia::escapeString(str) + "<br>";
502 marker = true; 503 marker = true;
503 } 504 }
504 str = businessPhone(); 505 str = businessPhone();
505 if ( !str.isEmpty() ){ 506 if ( !str.isEmpty() ){
506 text += "<b>" + QObject::tr("Business Phone: ") + "</b>" 507 text += "<b>" + QObject::tr("Business Phone: ") + "</b>"
507 + Qtopia::escapeString(str) + "<br>"; 508 + Qtopia::escapeString(str) + "<br>";
508 marker = true; 509 marker = true;
509 } 510 }
510 str = businessFax(); 511 str = businessFax();
511 if ( !str.isEmpty() ){ 512 if ( !str.isEmpty() ){
512 text += "<b>" + QObject::tr("Business Fax: ") + "</b>" 513 text += "<b>" + QObject::tr("Business Fax: ") + "</b>"
513 + Qtopia::escapeString(str) + "<br>"; 514 + Qtopia::escapeString(str) + "<br>";
514 marker = true; 515 marker = true;
515 } 516 }
516 str = businessMobile(); 517 str = businessMobile();
517 if ( !str.isEmpty() ){ 518 if ( !str.isEmpty() ){
518 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" 519 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>"
519 + Qtopia::escapeString(str) + "<br>"; 520 + Qtopia::escapeString(str) + "<br>";
520 marker = true; 521 marker = true;
521 } 522 }
522 str = businessPager(); 523 str = businessPager();
523 if ( !str.isEmpty() ){ 524 if ( !str.isEmpty() ){
524 text += "<b>" + QObject::tr("Business Pager: ") + "</b>" 525 text += "<b>" + QObject::tr("Business Pager: ") + "</b>"
525 + Qtopia::escapeString(str) + "<br>"; 526 + Qtopia::escapeString(str) + "<br>";
526 marker = true; 527 marker = true;
527 } 528 }
528 529
529 // home address 530 // home address
530 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || 531 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
531 !homeZip().isEmpty() || !homeCountry().isEmpty() ) { 532 !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
532 text += "<br>"; 533 text += "<br>";
533 text += QObject::tr( "<b>Home Address:</b>" ); 534 text += QObject::tr( "<b>Home Address:</b>" );
534 text += "<br>"; 535 text += "<br>";
535 } 536 }
536 537
537 if ( !(value = homeStreet()).isEmpty() ) 538 if ( !(value = homeStreet()).isEmpty() )
538 text += Qtopia::escapeString(value) + "<br>"; 539 text += Qtopia::escapeString(value) + "<br>";
539 state = homeState(); 540 state = homeState();
541 if ( !(value = homeZip()).isEmpty() )
542 text += Qtopia::escapeString(value) + " ";
540 if ( !(value = homeCity()).isEmpty() ) { 543 if ( !(value = homeCity()).isEmpty() ) {
541 text += Qtopia::escapeString(value); 544 text += Qtopia::escapeString(value);
542 if ( !state.isEmpty() ) 545 if ( !state.isEmpty() )
543 text += ", " + Qtopia::escapeString(state); 546 text += ", " + Qtopia::escapeString(state);
544 text += "<br>"; 547 text += "<br>";
545 } else if (!state.isEmpty()) 548 } else if (!state.isEmpty())
546 text += Qtopia::escapeString(state) + "<br>"; 549 text += Qtopia::escapeString(state) + "<br>";
547 if ( !(value = homeZip()).isEmpty() )
548 text += Qtopia::escapeString(value) + "<br>";
549 if ( !(value = homeCountry()).isEmpty() ) 550 if ( !(value = homeCountry()).isEmpty() )
550 text += Qtopia::escapeString(value) + "<br>"; 551 text += Qtopia::escapeString(value) + "<br>";
551 552
552 // rest of Home data 553 // rest of Home data
553 str = homeWebpage(); 554 str = homeWebpage();
554 if ( !str.isEmpty() ){ 555 if ( !str.isEmpty() ){
555 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" 556 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>"
556 + Qtopia::escapeString(str) + "<br>"; 557 + Qtopia::escapeString(str) + "<br>";
557 marker = true; 558 marker = true;
558 } 559 }
559 str = homePhone(); 560 str = homePhone();
560 if ( !str.isEmpty() ){ 561 if ( !str.isEmpty() ){
561 text += "<b>" + QObject::tr("Home Phone: ") + "</b>" 562 text += "<b>" + QObject::tr("Home Phone: ") + "</b>"
562 + Qtopia::escapeString(str) + "<br>"; 563 + Qtopia::escapeString(str) + "<br>";
563 marker = true; 564 marker = true;
564 } 565 }
565 str = homeFax(); 566 str = homeFax();
566 if ( !str.isEmpty() ){ 567 if ( !str.isEmpty() ){
567 text += "<b>" + QObject::tr("Home Fax: ") + "</b>" 568 text += "<b>" + QObject::tr("Home Fax: ") + "</b>"
568 + Qtopia::escapeString(str) + "<br>"; 569 + Qtopia::escapeString(str) + "<br>";
569 marker = true; 570 marker = true;
570 } 571 }
571 str = homeMobile(); 572 str = homeMobile();
572 if ( !str.isEmpty() ){ 573 if ( !str.isEmpty() ){
573 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" 574 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>"
574 + Qtopia::escapeString(str) + "<br>"; 575 + Qtopia::escapeString(str) + "<br>";
575 marker = true; 576 marker = true;
576 } 577 }
577 578
578 if ( marker ) 579 if ( marker )
579 text += "<br><hr><br>"; 580 text += "<br><hr><br>";
580 // the others... 581 // the others...
581 str = emails(); 582 str = emails();
582 if ( !str.isEmpty() && ( str != defEmail ) ) 583 if ( !str.isEmpty() && ( str != defEmail ) )
583 text += "<b>" + QObject::tr("All Emails: ") + "</b>" 584 text += "<b>" + QObject::tr("All Emails: ") + "</b>"
584 + Qtopia::escapeString(str) + "<br>"; 585 + Qtopia::escapeString(str) + "<br>";
585 str = profession(); 586 str = profession();
586 if ( !str.isEmpty() ) 587 if ( !str.isEmpty() )
587 text += "<b>" + QObject::tr("Profession: ") + "</b>" 588 text += "<b>" + QObject::tr("Profession: ") + "</b>"
588 + Qtopia::escapeString(str) + "<br>"; 589 + Qtopia::escapeString(str) + "<br>";
589 str = assistant(); 590 str = assistant();
590 if ( !str.isEmpty() ) 591 if ( !str.isEmpty() )
591 text += "<b>" + QObject::tr("Assistant: ") + "</b>" 592 text += "<b>" + QObject::tr("Assistant: ") + "</b>"
592 + Qtopia::escapeString(str) + "<br>"; 593 + Qtopia::escapeString(str) + "<br>";
593 str = manager(); 594 str = manager();
594 if ( !str.isEmpty() ) 595 if ( !str.isEmpty() )
595 text += "<b>" + QObject::tr("Manager: ") + "</b>" 596 text += "<b>" + QObject::tr("Manager: ") + "</b>"
596 + Qtopia::escapeString(str) + "<br>"; 597 + Qtopia::escapeString(str) + "<br>";
597 str = gender(); 598 str = gender();
598 if ( !str.isEmpty() && str.toInt() != 0 ) { 599 if ( !str.isEmpty() && str.toInt() != 0 ) {
599 if ( str.toInt() == 1 ) 600 if ( str.toInt() == 1 )
600 str = QObject::tr( "Male" ); 601 str = QObject::tr( "Male" );
601 else if ( str.toInt() == 2 ) 602 else if ( str.toInt() == 2 )
602 str = QObject::tr( "Female" ); 603 str = QObject::tr( "Female" );
603 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; 604 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>";
604 } 605 }
605 str = spouse(); 606 str = spouse();
606 if ( !str.isEmpty() ) 607 if ( !str.isEmpty() )
607 text += "<b>" + QObject::tr("Spouse: ") + "</b>" 608 text += "<b>" + QObject::tr("Spouse: ") + "</b>"
608 + Qtopia::escapeString(str) + "<br>"; 609 + Qtopia::escapeString(str) + "<br>";
609 if ( birthday().isValid() ){ 610 if ( birthday().isValid() ){
610 str = TimeString::numberDateString( birthday() ); 611 str = TimeString::numberDateString( birthday() );
611 text += "<b>" + QObject::tr("Birthday: ") + "</b>" 612 text += "<b>" + QObject::tr("Birthday: ") + "</b>"
612 + Qtopia::escapeString(str) + "<br>"; 613 + Qtopia::escapeString(str) + "<br>";
613 } 614 }
614 if ( anniversary().isValid() ){ 615 if ( anniversary().isValid() ){
615 str = TimeString::numberDateString( anniversary() ); 616 str = TimeString::numberDateString( anniversary() );
616 text += "<b>" + QObject::tr("Anniversary: ") + "</b>" 617 text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
617 + Qtopia::escapeString(str) + "<br>"; 618 + Qtopia::escapeString(str) + "<br>";
618 } 619 }
619 str = children(); 620 str = children();
620 if ( !str.isEmpty() ) 621 if ( !str.isEmpty() )
621 text += "<b>" + QObject::tr("Children: ") + "</b>" 622 text += "<b>" + QObject::tr("Children: ") + "</b>"
622 + Qtopia::escapeString(str) + "<br>"; 623 + Qtopia::escapeString(str) + "<br>";
623 624
624 str = nickname(); 625 str = nickname();
625 if ( !str.isEmpty() ) 626 if ( !str.isEmpty() )
626 text += "<b>" + QObject::tr("Nickname: ") + "</b>" 627 text += "<b>" + QObject::tr("Nickname: ") + "</b>"
627 + Qtopia::escapeString(str) + "<br>"; 628 + Qtopia::escapeString(str) + "<br>";
628 629
629 if ( categoryNames().count() ){ 630 if ( categoryNames().count() ){
630 text += "<b>" + QObject::tr( "Category:") + "</b> "; 631 text += "<b>" + QObject::tr( "Category:") + "</b> ";
631 text += categoryNames().join(", "); 632 text += categoryNames().join(", ");
632 text += "<br>"; 633 text += "<br>";
633 } 634 }
634 635
635 // notes last 636 // notes last
636 if ( (value = notes()) ) { 637 if ( !(value = notes()).isEmpty() ) {
637 text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; 638 text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> ";
638 QRegExp reg("\n"); 639 QRegExp reg("\n");
639 640
640 //QString tmp = Qtopia::escapeString(value); 641 //QString tmp = Qtopia::escapeString(value);
641 QString tmp = QStyleSheet::convertFromPlainText(value); 642 QString tmp = QStyleSheet::convertFromPlainText(value);
642 //tmp.replace( reg, "<br>" ); 643 //tmp.replace( reg, "<br>" );
643 text += "<br>" + tmp + "<br>"; 644 text += "<br>" + tmp + "<br>";
644 } 645 }
645 return text; 646 return text;
646} 647}
647 648
648/*! 649/*!
649 \internal 650 \internal
650*/ 651*/
651void OContact::insert( int key, const QString &v ) 652void OContact::insert( int key, const QString &v )
652{ 653{
653 QString value = v.stripWhiteSpace(); 654 QString value = v.stripWhiteSpace();
654 if ( value.isEmpty() ) 655 if ( value.isEmpty() )
655 mMap.remove( key ); 656 mMap.remove( key );
656 else 657 else
657 mMap.insert( key, value ); 658 mMap.insert( key, value );
658} 659}
659 660
660/*! 661/*!
661 \internal 662 \internal
662*/ 663*/
663void OContact::replace( int key, const QString & v ) 664void OContact::replace( int key, const QString & v )
664{ 665{
665 QString value = v.stripWhiteSpace(); 666 QString value = v.stripWhiteSpace();
666 if ( value.isEmpty() ) 667 if ( value.isEmpty() )
667 mMap.remove( key ); 668 mMap.remove( key );
668 else 669 else
669 mMap.replace( key, value ); 670 mMap.replace( key, value );
670} 671}
671 672
672/*! 673/*!
673 \internal 674 \internal
674*/ 675*/
675QString OContact::find( int key ) const 676QString OContact::find( int key ) const
676{ 677{
677 return mMap[key]; 678 return mMap[key];
678} 679}
679 680
680/*! 681/*!
681 \internal 682 \internal
682*/ 683*/
683QString OContact::displayAddress( const QString &street, 684QString OContact::displayAddress( const QString &street,
684 const QString &city, 685 const QString &city,
685 const QString &state, 686 const QString &state,
686 const QString &zip, 687 const QString &zip,
687 const QString &country ) const 688 const QString &country ) const
688{ 689{
689 QString s = street; 690 QString s = street;
690 if ( !street.isEmpty() ) 691 if ( !street.isEmpty() )
691 s+= "\n"; 692 s+= "\n";
692 s += city; 693 s += city;
693 if ( !city.isEmpty() && !state.isEmpty() ) 694 if ( !city.isEmpty() && !state.isEmpty() )
694 s += ", "; 695 s += ", ";
695 s += state; 696 s += state;
696 if ( !state.isEmpty() && !zip.isEmpty() ) 697 if ( !state.isEmpty() && !zip.isEmpty() )
697 s += " "; 698 s += " ";
698 s += zip; 699 s += zip;
699 if ( !country.isEmpty() && !s.isEmpty() ) 700 if ( !country.isEmpty() && !s.isEmpty() )
700 s += "\n"; 701 s += "\n";
701 s += country; 702 s += country;
702 return s; 703 return s;
703} 704}
704 705
705/*! 706/*!
706 \internal 707 \internal
707*/ 708*/
708QString OContact::displayBusinessAddress() const 709QString OContact::displayBusinessAddress() const
709{ 710{
710 return displayAddress( businessStreet(), businessCity(), 711 return displayAddress( businessStreet(), businessCity(),
711 businessState(), businessZip(), 712 businessState(), businessZip(),
712 businessCountry() ); 713 businessCountry() );
713} 714}
714 715
715/*! 716/*!
716 \internal 717 \internal
717*/ 718*/
718QString OContact::displayHomeAddress() const 719QString OContact::displayHomeAddress() const
719{ 720{
720 return displayAddress( homeStreet(), homeCity(), 721 return displayAddress( homeStreet(), homeCity(),
721 homeState(), homeZip(), 722 homeState(), homeZip(),
722 homeCountry() ); 723 homeCountry() );
723} 724}
724 725
725/*! 726/*!
726 Returns the full name of the contact 727 Returns the full name of the contact
727*/ 728*/
728QString OContact::fullName() const 729QString OContact::fullName() const
729{ 730{
730 QString title = find( Qtopia::Title ); 731 QString title = find( Qtopia::Title );
731 QString firstName = find( Qtopia::FirstName ); 732 QString firstName = find( Qtopia::FirstName );
732 QString middleName = find( Qtopia::MiddleName ); 733 QString middleName = find( Qtopia::MiddleName );
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index 9230b8b..178559b 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -383,350 +383,351 @@ OContact::~OContact()
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; 440 QString str;
441 bool marker = false; 441 bool marker = false;
442 442
443 // name, jobtitle and company 443 // name, jobtitle and company
444 if ( !(value = fullName()).isEmpty() ) 444 if ( !(value = fullName()).isEmpty() )
445 text += "<b><h3>" + Qtopia::escapeString(value) + "</h3></b><br>"; 445 text += "<b><h3>" + Qtopia::escapeString(value) + "</h3></b><br>";
446 if ( !(value = jobTitle()).isEmpty() ) 446 if ( !(value = jobTitle()).isEmpty() )
447 text += Qtopia::escapeString(value) + "<br>"; 447 text += Qtopia::escapeString(value) + "<br>";
448 448
449 comp = company(); 449 comp = company();
450 if ( !(value = department()).isEmpty() ) { 450 if ( !(value = department()).isEmpty() ) {
451 text += Qtopia::escapeString(value); 451 text += Qtopia::escapeString(value);
452 if ( comp ) 452 if ( comp )
453 text += ", "; 453 text += ", ";
454 else 454 else
455 text += "<br>"; 455 text += "<br>";
456 } 456 }
457 if ( !comp.isEmpty() ) 457 if ( !comp.isEmpty() )
458 text += Qtopia::escapeString(comp) + "<br>"; 458 text += Qtopia::escapeString(comp) + "<br>";
459 459
460 QString defEmail = defaultEmail(); 460 QString defEmail = defaultEmail();
461 if ( !defEmail.isEmpty() ) 461 if ( !defEmail.isEmpty() )
462 text += "<b>" + QObject::tr("Default Email: ") + "</b>" 462 text += "<b>" + QObject::tr("Default Email: ") + "</b>"
463 + Qtopia::escapeString(defEmail) + "<br>"; 463 + Qtopia::escapeString(defEmail) + "<br>";
464 464
465 text += "<hr>"; 465 text += "<hr>";
466 466
467 // business address 467 // business address
468 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 468 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
469 !businessZip().isEmpty() || !businessCountry().isEmpty() ) { 469 !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
470 text += "<br>"; 470 text += "<br>";
471 text += QObject::tr( "<b>Work Address:</b>" ); 471 text += QObject::tr( "<b>Work Address:</b>" );
472 text += "<br>"; 472 text += "<br>";
473 marker = true; 473 marker = true;
474 } 474 }
475 475
476 if ( !(value = businessStreet()).isEmpty() ) 476 if ( !(value = businessStreet()).isEmpty() )
477 text += Qtopia::escapeString(value) + "<br>"; 477 text += Qtopia::escapeString(value) + "<br>";
478 state = businessState(); 478 state = businessState();
479 if ( !(value = businessZip()).isEmpty() )
480 text += Qtopia::escapeString(value) + " ";
479 if ( !(value = businessCity()).isEmpty() ) { 481 if ( !(value = businessCity()).isEmpty() ) {
480 text += Qtopia::escapeString(value); 482 text += Qtopia::escapeString(value);
481 if ( state ) 483 if ( state )
482 text += ", " + Qtopia::escapeString(state); 484 text += ", " + Qtopia::escapeString(state);
483 text += "<br>"; 485 text += "<br>";
484 } else if ( !state.isEmpty() ) 486 } else if ( !state.isEmpty() )
485 text += Qtopia::escapeString(state) + "<br>"; 487 text += Qtopia::escapeString(state) + "<br>";
486 if ( !(value = businessZip()).isEmpty() ) 488
487 text += Qtopia::escapeString(value) + "<br>";
488 if ( !(value = businessCountry()).isEmpty() ) 489 if ( !(value = businessCountry()).isEmpty() )
489 text += Qtopia::escapeString(value) + "<br>"; 490 text += Qtopia::escapeString(value) + "<br>";
490 491
491 // rest of Business data 492 // rest of Business data
492 str = office(); 493 str = office();
493 if ( !str.isEmpty() ){ 494 if ( !str.isEmpty() ){
494 text += "<b>" + QObject::tr("Office: ") + "</b>" 495 text += "<b>" + QObject::tr("Office: ") + "</b>"
495 + Qtopia::escapeString(str) + "<br>"; 496 + Qtopia::escapeString(str) + "<br>";
496 marker = true; 497 marker = true;
497 } 498 }
498 str = businessWebpage(); 499 str = businessWebpage();
499 if ( !str.isEmpty() ){ 500 if ( !str.isEmpty() ){
500 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" 501 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>"
501 + Qtopia::escapeString(str) + "<br>"; 502 + Qtopia::escapeString(str) + "<br>";
502 marker = true; 503 marker = true;
503 } 504 }
504 str = businessPhone(); 505 str = businessPhone();
505 if ( !str.isEmpty() ){ 506 if ( !str.isEmpty() ){
506 text += "<b>" + QObject::tr("Business Phone: ") + "</b>" 507 text += "<b>" + QObject::tr("Business Phone: ") + "</b>"
507 + Qtopia::escapeString(str) + "<br>"; 508 + Qtopia::escapeString(str) + "<br>";
508 marker = true; 509 marker = true;
509 } 510 }
510 str = businessFax(); 511 str = businessFax();
511 if ( !str.isEmpty() ){ 512 if ( !str.isEmpty() ){
512 text += "<b>" + QObject::tr("Business Fax: ") + "</b>" 513 text += "<b>" + QObject::tr("Business Fax: ") + "</b>"
513 + Qtopia::escapeString(str) + "<br>"; 514 + Qtopia::escapeString(str) + "<br>";
514 marker = true; 515 marker = true;
515 } 516 }
516 str = businessMobile(); 517 str = businessMobile();
517 if ( !str.isEmpty() ){ 518 if ( !str.isEmpty() ){
518 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" 519 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>"
519 + Qtopia::escapeString(str) + "<br>"; 520 + Qtopia::escapeString(str) + "<br>";
520 marker = true; 521 marker = true;
521 } 522 }
522 str = businessPager(); 523 str = businessPager();
523 if ( !str.isEmpty() ){ 524 if ( !str.isEmpty() ){
524 text += "<b>" + QObject::tr("Business Pager: ") + "</b>" 525 text += "<b>" + QObject::tr("Business Pager: ") + "</b>"
525 + Qtopia::escapeString(str) + "<br>"; 526 + Qtopia::escapeString(str) + "<br>";
526 marker = true; 527 marker = true;
527 } 528 }
528 529
529 // home address 530 // home address
530 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || 531 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
531 !homeZip().isEmpty() || !homeCountry().isEmpty() ) { 532 !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
532 text += "<br>"; 533 text += "<br>";
533 text += QObject::tr( "<b>Home Address:</b>" ); 534 text += QObject::tr( "<b>Home Address:</b>" );
534 text += "<br>"; 535 text += "<br>";
535 } 536 }
536 537
537 if ( !(value = homeStreet()).isEmpty() ) 538 if ( !(value = homeStreet()).isEmpty() )
538 text += Qtopia::escapeString(value) + "<br>"; 539 text += Qtopia::escapeString(value) + "<br>";
539 state = homeState(); 540 state = homeState();
541 if ( !(value = homeZip()).isEmpty() )
542 text += Qtopia::escapeString(value) + " ";
540 if ( !(value = homeCity()).isEmpty() ) { 543 if ( !(value = homeCity()).isEmpty() ) {
541 text += Qtopia::escapeString(value); 544 text += Qtopia::escapeString(value);
542 if ( !state.isEmpty() ) 545 if ( !state.isEmpty() )
543 text += ", " + Qtopia::escapeString(state); 546 text += ", " + Qtopia::escapeString(state);
544 text += "<br>"; 547 text += "<br>";
545 } else if (!state.isEmpty()) 548 } else if (!state.isEmpty())
546 text += Qtopia::escapeString(state) + "<br>"; 549 text += Qtopia::escapeString(state) + "<br>";
547 if ( !(value = homeZip()).isEmpty() )
548 text += Qtopia::escapeString(value) + "<br>";
549 if ( !(value = homeCountry()).isEmpty() ) 550 if ( !(value = homeCountry()).isEmpty() )
550 text += Qtopia::escapeString(value) + "<br>"; 551 text += Qtopia::escapeString(value) + "<br>";
551 552
552 // rest of Home data 553 // rest of Home data
553 str = homeWebpage(); 554 str = homeWebpage();
554 if ( !str.isEmpty() ){ 555 if ( !str.isEmpty() ){
555 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" 556 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>"
556 + Qtopia::escapeString(str) + "<br>"; 557 + Qtopia::escapeString(str) + "<br>";
557 marker = true; 558 marker = true;
558 } 559 }
559 str = homePhone(); 560 str = homePhone();
560 if ( !str.isEmpty() ){ 561 if ( !str.isEmpty() ){
561 text += "<b>" + QObject::tr("Home Phone: ") + "</b>" 562 text += "<b>" + QObject::tr("Home Phone: ") + "</b>"
562 + Qtopia::escapeString(str) + "<br>"; 563 + Qtopia::escapeString(str) + "<br>";
563 marker = true; 564 marker = true;
564 } 565 }
565 str = homeFax(); 566 str = homeFax();
566 if ( !str.isEmpty() ){ 567 if ( !str.isEmpty() ){
567 text += "<b>" + QObject::tr("Home Fax: ") + "</b>" 568 text += "<b>" + QObject::tr("Home Fax: ") + "</b>"
568 + Qtopia::escapeString(str) + "<br>"; 569 + Qtopia::escapeString(str) + "<br>";
569 marker = true; 570 marker = true;
570 } 571 }
571 str = homeMobile(); 572 str = homeMobile();
572 if ( !str.isEmpty() ){ 573 if ( !str.isEmpty() ){
573 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" 574 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>"
574 + Qtopia::escapeString(str) + "<br>"; 575 + Qtopia::escapeString(str) + "<br>";
575 marker = true; 576 marker = true;
576 } 577 }
577 578
578 if ( marker ) 579 if ( marker )
579 text += "<br><hr><br>"; 580 text += "<br><hr><br>";
580 // the others... 581 // the others...
581 str = emails(); 582 str = emails();
582 if ( !str.isEmpty() && ( str != defEmail ) ) 583 if ( !str.isEmpty() && ( str != defEmail ) )
583 text += "<b>" + QObject::tr("All Emails: ") + "</b>" 584 text += "<b>" + QObject::tr("All Emails: ") + "</b>"
584 + Qtopia::escapeString(str) + "<br>"; 585 + Qtopia::escapeString(str) + "<br>";
585 str = profession(); 586 str = profession();
586 if ( !str.isEmpty() ) 587 if ( !str.isEmpty() )
587 text += "<b>" + QObject::tr("Profession: ") + "</b>" 588 text += "<b>" + QObject::tr("Profession: ") + "</b>"
588 + Qtopia::escapeString(str) + "<br>"; 589 + Qtopia::escapeString(str) + "<br>";
589 str = assistant(); 590 str = assistant();
590 if ( !str.isEmpty() ) 591 if ( !str.isEmpty() )
591 text += "<b>" + QObject::tr("Assistant: ") + "</b>" 592 text += "<b>" + QObject::tr("Assistant: ") + "</b>"
592 + Qtopia::escapeString(str) + "<br>"; 593 + Qtopia::escapeString(str) + "<br>";
593 str = manager(); 594 str = manager();
594 if ( !str.isEmpty() ) 595 if ( !str.isEmpty() )
595 text += "<b>" + QObject::tr("Manager: ") + "</b>" 596 text += "<b>" + QObject::tr("Manager: ") + "</b>"
596 + Qtopia::escapeString(str) + "<br>"; 597 + Qtopia::escapeString(str) + "<br>";
597 str = gender(); 598 str = gender();
598 if ( !str.isEmpty() && str.toInt() != 0 ) { 599 if ( !str.isEmpty() && str.toInt() != 0 ) {
599 if ( str.toInt() == 1 ) 600 if ( str.toInt() == 1 )
600 str = QObject::tr( "Male" ); 601 str = QObject::tr( "Male" );
601 else if ( str.toInt() == 2 ) 602 else if ( str.toInt() == 2 )
602 str = QObject::tr( "Female" ); 603 str = QObject::tr( "Female" );
603 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; 604 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>";
604 } 605 }
605 str = spouse(); 606 str = spouse();
606 if ( !str.isEmpty() ) 607 if ( !str.isEmpty() )
607 text += "<b>" + QObject::tr("Spouse: ") + "</b>" 608 text += "<b>" + QObject::tr("Spouse: ") + "</b>"
608 + Qtopia::escapeString(str) + "<br>"; 609 + Qtopia::escapeString(str) + "<br>";
609 if ( birthday().isValid() ){ 610 if ( birthday().isValid() ){
610 str = TimeString::numberDateString( birthday() ); 611 str = TimeString::numberDateString( birthday() );
611 text += "<b>" + QObject::tr("Birthday: ") + "</b>" 612 text += "<b>" + QObject::tr("Birthday: ") + "</b>"
612 + Qtopia::escapeString(str) + "<br>"; 613 + Qtopia::escapeString(str) + "<br>";
613 } 614 }
614 if ( anniversary().isValid() ){ 615 if ( anniversary().isValid() ){
615 str = TimeString::numberDateString( anniversary() ); 616 str = TimeString::numberDateString( anniversary() );
616 text += "<b>" + QObject::tr("Anniversary: ") + "</b>" 617 text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
617 + Qtopia::escapeString(str) + "<br>"; 618 + Qtopia::escapeString(str) + "<br>";
618 } 619 }
619 str = children(); 620 str = children();
620 if ( !str.isEmpty() ) 621 if ( !str.isEmpty() )
621 text += "<b>" + QObject::tr("Children: ") + "</b>" 622 text += "<b>" + QObject::tr("Children: ") + "</b>"
622 + Qtopia::escapeString(str) + "<br>"; 623 + Qtopia::escapeString(str) + "<br>";
623 624
624 str = nickname(); 625 str = nickname();
625 if ( !str.isEmpty() ) 626 if ( !str.isEmpty() )
626 text += "<b>" + QObject::tr("Nickname: ") + "</b>" 627 text += "<b>" + QObject::tr("Nickname: ") + "</b>"
627 + Qtopia::escapeString(str) + "<br>"; 628 + Qtopia::escapeString(str) + "<br>";
628 629
629 if ( categoryNames().count() ){ 630 if ( categoryNames().count() ){
630 text += "<b>" + QObject::tr( "Category:") + "</b> "; 631 text += "<b>" + QObject::tr( "Category:") + "</b> ";
631 text += categoryNames().join(", "); 632 text += categoryNames().join(", ");
632 text += "<br>"; 633 text += "<br>";
633 } 634 }
634 635
635 // notes last 636 // notes last
636 if ( (value = notes()) ) { 637 if ( !(value = notes()).isEmpty() ) {
637 text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; 638 text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> ";
638 QRegExp reg("\n"); 639 QRegExp reg("\n");
639 640
640 //QString tmp = Qtopia::escapeString(value); 641 //QString tmp = Qtopia::escapeString(value);
641 QString tmp = QStyleSheet::convertFromPlainText(value); 642 QString tmp = QStyleSheet::convertFromPlainText(value);
642 //tmp.replace( reg, "<br>" ); 643 //tmp.replace( reg, "<br>" );
643 text += "<br>" + tmp + "<br>"; 644 text += "<br>" + tmp + "<br>";
644 } 645 }
645 return text; 646 return text;
646} 647}
647 648
648/*! 649/*!
649 \internal 650 \internal
650*/ 651*/
651void OContact::insert( int key, const QString &v ) 652void OContact::insert( int key, const QString &v )
652{ 653{
653 QString value = v.stripWhiteSpace(); 654 QString value = v.stripWhiteSpace();
654 if ( value.isEmpty() ) 655 if ( value.isEmpty() )
655 mMap.remove( key ); 656 mMap.remove( key );
656 else 657 else
657 mMap.insert( key, value ); 658 mMap.insert( key, value );
658} 659}
659 660
660/*! 661/*!
661 \internal 662 \internal
662*/ 663*/
663void OContact::replace( int key, const QString & v ) 664void OContact::replace( int key, const QString & v )
664{ 665{
665 QString value = v.stripWhiteSpace(); 666 QString value = v.stripWhiteSpace();
666 if ( value.isEmpty() ) 667 if ( value.isEmpty() )
667 mMap.remove( key ); 668 mMap.remove( key );
668 else 669 else
669 mMap.replace( key, value ); 670 mMap.replace( key, value );
670} 671}
671 672
672/*! 673/*!
673 \internal 674 \internal
674*/ 675*/
675QString OContact::find( int key ) const 676QString OContact::find( int key ) const
676{ 677{
677 return mMap[key]; 678 return mMap[key];
678} 679}
679 680
680/*! 681/*!
681 \internal 682 \internal
682*/ 683*/
683QString OContact::displayAddress( const QString &street, 684QString OContact::displayAddress( const QString &street,
684 const QString &city, 685 const QString &city,
685 const QString &state, 686 const QString &state,
686 const QString &zip, 687 const QString &zip,
687 const QString &country ) const 688 const QString &country ) const
688{ 689{
689 QString s = street; 690 QString s = street;
690 if ( !street.isEmpty() ) 691 if ( !street.isEmpty() )
691 s+= "\n"; 692 s+= "\n";
692 s += city; 693 s += city;
693 if ( !city.isEmpty() && !state.isEmpty() ) 694 if ( !city.isEmpty() && !state.isEmpty() )
694 s += ", "; 695 s += ", ";
695 s += state; 696 s += state;
696 if ( !state.isEmpty() && !zip.isEmpty() ) 697 if ( !state.isEmpty() && !zip.isEmpty() )
697 s += " "; 698 s += " ";
698 s += zip; 699 s += zip;
699 if ( !country.isEmpty() && !s.isEmpty() ) 700 if ( !country.isEmpty() && !s.isEmpty() )
700 s += "\n"; 701 s += "\n";
701 s += country; 702 s += country;
702 return s; 703 return s;
703} 704}
704 705
705/*! 706/*!
706 \internal 707 \internal
707*/ 708*/
708QString OContact::displayBusinessAddress() const 709QString OContact::displayBusinessAddress() const
709{ 710{
710 return displayAddress( businessStreet(), businessCity(), 711 return displayAddress( businessStreet(), businessCity(),
711 businessState(), businessZip(), 712 businessState(), businessZip(),
712 businessCountry() ); 713 businessCountry() );
713} 714}
714 715
715/*! 716/*!
716 \internal 717 \internal
717*/ 718*/
718QString OContact::displayHomeAddress() const 719QString OContact::displayHomeAddress() const
719{ 720{
720 return displayAddress( homeStreet(), homeCity(), 721 return displayAddress( homeStreet(), homeCity(),
721 homeState(), homeZip(), 722 homeState(), homeZip(),
722 homeCountry() ); 723 homeCountry() );
723} 724}
724 725
725/*! 726/*!
726 Returns the full name of the contact 727 Returns the full name of the contact
727*/ 728*/
728QString OContact::fullName() const 729QString OContact::fullName() const
729{ 730{
730 QString title = find( Qtopia::Title ); 731 QString title = find( Qtopia::Title );
731 QString firstName = find( Qtopia::FirstName ); 732 QString firstName = find( Qtopia::FirstName );
732 QString middleName = find( Qtopia::MiddleName ); 733 QString middleName = find( Qtopia::MiddleName );