summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/ocontact.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/ocontact.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/ocontact.cpp219
1 files changed, 146 insertions, 73 deletions
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index be4ce0a..3473baa 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -21,10 +21,11 @@
21 21
22#include "ocontact.h" 22#include "ocontact.h"
23#include "opimresolver.h" 23#include "opimresolver.h"
24#include "oconversion.h"
24 25
25#include <qpe/stringutil.h> 26#include <qpe/stringutil.h>
26#include "oconversion.h"
27#include <qpe/timestring.h> 27#include <qpe/timestring.h>
28#include <qpe/config.h>
28 29
29#include <qobject.h> 30#include <qobject.h>
30#include <qregexp.h> 31#include <qregexp.h>
@@ -438,12 +439,16 @@ QString OContact::toRichText() const
438 QString str; 439 QString str;
439 bool marker = false; 440 bool marker = false;
440 441
442 Config cfg("qpe");
443 cfg.setGroup("Appearance");
444 int addressformat = cfg.readNumEntry( "AddressFormat", Zip_City_State );
445
441 // name, jobtitle and company 446 // name, jobtitle and company
442 if ( !(value = fullName()).isEmpty() ) 447 if ( !(value = fullName()).isEmpty() )
443 text += "<b><h3><img src=\"addressbook/AddressBook\">" + Qtopia::escapeString(value) + "</h3></b>"; 448 text += "<b><h3><img src=\"addressbook/AddressBook\">" + Qtopia::escapeString(value) + "</h3></b>";
444 449
445 if ( !(value = jobTitle()).isEmpty() ) 450 if ( !(value = jobTitle()).isEmpty() )
446 text += Qtopia::escapeString(value) + "<br>"; 451 text += Qtopia::escapeString(value);
447 452
448 comp = company(); 453 comp = company();
449 if ( !(value = department()).isEmpty() ) { 454 if ( !(value = department()).isEmpty() ) {
@@ -454,77 +459,110 @@ QString OContact::toRichText() const
454 text += "<br>"; 459 text += "<br>";
455 } 460 }
456 if ( !comp.isEmpty() ) 461 if ( !comp.isEmpty() )
457 text += Qtopia::escapeString(comp) + "<br>"; 462 text += Qtopia::escapeString(comp);
458 463
459 text += "<hr><br>"; 464 text += "<br><hr>";
460 465
461 // defailt email 466 // defailt email
462 QString defEmail = defaultEmail(); 467 QString defEmail = defaultEmail();
463 if ( !defEmail.isEmpty() ) 468 if ( !defEmail.isEmpty() ){
464 text += "<b><img src=\"addressbook/email\">" + QObject::tr("Default Email: ") + "</b>" 469 text += "<b><img src=\"addressbook/email\">" + QObject::tr("Default Email: ") + "</b>"
465 + Qtopia::escapeString(defEmail) + "<br>"; 470 + Qtopia::escapeString(defEmail);
466 471 marker = true;
467 text += "<br>"; 472 }
468 473
469 // business address 474 // business address
470 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 475 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
471 !businessZip().isEmpty() || !businessCountry().isEmpty() ) { 476 !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
472 text += QObject::tr( "<b>Work Address:</b>" ); 477 text += QObject::tr( "<br><br><b>Work Address:</b>" );
473 text += "<br>";
474 marker = true; 478 marker = true;
475 } 479 }
476 480
477 if ( !(value = businessStreet()).isEmpty() ) 481 if ( !(value = businessStreet()).isEmpty() ){
478 text += Qtopia::escapeString(value) + "<br>"; 482 text += "<br>" + Qtopia::escapeString(value);
483 marker = true;
484 }
485
486 switch( addressformat ){
487 case Zip_City_State:{ // Zip_Code City, State
479 state = businessState(); 488 state = businessState();
480 if ( !(value = businessZip()).isEmpty() ) 489 if ( !(value = businessZip()).isEmpty() ){
481 text += Qtopia::escapeString(value) + " "; 490 text += "<br>" + Qtopia::escapeString(value) + " ";
491 marker = true;
492
493 } else
494 text += "<br>";
495
482 if ( !(value = businessCity()).isEmpty() ) { 496 if ( !(value = businessCity()).isEmpty() ) {
497 marker = true;
483 text += Qtopia::escapeString(value); 498 text += Qtopia::escapeString(value);
484 if ( state ) 499 if ( state )
485 text += ", " + Qtopia::escapeString(state); 500 text += ", " + Qtopia::escapeString(state);
486 text += "<br>"; 501 } else if ( !state.isEmpty() ){
487 } else if ( !state.isEmpty() ) 502 text += "<br>" + Qtopia::escapeString(state);
488 text += Qtopia::escapeString(state) + "<br>"; 503 marker = true;
504 }
505 break;
506 }
507 case City_State_Zip:{ // City, State Zip_Code
508 state = businessState();
509 if ( !(value = businessCity()).isEmpty() ) {
510 marker = true;
511 text += "<br>" + Qtopia::escapeString(value);
512 if ( state )
513 text += ", " + Qtopia::escapeString(state);
514 } else if ( !state.isEmpty() ){
515 text += "<br>" + Qtopia::escapeString(state);
516 marker = true;
517 }
518 if ( !(value = businessZip()).isEmpty() ){
519 text += " " + Qtopia::escapeString(value);
520 marker = true;
521 }
522 break;
523 }
524 }
489 525
490 if ( !(value = businessCountry()).isEmpty() ) 526 if ( !(value = businessCountry()).isEmpty() ){
491 text += Qtopia::escapeString(value) + "<br>"; 527 text += "<br>" + Qtopia::escapeString(value);
528 marker = true;
529 }
492 530
493 // rest of Business data 531 // rest of Business data
494 str = office(); 532 str = office();
495 if ( !str.isEmpty() ){ 533 if ( !str.isEmpty() ){
496 text += "<b>" + QObject::tr("Office: ") + "</b>" 534 text += "<br><b>" + QObject::tr("Office: ") + "</b>"
497 + Qtopia::escapeString(str) + "<br>"; 535 + Qtopia::escapeString(str);
498 marker = true; 536 marker = true;
499 } 537 }
500 str = businessWebpage(); 538 str = businessWebpage();
501 if ( !str.isEmpty() ){ 539 if ( !str.isEmpty() ){
502 text += "<b><img src=\"addressbook/webpagework\">" + QObject::tr("Business Web Page: ") + "</b>" 540 text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr("Business Web Page: ") + "</b>"
503 + Qtopia::escapeString(str) + "<br>"; 541 + Qtopia::escapeString(str);
504 marker = true; 542 marker = true;
505 } 543 }
506 str = businessPhone(); 544 str = businessPhone();
507 if ( !str.isEmpty() ){ 545 if ( !str.isEmpty() ){
508 text += "<b><img src=\"addressbook/phonework\">" + QObject::tr("Business Phone: ") + "</b>" 546 text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr("Business Phone: ") + "</b>"
509 + Qtopia::escapeString(str) + "<br>"; 547 + Qtopia::escapeString(str);
510 marker = true; 548 marker = true;
511 } 549 }
512 str = businessFax(); 550 str = businessFax();
513 if ( !str.isEmpty() ){ 551 if ( !str.isEmpty() ){
514 text += "<b><img src=\"addressbook/faxwork\">" + QObject::tr("Business Fax: ") + "</b>" 552 text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr("Business Fax: ") + "</b>"
515 + Qtopia::escapeString(str) + "<br>"; 553 + Qtopia::escapeString(str);
516 marker = true; 554 marker = true;
517 } 555 }
518 str = businessMobile(); 556 str = businessMobile();
519 if ( !str.isEmpty() ){ 557 if ( !str.isEmpty() ){
520 text += "<b><img src=\"addressbook/mobilework\">" + QObject::tr("Business Mobile: ") + "</b>" 558 text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr("Business Mobile: ") + "</b>"
521 + Qtopia::escapeString(str) + "<br>"; 559 + Qtopia::escapeString(str);
522 marker = true; 560 marker = true;
523 } 561 }
524 str = businessPager(); 562 str = businessPager();
525 if ( !str.isEmpty() ){ 563 if ( !str.isEmpty() ){
526 text += "<b>" + QObject::tr("Business Pager: ") + "</b>" 564 text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>"
527 + Qtopia::escapeString(str) + "<br>"; 565 + Qtopia::escapeString(str);
528 marker = true; 566 marker = true;
529 } 567 }
530 568
@@ -533,107 +571,142 @@ QString OContact::toRichText() const
533 // home address 571 // home address
534 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || 572 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
535 !homeZip().isEmpty() || !homeCountry().isEmpty() ) { 573 !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
536 text += QObject::tr( "<b>Home Address:</b>" ); 574 text += QObject::tr( "<br><br><b>Home Address:</b>" );
537 text += "<br>"; 575 marker = true;
538 } 576 }
539 577
540 if ( !(value = homeStreet()).isEmpty() ) 578 if ( !(value = homeStreet()).isEmpty() ){
541 text += Qtopia::escapeString(value) + "<br>"; 579 text += "<br>" + Qtopia::escapeString(value);
580 marker = true;
581 }
582
583 switch( addressformat ){
584 case Zip_City_State:{ // Zip_Code City, State
542 state = homeState(); 585 state = homeState();
543 if ( !(value = homeZip()).isEmpty() ) 586 if ( !(value = homeZip()).isEmpty() ){
544 text += Qtopia::escapeString(value) + " "; 587 text += "<br>" + Qtopia::escapeString(value) + " ";
588 marker = true;
589 } else
590 text += "<br>";
591
545 if ( !(value = homeCity()).isEmpty() ) { 592 if ( !(value = homeCity()).isEmpty() ) {
593 marker = true;
546 text += Qtopia::escapeString(value); 594 text += Qtopia::escapeString(value);
547 if ( !state.isEmpty() ) 595 if ( !state.isEmpty() )
548 text += ", " + Qtopia::escapeString(state); 596 text += ", " + Qtopia::escapeString(state);
549 text += "<br>"; 597 } else if (!state.isEmpty()) {
550 } else if (!state.isEmpty()) 598 text += "<br>" + Qtopia::escapeString(state);
551 text += Qtopia::escapeString(state) + "<br>"; 599 marker = true;
552 if ( !(value = homeCountry()).isEmpty() ) 600 }
553 text += Qtopia::escapeString(value) + "<br>"; 601 break;
602 }
603 case City_State_Zip:{ // City, State Zip_Code
604 state = homeState();
605 if ( !(value = homeCity()).isEmpty() ) {
606 marker = true;
607 text += "<br>" + Qtopia::escapeString(value);
608 if ( state )
609 text += ", " + Qtopia::escapeString(state);
610 } else if ( !state.isEmpty() ){
611 text += "<br>" + Qtopia::escapeString(state);
612 marker = true;
613 }
614 if ( !(value = homeZip()).isEmpty() ){
615 text += " " + Qtopia::escapeString(value);
616 marker = true;
617 }
618 break;
619 }
620 }
621
622 if ( !(value = homeCountry()).isEmpty() ){
623 text += "<br>" + Qtopia::escapeString(value);
624 marker = true;
625 }
554 626
555 // rest of Home data 627 // rest of Home data
556 str = homeWebpage(); 628 str = homeWebpage();
557 if ( !str.isEmpty() ){ 629 if ( !str.isEmpty() ){
558 text += "<b><img src=\"addressbook/webpagehome\">" + QObject::tr("Home Web Page: ") + "</b>" 630 text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr("Home Web Page: ") + "</b>"
559 + Qtopia::escapeString(str) + "<br>"; 631 + Qtopia::escapeString(str);
560 marker = true; 632 marker = true;
561 } 633 }
562 str = homePhone(); 634 str = homePhone();
563 if ( !str.isEmpty() ){ 635 if ( !str.isEmpty() ){
564 text += "<b><img src=\"addressbook/phonehome\">" + QObject::tr("Home Phone: ") + "</b>" 636 text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr("Home Phone: ") + "</b>"
565 + Qtopia::escapeString(str) + "<br>"; 637 + Qtopia::escapeString(str);
566 marker = true; 638 marker = true;
567 } 639 }
568 str = homeFax(); 640 str = homeFax();
569 if ( !str.isEmpty() ){ 641 if ( !str.isEmpty() ){
570 text += "<b><img src=\"addressbook/faxhome\">" + QObject::tr("Home Fax: ") + "</b>" 642 text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr("Home Fax: ") + "</b>"
571 + Qtopia::escapeString(str) + "<br>"; 643 + Qtopia::escapeString(str);
572 marker = true; 644 marker = true;
573 } 645 }
574 str = homeMobile(); 646 str = homeMobile();
575 if ( !str.isEmpty() ){ 647 if ( !str.isEmpty() ){
576 text += "<b><img src=\"addressbook/mobilehome\">" + QObject::tr("Home Mobile: ") + "</b>" 648 text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>"
577 + Qtopia::escapeString(str) + "<br>"; 649 + Qtopia::escapeString(str);
578 marker = true; 650 marker = true;
579 } 651 }
580 652
581 if ( marker ) 653 if ( marker )
582 text += "<br><hr><br>"; 654 text += "<br><hr>";
583 // the others... 655
656 // the rest...
584 str = emails(); 657 str = emails();
585 if ( !str.isEmpty() && ( str != defEmail ) ) 658 if ( !str.isEmpty() && ( str != defEmail ) )
586 text += "<b>" + QObject::tr("All Emails: ") + "</b>" 659 text += "<br><b>" + QObject::tr("All Emails: ") + "</b>"
587 + Qtopia::escapeString(str) + "<br>"; 660 + Qtopia::escapeString(str);
588 str = profession(); 661 str = profession();
589 if ( !str.isEmpty() ) 662 if ( !str.isEmpty() )
590 text += "<b>" + QObject::tr("Profession: ") + "</b>" 663 text += "<br><b>" + QObject::tr("Profession: ") + "</b>"
591 + Qtopia::escapeString(str) + "<br>"; 664 + Qtopia::escapeString(str);
592 str = assistant(); 665 str = assistant();
593 if ( !str.isEmpty() ) 666 if ( !str.isEmpty() )
594 text += "<b>" + QObject::tr("Assistant: ") + "</b>" 667 text += "<br><b>" + QObject::tr("Assistant: ") + "</b>"
595 + Qtopia::escapeString(str) + "<br>"; 668 + Qtopia::escapeString(str);
596 str = manager(); 669 str = manager();
597 if ( !str.isEmpty() ) 670 if ( !str.isEmpty() )
598 text += "<b>" + QObject::tr("Manager: ") + "</b>" 671 text += "<br><b>" + QObject::tr("Manager: ") + "</b>"
599 + Qtopia::escapeString(str) + "<br>"; 672 + Qtopia::escapeString(str);
600 str = gender(); 673 str = gender();
601 if ( !str.isEmpty() && str.toInt() != 0 ) { 674 if ( !str.isEmpty() && str.toInt() != 0 ) {
675 text += "<br>";
602 if ( str.toInt() == 1 ) 676 if ( str.toInt() == 1 )
603 str = QObject::tr( "Male" ); 677 str = QObject::tr( "Male" );
604 else if ( str.toInt() == 2 ) 678 else if ( str.toInt() == 2 )
605 str = QObject::tr( "Female" ); 679 str = QObject::tr( "Female" );
606 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; 680 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str;
607 } 681 }
608 str = spouse(); 682 str = spouse();
609 if ( !str.isEmpty() ) 683 if ( !str.isEmpty() )
610 text += "<b>" + QObject::tr("Spouse: ") + "</b>" 684 text += "<br><b>" + QObject::tr("Spouse: ") + "</b>"
611 + Qtopia::escapeString(str) + "<br>"; 685 + Qtopia::escapeString(str);
612 if ( birthday().isValid() ){ 686 if ( birthday().isValid() ){
613 str = TimeString::numberDateString( birthday() ); 687 str = TimeString::numberDateString( birthday() );
614 text += "<b>" + QObject::tr("Birthday: ") + "</b>" 688 text += "<br><b>" + QObject::tr("Birthday: ") + "</b>"
615 + Qtopia::escapeString(str) + "<br>"; 689 + Qtopia::escapeString(str);
616 } 690 }
617 if ( anniversary().isValid() ){ 691 if ( anniversary().isValid() ){
618 str = TimeString::numberDateString( anniversary() ); 692 str = TimeString::numberDateString( anniversary() );
619 text += "<b>" + QObject::tr("Anniversary: ") + "</b>" 693 text += "<br><b>" + QObject::tr("Anniversary: ") + "</b>"
620 + Qtopia::escapeString(str) + "<br>"; 694 + Qtopia::escapeString(str);
621 } 695 }
622 str = children(); 696 str = children();
623 if ( !str.isEmpty() ) 697 if ( !str.isEmpty() )
624 text += "<b>" + QObject::tr("Children: ") + "</b>" 698 text += "<br><b>" + QObject::tr("Children: ") + "</b>"
625 + Qtopia::escapeString(str) + "<br>"; 699 + Qtopia::escapeString(str);
626 700
627 str = nickname(); 701 str = nickname();
628 if ( !str.isEmpty() ) 702 if ( !str.isEmpty() )
629 text += "<b>" + QObject::tr("Nickname: ") + "</b>" 703 text += "<br><b>" + QObject::tr("Nickname: ") + "</b>"
630 + Qtopia::escapeString(str) + "<br>"; 704 + Qtopia::escapeString(str);
631 705
632 // categories 706 // categories
633 if ( categoryNames("Contacts").count() ){ 707 if ( categoryNames("Contacts").count() ){
634 text += "<b>" + QObject::tr( "Category:") + "</b> "; 708 text += "<br><b>" + QObject::tr( "Category:") + "</b> ";
635 text += categoryNames("Contacts").join(", "); 709 text += categoryNames("Contacts").join(", ");
636 text += "<br>";
637 } 710 }
638 711
639 // notes last 712 // notes last