author | zautrix <zautrix> | 2004-10-14 07:24:50 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-14 07:24:50 (UTC) |
commit | 57bd80b04dddd40a897dce8b6902d1046d71c631 (patch) (side-by-side diff) | |
tree | c51cb1985344173951109f4bffb12bb6a68ea7f7 /kabc/addressee.cpp | |
parent | a6dff815a9c6d3a91094573d23c28a8553fc7cc2 (diff) | |
download | kdepimpi-57bd80b04dddd40a897dce8b6902d1046d71c631.zip kdepimpi-57bd80b04dddd40a897dce8b6902d1046d71c631.tar.gz kdepimpi-57bd80b04dddd40a897dce8b6902d1046d71c631.tar.bz2 |
phone fixes
-rw-r--r-- | kabc/addressee.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 295ee4f..2564894 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -418,71 +418,89 @@ bool Addressee::removeVoice() bool Addressee::containsAdr(const Addressee& ad ) { if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; // compare phone numbers PhoneNumber::List phoneN = ad.phoneNumbers(); PhoneNumber::List::Iterator phoneIt; bool found = false; for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { bool found = false; PhoneNumber::List phoneL = ad.phoneNumbers(); PhoneNumber::List::Iterator phoneItL; for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { found = true; break; } } if ( ! found ) return false; } return true; } void Addressee::simplifyAddresses() { + + + Address::List list; + Address::List::Iterator it; + Address::List::Iterator it2; + for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { + it2 = it; + ++it2; + for( ; it2 != mData->addresses.end(); ++it2 ) { + if ( (*it) == (*it2) ) { + list.append( *it ); + break; + } + } + } + for( it = list.begin(); it != list.end(); ++it ) { + removeAddress( (*it) ); + } + + list.clear(); int max = 2; if ( mData->url.isValid() ) max = 1; if ( mData->addresses.count() <= max ) return ; int count = 0; - Address::List list; - Address::List::Iterator it; for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { if ( count >= max ) list.append( *it ); ++count; } for( it = list.begin(); it != list.end(); ++it ) { removeAddress( (*it) ); } } // removes all emails but the first // needed by phone sync void Addressee::simplifyEmails() { if ( mData->emails.count() == 0 ) return ; QString email = mData->emails.first(); detach(); mData->emails.clear(); mData->emails.append( email ); } void Addressee::simplifyPhoneNumbers() { int max = 4; int inList = mData->phoneNumbers.count(); KABC::PhoneNumber::List removeNumbers; KABC::PhoneNumber::List::Iterator phoneIter; if ( inList > max ) { // delete non-preferred numbers for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { if ( inList > max ) { |