author | zautrix <zautrix> | 2004-10-13 12:38:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-13 12:38:18 (UTC) |
commit | efdd0735bda81dcd82dfb6d6dc0d0c143f249336 (patch) (unidiff) | |
tree | 8d67e4b51fbc3e8c48e1656c78054cfe6d2ead66 /kabc | |
parent | f22ee1ec902fe2fc610786f39049fb84542b8726 (diff) | |
download | kdepimpi-efdd0735bda81dcd82dfb6d6dc0d0c143f249336.zip kdepimpi-efdd0735bda81dcd82dfb6d6dc0d0c143f249336.tar.gz kdepimpi-efdd0735bda81dcd82dfb6d6dc0d0c143f249336.tar.bz2 |
mege contact fixes
-rw-r--r-- | kabc/addressee.cpp | 67 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 22 | ||||
-rw-r--r-- | kabc/phonenumber.h | 1 |
3 files changed, 53 insertions, 37 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index cb10160..2aca559 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -307,8 +307,9 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | |||
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 | } |
@@ -358,48 +359,40 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | |||
358 | mData->agent = ad.mData->agent; | 359 | mData->agent = ad.mData->agent; |
359 | } | 360 | } |
360 | } | 361 | } |
362 | { | ||
363 | Key::List::Iterator itA; | ||
364 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | ||
365 | bool found = false; | ||
366 | Key::List::Iterator it; | ||
367 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | ||
368 | if ( (*it) == (*itA)) { | ||
369 | found = true; | ||
370 | break; | ||
361 | 371 | ||
362 | #if 0 | 372 | } |
363 | 373 | } | |
364 | if ( mData->url.isValid() ) | 374 | if ( ! found ) { |
365 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 375 | mData->keys.append( *itA ); |
366 | KABC::PhoneNumber::List phoneNumbers; | 376 | } |
367 | KABC::PhoneNumber::List::Iterator phoneIter; | 377 | } |
368 | 378 | } | |
369 | QStringList t; | 379 | KABC::Address::List::Iterator addressIterA; |
370 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 380 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
371 | ++phoneIter ) | 381 | bool found = false; |
372 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | ||
373 | t.sort(); | ||
374 | uint iii; | ||
375 | for ( iii = 0; iii < t.count(); ++iii) | ||
376 | l.append( t[iii] ); | ||
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; | 382 | KABC::Address::List::Iterator addressIter; |
390 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 383 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
391 | ++addressIter ) { | 384 | ++addressIter ) { |
392 | t = (*addressIter).asList(); | 385 | if ( (*addressIter) == (*addressIterA)) { |
393 | t.sort(); | 386 | found = true; |
394 | for ( iii = 0; iii < t.count(); ++iii) | 387 | (*addressIter).setType( (*addressIterA).type() ); |
395 | l.append( t[iii] ); | 388 | break; |
396 | } | 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() ); |
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index d7e3925..3d82553 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -87,6 +87,28 @@ void PhoneNumber::simplifyType() | |||
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; |
diff --git a/kabc/phonenumber.h b/kabc/phonenumber.h index 410a52f..2d4d3e0 100644 --- a/kabc/phonenumber.h +++ b/kabc/phonenumber.h | |||
@@ -92,6 +92,7 @@ class PhoneNumber | |||
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 | */ |