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 | |
parent | f22ee1ec902fe2fc610786f39049fb84542b8726 (diff) | |
download | kdepimpi-efdd0735bda81dcd82dfb6d6dc0d0c143f249336.zip kdepimpi-efdd0735bda81dcd82dfb6d6dc0d0c143f249336.tar.gz kdepimpi-efdd0735bda81dcd82dfb6d6dc0d0c143f249336.tar.bz2 |
mege contact fixes
-rw-r--r-- | kabc/addressee.cpp | 75 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 32 | ||||
-rw-r--r-- | kabc/phonenumber.h | 1 |
3 files changed, 62 insertions, 46 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index cb10160..2aca559 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1938 +1,1931 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
50 | { | 50 | { |
51 | QString uid; | 51 | QString uid; |
52 | QString name; | 52 | QString name; |
53 | QString formattedName; | 53 | QString formattedName; |
54 | QString familyName; | 54 | QString familyName; |
55 | QString givenName; | 55 | QString givenName; |
56 | QString additionalName; | 56 | QString additionalName; |
57 | QString prefix; | 57 | QString prefix; |
58 | QString suffix; | 58 | QString suffix; |
59 | QString nickName; | 59 | QString nickName; |
60 | QDateTime birthday; | 60 | QDateTime birthday; |
61 | QString mailer; | 61 | QString mailer; |
62 | TimeZone timeZone; | 62 | TimeZone timeZone; |
63 | Geo geo; | 63 | Geo geo; |
64 | QString title; | 64 | QString title; |
65 | QString role; | 65 | QString role; |
66 | QString organization; | 66 | QString organization; |
67 | QString note; | 67 | QString note; |
68 | QString productId; | 68 | QString productId; |
69 | QDateTime revision; | 69 | QDateTime revision; |
70 | QString sortString; | 70 | QString sortString; |
71 | QString externalUID; | 71 | QString externalUID; |
72 | QString originalExternalUID; | 72 | QString originalExternalUID; |
73 | KURL url; | 73 | KURL url; |
74 | Secrecy secrecy; | 74 | Secrecy secrecy; |
75 | Picture logo; | 75 | Picture logo; |
76 | Picture photo; | 76 | Picture photo; |
77 | Sound sound; | 77 | Sound sound; |
78 | Agent agent; | 78 | Agent agent; |
79 | QString mExternalId; | 79 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 81 | Address::List addresses; |
82 | Key::List keys; | 82 | Key::List keys; |
83 | QStringList emails; | 83 | QStringList emails; |
84 | QStringList categories; | 84 | QStringList categories; |
85 | QStringList custom; | 85 | QStringList custom; |
86 | int mTempSyncStat; | 86 | int mTempSyncStat; |
87 | Resource *resource; | 87 | Resource *resource; |
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | bool tagged :1; | 91 | bool tagged :1; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | Addressee::Addressee() | 94 | Addressee::Addressee() |
95 | { | 95 | { |
96 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
97 | mData->empty = true; | 97 | mData->empty = true; |
98 | mData->changed = false; | 98 | mData->changed = false; |
99 | mData->resource = 0; | 99 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 103 | } |
104 | 104 | ||
105 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 115 | { |
116 | mData = a.mData; | 116 | mData = a.mData; |
117 | return (*this); | 117 | return (*this); |
118 | } | 118 | } |
119 | 119 | ||
120 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
121 | { | 121 | { |
122 | Addressee a; | 122 | Addressee a; |
123 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
124 | return a; | 124 | return a; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Addressee::detach() | 127 | void Addressee::detach() |
128 | { | 128 | { |
129 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 130 | *this = copy(); |
131 | } | 131 | } |
132 | 132 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 134 | { |
135 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 173 | { |
174 | return !( a == *this ); | 174 | return !( a == *this ); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
178 | { | 178 | { |
179 | return mData->empty; | 179 | return mData->empty; |
180 | } | 180 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 182 | { |
183 | int max = attList.count(); | 183 | int max = attList.count(); |
184 | ulong cSum = 0; | 184 | ulong cSum = 0; |
185 | int j,k,i; | 185 | int j,k,i; |
186 | int add; | 186 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 188 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 190 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 192 | int mul = k +1; |
193 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 194 | if ( k < 16 ) |
195 | mul = mul * mul; | 195 | mul = mul * mul; |
196 | int ii = i+1; | 196 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 198 | cSum += add; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | //QString dump = attList.join(","); | 203 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 204 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 205 | ||
206 | return cSum; | 206 | return cSum; |
207 | 207 | ||
208 | } | 208 | } |
209 | void Addressee::computeCsum(const QString &dev) | 209 | void Addressee::computeCsum(const QString &dev) |
210 | { | 210 | { |
211 | QStringList l; | 211 | QStringList l; |
212 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 212 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 216 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 231 | // if ( !mData->logo.isEmpty() ) l.append( ); |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 232 | //if ( !mData->photo.isEmpty() ) l.append( ); |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 233 | //if ( !mData->sound.isEmpty() ) l.append( ); |
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 234 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | if ( mData->url.isValid() ) | 235 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 237 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 238 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 239 | ||
240 | QStringList t; | 240 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 242 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 244 | t.sort(); |
245 | uint iii; | 245 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 246 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 247 | l.append( t[iii] ); |
248 | t = mData->emails; | 248 | t = mData->emails; |
249 | t.sort(); | 249 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 250 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 251 | l.append( t[iii] ); |
252 | t = mData->categories; | 252 | t = mData->categories; |
253 | t.sort(); | 253 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 254 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 255 | l.append( t[iii] ); |
256 | t = mData->custom; | 256 | t = mData->custom; |
257 | t.sort(); | 257 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 258 | for ( iii = 0; iii < t.count(); ++iii) |
259 | l.append( t[iii] ); | 259 | l.append( t[iii] ); |
260 | KABC::Address::List::Iterator addressIter; | 260 | KABC::Address::List::Iterator addressIter; |
261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
262 | ++addressIter ) { | 262 | ++addressIter ) { |
263 | t = (*addressIter).asList(); | 263 | t = (*addressIter).asList(); |
264 | t.sort(); | 264 | t.sort(); |
265 | for ( iii = 0; iii < t.count(); ++iii) | 265 | for ( iii = 0; iii < t.count(); ++iii) |
266 | l.append( t[iii] ); | 266 | l.append( t[iii] ); |
267 | } | 267 | } |
268 | uint cs = getCsum4List(l); | 268 | uint cs = getCsum4List(l); |
269 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 269 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
270 | setCsum( dev, QString::number (cs )); | 270 | setCsum( dev, QString::number (cs )); |
271 | } | 271 | } |
272 | 272 | ||
273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
274 | { | 274 | { |
275 | 275 | ||
276 | detach(); | 276 | detach(); |
277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
285 | if ( !mData->birthday.isValid() ) | 285 | if ( !mData->birthday.isValid() ) |
286 | if ( ad.mData->birthday.isValid()) | 286 | if ( ad.mData->birthday.isValid()) |
287 | mData->birthday = ad.mData->birthday; | 287 | mData->birthday = ad.mData->birthday; |
288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
299 | QStringList t; | 299 | QStringList t; |
300 | QStringList tAD; | 300 | QStringList tAD; |
301 | uint iii; | 301 | uint iii; |
302 | if ( isSubSet ) { | 302 | if ( isSubSet ) { |
303 | // ********** phone numbers | 303 | // ********** phone numbers |
304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
305 | PhoneNumber::List::Iterator phoneItAD; | 305 | PhoneNumber::List::Iterator phoneItAD; |
306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
307 | bool found = false; | 307 | bool found = false; |
308 | PhoneNumber::List::Iterator it; | 308 | PhoneNumber::List::Iterator it; |
309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
310 | if ( (*it) == ( *phoneItAD ) ) { | 310 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
311 | found = true; | 311 | found = true; |
312 | (*it).setType( ( *phoneItAD ).type() ); | ||
312 | break; | 313 | break; |
313 | } | 314 | } |
314 | } | 315 | } |
315 | if ( ! found ) | 316 | if ( ! found ) |
316 | mData->phoneNumbers.append( *phoneItAD ); | 317 | mData->phoneNumbers.append( *phoneItAD ); |
317 | } | 318 | } |
318 | // ************* emails; | 319 | // ************* emails; |
319 | t = mData->emails; | 320 | t = mData->emails; |
320 | tAD = ad.mData->emails; | 321 | tAD = ad.mData->emails; |
321 | for ( iii = 0; iii < tAD.count(); ++iii) | 322 | for ( iii = 0; iii < tAD.count(); ++iii) |
322 | if ( !t.contains(tAD[iii] ) ) | 323 | if ( !t.contains(tAD[iii] ) ) |
323 | mData->emails.append( tAD[iii] ); | 324 | mData->emails.append( tAD[iii] ); |
324 | // ************* categories; | 325 | // ************* categories; |
325 | t = mData->categories; | 326 | t = mData->categories; |
326 | tAD = ad.mData->categories; | 327 | tAD = ad.mData->categories; |
327 | for ( iii = 0; iii < tAD.count(); ++iii) | 328 | for ( iii = 0; iii < tAD.count(); ++iii) |
328 | if ( !t.contains(tAD[iii] ) ) | 329 | if ( !t.contains(tAD[iii] ) ) |
329 | mData->categories.append( tAD[iii] ); | 330 | mData->categories.append( tAD[iii] ); |
330 | 331 | ||
331 | 332 | ||
332 | } | 333 | } |
333 | 334 | ||
334 | QStringList::ConstIterator it; | 335 | QStringList::ConstIterator it; |
335 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 336 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
336 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 337 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
337 | bool found = false; | 338 | bool found = false; |
338 | QStringList::ConstIterator itL; | 339 | QStringList::ConstIterator itL; |
339 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 340 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
340 | if ( (*itL).startsWith( qualifiedName ) ) { | 341 | if ( (*itL).startsWith( qualifiedName ) ) { |
341 | found = true; | 342 | found = true; |
342 | break; | 343 | break; |
343 | } | 344 | } |
344 | } | 345 | } |
345 | if ( ! found ) { | 346 | if ( ! found ) { |
346 | mData->custom.append( *it ); | 347 | mData->custom.append( *it ); |
347 | } | 348 | } |
348 | } | 349 | } |
349 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 350 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
350 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 351 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
351 | if ( !mData->sound.isIntern() ) { | 352 | if ( !mData->sound.isIntern() ) { |
352 | if ( mData->sound.url().isEmpty() ) { | 353 | if ( mData->sound.url().isEmpty() ) { |
353 | mData->sound = ad.mData->sound; | 354 | mData->sound = ad.mData->sound; |
354 | } | 355 | } |
355 | } | 356 | } |
356 | if ( !mData->agent.isIntern() ) { | 357 | if ( !mData->agent.isIntern() ) { |
357 | if ( mData->agent.url().isEmpty() ) { | 358 | if ( mData->agent.url().isEmpty() ) { |
358 | mData->agent = ad.mData->agent; | 359 | mData->agent = ad.mData->agent; |
359 | } | 360 | } |
360 | } | 361 | } |
361 | 362 | { | |
362 | #if 0 | 363 | Key::List::Iterator itA; |
363 | 364 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | |
364 | if ( mData->url.isValid() ) | 365 | bool found = false; |
365 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 366 | Key::List::Iterator it; |
366 | KABC::PhoneNumber::List phoneNumbers; | 367 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
367 | KABC::PhoneNumber::List::Iterator phoneIter; | 368 | if ( (*it) == (*itA)) { |
368 | 369 | found = true; | |
369 | QStringList t; | 370 | break; |
370 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 371 | |
371 | ++phoneIter ) | 372 | } |
372 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 373 | } |
373 | t.sort(); | 374 | if ( ! found ) { |
374 | uint iii; | 375 | mData->keys.append( *itA ); |
375 | for ( iii = 0; iii < t.count(); ++iii) | 376 | } |
376 | l.append( t[iii] ); | 377 | } |
377 | t = mData->emails; | ||
378 | t.sort(); | ||
379 | for ( iii = 0; iii < t.count(); ++iii) | ||
380 | l.append( t[iii] ); | ||
381 | t = mData->categories; | ||
382 | t.sort(); | ||
383 | for ( iii = 0; iii < t.count(); ++iii) | ||
384 | l.append( t[iii] ); | ||
385 | t = mData->custom; | ||
386 | t.sort(); | ||
387 | for ( iii = 0; iii < t.count(); ++iii) | ||
388 | l.append( t[iii] ); | ||
389 | KABC::Address::List::Iterator addressIter; | ||
390 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | ||
391 | ++addressIter ) { | ||
392 | t = (*addressIter).asList(); | ||
393 | t.sort(); | ||
394 | for ( iii = 0; iii < t.count(); ++iii) | ||
395 | l.append( t[iii] ); | ||
396 | } | 378 | } |
379 | KABC::Address::List::Iterator addressIterA; | ||
380 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | ||
381 | bool found = false; | ||
382 | KABC::Address::List::Iterator addressIter; | ||
383 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | ||
384 | ++addressIter ) { | ||
385 | if ( (*addressIter) == (*addressIterA)) { | ||
386 | found = true; | ||
387 | (*addressIter).setType( (*addressIterA).type() ); | ||
388 | break; | ||
389 | } | ||
397 | 390 | ||
398 | #endif | 391 | } |
399 | 392 | if ( ! found ) { | |
400 | // pending: | 393 | mData->addresses.append( *addressIterA ); |
401 | // merging addresses | 394 | } |
402 | // merging keys | 395 | } |
403 | //qDebug("merge contact %s ", ad.uid().latin1()); | 396 | //qDebug("merge contact %s ", ad.uid().latin1()); |
404 | setUid( ad.uid() ); | 397 | setUid( ad.uid() ); |
405 | setRevision( ad.revision() ); | 398 | setRevision( ad.revision() ); |
406 | } | 399 | } |
407 | 400 | ||
408 | bool Addressee::removeVoice() | 401 | bool Addressee::removeVoice() |
409 | { | 402 | { |
410 | PhoneNumber::List phoneN = phoneNumbers(); | 403 | PhoneNumber::List phoneN = phoneNumbers(); |
411 | PhoneNumber::List::Iterator phoneIt; | 404 | PhoneNumber::List::Iterator phoneIt; |
412 | bool found = false; | 405 | bool found = false; |
413 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 406 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
414 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 407 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
415 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 408 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
416 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 409 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
417 | insertPhoneNumber( (*phoneIt) ); | 410 | insertPhoneNumber( (*phoneIt) ); |
418 | found = true; | 411 | found = true; |
419 | } | 412 | } |
420 | } | 413 | } |
421 | 414 | ||
422 | } | 415 | } |
423 | return found; | 416 | return found; |
424 | } | 417 | } |
425 | 418 | ||
426 | bool Addressee::containsAdr(const Addressee& ad ) | 419 | bool Addressee::containsAdr(const Addressee& ad ) |
427 | { | 420 | { |
428 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 421 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
429 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 422 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
430 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 423 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
431 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 424 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
432 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 425 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
433 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 426 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
434 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 427 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
435 | 428 | ||
436 | // compare phone numbers | 429 | // compare phone numbers |
437 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 430 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
438 | PhoneNumber::List::Iterator phoneIt; | 431 | PhoneNumber::List::Iterator phoneIt; |
439 | bool found = false; | 432 | bool found = false; |
440 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 433 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
441 | bool found = false; | 434 | bool found = false; |
442 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 435 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
443 | PhoneNumber::List::Iterator phoneItL; | 436 | PhoneNumber::List::Iterator phoneItL; |
444 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 437 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
445 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 438 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
446 | found = true; | 439 | found = true; |
447 | break; | 440 | break; |
448 | } | 441 | } |
449 | } | 442 | } |
450 | if ( ! found ) | 443 | if ( ! found ) |
451 | return false; | 444 | return false; |
452 | } | 445 | } |
453 | return true; | 446 | return true; |
454 | 447 | ||
455 | } | 448 | } |
456 | void Addressee::simplifyAddresses() | 449 | void Addressee::simplifyAddresses() |
457 | { | 450 | { |
458 | int max = 2; | 451 | int max = 2; |
459 | if ( mData->url.isValid() ) | 452 | if ( mData->url.isValid() ) |
460 | max = 1; | 453 | max = 1; |
461 | if ( mData->addresses.count() <= max ) return ; | 454 | if ( mData->addresses.count() <= max ) return ; |
462 | int count = 0; | 455 | int count = 0; |
463 | Address::List list; | 456 | Address::List list; |
464 | Address::List::Iterator it; | 457 | Address::List::Iterator it; |
465 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 458 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
466 | if ( count >= max ) | 459 | if ( count >= max ) |
467 | list.append( *it ); | 460 | list.append( *it ); |
468 | ++count; | 461 | ++count; |
469 | } | 462 | } |
470 | for( it = list.begin(); it != list.end(); ++it ) { | 463 | for( it = list.begin(); it != list.end(); ++it ) { |
471 | removeAddress( (*it) ); | 464 | removeAddress( (*it) ); |
472 | } | 465 | } |
473 | } | 466 | } |
474 | 467 | ||
475 | // removes all emails but the first | 468 | // removes all emails but the first |
476 | // needed by phone sync | 469 | // needed by phone sync |
477 | void Addressee::simplifyEmails() | 470 | void Addressee::simplifyEmails() |
478 | { | 471 | { |
479 | if ( mData->emails.count() == 0 ) return ; | 472 | if ( mData->emails.count() == 0 ) return ; |
480 | QString email = mData->emails.first(); | 473 | QString email = mData->emails.first(); |
481 | detach(); | 474 | detach(); |
482 | mData->emails.clear(); | 475 | mData->emails.clear(); |
483 | mData->emails.append( email ); | 476 | mData->emails.append( email ); |
484 | } | 477 | } |
485 | 478 | ||
486 | void Addressee::simplifyPhoneNumbers() | 479 | void Addressee::simplifyPhoneNumbers() |
487 | { | 480 | { |
488 | KABC::PhoneNumber::List removeNumbers; | 481 | KABC::PhoneNumber::List removeNumbers; |
489 | KABC::PhoneNumber::List::Iterator phoneIter; | 482 | KABC::PhoneNumber::List::Iterator phoneIter; |
490 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 483 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
491 | ++phoneIter ) { | 484 | ++phoneIter ) { |
492 | if ( ! ( *phoneIter ).simplifyNumber() ) | 485 | if ( ! ( *phoneIter ).simplifyNumber() ) |
493 | removeNumbers.append( ( *phoneIter ) ); | 486 | removeNumbers.append( ( *phoneIter ) ); |
494 | } | 487 | } |
495 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 488 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
496 | ++phoneIter ) { | 489 | ++phoneIter ) { |
497 | removePhoneNumber(( *phoneIter )); | 490 | removePhoneNumber(( *phoneIter )); |
498 | } | 491 | } |
499 | } | 492 | } |
500 | void Addressee::simplifyPhoneNumberTypes() | 493 | void Addressee::simplifyPhoneNumberTypes() |
501 | { | 494 | { |
502 | KABC::PhoneNumber::List::Iterator phoneIter; | 495 | KABC::PhoneNumber::List::Iterator phoneIter; |
503 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 496 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
504 | ++phoneIter ) | 497 | ++phoneIter ) |
505 | ( *phoneIter ).simplifyType(); | 498 | ( *phoneIter ).simplifyType(); |
506 | } | 499 | } |
507 | void Addressee::removeID(const QString &prof) | 500 | void Addressee::removeID(const QString &prof) |
508 | { | 501 | { |
509 | detach(); | 502 | detach(); |
510 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 503 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
511 | 504 | ||
512 | } | 505 | } |
513 | void Addressee::setID( const QString & prof , const QString & id ) | 506 | void Addressee::setID( const QString & prof , const QString & id ) |
514 | { | 507 | { |
515 | detach(); | 508 | detach(); |
516 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 509 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
517 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 510 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
518 | } | 511 | } |
519 | void Addressee::setTempSyncStat( int id ) | 512 | void Addressee::setTempSyncStat( int id ) |
520 | { | 513 | { |
521 | if ( mData->mTempSyncStat == id ) return; | 514 | if ( mData->mTempSyncStat == id ) return; |
522 | detach(); | 515 | detach(); |
523 | mData->mTempSyncStat = id; | 516 | mData->mTempSyncStat = id; |
524 | } | 517 | } |
525 | int Addressee::tempSyncStat() const | 518 | int Addressee::tempSyncStat() const |
526 | { | 519 | { |
527 | return mData->mTempSyncStat; | 520 | return mData->mTempSyncStat; |
528 | } | 521 | } |
529 | 522 | ||
530 | QString Addressee::getID( const QString & prof) | 523 | QString Addressee::getID( const QString & prof) |
531 | { | 524 | { |
532 | return KIdManager::getId ( mData->mExternalId, prof ); | 525 | return KIdManager::getId ( mData->mExternalId, prof ); |
533 | } | 526 | } |
534 | 527 | ||
535 | void Addressee::setCsum( const QString & prof , const QString & id ) | 528 | void Addressee::setCsum( const QString & prof , const QString & id ) |
536 | { | 529 | { |
537 | detach(); | 530 | detach(); |
538 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 531 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
539 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 532 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
540 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 533 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
541 | } | 534 | } |
542 | 535 | ||
543 | QString Addressee::getCsum( const QString & prof) | 536 | QString Addressee::getCsum( const QString & prof) |
544 | { | 537 | { |
545 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 538 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
546 | } | 539 | } |
547 | 540 | ||
548 | void Addressee::setIDStr( const QString & s ) | 541 | void Addressee::setIDStr( const QString & s ) |
549 | { | 542 | { |
550 | detach(); | 543 | detach(); |
551 | mData->mExternalId = s; | 544 | mData->mExternalId = s; |
552 | } | 545 | } |
553 | 546 | ||
554 | QString Addressee::IDStr() const | 547 | QString Addressee::IDStr() const |
555 | { | 548 | { |
556 | return mData->mExternalId; | 549 | return mData->mExternalId; |
557 | } | 550 | } |
558 | 551 | ||
559 | void Addressee::setExternalUID( const QString &id ) | 552 | void Addressee::setExternalUID( const QString &id ) |
560 | { | 553 | { |
561 | if ( id == mData->externalUID ) return; | 554 | if ( id == mData->externalUID ) return; |
562 | detach(); | 555 | detach(); |
563 | mData->empty = false; | 556 | mData->empty = false; |
564 | mData->externalUID = id; | 557 | mData->externalUID = id; |
565 | } | 558 | } |
566 | 559 | ||
567 | QString Addressee::externalUID() const | 560 | QString Addressee::externalUID() const |
568 | { | 561 | { |
569 | return mData->externalUID; | 562 | return mData->externalUID; |
570 | } | 563 | } |
571 | void Addressee::setOriginalExternalUID( const QString &id ) | 564 | void Addressee::setOriginalExternalUID( const QString &id ) |
572 | { | 565 | { |
573 | if ( id == mData->originalExternalUID ) return; | 566 | if ( id == mData->originalExternalUID ) return; |
574 | detach(); | 567 | detach(); |
575 | mData->empty = false; | 568 | mData->empty = false; |
576 | //qDebug("*******Set orig uid %s ", id.latin1()); | 569 | //qDebug("*******Set orig uid %s ", id.latin1()); |
577 | mData->originalExternalUID = id; | 570 | mData->originalExternalUID = id; |
578 | } | 571 | } |
579 | 572 | ||
580 | QString Addressee::originalExternalUID() const | 573 | QString Addressee::originalExternalUID() const |
581 | { | 574 | { |
582 | return mData->originalExternalUID; | 575 | return mData->originalExternalUID; |
583 | } | 576 | } |
584 | 577 | ||
585 | void Addressee::setUid( const QString &id ) | 578 | void Addressee::setUid( const QString &id ) |
586 | { | 579 | { |
587 | if ( id == mData->uid ) return; | 580 | if ( id == mData->uid ) return; |
588 | detach(); | 581 | detach(); |
589 | //qDebug("****setuid %s ", id.latin1()); | 582 | //qDebug("****setuid %s ", id.latin1()); |
590 | mData->empty = false; | 583 | mData->empty = false; |
591 | mData->uid = id; | 584 | mData->uid = id; |
592 | } | 585 | } |
593 | 586 | ||
594 | QString Addressee::uid() const | 587 | QString Addressee::uid() const |
595 | { | 588 | { |
596 | if ( mData->uid.isEmpty() ) | 589 | if ( mData->uid.isEmpty() ) |
597 | mData->uid = KApplication::randomString( 10 ); | 590 | mData->uid = KApplication::randomString( 10 ); |
598 | 591 | ||
599 | return mData->uid; | 592 | return mData->uid; |
600 | } | 593 | } |
601 | 594 | ||
602 | QString Addressee::uidLabel() | 595 | QString Addressee::uidLabel() |
603 | { | 596 | { |
604 | return i18n("Unique Identifier"); | 597 | return i18n("Unique Identifier"); |
605 | } | 598 | } |
606 | 599 | ||
607 | void Addressee::setName( const QString &name ) | 600 | void Addressee::setName( const QString &name ) |
608 | { | 601 | { |
609 | if ( name == mData->name ) return; | 602 | if ( name == mData->name ) return; |
610 | detach(); | 603 | detach(); |
611 | mData->empty = false; | 604 | mData->empty = false; |
612 | mData->name = name; | 605 | mData->name = name; |
613 | } | 606 | } |
614 | 607 | ||
615 | QString Addressee::name() const | 608 | QString Addressee::name() const |
616 | { | 609 | { |
617 | return mData->name; | 610 | return mData->name; |
618 | } | 611 | } |
619 | 612 | ||
620 | QString Addressee::nameLabel() | 613 | QString Addressee::nameLabel() |
621 | { | 614 | { |
622 | return i18n("Name"); | 615 | return i18n("Name"); |
623 | } | 616 | } |
624 | 617 | ||
625 | 618 | ||
626 | void Addressee::setFormattedName( const QString &formattedName ) | 619 | void Addressee::setFormattedName( const QString &formattedName ) |
627 | { | 620 | { |
628 | if ( formattedName == mData->formattedName ) return; | 621 | if ( formattedName == mData->formattedName ) return; |
629 | detach(); | 622 | detach(); |
630 | mData->empty = false; | 623 | mData->empty = false; |
631 | mData->formattedName = formattedName; | 624 | mData->formattedName = formattedName; |
632 | } | 625 | } |
633 | 626 | ||
634 | QString Addressee::formattedName() const | 627 | QString Addressee::formattedName() const |
635 | { | 628 | { |
636 | return mData->formattedName; | 629 | return mData->formattedName; |
637 | } | 630 | } |
638 | 631 | ||
639 | QString Addressee::formattedNameLabel() | 632 | QString Addressee::formattedNameLabel() |
640 | { | 633 | { |
641 | return i18n("Formatted Name"); | 634 | return i18n("Formatted Name"); |
642 | } | 635 | } |
643 | 636 | ||
644 | 637 | ||
645 | void Addressee::setFamilyName( const QString &familyName ) | 638 | void Addressee::setFamilyName( const QString &familyName ) |
646 | { | 639 | { |
647 | if ( familyName == mData->familyName ) return; | 640 | if ( familyName == mData->familyName ) return; |
648 | detach(); | 641 | detach(); |
649 | mData->empty = false; | 642 | mData->empty = false; |
650 | mData->familyName = familyName; | 643 | mData->familyName = familyName; |
651 | } | 644 | } |
652 | 645 | ||
653 | QString Addressee::familyName() const | 646 | QString Addressee::familyName() const |
654 | { | 647 | { |
655 | return mData->familyName; | 648 | return mData->familyName; |
656 | } | 649 | } |
657 | 650 | ||
658 | QString Addressee::familyNameLabel() | 651 | QString Addressee::familyNameLabel() |
659 | { | 652 | { |
660 | return i18n("Family Name"); | 653 | return i18n("Family Name"); |
661 | } | 654 | } |
662 | 655 | ||
663 | 656 | ||
664 | void Addressee::setGivenName( const QString &givenName ) | 657 | void Addressee::setGivenName( const QString &givenName ) |
665 | { | 658 | { |
666 | if ( givenName == mData->givenName ) return; | 659 | if ( givenName == mData->givenName ) return; |
667 | detach(); | 660 | detach(); |
668 | mData->empty = false; | 661 | mData->empty = false; |
669 | mData->givenName = givenName; | 662 | mData->givenName = givenName; |
670 | } | 663 | } |
671 | 664 | ||
672 | QString Addressee::givenName() const | 665 | QString Addressee::givenName() const |
673 | { | 666 | { |
674 | return mData->givenName; | 667 | return mData->givenName; |
675 | } | 668 | } |
676 | 669 | ||
677 | QString Addressee::givenNameLabel() | 670 | QString Addressee::givenNameLabel() |
678 | { | 671 | { |
679 | return i18n("Given Name"); | 672 | return i18n("Given Name"); |
680 | } | 673 | } |
681 | 674 | ||
682 | 675 | ||
683 | void Addressee::setAdditionalName( const QString &additionalName ) | 676 | void Addressee::setAdditionalName( const QString &additionalName ) |
684 | { | 677 | { |
685 | if ( additionalName == mData->additionalName ) return; | 678 | if ( additionalName == mData->additionalName ) return; |
686 | detach(); | 679 | detach(); |
687 | mData->empty = false; | 680 | mData->empty = false; |
688 | mData->additionalName = additionalName; | 681 | mData->additionalName = additionalName; |
689 | } | 682 | } |
690 | 683 | ||
691 | QString Addressee::additionalName() const | 684 | QString Addressee::additionalName() const |
692 | { | 685 | { |
693 | return mData->additionalName; | 686 | return mData->additionalName; |
694 | } | 687 | } |
695 | 688 | ||
696 | QString Addressee::additionalNameLabel() | 689 | QString Addressee::additionalNameLabel() |
697 | { | 690 | { |
698 | return i18n("Additional Names"); | 691 | return i18n("Additional Names"); |
699 | } | 692 | } |
700 | 693 | ||
701 | 694 | ||
702 | void Addressee::setPrefix( const QString &prefix ) | 695 | void Addressee::setPrefix( const QString &prefix ) |
703 | { | 696 | { |
704 | if ( prefix == mData->prefix ) return; | 697 | if ( prefix == mData->prefix ) return; |
705 | detach(); | 698 | detach(); |
706 | mData->empty = false; | 699 | mData->empty = false; |
707 | mData->prefix = prefix; | 700 | mData->prefix = prefix; |
708 | } | 701 | } |
709 | 702 | ||
710 | QString Addressee::prefix() const | 703 | QString Addressee::prefix() const |
711 | { | 704 | { |
712 | return mData->prefix; | 705 | return mData->prefix; |
713 | } | 706 | } |
714 | 707 | ||
715 | QString Addressee::prefixLabel() | 708 | QString Addressee::prefixLabel() |
716 | { | 709 | { |
717 | return i18n("Honorific Prefixes"); | 710 | return i18n("Honorific Prefixes"); |
718 | } | 711 | } |
719 | 712 | ||
720 | 713 | ||
721 | void Addressee::setSuffix( const QString &suffix ) | 714 | void Addressee::setSuffix( const QString &suffix ) |
722 | { | 715 | { |
723 | if ( suffix == mData->suffix ) return; | 716 | if ( suffix == mData->suffix ) return; |
724 | detach(); | 717 | detach(); |
725 | mData->empty = false; | 718 | mData->empty = false; |
726 | mData->suffix = suffix; | 719 | mData->suffix = suffix; |
727 | } | 720 | } |
728 | 721 | ||
729 | QString Addressee::suffix() const | 722 | QString Addressee::suffix() const |
730 | { | 723 | { |
731 | return mData->suffix; | 724 | return mData->suffix; |
732 | } | 725 | } |
733 | 726 | ||
734 | QString Addressee::suffixLabel() | 727 | QString Addressee::suffixLabel() |
735 | { | 728 | { |
736 | return i18n("Honorific Suffixes"); | 729 | return i18n("Honorific Suffixes"); |
737 | } | 730 | } |
738 | 731 | ||
739 | 732 | ||
740 | void Addressee::setNickName( const QString &nickName ) | 733 | void Addressee::setNickName( const QString &nickName ) |
741 | { | 734 | { |
742 | if ( nickName == mData->nickName ) return; | 735 | if ( nickName == mData->nickName ) return; |
743 | detach(); | 736 | detach(); |
744 | mData->empty = false; | 737 | mData->empty = false; |
745 | mData->nickName = nickName; | 738 | mData->nickName = nickName; |
746 | } | 739 | } |
747 | 740 | ||
748 | QString Addressee::nickName() const | 741 | QString Addressee::nickName() const |
749 | { | 742 | { |
750 | return mData->nickName; | 743 | return mData->nickName; |
751 | } | 744 | } |
752 | 745 | ||
753 | QString Addressee::nickNameLabel() | 746 | QString Addressee::nickNameLabel() |
754 | { | 747 | { |
755 | return i18n("Nick Name"); | 748 | return i18n("Nick Name"); |
756 | } | 749 | } |
757 | 750 | ||
758 | 751 | ||
759 | void Addressee::setBirthday( const QDateTime &birthday ) | 752 | void Addressee::setBirthday( const QDateTime &birthday ) |
760 | { | 753 | { |
761 | if ( birthday == mData->birthday ) return; | 754 | if ( birthday == mData->birthday ) return; |
762 | detach(); | 755 | detach(); |
763 | mData->empty = false; | 756 | mData->empty = false; |
764 | mData->birthday = birthday; | 757 | mData->birthday = birthday; |
765 | } | 758 | } |
766 | 759 | ||
767 | QDateTime Addressee::birthday() const | 760 | QDateTime Addressee::birthday() const |
768 | { | 761 | { |
769 | return mData->birthday; | 762 | return mData->birthday; |
770 | } | 763 | } |
771 | 764 | ||
772 | QString Addressee::birthdayLabel() | 765 | QString Addressee::birthdayLabel() |
773 | { | 766 | { |
774 | return i18n("Birthday"); | 767 | return i18n("Birthday"); |
775 | } | 768 | } |
776 | 769 | ||
777 | 770 | ||
778 | QString Addressee::homeAddressStreetLabel() | 771 | QString Addressee::homeAddressStreetLabel() |
779 | { | 772 | { |
780 | return i18n("Home Address Street"); | 773 | return i18n("Home Address Street"); |
781 | } | 774 | } |
782 | 775 | ||
783 | 776 | ||
784 | QString Addressee::homeAddressLocalityLabel() | 777 | QString Addressee::homeAddressLocalityLabel() |
785 | { | 778 | { |
786 | return i18n("Home Address Locality"); | 779 | return i18n("Home Address Locality"); |
787 | } | 780 | } |
788 | 781 | ||
789 | 782 | ||
790 | QString Addressee::homeAddressRegionLabel() | 783 | QString Addressee::homeAddressRegionLabel() |
791 | { | 784 | { |
792 | return i18n("Home Address Region"); | 785 | return i18n("Home Address Region"); |
793 | } | 786 | } |
794 | 787 | ||
795 | 788 | ||
796 | QString Addressee::homeAddressPostalCodeLabel() | 789 | QString Addressee::homeAddressPostalCodeLabel() |
797 | { | 790 | { |
798 | return i18n("Home Address Postal Code"); | 791 | return i18n("Home Address Postal Code"); |
799 | } | 792 | } |
800 | 793 | ||
801 | 794 | ||
802 | QString Addressee::homeAddressCountryLabel() | 795 | QString Addressee::homeAddressCountryLabel() |
803 | { | 796 | { |
804 | return i18n("Home Address Country"); | 797 | return i18n("Home Address Country"); |
805 | } | 798 | } |
806 | 799 | ||
807 | 800 | ||
808 | QString Addressee::homeAddressLabelLabel() | 801 | QString Addressee::homeAddressLabelLabel() |
809 | { | 802 | { |
810 | return i18n("Home Address Label"); | 803 | return i18n("Home Address Label"); |
811 | } | 804 | } |
812 | 805 | ||
813 | 806 | ||
814 | QString Addressee::businessAddressStreetLabel() | 807 | QString Addressee::businessAddressStreetLabel() |
815 | { | 808 | { |
816 | return i18n("Business Address Street"); | 809 | return i18n("Business Address Street"); |
817 | } | 810 | } |
818 | 811 | ||
819 | 812 | ||
820 | QString Addressee::businessAddressLocalityLabel() | 813 | QString Addressee::businessAddressLocalityLabel() |
821 | { | 814 | { |
822 | return i18n("Business Address Locality"); | 815 | return i18n("Business Address Locality"); |
823 | } | 816 | } |
824 | 817 | ||
825 | 818 | ||
826 | QString Addressee::businessAddressRegionLabel() | 819 | QString Addressee::businessAddressRegionLabel() |
827 | { | 820 | { |
828 | return i18n("Business Address Region"); | 821 | return i18n("Business Address Region"); |
829 | } | 822 | } |
830 | 823 | ||
831 | 824 | ||
832 | QString Addressee::businessAddressPostalCodeLabel() | 825 | QString Addressee::businessAddressPostalCodeLabel() |
833 | { | 826 | { |
834 | return i18n("Business Address Postal Code"); | 827 | return i18n("Business Address Postal Code"); |
835 | } | 828 | } |
836 | 829 | ||
837 | 830 | ||
838 | QString Addressee::businessAddressCountryLabel() | 831 | QString Addressee::businessAddressCountryLabel() |
839 | { | 832 | { |
840 | return i18n("Business Address Country"); | 833 | return i18n("Business Address Country"); |
841 | } | 834 | } |
842 | 835 | ||
843 | 836 | ||
844 | QString Addressee::businessAddressLabelLabel() | 837 | QString Addressee::businessAddressLabelLabel() |
845 | { | 838 | { |
846 | return i18n("Business Address Label"); | 839 | return i18n("Business Address Label"); |
847 | } | 840 | } |
848 | 841 | ||
849 | 842 | ||
850 | QString Addressee::homePhoneLabel() | 843 | QString Addressee::homePhoneLabel() |
851 | { | 844 | { |
852 | return i18n("Home Phone"); | 845 | return i18n("Home Phone"); |
853 | } | 846 | } |
854 | 847 | ||
855 | 848 | ||
856 | QString Addressee::businessPhoneLabel() | 849 | QString Addressee::businessPhoneLabel() |
857 | { | 850 | { |
858 | return i18n("Business Phone"); | 851 | return i18n("Business Phone"); |
859 | } | 852 | } |
860 | 853 | ||
861 | 854 | ||
862 | QString Addressee::mobilePhoneLabel() | 855 | QString Addressee::mobilePhoneLabel() |
863 | { | 856 | { |
864 | return i18n("Mobile Phone"); | 857 | return i18n("Mobile Phone"); |
865 | } | 858 | } |
866 | 859 | ||
867 | 860 | ||
868 | QString Addressee::homeFaxLabel() | 861 | QString Addressee::homeFaxLabel() |
869 | { | 862 | { |
870 | return i18n("Home Fax"); | 863 | return i18n("Home Fax"); |
871 | } | 864 | } |
872 | 865 | ||
873 | 866 | ||
874 | QString Addressee::businessFaxLabel() | 867 | QString Addressee::businessFaxLabel() |
875 | { | 868 | { |
876 | return i18n("Business Fax"); | 869 | return i18n("Business Fax"); |
877 | } | 870 | } |
878 | 871 | ||
879 | 872 | ||
880 | QString Addressee::carPhoneLabel() | 873 | QString Addressee::carPhoneLabel() |
881 | { | 874 | { |
882 | return i18n("Car Phone"); | 875 | return i18n("Car Phone"); |
883 | } | 876 | } |
884 | 877 | ||
885 | 878 | ||
886 | QString Addressee::isdnLabel() | 879 | QString Addressee::isdnLabel() |
887 | { | 880 | { |
888 | return i18n("ISDN"); | 881 | return i18n("ISDN"); |
889 | } | 882 | } |
890 | 883 | ||
891 | 884 | ||
892 | QString Addressee::pagerLabel() | 885 | QString Addressee::pagerLabel() |
893 | { | 886 | { |
894 | return i18n("Pager"); | 887 | return i18n("Pager"); |
895 | } | 888 | } |
896 | 889 | ||
897 | QString Addressee::sipLabel() | 890 | QString Addressee::sipLabel() |
898 | { | 891 | { |
899 | return i18n("SIP"); | 892 | return i18n("SIP"); |
900 | } | 893 | } |
901 | 894 | ||
902 | QString Addressee::emailLabel() | 895 | QString Addressee::emailLabel() |
903 | { | 896 | { |
904 | return i18n("Email Address"); | 897 | return i18n("Email Address"); |
905 | } | 898 | } |
906 | 899 | ||
907 | 900 | ||
908 | void Addressee::setMailer( const QString &mailer ) | 901 | void Addressee::setMailer( const QString &mailer ) |
909 | { | 902 | { |
910 | if ( mailer == mData->mailer ) return; | 903 | if ( mailer == mData->mailer ) return; |
911 | detach(); | 904 | detach(); |
912 | mData->empty = false; | 905 | mData->empty = false; |
913 | mData->mailer = mailer; | 906 | mData->mailer = mailer; |
914 | } | 907 | } |
915 | 908 | ||
916 | QString Addressee::mailer() const | 909 | QString Addressee::mailer() const |
917 | { | 910 | { |
918 | return mData->mailer; | 911 | return mData->mailer; |
919 | } | 912 | } |
920 | 913 | ||
921 | QString Addressee::mailerLabel() | 914 | QString Addressee::mailerLabel() |
922 | { | 915 | { |
923 | return i18n("Mail Client"); | 916 | return i18n("Mail Client"); |
924 | } | 917 | } |
925 | 918 | ||
926 | 919 | ||
927 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 920 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
928 | { | 921 | { |
929 | if ( timeZone == mData->timeZone ) return; | 922 | if ( timeZone == mData->timeZone ) return; |
930 | detach(); | 923 | detach(); |
931 | mData->empty = false; | 924 | mData->empty = false; |
932 | mData->timeZone = timeZone; | 925 | mData->timeZone = timeZone; |
933 | } | 926 | } |
934 | 927 | ||
935 | TimeZone Addressee::timeZone() const | 928 | TimeZone Addressee::timeZone() const |
936 | { | 929 | { |
937 | return mData->timeZone; | 930 | return mData->timeZone; |
938 | } | 931 | } |
939 | 932 | ||
940 | QString Addressee::timeZoneLabel() | 933 | QString Addressee::timeZoneLabel() |
941 | { | 934 | { |
942 | return i18n("Time Zone"); | 935 | return i18n("Time Zone"); |
943 | } | 936 | } |
944 | 937 | ||
945 | 938 | ||
946 | void Addressee::setGeo( const Geo &geo ) | 939 | void Addressee::setGeo( const Geo &geo ) |
947 | { | 940 | { |
948 | if ( geo == mData->geo ) return; | 941 | if ( geo == mData->geo ) return; |
949 | detach(); | 942 | detach(); |
950 | mData->empty = false; | 943 | mData->empty = false; |
951 | mData->geo = geo; | 944 | mData->geo = geo; |
952 | } | 945 | } |
953 | 946 | ||
954 | Geo Addressee::geo() const | 947 | Geo Addressee::geo() const |
955 | { | 948 | { |
956 | return mData->geo; | 949 | return mData->geo; |
957 | } | 950 | } |
958 | 951 | ||
959 | QString Addressee::geoLabel() | 952 | QString Addressee::geoLabel() |
960 | { | 953 | { |
961 | return i18n("Geographic Position"); | 954 | return i18n("Geographic Position"); |
962 | } | 955 | } |
963 | 956 | ||
964 | 957 | ||
965 | void Addressee::setTitle( const QString &title ) | 958 | void Addressee::setTitle( const QString &title ) |
966 | { | 959 | { |
967 | if ( title == mData->title ) return; | 960 | if ( title == mData->title ) return; |
968 | detach(); | 961 | detach(); |
969 | mData->empty = false; | 962 | mData->empty = false; |
970 | mData->title = title; | 963 | mData->title = title; |
971 | } | 964 | } |
972 | 965 | ||
973 | QString Addressee::title() const | 966 | QString Addressee::title() const |
974 | { | 967 | { |
975 | return mData->title; | 968 | return mData->title; |
976 | } | 969 | } |
977 | 970 | ||
978 | QString Addressee::titleLabel() | 971 | QString Addressee::titleLabel() |
979 | { | 972 | { |
980 | return i18n("Title"); | 973 | return i18n("Title"); |
981 | } | 974 | } |
982 | 975 | ||
983 | 976 | ||
984 | void Addressee::setRole( const QString &role ) | 977 | void Addressee::setRole( const QString &role ) |
985 | { | 978 | { |
986 | if ( role == mData->role ) return; | 979 | if ( role == mData->role ) return; |
987 | detach(); | 980 | detach(); |
988 | mData->empty = false; | 981 | mData->empty = false; |
989 | mData->role = role; | 982 | mData->role = role; |
990 | } | 983 | } |
991 | 984 | ||
992 | QString Addressee::role() const | 985 | QString Addressee::role() const |
993 | { | 986 | { |
994 | return mData->role; | 987 | return mData->role; |
995 | } | 988 | } |
996 | 989 | ||
997 | QString Addressee::roleLabel() | 990 | QString Addressee::roleLabel() |
998 | { | 991 | { |
999 | return i18n("Role"); | 992 | return i18n("Role"); |
1000 | } | 993 | } |
1001 | 994 | ||
1002 | 995 | ||
1003 | void Addressee::setOrganization( const QString &organization ) | 996 | void Addressee::setOrganization( const QString &organization ) |
1004 | { | 997 | { |
1005 | if ( organization == mData->organization ) return; | 998 | if ( organization == mData->organization ) return; |
1006 | detach(); | 999 | detach(); |
1007 | mData->empty = false; | 1000 | mData->empty = false; |
1008 | mData->organization = organization; | 1001 | mData->organization = organization; |
1009 | } | 1002 | } |
1010 | 1003 | ||
1011 | QString Addressee::organization() const | 1004 | QString Addressee::organization() const |
1012 | { | 1005 | { |
1013 | return mData->organization; | 1006 | return mData->organization; |
1014 | } | 1007 | } |
1015 | 1008 | ||
1016 | QString Addressee::organizationLabel() | 1009 | QString Addressee::organizationLabel() |
1017 | { | 1010 | { |
1018 | return i18n("Organization"); | 1011 | return i18n("Organization"); |
1019 | } | 1012 | } |
1020 | 1013 | ||
1021 | 1014 | ||
1022 | void Addressee::setNote( const QString ¬e ) | 1015 | void Addressee::setNote( const QString ¬e ) |
1023 | { | 1016 | { |
1024 | if ( note == mData->note ) return; | 1017 | if ( note == mData->note ) return; |
1025 | detach(); | 1018 | detach(); |
1026 | mData->empty = false; | 1019 | mData->empty = false; |
1027 | mData->note = note; | 1020 | mData->note = note; |
1028 | } | 1021 | } |
1029 | 1022 | ||
1030 | QString Addressee::note() const | 1023 | QString Addressee::note() const |
1031 | { | 1024 | { |
1032 | return mData->note; | 1025 | return mData->note; |
1033 | } | 1026 | } |
1034 | 1027 | ||
1035 | QString Addressee::noteLabel() | 1028 | QString Addressee::noteLabel() |
1036 | { | 1029 | { |
1037 | return i18n("Note"); | 1030 | return i18n("Note"); |
1038 | } | 1031 | } |
1039 | 1032 | ||
1040 | 1033 | ||
1041 | void Addressee::setProductId( const QString &productId ) | 1034 | void Addressee::setProductId( const QString &productId ) |
1042 | { | 1035 | { |
1043 | if ( productId == mData->productId ) return; | 1036 | if ( productId == mData->productId ) return; |
1044 | detach(); | 1037 | detach(); |
1045 | mData->empty = false; | 1038 | mData->empty = false; |
1046 | mData->productId = productId; | 1039 | mData->productId = productId; |
1047 | } | 1040 | } |
1048 | 1041 | ||
1049 | QString Addressee::productId() const | 1042 | QString Addressee::productId() const |
1050 | { | 1043 | { |
1051 | return mData->productId; | 1044 | return mData->productId; |
1052 | } | 1045 | } |
1053 | 1046 | ||
1054 | QString Addressee::productIdLabel() | 1047 | QString Addressee::productIdLabel() |
1055 | { | 1048 | { |
1056 | return i18n("Product Identifier"); | 1049 | return i18n("Product Identifier"); |
1057 | } | 1050 | } |
1058 | 1051 | ||
1059 | 1052 | ||
1060 | void Addressee::setRevision( const QDateTime &revision ) | 1053 | void Addressee::setRevision( const QDateTime &revision ) |
1061 | { | 1054 | { |
1062 | if ( revision == mData->revision ) return; | 1055 | if ( revision == mData->revision ) return; |
1063 | detach(); | 1056 | detach(); |
1064 | mData->empty = false; | 1057 | mData->empty = false; |
1065 | mData->revision = revision; | 1058 | mData->revision = revision; |
1066 | } | 1059 | } |
1067 | 1060 | ||
1068 | QDateTime Addressee::revision() const | 1061 | QDateTime Addressee::revision() const |
1069 | { | 1062 | { |
1070 | return mData->revision; | 1063 | return mData->revision; |
1071 | } | 1064 | } |
1072 | 1065 | ||
1073 | QString Addressee::revisionLabel() | 1066 | QString Addressee::revisionLabel() |
1074 | { | 1067 | { |
1075 | return i18n("Revision Date"); | 1068 | return i18n("Revision Date"); |
1076 | } | 1069 | } |
1077 | 1070 | ||
1078 | 1071 | ||
1079 | void Addressee::setSortString( const QString &sortString ) | 1072 | void Addressee::setSortString( const QString &sortString ) |
1080 | { | 1073 | { |
1081 | if ( sortString == mData->sortString ) return; | 1074 | if ( sortString == mData->sortString ) return; |
1082 | detach(); | 1075 | detach(); |
1083 | mData->empty = false; | 1076 | mData->empty = false; |
1084 | mData->sortString = sortString; | 1077 | mData->sortString = sortString; |
1085 | } | 1078 | } |
1086 | 1079 | ||
1087 | QString Addressee::sortString() const | 1080 | QString Addressee::sortString() const |
1088 | { | 1081 | { |
1089 | return mData->sortString; | 1082 | return mData->sortString; |
1090 | } | 1083 | } |
1091 | 1084 | ||
1092 | QString Addressee::sortStringLabel() | 1085 | QString Addressee::sortStringLabel() |
1093 | { | 1086 | { |
1094 | return i18n("Sort String"); | 1087 | return i18n("Sort String"); |
1095 | } | 1088 | } |
1096 | 1089 | ||
1097 | 1090 | ||
1098 | void Addressee::setUrl( const KURL &url ) | 1091 | void Addressee::setUrl( const KURL &url ) |
1099 | { | 1092 | { |
1100 | if ( url == mData->url ) return; | 1093 | if ( url == mData->url ) return; |
1101 | detach(); | 1094 | detach(); |
1102 | mData->empty = false; | 1095 | mData->empty = false; |
1103 | mData->url = url; | 1096 | mData->url = url; |
1104 | } | 1097 | } |
1105 | 1098 | ||
1106 | KURL Addressee::url() const | 1099 | KURL Addressee::url() const |
1107 | { | 1100 | { |
1108 | return mData->url; | 1101 | return mData->url; |
1109 | } | 1102 | } |
1110 | 1103 | ||
1111 | QString Addressee::urlLabel() | 1104 | QString Addressee::urlLabel() |
1112 | { | 1105 | { |
1113 | return i18n("URL"); | 1106 | return i18n("URL"); |
1114 | } | 1107 | } |
1115 | 1108 | ||
1116 | 1109 | ||
1117 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 1110 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
1118 | { | 1111 | { |
1119 | if ( secrecy == mData->secrecy ) return; | 1112 | if ( secrecy == mData->secrecy ) return; |
1120 | detach(); | 1113 | detach(); |
1121 | mData->empty = false; | 1114 | mData->empty = false; |
1122 | mData->secrecy = secrecy; | 1115 | mData->secrecy = secrecy; |
1123 | } | 1116 | } |
1124 | 1117 | ||
1125 | Secrecy Addressee::secrecy() const | 1118 | Secrecy Addressee::secrecy() const |
1126 | { | 1119 | { |
1127 | return mData->secrecy; | 1120 | return mData->secrecy; |
1128 | } | 1121 | } |
1129 | 1122 | ||
1130 | QString Addressee::secrecyLabel() | 1123 | QString Addressee::secrecyLabel() |
1131 | { | 1124 | { |
1132 | return i18n("Security Class"); | 1125 | return i18n("Security Class"); |
1133 | } | 1126 | } |
1134 | 1127 | ||
1135 | 1128 | ||
1136 | void Addressee::setLogo( const Picture &logo ) | 1129 | void Addressee::setLogo( const Picture &logo ) |
1137 | { | 1130 | { |
1138 | if ( logo == mData->logo ) return; | 1131 | if ( logo == mData->logo ) return; |
1139 | detach(); | 1132 | detach(); |
1140 | mData->empty = false; | 1133 | mData->empty = false; |
1141 | mData->logo = logo; | 1134 | mData->logo = logo; |
1142 | } | 1135 | } |
1143 | 1136 | ||
1144 | Picture Addressee::logo() const | 1137 | Picture Addressee::logo() const |
1145 | { | 1138 | { |
1146 | return mData->logo; | 1139 | return mData->logo; |
1147 | } | 1140 | } |
1148 | 1141 | ||
1149 | QString Addressee::logoLabel() | 1142 | QString Addressee::logoLabel() |
1150 | { | 1143 | { |
1151 | return i18n("Logo"); | 1144 | return i18n("Logo"); |
1152 | } | 1145 | } |
1153 | 1146 | ||
1154 | 1147 | ||
1155 | void Addressee::setPhoto( const Picture &photo ) | 1148 | void Addressee::setPhoto( const Picture &photo ) |
1156 | { | 1149 | { |
1157 | if ( photo == mData->photo ) return; | 1150 | if ( photo == mData->photo ) return; |
1158 | detach(); | 1151 | detach(); |
1159 | mData->empty = false; | 1152 | mData->empty = false; |
1160 | mData->photo = photo; | 1153 | mData->photo = photo; |
1161 | } | 1154 | } |
1162 | 1155 | ||
1163 | Picture Addressee::photo() const | 1156 | Picture Addressee::photo() const |
1164 | { | 1157 | { |
1165 | return mData->photo; | 1158 | return mData->photo; |
1166 | } | 1159 | } |
1167 | 1160 | ||
1168 | QString Addressee::photoLabel() | 1161 | QString Addressee::photoLabel() |
1169 | { | 1162 | { |
1170 | return i18n("Photo"); | 1163 | return i18n("Photo"); |
1171 | } | 1164 | } |
1172 | 1165 | ||
1173 | 1166 | ||
1174 | void Addressee::setSound( const Sound &sound ) | 1167 | void Addressee::setSound( const Sound &sound ) |
1175 | { | 1168 | { |
1176 | if ( sound == mData->sound ) return; | 1169 | if ( sound == mData->sound ) return; |
1177 | detach(); | 1170 | detach(); |
1178 | mData->empty = false; | 1171 | mData->empty = false; |
1179 | mData->sound = sound; | 1172 | mData->sound = sound; |
1180 | } | 1173 | } |
1181 | 1174 | ||
1182 | Sound Addressee::sound() const | 1175 | Sound Addressee::sound() const |
1183 | { | 1176 | { |
1184 | return mData->sound; | 1177 | return mData->sound; |
1185 | } | 1178 | } |
1186 | 1179 | ||
1187 | QString Addressee::soundLabel() | 1180 | QString Addressee::soundLabel() |
1188 | { | 1181 | { |
1189 | return i18n("Sound"); | 1182 | return i18n("Sound"); |
1190 | } | 1183 | } |
1191 | 1184 | ||
1192 | 1185 | ||
1193 | void Addressee::setAgent( const Agent &agent ) | 1186 | void Addressee::setAgent( const Agent &agent ) |
1194 | { | 1187 | { |
1195 | if ( agent == mData->agent ) return; | 1188 | if ( agent == mData->agent ) return; |
1196 | detach(); | 1189 | detach(); |
1197 | mData->empty = false; | 1190 | mData->empty = false; |
1198 | mData->agent = agent; | 1191 | mData->agent = agent; |
1199 | } | 1192 | } |
1200 | 1193 | ||
1201 | Agent Addressee::agent() const | 1194 | Agent Addressee::agent() const |
1202 | { | 1195 | { |
1203 | return mData->agent; | 1196 | return mData->agent; |
1204 | } | 1197 | } |
1205 | 1198 | ||
1206 | QString Addressee::agentLabel() | 1199 | QString Addressee::agentLabel() |
1207 | { | 1200 | { |
1208 | return i18n("Agent"); | 1201 | return i18n("Agent"); |
1209 | } | 1202 | } |
1210 | 1203 | ||
1211 | 1204 | ||
1212 | 1205 | ||
1213 | void Addressee::setNameFromString( const QString &str ) | 1206 | void Addressee::setNameFromString( const QString &str ) |
1214 | { | 1207 | { |
1215 | setFormattedName( str ); | 1208 | setFormattedName( str ); |
1216 | setName( str ); | 1209 | setName( str ); |
1217 | 1210 | ||
1218 | static bool first = true; | 1211 | static bool first = true; |
1219 | static QStringList titles; | 1212 | static QStringList titles; |
1220 | static QStringList suffixes; | 1213 | static QStringList suffixes; |
1221 | static QStringList prefixes; | 1214 | static QStringList prefixes; |
1222 | 1215 | ||
1223 | if ( first ) { | 1216 | if ( first ) { |
1224 | first = false; | 1217 | first = false; |
1225 | titles += i18n( "Dr." ); | 1218 | titles += i18n( "Dr." ); |
1226 | titles += i18n( "Miss" ); | 1219 | titles += i18n( "Miss" ); |
1227 | titles += i18n( "Mr." ); | 1220 | titles += i18n( "Mr." ); |
1228 | titles += i18n( "Mrs." ); | 1221 | titles += i18n( "Mrs." ); |
1229 | titles += i18n( "Ms." ); | 1222 | titles += i18n( "Ms." ); |
1230 | titles += i18n( "Prof." ); | 1223 | titles += i18n( "Prof." ); |
1231 | 1224 | ||
1232 | suffixes += i18n( "I" ); | 1225 | suffixes += i18n( "I" ); |
1233 | suffixes += i18n( "II" ); | 1226 | suffixes += i18n( "II" ); |
1234 | suffixes += i18n( "III" ); | 1227 | suffixes += i18n( "III" ); |
1235 | suffixes += i18n( "Jr." ); | 1228 | suffixes += i18n( "Jr." ); |
1236 | suffixes += i18n( "Sr." ); | 1229 | suffixes += i18n( "Sr." ); |
1237 | 1230 | ||
1238 | prefixes += "van"; | 1231 | prefixes += "van"; |
1239 | prefixes += "von"; | 1232 | prefixes += "von"; |
1240 | prefixes += "de"; | 1233 | prefixes += "de"; |
1241 | 1234 | ||
1242 | KConfig config( locateLocal( "config", "kabcrc") ); | 1235 | KConfig config( locateLocal( "config", "kabcrc") ); |
1243 | config.setGroup( "General" ); | 1236 | config.setGroup( "General" ); |
1244 | titles += config.readListEntry( "Prefixes" ); | 1237 | titles += config.readListEntry( "Prefixes" ); |
1245 | titles.remove( "" ); | 1238 | titles.remove( "" ); |
1246 | prefixes += config.readListEntry( "Inclusions" ); | 1239 | prefixes += config.readListEntry( "Inclusions" ); |
1247 | prefixes.remove( "" ); | 1240 | prefixes.remove( "" ); |
1248 | suffixes += config.readListEntry( "Suffixes" ); | 1241 | suffixes += config.readListEntry( "Suffixes" ); |
1249 | suffixes.remove( "" ); | 1242 | suffixes.remove( "" ); |
1250 | } | 1243 | } |
1251 | 1244 | ||
1252 | // clear all name parts | 1245 | // clear all name parts |
1253 | setPrefix( "" ); | 1246 | setPrefix( "" ); |
1254 | setGivenName( "" ); | 1247 | setGivenName( "" ); |
1255 | setAdditionalName( "" ); | 1248 | setAdditionalName( "" ); |
1256 | setFamilyName( "" ); | 1249 | setFamilyName( "" ); |
1257 | setSuffix( "" ); | 1250 | setSuffix( "" ); |
1258 | 1251 | ||
1259 | if ( str.isEmpty() ) | 1252 | if ( str.isEmpty() ) |
1260 | return; | 1253 | return; |
1261 | 1254 | ||
1262 | int i = str.find(','); | 1255 | int i = str.find(','); |
1263 | if( i < 0 ) { | 1256 | if( i < 0 ) { |
1264 | QStringList parts = QStringList::split( " ", str ); | 1257 | QStringList parts = QStringList::split( " ", str ); |
1265 | int leftOffset = 0; | 1258 | int leftOffset = 0; |
1266 | int rightOffset = parts.count() - 1; | 1259 | int rightOffset = parts.count() - 1; |
1267 | 1260 | ||
1268 | QString suffix; | 1261 | QString suffix; |
1269 | while ( rightOffset >= 0 ) { | 1262 | while ( rightOffset >= 0 ) { |
1270 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1263 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1271 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1264 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1272 | rightOffset--; | 1265 | rightOffset--; |
1273 | } else | 1266 | } else |
1274 | break; | 1267 | break; |
1275 | } | 1268 | } |
1276 | setSuffix( suffix ); | 1269 | setSuffix( suffix ); |
1277 | 1270 | ||
1278 | if ( rightOffset < 0 ) | 1271 | if ( rightOffset < 0 ) |
1279 | return; | 1272 | return; |
1280 | 1273 | ||
1281 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1274 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1282 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1275 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1283 | rightOffset--; | 1276 | rightOffset--; |
1284 | } else | 1277 | } else |
1285 | setFamilyName( parts[ rightOffset ] ); | 1278 | setFamilyName( parts[ rightOffset ] ); |
1286 | 1279 | ||
1287 | QString prefix; | 1280 | QString prefix; |
1288 | while ( leftOffset < rightOffset ) { | 1281 | while ( leftOffset < rightOffset ) { |
1289 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1282 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1290 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1283 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1291 | leftOffset++; | 1284 | leftOffset++; |
1292 | } else | 1285 | } else |
1293 | break; | 1286 | break; |
1294 | } | 1287 | } |
1295 | setPrefix( prefix ); | 1288 | setPrefix( prefix ); |
1296 | 1289 | ||
1297 | if ( leftOffset < rightOffset ) { | 1290 | if ( leftOffset < rightOffset ) { |
1298 | setGivenName( parts[ leftOffset ] ); | 1291 | setGivenName( parts[ leftOffset ] ); |
1299 | leftOffset++; | 1292 | leftOffset++; |
1300 | } | 1293 | } |
1301 | 1294 | ||
1302 | QString additionalName; | 1295 | QString additionalName; |
1303 | while ( leftOffset < rightOffset ) { | 1296 | while ( leftOffset < rightOffset ) { |
1304 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1297 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1305 | leftOffset++; | 1298 | leftOffset++; |
1306 | } | 1299 | } |
1307 | setAdditionalName( additionalName ); | 1300 | setAdditionalName( additionalName ); |
1308 | } else { | 1301 | } else { |
1309 | QString part1 = str.left( i ); | 1302 | QString part1 = str.left( i ); |
1310 | QString part2 = str.mid( i + 1 ); | 1303 | QString part2 = str.mid( i + 1 ); |
1311 | 1304 | ||
1312 | QStringList parts = QStringList::split( " ", part1 ); | 1305 | QStringList parts = QStringList::split( " ", part1 ); |
1313 | int leftOffset = 0; | 1306 | int leftOffset = 0; |
1314 | int rightOffset = parts.count() - 1; | 1307 | int rightOffset = parts.count() - 1; |
1315 | 1308 | ||
1316 | QString suffix; | 1309 | QString suffix; |
1317 | while ( rightOffset >= 0 ) { | 1310 | while ( rightOffset >= 0 ) { |
1318 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1311 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1319 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1312 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1320 | rightOffset--; | 1313 | rightOffset--; |
1321 | } else | 1314 | } else |
1322 | break; | 1315 | break; |
1323 | } | 1316 | } |
1324 | setSuffix( suffix ); | 1317 | setSuffix( suffix ); |
1325 | 1318 | ||
1326 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1319 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1327 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1320 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1328 | rightOffset--; | 1321 | rightOffset--; |
1329 | } else | 1322 | } else |
1330 | setFamilyName( parts[ rightOffset ] ); | 1323 | setFamilyName( parts[ rightOffset ] ); |
1331 | 1324 | ||
1332 | QString prefix; | 1325 | QString prefix; |
1333 | while ( leftOffset < rightOffset ) { | 1326 | while ( leftOffset < rightOffset ) { |
1334 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1327 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1335 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1328 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1336 | leftOffset++; | 1329 | leftOffset++; |
1337 | } else | 1330 | } else |
1338 | break; | 1331 | break; |
1339 | } | 1332 | } |
1340 | 1333 | ||
1341 | parts = QStringList::split( " ", part2 ); | 1334 | parts = QStringList::split( " ", part2 ); |
1342 | 1335 | ||
1343 | leftOffset = 0; | 1336 | leftOffset = 0; |
1344 | rightOffset = parts.count(); | 1337 | rightOffset = parts.count(); |
1345 | 1338 | ||
1346 | while ( leftOffset < rightOffset ) { | 1339 | while ( leftOffset < rightOffset ) { |
1347 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1340 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1348 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1341 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1349 | leftOffset++; | 1342 | leftOffset++; |
1350 | } else | 1343 | } else |
1351 | break; | 1344 | break; |
1352 | } | 1345 | } |
1353 | setPrefix( prefix ); | 1346 | setPrefix( prefix ); |
1354 | 1347 | ||
1355 | if ( leftOffset < rightOffset ) { | 1348 | if ( leftOffset < rightOffset ) { |
1356 | setGivenName( parts[ leftOffset ] ); | 1349 | setGivenName( parts[ leftOffset ] ); |
1357 | leftOffset++; | 1350 | leftOffset++; |
1358 | } | 1351 | } |
1359 | 1352 | ||
1360 | QString additionalName; | 1353 | QString additionalName; |
1361 | while ( leftOffset < rightOffset ) { | 1354 | while ( leftOffset < rightOffset ) { |
1362 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1355 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1363 | leftOffset++; | 1356 | leftOffset++; |
1364 | } | 1357 | } |
1365 | setAdditionalName( additionalName ); | 1358 | setAdditionalName( additionalName ); |
1366 | } | 1359 | } |
1367 | } | 1360 | } |
1368 | 1361 | ||
1369 | QString Addressee::realName() const | 1362 | QString Addressee::realName() const |
1370 | { | 1363 | { |
1371 | if ( !formattedName().isEmpty() ) | 1364 | if ( !formattedName().isEmpty() ) |
1372 | return formattedName(); | 1365 | return formattedName(); |
1373 | 1366 | ||
1374 | QString n = assembledName(); | 1367 | QString n = assembledName(); |
1375 | 1368 | ||
1376 | if ( n.isEmpty() ) | 1369 | if ( n.isEmpty() ) |
1377 | n = name(); | 1370 | n = name(); |
1378 | 1371 | ||
1379 | return n; | 1372 | return n; |
1380 | } | 1373 | } |
1381 | 1374 | ||
1382 | QString Addressee::assembledName() const | 1375 | QString Addressee::assembledName() const |
1383 | { | 1376 | { |
1384 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1377 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1385 | familyName() + " " + suffix(); | 1378 | familyName() + " " + suffix(); |
1386 | 1379 | ||
1387 | return name.simplifyWhiteSpace(); | 1380 | return name.simplifyWhiteSpace(); |
1388 | } | 1381 | } |
1389 | 1382 | ||
1390 | QString Addressee::fullEmail( const QString &email ) const | 1383 | QString Addressee::fullEmail( const QString &email ) const |
1391 | { | 1384 | { |
1392 | QString e; | 1385 | QString e; |
1393 | if ( email.isNull() ) { | 1386 | if ( email.isNull() ) { |
1394 | e = preferredEmail(); | 1387 | e = preferredEmail(); |
1395 | } else { | 1388 | } else { |
1396 | e = email; | 1389 | e = email; |
1397 | } | 1390 | } |
1398 | if ( e.isEmpty() ) return QString::null; | 1391 | if ( e.isEmpty() ) return QString::null; |
1399 | 1392 | ||
1400 | QString text; | 1393 | QString text; |
1401 | if ( realName().isEmpty() ) | 1394 | if ( realName().isEmpty() ) |
1402 | text = e; | 1395 | text = e; |
1403 | else | 1396 | else |
1404 | text = assembledName() + " <" + e + ">"; | 1397 | text = assembledName() + " <" + e + ">"; |
1405 | 1398 | ||
1406 | return text; | 1399 | return text; |
1407 | } | 1400 | } |
1408 | 1401 | ||
1409 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1402 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1410 | { | 1403 | { |
1411 | detach(); | 1404 | detach(); |
1412 | 1405 | ||
1413 | QStringList::Iterator it = mData->emails.find( email ); | 1406 | QStringList::Iterator it = mData->emails.find( email ); |
1414 | 1407 | ||
1415 | if ( it != mData->emails.end() ) { | 1408 | if ( it != mData->emails.end() ) { |
1416 | if ( !preferred || it == mData->emails.begin() ) return; | 1409 | if ( !preferred || it == mData->emails.begin() ) return; |
1417 | mData->emails.remove( it ); | 1410 | mData->emails.remove( it ); |
1418 | mData->emails.prepend( email ); | 1411 | mData->emails.prepend( email ); |
1419 | } else { | 1412 | } else { |
1420 | if ( preferred ) { | 1413 | if ( preferred ) { |
1421 | mData->emails.prepend( email ); | 1414 | mData->emails.prepend( email ); |
1422 | } else { | 1415 | } else { |
1423 | mData->emails.append( email ); | 1416 | mData->emails.append( email ); |
1424 | } | 1417 | } |
1425 | } | 1418 | } |
1426 | } | 1419 | } |
1427 | 1420 | ||
1428 | void Addressee::removeEmail( const QString &email ) | 1421 | void Addressee::removeEmail( const QString &email ) |
1429 | { | 1422 | { |
1430 | detach(); | 1423 | detach(); |
1431 | 1424 | ||
1432 | QStringList::Iterator it = mData->emails.find( email ); | 1425 | QStringList::Iterator it = mData->emails.find( email ); |
1433 | if ( it == mData->emails.end() ) return; | 1426 | if ( it == mData->emails.end() ) return; |
1434 | 1427 | ||
1435 | mData->emails.remove( it ); | 1428 | mData->emails.remove( it ); |
1436 | } | 1429 | } |
1437 | 1430 | ||
1438 | QString Addressee::preferredEmail() const | 1431 | QString Addressee::preferredEmail() const |
1439 | { | 1432 | { |
1440 | if ( mData->emails.count() == 0 ) return QString::null; | 1433 | if ( mData->emails.count() == 0 ) return QString::null; |
1441 | else return mData->emails.first(); | 1434 | else return mData->emails.first(); |
1442 | } | 1435 | } |
1443 | 1436 | ||
1444 | QStringList Addressee::emails() const | 1437 | QStringList Addressee::emails() const |
1445 | { | 1438 | { |
1446 | return mData->emails; | 1439 | return mData->emails; |
1447 | } | 1440 | } |
1448 | void Addressee::setEmails( const QStringList& emails ) { | 1441 | void Addressee::setEmails( const QStringList& emails ) { |
1449 | detach(); | 1442 | detach(); |
1450 | mData->emails = emails; | 1443 | mData->emails = emails; |
1451 | } | 1444 | } |
1452 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1445 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1453 | { | 1446 | { |
1454 | detach(); | 1447 | detach(); |
1455 | mData->empty = false; | 1448 | mData->empty = false; |
1456 | 1449 | ||
1457 | PhoneNumber::List::Iterator it; | 1450 | PhoneNumber::List::Iterator it; |
1458 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1451 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1459 | if ( (*it).id() == phoneNumber.id() ) { | 1452 | if ( (*it).id() == phoneNumber.id() ) { |
1460 | *it = phoneNumber; | 1453 | *it = phoneNumber; |
1461 | return; | 1454 | return; |
1462 | } | 1455 | } |
1463 | } | 1456 | } |
1464 | mData->phoneNumbers.append( phoneNumber ); | 1457 | mData->phoneNumbers.append( phoneNumber ); |
1465 | } | 1458 | } |
1466 | 1459 | ||
1467 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1460 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1468 | { | 1461 | { |
1469 | detach(); | 1462 | detach(); |
1470 | 1463 | ||
1471 | PhoneNumber::List::Iterator it; | 1464 | PhoneNumber::List::Iterator it; |
1472 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1465 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1473 | if ( (*it).id() == phoneNumber.id() ) { | 1466 | if ( (*it).id() == phoneNumber.id() ) { |
1474 | mData->phoneNumbers.remove( it ); | 1467 | mData->phoneNumbers.remove( it ); |
1475 | return; | 1468 | return; |
1476 | } | 1469 | } |
1477 | } | 1470 | } |
1478 | } | 1471 | } |
1479 | 1472 | ||
1480 | PhoneNumber Addressee::phoneNumber( int type ) const | 1473 | PhoneNumber Addressee::phoneNumber( int type ) const |
1481 | { | 1474 | { |
1482 | PhoneNumber phoneNumber( "", type ); | 1475 | PhoneNumber phoneNumber( "", type ); |
1483 | PhoneNumber::List::ConstIterator it; | 1476 | PhoneNumber::List::ConstIterator it; |
1484 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1477 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1485 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1478 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1486 | if ( (*it).type() & PhoneNumber::Pref ) | 1479 | if ( (*it).type() & PhoneNumber::Pref ) |
1487 | return (*it); | 1480 | return (*it); |
1488 | else if ( phoneNumber.number().isEmpty() ) | 1481 | else if ( phoneNumber.number().isEmpty() ) |
1489 | phoneNumber = (*it); | 1482 | phoneNumber = (*it); |
1490 | } | 1483 | } |
1491 | } | 1484 | } |
1492 | 1485 | ||
1493 | return phoneNumber; | 1486 | return phoneNumber; |
1494 | } | 1487 | } |
1495 | 1488 | ||
1496 | PhoneNumber::List Addressee::phoneNumbers() const | 1489 | PhoneNumber::List Addressee::phoneNumbers() const |
1497 | { | 1490 | { |
1498 | return mData->phoneNumbers; | 1491 | return mData->phoneNumbers; |
1499 | } | 1492 | } |
1500 | 1493 | ||
1501 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1494 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1502 | { | 1495 | { |
1503 | PhoneNumber::List list; | 1496 | PhoneNumber::List list; |
1504 | 1497 | ||
1505 | PhoneNumber::List::ConstIterator it; | 1498 | PhoneNumber::List::ConstIterator it; |
1506 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1499 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1507 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1500 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1508 | list.append( *it ); | 1501 | list.append( *it ); |
1509 | } | 1502 | } |
1510 | } | 1503 | } |
1511 | return list; | 1504 | return list; |
1512 | } | 1505 | } |
1513 | 1506 | ||
1514 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1507 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1515 | { | 1508 | { |
1516 | PhoneNumber::List::ConstIterator it; | 1509 | PhoneNumber::List::ConstIterator it; |
1517 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1510 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1518 | if ( (*it).id() == id ) { | 1511 | if ( (*it).id() == id ) { |
1519 | return *it; | 1512 | return *it; |
1520 | } | 1513 | } |
1521 | } | 1514 | } |
1522 | return PhoneNumber(); | 1515 | return PhoneNumber(); |
1523 | } | 1516 | } |
1524 | 1517 | ||
1525 | void Addressee::insertKey( const Key &key ) | 1518 | void Addressee::insertKey( const Key &key ) |
1526 | { | 1519 | { |
1527 | detach(); | 1520 | detach(); |
1528 | mData->empty = false; | 1521 | mData->empty = false; |
1529 | 1522 | ||
1530 | Key::List::Iterator it; | 1523 | Key::List::Iterator it; |
1531 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1524 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1532 | if ( (*it).id() == key.id() ) { | 1525 | if ( (*it).id() == key.id() ) { |
1533 | *it = key; | 1526 | *it = key; |
1534 | return; | 1527 | return; |
1535 | } | 1528 | } |
1536 | } | 1529 | } |
1537 | mData->keys.append( key ); | 1530 | mData->keys.append( key ); |
1538 | } | 1531 | } |
1539 | 1532 | ||
1540 | void Addressee::removeKey( const Key &key ) | 1533 | void Addressee::removeKey( const Key &key ) |
1541 | { | 1534 | { |
1542 | detach(); | 1535 | detach(); |
1543 | 1536 | ||
1544 | Key::List::Iterator it; | 1537 | Key::List::Iterator it; |
1545 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1538 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1546 | if ( (*it).id() == key.id() ) { | 1539 | if ( (*it).id() == key.id() ) { |
1547 | mData->keys.remove( key ); | 1540 | mData->keys.remove( key ); |
1548 | return; | 1541 | return; |
1549 | } | 1542 | } |
1550 | } | 1543 | } |
1551 | } | 1544 | } |
1552 | 1545 | ||
1553 | Key Addressee::key( int type, QString customTypeString ) const | 1546 | Key Addressee::key( int type, QString customTypeString ) const |
1554 | { | 1547 | { |
1555 | Key::List::ConstIterator it; | 1548 | Key::List::ConstIterator it; |
1556 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1549 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1557 | if ( (*it).type() == type ) { | 1550 | if ( (*it).type() == type ) { |
1558 | if ( type == Key::Custom ) { | 1551 | if ( type == Key::Custom ) { |
1559 | if ( customTypeString.isEmpty() ) { | 1552 | if ( customTypeString.isEmpty() ) { |
1560 | return *it; | 1553 | return *it; |
1561 | } else { | 1554 | } else { |
1562 | if ( (*it).customTypeString() == customTypeString ) | 1555 | if ( (*it).customTypeString() == customTypeString ) |
1563 | return (*it); | 1556 | return (*it); |
1564 | } | 1557 | } |
1565 | } else { | 1558 | } else { |
1566 | return *it; | 1559 | return *it; |
1567 | } | 1560 | } |
1568 | } | 1561 | } |
1569 | } | 1562 | } |
1570 | return Key( QString(), type ); | 1563 | return Key( QString(), type ); |
1571 | } | 1564 | } |
1572 | void Addressee::setKeys( const Key::List& list ) { | 1565 | void Addressee::setKeys( const Key::List& list ) { |
1573 | detach(); | 1566 | detach(); |
1574 | mData->keys = list; | 1567 | mData->keys = list; |
1575 | } | 1568 | } |
1576 | 1569 | ||
1577 | Key::List Addressee::keys() const | 1570 | Key::List Addressee::keys() const |
1578 | { | 1571 | { |
1579 | return mData->keys; | 1572 | return mData->keys; |
1580 | } | 1573 | } |
1581 | 1574 | ||
1582 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1575 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1583 | { | 1576 | { |
1584 | Key::List list; | 1577 | Key::List list; |
1585 | 1578 | ||
1586 | Key::List::ConstIterator it; | 1579 | Key::List::ConstIterator it; |
1587 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1580 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1588 | if ( (*it).type() == type ) { | 1581 | if ( (*it).type() == type ) { |
1589 | if ( type == Key::Custom ) { | 1582 | if ( type == Key::Custom ) { |
1590 | if ( customTypeString.isEmpty() ) { | 1583 | if ( customTypeString.isEmpty() ) { |
1591 | list.append(*it); | 1584 | list.append(*it); |
1592 | } else { | 1585 | } else { |
1593 | if ( (*it).customTypeString() == customTypeString ) | 1586 | if ( (*it).customTypeString() == customTypeString ) |
1594 | list.append(*it); | 1587 | list.append(*it); |
1595 | } | 1588 | } |
1596 | } else { | 1589 | } else { |
1597 | list.append(*it); | 1590 | list.append(*it); |
1598 | } | 1591 | } |
1599 | } | 1592 | } |
1600 | } | 1593 | } |
1601 | return list; | 1594 | return list; |
1602 | } | 1595 | } |
1603 | 1596 | ||
1604 | Key Addressee::findKey( const QString &id ) const | 1597 | Key Addressee::findKey( const QString &id ) const |
1605 | { | 1598 | { |
1606 | Key::List::ConstIterator it; | 1599 | Key::List::ConstIterator it; |
1607 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1600 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1608 | if ( (*it).id() == id ) { | 1601 | if ( (*it).id() == id ) { |
1609 | return *it; | 1602 | return *it; |
1610 | } | 1603 | } |
1611 | } | 1604 | } |
1612 | return Key(); | 1605 | return Key(); |
1613 | } | 1606 | } |
1614 | 1607 | ||
1615 | QString Addressee::asString() const | 1608 | QString Addressee::asString() const |
1616 | { | 1609 | { |
1617 | return "Smith, agent Smith..."; | 1610 | return "Smith, agent Smith..."; |
1618 | } | 1611 | } |
1619 | 1612 | ||
1620 | void Addressee::dump() const | 1613 | void Addressee::dump() const |
1621 | { | 1614 | { |
1622 | return; | 1615 | return; |
1623 | kdDebug(5700) << "Addressee {" << endl; | 1616 | kdDebug(5700) << "Addressee {" << endl; |
1624 | 1617 | ||
1625 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1618 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1626 | 1619 | ||
1627 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1620 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1628 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1621 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1629 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1622 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1630 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1623 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1631 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1624 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1632 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1625 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1633 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1626 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1634 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1627 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1635 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1628 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1636 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1629 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1637 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1630 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1638 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1631 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1639 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1632 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1640 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1633 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1641 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1634 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1642 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1635 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1643 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1636 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1644 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1637 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1645 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1638 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1646 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1639 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1647 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1640 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1648 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1641 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1649 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1642 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1650 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1643 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1651 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1644 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1652 | 1645 | ||
1653 | kdDebug(5700) << " Emails {" << endl; | 1646 | kdDebug(5700) << " Emails {" << endl; |
1654 | QStringList e = emails(); | 1647 | QStringList e = emails(); |
1655 | QStringList::ConstIterator it; | 1648 | QStringList::ConstIterator it; |
1656 | for( it = e.begin(); it != e.end(); ++it ) { | 1649 | for( it = e.begin(); it != e.end(); ++it ) { |
1657 | kdDebug(5700) << " " << (*it) << endl; | 1650 | kdDebug(5700) << " " << (*it) << endl; |
1658 | } | 1651 | } |
1659 | kdDebug(5700) << " }" << endl; | 1652 | kdDebug(5700) << " }" << endl; |
1660 | 1653 | ||
1661 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1654 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1662 | PhoneNumber::List p = phoneNumbers(); | 1655 | PhoneNumber::List p = phoneNumbers(); |
1663 | PhoneNumber::List::ConstIterator it2; | 1656 | PhoneNumber::List::ConstIterator it2; |
1664 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1657 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1665 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1658 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1666 | } | 1659 | } |
1667 | kdDebug(5700) << " }" << endl; | 1660 | kdDebug(5700) << " }" << endl; |
1668 | 1661 | ||
1669 | Address::List a = addresses(); | 1662 | Address::List a = addresses(); |
1670 | Address::List::ConstIterator it3; | 1663 | Address::List::ConstIterator it3; |
1671 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1664 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1672 | (*it3).dump(); | 1665 | (*it3).dump(); |
1673 | } | 1666 | } |
1674 | 1667 | ||
1675 | kdDebug(5700) << " Keys {" << endl; | 1668 | kdDebug(5700) << " Keys {" << endl; |
1676 | Key::List k = keys(); | 1669 | Key::List k = keys(); |
1677 | Key::List::ConstIterator it4; | 1670 | Key::List::ConstIterator it4; |
1678 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1671 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1679 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1672 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1680 | " Key: " << (*it4).textData() << | 1673 | " Key: " << (*it4).textData() << |
1681 | " CustomString: " << (*it4).customTypeString() << endl; | 1674 | " CustomString: " << (*it4).customTypeString() << endl; |
1682 | } | 1675 | } |
1683 | kdDebug(5700) << " }" << endl; | 1676 | kdDebug(5700) << " }" << endl; |
1684 | 1677 | ||
1685 | kdDebug(5700) << "}" << endl; | 1678 | kdDebug(5700) << "}" << endl; |
1686 | } | 1679 | } |
1687 | 1680 | ||
1688 | 1681 | ||
1689 | void Addressee::insertAddress( const Address &address ) | 1682 | void Addressee::insertAddress( const Address &address ) |
1690 | { | 1683 | { |
1691 | detach(); | 1684 | detach(); |
1692 | mData->empty = false; | 1685 | mData->empty = false; |
1693 | 1686 | ||
1694 | Address::List::Iterator it; | 1687 | Address::List::Iterator it; |
1695 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1688 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1696 | if ( (*it).id() == address.id() ) { | 1689 | if ( (*it).id() == address.id() ) { |
1697 | *it = address; | 1690 | *it = address; |
1698 | return; | 1691 | return; |
1699 | } | 1692 | } |
1700 | } | 1693 | } |
1701 | mData->addresses.append( address ); | 1694 | mData->addresses.append( address ); |
1702 | } | 1695 | } |
1703 | 1696 | ||
1704 | void Addressee::removeAddress( const Address &address ) | 1697 | void Addressee::removeAddress( const Address &address ) |
1705 | { | 1698 | { |
1706 | detach(); | 1699 | detach(); |
1707 | 1700 | ||
1708 | Address::List::Iterator it; | 1701 | Address::List::Iterator it; |
1709 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1702 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1710 | if ( (*it).id() == address.id() ) { | 1703 | if ( (*it).id() == address.id() ) { |
1711 | mData->addresses.remove( it ); | 1704 | mData->addresses.remove( it ); |
1712 | return; | 1705 | return; |
1713 | } | 1706 | } |
1714 | } | 1707 | } |
1715 | } | 1708 | } |
1716 | 1709 | ||
1717 | Address Addressee::address( int type ) const | 1710 | Address Addressee::address( int type ) const |
1718 | { | 1711 | { |
1719 | Address address( type ); | 1712 | Address address( type ); |
1720 | Address::List::ConstIterator it; | 1713 | Address::List::ConstIterator it; |
1721 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1714 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1722 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 1715 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1723 | if ( (*it).type() & Address::Pref ) | 1716 | if ( (*it).type() & Address::Pref ) |
1724 | return (*it); | 1717 | return (*it); |
1725 | else if ( address.isEmpty() ) | 1718 | else if ( address.isEmpty() ) |
1726 | address = (*it); | 1719 | address = (*it); |
1727 | } | 1720 | } |
1728 | } | 1721 | } |
1729 | 1722 | ||
1730 | return address; | 1723 | return address; |
1731 | } | 1724 | } |
1732 | 1725 | ||
1733 | Address::List Addressee::addresses() const | 1726 | Address::List Addressee::addresses() const |
1734 | { | 1727 | { |
1735 | return mData->addresses; | 1728 | return mData->addresses; |
1736 | } | 1729 | } |
1737 | 1730 | ||
1738 | Address::List Addressee::addresses( int type ) const | 1731 | Address::List Addressee::addresses( int type ) const |
1739 | { | 1732 | { |
1740 | Address::List list; | 1733 | Address::List list; |
1741 | 1734 | ||
1742 | Address::List::ConstIterator it; | 1735 | Address::List::ConstIterator it; |
1743 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1736 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1744 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1737 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1745 | list.append( *it ); | 1738 | list.append( *it ); |
1746 | } | 1739 | } |
1747 | } | 1740 | } |
1748 | 1741 | ||
1749 | return list; | 1742 | return list; |
1750 | } | 1743 | } |
1751 | 1744 | ||
1752 | Address Addressee::findAddress( const QString &id ) const | 1745 | Address Addressee::findAddress( const QString &id ) const |
1753 | { | 1746 | { |
1754 | Address::List::ConstIterator it; | 1747 | Address::List::ConstIterator it; |
1755 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1748 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1756 | if ( (*it).id() == id ) { | 1749 | if ( (*it).id() == id ) { |
1757 | return *it; | 1750 | return *it; |
1758 | } | 1751 | } |
1759 | } | 1752 | } |
1760 | return Address(); | 1753 | return Address(); |
1761 | } | 1754 | } |
1762 | 1755 | ||
1763 | void Addressee::insertCategory( const QString &c ) | 1756 | void Addressee::insertCategory( const QString &c ) |
1764 | { | 1757 | { |
1765 | detach(); | 1758 | detach(); |
1766 | mData->empty = false; | 1759 | mData->empty = false; |
1767 | 1760 | ||
1768 | if ( mData->categories.contains( c ) ) return; | 1761 | if ( mData->categories.contains( c ) ) return; |
1769 | 1762 | ||
1770 | mData->categories.append( c ); | 1763 | mData->categories.append( c ); |
1771 | } | 1764 | } |
1772 | 1765 | ||
1773 | void Addressee::removeCategory( const QString &c ) | 1766 | void Addressee::removeCategory( const QString &c ) |
1774 | { | 1767 | { |
1775 | detach(); | 1768 | detach(); |
1776 | 1769 | ||
1777 | QStringList::Iterator it = mData->categories.find( c ); | 1770 | QStringList::Iterator it = mData->categories.find( c ); |
1778 | if ( it == mData->categories.end() ) return; | 1771 | if ( it == mData->categories.end() ) return; |
1779 | 1772 | ||
1780 | mData->categories.remove( it ); | 1773 | mData->categories.remove( it ); |
1781 | } | 1774 | } |
1782 | 1775 | ||
1783 | bool Addressee::hasCategory( const QString &c ) const | 1776 | bool Addressee::hasCategory( const QString &c ) const |
1784 | { | 1777 | { |
1785 | return ( mData->categories.contains( c ) ); | 1778 | return ( mData->categories.contains( c ) ); |
1786 | } | 1779 | } |
1787 | 1780 | ||
1788 | void Addressee::setCategories( const QStringList &c ) | 1781 | void Addressee::setCategories( const QStringList &c ) |
1789 | { | 1782 | { |
1790 | detach(); | 1783 | detach(); |
1791 | mData->empty = false; | 1784 | mData->empty = false; |
1792 | 1785 | ||
1793 | mData->categories = c; | 1786 | mData->categories = c; |
1794 | } | 1787 | } |
1795 | 1788 | ||
1796 | QStringList Addressee::categories() const | 1789 | QStringList Addressee::categories() const |
1797 | { | 1790 | { |
1798 | return mData->categories; | 1791 | return mData->categories; |
1799 | } | 1792 | } |
1800 | 1793 | ||
1801 | void Addressee::insertCustom( const QString &app, const QString &name, | 1794 | void Addressee::insertCustom( const QString &app, const QString &name, |
1802 | const QString &value ) | 1795 | const QString &value ) |
1803 | { | 1796 | { |
1804 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1797 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1805 | 1798 | ||
1806 | detach(); | 1799 | detach(); |
1807 | mData->empty = false; | 1800 | mData->empty = false; |
1808 | 1801 | ||
1809 | QString qualifiedName = app + "-" + name + ":"; | 1802 | QString qualifiedName = app + "-" + name + ":"; |
1810 | 1803 | ||
1811 | QStringList::Iterator it; | 1804 | QStringList::Iterator it; |
1812 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1805 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1813 | if ( (*it).startsWith( qualifiedName ) ) { | 1806 | if ( (*it).startsWith( qualifiedName ) ) { |
1814 | (*it) = qualifiedName + value; | 1807 | (*it) = qualifiedName + value; |
1815 | return; | 1808 | return; |
1816 | } | 1809 | } |
1817 | } | 1810 | } |
1818 | mData->custom.append( qualifiedName + value ); | 1811 | mData->custom.append( qualifiedName + value ); |
1819 | } | 1812 | } |
1820 | 1813 | ||
1821 | void Addressee::removeCustom( const QString &app, const QString &name) | 1814 | void Addressee::removeCustom( const QString &app, const QString &name) |
1822 | { | 1815 | { |
1823 | detach(); | 1816 | detach(); |
1824 | 1817 | ||
1825 | QString qualifiedName = app + "-" + name + ":"; | 1818 | QString qualifiedName = app + "-" + name + ":"; |
1826 | 1819 | ||
1827 | QStringList::Iterator it; | 1820 | QStringList::Iterator it; |
1828 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1821 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1829 | if ( (*it).startsWith( qualifiedName ) ) { | 1822 | if ( (*it).startsWith( qualifiedName ) ) { |
1830 | mData->custom.remove( it ); | 1823 | mData->custom.remove( it ); |
1831 | return; | 1824 | return; |
1832 | } | 1825 | } |
1833 | } | 1826 | } |
1834 | } | 1827 | } |
1835 | 1828 | ||
1836 | QString Addressee::custom( const QString &app, const QString &name ) const | 1829 | QString Addressee::custom( const QString &app, const QString &name ) const |
1837 | { | 1830 | { |
1838 | QString qualifiedName = app + "-" + name + ":"; | 1831 | QString qualifiedName = app + "-" + name + ":"; |
1839 | QString value; | 1832 | QString value; |
1840 | 1833 | ||
1841 | QStringList::ConstIterator it; | 1834 | QStringList::ConstIterator it; |
1842 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1835 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1843 | if ( (*it).startsWith( qualifiedName ) ) { | 1836 | if ( (*it).startsWith( qualifiedName ) ) { |
1844 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1837 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1845 | break; | 1838 | break; |
1846 | } | 1839 | } |
1847 | } | 1840 | } |
1848 | 1841 | ||
1849 | return value; | 1842 | return value; |
1850 | } | 1843 | } |
1851 | 1844 | ||
1852 | void Addressee::setCustoms( const QStringList &l ) | 1845 | void Addressee::setCustoms( const QStringList &l ) |
1853 | { | 1846 | { |
1854 | detach(); | 1847 | detach(); |
1855 | mData->empty = false; | 1848 | mData->empty = false; |
1856 | 1849 | ||
1857 | mData->custom = l; | 1850 | mData->custom = l; |
1858 | } | 1851 | } |
1859 | 1852 | ||
1860 | QStringList Addressee::customs() const | 1853 | QStringList Addressee::customs() const |
1861 | { | 1854 | { |
1862 | return mData->custom; | 1855 | return mData->custom; |
1863 | } | 1856 | } |
1864 | 1857 | ||
1865 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1858 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1866 | QString &email) | 1859 | QString &email) |
1867 | { | 1860 | { |
1868 | int startPos, endPos, len; | 1861 | int startPos, endPos, len; |
1869 | QString partA, partB, result; | 1862 | QString partA, partB, result; |
1870 | char endCh = '>'; | 1863 | char endCh = '>'; |
1871 | 1864 | ||
1872 | startPos = rawEmail.find('<'); | 1865 | startPos = rawEmail.find('<'); |
1873 | if (startPos < 0) | 1866 | if (startPos < 0) |
1874 | { | 1867 | { |
1875 | startPos = rawEmail.find('('); | 1868 | startPos = rawEmail.find('('); |
1876 | endCh = ')'; | 1869 | endCh = ')'; |
1877 | } | 1870 | } |
1878 | if (startPos < 0) | 1871 | if (startPos < 0) |
1879 | { | 1872 | { |
1880 | // We couldn't find any separators, so we assume the whole string | 1873 | // We couldn't find any separators, so we assume the whole string |
1881 | // is the email address | 1874 | // is the email address |
1882 | email = rawEmail; | 1875 | email = rawEmail; |
1883 | fullName = ""; | 1876 | fullName = ""; |
1884 | } | 1877 | } |
1885 | else | 1878 | else |
1886 | { | 1879 | { |
1887 | // We have a start position, try to find an end | 1880 | // We have a start position, try to find an end |
1888 | endPos = rawEmail.find(endCh, startPos+1); | 1881 | endPos = rawEmail.find(endCh, startPos+1); |
1889 | 1882 | ||
1890 | if (endPos < 0) | 1883 | if (endPos < 0) |
1891 | { | 1884 | { |
1892 | // We couldn't find the end of the email address. We can only | 1885 | // We couldn't find the end of the email address. We can only |
1893 | // assume the entire string is the email address. | 1886 | // assume the entire string is the email address. |
1894 | email = rawEmail; | 1887 | email = rawEmail; |
1895 | fullName = ""; | 1888 | fullName = ""; |
1896 | } | 1889 | } |
1897 | else | 1890 | else |
1898 | { | 1891 | { |
1899 | // We have a start and end to the email address | 1892 | // We have a start and end to the email address |
1900 | 1893 | ||
1901 | // Grab the name part | 1894 | // Grab the name part |
1902 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1895 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1903 | 1896 | ||
1904 | // grab the email part | 1897 | // grab the email part |
1905 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1898 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1906 | 1899 | ||
1907 | // Check that we do not have any extra characters on the end of the | 1900 | // Check that we do not have any extra characters on the end of the |
1908 | // strings | 1901 | // strings |
1909 | len = fullName.length(); | 1902 | len = fullName.length(); |
1910 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1903 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1911 | fullName = fullName.mid(1, len-2); | 1904 | fullName = fullName.mid(1, len-2); |
1912 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1905 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1913 | fullName = fullName.mid(1, len-2); | 1906 | fullName = fullName.mid(1, len-2); |
1914 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1907 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1915 | fullName = fullName.mid(1, len-2); | 1908 | fullName = fullName.mid(1, len-2); |
1916 | } | 1909 | } |
1917 | } | 1910 | } |
1918 | } | 1911 | } |
1919 | 1912 | ||
1920 | void Addressee::setResource( Resource *resource ) | 1913 | void Addressee::setResource( Resource *resource ) |
1921 | { | 1914 | { |
1922 | detach(); | 1915 | detach(); |
1923 | mData->resource = resource; | 1916 | mData->resource = resource; |
1924 | } | 1917 | } |
1925 | 1918 | ||
1926 | Resource *Addressee::resource() const | 1919 | Resource *Addressee::resource() const |
1927 | { | 1920 | { |
1928 | return mData->resource; | 1921 | return mData->resource; |
1929 | } | 1922 | } |
1930 | 1923 | ||
1931 | //US | 1924 | //US |
1932 | QString Addressee::resourceLabel() | 1925 | QString Addressee::resourceLabel() |
1933 | { | 1926 | { |
1934 | return i18n("Resource"); | 1927 | return i18n("Resource"); |
1935 | } | 1928 | } |
1936 | 1929 | ||
1937 | void Addressee::setChanged( bool value ) | 1930 | void Addressee::setChanged( bool value ) |
1938 | { | 1931 | { |
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index d7e3925..3d82553 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -1,223 +1,245 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <kapplication.h> | 28 | #include <kapplication.h> |
29 | #include <klocale.h> | 29 | #include <klocale.h> |
30 | 30 | ||
31 | #include "phonenumber.h" | 31 | #include "phonenumber.h" |
32 | 32 | ||
33 | using namespace KABC; | 33 | using namespace KABC; |
34 | 34 | ||
35 | PhoneNumber::PhoneNumber() : | 35 | 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 | } |
138 | 160 | ||
139 | QString PhoneNumber::label() const | 161 | QString PhoneNumber::label() const |
140 | { | 162 | { |
141 | return typeLabel( type() ); | 163 | return typeLabel( type() ); |
142 | } | 164 | } |
143 | 165 | ||
144 | PhoneNumber::TypeList PhoneNumber::typeList() | 166 | PhoneNumber::TypeList PhoneNumber::typeList() |
145 | { | 167 | { |
146 | TypeList list; | 168 | TypeList list; |
147 | 169 | ||
148 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video | 170 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video |
149 | << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; | 171 | << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; |
150 | 172 | ||
151 | return list; | 173 | return list; |
152 | } | 174 | } |
153 | 175 | ||
154 | QString PhoneNumber::label( int type ) | 176 | QString PhoneNumber::label( int type ) |
155 | { | 177 | { |
156 | return typeLabel( type ); | 178 | return typeLabel( type ); |
157 | } | 179 | } |
158 | 180 | ||
159 | QString PhoneNumber::typeLabel( int type ) | 181 | QString PhoneNumber::typeLabel( int type ) |
160 | { | 182 | { |
161 | QString typeString; | 183 | QString typeString; |
162 | 184 | ||
163 | if ((type & Home) == Home) | 185 | if ((type & Home) == Home) |
164 | typeString += i18n("Home"); | 186 | typeString += i18n("Home"); |
165 | else if ((type & Work) == Work) | 187 | else if ((type & Work) == Work) |
166 | typeString += i18n("Work"); | 188 | typeString += i18n("Work"); |
167 | 189 | ||
168 | if (!typeString.isEmpty()) | 190 | if (!typeString.isEmpty()) |
169 | typeString += " "; | 191 | typeString += " "; |
170 | 192 | ||
171 | if ((type & Cell) == Cell) | 193 | if ((type & Cell) == Cell) |
172 | typeString += i18n("Mobile"); | 194 | typeString += i18n("Mobile"); |
173 | else if ((type & Fax) == Fax) | 195 | else if ((type & Fax) == Fax) |
174 | typeString += i18n("Fax"); | 196 | typeString += i18n("Fax"); |
175 | else if ((type & Msg) == Msg) | 197 | else if ((type & Msg) == Msg) |
176 | typeString += i18n("Messenger"); | 198 | typeString += i18n("Messenger"); |
177 | else if ((type & Voice) == Voice) { | 199 | else if ((type & Voice) == Voice) { |
178 | // add nothing in case of the Voice flag | 200 | // add nothing in case of the Voice flag |
179 | // typeString += i18n("Voice"); | 201 | // typeString += i18n("Voice"); |
180 | } | 202 | } |
181 | else if ((type & Video) == Video) | 203 | else if ((type & Video) == Video) |
182 | typeString += i18n("Video"); | 204 | typeString += i18n("Video"); |
183 | else if ((type & Bbs) == Bbs) | 205 | else if ((type & Bbs) == Bbs) |
184 | typeString += i18n("Mailbox"); | 206 | typeString += i18n("Mailbox"); |
185 | else if ((type & Modem) == Modem) | 207 | else if ((type & Modem) == Modem) |
186 | typeString += i18n("Modem"); | 208 | typeString += i18n("Modem"); |
187 | else if ((type & Car) == Car) | 209 | else if ((type & Car) == Car) |
188 | typeString += i18n("Car"); | 210 | typeString += i18n("Car"); |
189 | else if ((type & Isdn) == Isdn) | 211 | else if ((type & Isdn) == Isdn) |
190 | typeString += i18n("ISDN"); | 212 | typeString += i18n("ISDN"); |
191 | else if ((type & Pcs) == Pcs) | 213 | else if ((type & Pcs) == Pcs) |
192 | typeString += i18n("PCS"); | 214 | typeString += i18n("PCS"); |
193 | else if ((type & Pager) == Pager) | 215 | else if ((type & Pager) == Pager) |
194 | typeString += i18n("Pager"); | 216 | typeString += i18n("Pager"); |
195 | else if ((type & Sip) == Sip) | 217 | else if ((type & Sip) == Sip) |
196 | typeString += i18n("SIP"); | 218 | typeString += i18n("SIP"); |
197 | 219 | ||
198 | // add the prefered flag | 220 | // add the prefered flag |
199 | if (!typeString.isEmpty()) | 221 | if (!typeString.isEmpty()) |
200 | typeString += " "; | 222 | typeString += " "; |
201 | /* | 223 | /* |
202 | if ((type & Pref) == Pref) | 224 | if ((type & Pref) == Pref) |
203 | typeString += i18n("(p)"); | 225 | typeString += i18n("(p)"); |
204 | */ | 226 | */ |
205 | //if we still have no match, return "other" | 227 | //if we still have no match, return "other" |
206 | if (typeString.isEmpty()) | 228 | if (typeString.isEmpty()) |
207 | return i18n("Other"); | 229 | return i18n("Other"); |
208 | 230 | ||
209 | 231 | ||
210 | return typeString; | 232 | return typeString; |
211 | } | 233 | } |
212 | 234 | ||
213 | QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) | 235 | QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) |
214 | { | 236 | { |
215 | return s << phone.mId << phone.mType << phone.mNumber; | 237 | return s << phone.mId << phone.mType << phone.mNumber; |
216 | } | 238 | } |
217 | 239 | ||
218 | QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) | 240 | QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) |
219 | { | 241 | { |
220 | s >> phone.mId >> phone.mType >> phone.mNumber; | 242 | s >> phone.mId >> phone.mType >> phone.mNumber; |
221 | 243 | ||
222 | return s; | 244 | return s; |
223 | } | 245 | } |
diff --git a/kabc/phonenumber.h b/kabc/phonenumber.h index 410a52f..2d4d3e0 100644 --- a/kabc/phonenumber.h +++ b/kabc/phonenumber.h | |||
@@ -1,168 +1,169 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_PHONENUMBER_H | 28 | #ifndef KABC_PHONENUMBER_H |
29 | #define KABC_PHONENUMBER_H | 29 | #define KABC_PHONENUMBER_H |
30 | 30 | ||
31 | #include <qvaluelist.h> | 31 | #include <qvaluelist.h> |
32 | #include <qstring.h> | 32 | #include <qstring.h> |
33 | 33 | ||
34 | namespace KABC { | 34 | namespace KABC { |
35 | 35 | ||
36 | /** | 36 | /** |
37 | @short Phonenumber information. | 37 | @short Phonenumber information. |
38 | 38 | ||
39 | This class provides phone number information. A phone number is classified by | 39 | This class provides phone number information. A phone number is classified by |
40 | a type. The following types are available, it's possible to use multiple types | 40 | a type. The following types are available, it's possible to use multiple types |
41 | @ref Types for a number by combining them through a logical or. | 41 | @ref Types for a number by combining them through a logical or. |
42 | */ | 42 | */ |
43 | class PhoneNumber | 43 | class PhoneNumber |
44 | { | 44 | { |
45 | friend QDataStream &operator<<( QDataStream &, const PhoneNumber & ); | 45 | friend QDataStream &operator<<( QDataStream &, const PhoneNumber & ); |
46 | friend QDataStream &operator>>( QDataStream &, PhoneNumber & ); | 46 | friend QDataStream &operator>>( QDataStream &, PhoneNumber & ); |
47 | 47 | ||
48 | public: | 48 | public: |
49 | typedef QValueList<PhoneNumber> List; | 49 | typedef QValueList<PhoneNumber> List; |
50 | typedef QValueList<int> TypeList; | 50 | typedef QValueList<int> TypeList; |
51 | 51 | ||
52 | /** | 52 | /** |
53 | @li @p Home - Home number | 53 | @li @p Home - Home number |
54 | @li @p Work - Office number | 54 | @li @p Work - Office number |
55 | @li @p Msg - Messaging | 55 | @li @p Msg - Messaging |
56 | @li @p Pref - Preferred number | 56 | @li @p Pref - Preferred number |
57 | @li @p Voice - Voice | 57 | @li @p Voice - Voice |
58 | @li @p Fax - Fax machine | 58 | @li @p Fax - Fax machine |
59 | @li @p Cell - Cell phone | 59 | @li @p Cell - Cell phone |
60 | @li @p Video - Video phone | 60 | @li @p Video - Video phone |
61 | @li @p Bbs - Mailbox | 61 | @li @p Bbs - Mailbox |
62 | @li @p Modem - Modem | 62 | @li @p Modem - Modem |
63 | @li @p Car - Car phone | 63 | @li @p Car - Car phone |
64 | @li @p Isdn - ISDN connection | 64 | @li @p Isdn - ISDN connection |
65 | @li @p Pcs - Personal Communication Service | 65 | @li @p Pcs - Personal Communication Service |
66 | @li @p Pager - Pager | 66 | @li @p Pager - Pager |
67 | @li @p SIP - VoIP | 67 | @li @p SIP - VoIP |
68 | */ | 68 | */ |
69 | enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, | 69 | enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, |
70 | Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, | 70 | Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, |
71 | Isdn = 2048, Pcs = 4096, Pager = 8192, Sip = 16384 }; | 71 | Isdn = 2048, Pcs = 4096, Pager = 8192, Sip = 16384 }; |
72 | 72 | ||
73 | /** | 73 | /** |
74 | Create an empty phone number object. | 74 | Create an empty phone number object. |
75 | */ | 75 | */ |
76 | PhoneNumber(); | 76 | PhoneNumber(); |
77 | 77 | ||
78 | /** | 78 | /** |
79 | Create a phonenumber object. | 79 | Create a phonenumber object. |
80 | 80 | ||
81 | @param number Number | 81 | @param number Number |
82 | @param type Type as defined in enum. Multiple types can be | 82 | @param type Type as defined in enum. Multiple types can be |
83 | specified by combining them by a logical or. | 83 | specified by combining them by a logical or. |
84 | */ | 84 | */ |
85 | PhoneNumber( const QString &number, int type = Home ); | 85 | PhoneNumber( const QString &number, int type = Home ); |
86 | 86 | ||
87 | /** | 87 | /** |
88 | Destructor. | 88 | Destructor. |
89 | */ | 89 | */ |
90 | ~PhoneNumber(); | 90 | ~PhoneNumber(); |
91 | 91 | ||
92 | bool operator==( const PhoneNumber & ) const; | 92 | bool operator==( const PhoneNumber & ) const; |
93 | bool operator!=( const PhoneNumber & ) const; | 93 | bool operator!=( const PhoneNumber & ) const; |
94 | 94 | ||
95 | bool contains( const PhoneNumber &p ); | ||
95 | /** | 96 | /** |
96 | Sets the unique identifier. | 97 | Sets the unique identifier. |
97 | */ | 98 | */ |
98 | void setId( const QString &id ); | 99 | void setId( const QString &id ); |
99 | 100 | ||
100 | /** | 101 | /** |
101 | Returns the unique identifier. | 102 | Returns the unique identifier. |
102 | */ | 103 | */ |
103 | QString id() const; | 104 | QString id() const; |
104 | 105 | ||
105 | /** | 106 | /** |
106 | Sets the number. | 107 | Sets the number. |
107 | */ | 108 | */ |
108 | void setNumber( const QString & ); | 109 | void setNumber( const QString & ); |
109 | 110 | ||
110 | /** | 111 | /** |
111 | Returns the number. | 112 | Returns the number. |
112 | */ | 113 | */ |
113 | QString number() const; | 114 | QString number() const; |
114 | 115 | ||
115 | /** | 116 | /** |
116 | Sets the type. Multiple types can be specified by combining them by | 117 | Sets the type. Multiple types can be specified by combining them by |
117 | a logical or. | 118 | a logical or. |
118 | */ | 119 | */ |
119 | void setType( int ); | 120 | void setType( int ); |
120 | 121 | ||
121 | /** | 122 | /** |
122 | Returns the type. Can be a multiple types combined by a logical or. | 123 | Returns the type. Can be a multiple types combined by a logical or. |
123 | */ | 124 | */ |
124 | int type() const; | 125 | int type() const; |
125 | 126 | ||
126 | /** | 127 | /** |
127 | Returns a translated string of all types the address has. | 128 | Returns a translated string of all types the address has. |
128 | */ | 129 | */ |
129 | QString typeLabel() const; | 130 | QString typeLabel() const; |
130 | 131 | ||
131 | /** | 132 | /** |
132 | Returns the translated label for phone number depending on its type. | 133 | Returns the translated label for phone number depending on its type. |
133 | */ | 134 | */ |
134 | QString label() const; | 135 | QString label() const; |
135 | 136 | ||
136 | /** | 137 | /** |
137 | Returns a list of all available types | 138 | Returns a list of all available types |
138 | */ | 139 | */ |
139 | static TypeList typeList(); | 140 | static TypeList typeList(); |
140 | 141 | ||
141 | /** | 142 | /** |
142 | Returns the translated label for phone number type. | 143 | Returns the translated label for phone number type. |
143 | */ | 144 | */ |
144 | static QString typeLabel( int type ); | 145 | static QString typeLabel( int type ); |
145 | 146 | ||
146 | /** | 147 | /** |
147 | Returns the translated label for phone number type. | 148 | Returns the translated label for phone number type. |
148 | @obsolete | 149 | @obsolete |
149 | */ | 150 | */ |
150 | static QString label( int type ); | 151 | static QString label( int type ); |
151 | bool simplifyNumber(); | 152 | bool simplifyNumber(); |
152 | void simplifyType(); | 153 | void simplifyType(); |
153 | 154 | ||
154 | private: | 155 | private: |
155 | void init(); | 156 | void init(); |
156 | 157 | ||
157 | QString mId; | 158 | QString mId; |
158 | 159 | ||
159 | int mType; | 160 | int mType; |
160 | QString mNumber; | 161 | QString mNumber; |
161 | }; | 162 | }; |
162 | 163 | ||
163 | QDataStream &operator<<( QDataStream &, const PhoneNumber & ); | 164 | QDataStream &operator<<( QDataStream &, const PhoneNumber & ); |
164 | QDataStream &operator>>( QDataStream &, PhoneNumber & ); | 165 | QDataStream &operator>>( QDataStream &, PhoneNumber & ); |
165 | 166 | ||
166 | } | 167 | } |
167 | 168 | ||
168 | #endif | 169 | #endif |