summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 82b4b9b..bfcfab5 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -147,384 +147,403 @@ bool Addressee::operator==( const Addressee &a ) const
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
172bool Addressee::operator!=( const Addressee &a ) const 172bool Addressee::operator!=( const Addressee &a ) const
173{ 173{
174 return !( a == *this ); 174 return !( a == *this );
175} 175}
176 176
177bool Addressee::isEmpty() const 177bool Addressee::isEmpty() const
178{ 178{
179 return mData->empty; 179 return mData->empty;
180} 180}
181ulong Addressee::getCsum4List( const QStringList & attList) 181ulong 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}
209void Addressee::computeCsum(const QString &dev) 209void 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.isEmpty() ) l.append( mData->additionalName ); 216 if ( !mData->additionalName.isEmpty() ) 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 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { 259 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) {
260 int find = t[iii].find (':')+1; 260 int find = t[iii].find (':')+1;
261 //qDebug("lennnn %d %d ", find, t[iii].length()); 261 //qDebug("lennnn %d %d ", find, t[iii].length());
262 if ( find < t[iii].length()) 262 if ( find < t[iii].length())
263 l.append( t[iii] ); 263 l.append( t[iii] );
264 264
265 } 265 }
266 KABC::Address::List::Iterator addressIter; 266 KABC::Address::List::Iterator addressIter;
267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
268 ++addressIter ) { 268 ++addressIter ) {
269 t = (*addressIter).asList(); 269 t = (*addressIter).asList();
270 t.sort(); 270 t.sort();
271 for ( iii = 0; iii < t.count(); ++iii) 271 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 272 l.append( t[iii] );
273 } 273 }
274 uint cs = getCsum4List(l); 274 uint cs = getCsum4List(l);
275 275
276#if 0 276#if 0
277 for ( iii = 0; iii < l.count(); ++iii) 277 for ( iii = 0; iii < l.count(); ++iii)
278 qDebug("%d***%s***",iii,l[iii].latin1()); 278 qDebug("%d***%s***",iii,l[iii].latin1());
279 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 279 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
280#endif 280#endif
281 281
282 setCsum( dev, QString::number (cs )); 282 setCsum( dev, QString::number (cs ));
283} 283}
284 284
285void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 285void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
286{ 286{
287 // merge all standard non-outlook fields. 287 // merge all standard non-outlook fields.
288 //if isSubSet (e.g. mobile phone sync) merge all fields 288 //if isSubSet (e.g. mobile phone sync) merge all fields
289 289
290 detach(); 290 detach();
291 if ( isSubSet ) { 291 if ( isSubSet ) {
292 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 292 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
293 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 293 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
294 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 294 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
295 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 295 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
296 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 296 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
297 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 297 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
298 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 298 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
299 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 299 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
300 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 300 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
301 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 301 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
302 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 302 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
303 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 303 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
304 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 304 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
305 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 305 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
306 if ( !mData->birthday.isValid() ) 306 if ( !mData->birthday.isValid() )
307 if ( ad.mData->birthday.isValid()) 307 if ( ad.mData->birthday.isValid())
308 mData->birthday = ad.mData->birthday; 308 mData->birthday = ad.mData->birthday;
309 309
310 } 310 }
311 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 311 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
312 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 312 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
313 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 313 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
314 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 314 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
315 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 315 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
316 QStringList t; 316 QStringList t;
317 QStringList tAD; 317 QStringList tAD;
318 uint iii; 318 uint iii;
319 319
320 // ********** phone numbers 320 // ********** phone numbers
321 if ( isSubSet ) { 321 if ( isSubSet ) {
322 PhoneNumber::List phoneAD = ad.phoneNumbers(); 322 PhoneNumber::List phoneAD = ad.phoneNumbers();
323 PhoneNumber::List::Iterator phoneItAD; 323 PhoneNumber::List::Iterator phoneItAD;
324 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 324 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
325 bool found = false; 325 bool found = false;
326 PhoneNumber::List::Iterator it; 326 PhoneNumber::List::Iterator it;
327 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 327 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
328 if ( ( *phoneItAD ).contains( (*it) ) ) { 328 if ( ( *phoneItAD ).contains( (*it) ) ) {
329 found = true; 329 found = true;
330 (*it).setType( ( *phoneItAD ).type() ); 330 (*it).setType( ( *phoneItAD ).type() );
331 (*it).setNumber( ( *phoneItAD ).number() ); 331 (*it).setNumber( ( *phoneItAD ).number() );
332 break; 332 break;
333 } 333 }
334 } 334 }
335 // if ( isSubSet && ! found ) 335 // if ( isSubSet && ! found )
336 if ( ! found ) // LR try this one... 336 if ( ! found ) // LR try this one...
337 mData->phoneNumbers.append( *phoneItAD ); 337 mData->phoneNumbers.append( *phoneItAD );
338 } 338 }
339 } else {
340 PhoneNumber::List phoneAD = ad.phoneNumbers();
341 PhoneNumber::List::Iterator phoneItAD;
342 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
343 bool found = false;
344 PhoneNumber::List::Iterator it;
345 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
346 if ( ( *phoneItAD ).contains( (*it) ) ) {
347 found = true;
348 (*it).setType( ( *phoneItAD ).type() );
349 (*it).setNumber( ( *phoneItAD ).number() );
350 break;
351 }
352 }
353 if ( ! found ) { // append numbers which do not have work or home type
354 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) )
355 mData->phoneNumbers.append( *phoneItAD );
356 }
357 }
339 } 358 }
340 if ( isSubSet ) { 359 if ( isSubSet ) {
341 // ************* emails; 360 // ************* emails;
342 t = mData->emails; 361 t = mData->emails;
343 tAD = ad.mData->emails; 362 tAD = ad.mData->emails;
344 for ( iii = 0; iii < tAD.count(); ++iii) 363 for ( iii = 0; iii < tAD.count(); ++iii)
345 if ( !t.contains(tAD[iii] ) ) 364 if ( !t.contains(tAD[iii] ) )
346 mData->emails.append( tAD[iii] ); 365 mData->emails.append( tAD[iii] );
347 } 366 }
348 367
349 // ************* categories; 368 // ************* categories;
350 if ( isSubSet ) { 369 if ( isSubSet ) {
351 t = mData->categories; 370 t = mData->categories;
352 tAD = ad.mData->categories; 371 tAD = ad.mData->categories;
353 for ( iii = 0; iii < tAD.count(); ++iii) 372 for ( iii = 0; iii < tAD.count(); ++iii)
354 if ( !t.contains(tAD[iii] ) ) 373 if ( !t.contains(tAD[iii] ) )
355 mData->categories.append( tAD[iii] ); 374 mData->categories.append( tAD[iii] );
356 } 375 }
357 QStringList::ConstIterator it; 376 QStringList::ConstIterator it;
358 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 377 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
359 QString qualifiedName = (*it).left( (*it).find( ":" )); 378 QString qualifiedName = (*it).left( (*it).find( ":" ));
360 bool found = false; 379 bool found = false;
361 QStringList::ConstIterator itL; 380 QStringList::ConstIterator itL;
362 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 381 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
363 if ( (*itL).startsWith( qualifiedName ) ) { 382 if ( (*itL).startsWith( qualifiedName ) ) {
364 found = true; 383 found = true;
365 break; 384 break;
366 } 385 }
367 } 386 }
368 if ( ! found ) { 387 if ( ! found ) {
369 mData->custom.append( *it ); 388 mData->custom.append( *it );
370 } 389 }
371 } 390 }
372 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 391 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
373 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 392 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
374 if ( !mData->sound.isIntern() ) { 393 if ( !mData->sound.isIntern() ) {
375 if ( mData->sound.url().isEmpty() ) { 394 if ( mData->sound.url().isEmpty() ) {
376 mData->sound = ad.mData->sound; 395 mData->sound = ad.mData->sound;
377 } 396 }
378 } 397 }
379 if ( !mData->agent.isIntern() ) { 398 if ( !mData->agent.isIntern() ) {
380 if ( mData->agent.url().isEmpty() ) { 399 if ( mData->agent.url().isEmpty() ) {
381 mData->agent = ad.mData->agent; 400 mData->agent = ad.mData->agent;
382 } 401 }
383 } 402 }
384 { 403 {
385 Key::List::Iterator itA; 404 Key::List::Iterator itA;
386 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 405 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
387 bool found = false; 406 bool found = false;
388 Key::List::Iterator it; 407 Key::List::Iterator it;
389 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 408 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
390 if ( (*it) == (*itA)) { 409 if ( (*it) == (*itA)) {
391 found = true; 410 found = true;
392 break; 411 break;
393 412
394 } 413 }
395 } 414 }
396 if ( ! found ) { 415 if ( ! found ) {
397 mData->keys.append( *itA ); 416 mData->keys.append( *itA );
398 } 417 }
399 } 418 }
400 } 419 }
401 if ( isSubSet ) { 420 if ( isSubSet ) {
402 KABC::Address::List::Iterator addressIterA; 421 KABC::Address::List::Iterator addressIterA;
403 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 422 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
404 bool found = false; 423 bool found = false;
405 KABC::Address::List::Iterator addressIter; 424 KABC::Address::List::Iterator addressIter;
406 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 425 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
407 ++addressIter ) { 426 ++addressIter ) {
408 if ( (*addressIter) == (*addressIterA)) { 427 if ( (*addressIter) == (*addressIterA)) {
409 found = true; 428 found = true;
410 (*addressIter).setType( (*addressIterA).type() ); 429 (*addressIter).setType( (*addressIterA).type() );
411 break; 430 break;
412 } 431 }
413 432
414 } 433 }
415 if ( isSubSet && ! found ) { 434 if ( isSubSet && ! found ) {
416 mData->addresses.append( *addressIterA ); 435 mData->addresses.append( *addressIterA );
417 } 436 }
418 } 437 }
419 } 438 }
420 //qDebug("merge contact %s ", ad.uid().latin1()); 439 //qDebug("merge contact %s ", ad.uid().latin1());
421 setUid( ad.uid() ); 440 setUid( ad.uid() );
422 setRevision( ad.revision() ); 441 setRevision( ad.revision() );
423} 442}
424 443
425bool Addressee::removeVoice() 444bool Addressee::removeVoice()
426{ 445{
427 PhoneNumber::List phoneN = phoneNumbers(); 446 PhoneNumber::List phoneN = phoneNumbers();
428 PhoneNumber::List::Iterator phoneIt; 447 PhoneNumber::List::Iterator phoneIt;
429 bool found = false; 448 bool found = false;
430 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 449 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
431 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 450 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
432 if ((*phoneIt).type() - PhoneNumber::Voice ) { 451 if ((*phoneIt).type() - PhoneNumber::Voice ) {
433 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 452 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
434 insertPhoneNumber( (*phoneIt) ); 453 insertPhoneNumber( (*phoneIt) );
435 found = true; 454 found = true;
436 } 455 }
437 } 456 }
438 457
439 } 458 }
440 return found; 459 return found;
441} 460}
442 461
443bool Addressee::containsAdr(const Addressee& ad ) 462bool Addressee::containsAdr(const Addressee& ad )
444{ 463{
445 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 464 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
446 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 465 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
447 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 466 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
448 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 467 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
449 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 468 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
450 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 469 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
451 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 470 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
452 471
453 // compare phone numbers 472 // compare phone numbers
454 PhoneNumber::List phoneN = ad.phoneNumbers(); 473 PhoneNumber::List phoneN = ad.phoneNumbers();
455 PhoneNumber::List::Iterator phoneIt; 474 PhoneNumber::List::Iterator phoneIt;
456 bool found = false; 475 bool found = false;
457 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 476 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
458 bool found = false; 477 bool found = false;
459 PhoneNumber::List phoneL = ad.phoneNumbers(); 478 PhoneNumber::List phoneL = ad.phoneNumbers();
460 PhoneNumber::List::Iterator phoneItL; 479 PhoneNumber::List::Iterator phoneItL;
461 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 480 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
462 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 481 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
463 found = true; 482 found = true;
464 break; 483 break;
465 } 484 }
466 } 485 }
467 if ( ! found ) 486 if ( ! found )
468 return false; 487 return false;
469 } 488 }
470 return true; 489 return true;
471 490
472} 491}
473void Addressee::simplifyAddresses() 492void Addressee::simplifyAddresses()
474{ 493{
475 494
476 495
477 Address::List list; 496 Address::List list;
478 Address::List::Iterator it; 497 Address::List::Iterator it;
479 Address::List::Iterator it2; 498 Address::List::Iterator it2;
480 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 499 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
481 it2 = it; 500 it2 = it;
482 ++it2; 501 ++it2;
483 for( ; it2 != mData->addresses.end(); ++it2 ) { 502 for( ; it2 != mData->addresses.end(); ++it2 ) {
484 if ( (*it) == (*it2) ) { 503 if ( (*it) == (*it2) ) {
485 list.append( *it ); 504 list.append( *it );
486 break; 505 break;
487 } 506 }
488 } 507 }
489 } 508 }
490 for( it = list.begin(); it != list.end(); ++it ) { 509 for( it = list.begin(); it != list.end(); ++it ) {
491 removeAddress( (*it) ); 510 removeAddress( (*it) );
492 } 511 }
493 512
494 list.clear(); 513 list.clear();
495 int max = 2; 514 int max = 2;
496 if ( mData->url.isValid() ) 515 if ( mData->url.isValid() )
497 max = 1; 516 max = 1;
498 if ( mData->addresses.count() <= max ) return ; 517 if ( mData->addresses.count() <= max ) return ;
499 int count = 0; 518 int count = 0;
500 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 519 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
501 if ( count >= max ) 520 if ( count >= max )
502 list.append( *it ); 521 list.append( *it );
503 ++count; 522 ++count;
504 } 523 }
505 for( it = list.begin(); it != list.end(); ++it ) { 524 for( it = list.begin(); it != list.end(); ++it ) {
506 removeAddress( (*it) ); 525 removeAddress( (*it) );
507 } 526 }
508} 527}
509 528
510// removes all emails but the first 529// removes all emails but the first
511// needed by phone sync 530// needed by phone sync
512void Addressee::simplifyEmails() 531void Addressee::simplifyEmails()
513{ 532{
514 if ( mData->emails.count() == 0 ) return ; 533 if ( mData->emails.count() == 0 ) return ;
515 QString email = mData->emails.first(); 534 QString email = mData->emails.first();
516 detach(); 535 detach();
517 mData->emails.clear(); 536 mData->emails.clear();
518 mData->emails.append( email ); 537 mData->emails.append( email );
519} 538}
520 539
521void Addressee::simplifyPhoneNumbers() 540void Addressee::simplifyPhoneNumbers()
522{ 541{
523 int max = 4; 542 int max = 4;
524 int inList = mData->phoneNumbers.count(); 543 int inList = mData->phoneNumbers.count();
525 KABC::PhoneNumber::List removeNumbers; 544 KABC::PhoneNumber::List removeNumbers;
526 KABC::PhoneNumber::List::Iterator phoneIter; 545 KABC::PhoneNumber::List::Iterator phoneIter;
527 if ( inList > max ) { 546 if ( inList > max ) {
528 // delete non-preferred numbers 547 // delete non-preferred numbers
529 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 548 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
530 ++phoneIter ) { 549 ++phoneIter ) {