-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,9 +1,9 @@ | |||
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. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
@@ -24,47 +24,31 @@ | |||
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
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> |
61 | #include <qstylesheet.h> | 44 | #include <qstylesheet.h> |
62 | #include <qfileinfo.h> | 45 | #include <qfileinfo.h> |
63 | #include <qmap.h> | 46 | #include <qmap.h> |
64 | 47 | ||
48 | /* STD */ | ||
65 | #include <stdio.h> | 49 | #include <stdio.h> |
66 | 50 | ||
67 | /*! | 51 | /*! |
68 | \class Contact contact.h | 52 | \class Contact contact.h |
69 | \brief The Contact class holds the data of an address book entry. | 53 | \brief The Contact class holds the data of an address book entry. |
70 | 54 | ||
@@ -73,51 +57,50 @@ | |||
73 | 57 | ||
74 | \ingroup qtopiaemb | 58 | \ingroup qtopiaemb |
75 | \ingroup qtopiadesktop | 59 | \ingroup qtopiadesktop |
76 | */ | 60 | */ |
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 | /*! |
89 | \internal | 72 | \internal |
90 | Creates a new contact. The properties of the contact are | 73 | Creates a new contact. The properties of the contact are |
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 ]; |
97 | if ( !cats.isEmpty() ) | 79 | if ( !cats.isEmpty() ) |
98 | setCategories( idsFromString( cats ) ); | 80 | setCategories( idsFromString( cats ) ); |
99 | 81 | ||
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 | ||
108 | // if ( !uidStr.isEmpty() ) | 92 | // if ( !uidStr.isEmpty() ) |
109 | // setUid( uidStr.toInt() ); | 93 | // setUid( uidStr.toInt() ); |
110 | } | 94 | } |
111 | 95 | ||
112 | /*! | 96 | /*! |
113 | Destroys a contact. | 97 | Destroys a contact. |
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 ) |
120 | Sets the title of the contact to \a str. | 103 | Sets the title of the contact to \a str. |
121 | */ | 104 | */ |
122 | 105 | ||
123 | /*! \fn void OContact::setFirstName( const QString &str ) | 106 | /*! \fn void OContact::setFirstName( const QString &str ) |
@@ -478,202 +461,243 @@ QString OContact::toRichText() const | |||
478 | text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString(value) + "</h3></b>"; | 461 | text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString(value) + "</h3></b>"; |
479 | 462 | ||
480 | if ( !(value = jobTitle()).isEmpty() ) | 463 | if ( !(value = jobTitle()).isEmpty() ) |
481 | text += Qtopia::escapeString(value) + " "; | 464 | text += Qtopia::escapeString(value) + " "; |
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>"; |
491 | 476 | ||
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); |
497 | marker = true; | 483 | marker = true; |
498 | } | 484 | } |
499 | 485 | ||
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() ) |
523 | text += "<br>"; | 515 | text += "<br>"; |
524 | text += Qtopia::escapeString(value); | 516 | text += Qtopia::escapeString(value); |
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; |
530 | } | 524 | } |
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; |
547 | } | 546 | } |
548 | break; | 547 | break; |
549 | } | 548 | } |
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; |
555 | } | 555 | } |
556 | 556 | ||
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); |
562 | marker = true; | 563 | marker = true; |
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); |
568 | marker = true; | 570 | marker = true; |
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); |
574 | marker = true; | 577 | marker = true; |
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); |
580 | marker = true; | 584 | marker = true; |
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); |
586 | marker = true; | 591 | marker = true; |
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); |
592 | marker = true; | 598 | marker = true; |
593 | } | 599 | } |
594 | 600 | ||
595 | // text += "<br>"; | 601 | // text += "<br>"; |
596 | 602 | ||
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() ) |
619 | text += "<br>"; | 631 | text += "<br>"; |
620 | text += Qtopia::escapeString(value); | 632 | text += Qtopia::escapeString(value); |
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; |
626 | } | 640 | } |
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; |
643 | } | 662 | } |
644 | break; | 663 | break; |
645 | } | 664 | } |
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; |
651 | } | 671 | } |
652 | 672 | ||
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); |
658 | marker = true; | 679 | marker = true; |
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); |
664 | marker = true; | 686 | marker = true; |
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); |
670 | marker = true; | 693 | marker = true; |
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); |
676 | marker = true; | 700 | marker = true; |
677 | } | 701 | } |
678 | 702 | ||
679 | if ( marker ) | 703 | if ( marker ) |
@@ -694,30 +718,33 @@ QString OContact::toRichText() const | |||
694 | + Qtopia::escapeString(str); | 718 | + Qtopia::escapeString(str); |
695 | str = manager(); | 719 | str = manager(); |
696 | if ( !str.isEmpty() ) | 720 | if ( !str.isEmpty() ) |
697 | text += "<br><b>" + QObject::tr("Manager: ") + "</b>" | 721 | text += "<br><b>" + QObject::tr("Manager: ") + "</b>" |
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 ) |
703 | str = QObject::tr( "Male" ); | 728 | str = QObject::tr( "Male" ); |
704 | else if ( str.toInt() == 2 ) | 729 | else if ( str.toInt() == 2 ) |
705 | str = QObject::tr( "Female" ); | 730 | str = QObject::tr( "Female" ); |
706 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str; | 731 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str; |
707 | } | 732 | } |
708 | str = spouse(); | 733 | str = spouse(); |
709 | if ( !str.isEmpty() ) | 734 | if ( !str.isEmpty() ) |
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>" |
720 | + Qtopia::escapeString(str); | 747 | + Qtopia::escapeString(str); |
721 | } | 748 | } |
722 | str = children(); | 749 | str = children(); |
723 | if ( !str.isEmpty() ) | 750 | if ( !str.isEmpty() ) |
@@ -727,19 +754,21 @@ QString OContact::toRichText() const | |||
727 | str = nickname(); | 754 | str = nickname(); |
728 | if ( !str.isEmpty() ) | 755 | if ( !str.isEmpty() ) |
729 | text += "<br><b>" + QObject::tr("Nickname: ") + "</b>" | 756 | text += "<br><b>" + QObject::tr("Nickname: ") + "</b>" |
730 | + Qtopia::escapeString(str); | 757 | + Qtopia::escapeString(str); |
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(", "); |
736 | } | 764 | } |
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"); |
742 | 771 | ||
743 | //QString tmp = Qtopia::escapeString(value); | 772 | //QString tmp = Qtopia::escapeString(value); |
744 | QString tmp = QStyleSheet::convertFromPlainText(value); | 773 | QString tmp = QStyleSheet::convertFromPlainText(value); |
745 | //tmp.replace( reg, "<br>" ); | 774 | //tmp.replace( reg, "<br>" ); |
@@ -834,28 +863,32 @@ QString OContact::fullName() const | |||
834 | QString firstName = find( Qtopia::FirstName ); | 863 | QString firstName = find( Qtopia::FirstName ); |
835 | QString middleName = find( Qtopia::MiddleName ); | 864 | QString middleName = find( Qtopia::MiddleName ); |
836 | QString lastName = find( Qtopia::LastName ); | 865 | QString lastName = find( Qtopia::LastName ); |
837 | QString suffix = find( Qtopia::Suffix ); | 866 | QString suffix = find( Qtopia::Suffix ); |
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 += " "; |
858 | name += suffix; | 891 | name += suffix; |
859 | } | 892 | } |
860 | return name.simplifyWhiteSpace(); | 893 | return name.simplifyWhiteSpace(); |
861 | } | 894 | } |
@@ -897,13 +930,14 @@ QStringList OContact::childrenList() const | |||
897 | */ | 930 | */ |
898 | QStringList OContact::emailList() const | 931 | QStringList OContact::emailList() const |
899 | { | 932 | { |
900 | QString emailStr = emails(); | 933 | QString emailStr = emails(); |
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 ); |
906 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) | 940 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) |
907 | r += (*it).simplifyWhiteSpace(); | 941 | r += (*it).simplifyWhiteSpace(); |
908 | } | 942 | } |
909 | 943 | ||
@@ -943,16 +977,18 @@ void OContact::setFileAs() | |||
943 | */ | 977 | */ |
944 | void OContact::save( QString &buf ) const | 978 | void OContact::save( QString &buf ) const |
945 | { | 979 | { |
946 | static const QStringList SLFIELDS = fields(); | 980 | static const QStringList SLFIELDS = fields(); |
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; |
955 | 991 | ||
956 | key -= Qtopia::AddressCategory+1; | 992 | key -= Qtopia::AddressCategory+1; |
957 | buf += SLFIELDS[key]; | 993 | buf += SLFIELDS[key]; |
958 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 994 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; |
@@ -1058,14 +1094,16 @@ void OContact::setChildren( const QString &str ) | |||
1058 | bool OContact::match( const QRegExp &r ) const | 1094 | bool OContact::match( const QRegExp &r ) const |
1059 | { | 1095 | { |
1060 | setLastHitField( -1 ); | 1096 | setLastHitField( -1 ); |
1061 | bool match; | 1097 | bool match; |
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; |
1068 | break; | 1106 | break; |
1069 | } | 1107 | } |
1070 | } | 1108 | } |
1071 | return match; | 1109 | return match; |
@@ -1073,19 +1111,20 @@ bool OContact::match( const QRegExp &r ) const | |||
1073 | 1111 | ||
1074 | 1112 | ||
1075 | QString OContact::toShortText() const | 1113 | QString OContact::toShortText() const |
1076 | { | 1114 | { |
1077 | return ( fullName() ); | 1115 | return ( fullName() ); |
1078 | } | 1116 | } |
1117 | |||
1118 | |||
1079 | QString OContact::type() const | 1119 | QString OContact::type() const |
1080 | { | 1120 | { |
1081 | return QString::fromLatin1( "OContact" ); | 1121 | return QString::fromLatin1( "OContact" ); |
1082 | } | 1122 | } |
1083 | 1123 | ||
1084 | 1124 | ||
1085 | |||
1086 | class QString OContact::recordField( int pos ) const | 1125 | class QString OContact::recordField( int pos ) const |
1087 | { | 1126 | { |
1088 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 1127 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
1089 | return SLFIELDS[pos]; | 1128 | return SLFIELDS[pos]; |
1090 | } | 1129 | } |
1091 | 1130 | ||
@@ -1096,13 +1135,14 @@ class QString OContact::recordField( int pos ) const | |||
1096 | /*! \fn void OContact::setBirthday( const QDate& date ) | 1135 | /*! \fn void OContact::setBirthday( const QDate& date ) |
1097 | Sets the birthday for the contact to \a date. If date is null | 1136 | Sets the birthday for the contact to \a date. If date is null |
1098 | the current stored date will be removed. | 1137 | the current stored date will be removed. |
1099 | */ | 1138 | */ |
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 ); |
1105 | return; | 1145 | return; |
1106 | } | 1146 | } |
1107 | 1147 | ||
1108 | if ( v.isValid() ) | 1148 | if ( v.isValid() ) |
@@ -1114,22 +1154,24 @@ void OContact::setBirthday( const QDate &v ) | |||
1114 | /*! \fn void OContact::setAnniversary( const QDate &date ) | 1154 | /*! \fn void OContact::setAnniversary( const QDate &date ) |
1115 | Sets the anniversary of the contact to \a date. If date is | 1155 | Sets the anniversary of the contact to \a date. If date is |
1116 | null, the current stored date will be removed. | 1156 | null, the current stored date will be removed. |
1117 | */ | 1157 | */ |
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 ); |
1123 | return; | 1164 | return; |
1124 | } | 1165 | } |
1125 | 1166 | ||
1126 | if ( v.isValid() ) | 1167 | if ( v.isValid() ) |
1127 | replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); | 1168 | replace( Qtopia::Anniversary, OConversion::dateToString( 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. |
1132 | */ | 1174 | */ |
1133 | QDate OContact::birthday() const | 1175 | QDate OContact::birthday() const |
1134 | { | 1176 | { |
1135 | QString str = find( Qtopia::Birthday ); | 1177 | QString str = find( Qtopia::Birthday ); |
@@ -1160,13 +1202,14 @@ void OContact::insertEmail( const QString &v ) | |||
1160 | { | 1202 | { |
1161 | //qDebug("insertEmail %s", v.latin1()); | 1203 | //qDebug("insertEmail %s", v.latin1()); |
1162 | QString e = v.simplifyWhiteSpace(); | 1204 | QString e = v.simplifyWhiteSpace(); |
1163 | QString def = defaultEmail(); | 1205 | QString def = defaultEmail(); |
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; |
1169 | } | 1212 | } |
1170 | 1213 | ||
1171 | // otherwise, insert assuming doesn't already exist | 1214 | // otherwise, insert assuming doesn't already exist |
1172 | QString emailsStr = find( Qtopia::Emails ); | 1215 | QString emailsStr = find( Qtopia::Emails ); |
@@ -1175,12 +1218,13 @@ void OContact::insertEmail( const QString &v ) | |||
1175 | if ( !emailsStr.isEmpty() ) | 1218 | if ( !emailsStr.isEmpty() ) |
1176 | emailsStr += emailSeparator(); | 1219 | emailsStr += emailSeparator(); |
1177 | emailsStr += e; | 1220 | emailsStr += e; |
1178 | replace( Qtopia::Emails, emailsStr ); | 1221 | replace( Qtopia::Emails, emailsStr ); |
1179 | } | 1222 | } |
1180 | 1223 | ||
1224 | |||
1181 | void OContact::removeEmail( const QString &v ) | 1225 | void OContact::removeEmail( const QString &v ) |
1182 | { | 1226 | { |
1183 | QString e = v.simplifyWhiteSpace(); | 1227 | QString e = v.simplifyWhiteSpace(); |
1184 | QString def = defaultEmail(); | 1228 | QString def = defaultEmail(); |
1185 | QString emailsStr = find( Qtopia::Emails ); | 1229 | QString emailsStr = find( Qtopia::Emails ); |
1186 | QStringList emails = emailList(); | 1230 | QStringList emails = emailList(); |
@@ -1194,45 +1238,56 @@ void OContact::removeEmail( const QString &v ) | |||
1194 | emails.remove( e ); | 1238 | emails.remove( e ); |
1195 | // reset the string | 1239 | // reset the string |
1196 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator | 1240 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator |
1197 | replace( Qtopia::Emails, emailsStr ); | 1241 | replace( Qtopia::Emails, emailsStr ); |
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() ) |
1203 | clearEmails(); | 1248 | clearEmails(); |
1204 | else // setDefaultEmail will remove e from the list | 1249 | else // setDefaultEmail will remove e from the list |
1205 | setDefaultEmail( emails.first() ); | 1250 | setDefaultEmail( emails.first() ); |
1206 | } | 1251 | } |
1207 | } | 1252 | } |
1253 | |||
1254 | |||
1208 | void OContact::clearEmails() | 1255 | void OContact::clearEmails() |
1209 | { | 1256 | { |
1210 | mMap.remove( Qtopia::DefaultEmail ); | 1257 | mMap.remove( Qtopia::DefaultEmail ); |
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 | { |
1215 | QString e = v.simplifyWhiteSpace(); | 1264 | QString e = v.simplifyWhiteSpace(); |
1216 | 1265 | ||
1217 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); | 1266 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); |
1218 | replace( Qtopia::DefaultEmail, e ); | 1267 | replace( Qtopia::DefaultEmail, e ); |
1219 | 1268 | ||
1220 | if ( !e.isEmpty() ) | 1269 | if ( !e.isEmpty() ) |
1221 | insertEmail( e ); | 1270 | insertEmail( e ); |
1222 | 1271 | ||
1223 | } | 1272 | } |
1224 | 1273 | ||
1274 | |||
1225 | void OContact::insertEmails( const QStringList &v ) | 1275 | void OContact::insertEmails( const QStringList &v ) |
1226 | { | 1276 | { |
1227 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) | 1277 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) |
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 | { |
1235 | OPimRecord::setUid(i); | 1290 | OPimRecord::setUid(i); |
1236 | replace( Qtopia::AddressUid , QString::number(i)); | 1291 | replace( Qtopia::AddressUid , QString::number(i)); |
1237 | } | 1292 | } |
1238 | } | 1293 | } |