-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 235 |
1 files changed, 145 insertions, 90 deletions
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index f1a22a7..fa5313f 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
@@ -28,33 +28,16 @@ | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | /********************************************************************** | ||
31 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
32 | ** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) | ||
33 | ** | ||
34 | ** This file may be distributed and/or modified under the terms of the | ||
35 | ** GNU General Public License version 2 as published by the Free Software | ||
36 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
37 | ** packaging of this file. | ||
38 | ** | ||
39 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
40 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
41 | ** | ||
42 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
43 | ** | ||
44 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
45 | ** not clear to you. | ||
46 | ** | ||
47 | **********************************************************************/ | ||
48 | |||
49 | #define QTOPIA_INTERNAL_CONTACT_MRE | 30 | #define QTOPIA_INTERNAL_CONTACT_MRE |
50 | 31 | ||
51 | #include <opie2/ocontact.h> | 32 | #include "ocontact.h" |
33 | |||
34 | /* OPIE */ | ||
52 | #include <opie2/opimresolver.h> | 35 | #include <opie2/opimresolver.h> |
53 | #include <opie2/oconversion.h> | 36 | #include <opie2/oconversion.h> |
54 | |||
55 | #include <qpe/stringutil.h> | 37 | #include <qpe/stringutil.h> |
56 | #include <qpe/timestring.h> | 38 | #include <qpe/timestring.h> |
57 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
58 | 40 | ||
41 | /* QT */ | ||
59 | #include <qobject.h> | 42 | #include <qobject.h> |
60 | #include <qregexp.h> | 43 | #include <qregexp.h> |
@@ -63,4 +46,5 @@ | |||
63 | #include <qmap.h> | 46 | #include <qmap.h> |
64 | 47 | ||
48 | /* STD */ | ||
65 | #include <stdio.h> | 49 | #include <stdio.h> |
66 | 50 | ||
@@ -77,12 +61,11 @@ | |||
77 | 61 | ||
78 | 62 | ||
79 | namespace Opie { | 63 | namespace Opie |
64 | { | ||
80 | /*! | 65 | /*! |
81 | Creates a new, empty contact. | 66 | Creates a new, empty contact. |
82 | */ | 67 | */ |
83 | OContact::OContact() | 68 | OContact::OContact():OPimRecord(), mMap(), d( 0 ) |
84 | : OPimRecord(), mMap(), d( 0 ) | 69 | {} |
85 | { | ||
86 | } | ||
87 | 70 | ||
88 | /*! | 71 | /*! |
@@ -91,6 +74,5 @@ OContact::OContact() | |||
91 | set from \a fromMap. | 74 | set from \a fromMap. |
92 | */ | 75 | */ |
93 | OContact::OContact( const QMap<int, QString> &fromMap ) : | 76 | OContact::OContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 ) |
94 | OPimRecord(), mMap( fromMap ), d( 0 ) | ||
95 | { | 77 | { |
96 | QString cats = mMap[ Qtopia::AddressCategory ]; | 78 | QString cats = mMap[ Qtopia::AddressCategory ]; |
@@ -100,8 +82,10 @@ OContact::OContact( const QMap<int, QString> &fromMap ) : | |||
100 | QString uidStr = find( Qtopia::AddressUid ); | 82 | QString uidStr = find( Qtopia::AddressUid ); |
101 | 83 | ||
102 | if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ | 84 | if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) ) |
85 | { | ||
103 | qWarning( "Invalid UID found. Generate new one.." ); | 86 | qWarning( "Invalid UID found. Generate new one.." ); |
104 | setUid( uidGen().generate() ); | 87 | setUid( uidGen().generate() ); |
105 | }else | 88 | } |
89 | else | ||
106 | setUid( uidStr.toInt() ); | 90 | setUid( uidStr.toInt() ); |
107 | 91 | ||
@@ -114,6 +98,5 @@ OContact::OContact( const QMap<int, QString> &fromMap ) : | |||
114 | */ | 98 | */ |
115 | OContact::~OContact() | 99 | OContact::~OContact() |
116 | { | 100 | {} |
117 | } | ||
118 | 101 | ||
119 | /*! \fn void OContact::setTitle( const QString &str ) | 102 | /*! \fn void OContact::setTitle( const QString &str ) |
@@ -482,9 +465,11 @@ QString OContact::toRichText() const | |||
482 | 465 | ||
483 | comp = company(); | 466 | comp = company(); |
484 | if ( !(value = department()).isEmpty() ) { | 467 | if ( !( value = department() ).isEmpty() ) |
468 | { | ||
485 | text += Qtopia::escapeString(value); | 469 | text += Qtopia::escapeString(value); |
486 | if ( comp ) | 470 | if ( comp ) |
487 | text += ", " + Qtopia::escapeString(comp); | 471 | text += ", " + Qtopia::escapeString(comp); |
488 | }else if ( comp ) | 472 | } |
473 | else if ( comp ) | ||
489 | text += "<br>" + Qtopia::escapeString(comp); | 474 | text += "<br>" + Qtopia::escapeString(comp); |
490 | text += "<br><hr>"; | 475 | text += "<br><hr>"; |
@@ -492,5 +477,6 @@ QString OContact::toRichText() const | |||
492 | // defailt email | 477 | // defailt email |
493 | QString defEmail = defaultEmail(); | 478 | QString defEmail = defaultEmail(); |
494 | if ( !defEmail.isEmpty() ){ | 479 | if ( !defEmail.isEmpty() ) |
480 | { | ||
495 | text += "<b><img src=\"addressbook/email\"> " + QObject::tr("Default Email: ") + "</b>" | 481 | text += "<b><img src=\"addressbook/email\"> " + QObject::tr("Default Email: ") + "</b>" |
496 | + Qtopia::escapeString(defEmail); | 482 | + Qtopia::escapeString(defEmail); |
@@ -500,23 +486,29 @@ QString OContact::toRichText() const | |||
500 | // business address | 486 | // business address |
501 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || | 487 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || |
502 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { | 488 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) |
489 | { | ||
503 | text += QObject::tr( "<br><b>Work Address:</b>" ); | 490 | text += QObject::tr( "<br><b>Work Address:</b>" ); |
504 | marker = true; | 491 | marker = true; |
505 | } | 492 | } |
506 | 493 | ||
507 | if ( !(value = businessStreet()).isEmpty() ){ | 494 | if ( !( value = businessStreet() ).isEmpty() ) |
495 | { | ||
508 | text += "<br>" + Qtopia::escapeString(value); | 496 | text += "<br>" + Qtopia::escapeString(value); |
509 | marker = true; | 497 | marker = true; |
510 | } | 498 | } |
511 | 499 | ||
512 | switch( addressformat ){ | 500 | switch ( addressformat ) |
513 | case Zip_City_State:{ // Zip_Code City, State | 501 | { |
502 | case Zip_City_State: | ||
503 | { // Zip_Code City, State | ||
514 | state = businessState(); | 504 | state = businessState(); |
515 | if ( !(value = businessZip()).isEmpty() ){ | 505 | if ( !( value = businessZip() ).isEmpty() ) |
506 | { | ||
516 | text += "<br>" + Qtopia::escapeString(value) + " "; | 507 | text += "<br>" + Qtopia::escapeString(value) + " "; |
517 | marker = true; | 508 | marker = true; |
518 | 509 | ||
519 | } | 510 | } |
520 | if ( !(value = businessCity()).isEmpty() ) { | 511 | if ( !( value = businessCity() ).isEmpty() ) |
512 | { | ||
521 | marker = true; | 513 | marker = true; |
522 | if ( businessZip().isEmpty() && !businessStreet().isEmpty() ) | 514 | if ( businessZip().isEmpty() && !businessStreet().isEmpty() ) |
@@ -525,5 +517,7 @@ QString OContact::toRichText() const | |||
525 | if ( state ) | 517 | if ( state ) |
526 | text += ", " + Qtopia::escapeString(state); | 518 | text += ", " + Qtopia::escapeString(state); |
527 | } else if ( !state.isEmpty() ){ | 519 | } |
520 | else if ( !state.isEmpty() ) | ||
521 | { | ||
528 | text += "<br>" + Qtopia::escapeString(state); | 522 | text += "<br>" + Qtopia::escapeString(state); |
529 | marker = true; | 523 | marker = true; |
@@ -531,16 +525,21 @@ QString OContact::toRichText() const | |||
531 | break; | 525 | break; |
532 | } | 526 | } |
533 | case City_State_Zip:{ // City, State Zip_Code | 527 | case City_State_Zip: |
528 | { // City, State Zip_Code | ||
534 | state = businessState(); | 529 | state = businessState(); |
535 | if ( !(value = businessCity()).isEmpty() ) { | 530 | if ( !( value = businessCity() ).isEmpty() ) |
531 | { | ||
536 | marker = true; | 532 | marker = true; |
537 | text += "<br>" + Qtopia::escapeString(value); | 533 | text += "<br>" + Qtopia::escapeString(value); |
538 | if ( state ) | 534 | if ( state ) |
539 | text += ", " + Qtopia::escapeString(state); | 535 | text += ", " + Qtopia::escapeString(state); |
540 | } else if ( !state.isEmpty() ){ | 536 | } |
537 | else if ( !state.isEmpty() ) | ||
538 | { | ||
541 | text += "<br>" + Qtopia::escapeString(state); | 539 | text += "<br>" + Qtopia::escapeString(state); |
542 | marker = true; | 540 | marker = true; |
543 | } | 541 | } |
544 | if ( !(value = businessZip()).isEmpty() ){ | 542 | if ( !( value = businessZip() ).isEmpty() ) |
543 | { | ||
545 | text += " " + Qtopia::escapeString(value); | 544 | text += " " + Qtopia::escapeString(value); |
546 | marker = true; | 545 | marker = true; |
@@ -550,5 +549,6 @@ QString OContact::toRichText() const | |||
550 | } | 549 | } |
551 | 550 | ||
552 | if ( !(value = businessCountry()).isEmpty() ){ | 551 | if ( !( value = businessCountry() ).isEmpty() ) |
552 | { | ||
553 | text += "<br>" + Qtopia::escapeString(value); | 553 | text += "<br>" + Qtopia::escapeString(value); |
554 | marker = true; | 554 | marker = true; |
@@ -557,5 +557,6 @@ QString OContact::toRichText() const | |||
557 | // rest of Business data | 557 | // rest of Business data |
558 | str = office(); | 558 | str = office(); |
559 | if ( !str.isEmpty() ){ | 559 | if ( !str.isEmpty() ) |
560 | { | ||
560 | text += "<br><b>" + QObject::tr("Office: ") + "</b>" | 561 | text += "<br><b>" + QObject::tr("Office: ") + "</b>" |
561 | + Qtopia::escapeString(str); | 562 | + Qtopia::escapeString(str); |
@@ -563,5 +564,6 @@ QString OContact::toRichText() const | |||
563 | } | 564 | } |
564 | str = businessWebpage(); | 565 | str = businessWebpage(); |
565 | if ( !str.isEmpty() ){ | 566 | if ( !str.isEmpty() ) |
567 | { | ||
566 | text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr("Business Web Page: ") + "</b>" | 568 | text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr("Business Web Page: ") + "</b>" |
567 | + Qtopia::escapeString(str); | 569 | + Qtopia::escapeString(str); |
@@ -569,5 +571,6 @@ QString OContact::toRichText() const | |||
569 | } | 571 | } |
570 | str = businessPhone(); | 572 | str = businessPhone(); |
571 | if ( !str.isEmpty() ){ | 573 | if ( !str.isEmpty() ) |
574 | { | ||
572 | text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr("Business Phone: ") + "</b>" | 575 | text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr("Business Phone: ") + "</b>" |
573 | + Qtopia::escapeString(str); | 576 | + Qtopia::escapeString(str); |
@@ -575,5 +578,6 @@ QString OContact::toRichText() const | |||
575 | } | 578 | } |
576 | str = businessFax(); | 579 | str = businessFax(); |
577 | if ( !str.isEmpty() ){ | 580 | if ( !str.isEmpty() ) |
581 | { | ||
578 | text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr("Business Fax: ") + "</b>" | 582 | text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr("Business Fax: ") + "</b>" |
579 | + Qtopia::escapeString(str); | 583 | + Qtopia::escapeString(str); |
@@ -581,5 +585,6 @@ QString OContact::toRichText() const | |||
581 | } | 585 | } |
582 | str = businessMobile(); | 586 | str = businessMobile(); |
583 | if ( !str.isEmpty() ){ | 587 | if ( !str.isEmpty() ) |
588 | { | ||
584 | text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr("Business Mobile: ") + "</b>" | 589 | text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr("Business Mobile: ") + "</b>" |
585 | + Qtopia::escapeString(str); | 590 | + Qtopia::escapeString(str); |
@@ -587,5 +592,6 @@ QString OContact::toRichText() const | |||
587 | } | 592 | } |
588 | str = businessPager(); | 593 | str = businessPager(); |
589 | if ( !str.isEmpty() ){ | 594 | if ( !str.isEmpty() ) |
595 | { | ||
590 | text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>" | 596 | text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>" |
591 | + Qtopia::escapeString(str); | 597 | + Qtopia::escapeString(str); |
@@ -597,22 +603,28 @@ QString OContact::toRichText() const | |||
597 | // home address | 603 | // home address |
598 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || | 604 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || |
599 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { | 605 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) |
606 | { | ||
600 | text += QObject::tr( "<br><b>Home Address:</b>" ); | 607 | text += QObject::tr( "<br><b>Home Address:</b>" ); |
601 | marker = true; | 608 | marker = true; |
602 | } | 609 | } |
603 | 610 | ||
604 | if ( !(value = homeStreet()).isEmpty() ){ | 611 | if ( !( value = homeStreet() ).isEmpty() ) |
612 | { | ||
605 | text += "<br>" + Qtopia::escapeString(value); | 613 | text += "<br>" + Qtopia::escapeString(value); |
606 | marker = true; | 614 | marker = true; |
607 | } | 615 | } |
608 | 616 | ||
609 | switch( addressformat ){ | 617 | switch ( addressformat ) |
610 | case Zip_City_State:{ // Zip_Code City, State | 618 | { |
619 | case Zip_City_State: | ||
620 | { // Zip_Code City, State | ||
611 | state = homeState(); | 621 | state = homeState(); |
612 | if ( !(value = homeZip()).isEmpty() ){ | 622 | if ( !( value = homeZip() ).isEmpty() ) |
623 | { | ||
613 | text += "<br>" + Qtopia::escapeString(value) + " "; | 624 | text += "<br>" + Qtopia::escapeString(value) + " "; |
614 | marker = true; | 625 | marker = true; |
615 | } | 626 | } |
616 | if ( !(value = homeCity()).isEmpty() ) { | 627 | if ( !( value = homeCity() ).isEmpty() ) |
628 | { | ||
617 | marker = true; | 629 | marker = true; |
618 | if ( homeZip().isEmpty() && !homeStreet().isEmpty() ) | 630 | if ( homeZip().isEmpty() && !homeStreet().isEmpty() ) |
@@ -621,5 +633,7 @@ QString OContact::toRichText() const | |||
621 | if ( !state.isEmpty() ) | 633 | if ( !state.isEmpty() ) |
622 | text += ", " + Qtopia::escapeString(state); | 634 | text += ", " + Qtopia::escapeString(state); |
623 | } else if (!state.isEmpty()) { | 635 | } |
636 | else if ( !state.isEmpty() ) | ||
637 | { | ||
624 | text += "<br>" + Qtopia::escapeString(state); | 638 | text += "<br>" + Qtopia::escapeString(state); |
625 | marker = true; | 639 | marker = true; |
@@ -627,16 +641,21 @@ QString OContact::toRichText() const | |||
627 | break; | 641 | break; |
628 | } | 642 | } |
629 | case City_State_Zip:{ // City, State Zip_Code | 643 | case City_State_Zip: |
644 | { // City, State Zip_Code | ||
630 | state = homeState(); | 645 | state = homeState(); |
631 | if ( !(value = homeCity()).isEmpty() ) { | 646 | if ( !( value = homeCity() ).isEmpty() ) |
647 | { | ||
632 | marker = true; | 648 | marker = true; |
633 | text += "<br>" + Qtopia::escapeString(value); | 649 | text += "<br>" + Qtopia::escapeString(value); |
634 | if ( state ) | 650 | if ( state ) |
635 | text += ", " + Qtopia::escapeString(state); | 651 | text += ", " + Qtopia::escapeString(state); |
636 | } else if ( !state.isEmpty() ){ | 652 | } |
653 | else if ( !state.isEmpty() ) | ||
654 | { | ||
637 | text += "<br>" + Qtopia::escapeString(state); | 655 | text += "<br>" + Qtopia::escapeString(state); |
638 | marker = true; | 656 | marker = true; |
639 | } | 657 | } |
640 | if ( !(value = homeZip()).isEmpty() ){ | 658 | if ( !( value = homeZip() ).isEmpty() ) |
659 | { | ||
641 | text += " " + Qtopia::escapeString(value); | 660 | text += " " + Qtopia::escapeString(value); |
642 | marker = true; | 661 | marker = true; |
@@ -646,5 +665,6 @@ QString OContact::toRichText() const | |||
646 | } | 665 | } |
647 | 666 | ||
648 | if ( !(value = homeCountry()).isEmpty() ){ | 667 | if ( !( value = homeCountry() ).isEmpty() ) |
668 | { | ||
649 | text += "<br>" + Qtopia::escapeString(value); | 669 | text += "<br>" + Qtopia::escapeString(value); |
650 | marker = true; | 670 | marker = true; |
@@ -653,5 +673,6 @@ QString OContact::toRichText() const | |||
653 | // rest of Home data | 673 | // rest of Home data |
654 | str = homeWebpage(); | 674 | str = homeWebpage(); |
655 | if ( !str.isEmpty() ){ | 675 | if ( !str.isEmpty() ) |
676 | { | ||
656 | text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr("Home Web Page: ") + "</b>" | 677 | text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr("Home Web Page: ") + "</b>" |
657 | + Qtopia::escapeString(str); | 678 | + Qtopia::escapeString(str); |
@@ -659,5 +680,6 @@ QString OContact::toRichText() const | |||
659 | } | 680 | } |
660 | str = homePhone(); | 681 | str = homePhone(); |
661 | if ( !str.isEmpty() ){ | 682 | if ( !str.isEmpty() ) |
683 | { | ||
662 | text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr("Home Phone: ") + "</b>" | 684 | text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr("Home Phone: ") + "</b>" |
663 | + Qtopia::escapeString(str); | 685 | + Qtopia::escapeString(str); |
@@ -665,5 +687,6 @@ QString OContact::toRichText() const | |||
665 | } | 687 | } |
666 | str = homeFax(); | 688 | str = homeFax(); |
667 | if ( !str.isEmpty() ){ | 689 | if ( !str.isEmpty() ) |
690 | { | ||
668 | text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr("Home Fax: ") + "</b>" | 691 | text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr("Home Fax: ") + "</b>" |
669 | + Qtopia::escapeString(str); | 692 | + Qtopia::escapeString(str); |
@@ -671,5 +694,6 @@ QString OContact::toRichText() const | |||
671 | } | 694 | } |
672 | str = homeMobile(); | 695 | str = homeMobile(); |
673 | if ( !str.isEmpty() ){ | 696 | if ( !str.isEmpty() ) |
697 | { | ||
674 | text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>" | 698 | text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>" |
675 | + Qtopia::escapeString(str); | 699 | + Qtopia::escapeString(str); |
@@ -698,5 +722,6 @@ QString OContact::toRichText() const | |||
698 | + Qtopia::escapeString(str); | 722 | + Qtopia::escapeString(str); |
699 | str = gender(); | 723 | str = gender(); |
700 | if ( !str.isEmpty() && str.toInt() != 0 ) { | 724 | if ( !str.isEmpty() && str.toInt() != 0 ) |
725 | { | ||
701 | text += "<br>"; | 726 | text += "<br>"; |
702 | if ( str.toInt() == 1 ) | 727 | if ( str.toInt() == 1 ) |
@@ -710,10 +735,12 @@ QString OContact::toRichText() const | |||
710 | text += "<br><b>" + QObject::tr("Spouse: ") + "</b>" | 735 | text += "<br><b>" + QObject::tr("Spouse: ") + "</b>" |
711 | + Qtopia::escapeString(str); | 736 | + Qtopia::escapeString(str); |
712 | if ( birthday().isValid() ){ | 737 | if ( birthday().isValid() ) |
738 | { | ||
713 | str = TimeString::numberDateString( birthday() ); | 739 | str = TimeString::numberDateString( birthday() ); |
714 | text += "<br><b>" + QObject::tr("Birthday: ") + "</b>" | 740 | text += "<br><b>" + QObject::tr("Birthday: ") + "</b>" |
715 | + Qtopia::escapeString(str); | 741 | + Qtopia::escapeString(str); |
716 | } | 742 | } |
717 | if ( anniversary().isValid() ){ | 743 | if ( anniversary().isValid() ) |
744 | { | ||
718 | str = TimeString::numberDateString( anniversary() ); | 745 | str = TimeString::numberDateString( anniversary() ); |
719 | text += "<br><b>" + QObject::tr("Anniversary: ") + "</b>" | 746 | text += "<br><b>" + QObject::tr("Anniversary: ") + "</b>" |
@@ -731,5 +758,6 @@ QString OContact::toRichText() const | |||
731 | 758 | ||
732 | // categories | 759 | // categories |
733 | if ( categoryNames("Contacts").count() ){ | 760 | if ( categoryNames( "Contacts" ).count() ) |
761 | { | ||
734 | text += "<br><b>" + QObject::tr( "Category:") + "</b> "; | 762 | text += "<br><b>" + QObject::tr( "Category:") + "</b> "; |
735 | text += categoryNames("Contacts").join(", "); | 763 | text += categoryNames("Contacts").join(", "); |
@@ -737,5 +765,6 @@ QString OContact::toRichText() const | |||
737 | 765 | ||
738 | // notes last | 766 | // notes last |
739 | if ( !(value = notes()).isEmpty() ) { | 767 | if ( !( value = notes() ).isEmpty() ) |
768 | { | ||
740 | text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; | 769 | text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; |
741 | QRegExp reg("\n"); | 770 | QRegExp reg("\n"); |
@@ -838,20 +867,24 @@ QString OContact::fullName() const | |||
838 | 867 | ||
839 | QString name = title; | 868 | QString name = title; |
840 | if ( !firstName.isEmpty() ) { | 869 | if ( !firstName.isEmpty() ) |
870 | { | ||
841 | if ( !name.isEmpty() ) | 871 | if ( !name.isEmpty() ) |
842 | name += " "; | 872 | name += " "; |
843 | name += firstName; | 873 | name += firstName; |
844 | } | 874 | } |
845 | if ( !middleName.isEmpty() ) { | 875 | if ( !middleName.isEmpty() ) |
876 | { | ||
846 | if ( !name.isEmpty() ) | 877 | if ( !name.isEmpty() ) |
847 | name += " "; | 878 | name += " "; |
848 | name += middleName; | 879 | name += middleName; |
849 | } | 880 | } |
850 | if ( !lastName.isEmpty() ) { | 881 | if ( !lastName.isEmpty() ) |
882 | { | ||
851 | if ( !name.isEmpty() ) | 883 | if ( !name.isEmpty() ) |
852 | name += " "; | 884 | name += " "; |
853 | name += lastName; | 885 | name += lastName; |
854 | } | 886 | } |
855 | if ( !suffix.isEmpty() ) { | 887 | if ( !suffix.isEmpty() ) |
888 | { | ||
856 | if ( !name.isEmpty() ) | 889 | if ( !name.isEmpty() ) |
857 | name += " "; | 890 | name += " "; |
@@ -901,5 +934,6 @@ QStringList OContact::emailList() const | |||
901 | 934 | ||
902 | QStringList r; | 935 | QStringList r; |
903 | if ( !emailStr.isEmpty() ) { | 936 | if ( !emailStr.isEmpty() ) |
937 | { | ||
904 | qDebug(" emailstr "); | 938 | qDebug(" emailstr "); |
905 | QStringList l = QStringList::split( emailSeparator(), emailStr ); | 939 | QStringList l = QStringList::split( emailSeparator(), emailStr ); |
@@ -947,8 +981,10 @@ void OContact::save( QString &buf ) const | |||
947 | // I'm expecting "<Contact " in front of this... | 981 | // I'm expecting "<Contact " in front of this... |
948 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); | 982 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); |
949 | it != mMap.end(); ++it ) { | 983 | it != mMap.end(); ++it ) |
984 | { | ||
950 | const QString &value = it.data(); | 985 | const QString &value = it.data(); |
951 | int key = it.key(); | 986 | int key = it.key(); |
952 | if ( !value.isEmpty() ) { | 987 | if ( !value.isEmpty() ) |
988 | { | ||
953 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) | 989 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) |
954 | continue; | 990 | continue; |
@@ -1062,6 +1098,8 @@ bool OContact::match( const QRegExp &r ) const | |||
1062 | match = false; | 1098 | match = false; |
1063 | QMap<int, QString>::ConstIterator it; | 1099 | QMap<int, QString>::ConstIterator it; |
1064 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 1100 | for ( it = mMap.begin(); it != mMap.end(); ++it ) |
1065 | if ( (*it).find( r ) > -1 ) { | 1101 | { |
1102 | if ( ( *it ).find( r ) > -1 ) | ||
1103 | { | ||
1066 | setLastHitField( it.key() ); | 1104 | setLastHitField( it.key() ); |
1067 | match = true; | 1105 | match = true; |
@@ -1077,4 +1115,6 @@ QString OContact::toShortText() const | |||
1077 | return ( fullName() ); | 1115 | return ( fullName() ); |
1078 | } | 1116 | } |
1117 | |||
1118 | |||
1079 | QString OContact::type() const | 1119 | QString OContact::type() const |
1080 | { | 1120 | { |
@@ -1083,5 +1123,4 @@ QString OContact::type() const | |||
1083 | 1123 | ||
1084 | 1124 | ||
1085 | |||
1086 | class QString OContact::recordField( int pos ) const | 1125 | class QString OContact::recordField( int pos ) const |
1087 | { | 1126 | { |
@@ -1100,5 +1139,6 @@ class QString OContact::recordField( int pos ) const | |||
1100 | void OContact::setBirthday( const QDate &v ) | 1139 | void OContact::setBirthday( const QDate &v ) |
1101 | { | 1140 | { |
1102 | if ( v.isNull() ){ | 1141 | if ( v.isNull() ) |
1142 | { | ||
1103 | qWarning( "Remove Birthday"); | 1143 | qWarning( "Remove Birthday"); |
1104 | replace( Qtopia::Birthday, QString::null ); | 1144 | replace( Qtopia::Birthday, QString::null ); |
@@ -1118,5 +1158,6 @@ void OContact::setBirthday( const QDate &v ) | |||
1118 | void OContact::setAnniversary( const QDate &v ) | 1158 | void OContact::setAnniversary( const QDate &v ) |
1119 | { | 1159 | { |
1120 | if ( v.isNull() ){ | 1160 | if ( v.isNull() ) |
1161 | { | ||
1121 | qWarning( "Remove Anniversary"); | 1162 | qWarning( "Remove Anniversary"); |
1122 | replace( Qtopia::Anniversary, QString::null ); | 1163 | replace( Qtopia::Anniversary, QString::null ); |
@@ -1128,4 +1169,5 @@ void OContact::setAnniversary( const QDate &v ) | |||
1128 | } | 1169 | } |
1129 | 1170 | ||
1171 | |||
1130 | /*! \fn QDate OContact::birthday() const | 1172 | /*! \fn QDate OContact::birthday() const |
1131 | Returns the birthday of the contact. | 1173 | Returns the birthday of the contact. |
@@ -1164,5 +1206,6 @@ void OContact::insertEmail( const QString &v ) | |||
1164 | 1206 | ||
1165 | // if no default, set it as the default email and don't insert | 1207 | // if no default, set it as the default email and don't insert |
1166 | if ( def.isEmpty() ) { | 1208 | if ( def.isEmpty() ) |
1209 | { | ||
1167 | setDefaultEmail( e ); // will insert into the list for us | 1210 | setDefaultEmail( e ); // will insert into the list for us |
1168 | return; | 1211 | return; |
@@ -1179,4 +1222,5 @@ void OContact::insertEmail( const QString &v ) | |||
1179 | } | 1222 | } |
1180 | 1223 | ||
1224 | |||
1181 | void OContact::removeEmail( const QString &v ) | 1225 | void OContact::removeEmail( const QString &v ) |
1182 | { | 1226 | { |
@@ -1198,5 +1242,6 @@ void OContact::removeEmail( const QString &v ) | |||
1198 | 1242 | ||
1199 | // if default, then replace the default email with the first one | 1243 | // if default, then replace the default email with the first one |
1200 | if ( def == e ) { | 1244 | if ( def == e ) |
1245 | { | ||
1201 | //qDebug("removeEmail is default; setting new default"); | 1246 | //qDebug("removeEmail is default; setting new default"); |
1202 | if ( !emails.count() ) | 1247 | if ( !emails.count() ) |
@@ -1206,4 +1251,6 @@ void OContact::removeEmail( const QString &v ) | |||
1206 | } | 1251 | } |
1207 | } | 1252 | } |
1253 | |||
1254 | |||
1208 | void OContact::clearEmails() | 1255 | void OContact::clearEmails() |
1209 | { | 1256 | { |
@@ -1211,4 +1258,6 @@ void OContact::clearEmails() | |||
1211 | mMap.remove( Qtopia::Emails ); | 1258 | mMap.remove( Qtopia::Emails ); |
1212 | } | 1259 | } |
1260 | |||
1261 | |||
1213 | void OContact::setDefaultEmail( const QString &v ) | 1262 | void OContact::setDefaultEmail( const QString &v ) |
1214 | { | 1263 | { |
@@ -1223,4 +1272,5 @@ void OContact::setDefaultEmail( const QString &v ) | |||
1223 | } | 1272 | } |
1224 | 1273 | ||
1274 | |||
1225 | void OContact::insertEmails( const QStringList &v ) | 1275 | void OContact::insertEmails( const QStringList &v ) |
1226 | { | 1276 | { |
@@ -1228,7 +1278,12 @@ void OContact::insertEmails( const QStringList &v ) | |||
1228 | insertEmail( *it ); | 1278 | insertEmail( *it ); |
1229 | } | 1279 | } |
1230 | int OContact::rtti() { | 1280 | |
1281 | |||
1282 | int OContact::rtti() | ||
1283 | { | ||
1231 | return OPimResolver::AddressBook; | 1284 | return OPimResolver::AddressBook; |
1232 | } | 1285 | } |
1286 | |||
1287 | |||
1233 | void OContact::setUid( int i ) | 1288 | void OContact::setUid( int i ) |
1234 | { | 1289 | { |