Diffstat (limited to 'libopie2/opiepim/ocontact.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index 6aec62e..38cba72 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp | |||
@@ -1,120 +1,121 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file is part of the Qtopia Environment. | 5 | ** This file is part of the Qtopia Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #define QTOPIA_INTERNAL_CONTACT_MRE | 22 | #define QTOPIA_INTERNAL_CONTACT_MRE |
23 | 23 | ||
24 | #include "ocontact.h" | 24 | #include "ocontact.h" |
25 | #include "opimresolver.h" | ||
25 | 26 | ||
26 | #include <qpe/stringutil.h> | 27 | #include <qpe/stringutil.h> |
27 | #include <qpe/timeconversion.h> | 28 | #include <qpe/timeconversion.h> |
28 | #include <qpe/timestring.h> | 29 | #include <qpe/timestring.h> |
29 | 30 | ||
30 | #include <qobject.h> | 31 | #include <qobject.h> |
31 | #include <qregexp.h> | 32 | #include <qregexp.h> |
32 | #include <qstylesheet.h> | 33 | #include <qstylesheet.h> |
33 | #include <qfileinfo.h> | 34 | #include <qfileinfo.h> |
34 | #include <qmap.h> | 35 | #include <qmap.h> |
35 | 36 | ||
36 | #include <stdio.h> | 37 | #include <stdio.h> |
37 | 38 | ||
38 | /*! | 39 | /*! |
39 | \class Contact contact.h | 40 | \class Contact contact.h |
40 | \brief The Contact class holds the data of an address book entry. | 41 | \brief The Contact class holds the data of an address book entry. |
41 | 42 | ||
42 | This data includes information the name of the person, contact | 43 | This data includes information the name of the person, contact |
43 | information, and business information such as deparment and job title. | 44 | information, and business information such as deparment and job title. |
44 | 45 | ||
45 | \ingroup qtopiaemb | 46 | \ingroup qtopiaemb |
46 | \ingroup qtopiadesktop | 47 | \ingroup qtopiadesktop |
47 | */ | 48 | */ |
48 | 49 | ||
49 | 50 | ||
50 | /*! | 51 | /*! |
51 | Creates a new, empty contact. | 52 | Creates a new, empty contact. |
52 | */ | 53 | */ |
53 | OContact::OContact() | 54 | OContact::OContact() |
54 | : OPimRecord(), mMap(), d( 0 ) | 55 | : OPimRecord(), mMap(), d( 0 ) |
55 | { | 56 | { |
56 | } | 57 | } |
57 | 58 | ||
58 | /*! | 59 | /*! |
59 | \internal | 60 | \internal |
60 | Creates a new contact. The properties of the contact are | 61 | Creates a new contact. The properties of the contact are |
61 | set from \a fromMap. | 62 | set from \a fromMap. |
62 | */ | 63 | */ |
63 | OContact::OContact( const QMap<int, QString> &fromMap ) : | 64 | OContact::OContact( const QMap<int, QString> &fromMap ) : |
64 | OPimRecord(), mMap( fromMap ), d( 0 ) | 65 | OPimRecord(), mMap( fromMap ), d( 0 ) |
65 | { | 66 | { |
66 | QString cats = mMap[ Qtopia::AddressCategory ]; | 67 | QString cats = mMap[ Qtopia::AddressCategory ]; |
67 | if ( !cats.isEmpty() ) | 68 | if ( !cats.isEmpty() ) |
68 | setCategories( idsFromString( cats ) ); | 69 | setCategories( idsFromString( cats ) ); |
69 | 70 | ||
70 | QString uidStr = find( Qtopia::AddressUid ); | 71 | QString uidStr = find( Qtopia::AddressUid ); |
71 | 72 | ||
72 | if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ | 73 | if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ |
73 | qWarning( "Invalid UID found. Generate new one.." ); | 74 | qWarning( "Invalid UID found. Generate new one.." ); |
74 | setUid( uidGen().generate() ); | 75 | setUid( uidGen().generate() ); |
75 | }else | 76 | }else |
76 | setUid( uidStr.toInt() ); | 77 | setUid( uidStr.toInt() ); |
77 | 78 | ||
78 | // if ( !uidStr.isEmpty() ) | 79 | // if ( !uidStr.isEmpty() ) |
79 | // setUid( uidStr.toInt() ); | 80 | // setUid( uidStr.toInt() ); |
80 | } | 81 | } |
81 | 82 | ||
82 | /*! | 83 | /*! |
83 | Destroys a contact. | 84 | Destroys a contact. |
84 | */ | 85 | */ |
85 | OContact::~OContact() | 86 | OContact::~OContact() |
86 | { | 87 | { |
87 | } | 88 | } |
88 | 89 | ||
89 | /*! \fn void OContact::setTitle( const QString &str ) | 90 | /*! \fn void OContact::setTitle( const QString &str ) |
90 | Sets the title of the contact to \a str. | 91 | Sets the title of the contact to \a str. |
91 | */ | 92 | */ |
92 | 93 | ||
93 | /*! \fn void OContact::setFirstName( const QString &str ) | 94 | /*! \fn void OContact::setFirstName( const QString &str ) |
94 | Sets the first name of the contact to \a str. | 95 | Sets the first name of the contact to \a str. |
95 | */ | 96 | */ |
96 | 97 | ||
97 | /*! \fn void OContact::setMiddleName( const QString &str ) | 98 | /*! \fn void OContact::setMiddleName( const QString &str ) |
98 | Sets the middle name of the contact to \a str. | 99 | Sets the middle name of the contact to \a str. |
99 | */ | 100 | */ |
100 | 101 | ||
101 | /*! \fn void OContact::setLastName( const QString &str ) | 102 | /*! \fn void OContact::setLastName( const QString &str ) |
102 | Sets the last name of the contact to \a str. | 103 | Sets the last name of the contact to \a str. |
103 | */ | 104 | */ |
104 | 105 | ||
105 | /*! \fn void OContact::setSuffix( const QString &str ) | 106 | /*! \fn void OContact::setSuffix( const QString &str ) |
106 | Sets the suffix of the contact to \a str. | 107 | Sets the suffix of the contact to \a str. |
107 | */ | 108 | */ |
108 | 109 | ||
109 | /*! \fn void OContact::setFileAs( const QString &str ) | 110 | /*! \fn void OContact::setFileAs( const QString &str ) |
110 | Sets the contact to filed as \a str. | 111 | Sets the contact to filed as \a str. |
111 | */ | 112 | */ |
112 | 113 | ||
113 | /*! \fn void OContact::setDefaultEmail( const QString &str ) | 114 | /*! \fn void OContact::setDefaultEmail( const QString &str ) |
114 | Sets the default email of the contact to \a str. | 115 | Sets the default email of the contact to \a str. |
115 | */ | 116 | */ |
116 | 117 | ||
117 | /*! \fn void OContact::setHomeStreet( const QString &str ) | 118 | /*! \fn void OContact::setHomeStreet( const QString &str ) |
118 | Sets the home street address of the contact to \a str. | 119 | Sets the home street address of the contact to \a str. |
119 | */ | 120 | */ |
120 | 121 | ||
@@ -736,193 +737,193 @@ QStringList OContact::childrenList() const | |||
736 | /*! \fn void OContact::removeEmail( const QString &email ) | 737 | /*! \fn void OContact::removeEmail( const QString &email ) |
737 | 738 | ||
738 | Removes the \a email from the email list. If the default email was \a email, | 739 | Removes the \a email from the email list. If the default email was \a email, |
739 | then the default email address is assigned to the first email in the | 740 | then the default email address is assigned to the first email in the |
740 | email list | 741 | email list |
741 | */ | 742 | */ |
742 | 743 | ||
743 | /*! \fn void OContact::clearEmails() | 744 | /*! \fn void OContact::clearEmails() |
744 | 745 | ||
745 | Clears the email list. | 746 | Clears the email list. |
746 | */ | 747 | */ |
747 | 748 | ||
748 | /*! \fn void OContact::insertEmails( const QStringList &emailList ) | 749 | /*! \fn void OContact::insertEmails( const QStringList &emailList ) |
749 | 750 | ||
750 | Appends the \a emailList to the exiting email list | 751 | Appends the \a emailList to the exiting email list |
751 | */ | 752 | */ |
752 | 753 | ||
753 | /*! | 754 | /*! |
754 | Returns a list of email addresses belonging to the contact, including | 755 | Returns a list of email addresses belonging to the contact, including |
755 | the default email address. | 756 | the default email address. |
756 | */ | 757 | */ |
757 | QStringList OContact::emailList() const | 758 | QStringList OContact::emailList() const |
758 | { | 759 | { |
759 | QString emailStr = emails(); | 760 | QString emailStr = emails(); |
760 | 761 | ||
761 | QStringList r; | 762 | QStringList r; |
762 | if ( !emailStr.isEmpty() ) { | 763 | if ( !emailStr.isEmpty() ) { |
763 | qDebug(" emailstr "); | 764 | qDebug(" emailstr "); |
764 | QStringList l = QStringList::split( emailSeparator(), emailStr ); | 765 | QStringList l = QStringList::split( emailSeparator(), emailStr ); |
765 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) | 766 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) |
766 | r += (*it).simplifyWhiteSpace(); | 767 | r += (*it).simplifyWhiteSpace(); |
767 | } | 768 | } |
768 | 769 | ||
769 | return r; | 770 | return r; |
770 | } | 771 | } |
771 | 772 | ||
772 | /*! | 773 | /*! |
773 | \overload | 774 | \overload |
774 | 775 | ||
775 | Generates the string for the contact to be filed as from the first, | 776 | Generates the string for the contact to be filed as from the first, |
776 | middle and last name of the contact. | 777 | middle and last name of the contact. |
777 | */ | 778 | */ |
778 | void OContact::setFileAs() | 779 | void OContact::setFileAs() |
779 | { | 780 | { |
780 | QString lastName, firstName, middleName, fileas; | 781 | QString lastName, firstName, middleName, fileas; |
781 | 782 | ||
782 | lastName = find( Qtopia::LastName ); | 783 | lastName = find( Qtopia::LastName ); |
783 | firstName = find( Qtopia::FirstName ); | 784 | firstName = find( Qtopia::FirstName ); |
784 | middleName = find( Qtopia::MiddleName ); | 785 | middleName = find( Qtopia::MiddleName ); |
785 | if ( !lastName.isEmpty() && !firstName.isEmpty() | 786 | if ( !lastName.isEmpty() && !firstName.isEmpty() |
786 | && !middleName.isEmpty() ) | 787 | && !middleName.isEmpty() ) |
787 | fileas = lastName + ", " + firstName + " " + middleName; | 788 | fileas = lastName + ", " + firstName + " " + middleName; |
788 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) | 789 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) |
789 | fileas = lastName + ", " + firstName; | 790 | fileas = lastName + ", " + firstName; |
790 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || | 791 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || |
791 | !middleName.isEmpty() ) | 792 | !middleName.isEmpty() ) |
792 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) | 793 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) |
793 | + middleName + ( middleName.isEmpty() ? "" : " " ) | 794 | + middleName + ( middleName.isEmpty() ? "" : " " ) |
794 | + lastName; | 795 | + lastName; |
795 | 796 | ||
796 | replace( Qtopia::FileAs, fileas ); | 797 | replace( Qtopia::FileAs, fileas ); |
797 | } | 798 | } |
798 | 799 | ||
799 | /*! | 800 | /*! |
800 | \internal | 801 | \internal |
801 | Appends the contact information to \a buf. | 802 | Appends the contact information to \a buf. |
802 | */ | 803 | */ |
803 | void OContact::save( QString &buf ) const | 804 | void OContact::save( QString &buf ) const |
804 | { | 805 | { |
805 | static const QStringList SLFIELDS = fields(); | 806 | static const QStringList SLFIELDS = fields(); |
806 | // I'm expecting "<Contact " in front of this... | 807 | // I'm expecting "<Contact " in front of this... |
807 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); | 808 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); |
808 | it != mMap.end(); ++it ) { | 809 | it != mMap.end(); ++it ) { |
809 | const QString &value = it.data(); | 810 | const QString &value = it.data(); |
810 | int key = it.key(); | 811 | int key = it.key(); |
811 | if ( !value.isEmpty() ) { | 812 | if ( !value.isEmpty() ) { |
812 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) | 813 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) |
813 | continue; | 814 | continue; |
814 | 815 | ||
815 | key -= Qtopia::AddressCategory+1; | 816 | key -= Qtopia::AddressCategory+1; |
816 | buf += SLFIELDS[key]; | 817 | buf += SLFIELDS[key]; |
817 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 818 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; |
818 | } | 819 | } |
819 | } | 820 | } |
820 | buf += customToXml(); | 821 | buf += customToXml(); |
821 | if ( categories().count() > 0 ) | 822 | if ( categories().count() > 0 ) |
822 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 823 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
823 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 824 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
824 | // You need to close this yourself | 825 | // You need to close this yourself |
825 | } | 826 | } |
826 | 827 | ||
827 | 828 | ||
828 | /*! | 829 | /*! |
829 | \internal | 830 | \internal |
830 | Returns the list of fields belonging to a contact | 831 | Returns the list of fields belonging to a contact |
831 | Never change order of this list ! It has to be regarding | 832 | Never change order of this list ! It has to be regarding |
832 | enum AddressBookFields !! | 833 | enum AddressBookFields !! |
833 | */ | 834 | */ |
834 | QStringList OContact::fields() | 835 | QStringList OContact::fields() |
835 | { | 836 | { |
836 | QStringList list; | 837 | QStringList list; |
837 | 838 | ||
838 | list.append( "Title" ); // Not Used! | 839 | list.append( "Title" ); // Not Used! |
839 | list.append( "FirstName" ); | 840 | list.append( "FirstName" ); |
840 | list.append( "MiddleName" ); | 841 | list.append( "MiddleName" ); |
841 | list.append( "LastName" ); | 842 | list.append( "LastName" ); |
842 | list.append( "Suffix" ); | 843 | list.append( "Suffix" ); |
843 | list.append( "FileAs" ); | 844 | list.append( "FileAs" ); |
844 | 845 | ||
845 | list.append( "JobTitle" ); | 846 | list.append( "JobTitle" ); |
846 | list.append( "Department" ); | 847 | list.append( "Department" ); |
847 | list.append( "Company" ); | 848 | list.append( "Company" ); |
848 | list.append( "BusinessPhone" ); | 849 | list.append( "BusinessPhone" ); |
849 | list.append( "BusinessFax" ); | 850 | list.append( "BusinessFax" ); |
850 | list.append( "BusinessMobile" ); | 851 | list.append( "BusinessMobile" ); |
851 | 852 | ||
852 | list.append( "DefaultEmail" ); | 853 | list.append( "DefaultEmail" ); |
853 | list.append( "Emails" ); | 854 | list.append( "Emails" ); |
854 | 855 | ||
855 | list.append( "HomePhone" ); | 856 | list.append( "HomePhone" ); |
856 | list.append( "HomeFax" ); | 857 | list.append( "HomeFax" ); |
857 | list.append( "HomeMobile" ); | 858 | list.append( "HomeMobile" ); |
858 | 859 | ||
859 | list.append( "BusinessStreet" ); | 860 | list.append( "BusinessStreet" ); |
860 | list.append( "BusinessCity" ); | 861 | list.append( "BusinessCity" ); |
861 | list.append( "BusinessState" ); | 862 | list.append( "BusinessState" ); |
862 | list.append( "BusinessZip" ); | 863 | list.append( "BusinessZip" ); |
863 | list.append( "BusinessCountry" ); | 864 | list.append( "BusinessCountry" ); |
864 | list.append( "BusinessPager" ); | 865 | list.append( "BusinessPager" ); |
865 | list.append( "BusinessWebPage" ); | 866 | list.append( "BusinessWebPage" ); |
866 | 867 | ||
867 | list.append( "Office" ); | 868 | list.append( "Office" ); |
868 | list.append( "Profession" ); | 869 | list.append( "Profession" ); |
869 | list.append( "Assistant" ); | 870 | list.append( "Assistant" ); |
870 | list.append( "Manager" ); | 871 | list.append( "Manager" ); |
871 | 872 | ||
872 | list.append( "HomeStreet" ); | 873 | list.append( "HomeStreet" ); |
873 | list.append( "HomeCity" ); | 874 | list.append( "HomeCity" ); |
874 | list.append( "HomeState" ); | 875 | list.append( "HomeState" ); |
875 | list.append( "HomeZip" ); | 876 | list.append( "HomeZip" ); |
876 | list.append( "HomeCountry" ); | 877 | list.append( "HomeCountry" ); |
877 | list.append( "HomeWebPage" ); | 878 | list.append( "HomeWebPage" ); |
878 | 879 | ||
879 | list.append( "Spouse" ); | 880 | list.append( "Spouse" ); |
880 | list.append( "Gender" ); | 881 | list.append( "Gender" ); |
881 | list.append( "Birthday" ); | 882 | list.append( "Birthday" ); |
882 | list.append( "Anniversary" ); | 883 | list.append( "Anniversary" ); |
883 | list.append( "Nickname" ); | 884 | list.append( "Nickname" ); |
884 | list.append( "Children" ); | 885 | list.append( "Children" ); |
885 | 886 | ||
886 | list.append( "Notes" ); | 887 | list.append( "Notes" ); |
887 | list.append( "Groups" ); | 888 | list.append( "Groups" ); |
888 | 889 | ||
889 | return list; | 890 | return list; |
890 | } | 891 | } |
891 | 892 | ||
892 | 893 | ||
893 | /*! | 894 | /*! |
894 | Sets the list of email address for contact to those contained in \a str. | 895 | Sets the list of email address for contact to those contained in \a str. |
895 | Email address should be separated by ';'s. | 896 | Email address should be separated by ';'s. |
896 | */ | 897 | */ |
897 | void OContact::setEmails( const QString &str ) | 898 | void OContact::setEmails( const QString &str ) |
898 | { | 899 | { |
899 | replace( Qtopia::Emails, str ); | 900 | replace( Qtopia::Emails, str ); |
900 | if ( str.isEmpty() ) | 901 | if ( str.isEmpty() ) |
901 | setDefaultEmail( QString::null ); | 902 | setDefaultEmail( QString::null ); |
902 | } | 903 | } |
903 | 904 | ||
904 | /*! | 905 | /*! |
905 | Sets the list of children for the contact to those contained in \a str. | 906 | Sets the list of children for the contact to those contained in \a str. |
906 | */ | 907 | */ |
907 | void OContact::setChildren( const QString &str ) | 908 | void OContact::setChildren( const QString &str ) |
908 | { | 909 | { |
909 | replace( Qtopia::Children, str ); | 910 | replace( Qtopia::Children, str ); |
910 | } | 911 | } |
911 | 912 | ||
912 | /*! | 913 | /*! |
913 | Returns TRUE if the contact matches the regular expression \a regexp. | 914 | Returns TRUE if the contact matches the regular expression \a regexp. |
914 | Otherwise returns FALSE. | 915 | Otherwise returns FALSE. |
915 | */ | 916 | */ |
916 | bool OContact::match( const QString ®exp ) const | 917 | bool OContact::match( const QString ®exp ) const |
917 | { | 918 | { |
918 | return match(QRegExp(regexp)); | 919 | return match(QRegExp(regexp)); |
919 | } | 920 | } |
920 | 921 | ||
921 | /*! | 922 | /*! |
922 | \overload | 923 | \overload |
923 | Returns TRUE if the contact matches the regular expression \a regexp. | 924 | Returns TRUE if the contact matches the regular expression \a regexp. |
924 | Otherwise returns FALSE. | 925 | Otherwise returns FALSE. |
925 | */ | 926 | */ |
926 | bool OContact::match( const QRegExp &r ) const | 927 | bool OContact::match( const QRegExp &r ) const |
927 | { | 928 | { |
928 | bool match; | 929 | bool match; |
@@ -1007,103 +1008,103 @@ QDate OContact::birthday() const | |||
1007 | QString str = find( Qtopia::Birthday ); | 1008 | QString str = find( Qtopia::Birthday ); |
1008 | qWarning ("Birthday %s", str.latin1() ); | 1009 | qWarning ("Birthday %s", str.latin1() ); |
1009 | if ( !str.isEmpty() ) | 1010 | if ( !str.isEmpty() ) |
1010 | return TimeConversion::fromString ( str ); | 1011 | return TimeConversion::fromString ( str ); |
1011 | else | 1012 | else |
1012 | return QDate(); | 1013 | return QDate(); |
1013 | } | 1014 | } |
1014 | 1015 | ||
1015 | 1016 | ||
1016 | /*! \fn QDate OContact::anniversary() const | 1017 | /*! \fn QDate OContact::anniversary() const |
1017 | Returns the anniversary of the contact. | 1018 | Returns the anniversary of the contact. |
1018 | */ | 1019 | */ |
1019 | QDate OContact::anniversary() const | 1020 | QDate OContact::anniversary() const |
1020 | { | 1021 | { |
1021 | QDate empty; | 1022 | QDate empty; |
1022 | QString str = find( Qtopia::Anniversary ); | 1023 | QString str = find( Qtopia::Anniversary ); |
1023 | qWarning ("Anniversary %s", str.latin1() ); | 1024 | qWarning ("Anniversary %s", str.latin1() ); |
1024 | if ( !str.isEmpty() ) | 1025 | if ( !str.isEmpty() ) |
1025 | return TimeConversion::fromString ( str ); | 1026 | return TimeConversion::fromString ( str ); |
1026 | else | 1027 | else |
1027 | return empty; | 1028 | return empty; |
1028 | } | 1029 | } |
1029 | 1030 | ||
1030 | 1031 | ||
1031 | void OContact::insertEmail( const QString &v ) | 1032 | void OContact::insertEmail( const QString &v ) |
1032 | { | 1033 | { |
1033 | //qDebug("insertEmail %s", v.latin1()); | 1034 | //qDebug("insertEmail %s", v.latin1()); |
1034 | QString e = v.simplifyWhiteSpace(); | 1035 | QString e = v.simplifyWhiteSpace(); |
1035 | QString def = defaultEmail(); | 1036 | QString def = defaultEmail(); |
1036 | 1037 | ||
1037 | // if no default, set it as the default email and don't insert | 1038 | // if no default, set it as the default email and don't insert |
1038 | if ( def.isEmpty() ) { | 1039 | if ( def.isEmpty() ) { |
1039 | setDefaultEmail( e ); // will insert into the list for us | 1040 | setDefaultEmail( e ); // will insert into the list for us |
1040 | return; | 1041 | return; |
1041 | } | 1042 | } |
1042 | 1043 | ||
1043 | // otherwise, insert assuming doesn't already exist | 1044 | // otherwise, insert assuming doesn't already exist |
1044 | QString emailsStr = find( Qtopia::Emails ); | 1045 | QString emailsStr = find( Qtopia::Emails ); |
1045 | if ( emailsStr.contains( e )) | 1046 | if ( emailsStr.contains( e )) |
1046 | return; | 1047 | return; |
1047 | if ( !emailsStr.isEmpty() ) | 1048 | if ( !emailsStr.isEmpty() ) |
1048 | emailsStr += emailSeparator(); | 1049 | emailsStr += emailSeparator(); |
1049 | emailsStr += e; | 1050 | emailsStr += e; |
1050 | replace( Qtopia::Emails, emailsStr ); | 1051 | replace( Qtopia::Emails, emailsStr ); |
1051 | } | 1052 | } |
1052 | 1053 | ||
1053 | void OContact::removeEmail( const QString &v ) | 1054 | void OContact::removeEmail( const QString &v ) |
1054 | { | 1055 | { |
1055 | QString e = v.simplifyWhiteSpace(); | 1056 | QString e = v.simplifyWhiteSpace(); |
1056 | QString def = defaultEmail(); | 1057 | QString def = defaultEmail(); |
1057 | QString emailsStr = find( Qtopia::Emails ); | 1058 | QString emailsStr = find( Qtopia::Emails ); |
1058 | QStringList emails = emailList(); | 1059 | QStringList emails = emailList(); |
1059 | 1060 | ||
1060 | // otherwise, must first contain it | 1061 | // otherwise, must first contain it |
1061 | if ( !emailsStr.contains( e ) ) | 1062 | if ( !emailsStr.contains( e ) ) |
1062 | return; | 1063 | return; |
1063 | 1064 | ||
1064 | // remove it | 1065 | // remove it |
1065 | //qDebug(" removing email from list %s", e.latin1()); | 1066 | //qDebug(" removing email from list %s", e.latin1()); |
1066 | emails.remove( e ); | 1067 | emails.remove( e ); |
1067 | // reset the string | 1068 | // reset the string |
1068 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator | 1069 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator |
1069 | replace( Qtopia::Emails, emailsStr ); | 1070 | replace( Qtopia::Emails, emailsStr ); |
1070 | 1071 | ||
1071 | // if default, then replace the default email with the first one | 1072 | // if default, then replace the default email with the first one |
1072 | if ( def == e ) { | 1073 | if ( def == e ) { |
1073 | //qDebug("removeEmail is default; setting new default"); | 1074 | //qDebug("removeEmail is default; setting new default"); |
1074 | if ( !emails.count() ) | 1075 | if ( !emails.count() ) |
1075 | clearEmails(); | 1076 | clearEmails(); |
1076 | else // setDefaultEmail will remove e from the list | 1077 | else // setDefaultEmail will remove e from the list |
1077 | setDefaultEmail( emails.first() ); | 1078 | setDefaultEmail( emails.first() ); |
1078 | } | 1079 | } |
1079 | } | 1080 | } |
1080 | void OContact::clearEmails() | 1081 | void OContact::clearEmails() |
1081 | { | 1082 | { |
1082 | mMap.remove( Qtopia::DefaultEmail ); | 1083 | mMap.remove( Qtopia::DefaultEmail ); |
1083 | mMap.remove( Qtopia::Emails ); | 1084 | mMap.remove( Qtopia::Emails ); |
1084 | } | 1085 | } |
1085 | void OContact::setDefaultEmail( const QString &v ) | 1086 | void OContact::setDefaultEmail( const QString &v ) |
1086 | { | 1087 | { |
1087 | QString e = v.simplifyWhiteSpace(); | 1088 | QString e = v.simplifyWhiteSpace(); |
1088 | 1089 | ||
1089 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); | 1090 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); |
1090 | replace( Qtopia::DefaultEmail, e ); | 1091 | replace( Qtopia::DefaultEmail, e ); |
1091 | 1092 | ||
1092 | if ( !e.isEmpty() ) | 1093 | if ( !e.isEmpty() ) |
1093 | insertEmail( e ); | 1094 | insertEmail( e ); |
1094 | 1095 | ||
1095 | } | 1096 | } |
1096 | 1097 | ||
1097 | void OContact::insertEmails( const QStringList &v ) | 1098 | void OContact::insertEmails( const QStringList &v ) |
1098 | { | 1099 | { |
1099 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) | 1100 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) |
1100 | insertEmail( *it ); | 1101 | insertEmail( *it ); |
1101 | } | 1102 | } |
1102 | int OContact::rtti() { | 1103 | int OContact::rtti() { |
1103 | return 2; | 1104 | return OPimResolver::AddressBook; |
1104 | } | 1105 | } |
1105 | void OContact::setUid( int i ) | 1106 | void OContact::setUid( int i ) |
1106 | { | 1107 | { |
1107 | OPimRecord::setUid(i); | 1108 | OPimRecord::setUid(i); |
1108 | replace( Qtopia::AddressUid , QString::number(i)); | 1109 | replace( Qtopia::AddressUid , QString::number(i)); |
1109 | } | 1110 | } |