-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() | |||
586 | mData->emails.clear(); | 586 | mData->emails.clear(); |
587 | mData->emails.append( email ); | 587 | mData->emails.append( email ); |
588 | } | 588 | } |
589 | void Addressee::makePhoneNumbersOLcompatible() | ||
590 | { | ||
591 | KABC::PhoneNumber::List::Iterator phoneIter; | ||
592 | KABC::PhoneNumber::List::Iterator phoneIter2; | ||
593 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | ||
594 | ++phoneIter ) { | ||
595 | ( *phoneIter ).makeCompat(); | ||
596 | } | ||
597 | int hasHome = hasPhoneNumberType( PhoneNumber::Home | PhoneNumber::Pref ); | ||
598 | int hasHome2 = hasPhoneNumberType( PhoneNumber::Home ); | ||
599 | int hasWork = hasPhoneNumberType( PhoneNumber::Work | PhoneNumber::Pref ); | ||
600 | int hasWork2 = hasPhoneNumberType( PhoneNumber::Work ); | ||
601 | int hasCell = hasPhoneNumberType( PhoneNumber::Cell ); | ||
602 | int hasCell2 = hasPhoneNumberType( PhoneNumber::Car ); | ||
603 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | ||
604 | ++phoneIter ) { | ||
605 | if ( (*phoneIter).type() == PhoneNumber::Home && ! hasHome ) { | ||
606 | (*phoneIter).setType( PhoneNumber::Home | PhoneNumber::Pref ); | ||
607 | ++hasHome; | ||
608 | if ( hasHome2 ) --hasHome2; | ||
609 | } else if ( ( (*phoneIter).type() == PhoneNumber::Home | PhoneNumber::Pref) && hasHome>1 && !hasHome2 ) { | ||
610 | (*phoneIter).setType( PhoneNumber::Home ); | ||
611 | --hasHome; | ||
612 | ++hasHome2; | ||
613 | } else if ( (*phoneIter).type() == PhoneNumber::Work && ! hasWork ) { | ||
614 | (*phoneIter).setType( PhoneNumber::Work | PhoneNumber::Pref ); | ||
615 | ++hasWork; | ||
616 | if ( hasWork2 ) --hasWork2; | ||
617 | } else if ( ( (*phoneIter).type() == PhoneNumber::Work | PhoneNumber::Pref) && hasWork > 1 && ! hasWork2 ) { | ||
618 | (*phoneIter).setType( PhoneNumber::Work ); | ||
619 | --hasWork; | ||
620 | ++hasWork2; | ||
621 | } else if ( (*phoneIter).type() == PhoneNumber::Cell && hasCell > 1 && !hasCell2) { | ||
622 | (*phoneIter).setType( PhoneNumber::Car ); | ||
623 | ++hasCell2; | ||
624 | --hasCell; | ||
625 | } else if ( (*phoneIter).type() == PhoneNumber::Car && hasCell2 > 1 && !hasCell) { | ||
626 | (*phoneIter).setType( PhoneNumber::Cell ); | ||
627 | ++hasCell; | ||
628 | --hasCell2; | ||
629 | } else{ | ||
630 | phoneIter2 = phoneIter; | ||
631 | ++phoneIter2; | ||
632 | for ( ; phoneIter2 != mData->phoneNumbers.end(); | ||
633 | ++phoneIter2 ) { | ||
634 | if ( (*phoneIter2).type() == (*phoneIter).type() ) { | ||
635 | (*phoneIter2).setType( PhoneNumber::Voice ); | ||
589 | 636 | ||
637 | } | ||
638 | } | ||
639 | } | ||
640 | } | ||
641 | } | ||
590 | void Addressee::simplifyPhoneNumbers() | 642 | void Addressee::simplifyPhoneNumbers() |
591 | { | 643 | { |
592 | int max = 4; | 644 | int max = 4; |
@@ -997,7 +1049,7 @@ QString Addressee::homePhoneLabel() | |||
997 | 1049 | ||
998 | QString Addressee::businessPhoneLabel() | 1050 | QString Addressee::businessPhoneLabel() |
999 | { | 1051 | { |
1000 | return i18n("Business Phone"); | 1052 | return i18n("Work Phone"); |
1001 | } | 1053 | } |
1002 | 1054 | ||
1003 | 1055 | ||
@@ -1007,29 +1059,29 @@ QString Addressee::mobilePhoneLabel() | |||
1007 | } | 1059 | } |
1008 | QString Addressee::mobileWorkPhoneLabel() | 1060 | QString Addressee::mobileWorkPhoneLabel() |
1009 | { | 1061 | { |
1010 | return i18n("Mobile (work)"); | 1062 | return i18n("Mobile2 (work)"); |
1011 | } | 1063 | } |
1012 | QString Addressee::mobileHomePhoneLabel() | 1064 | QString Addressee::mobileHomePhoneLabel() |
1013 | { | 1065 | { |
1014 | return i18n("Mobile (home)"); | 1066 | return i18n("Mobile"); |
1015 | } | 1067 | } |
1016 | 1068 | ||
1017 | 1069 | ||
1018 | QString Addressee::homeFaxLabel() | 1070 | QString Addressee::homeFaxLabel() |
1019 | { | 1071 | { |
1020 | return i18n("Home Fax"); | 1072 | return i18n("Fax (Home)"); |
1021 | } | 1073 | } |
1022 | 1074 | ||
1023 | 1075 | ||
1024 | QString Addressee::businessFaxLabel() | 1076 | QString Addressee::businessFaxLabel() |
1025 | { | 1077 | { |
1026 | return i18n("Business Fax"); | 1078 | return i18n("Fax (Work)"); |
1027 | } | 1079 | } |
1028 | 1080 | ||
1029 | 1081 | ||
1030 | QString Addressee::carPhoneLabel() | 1082 | QString Addressee::carPhoneLabel() |
1031 | { | 1083 | { |
1032 | return i18n("Car Phone"); | 1084 | return i18n("Mobile2 (work)"); |
1033 | } | 1085 | } |
1034 | 1086 | ||
1035 | 1087 | ||
@@ -1652,6 +1704,16 @@ PhoneNumber::List Addressee::phoneNumbers() const | |||
1652 | return mData->phoneNumbers; | 1704 | return mData->phoneNumbers; |
1653 | } | 1705 | } |
1654 | 1706 | ||
1707 | int Addressee::hasPhoneNumberType( int type ) | ||
1708 | { | ||
1709 | int retval = 0; | ||
1710 | PhoneNumber::List::ConstIterator it; | ||
1711 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | ||
1712 | if ( (*it).type() == type ) | ||
1713 | ++retval; | ||
1714 | } | ||
1715 | return retval; | ||
1716 | } | ||
1655 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1717 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1656 | { | 1718 | { |
1657 | PhoneNumber::List list; | 1719 | PhoneNumber::List list; |