author | zautrix <zautrix> | 2005-10-28 03:24:50 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-28 03:24:50 (UTC) |
commit | f83a59cf4f9d0cff4111b6f5c88e88e6dc96e79e (patch) (unidiff) | |
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 | |||
@@ -565,49 +565,101 @@ void Addressee::simplifyAddresses() | |||
565 | if ( mData->url.isValid() ) | 565 | if ( mData->url.isValid() ) |
566 | max = 1; | 566 | max = 1; |
567 | if ( mData->addresses.count() <= max ) return ; | 567 | if ( mData->addresses.count() <= max ) return ; |
568 | int count = 0; | 568 | int count = 0; |
569 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 569 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
570 | if ( count >= max ) | 570 | if ( count >= max ) |
571 | list.append( *it ); | 571 | list.append( *it ); |
572 | ++count; | 572 | ++count; |
573 | } | 573 | } |
574 | for( it = list.begin(); it != list.end(); ++it ) { | 574 | for( it = list.begin(); it != list.end(); ++it ) { |
575 | removeAddress( (*it) ); | 575 | removeAddress( (*it) ); |
576 | } | 576 | } |
577 | } | 577 | } |
578 | 578 | ||
579 | // removes all emails but the first | 579 | // removes all emails but the first |
580 | // needed by phone sync | 580 | // needed by phone sync |
581 | void Addressee::simplifyEmails() | 581 | void Addressee::simplifyEmails() |
582 | { | 582 | { |
583 | if ( mData->emails.count() == 0 ) return ; | 583 | if ( mData->emails.count() == 0 ) return ; |
584 | QString email = mData->emails.first(); | 584 | QString email = mData->emails.first(); |
585 | detach(); | 585 | detach(); |
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; |
593 | int inList = mData->phoneNumbers.count(); | 645 | int inList = mData->phoneNumbers.count(); |
594 | KABC::PhoneNumber::List removeNumbers; | 646 | KABC::PhoneNumber::List removeNumbers; |
595 | KABC::PhoneNumber::List::Iterator phoneIter; | 647 | KABC::PhoneNumber::List::Iterator phoneIter; |
596 | if ( inList > max ) { | 648 | if ( inList > max ) { |
597 | // delete non-preferred numbers | 649 | // delete non-preferred numbers |
598 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 650 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
599 | ++phoneIter ) { | 651 | ++phoneIter ) { |
600 | if ( inList > max ) { | 652 | if ( inList > max ) { |
601 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | 653 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { |
602 | removeNumbers.append( ( *phoneIter ) ); | 654 | removeNumbers.append( ( *phoneIter ) ); |
603 | --inList; | 655 | --inList; |
604 | } | 656 | } |
605 | } else | 657 | } else |
606 | break; | 658 | break; |
607 | } | 659 | } |
608 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 660 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
609 | ++phoneIter ) { | 661 | ++phoneIter ) { |
610 | removePhoneNumber(( *phoneIter )); | 662 | removePhoneNumber(( *phoneIter )); |
611 | } | 663 | } |
612 | // delete preferred numbers | 664 | // delete preferred numbers |
613 | if ( inList > max ) { | 665 | if ( inList > max ) { |
@@ -976,81 +1028,81 @@ QString Addressee::businessAddressPostalCodeLabel() | |||
976 | return i18n("Business Address Postal Code"); | 1028 | return i18n("Business Address Postal Code"); |
977 | } | 1029 | } |
978 | 1030 | ||
979 | 1031 | ||
980 | QString Addressee::businessAddressCountryLabel() | 1032 | QString Addressee::businessAddressCountryLabel() |
981 | { | 1033 | { |
982 | return i18n("Business Address Country"); | 1034 | return i18n("Business Address Country"); |
983 | } | 1035 | } |
984 | 1036 | ||
985 | 1037 | ||
986 | QString Addressee::businessAddressLabelLabel() | 1038 | QString Addressee::businessAddressLabelLabel() |
987 | { | 1039 | { |
988 | return i18n("Business Address Label"); | 1040 | return i18n("Business Address Label"); |
989 | } | 1041 | } |
990 | 1042 | ||
991 | 1043 | ||
992 | QString Addressee::homePhoneLabel() | 1044 | QString Addressee::homePhoneLabel() |
993 | { | 1045 | { |
994 | return i18n("Home Phone"); | 1046 | return i18n("Home Phone"); |
995 | } | 1047 | } |
996 | 1048 | ||
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 | ||
1004 | QString Addressee::mobilePhoneLabel() | 1056 | QString Addressee::mobilePhoneLabel() |
1005 | { | 1057 | { |
1006 | return i18n("Mobile Phone"); | 1058 | return i18n("Mobile Phone"); |
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 | ||
1036 | QString Addressee::isdnLabel() | 1088 | QString Addressee::isdnLabel() |
1037 | { | 1089 | { |
1038 | return i18n("ISDN"); | 1090 | return i18n("ISDN"); |
1039 | } | 1091 | } |
1040 | 1092 | ||
1041 | 1093 | ||
1042 | QString Addressee::pagerLabel() | 1094 | QString Addressee::pagerLabel() |
1043 | { | 1095 | { |
1044 | return i18n("Pager"); | 1096 | return i18n("Pager"); |
1045 | } | 1097 | } |
1046 | 1098 | ||
1047 | QString Addressee::sipLabel() | 1099 | QString Addressee::sipLabel() |
1048 | { | 1100 | { |
1049 | return i18n("SIP"); | 1101 | return i18n("SIP"); |
1050 | } | 1102 | } |
1051 | 1103 | ||
1052 | QString Addressee::emailLabel() | 1104 | QString Addressee::emailLabel() |
1053 | { | 1105 | { |
1054 | return i18n("Email Address"); | 1106 | return i18n("Email Address"); |
1055 | } | 1107 | } |
1056 | 1108 | ||
@@ -1631,48 +1683,58 @@ void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | |||
1631 | } | 1683 | } |
1632 | } | 1684 | } |
1633 | 1685 | ||
1634 | PhoneNumber Addressee::phoneNumber( int type ) const | 1686 | PhoneNumber Addressee::phoneNumber( int type ) const |
1635 | { | 1687 | { |
1636 | PhoneNumber phoneNumber( "", type ); | 1688 | PhoneNumber phoneNumber( "", type ); |
1637 | PhoneNumber::List::ConstIterator it; | 1689 | PhoneNumber::List::ConstIterator it; |
1638 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1690 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1639 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1691 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1640 | if ( (*it).type() & PhoneNumber::Pref ) | 1692 | if ( (*it).type() & PhoneNumber::Pref ) |
1641 | return (*it); | 1693 | return (*it); |
1642 | else if ( phoneNumber.number().isEmpty() ) | 1694 | else if ( phoneNumber.number().isEmpty() ) |
1643 | phoneNumber = (*it); | 1695 | phoneNumber = (*it); |
1644 | } | 1696 | } |
1645 | } | 1697 | } |
1646 | 1698 | ||
1647 | return phoneNumber; | 1699 | return phoneNumber; |
1648 | } | 1700 | } |
1649 | 1701 | ||
1650 | PhoneNumber::List Addressee::phoneNumbers() const | 1702 | PhoneNumber::List Addressee::phoneNumbers() const |
1651 | { | 1703 | { |
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; |
1658 | 1720 | ||
1659 | PhoneNumber::List::ConstIterator it; | 1721 | PhoneNumber::List::ConstIterator it; |
1660 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1722 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1661 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1723 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1662 | list.append( *it ); | 1724 | list.append( *it ); |
1663 | } | 1725 | } |
1664 | } | 1726 | } |
1665 | return list; | 1727 | return list; |
1666 | } | 1728 | } |
1667 | 1729 | ||
1668 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1730 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1669 | { | 1731 | { |
1670 | PhoneNumber::List::ConstIterator it; | 1732 | PhoneNumber::List::ConstIterator it; |
1671 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1733 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1672 | if ( (*it).id() == id ) { | 1734 | if ( (*it).id() == id ) { |
1673 | return *it; | 1735 | return *it; |
1674 | } | 1736 | } |
1675 | } | 1737 | } |
1676 | return PhoneNumber(); | 1738 | return PhoneNumber(); |
1677 | } | 1739 | } |
1678 | 1740 | ||