-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 @@ -587,5 +587,57 @@ void Addressee::simplifyEmails() 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() { @@ -998,5 +1050,5 @@ QString Addressee::homePhoneLabel() QString Addressee::businessPhoneLabel() { - return i18n("Business Phone"); + return i18n("Work Phone"); } @@ -1008,9 +1060,9 @@ QString Addressee::mobilePhoneLabel() QString Addressee::mobileWorkPhoneLabel() { - return i18n("Mobile (work)"); + return i18n("Mobile2 (work)"); } QString Addressee::mobileHomePhoneLabel() { - return i18n("Mobile (home)"); + return i18n("Mobile"); } @@ -1018,5 +1070,5 @@ QString Addressee::mobileHomePhoneLabel() QString Addressee::homeFaxLabel() { - return i18n("Home Fax"); + return i18n("Fax (Home)"); } @@ -1024,5 +1076,5 @@ QString Addressee::homeFaxLabel() QString Addressee::businessFaxLabel() { - return i18n("Business Fax"); + return i18n("Fax (Work)"); } @@ -1030,5 +1082,5 @@ QString Addressee::businessFaxLabel() QString Addressee::carPhoneLabel() { - return i18n("Car Phone"); + return i18n("Mobile2 (work)"); } @@ -1653,4 +1705,14 @@ PhoneNumber::List Addressee::phoneNumbers() const } +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 { |