author | zautrix <zautrix> | 2004-10-13 12:38:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-13 12:38:18 (UTC) |
commit | efdd0735bda81dcd82dfb6d6dc0d0c143f249336 (patch) (unidiff) | |
tree | 8d67e4b51fbc3e8c48e1656c78054cfe6d2ead66 /kabc/phonenumber.cpp | |
parent | f22ee1ec902fe2fc610786f39049fb84542b8726 (diff) | |
download | kdepimpi-efdd0735bda81dcd82dfb6d6dc0d0c143f249336.zip kdepimpi-efdd0735bda81dcd82dfb6d6dc0d0c143f249336.tar.gz kdepimpi-efdd0735bda81dcd82dfb6d6dc0d0c143f249336.tar.bz2 |
mege contact fixes
-rw-r--r-- | kabc/phonenumber.cpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index d7e3925..3d82553 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -36,102 +36,124 @@ PhoneNumber::PhoneNumber() : | |||
36 | mType( Home ) | 36 | mType( Home ) |
37 | { | 37 | { |
38 | init(); | 38 | init(); |
39 | } | 39 | } |
40 | 40 | ||
41 | PhoneNumber::PhoneNumber( const QString &number, int type ) : | 41 | PhoneNumber::PhoneNumber( const QString &number, int type ) : |
42 | mType( type ), mNumber( number ) | 42 | mType( type ), mNumber( number ) |
43 | { | 43 | { |
44 | init(); | 44 | init(); |
45 | } | 45 | } |
46 | 46 | ||
47 | PhoneNumber::~PhoneNumber() | 47 | PhoneNumber::~PhoneNumber() |
48 | { | 48 | { |
49 | } | 49 | } |
50 | 50 | ||
51 | void PhoneNumber::init() | 51 | void PhoneNumber::init() |
52 | { | 52 | { |
53 | mId = KApplication::randomString( 8 ); | 53 | mId = KApplication::randomString( 8 ); |
54 | } | 54 | } |
55 | 55 | ||
56 | bool PhoneNumber::operator==( const PhoneNumber &p ) const | 56 | bool PhoneNumber::operator==( const PhoneNumber &p ) const |
57 | { | 57 | { |
58 | if ( mNumber != p.mNumber ) return false; | 58 | if ( mNumber != p.mNumber ) return false; |
59 | if ( mType != p.mType ) return false; | 59 | if ( mType != p.mType ) return false; |
60 | 60 | ||
61 | return true; | 61 | return true; |
62 | } | 62 | } |
63 | 63 | ||
64 | bool PhoneNumber::operator!=( const PhoneNumber &p ) const | 64 | bool PhoneNumber::operator!=( const PhoneNumber &p ) const |
65 | { | 65 | { |
66 | return !( p == *this ); | 66 | return !( p == *this ); |
67 | } | 67 | } |
68 | 68 | ||
69 | bool PhoneNumber::simplifyNumber() | 69 | bool PhoneNumber::simplifyNumber() |
70 | { | 70 | { |
71 | QString Number; | 71 | QString Number; |
72 | int i; | 72 | int i; |
73 | Number = mNumber.stripWhiteSpace (); | 73 | Number = mNumber.stripWhiteSpace (); |
74 | mNumber = ""; | 74 | mNumber = ""; |
75 | for ( i = 0; i < Number.length(); ++i) { | 75 | for ( i = 0; i < Number.length(); ++i) { |
76 | if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) | 76 | if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) |
77 | mNumber += Number.at(i); | 77 | mNumber += Number.at(i); |
78 | } | 78 | } |
79 | return ( mNumber.length() > 0 ); | 79 | return ( mNumber.length() > 0 ); |
80 | } | 80 | } |
81 | // make cellphone compatible | 81 | // make cellphone compatible |
82 | void PhoneNumber::simplifyType() | 82 | void PhoneNumber::simplifyType() |
83 | { | 83 | { |
84 | if ( mType & Fax ) mType = Fax; | 84 | if ( mType & Fax ) mType = Fax; |
85 | else if ( mType & Cell ) mType = Cell; | 85 | else if ( mType & Cell ) mType = Cell; |
86 | else if ( mType & Work ) mType = Work ; | 86 | else if ( mType & Work ) mType = Work ; |
87 | else if ( mType & Home ) mType = Home; | 87 | else if ( mType & Home ) mType = Home; |
88 | else mType = Pref; | 88 | else mType = Pref; |
89 | } | 89 | } |
90 | bool PhoneNumber::contains( const PhoneNumber &p ) | ||
91 | { | ||
92 | QString Number; | ||
93 | QString Num; | ||
94 | uint i; | ||
95 | Number = mNumber.stripWhiteSpace (); | ||
96 | Num = ""; | ||
97 | for ( i = 0; i < Number.length(); ++i) { | ||
98 | if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) | ||
99 | Num += Number.at(i); | ||
100 | } | ||
101 | QString NumberR; | ||
102 | QString NumR; | ||
103 | NumberR = p.mNumber.stripWhiteSpace (); | ||
104 | NumR = ""; | ||
105 | for ( i = 0; i < NumberR.length(); ++i) { | ||
106 | if ( NumberR.at(i).isDigit() || NumberR.at(i) == '+'|| NumberR.at(i) == '*'|| NumberR.at(i) == '#' ) | ||
107 | NumR += NumberR.at(i); | ||
108 | } | ||
109 | return (Num == NumR); | ||
110 | } | ||
111 | |||
90 | void PhoneNumber::setId( const QString &id ) | 112 | void PhoneNumber::setId( const QString &id ) |
91 | { | 113 | { |
92 | mId = id; | 114 | mId = id; |
93 | } | 115 | } |
94 | 116 | ||
95 | QString PhoneNumber::id() const | 117 | QString PhoneNumber::id() const |
96 | { | 118 | { |
97 | return mId; | 119 | return mId; |
98 | } | 120 | } |
99 | 121 | ||
100 | void PhoneNumber::setNumber( const QString &number ) | 122 | void PhoneNumber::setNumber( const QString &number ) |
101 | { | 123 | { |
102 | mNumber = number; | 124 | mNumber = number; |
103 | } | 125 | } |
104 | 126 | ||
105 | QString PhoneNumber::number() const | 127 | QString PhoneNumber::number() const |
106 | { | 128 | { |
107 | return mNumber; | 129 | return mNumber; |
108 | } | 130 | } |
109 | 131 | ||
110 | void PhoneNumber::setType( int type ) | 132 | void PhoneNumber::setType( int type ) |
111 | { | 133 | { |
112 | mType = type; | 134 | mType = type; |
113 | } | 135 | } |
114 | 136 | ||
115 | int PhoneNumber::type() const | 137 | int PhoneNumber::type() const |
116 | { | 138 | { |
117 | return mType; | 139 | return mType; |
118 | } | 140 | } |
119 | 141 | ||
120 | QString PhoneNumber::typeLabel() const | 142 | QString PhoneNumber::typeLabel() const |
121 | { | 143 | { |
122 | QString label; | 144 | QString label; |
123 | bool first = true; | 145 | bool first = true; |
124 | 146 | ||
125 | TypeList list = typeList(); | 147 | TypeList list = typeList(); |
126 | 148 | ||
127 | TypeList::Iterator it; | 149 | TypeList::Iterator it; |
128 | for ( it = list.begin(); it != list.end(); ++it ) { | 150 | for ( it = list.begin(); it != list.end(); ++it ) { |
129 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { | 151 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { |
130 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); | 152 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); |
131 | if ( first ) | 153 | if ( first ) |
132 | first = false; | 154 | first = false; |
133 | } | 155 | } |
134 | } | 156 | } |
135 | 157 | ||
136 | return label; | 158 | return label; |
137 | } | 159 | } |