author | zautrix <zautrix> | 2005-10-28 03:24:50 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-28 03:24:50 (UTC) |
commit | f83a59cf4f9d0cff4111b6f5c88e88e6dc96e79e (patch) (side-by-side diff) | |
tree | 969e6cf85499e3b1dcaa4dc24c972b65c906cfa9 /kabc/addressee.cpp | |
parent | cbda16d4966c7483d20d1b6b5a64c8af367ea732 (diff) | |
download | kdepimpi-f83a59cf4f9d0cff4111b6f5c88e88e6dc96e79e.zip kdepimpi-f83a59cf4f9d0cff4111b6f5c88e88e6dc96e79e.tar.gz kdepimpi-f83a59cf4f9d0cff4111b6f5c88e88e6dc96e79e.tar.bz2 |
many new bugs...
-rw-r--r-- | kabc/addressee.cpp | 74 |
1 files changed, 68 insertions, 6 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 7e1e414..661bdf6 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -585,9 +585,61 @@ void Addressee::simplifyEmails() detach(); mData->emails.clear(); mData->emails.append( email ); } +void Addressee::makePhoneNumbersOLcompatible() +{ + KABC::PhoneNumber::List::Iterator phoneIter; + KABC::PhoneNumber::List::Iterator phoneIter2; + for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); + ++phoneIter ) { + ( *phoneIter ).makeCompat(); + } + int hasHome = hasPhoneNumberType( PhoneNumber::Home | PhoneNumber::Pref ); + int hasHome2 = hasPhoneNumberType( PhoneNumber::Home ); + int hasWork = hasPhoneNumberType( PhoneNumber::Work | PhoneNumber::Pref ); + int hasWork2 = hasPhoneNumberType( PhoneNumber::Work ); + int hasCell = hasPhoneNumberType( PhoneNumber::Cell ); + int hasCell2 = hasPhoneNumberType( PhoneNumber::Car ); + for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); + ++phoneIter ) { + if ( (*phoneIter).type() == PhoneNumber::Home && ! hasHome ) { + (*phoneIter).setType( PhoneNumber::Home | PhoneNumber::Pref ); + ++hasHome; + if ( hasHome2 ) --hasHome2; + } else if ( ( (*phoneIter).type() == PhoneNumber::Home | PhoneNumber::Pref) && hasHome>1 && !hasHome2 ) { + (*phoneIter).setType( PhoneNumber::Home ); + --hasHome; + ++hasHome2; + } else if ( (*phoneIter).type() == PhoneNumber::Work && ! hasWork ) { + (*phoneIter).setType( PhoneNumber::Work | PhoneNumber::Pref ); + ++hasWork; + if ( hasWork2 ) --hasWork2; + } else if ( ( (*phoneIter).type() == PhoneNumber::Work | PhoneNumber::Pref) && hasWork > 1 && ! hasWork2 ) { + (*phoneIter).setType( PhoneNumber::Work ); + --hasWork; + ++hasWork2; + } else if ( (*phoneIter).type() == PhoneNumber::Cell && hasCell > 1 && !hasCell2) { + (*phoneIter).setType( PhoneNumber::Car ); + ++hasCell2; + --hasCell; + } else if ( (*phoneIter).type() == PhoneNumber::Car && hasCell2 > 1 && !hasCell) { + (*phoneIter).setType( PhoneNumber::Cell ); + ++hasCell; + --hasCell2; + } else{ + phoneIter2 = phoneIter; + ++phoneIter2; + for ( ; phoneIter2 != mData->phoneNumbers.end(); + ++phoneIter2 ) { + if ( (*phoneIter2).type() == (*phoneIter).type() ) { + (*phoneIter2).setType( PhoneNumber::Voice ); + } + } + } + } +} void Addressee::simplifyPhoneNumbers() { int max = 4; int inList = mData->phoneNumbers.count(); @@ -996,9 +1048,9 @@ QString Addressee::homePhoneLabel() QString Addressee::businessPhoneLabel() { - return i18n("Business Phone"); + return i18n("Work Phone"); } QString Addressee::mobilePhoneLabel() @@ -1006,31 +1058,31 @@ QString Addressee::mobilePhoneLabel() return i18n("Mobile Phone"); } QString Addressee::mobileWorkPhoneLabel() { - return i18n("Mobile (work)"); + return i18n("Mobile2 (work)"); } QString Addressee::mobileHomePhoneLabel() { - return i18n("Mobile (home)"); + return i18n("Mobile"); } QString Addressee::homeFaxLabel() { - return i18n("Home Fax"); + return i18n("Fax (Home)"); } QString Addressee::businessFaxLabel() { - return i18n("Business Fax"); + return i18n("Fax (Work)"); } QString Addressee::carPhoneLabel() { - return i18n("Car Phone"); + return i18n("Mobile2 (work)"); } QString Addressee::isdnLabel() @@ -1651,8 +1703,18 @@ PhoneNumber::List Addressee::phoneNumbers() const { return mData->phoneNumbers; } +int Addressee::hasPhoneNumberType( int type ) +{ + int retval = 0; + PhoneNumber::List::ConstIterator it; + for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { + if ( (*it).type() == type ) + ++retval; + } + return retval; +} PhoneNumber::List Addressee::phoneNumbers( int type ) const { PhoneNumber::List list; |