-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 @@ -586,7 +586,59 @@ void Addressee::simplifyEmails() 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; @@ -997,7 +1049,7 @@ QString Addressee::homePhoneLabel() QString Addressee::businessPhoneLabel() { - return i18n("Business Phone"); + return i18n("Work Phone"); } @@ -1007,29 +1059,29 @@ QString Addressee::mobilePhoneLabel() } 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)"); } @@ -1652,6 +1704,16 @@ 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; |