author | zautrix <zautrix> | 2005-01-18 10:15:21 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-18 10:15:21 (UTC) |
commit | fbc1ca53388337b66017973896725d51416aae1a (patch) (unidiff) | |
tree | 436dd042c407dd994976c8e460d4c85d527799b7 /kabc | |
parent | f973a8310cc378cc86d96bfce3f08f06725a2b7d (diff) | |
download | kdepimpi-fbc1ca53388337b66017973896725d51416aae1a.zip kdepimpi-fbc1ca53388337b66017973896725d51416aae1a.tar.gz kdepimpi-fbc1ca53388337b66017973896725d51416aae1a.tar.bz2 |
fix
-rw-r--r-- | kabc/addressee.cpp | 19 |
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 | |||
@@ -275,128 +275,147 @@ void Addressee::computeCsum(const QString &dev) | |||
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 | ||
285 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 285 | void 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; |