-rw-r--r-- | libopie/pim/ocontact.cpp | 122 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 122 |
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 | |||
@@ -436,12 +436,14 @@ QMap<int, QString> OContact::toMap() const | |||
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 | 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(); |
@@ -454,14 +456,22 @@ QString OContact::toRichText() const | |||
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>"; |
@@ -477,8 +487,46 @@ QString OContact::toRichText() const | |||
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>"; |
@@ -500,57 +548,40 @@ QString OContact::toRichText() const | |||
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>" |
@@ -602,14 +633,15 @@ QString OContact::toRichText() const | |||
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 | ||
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 | |||
@@ -436,12 +436,14 @@ QMap<int, QString> OContact::toMap() const | |||
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 | 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(); |
@@ -454,14 +456,22 @@ QString OContact::toRichText() const | |||
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>"; |
@@ -477,8 +487,46 @@ QString OContact::toRichText() const | |||
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>"; |
@@ -500,57 +548,40 @@ QString OContact::toRichText() const | |||
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>" |
@@ -602,14 +633,15 @@ QString OContact::toRichText() const | |||
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 | ||