-rw-r--r-- | kabc/addressbook.cpp | 4 | ||||
-rw-r--r-- | kabc/addressbook.h | 2 | ||||
-rw-r--r-- | kabc/addressee.cpp | 10 | ||||
-rw-r--r-- | kabc/addressee.h | 10 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 33 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 2 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 5 | ||||
-rw-r--r-- | libkdepim/ksyncprefsdialog.cpp | 2 | ||||
-rw-r--r-- | microkde/kidmanager.cpp | 10 | ||||
-rw-r--r-- | microkde/kidmanager.h | 10 |
10 files changed, 55 insertions, 33 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 4de7da2..9e61261 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -771,387 +771,387 @@ void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeRes | |||
771 | 771 | ||
772 | bool changed = false; | 772 | bool changed = false; |
773 | Addressee addr = a; | 773 | Addressee addr = a; |
774 | if ( addr != (*it) ) | 774 | if ( addr != (*it) ) |
775 | changed = true; | 775 | changed = true; |
776 | 776 | ||
777 | if ( takeResource ) { | 777 | if ( takeResource ) { |
778 | Resource * res = (*it).resource(); | 778 | Resource * res = (*it).resource(); |
779 | (*it) = a; | 779 | (*it) = a; |
780 | (*it).setResource( res ); | 780 | (*it).setResource( res ); |
781 | } else { | 781 | } else { |
782 | (*it) = a; | 782 | (*it) = a; |
783 | if ( (*it).resource() == 0 ) | 783 | if ( (*it).resource() == 0 ) |
784 | (*it).setResource( standardResource() ); | 784 | (*it).setResource( standardResource() ); |
785 | } | 785 | } |
786 | if ( changed ) { | 786 | if ( changed ) { |
787 | if ( setRev ) { | 787 | if ( setRev ) { |
788 | (*it).setRevision( QDateTime::currentDateTime() ); | 788 | (*it).setRevision( QDateTime::currentDateTime() ); |
789 | } | 789 | } |
790 | (*it).setChanged( true ); | 790 | (*it).setChanged( true ); |
791 | } | 791 | } |
792 | 792 | ||
793 | found = true; | 793 | found = true; |
794 | } else { | 794 | } else { |
795 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 795 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
796 | QString name = (*it).uid().mid( 19 ); | 796 | QString name = (*it).uid().mid( 19 ); |
797 | Addressee b = a; | 797 | Addressee b = a; |
798 | QString id = b.getID( name ); | 798 | QString id = b.getID( name ); |
799 | if ( ! id.isEmpty() ) { | 799 | if ( ! id.isEmpty() ) { |
800 | QString des = (*it).note(); | 800 | QString des = (*it).note(); |
801 | int startN; | 801 | int startN; |
802 | if( (startN = des.find( id ) ) >= 0 ) { | 802 | if( (startN = des.find( id ) ) >= 0 ) { |
803 | int endN = des.find( ",", startN+1 ); | 803 | int endN = des.find( ",", startN+1 ); |
804 | des = des.left( startN ) + des.mid( endN+1 ); | 804 | des = des.left( startN ) + des.mid( endN+1 ); |
805 | (*it).setNote( des ); | 805 | (*it).setNote( des ); |
806 | } | 806 | } |
807 | } | 807 | } |
808 | } | 808 | } |
809 | } | 809 | } |
810 | } | 810 | } |
811 | if ( found ) | 811 | if ( found ) |
812 | return; | 812 | return; |
813 | 813 | ||
814 | d->mAddressees.append( a ); | 814 | d->mAddressees.append( a ); |
815 | Addressee& addr = d->mAddressees.last(); | 815 | Addressee& addr = d->mAddressees.last(); |
816 | if ( addr.resource() == 0 ) | 816 | if ( addr.resource() == 0 ) |
817 | addr.setResource( standardResource() ); | 817 | addr.setResource( standardResource() ); |
818 | addr.setChanged( true ); | 818 | addr.setChanged( true ); |
819 | } | 819 | } |
820 | 820 | ||
821 | void AddressBook::removeAddressee( const Addressee &a ) | 821 | void AddressBook::removeAddressee( const Addressee &a ) |
822 | { | 822 | { |
823 | Iterator it; | 823 | Iterator it; |
824 | Iterator it2; | 824 | Iterator it2; |
825 | bool found = false; | 825 | bool found = false; |
826 | for ( it = begin(); it != end(); ++it ) { | 826 | for ( it = begin(); it != end(); ++it ) { |
827 | if ( a.uid() == (*it).uid() ) { | 827 | if ( a.uid() == (*it).uid() ) { |
828 | found = true; | 828 | found = true; |
829 | it2 = it; | 829 | it2 = it; |
830 | } else { | 830 | } else { |
831 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 831 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
832 | QString name = (*it).uid().mid( 19 ); | 832 | QString name = (*it).uid().mid( 19 ); |
833 | Addressee b = a; | 833 | Addressee b = a; |
834 | QString id = b.getID( name ); | 834 | QString id = b.getID( name ); |
835 | if ( ! id.isEmpty() ) { | 835 | if ( ! id.isEmpty() ) { |
836 | QString des = (*it).note(); | 836 | QString des = (*it).note(); |
837 | if( des.find( id ) < 0 ) { | 837 | if( des.find( id ) < 0 ) { |
838 | des += id + ","; | 838 | des += id + ","; |
839 | (*it).setNote( des ); | 839 | (*it).setNote( des ); |
840 | } | 840 | } |
841 | } | 841 | } |
842 | } | 842 | } |
843 | 843 | ||
844 | } | 844 | } |
845 | } | 845 | } |
846 | 846 | ||
847 | if ( found ) | 847 | if ( found ) |
848 | removeAddressee( it2 ); | 848 | removeAddressee( it2 ); |
849 | 849 | ||
850 | } | 850 | } |
851 | 851 | ||
852 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 852 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
853 | { | 853 | { |
854 | Iterator it = begin(); | 854 | Iterator it = begin(); |
855 | Iterator it2 ; | 855 | Iterator it2 ; |
856 | QDateTime dt ( QDate( 2003,1,1) ); | 856 | QDateTime dt ( QDate( 2003,1,1) ); |
857 | while ( it != end() ) { | 857 | while ( it != end() ) { |
858 | (*it).setRevision( dt ); | 858 | (*it).setRevision( dt ); |
859 | if (( *it).IDStr() != "changed" ) { | 859 | if (( *it).IDStr() != "changed" ) { |
860 | // "changed" is used for tagging changed addressees when syncing with KDE or OL | 860 | // "changed" is used for tagging changed addressees when syncing with KDE or OL |
861 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 861 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
862 | (*it).setIDStr(":"); | 862 | (*it).setIDStr(":"); |
863 | } | 863 | } |
864 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 864 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
865 | it2 = it; | 865 | it2 = it; |
866 | //qDebug("removing %s ",(*it).uid().latin1() ); | 866 | //qDebug("removing %s ",(*it).uid().latin1() ); |
867 | ++it; | 867 | ++it; |
868 | removeAddressee( it2 ); | 868 | removeAddressee( it2 ); |
869 | } else { | 869 | } else { |
870 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 870 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
871 | if ( removeDeleted ) { | 871 | if ( removeDeleted ) { |
872 | // we have no postprocessing in the resource, we have to do it here | 872 | // we have no postprocessing in the resource, we have to do it here |
873 | // we have to compute csum for all, because it could be the first sync | 873 | // we have to compute csum for all, because it could be the first sync |
874 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 874 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
875 | } | 875 | } |
876 | ++it; | 876 | ++it; |
877 | } | 877 | } |
878 | } | 878 | } |
879 | deleteRemovedAddressees(); | 879 | deleteRemovedAddressees(); |
880 | } | 880 | } |
881 | 881 | ||
882 | void AddressBook::removeAddressee( const Iterator &it ) | 882 | void AddressBook::removeAddressee( const Iterator &it ) |
883 | { | 883 | { |
884 | d->mRemovedAddressees.append( (*it) ); | 884 | d->mRemovedAddressees.append( (*it) ); |
885 | d->mAddressees.remove( it.d->mIt ); | 885 | d->mAddressees.remove( it.d->mIt ); |
886 | } | 886 | } |
887 | 887 | ||
888 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 888 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
889 | { | 889 | { |
890 | Iterator it; | 890 | Iterator it; |
891 | for ( it = begin(); it != end(); ++it ) { | 891 | for ( it = begin(); it != end(); ++it ) { |
892 | if ( a.uid() == (*it).uid() ) { | 892 | if ( a.uid() == (*it).uid() ) { |
893 | return it; | 893 | return it; |
894 | } | 894 | } |
895 | } | 895 | } |
896 | return end(); | 896 | return end(); |
897 | } | 897 | } |
898 | 898 | ||
899 | Addressee AddressBook::findByUid( const QString &uid ) | 899 | Addressee AddressBook::findByUid( const QString &uid ) |
900 | { | 900 | { |
901 | Iterator it; | 901 | Iterator it; |
902 | for ( it = begin(); it != end(); ++it ) { | 902 | for ( it = begin(); it != end(); ++it ) { |
903 | if ( uid == (*it).uid() ) { | 903 | if ( uid == (*it).uid() ) { |
904 | return *it; | 904 | return *it; |
905 | } | 905 | } |
906 | } | 906 | } |
907 | return Addressee(); | 907 | return Addressee(); |
908 | } | 908 | } |
909 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) | 909 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) |
910 | { | 910 | { |
911 | //qDebug("AddressBook::preExternSync "); | 911 | //qDebug("AddressBook::preExternSync "); |
912 | AddressBook::Iterator it; | 912 | AddressBook::Iterator it; |
913 | for ( it = begin(); it != end(); ++it ) { | 913 | for ( it = begin(); it != end(); ++it ) { |
914 | (*it).setID( csd, (*it).externalUID() ); | 914 | (*it).setID( csd, (*it).externalUID() ); |
915 | (*it).computeCsum( csd ); | 915 | (*it).computeCsum( csd ); |
916 | } | 916 | } |
917 | mergeAB( aBook ,csd, isSubset ); | 917 | mergeAB( aBook ,csd, isSubset ); |
918 | } | 918 | } |
919 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) | 919 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) |
920 | { | 920 | { |
921 | //qDebug("AddressBook::postExternSync "); | 921 | //qDebug("AddressBook::postExternSync "); |
922 | AddressBook::Iterator it; | 922 | AddressBook::Iterator it; |
923 | int foundEmpty = 0; | 923 | int foundEmpty = 0; |
924 | for ( it = begin(); it != end(); ++it ) { | 924 | for ( it = begin(); it != end(); ++it ) { |
925 | //qDebug("check uid %s ", (*it).uid().latin1() ); | 925 | //qDebug("check uid %s ", (*it).uid().latin1() ); |
926 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 926 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
927 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || | 927 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || |
928 | (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { | 928 | (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { |
929 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 929 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
930 | if ( ad.isEmpty() ) { | 930 | if ( ad.isEmpty() ) { |
931 | ++foundEmpty; | 931 | ++foundEmpty; |
932 | //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); | 932 | //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); |
933 | //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); | 933 | //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); |
934 | } else { | 934 | } else { |
935 | (*it).setIDStr(":"); | 935 | (*it).setIDStr(":"); |
936 | if ( setID ) { | 936 | if ( setID ) { |
937 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 937 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
938 | ad.setID( csd, (*it).externalUID() ); | 938 | ad.setID( csd, (*it).externalUID() ); |
939 | } else | 939 | } else |
940 | ad.setID( csd, (*it).uid() ); | 940 | ad.setID( csd, (*it).uid() ); |
941 | (*it).computeCsum( csd ); | 941 | (*it).computeCsum( csd ); |
942 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 942 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
943 | //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); | 943 | //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); |
944 | aBook->insertAddressee( ad , false); | 944 | aBook->insertAddressee( ad , false); |
945 | } | 945 | } |
946 | } | 946 | } |
947 | } | 947 | } |
948 | if ( foundEmpty ) { | 948 | if ( foundEmpty ) { |
949 | qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); | 949 | qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); |
950 | } | 950 | } |
951 | 951 | ||
952 | } | 952 | } |
953 | 953 | ||
954 | bool AddressBook::containsExternalUid( const QString& uid ) | 954 | bool AddressBook::containsExternalUid( const QString& uid ) |
955 | { | 955 | { |
956 | Iterator it; | 956 | Iterator it; |
957 | for ( it = begin(); it != end(); ++it ) { | 957 | for ( it = begin(); it != end(); ++it ) { |
958 | if ( uid == (*it).externalUID( ) ) | 958 | if ( uid == (*it).externalUID( ) ) |
959 | return true; | 959 | return true; |
960 | } | 960 | } |
961 | return false; | 961 | return false; |
962 | } | 962 | } |
963 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 963 | const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const |
964 | { | 964 | { |
965 | Iterator it; | 965 | ConstIterator it; |
966 | for ( it = begin(); it != end(); ++it ) { | 966 | for ( it = begin(); it != end(); ++it ) { |
967 | if ( uid == (*it).getID( profile ) ) | 967 | if ( uid == (*it).getID( profile ) ) |
968 | return (*it); | 968 | return (*it); |
969 | } | 969 | } |
970 | return Addressee(); | 970 | return Addressee(); |
971 | } | 971 | } |
972 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) | 972 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) |
973 | { | 973 | { |
974 | Iterator it; | 974 | Iterator it; |
975 | Addressee ad; | 975 | Addressee ad; |
976 | for ( it = begin(); it != end(); ++it ) { | 976 | for ( it = begin(); it != end(); ++it ) { |
977 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 977 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
978 | if ( !ad.isEmpty() ) { | 978 | if ( !ad.isEmpty() ) { |
979 | (*it).mergeContact( ad ,isSubset); | 979 | (*it).mergeContact( ad ,isSubset); |
980 | } | 980 | } |
981 | } | 981 | } |
982 | #if 0 | 982 | #if 0 |
983 | // test only | 983 | // test only |
984 | for ( it = begin(); it != end(); ++it ) { | 984 | for ( it = begin(); it != end(); ++it ) { |
985 | 985 | ||
986 | qDebug("uid %s ", (*it).uid().latin1()); | 986 | qDebug("uid %s ", (*it).uid().latin1()); |
987 | } | 987 | } |
988 | #endif | 988 | #endif |
989 | } | 989 | } |
990 | 990 | ||
991 | #if 0 | 991 | #if 0 |
992 | Addressee::List AddressBook::getExternLastSyncAddressees() | 992 | Addressee::List AddressBook::getExternLastSyncAddressees() |
993 | { | 993 | { |
994 | Addressee::List results; | 994 | Addressee::List results; |
995 | 995 | ||
996 | Iterator it; | 996 | Iterator it; |
997 | for ( it = begin(); it != end(); ++it ) { | 997 | for ( it = begin(); it != end(); ++it ) { |
998 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 998 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
999 | if ( (*it).familyName().left(4) == "!E: " ) | 999 | if ( (*it).familyName().left(4) == "!E: " ) |
1000 | results.append( *it ); | 1000 | results.append( *it ); |
1001 | } | 1001 | } |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | return results; | 1004 | return results; |
1005 | } | 1005 | } |
1006 | #endif | 1006 | #endif |
1007 | void AddressBook::resetTempSyncStat() | 1007 | void AddressBook::resetTempSyncStat() |
1008 | { | 1008 | { |
1009 | Iterator it; | 1009 | Iterator it; |
1010 | for ( it = begin(); it != end(); ++it ) { | 1010 | for ( it = begin(); it != end(); ++it ) { |
1011 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 1011 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
1012 | } | 1012 | } |
1013 | 1013 | ||
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | QStringList AddressBook:: uidList() | 1016 | QStringList AddressBook:: uidList() |
1017 | { | 1017 | { |
1018 | QStringList results; | 1018 | QStringList results; |
1019 | Iterator it; | 1019 | Iterator it; |
1020 | for ( it = begin(); it != end(); ++it ) { | 1020 | for ( it = begin(); it != end(); ++it ) { |
1021 | results.append( (*it).uid() ); | 1021 | results.append( (*it).uid() ); |
1022 | } | 1022 | } |
1023 | return results; | 1023 | return results; |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | 1026 | ||
1027 | Addressee::List AddressBook::allAddressees() | 1027 | Addressee::List AddressBook::allAddressees() |
1028 | { | 1028 | { |
1029 | return d->mAddressees; | 1029 | return d->mAddressees; |
1030 | 1030 | ||
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | Addressee::List AddressBook::findByName( const QString &name ) | 1033 | Addressee::List AddressBook::findByName( const QString &name ) |
1034 | { | 1034 | { |
1035 | Addressee::List results; | 1035 | Addressee::List results; |
1036 | 1036 | ||
1037 | Iterator it; | 1037 | Iterator it; |
1038 | for ( it = begin(); it != end(); ++it ) { | 1038 | for ( it = begin(); it != end(); ++it ) { |
1039 | if ( name == (*it).realName() ) { | 1039 | if ( name == (*it).realName() ) { |
1040 | results.append( *it ); | 1040 | results.append( *it ); |
1041 | } | 1041 | } |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | return results; | 1044 | return results; |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | Addressee::List AddressBook::findByEmail( const QString &email ) | 1047 | Addressee::List AddressBook::findByEmail( const QString &email ) |
1048 | { | 1048 | { |
1049 | Addressee::List results; | 1049 | Addressee::List results; |
1050 | QStringList mailList; | 1050 | QStringList mailList; |
1051 | 1051 | ||
1052 | Iterator it; | 1052 | Iterator it; |
1053 | for ( it = begin(); it != end(); ++it ) { | 1053 | for ( it = begin(); it != end(); ++it ) { |
1054 | mailList = (*it).emails(); | 1054 | mailList = (*it).emails(); |
1055 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 1055 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
1056 | if ( email == (*ite) ) { | 1056 | if ( email == (*ite) ) { |
1057 | results.append( *it ); | 1057 | results.append( *it ); |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | return results; | 1062 | return results; |
1063 | } | 1063 | } |
1064 | 1064 | ||
1065 | Addressee::List AddressBook::findByCategory( const QString &category ) | 1065 | Addressee::List AddressBook::findByCategory( const QString &category ) |
1066 | { | 1066 | { |
1067 | Addressee::List results; | 1067 | Addressee::List results; |
1068 | 1068 | ||
1069 | Iterator it; | 1069 | Iterator it; |
1070 | for ( it = begin(); it != end(); ++it ) { | 1070 | for ( it = begin(); it != end(); ++it ) { |
1071 | if ( (*it).hasCategory( category) ) { | 1071 | if ( (*it).hasCategory( category) ) { |
1072 | results.append( *it ); | 1072 | results.append( *it ); |
1073 | } | 1073 | } |
1074 | } | 1074 | } |
1075 | 1075 | ||
1076 | return results; | 1076 | return results; |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | void AddressBook::dump() const | 1079 | void AddressBook::dump() const |
1080 | { | 1080 | { |
1081 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 1081 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
1082 | 1082 | ||
1083 | ConstIterator it; | 1083 | ConstIterator it; |
1084 | for( it = begin(); it != end(); ++it ) { | 1084 | for( it = begin(); it != end(); ++it ) { |
1085 | (*it).dump(); | 1085 | (*it).dump(); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 1088 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | QString AddressBook::identifier() | 1091 | QString AddressBook::identifier() |
1092 | { | 1092 | { |
1093 | QStringList identifier; | 1093 | QStringList identifier; |
1094 | 1094 | ||
1095 | 1095 | ||
1096 | KRES::Manager<Resource>::ActiveIterator it; | 1096 | KRES::Manager<Resource>::ActiveIterator it; |
1097 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 1097 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
1098 | if ( !(*it)->identifier().isEmpty() ) | 1098 | if ( !(*it)->identifier().isEmpty() ) |
1099 | identifier.append( (*it)->identifier() ); | 1099 | identifier.append( (*it)->identifier() ); |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | return identifier.join( ":" ); | 1102 | return identifier.join( ":" ); |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | Field::List AddressBook::fields( int category ) | 1105 | Field::List AddressBook::fields( int category ) |
1106 | { | 1106 | { |
1107 | if ( d->mAllFields.isEmpty() ) { | 1107 | if ( d->mAllFields.isEmpty() ) { |
1108 | d->mAllFields = Field::allFields(); | 1108 | d->mAllFields = Field::allFields(); |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | if ( category == Field::All ) return d->mAllFields; | 1111 | if ( category == Field::All ) return d->mAllFields; |
1112 | 1112 | ||
1113 | Field::List result; | 1113 | Field::List result; |
1114 | Field::List::ConstIterator it; | 1114 | Field::List::ConstIterator it; |
1115 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 1115 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
1116 | if ( (*it)->category() & category ) result.append( *it ); | 1116 | if ( (*it)->category() & category ) result.append( *it ); |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | return result; | 1119 | return result; |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | bool AddressBook::addCustomField( const QString &label, int category, | 1122 | bool AddressBook::addCustomField( const QString &label, int category, |
1123 | const QString &key, const QString &app ) | 1123 | const QString &key, const QString &app ) |
1124 | { | 1124 | { |
1125 | if ( d->mAllFields.isEmpty() ) { | 1125 | if ( d->mAllFields.isEmpty() ) { |
1126 | d->mAllFields = Field::allFields(); | 1126 | d->mAllFields = Field::allFields(); |
1127 | } | 1127 | } |
1128 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 1128 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
1129 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 1129 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
1130 | 1130 | ||
1131 | QString k = key.isNull() ? label : key; | 1131 | QString k = key.isNull() ? label : key; |
1132 | 1132 | ||
1133 | Field *field = Field::createCustomField( label, category, k, a ); | 1133 | Field *field = Field::createCustomField( label, category, k, a ); |
1134 | 1134 | ||
1135 | if ( !field ) return false; | 1135 | if ( !field ) return false; |
1136 | 1136 | ||
1137 | d->mAllFields.append( field ); | 1137 | d->mAllFields.append( field ); |
1138 | 1138 | ||
1139 | return true; | 1139 | return true; |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 1142 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
1143 | { | 1143 | { |
1144 | if (!ab.d) return s; | 1144 | if (!ab.d) return s; |
1145 | 1145 | ||
1146 | return s << ab.d->mAddressees; | 1146 | return s << ab.d->mAddressees; |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 1149 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
1150 | { | 1150 | { |
1151 | if (!ab.d) return s; | 1151 | if (!ab.d) return s; |
1152 | 1152 | ||
1153 | s >> ab.d->mAddressees; | 1153 | s >> ab.d->mAddressees; |
1154 | 1154 | ||
1155 | return s; | 1155 | return s; |
1156 | } | 1156 | } |
1157 | 1157 | ||
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 2351add..18c03b5 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -115,236 +115,236 @@ class AddressBook : public QObject | |||
115 | @param format File format class. | 115 | @param format File format class. |
116 | */ | 116 | */ |
117 | AddressBook(); | 117 | AddressBook(); |
118 | AddressBook( const QString &config ); | 118 | AddressBook( const QString &config ); |
119 | AddressBook( const QString &config, const QString &family ); | 119 | AddressBook( const QString &config, const QString &family ); |
120 | virtual ~AddressBook(); | 120 | virtual ~AddressBook(); |
121 | 121 | ||
122 | /** | 122 | /** |
123 | Requests a ticket for saving the addressbook. Calling this function locks | 123 | Requests a ticket for saving the addressbook. Calling this function locks |
124 | the addressbook for all other processes. If the address book is already | 124 | the addressbook for all other processes. If the address book is already |
125 | locked the function returns 0. You need the returned @ref Ticket object | 125 | locked the function returns 0. You need the returned @ref Ticket object |
126 | for calling the @ref save() function. | 126 | for calling the @ref save() function. |
127 | 127 | ||
128 | @see save() | 128 | @see save() |
129 | */ | 129 | */ |
130 | Ticket *requestSaveTicket( Resource *resource=0 ); | 130 | Ticket *requestSaveTicket( Resource *resource=0 ); |
131 | 131 | ||
132 | /** | 132 | /** |
133 | Load address book from file. | 133 | Load address book from file. |
134 | */ | 134 | */ |
135 | bool load(); | 135 | bool load(); |
136 | 136 | ||
137 | /** | 137 | /** |
138 | Save address book. The address book is saved to the file, the Ticket | 138 | Save address book. The address book is saved to the file, the Ticket |
139 | object has been requested for by @ref requestSaveTicket(). | 139 | object has been requested for by @ref requestSaveTicket(). |
140 | 140 | ||
141 | @param ticket a ticket object returned by @ref requestSaveTicket() | 141 | @param ticket a ticket object returned by @ref requestSaveTicket() |
142 | */ | 142 | */ |
143 | bool save( Ticket *ticket ); | 143 | bool save( Ticket *ticket ); |
144 | bool saveAB( ); | 144 | bool saveAB( ); |
145 | bool saveABphone( QString fileName ); | 145 | bool saveABphone( QString fileName ); |
146 | void smplifyAddressees(); | 146 | void smplifyAddressees(); |
147 | void removeSyncInfo( QString syncProfile); | 147 | void removeSyncInfo( QString syncProfile); |
148 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); | 148 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); |
149 | void export2File( QString fileName ); | 149 | void export2File( QString fileName ); |
150 | bool export2PhoneFormat( QStringList uids ,QString fileName ); | 150 | bool export2PhoneFormat( QStringList uids ,QString fileName ); |
151 | int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); | 151 | int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); |
152 | void setUntagged( bool setNonSyncTagged = false ); | 152 | void setUntagged( bool setNonSyncTagged = false ); |
153 | void removeUntagged(); | 153 | void removeUntagged(); |
154 | void findNewExtIds( QString fileName, QString currentSyncDevice ); | 154 | void findNewExtIds( QString fileName, QString currentSyncDevice ); |
155 | /** | 155 | /** |
156 | Returns a iterator for first entry of address book. | 156 | Returns a iterator for first entry of address book. |
157 | */ | 157 | */ |
158 | Iterator begin(); | 158 | Iterator begin(); |
159 | 159 | ||
160 | /** | 160 | /** |
161 | Returns a const iterator for first entry of address book. | 161 | Returns a const iterator for first entry of address book. |
162 | */ | 162 | */ |
163 | ConstIterator begin() const; | 163 | ConstIterator begin() const; |
164 | 164 | ||
165 | /** | 165 | /** |
166 | Returns a iterator for first entry of address book. | 166 | Returns a iterator for first entry of address book. |
167 | */ | 167 | */ |
168 | Iterator end(); | 168 | Iterator end(); |
169 | 169 | ||
170 | /** | 170 | /** |
171 | Returns a const iterator for first entry of address book. | 171 | Returns a const iterator for first entry of address book. |
172 | */ | 172 | */ |
173 | ConstIterator end() const; | 173 | ConstIterator end() const; |
174 | 174 | ||
175 | /** | 175 | /** |
176 | Removes all entries from address book. | 176 | Removes all entries from address book. |
177 | */ | 177 | */ |
178 | void clear(); | 178 | void clear(); |
179 | 179 | ||
180 | /** | 180 | /** |
181 | Insert an Addressee object into address book. If an object with the same | 181 | Insert an Addressee object into address book. If an object with the same |
182 | unique id already exists in the address book it it replaced by the new | 182 | unique id already exists in the address book it it replaced by the new |
183 | one. If not the new object is appended to the address book. | 183 | one. If not the new object is appended to the address book. |
184 | */ | 184 | */ |
185 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 185 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
186 | 186 | ||
187 | /** | 187 | /** |
188 | Removes entry from the address book. | 188 | Removes entry from the address book. |
189 | */ | 189 | */ |
190 | void removeAddressee( const Addressee & ); | 190 | void removeAddressee( const Addressee & ); |
191 | 191 | ||
192 | /** | 192 | /** |
193 | This is like @ref removeAddressee() just above, with the difference that | 193 | This is like @ref removeAddressee() just above, with the difference that |
194 | the first element is a iterator, returned by @ref begin(). | 194 | the first element is a iterator, returned by @ref begin(). |
195 | */ | 195 | */ |
196 | void removeAddressee( const Iterator & ); | 196 | void removeAddressee( const Iterator & ); |
197 | 197 | ||
198 | /** | 198 | /** |
199 | Find the specified entry in address book. Returns end(), if the entry | 199 | Find the specified entry in address book. Returns end(), if the entry |
200 | couldn't be found. | 200 | couldn't be found. |
201 | */ | 201 | */ |
202 | Iterator find( const Addressee & ); | 202 | Iterator find( const Addressee & ); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | Find the entry specified by an unique id. Returns an empty Addressee | 205 | Find the entry specified by an unique id. Returns an empty Addressee |
206 | object, if the address book does not contain an entry with this id. | 206 | object, if the address book does not contain an entry with this id. |
207 | */ | 207 | */ |
208 | Addressee findByUid( const QString & ); | 208 | Addressee findByUid( const QString & ); |
209 | 209 | ||
210 | 210 | ||
211 | /** | 211 | /** |
212 | Returns a list of all addressees in the address book. This list can | 212 | Returns a list of all addressees in the address book. This list can |
213 | be sorted with @ref KABC::AddresseeList for example. | 213 | be sorted with @ref KABC::AddresseeList for example. |
214 | */ | 214 | */ |
215 | Addressee::List allAddressees(); | 215 | Addressee::List allAddressees(); |
216 | 216 | ||
217 | /** | 217 | /** |
218 | Find all entries with the specified name in the address book. Returns | 218 | Find all entries with the specified name in the address book. Returns |
219 | an empty list, if no entries could be found. | 219 | an empty list, if no entries could be found. |
220 | */ | 220 | */ |
221 | Addressee::List findByName( const QString & ); | 221 | Addressee::List findByName( const QString & ); |
222 | 222 | ||
223 | /** | 223 | /** |
224 | Find all entries with the specified email address in the address book. | 224 | Find all entries with the specified email address in the address book. |
225 | Returns an empty list, if no entries could be found. | 225 | Returns an empty list, if no entries could be found. |
226 | */ | 226 | */ |
227 | Addressee::List findByEmail( const QString & ); | 227 | Addressee::List findByEmail( const QString & ); |
228 | 228 | ||
229 | /** | 229 | /** |
230 | Find all entries wich have the specified category in the address book. | 230 | Find all entries wich have the specified category in the address book. |
231 | Returns an empty list, if no entries could be found. | 231 | Returns an empty list, if no entries could be found. |
232 | */ | 232 | */ |
233 | Addressee::List findByCategory( const QString & ); | 233 | Addressee::List findByCategory( const QString & ); |
234 | 234 | ||
235 | /** | 235 | /** |
236 | Return a string identifying this addressbook. | 236 | Return a string identifying this addressbook. |
237 | */ | 237 | */ |
238 | virtual QString identifier(); | 238 | virtual QString identifier(); |
239 | 239 | ||
240 | /** | 240 | /** |
241 | Used for debug output. | 241 | Used for debug output. |
242 | */ | 242 | */ |
243 | void dump() const; | 243 | void dump() const; |
244 | 244 | ||
245 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 245 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
246 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 246 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
247 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 247 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
248 | 248 | ||
249 | /** | 249 | /** |
250 | Return list of all Fields known to the address book which are associated | 250 | Return list of all Fields known to the address book which are associated |
251 | with the given field category. | 251 | with the given field category. |
252 | */ | 252 | */ |
253 | Field::List fields( int category = Field::All ); | 253 | Field::List fields( int category = Field::All ); |
254 | 254 | ||
255 | /** | 255 | /** |
256 | Add custom field to address book. | 256 | Add custom field to address book. |
257 | 257 | ||
258 | @param label User visible label of the field. | 258 | @param label User visible label of the field. |
259 | @param category Ored list of field categories. | 259 | @param category Ored list of field categories. |
260 | @param key Identifier used as key for reading and writing the field. | 260 | @param key Identifier used as key for reading and writing the field. |
261 | @param app String used as application key for reading and writing | 261 | @param app String used as application key for reading and writing |
262 | the field. | 262 | the field. |
263 | */ | 263 | */ |
264 | bool addCustomField( const QString &label, int category = Field::All, | 264 | bool addCustomField( const QString &label, int category = Field::All, |
265 | const QString &key = QString::null, | 265 | const QString &key = QString::null, |
266 | const QString &app = QString::null ); | 266 | const QString &app = QString::null ); |
267 | 267 | ||
268 | 268 | ||
269 | /** | 269 | /** |
270 | Add address book resource. | 270 | Add address book resource. |
271 | */ | 271 | */ |
272 | bool addResource( Resource * ); | 272 | bool addResource( Resource * ); |
273 | 273 | ||
274 | /** | 274 | /** |
275 | Remove address book resource. | 275 | Remove address book resource. |
276 | */ | 276 | */ |
277 | void removeResources(); | 277 | void removeResources(); |
278 | bool removeResource( Resource * ); | 278 | bool removeResource( Resource * ); |
279 | 279 | ||
280 | /** | 280 | /** |
281 | Return pointer list of all resources. | 281 | Return pointer list of all resources. |
282 | */ | 282 | */ |
283 | QPtrList<Resource> resources(); | 283 | QPtrList<Resource> resources(); |
284 | 284 | ||
285 | /** | 285 | /** |
286 | Set the @p ErrorHandler, that is used by @ref error() to | 286 | Set the @p ErrorHandler, that is used by @ref error() to |
287 | provide gui-independend error messages. | 287 | provide gui-independend error messages. |
288 | */ | 288 | */ |
289 | void setErrorHandler( ErrorHandler * ); | 289 | void setErrorHandler( ErrorHandler * ); |
290 | 290 | ||
291 | /** | 291 | /** |
292 | Shows gui independend error messages. | 292 | Shows gui independend error messages. |
293 | */ | 293 | */ |
294 | void error( const QString& ); | 294 | void error( const QString& ); |
295 | 295 | ||
296 | /** | 296 | /** |
297 | Query all resources to clean up their lock files | 297 | Query all resources to clean up their lock files |
298 | */ | 298 | */ |
299 | void cleanUp(); | 299 | void cleanUp(); |
300 | 300 | ||
301 | // sync stuff | 301 | // sync stuff |
302 | //Addressee::List getExternLastSyncAddressees(); | 302 | //Addressee::List getExternLastSyncAddressees(); |
303 | void resetTempSyncStat(); | 303 | void resetTempSyncStat(); |
304 | QStringList uidList(); | 304 | QStringList uidList(); |
305 | void removeSyncAddressees( bool removeDeleted = false ); | 305 | void removeSyncAddressees( bool removeDeleted = false ); |
306 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); | 306 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); |
307 | Addressee findByExternUid( const QString& uid , const QString& profile ); | 307 | const Addressee findByExternUid( const QString& uid , const QString& profile ) const; |
308 | bool containsExternalUid( const QString& uid ); | 308 | bool containsExternalUid( const QString& uid ); |
309 | 309 | ||
310 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); | 310 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); |
311 | void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); | 311 | void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); |
312 | signals: | 312 | signals: |
313 | /** | 313 | /** |
314 | Emitted, when the address book has changed on disk. | 314 | Emitted, when the address book has changed on disk. |
315 | */ | 315 | */ |
316 | void addressBookChanged( AddressBook * ); | 316 | void addressBookChanged( AddressBook * ); |
317 | 317 | ||
318 | /** | 318 | /** |
319 | Emitted, when the address book has been locked for writing. | 319 | Emitted, when the address book has been locked for writing. |
320 | */ | 320 | */ |
321 | void addressBookLocked( AddressBook * ); | 321 | void addressBookLocked( AddressBook * ); |
322 | 322 | ||
323 | /** | 323 | /** |
324 | Emitted, when the address book has been unlocked. | 324 | Emitted, when the address book has been unlocked. |
325 | */ | 325 | */ |
326 | void addressBookUnlocked( AddressBook * ); | 326 | void addressBookUnlocked( AddressBook * ); |
327 | 327 | ||
328 | protected: | 328 | protected: |
329 | void deleteRemovedAddressees(); | 329 | void deleteRemovedAddressees(); |
330 | void setStandardResource( Resource * ); | 330 | void setStandardResource( Resource * ); |
331 | Resource *standardResource(); | 331 | Resource *standardResource(); |
332 | KRES::Manager<Resource> *resourceManager(); | 332 | KRES::Manager<Resource> *resourceManager(); |
333 | 333 | ||
334 | void init(const QString &config, const QString &family); | 334 | void init(const QString &config, const QString &family); |
335 | 335 | ||
336 | private: | 336 | private: |
337 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 337 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
338 | 338 | ||
339 | 339 | ||
340 | struct AddressBookData; | 340 | struct AddressBookData; |
341 | AddressBookData *d; | 341 | AddressBookData *d; |
342 | bool blockLSEchange; | 342 | bool blockLSEchange; |
343 | }; | 343 | }; |
344 | 344 | ||
345 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 345 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
346 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 346 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
347 | 347 | ||
348 | } | 348 | } |
349 | 349 | ||
350 | #endif | 350 | #endif |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index d60cd6b..3b238f5 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -400,449 +400,449 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | |||
400 | (*addressIter).setType( (*addressIterA).type() ); | 400 | (*addressIter).setType( (*addressIterA).type() ); |
401 | break; | 401 | break; |
402 | } | 402 | } |
403 | 403 | ||
404 | } | 404 | } |
405 | if ( isSubSet && ! found ) { | 405 | if ( isSubSet && ! found ) { |
406 | mData->addresses.append( *addressIterA ); | 406 | mData->addresses.append( *addressIterA ); |
407 | } | 407 | } |
408 | } | 408 | } |
409 | //qDebug("merge contact %s ", ad.uid().latin1()); | 409 | //qDebug("merge contact %s ", ad.uid().latin1()); |
410 | setUid( ad.uid() ); | 410 | setUid( ad.uid() ); |
411 | setRevision( ad.revision() ); | 411 | setRevision( ad.revision() ); |
412 | } | 412 | } |
413 | 413 | ||
414 | bool Addressee::removeVoice() | 414 | bool Addressee::removeVoice() |
415 | { | 415 | { |
416 | PhoneNumber::List phoneN = phoneNumbers(); | 416 | PhoneNumber::List phoneN = phoneNumbers(); |
417 | PhoneNumber::List::Iterator phoneIt; | 417 | PhoneNumber::List::Iterator phoneIt; |
418 | bool found = false; | 418 | bool found = false; |
419 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 419 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
420 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 420 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
421 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 421 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
422 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 422 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
423 | insertPhoneNumber( (*phoneIt) ); | 423 | insertPhoneNumber( (*phoneIt) ); |
424 | found = true; | 424 | found = true; |
425 | } | 425 | } |
426 | } | 426 | } |
427 | 427 | ||
428 | } | 428 | } |
429 | return found; | 429 | return found; |
430 | } | 430 | } |
431 | 431 | ||
432 | bool Addressee::containsAdr(const Addressee& ad ) | 432 | bool Addressee::containsAdr(const Addressee& ad ) |
433 | { | 433 | { |
434 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 434 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
435 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 435 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
436 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 436 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
437 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 437 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
438 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 438 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
439 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 439 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
440 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 440 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
441 | 441 | ||
442 | // compare phone numbers | 442 | // compare phone numbers |
443 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 443 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
444 | PhoneNumber::List::Iterator phoneIt; | 444 | PhoneNumber::List::Iterator phoneIt; |
445 | bool found = false; | 445 | bool found = false; |
446 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 446 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
447 | bool found = false; | 447 | bool found = false; |
448 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 448 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
449 | PhoneNumber::List::Iterator phoneItL; | 449 | PhoneNumber::List::Iterator phoneItL; |
450 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 450 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
451 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 451 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
452 | found = true; | 452 | found = true; |
453 | break; | 453 | break; |
454 | } | 454 | } |
455 | } | 455 | } |
456 | if ( ! found ) | 456 | if ( ! found ) |
457 | return false; | 457 | return false; |
458 | } | 458 | } |
459 | return true; | 459 | return true; |
460 | 460 | ||
461 | } | 461 | } |
462 | void Addressee::simplifyAddresses() | 462 | void Addressee::simplifyAddresses() |
463 | { | 463 | { |
464 | 464 | ||
465 | 465 | ||
466 | Address::List list; | 466 | Address::List list; |
467 | Address::List::Iterator it; | 467 | Address::List::Iterator it; |
468 | Address::List::Iterator it2; | 468 | Address::List::Iterator it2; |
469 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 469 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
470 | it2 = it; | 470 | it2 = it; |
471 | ++it2; | 471 | ++it2; |
472 | for( ; it2 != mData->addresses.end(); ++it2 ) { | 472 | for( ; it2 != mData->addresses.end(); ++it2 ) { |
473 | if ( (*it) == (*it2) ) { | 473 | if ( (*it) == (*it2) ) { |
474 | list.append( *it ); | 474 | list.append( *it ); |
475 | break; | 475 | break; |
476 | } | 476 | } |
477 | } | 477 | } |
478 | } | 478 | } |
479 | for( it = list.begin(); it != list.end(); ++it ) { | 479 | for( it = list.begin(); it != list.end(); ++it ) { |
480 | removeAddress( (*it) ); | 480 | removeAddress( (*it) ); |
481 | } | 481 | } |
482 | 482 | ||
483 | list.clear(); | 483 | list.clear(); |
484 | int max = 2; | 484 | int max = 2; |
485 | if ( mData->url.isValid() ) | 485 | if ( mData->url.isValid() ) |
486 | max = 1; | 486 | max = 1; |
487 | if ( mData->addresses.count() <= max ) return ; | 487 | if ( mData->addresses.count() <= max ) return ; |
488 | int count = 0; | 488 | int count = 0; |
489 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 489 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
490 | if ( count >= max ) | 490 | if ( count >= max ) |
491 | list.append( *it ); | 491 | list.append( *it ); |
492 | ++count; | 492 | ++count; |
493 | } | 493 | } |
494 | for( it = list.begin(); it != list.end(); ++it ) { | 494 | for( it = list.begin(); it != list.end(); ++it ) { |
495 | removeAddress( (*it) ); | 495 | removeAddress( (*it) ); |
496 | } | 496 | } |
497 | } | 497 | } |
498 | 498 | ||
499 | // removes all emails but the first | 499 | // removes all emails but the first |
500 | // needed by phone sync | 500 | // needed by phone sync |
501 | void Addressee::simplifyEmails() | 501 | void Addressee::simplifyEmails() |
502 | { | 502 | { |
503 | if ( mData->emails.count() == 0 ) return ; | 503 | if ( mData->emails.count() == 0 ) return ; |
504 | QString email = mData->emails.first(); | 504 | QString email = mData->emails.first(); |
505 | detach(); | 505 | detach(); |
506 | mData->emails.clear(); | 506 | mData->emails.clear(); |
507 | mData->emails.append( email ); | 507 | mData->emails.append( email ); |
508 | } | 508 | } |
509 | 509 | ||
510 | void Addressee::simplifyPhoneNumbers() | 510 | void Addressee::simplifyPhoneNumbers() |
511 | { | 511 | { |
512 | int max = 4; | 512 | int max = 4; |
513 | int inList = mData->phoneNumbers.count(); | 513 | int inList = mData->phoneNumbers.count(); |
514 | KABC::PhoneNumber::List removeNumbers; | 514 | KABC::PhoneNumber::List removeNumbers; |
515 | KABC::PhoneNumber::List::Iterator phoneIter; | 515 | KABC::PhoneNumber::List::Iterator phoneIter; |
516 | if ( inList > max ) { | 516 | if ( inList > max ) { |
517 | // delete non-preferred numbers | 517 | // delete non-preferred numbers |
518 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 518 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
519 | ++phoneIter ) { | 519 | ++phoneIter ) { |
520 | if ( inList > max ) { | 520 | if ( inList > max ) { |
521 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | 521 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { |
522 | removeNumbers.append( ( *phoneIter ) ); | 522 | removeNumbers.append( ( *phoneIter ) ); |
523 | --inList; | 523 | --inList; |
524 | } | 524 | } |
525 | } else | 525 | } else |
526 | break; | 526 | break; |
527 | } | 527 | } |
528 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 528 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
529 | ++phoneIter ) { | 529 | ++phoneIter ) { |
530 | removePhoneNumber(( *phoneIter )); | 530 | removePhoneNumber(( *phoneIter )); |
531 | } | 531 | } |
532 | // delete preferred numbers | 532 | // delete preferred numbers |
533 | if ( inList > max ) { | 533 | if ( inList > max ) { |
534 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 534 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
535 | ++phoneIter ) { | 535 | ++phoneIter ) { |
536 | if ( inList > max ) { | 536 | if ( inList > max ) { |
537 | removeNumbers.append( ( *phoneIter ) ); | 537 | removeNumbers.append( ( *phoneIter ) ); |
538 | --inList; | 538 | --inList; |
539 | } else | 539 | } else |
540 | break; | 540 | break; |
541 | } | 541 | } |
542 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 542 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
543 | ++phoneIter ) { | 543 | ++phoneIter ) { |
544 | removePhoneNumber(( *phoneIter )); | 544 | removePhoneNumber(( *phoneIter )); |
545 | } | 545 | } |
546 | } | 546 | } |
547 | } | 547 | } |
548 | // remove non-numeric characters | 548 | // remove non-numeric characters |
549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
550 | ++phoneIter ) { | 550 | ++phoneIter ) { |
551 | if ( ! ( *phoneIter ).simplifyNumber() ) | 551 | if ( ! ( *phoneIter ).simplifyNumber() ) |
552 | removeNumbers.append( ( *phoneIter ) ); | 552 | removeNumbers.append( ( *phoneIter ) ); |
553 | } | 553 | } |
554 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 554 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
555 | ++phoneIter ) { | 555 | ++phoneIter ) { |
556 | removePhoneNumber(( *phoneIter )); | 556 | removePhoneNumber(( *phoneIter )); |
557 | } | 557 | } |
558 | } | 558 | } |
559 | void Addressee::simplifyPhoneNumberTypes() | 559 | void Addressee::simplifyPhoneNumberTypes() |
560 | { | 560 | { |
561 | KABC::PhoneNumber::List::Iterator phoneIter; | 561 | KABC::PhoneNumber::List::Iterator phoneIter; |
562 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 562 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
563 | ++phoneIter ) | 563 | ++phoneIter ) |
564 | ( *phoneIter ).simplifyType(); | 564 | ( *phoneIter ).simplifyType(); |
565 | } | 565 | } |
566 | void Addressee::removeID(const QString &prof) | 566 | void Addressee::removeID(const QString &prof) |
567 | { | 567 | { |
568 | detach(); | 568 | detach(); |
569 | if ( prof.isEmpty() ) | 569 | if ( prof.isEmpty() ) |
570 | mData->mExternalId = ":"; | 570 | mData->mExternalId = ":"; |
571 | else | 571 | else |
572 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 572 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
573 | 573 | ||
574 | } | 574 | } |
575 | void Addressee::setID( const QString & prof , const QString & id ) | 575 | void Addressee::setID( const QString & prof , const QString & id ) |
576 | { | 576 | { |
577 | detach(); | 577 | detach(); |
578 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 578 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
579 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 579 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
580 | } | 580 | } |
581 | void Addressee::setTempSyncStat( int id ) | 581 | void Addressee::setTempSyncStat( int id ) |
582 | { | 582 | { |
583 | if ( mData->mTempSyncStat == id ) return; | 583 | if ( mData->mTempSyncStat == id ) return; |
584 | detach(); | 584 | detach(); |
585 | mData->mTempSyncStat = id; | 585 | mData->mTempSyncStat = id; |
586 | } | 586 | } |
587 | int Addressee::tempSyncStat() const | 587 | int Addressee::tempSyncStat() const |
588 | { | 588 | { |
589 | return mData->mTempSyncStat; | 589 | return mData->mTempSyncStat; |
590 | } | 590 | } |
591 | 591 | ||
592 | QString Addressee::getID( const QString & prof) | 592 | const QString Addressee::getID( const QString & prof) const |
593 | { | 593 | { |
594 | return KIdManager::getId ( mData->mExternalId, prof ); | 594 | return KIdManager::getId ( mData->mExternalId, prof ); |
595 | } | 595 | } |
596 | 596 | ||
597 | void Addressee::setCsum( const QString & prof , const QString & id ) | 597 | void Addressee::setCsum( const QString & prof , const QString & id ) |
598 | { | 598 | { |
599 | detach(); | 599 | detach(); |
600 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 600 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
601 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 601 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
602 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 602 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
603 | } | 603 | } |
604 | 604 | ||
605 | QString Addressee::getCsum( const QString & prof) | 605 | const QString Addressee::getCsum( const QString & prof) const |
606 | { | 606 | { |
607 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 607 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
608 | } | 608 | } |
609 | 609 | ||
610 | void Addressee::setIDStr( const QString & s ) | 610 | void Addressee::setIDStr( const QString & s ) |
611 | { | 611 | { |
612 | detach(); | 612 | detach(); |
613 | mData->mExternalId = s; | 613 | mData->mExternalId = s; |
614 | } | 614 | } |
615 | 615 | ||
616 | QString Addressee::IDStr() const | 616 | const QString Addressee::IDStr() const |
617 | { | 617 | { |
618 | return mData->mExternalId; | 618 | return mData->mExternalId; |
619 | } | 619 | } |
620 | 620 | ||
621 | void Addressee::setExternalUID( const QString &id ) | 621 | void Addressee::setExternalUID( const QString &id ) |
622 | { | 622 | { |
623 | if ( id == mData->externalUID ) return; | 623 | if ( id == mData->externalUID ) return; |
624 | detach(); | 624 | detach(); |
625 | mData->empty = false; | 625 | mData->empty = false; |
626 | mData->externalUID = id; | 626 | mData->externalUID = id; |
627 | } | 627 | } |
628 | 628 | ||
629 | QString Addressee::externalUID() const | 629 | const QString Addressee::externalUID() const |
630 | { | 630 | { |
631 | return mData->externalUID; | 631 | return mData->externalUID; |
632 | } | 632 | } |
633 | void Addressee::setOriginalExternalUID( const QString &id ) | 633 | void Addressee::setOriginalExternalUID( const QString &id ) |
634 | { | 634 | { |
635 | if ( id == mData->originalExternalUID ) return; | 635 | if ( id == mData->originalExternalUID ) return; |
636 | detach(); | 636 | detach(); |
637 | mData->empty = false; | 637 | mData->empty = false; |
638 | //qDebug("*******Set orig uid %s ", id.latin1()); | 638 | //qDebug("*******Set orig uid %s ", id.latin1()); |
639 | mData->originalExternalUID = id; | 639 | mData->originalExternalUID = id; |
640 | } | 640 | } |
641 | 641 | ||
642 | QString Addressee::originalExternalUID() const | 642 | QString Addressee::originalExternalUID() const |
643 | { | 643 | { |
644 | return mData->originalExternalUID; | 644 | return mData->originalExternalUID; |
645 | } | 645 | } |
646 | 646 | ||
647 | void Addressee::setUid( const QString &id ) | 647 | void Addressee::setUid( const QString &id ) |
648 | { | 648 | { |
649 | if ( id == mData->uid ) return; | 649 | if ( id == mData->uid ) return; |
650 | detach(); | 650 | detach(); |
651 | //qDebug("****setuid %s ", id.latin1()); | 651 | //qDebug("****setuid %s ", id.latin1()); |
652 | mData->empty = false; | 652 | mData->empty = false; |
653 | mData->uid = id; | 653 | mData->uid = id; |
654 | } | 654 | } |
655 | 655 | ||
656 | QString Addressee::uid() const | 656 | const QString Addressee::uid() const |
657 | { | 657 | { |
658 | if ( mData->uid.isEmpty() ) | 658 | if ( mData->uid.isEmpty() ) |
659 | mData->uid = KApplication::randomString( 10 ); | 659 | mData->uid = KApplication::randomString( 10 ); |
660 | 660 | ||
661 | return mData->uid; | 661 | return mData->uid; |
662 | } | 662 | } |
663 | 663 | ||
664 | QString Addressee::uidLabel() | 664 | QString Addressee::uidLabel() |
665 | { | 665 | { |
666 | return i18n("Unique Identifier"); | 666 | return i18n("Unique Identifier"); |
667 | } | 667 | } |
668 | 668 | ||
669 | void Addressee::setName( const QString &name ) | 669 | void Addressee::setName( const QString &name ) |
670 | { | 670 | { |
671 | if ( name == mData->name ) return; | 671 | if ( name == mData->name ) return; |
672 | detach(); | 672 | detach(); |
673 | mData->empty = false; | 673 | mData->empty = false; |
674 | mData->name = name; | 674 | mData->name = name; |
675 | } | 675 | } |
676 | 676 | ||
677 | QString Addressee::name() const | 677 | QString Addressee::name() const |
678 | { | 678 | { |
679 | return mData->name; | 679 | return mData->name; |
680 | } | 680 | } |
681 | 681 | ||
682 | QString Addressee::nameLabel() | 682 | QString Addressee::nameLabel() |
683 | { | 683 | { |
684 | return i18n("Name"); | 684 | return i18n("Name"); |
685 | } | 685 | } |
686 | 686 | ||
687 | 687 | ||
688 | void Addressee::setFormattedName( const QString &formattedName ) | 688 | void Addressee::setFormattedName( const QString &formattedName ) |
689 | { | 689 | { |
690 | if ( formattedName == mData->formattedName ) return; | 690 | if ( formattedName == mData->formattedName ) return; |
691 | detach(); | 691 | detach(); |
692 | mData->empty = false; | 692 | mData->empty = false; |
693 | mData->formattedName = formattedName; | 693 | mData->formattedName = formattedName; |
694 | } | 694 | } |
695 | 695 | ||
696 | QString Addressee::formattedName() const | 696 | QString Addressee::formattedName() const |
697 | { | 697 | { |
698 | return mData->formattedName; | 698 | return mData->formattedName; |
699 | } | 699 | } |
700 | 700 | ||
701 | QString Addressee::formattedNameLabel() | 701 | QString Addressee::formattedNameLabel() |
702 | { | 702 | { |
703 | return i18n("Formatted Name"); | 703 | return i18n("Formatted Name"); |
704 | } | 704 | } |
705 | 705 | ||
706 | 706 | ||
707 | void Addressee::setFamilyName( const QString &familyName ) | 707 | void Addressee::setFamilyName( const QString &familyName ) |
708 | { | 708 | { |
709 | if ( familyName == mData->familyName ) return; | 709 | if ( familyName == mData->familyName ) return; |
710 | detach(); | 710 | detach(); |
711 | mData->empty = false; | 711 | mData->empty = false; |
712 | mData->familyName = familyName; | 712 | mData->familyName = familyName; |
713 | } | 713 | } |
714 | 714 | ||
715 | QString Addressee::familyName() const | 715 | QString Addressee::familyName() const |
716 | { | 716 | { |
717 | return mData->familyName; | 717 | return mData->familyName; |
718 | } | 718 | } |
719 | 719 | ||
720 | QString Addressee::familyNameLabel() | 720 | QString Addressee::familyNameLabel() |
721 | { | 721 | { |
722 | return i18n("Family Name"); | 722 | return i18n("Family Name"); |
723 | } | 723 | } |
724 | 724 | ||
725 | 725 | ||
726 | void Addressee::setGivenName( const QString &givenName ) | 726 | void Addressee::setGivenName( const QString &givenName ) |
727 | { | 727 | { |
728 | if ( givenName == mData->givenName ) return; | 728 | if ( givenName == mData->givenName ) return; |
729 | detach(); | 729 | detach(); |
730 | mData->empty = false; | 730 | mData->empty = false; |
731 | mData->givenName = givenName; | 731 | mData->givenName = givenName; |
732 | } | 732 | } |
733 | 733 | ||
734 | QString Addressee::givenName() const | 734 | QString Addressee::givenName() const |
735 | { | 735 | { |
736 | return mData->givenName; | 736 | return mData->givenName; |
737 | } | 737 | } |
738 | 738 | ||
739 | QString Addressee::givenNameLabel() | 739 | QString Addressee::givenNameLabel() |
740 | { | 740 | { |
741 | return i18n("Given Name"); | 741 | return i18n("Given Name"); |
742 | } | 742 | } |
743 | 743 | ||
744 | 744 | ||
745 | void Addressee::setAdditionalName( const QString &additionalName ) | 745 | void Addressee::setAdditionalName( const QString &additionalName ) |
746 | { | 746 | { |
747 | if ( additionalName == mData->additionalName ) return; | 747 | if ( additionalName == mData->additionalName ) return; |
748 | detach(); | 748 | detach(); |
749 | mData->empty = false; | 749 | mData->empty = false; |
750 | mData->additionalName = additionalName; | 750 | mData->additionalName = additionalName; |
751 | } | 751 | } |
752 | 752 | ||
753 | QString Addressee::additionalName() const | 753 | QString Addressee::additionalName() const |
754 | { | 754 | { |
755 | return mData->additionalName; | 755 | return mData->additionalName; |
756 | } | 756 | } |
757 | 757 | ||
758 | QString Addressee::additionalNameLabel() | 758 | QString Addressee::additionalNameLabel() |
759 | { | 759 | { |
760 | return i18n("Additional Names"); | 760 | return i18n("Additional Names"); |
761 | } | 761 | } |
762 | 762 | ||
763 | 763 | ||
764 | void Addressee::setPrefix( const QString &prefix ) | 764 | void Addressee::setPrefix( const QString &prefix ) |
765 | { | 765 | { |
766 | if ( prefix == mData->prefix ) return; | 766 | if ( prefix == mData->prefix ) return; |
767 | detach(); | 767 | detach(); |
768 | mData->empty = false; | 768 | mData->empty = false; |
769 | mData->prefix = prefix; | 769 | mData->prefix = prefix; |
770 | } | 770 | } |
771 | 771 | ||
772 | QString Addressee::prefix() const | 772 | QString Addressee::prefix() const |
773 | { | 773 | { |
774 | return mData->prefix; | 774 | return mData->prefix; |
775 | } | 775 | } |
776 | 776 | ||
777 | QString Addressee::prefixLabel() | 777 | QString Addressee::prefixLabel() |
778 | { | 778 | { |
779 | return i18n("Honorific Prefixes"); | 779 | return i18n("Honorific Prefixes"); |
780 | } | 780 | } |
781 | 781 | ||
782 | 782 | ||
783 | void Addressee::setSuffix( const QString &suffix ) | 783 | void Addressee::setSuffix( const QString &suffix ) |
784 | { | 784 | { |
785 | if ( suffix == mData->suffix ) return; | 785 | if ( suffix == mData->suffix ) return; |
786 | detach(); | 786 | detach(); |
787 | mData->empty = false; | 787 | mData->empty = false; |
788 | mData->suffix = suffix; | 788 | mData->suffix = suffix; |
789 | } | 789 | } |
790 | 790 | ||
791 | QString Addressee::suffix() const | 791 | QString Addressee::suffix() const |
792 | { | 792 | { |
793 | return mData->suffix; | 793 | return mData->suffix; |
794 | } | 794 | } |
795 | 795 | ||
796 | QString Addressee::suffixLabel() | 796 | QString Addressee::suffixLabel() |
797 | { | 797 | { |
798 | return i18n("Honorific Suffixes"); | 798 | return i18n("Honorific Suffixes"); |
799 | } | 799 | } |
800 | 800 | ||
801 | 801 | ||
802 | void Addressee::setNickName( const QString &nickName ) | 802 | void Addressee::setNickName( const QString &nickName ) |
803 | { | 803 | { |
804 | if ( nickName == mData->nickName ) return; | 804 | if ( nickName == mData->nickName ) return; |
805 | detach(); | 805 | detach(); |
806 | mData->empty = false; | 806 | mData->empty = false; |
807 | mData->nickName = nickName; | 807 | mData->nickName = nickName; |
808 | } | 808 | } |
809 | 809 | ||
810 | QString Addressee::nickName() const | 810 | QString Addressee::nickName() const |
811 | { | 811 | { |
812 | return mData->nickName; | 812 | return mData->nickName; |
813 | } | 813 | } |
814 | 814 | ||
815 | QString Addressee::nickNameLabel() | 815 | QString Addressee::nickNameLabel() |
816 | { | 816 | { |
817 | return i18n("Nick Name"); | 817 | return i18n("Nick Name"); |
818 | } | 818 | } |
819 | 819 | ||
820 | 820 | ||
821 | void Addressee::setBirthday( const QDateTime &birthday ) | 821 | void Addressee::setBirthday( const QDateTime &birthday ) |
822 | { | 822 | { |
823 | if ( birthday == mData->birthday ) return; | 823 | if ( birthday == mData->birthday ) return; |
824 | detach(); | 824 | detach(); |
825 | mData->empty = false; | 825 | mData->empty = false; |
826 | mData->birthday = birthday; | 826 | mData->birthday = birthday; |
827 | } | 827 | } |
828 | 828 | ||
829 | QDateTime Addressee::birthday() const | 829 | QDateTime Addressee::birthday() const |
830 | { | 830 | { |
831 | return mData->birthday; | 831 | return mData->birthday; |
832 | } | 832 | } |
833 | 833 | ||
834 | QString Addressee::birthdayLabel() | 834 | QString Addressee::birthdayLabel() |
835 | { | 835 | { |
836 | return i18n("Birthday"); | 836 | return i18n("Birthday"); |
837 | } | 837 | } |
838 | 838 | ||
839 | 839 | ||
840 | QString Addressee::homeAddressStreetLabel() | 840 | QString Addressee::homeAddressStreetLabel() |
841 | { | 841 | { |
842 | return i18n("Home Address Street"); | 842 | return i18n("Home Address Street"); |
843 | } | 843 | } |
844 | 844 | ||
845 | 845 | ||
846 | QString Addressee::homeAddressLocalityLabel() | 846 | QString Addressee::homeAddressLocalityLabel() |
847 | { | 847 | { |
848 | return i18n("Home Address Locality"); | 848 | return i18n("Home Address Locality"); |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 08d2f56..8051fec 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,326 +1,326 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include <ksharedptr.h> | 37 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 38 | #include <kurl.h> |
39 | 39 | ||
40 | #include "address.h" | 40 | #include "address.h" |
41 | #include "agent.h" | 41 | #include "agent.h" |
42 | #include "geo.h" | 42 | #include "geo.h" |
43 | #include "key.h" | 43 | #include "key.h" |
44 | #include "phonenumber.h" | 44 | #include "phonenumber.h" |
45 | #include "picture.h" | 45 | #include "picture.h" |
46 | #include "secrecy.h" | 46 | #include "secrecy.h" |
47 | #include "sound.h" | 47 | #include "sound.h" |
48 | #include "timezone.h" | 48 | #include "timezone.h" |
49 | 49 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class Resource; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | @short address book entry | 55 | @short address book entry |
56 | 56 | ||
57 | This class represents an entry in the address book. | 57 | This class represents an entry in the address book. |
58 | 58 | ||
59 | The data of this class is implicitly shared. You can pass this class by value. | 59 | The data of this class is implicitly shared. You can pass this class by value. |
60 | 60 | ||
61 | If you need the name of a field for presenting it to the user you should use | 61 | If you need the name of a field for presenting it to the user you should use |
62 | the functions ending in Label(). They return a translated string which can be | 62 | the functions ending in Label(). They return a translated string which can be |
63 | used as label for the corresponding field. | 63 | used as label for the corresponding field. |
64 | 64 | ||
65 | About the name fields: | 65 | About the name fields: |
66 | 66 | ||
67 | givenName() is the first name and familyName() the last name. In some | 67 | givenName() is the first name and familyName() the last name. In some |
68 | countries the family name comes first, that's the reason for the | 68 | countries the family name comes first, that's the reason for the |
69 | naming. formattedName() is the full name with the correct formatting. | 69 | naming. formattedName() is the full name with the correct formatting. |
70 | It is used as an override, when the correct formatting can't be generated | 70 | It is used as an override, when the correct formatting can't be generated |
71 | from the other name fields automatically. | 71 | from the other name fields automatically. |
72 | 72 | ||
73 | realName() returns a fully formatted name(). It uses formattedName, if set, | 73 | realName() returns a fully formatted name(). It uses formattedName, if set, |
74 | otherwise it constucts the name from the name fields. As fallback, if | 74 | otherwise it constucts the name from the name fields. As fallback, if |
75 | nothing else is set it uses name(). | 75 | nothing else is set it uses name(). |
76 | 76 | ||
77 | name() is the NAME type of RFC2426. It can be used as internal name for the | 77 | name() is the NAME type of RFC2426. It can be used as internal name for the |
78 | data enty, but shouldn't be used for displaying the data to the user. | 78 | data enty, but shouldn't be used for displaying the data to the user. |
79 | */ | 79 | */ |
80 | class Addressee | 80 | class Addressee |
81 | { | 81 | { |
82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QValueList<Addressee> List; | 86 | typedef QValueList<Addressee> List; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | Construct an empty address book entry. | 89 | Construct an empty address book entry. |
90 | */ | 90 | */ |
91 | Addressee(); | 91 | Addressee(); |
92 | ~Addressee(); | 92 | ~Addressee(); |
93 | 93 | ||
94 | Addressee( const Addressee & ); | 94 | Addressee( const Addressee & ); |
95 | Addressee &operator=( const Addressee & ); | 95 | Addressee &operator=( const Addressee & ); |
96 | 96 | ||
97 | bool operator==( const Addressee & ) const; | 97 | bool operator==( const Addressee & ) const; |
98 | bool operator!=( const Addressee & ) const; | 98 | bool operator!=( const Addressee & ) const; |
99 | // sync stuff | 99 | // sync stuff |
100 | void setTempSyncStat(int id); | 100 | void setTempSyncStat(int id); |
101 | int tempSyncStat() const; | 101 | int tempSyncStat() const; |
102 | void setIDStr( const QString & ); | 102 | void setIDStr( const QString & ); |
103 | QString IDStr() const; | 103 | const QString IDStr() const; |
104 | void setID( const QString &, const QString & ); | 104 | void setID( const QString &, const QString & ); |
105 | QString getID( const QString & ); | 105 | const QString getID( const QString & ) const; |
106 | void setCsum( const QString &, const QString & ); | 106 | void setCsum( const QString &, const QString & ); |
107 | QString getCsum( const QString & ); | 107 | const QString getCsum( const QString & ) const ; |
108 | void removeID(const QString &); | 108 | void removeID(const QString &); |
109 | void computeCsum(const QString &dev); | 109 | void computeCsum(const QString &dev); |
110 | ulong getCsum4List( const QStringList & attList); | 110 | ulong getCsum4List( const QStringList & attList); |
111 | /** | 111 | /** |
112 | Return, if the address book entry is empty. | 112 | Return, if the address book entry is empty. |
113 | */ | 113 | */ |
114 | bool isEmpty() const; | 114 | bool isEmpty() const; |
115 | void setExternalUID( const QString &id ); | 115 | void setExternalUID( const QString &id ); |
116 | QString externalUID() const; | 116 | const QString externalUID() const; |
117 | void setOriginalExternalUID( const QString &id ); | 117 | void setOriginalExternalUID( const QString &id ); |
118 | QString originalExternalUID() const; | 118 | QString originalExternalUID() const; |
119 | void mergeContact( const Addressee& ad, bool isSubSet ); | 119 | void mergeContact( const Addressee& ad, bool isSubSet ); |
120 | void simplifyEmails(); | 120 | void simplifyEmails(); |
121 | void simplifyAddresses(); | 121 | void simplifyAddresses(); |
122 | void simplifyPhoneNumbers(); | 122 | void simplifyPhoneNumbers(); |
123 | void simplifyPhoneNumberTypes(); | 123 | void simplifyPhoneNumberTypes(); |
124 | bool removeVoice(); | 124 | bool removeVoice(); |
125 | bool containsAdr(const Addressee& addr ); | 125 | bool containsAdr(const Addressee& addr ); |
126 | 126 | ||
127 | /** | 127 | /** |
128 | Set unique identifier. | 128 | Set unique identifier. |
129 | */ | 129 | */ |
130 | void setUid( const QString &uid ); | 130 | void setUid( const QString &uid ); |
131 | /** | 131 | /** |
132 | Return unique identifier. | 132 | Return unique identifier. |
133 | */ | 133 | */ |
134 | QString uid() const; | 134 | const QString uid() const; |
135 | /** | 135 | /** |
136 | Return translated label for uid field. | 136 | Return translated label for uid field. |
137 | */ | 137 | */ |
138 | static QString uidLabel(); | 138 | static QString uidLabel(); |
139 | 139 | ||
140 | /** | 140 | /** |
141 | Set name. | 141 | Set name. |
142 | */ | 142 | */ |
143 | void setName( const QString &name ); | 143 | void setName( const QString &name ); |
144 | /** | 144 | /** |
145 | Return name. | 145 | Return name. |
146 | */ | 146 | */ |
147 | QString name() const; | 147 | QString name() const; |
148 | /** | 148 | /** |
149 | Return translated label for name field. | 149 | Return translated label for name field. |
150 | */ | 150 | */ |
151 | static QString nameLabel(); | 151 | static QString nameLabel(); |
152 | 152 | ||
153 | /** | 153 | /** |
154 | Set formatted name. | 154 | Set formatted name. |
155 | */ | 155 | */ |
156 | void setFormattedName( const QString &formattedName ); | 156 | void setFormattedName( const QString &formattedName ); |
157 | /** | 157 | /** |
158 | Return formatted name. | 158 | Return formatted name. |
159 | */ | 159 | */ |
160 | QString formattedName() const; | 160 | QString formattedName() const; |
161 | /** | 161 | /** |
162 | Return translated label for formattedName field. | 162 | Return translated label for formattedName field. |
163 | */ | 163 | */ |
164 | static QString formattedNameLabel(); | 164 | static QString formattedNameLabel(); |
165 | 165 | ||
166 | /** | 166 | /** |
167 | Set family name. | 167 | Set family name. |
168 | */ | 168 | */ |
169 | void setFamilyName( const QString &familyName ); | 169 | void setFamilyName( const QString &familyName ); |
170 | /** | 170 | /** |
171 | Return family name. | 171 | Return family name. |
172 | */ | 172 | */ |
173 | QString familyName() const; | 173 | QString familyName() const; |
174 | /** | 174 | /** |
175 | Return translated label for familyName field. | 175 | Return translated label for familyName field. |
176 | */ | 176 | */ |
177 | static QString familyNameLabel(); | 177 | static QString familyNameLabel(); |
178 | 178 | ||
179 | /** | 179 | /** |
180 | Set given name. | 180 | Set given name. |
181 | */ | 181 | */ |
182 | void setGivenName( const QString &givenName ); | 182 | void setGivenName( const QString &givenName ); |
183 | /** | 183 | /** |
184 | Return given name. | 184 | Return given name. |
185 | */ | 185 | */ |
186 | QString givenName() const; | 186 | QString givenName() const; |
187 | /** | 187 | /** |
188 | Return translated label for givenName field. | 188 | Return translated label for givenName field. |
189 | */ | 189 | */ |
190 | static QString givenNameLabel(); | 190 | static QString givenNameLabel(); |
191 | 191 | ||
192 | /** | 192 | /** |
193 | Set additional names. | 193 | Set additional names. |
194 | */ | 194 | */ |
195 | void setAdditionalName( const QString &additionalName ); | 195 | void setAdditionalName( const QString &additionalName ); |
196 | /** | 196 | /** |
197 | Return additional names. | 197 | Return additional names. |
198 | */ | 198 | */ |
199 | QString additionalName() const; | 199 | QString additionalName() const; |
200 | /** | 200 | /** |
201 | Return translated label for additionalName field. | 201 | Return translated label for additionalName field. |
202 | */ | 202 | */ |
203 | static QString additionalNameLabel(); | 203 | static QString additionalNameLabel(); |
204 | 204 | ||
205 | /** | 205 | /** |
206 | Set honorific prefixes. | 206 | Set honorific prefixes. |
207 | */ | 207 | */ |
208 | void setPrefix( const QString &prefix ); | 208 | void setPrefix( const QString &prefix ); |
209 | /** | 209 | /** |
210 | Return honorific prefixes. | 210 | Return honorific prefixes. |
211 | */ | 211 | */ |
212 | QString prefix() const; | 212 | QString prefix() const; |
213 | /** | 213 | /** |
214 | Return translated label for prefix field. | 214 | Return translated label for prefix field. |
215 | */ | 215 | */ |
216 | static QString prefixLabel(); | 216 | static QString prefixLabel(); |
217 | 217 | ||
218 | /** | 218 | /** |
219 | Set honorific suffixes. | 219 | Set honorific suffixes. |
220 | */ | 220 | */ |
221 | void setSuffix( const QString &suffix ); | 221 | void setSuffix( const QString &suffix ); |
222 | /** | 222 | /** |
223 | Return honorific suffixes. | 223 | Return honorific suffixes. |
224 | */ | 224 | */ |
225 | QString suffix() const; | 225 | QString suffix() const; |
226 | /** | 226 | /** |
227 | Return translated label for suffix field. | 227 | Return translated label for suffix field. |
228 | */ | 228 | */ |
229 | static QString suffixLabel(); | 229 | static QString suffixLabel(); |
230 | 230 | ||
231 | /** | 231 | /** |
232 | Set nick name. | 232 | Set nick name. |
233 | */ | 233 | */ |
234 | void setNickName( const QString &nickName ); | 234 | void setNickName( const QString &nickName ); |
235 | /** | 235 | /** |
236 | Return nick name. | 236 | Return nick name. |
237 | */ | 237 | */ |
238 | QString nickName() const; | 238 | QString nickName() const; |
239 | /** | 239 | /** |
240 | Return translated label for nickName field. | 240 | Return translated label for nickName field. |
241 | */ | 241 | */ |
242 | static QString nickNameLabel(); | 242 | static QString nickNameLabel(); |
243 | 243 | ||
244 | /** | 244 | /** |
245 | Set birthday. | 245 | Set birthday. |
246 | */ | 246 | */ |
247 | void setBirthday( const QDateTime &birthday ); | 247 | void setBirthday( const QDateTime &birthday ); |
248 | /** | 248 | /** |
249 | Return birthday. | 249 | Return birthday. |
250 | */ | 250 | */ |
251 | QDateTime birthday() const; | 251 | QDateTime birthday() const; |
252 | /** | 252 | /** |
253 | Return translated label for birthday field. | 253 | Return translated label for birthday field. |
254 | */ | 254 | */ |
255 | static QString birthdayLabel(); | 255 | static QString birthdayLabel(); |
256 | 256 | ||
257 | /** | 257 | /** |
258 | Return translated label for homeAddressStreet field. | 258 | Return translated label for homeAddressStreet field. |
259 | */ | 259 | */ |
260 | static QString homeAddressStreetLabel(); | 260 | static QString homeAddressStreetLabel(); |
261 | 261 | ||
262 | /** | 262 | /** |
263 | Return translated label for homeAddressLocality field. | 263 | Return translated label for homeAddressLocality field. |
264 | */ | 264 | */ |
265 | static QString homeAddressLocalityLabel(); | 265 | static QString homeAddressLocalityLabel(); |
266 | 266 | ||
267 | /** | 267 | /** |
268 | Return translated label for homeAddressRegion field. | 268 | Return translated label for homeAddressRegion field. |
269 | */ | 269 | */ |
270 | static QString homeAddressRegionLabel(); | 270 | static QString homeAddressRegionLabel(); |
271 | 271 | ||
272 | /** | 272 | /** |
273 | Return translated label for homeAddressPostalCode field. | 273 | Return translated label for homeAddressPostalCode field. |
274 | */ | 274 | */ |
275 | static QString homeAddressPostalCodeLabel(); | 275 | static QString homeAddressPostalCodeLabel(); |
276 | 276 | ||
277 | /** | 277 | /** |
278 | Return translated label for homeAddressCountry field. | 278 | Return translated label for homeAddressCountry field. |
279 | */ | 279 | */ |
280 | static QString homeAddressCountryLabel(); | 280 | static QString homeAddressCountryLabel(); |
281 | 281 | ||
282 | /** | 282 | /** |
283 | Return translated label for homeAddressLabel field. | 283 | Return translated label for homeAddressLabel field. |
284 | */ | 284 | */ |
285 | static QString homeAddressLabelLabel(); | 285 | static QString homeAddressLabelLabel(); |
286 | 286 | ||
287 | /** | 287 | /** |
288 | Return translated label for businessAddressStreet field. | 288 | Return translated label for businessAddressStreet field. |
289 | */ | 289 | */ |
290 | static QString businessAddressStreetLabel(); | 290 | static QString businessAddressStreetLabel(); |
291 | 291 | ||
292 | /** | 292 | /** |
293 | Return translated label for businessAddressLocality field. | 293 | Return translated label for businessAddressLocality field. |
294 | */ | 294 | */ |
295 | static QString businessAddressLocalityLabel(); | 295 | static QString businessAddressLocalityLabel(); |
296 | 296 | ||
297 | /** | 297 | /** |
298 | Return translated label for businessAddressRegion field. | 298 | Return translated label for businessAddressRegion field. |
299 | */ | 299 | */ |
300 | static QString businessAddressRegionLabel(); | 300 | static QString businessAddressRegionLabel(); |
301 | 301 | ||
302 | /** | 302 | /** |
303 | Return translated label for businessAddressPostalCode field. | 303 | Return translated label for businessAddressPostalCode field. |
304 | */ | 304 | */ |
305 | static QString businessAddressPostalCodeLabel(); | 305 | static QString businessAddressPostalCodeLabel(); |
306 | 306 | ||
307 | /** | 307 | /** |
308 | Return translated label for businessAddressCountry field. | 308 | Return translated label for businessAddressCountry field. |
309 | */ | 309 | */ |
310 | static QString businessAddressCountryLabel(); | 310 | static QString businessAddressCountryLabel(); |
311 | 311 | ||
312 | /** | 312 | /** |
313 | Return translated label for businessAddressLabel field. | 313 | Return translated label for businessAddressLabel field. |
314 | */ | 314 | */ |
315 | static QString businessAddressLabelLabel(); | 315 | static QString businessAddressLabelLabel(); |
316 | 316 | ||
317 | /** | 317 | /** |
318 | Return translated label for homePhone field. | 318 | Return translated label for homePhone field. |
319 | */ | 319 | */ |
320 | static QString homePhoneLabel(); | 320 | static QString homePhoneLabel(); |
321 | 321 | ||
322 | /** | 322 | /** |
323 | Return translated label for businessPhone field. | 323 | Return translated label for businessPhone field. |
324 | */ | 324 | */ |
325 | static QString businessPhoneLabel(); | 325 | static QString businessPhoneLabel(); |
326 | 326 | ||
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d393660..42e147f 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1185,386 +1185,386 @@ bool KABCore::modified() const | |||
1185 | return mModified; | 1185 | return mModified; |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1188 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1189 | { | 1189 | { |
1190 | addrModified( addr ); | 1190 | addrModified( addr ); |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) | 1193 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) |
1194 | { | 1194 | { |
1195 | 1195 | ||
1196 | Command *command = 0; | 1196 | Command *command = 0; |
1197 | QString uid; | 1197 | QString uid; |
1198 | 1198 | ||
1199 | // check if it exists already | 1199 | // check if it exists already |
1200 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1200 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1201 | if ( origAddr.isEmpty() ) | 1201 | if ( origAddr.isEmpty() ) |
1202 | command = new PwNewCommand( mAddressBook, addr ); | 1202 | command = new PwNewCommand( mAddressBook, addr ); |
1203 | else { | 1203 | else { |
1204 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1204 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1205 | uid = addr.uid(); | 1205 | uid = addr.uid(); |
1206 | } | 1206 | } |
1207 | 1207 | ||
1208 | UndoStack::instance()->push( command ); | 1208 | UndoStack::instance()->push( command ); |
1209 | RedoStack::instance()->clear(); | 1209 | RedoStack::instance()->clear(); |
1210 | if ( updateDetails ) | 1210 | if ( updateDetails ) |
1211 | mDetails->setAddressee( addr ); | 1211 | mDetails->setAddressee( addr ); |
1212 | setModified( true ); | 1212 | setModified( true ); |
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | void KABCore::newContact() | 1215 | void KABCore::newContact() |
1216 | { | 1216 | { |
1217 | 1217 | ||
1218 | 1218 | ||
1219 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1219 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1220 | 1220 | ||
1221 | QPtrList<KRES::Resource> kresResources; | 1221 | QPtrList<KRES::Resource> kresResources; |
1222 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1222 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1223 | KABC::Resource *resource; | 1223 | KABC::Resource *resource; |
1224 | while ( ( resource = it.current() ) != 0 ) { | 1224 | while ( ( resource = it.current() ) != 0 ) { |
1225 | ++it; | 1225 | ++it; |
1226 | if ( !resource->readOnly() ) { | 1226 | if ( !resource->readOnly() ) { |
1227 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1227 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1228 | if ( res ) | 1228 | if ( res ) |
1229 | kresResources.append( res ); | 1229 | kresResources.append( res ); |
1230 | } | 1230 | } |
1231 | } | 1231 | } |
1232 | 1232 | ||
1233 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1233 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1234 | resource = static_cast<KABC::Resource*>( res ); | 1234 | resource = static_cast<KABC::Resource*>( res ); |
1235 | 1235 | ||
1236 | if ( resource ) { | 1236 | if ( resource ) { |
1237 | KABC::Addressee addr; | 1237 | KABC::Addressee addr; |
1238 | addr.setResource( resource ); | 1238 | addr.setResource( resource ); |
1239 | mEditorDialog->setAddressee( addr ); | 1239 | mEditorDialog->setAddressee( addr ); |
1240 | KApplication::execDialog ( mEditorDialog ); | 1240 | KApplication::execDialog ( mEditorDialog ); |
1241 | 1241 | ||
1242 | } else | 1242 | } else |
1243 | return; | 1243 | return; |
1244 | 1244 | ||
1245 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1245 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1246 | 1246 | ||
1247 | 1247 | ||
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | void KABCore::addEmail( QString aStr ) | 1250 | void KABCore::addEmail( QString aStr ) |
1251 | { | 1251 | { |
1252 | #ifndef KAB_EMBEDDED | 1252 | #ifndef KAB_EMBEDDED |
1253 | QString fullName, email; | 1253 | QString fullName, email; |
1254 | 1254 | ||
1255 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1255 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1256 | 1256 | ||
1257 | // Try to lookup the addressee matching the email address | 1257 | // Try to lookup the addressee matching the email address |
1258 | bool found = false; | 1258 | bool found = false; |
1259 | QStringList emailList; | 1259 | QStringList emailList; |
1260 | KABC::AddressBook::Iterator it; | 1260 | KABC::AddressBook::Iterator it; |
1261 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1261 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1262 | emailList = (*it).emails(); | 1262 | emailList = (*it).emails(); |
1263 | if ( emailList.contains( email ) > 0 ) { | 1263 | if ( emailList.contains( email ) > 0 ) { |
1264 | found = true; | 1264 | found = true; |
1265 | (*it).setNameFromString( fullName ); | 1265 | (*it).setNameFromString( fullName ); |
1266 | editContact( (*it).uid() ); | 1266 | editContact( (*it).uid() ); |
1267 | } | 1267 | } |
1268 | } | 1268 | } |
1269 | 1269 | ||
1270 | if ( !found ) { | 1270 | if ( !found ) { |
1271 | KABC::Addressee addr; | 1271 | KABC::Addressee addr; |
1272 | addr.setNameFromString( fullName ); | 1272 | addr.setNameFromString( fullName ); |
1273 | addr.insertEmail( email, true ); | 1273 | addr.insertEmail( email, true ); |
1274 | 1274 | ||
1275 | mAddressBook->insertAddressee( addr ); | 1275 | mAddressBook->insertAddressee( addr ); |
1276 | mViewManager->refreshView( addr.uid() ); | 1276 | mViewManager->refreshView( addr.uid() ); |
1277 | editContact( addr.uid() ); | 1277 | editContact( addr.uid() ); |
1278 | } | 1278 | } |
1279 | #else //KAB_EMBEDDED | 1279 | #else //KAB_EMBEDDED |
1280 | qDebug("KABCore::addEmail finsih method"); | 1280 | qDebug("KABCore::addEmail finsih method"); |
1281 | #endif //KAB_EMBEDDED | 1281 | #endif //KAB_EMBEDDED |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1284 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1285 | { | 1285 | { |
1286 | mXXPortManager->importVCard( url, showPreview ); | 1286 | mXXPortManager->importVCard( url, showPreview ); |
1287 | } | 1287 | } |
1288 | void KABCore::importFromOL() | 1288 | void KABCore::importFromOL() |
1289 | { | 1289 | { |
1290 | #ifdef _WIN32_ | 1290 | #ifdef _WIN32_ |
1291 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1291 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1292 | idgl->exec(); | 1292 | idgl->exec(); |
1293 | KABC::Addressee::List list = idgl->getAddressList(); | 1293 | KABC::Addressee::List list = idgl->getAddressList(); |
1294 | if ( list.count() > 0 ) { | 1294 | if ( list.count() > 0 ) { |
1295 | KABC::Addressee::List listNew; | 1295 | KABC::Addressee::List listNew; |
1296 | KABC::Addressee::List listExisting; | 1296 | KABC::Addressee::List listExisting; |
1297 | KABC::Addressee::List::Iterator it; | 1297 | KABC::Addressee::List::Iterator it; |
1298 | KABC::AddressBook::Iterator iter; | 1298 | KABC::AddressBook::Iterator iter; |
1299 | for ( it = list.begin(); it != list.end(); ++it ) { | 1299 | for ( it = list.begin(); it != list.end(); ++it ) { |
1300 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1300 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1301 | listNew.append( (*it) ); | 1301 | listNew.append( (*it) ); |
1302 | else | 1302 | else |
1303 | listExisting.append( (*it) ); | 1303 | listExisting.append( (*it) ); |
1304 | } | 1304 | } |
1305 | if ( listExisting.count() > 0 ) | 1305 | if ( listExisting.count() > 0 ) |
1306 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1306 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1307 | if ( listNew.count() > 0 ) { | 1307 | if ( listNew.count() > 0 ) { |
1308 | pasteWithNewUid = false; | 1308 | pasteWithNewUid = false; |
1309 | pasteContacts( listNew ); | 1309 | pasteContacts( listNew ); |
1310 | pasteWithNewUid = true; | 1310 | pasteWithNewUid = true; |
1311 | } | 1311 | } |
1312 | } | 1312 | } |
1313 | delete idgl; | 1313 | delete idgl; |
1314 | #endif | 1314 | #endif |
1315 | } | 1315 | } |
1316 | 1316 | ||
1317 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1317 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1318 | { | 1318 | { |
1319 | mXXPortManager->importVCard( vCard, showPreview ); | 1319 | mXXPortManager->importVCard( vCard, showPreview ); |
1320 | } | 1320 | } |
1321 | 1321 | ||
1322 | //US added a second method without defaultparameter | 1322 | //US added a second method without defaultparameter |
1323 | void KABCore::editContact2() { | 1323 | void KABCore::editContact2() { |
1324 | editContact( QString::null ); | 1324 | editContact( QString::null ); |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | void KABCore::editContact( const QString &uid ) | 1327 | void KABCore::editContact( const QString &uid ) |
1328 | { | 1328 | { |
1329 | 1329 | ||
1330 | if ( mExtensionManager->isQuickEditVisible() ) | 1330 | if ( mExtensionManager->isQuickEditVisible() ) |
1331 | return; | 1331 | return; |
1332 | 1332 | ||
1333 | // First, locate the contact entry | 1333 | // First, locate the contact entry |
1334 | QString localUID = uid; | 1334 | QString localUID = uid; |
1335 | if ( localUID.isNull() ) { | 1335 | if ( localUID.isNull() ) { |
1336 | QStringList uidList = mViewManager->selectedUids(); | 1336 | QStringList uidList = mViewManager->selectedUids(); |
1337 | if ( uidList.count() > 0 ) | 1337 | if ( uidList.count() > 0 ) |
1338 | localUID = *( uidList.at( 0 ) ); | 1338 | localUID = *( uidList.at( 0 ) ); |
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1341 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1342 | if ( !addr.isEmpty() ) { | 1342 | if ( !addr.isEmpty() ) { |
1343 | mEditorDialog->setAddressee( addr ); | 1343 | mEditorDialog->setAddressee( addr ); |
1344 | KApplication::execDialog ( mEditorDialog ); | 1344 | KApplication::execDialog ( mEditorDialog ); |
1345 | } | 1345 | } |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | /** | 1348 | /** |
1349 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1349 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1350 | the method will try to find a selected addressee in the view. | 1350 | the method will try to find a selected addressee in the view. |
1351 | */ | 1351 | */ |
1352 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1352 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1353 | { | 1353 | { |
1354 | if ( mMultipleViewsAtOnce ) | 1354 | if ( mMultipleViewsAtOnce ) |
1355 | { | 1355 | { |
1356 | editContact( uid ); | 1356 | editContact( uid ); |
1357 | } | 1357 | } |
1358 | else | 1358 | else |
1359 | { | 1359 | { |
1360 | setDetailsVisible( true ); | 1360 | setDetailsVisible( true ); |
1361 | mActionDetails->setChecked(true); | 1361 | mActionDetails->setChecked(true); |
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | void KABCore::save() | 1366 | void KABCore::save() |
1367 | { | 1367 | { |
1368 | if (syncManager->blockSave()) | 1368 | if (syncManager->blockSave()) |
1369 | return; | 1369 | return; |
1370 | if ( !mModified ) | 1370 | if ( !mModified ) |
1371 | return; | 1371 | return; |
1372 | 1372 | ||
1373 | syncManager->setBlockSave(true); | 1373 | syncManager->setBlockSave(true); |
1374 | QString text = i18n( "There was an error while attempting to save\n the " | 1374 | QString text = i18n( "There was an error while attempting to save\n the " |
1375 | "address book. Please check that some \nother application is " | 1375 | "address book. Please check that some \nother application is " |
1376 | "not using it. " ); | 1376 | "not using it. " ); |
1377 | message(i18n("Saving ... please wait! ")); | 1377 | message(i18n("Saving ... please wait! "), false); |
1378 | qApp->processEvents(); | 1378 | //qApp->processEvents(); |
1379 | #ifndef KAB_EMBEDDED | 1379 | #ifndef KAB_EMBEDDED |
1380 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1380 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1381 | if ( !b || !b->save() ) { | 1381 | if ( !b || !b->save() ) { |
1382 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1382 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1383 | } | 1383 | } |
1384 | #else //KAB_EMBEDDED | 1384 | #else //KAB_EMBEDDED |
1385 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1385 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1386 | if ( !b || !b->save() ) { | 1386 | if ( !b || !b->save() ) { |
1387 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1387 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1388 | } | 1388 | } |
1389 | #endif //KAB_EMBEDDED | 1389 | #endif //KAB_EMBEDDED |
1390 | 1390 | ||
1391 | message(i18n("Addressbook saved!")); | 1391 | message(i18n("Addressbook saved!")); |
1392 | setModified( false ); | 1392 | setModified( false ); |
1393 | syncManager->setBlockSave(false); | 1393 | syncManager->setBlockSave(false); |
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | 1396 | ||
1397 | void KABCore::undo() | 1397 | void KABCore::undo() |
1398 | { | 1398 | { |
1399 | UndoStack::instance()->undo(); | 1399 | UndoStack::instance()->undo(); |
1400 | 1400 | ||
1401 | // Refresh the view | 1401 | // Refresh the view |
1402 | mViewManager->refreshView(); | 1402 | mViewManager->refreshView(); |
1403 | } | 1403 | } |
1404 | 1404 | ||
1405 | void KABCore::redo() | 1405 | void KABCore::redo() |
1406 | { | 1406 | { |
1407 | RedoStack::instance()->redo(); | 1407 | RedoStack::instance()->redo(); |
1408 | 1408 | ||
1409 | // Refresh the view | 1409 | // Refresh the view |
1410 | mViewManager->refreshView(); | 1410 | mViewManager->refreshView(); |
1411 | } | 1411 | } |
1412 | 1412 | ||
1413 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1413 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1414 | { | 1414 | { |
1415 | if (mMultipleViewsAtOnce) | 1415 | if (mMultipleViewsAtOnce) |
1416 | { | 1416 | { |
1417 | if ( visible ) | 1417 | if ( visible ) |
1418 | mJumpButtonBar->show(); | 1418 | mJumpButtonBar->show(); |
1419 | else | 1419 | else |
1420 | mJumpButtonBar->hide(); | 1420 | mJumpButtonBar->hide(); |
1421 | } | 1421 | } |
1422 | else | 1422 | else |
1423 | { | 1423 | { |
1424 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1424 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1425 | if (mViewManager->isVisible()) | 1425 | if (mViewManager->isVisible()) |
1426 | { | 1426 | { |
1427 | if ( visible ) | 1427 | if ( visible ) |
1428 | mJumpButtonBar->show(); | 1428 | mJumpButtonBar->show(); |
1429 | else | 1429 | else |
1430 | mJumpButtonBar->hide(); | 1430 | mJumpButtonBar->hide(); |
1431 | } | 1431 | } |
1432 | else | 1432 | else |
1433 | { | 1433 | { |
1434 | mJumpButtonBar->hide(); | 1434 | mJumpButtonBar->hide(); |
1435 | } | 1435 | } |
1436 | } | 1436 | } |
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | 1439 | ||
1440 | void KABCore::setDetailsToState() | 1440 | void KABCore::setDetailsToState() |
1441 | { | 1441 | { |
1442 | setDetailsVisible( mActionDetails->isChecked() ); | 1442 | setDetailsVisible( mActionDetails->isChecked() ); |
1443 | } | 1443 | } |
1444 | void KABCore::setDetailsToggle() | 1444 | void KABCore::setDetailsToggle() |
1445 | { | 1445 | { |
1446 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | 1446 | mActionDetails->setChecked( !mActionDetails->isChecked() ); |
1447 | setDetailsToState(); | 1447 | setDetailsToState(); |
1448 | } | 1448 | } |
1449 | 1449 | ||
1450 | 1450 | ||
1451 | 1451 | ||
1452 | void KABCore::setDetailsVisible( bool visible ) | 1452 | void KABCore::setDetailsVisible( bool visible ) |
1453 | { | 1453 | { |
1454 | if (visible && mDetails->isHidden()) | 1454 | if (visible && mDetails->isHidden()) |
1455 | { | 1455 | { |
1456 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1456 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1457 | if ( addrList.count() > 0 ) | 1457 | if ( addrList.count() > 0 ) |
1458 | mDetails->setAddressee( addrList[ 0 ] ); | 1458 | mDetails->setAddressee( addrList[ 0 ] ); |
1459 | } | 1459 | } |
1460 | 1460 | ||
1461 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1461 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1462 | // the listview and the detailview. We do that by changing the splitbar size. | 1462 | // the listview and the detailview. We do that by changing the splitbar size. |
1463 | if (mMultipleViewsAtOnce) | 1463 | if (mMultipleViewsAtOnce) |
1464 | { | 1464 | { |
1465 | if ( visible ) | 1465 | if ( visible ) |
1466 | mDetails->show(); | 1466 | mDetails->show(); |
1467 | else | 1467 | else |
1468 | mDetails->hide(); | 1468 | mDetails->hide(); |
1469 | } | 1469 | } |
1470 | else | 1470 | else |
1471 | { | 1471 | { |
1472 | if ( visible ) { | 1472 | if ( visible ) { |
1473 | mViewManager->hide(); | 1473 | mViewManager->hide(); |
1474 | mDetails->show(); | 1474 | mDetails->show(); |
1475 | mIncSearchWidget->setFocus(); | 1475 | mIncSearchWidget->setFocus(); |
1476 | } | 1476 | } |
1477 | else { | 1477 | else { |
1478 | mViewManager->show(); | 1478 | mViewManager->show(); |
1479 | mDetails->hide(); | 1479 | mDetails->hide(); |
1480 | mViewManager->setFocusAV(); | 1480 | mViewManager->setFocusAV(); |
1481 | } | 1481 | } |
1482 | setJumpButtonBarVisible( !visible ); | 1482 | setJumpButtonBarVisible( !visible ); |
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | void KABCore::extensionChanged( int id ) | 1487 | void KABCore::extensionChanged( int id ) |
1488 | { | 1488 | { |
1489 | //change the details view only for non desktop systems | 1489 | //change the details view only for non desktop systems |
1490 | #ifndef DESKTOP_VERSION | 1490 | #ifndef DESKTOP_VERSION |
1491 | 1491 | ||
1492 | if (id == 0) | 1492 | if (id == 0) |
1493 | { | 1493 | { |
1494 | //the user disabled the extension. | 1494 | //the user disabled the extension. |
1495 | 1495 | ||
1496 | if (mMultipleViewsAtOnce) | 1496 | if (mMultipleViewsAtOnce) |
1497 | { // enable detailsview again | 1497 | { // enable detailsview again |
1498 | setDetailsVisible( true ); | 1498 | setDetailsVisible( true ); |
1499 | mActionDetails->setChecked( true ); | 1499 | mActionDetails->setChecked( true ); |
1500 | } | 1500 | } |
1501 | else | 1501 | else |
1502 | { //go back to the listview | 1502 | { //go back to the listview |
1503 | setDetailsVisible( false ); | 1503 | setDetailsVisible( false ); |
1504 | mActionDetails->setChecked( false ); | 1504 | mActionDetails->setChecked( false ); |
1505 | mActionDetails->setEnabled(true); | 1505 | mActionDetails->setEnabled(true); |
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | } | 1508 | } |
1509 | else | 1509 | else |
1510 | { | 1510 | { |
1511 | //the user enabled the extension. | 1511 | //the user enabled the extension. |
1512 | setDetailsVisible( false ); | 1512 | setDetailsVisible( false ); |
1513 | mActionDetails->setChecked( false ); | 1513 | mActionDetails->setChecked( false ); |
1514 | 1514 | ||
1515 | if (!mMultipleViewsAtOnce) | 1515 | if (!mMultipleViewsAtOnce) |
1516 | { | 1516 | { |
1517 | mActionDetails->setEnabled(false); | 1517 | mActionDetails->setEnabled(false); |
1518 | } | 1518 | } |
1519 | 1519 | ||
1520 | mExtensionManager->setSelectionChanged(); | 1520 | mExtensionManager->setSelectionChanged(); |
1521 | 1521 | ||
1522 | } | 1522 | } |
1523 | 1523 | ||
1524 | #endif// DESKTOP_VERSION | 1524 | #endif// DESKTOP_VERSION |
1525 | 1525 | ||
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | 1528 | ||
1529 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1529 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1530 | { | 1530 | { |
1531 | 1531 | ||
1532 | if ( list.count() != 0 ) { | 1532 | if ( list.count() != 0 ) { |
1533 | KABC::Addressee::List::ConstIterator it; | 1533 | KABC::Addressee::List::ConstIterator it; |
1534 | for ( it = list.begin(); it != list.end(); ++it ) | 1534 | for ( it = list.begin(); it != list.end(); ++it ) |
1535 | mAddressBook->insertAddressee( *it ); | 1535 | mAddressBook->insertAddressee( *it ); |
1536 | if ( list.count() > 1 ) | 1536 | if ( list.count() > 1 ) |
1537 | setModified(); | 1537 | setModified(); |
1538 | else | 1538 | else |
1539 | setModifiedWOrefresh(); | 1539 | setModifiedWOrefresh(); |
1540 | } | 1540 | } |
1541 | if ( list.count() == 0 ) | 1541 | if ( list.count() == 0 ) |
1542 | mViewManager->refreshView(); | 1542 | mViewManager->refreshView(); |
1543 | else | 1543 | else |
1544 | mViewManager->refreshView( list[ 0 ].uid() ); | 1544 | mViewManager->refreshView( list[ 0 ].uid() ); |
1545 | 1545 | ||
1546 | 1546 | ||
1547 | 1547 | ||
1548 | } | 1548 | } |
1549 | 1549 | ||
1550 | QString KABCore::getNameByPhone( const QString &phone ) | 1550 | QString KABCore::getNameByPhone( const QString &phone ) |
1551 | { | 1551 | { |
1552 | #ifndef KAB_EMBEDDED | 1552 | #ifndef KAB_EMBEDDED |
1553 | QRegExp r( "[/*/-/ ]" ); | 1553 | QRegExp r( "[/*/-/ ]" ); |
1554 | QString localPhone( phone ); | 1554 | QString localPhone( phone ); |
1555 | 1555 | ||
1556 | bool found = false; | 1556 | bool found = false; |
1557 | QString ownerName = ""; | 1557 | QString ownerName = ""; |
1558 | KABC::AddressBook::Iterator iter; | 1558 | KABC::AddressBook::Iterator iter; |
1559 | KABC::PhoneNumber::List::Iterator phoneIter; | 1559 | KABC::PhoneNumber::List::Iterator phoneIter; |
1560 | KABC::PhoneNumber::List phoneList; | 1560 | KABC::PhoneNumber::List phoneList; |
1561 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1561 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1562 | phoneList = (*iter).phoneNumbers(); | 1562 | phoneList = (*iter).phoneNumbers(); |
1563 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1563 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1564 | ++phoneIter) { | 1564 | ++phoneIter) { |
1565 | // Get rid of separator chars so just the numbers are compared. | 1565 | // Get rid of separator chars so just the numbers are compared. |
1566 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1566 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1567 | ownerName = (*iter).formattedName(); | 1567 | ownerName = (*iter).formattedName(); |
1568 | found = true; | 1568 | found = true; |
1569 | } | 1569 | } |
1570 | } | 1570 | } |
@@ -2108,479 +2108,489 @@ void KABCore::addActionsManually() | |||
2108 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 2108 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
2109 | //mb->insertItem( i18n("&Change"), changeMenu ); | 2109 | //mb->insertItem( i18n("&Change"), changeMenu ); |
2110 | mb->insertItem( i18n("&Help"), helpMenu ); | 2110 | mb->insertItem( i18n("&Help"), helpMenu ); |
2111 | mIncSearchWidget = new IncSearchWidget( tb ); | 2111 | mIncSearchWidget = new IncSearchWidget( tb ); |
2112 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2112 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2113 | #ifndef DESKTOP_VERSION | 2113 | #ifndef DESKTOP_VERSION |
2114 | } else { | 2114 | } else { |
2115 | //US setup toolbar | 2115 | //US setup toolbar |
2116 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2116 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2117 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2117 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2118 | menuBarTB->insertItem( "ME", popupBarTB); | 2118 | menuBarTB->insertItem( "ME", popupBarTB); |
2119 | tb->insertWidget(-1, 0, menuBarTB); | 2119 | tb->insertWidget(-1, 0, menuBarTB); |
2120 | mIncSearchWidget = new IncSearchWidget( tb ); | 2120 | mIncSearchWidget = new IncSearchWidget( tb ); |
2121 | 2121 | ||
2122 | tb->enableMoving(false); | 2122 | tb->enableMoving(false); |
2123 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2123 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2124 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2124 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2125 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2125 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2126 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2126 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2127 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2127 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2128 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2128 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2129 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2129 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2130 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2130 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2131 | if (QApplication::desktop()->width() > 320 ) { | 2131 | if (QApplication::desktop()->width() > 320 ) { |
2132 | // mViewManager->getFilterAction()->plug ( tb); | 2132 | // mViewManager->getFilterAction()->plug ( tb); |
2133 | } | 2133 | } |
2134 | } | 2134 | } |
2135 | #endif | 2135 | #endif |
2136 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2136 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2137 | 2137 | ||
2138 | 2138 | ||
2139 | 2139 | ||
2140 | //US Now connect the actions with the menue entries. | 2140 | //US Now connect the actions with the menue entries. |
2141 | #ifdef DESKTOP_VERSION | 2141 | #ifdef DESKTOP_VERSION |
2142 | mActionPrint->plug( fileMenu ); | 2142 | mActionPrint->plug( fileMenu ); |
2143 | mActionPrintDetails->plug( fileMenu ); | 2143 | mActionPrintDetails->plug( fileMenu ); |
2144 | fileMenu->insertSeparator(); | 2144 | fileMenu->insertSeparator(); |
2145 | #endif | 2145 | #endif |
2146 | mActionMail->plug( fileMenu ); | 2146 | mActionMail->plug( fileMenu ); |
2147 | fileMenu->insertSeparator(); | 2147 | fileMenu->insertSeparator(); |
2148 | 2148 | ||
2149 | mActionNewContact->plug( fileMenu ); | 2149 | mActionNewContact->plug( fileMenu ); |
2150 | mActionNewContact->plug( tb ); | 2150 | mActionNewContact->plug( tb ); |
2151 | 2151 | ||
2152 | mActionEditAddressee->plug( fileMenu ); | 2152 | mActionEditAddressee->plug( fileMenu ); |
2153 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2153 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2154 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2154 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2155 | mActionEditAddressee->plug( tb ); | 2155 | mActionEditAddressee->plug( tb ); |
2156 | 2156 | ||
2157 | fileMenu->insertSeparator(); | 2157 | fileMenu->insertSeparator(); |
2158 | mActionSave->plug( fileMenu ); | 2158 | mActionSave->plug( fileMenu ); |
2159 | fileMenu->insertItem( "&Import", ImportMenu ); | 2159 | fileMenu->insertItem( "&Import", ImportMenu ); |
2160 | fileMenu->insertItem( "&Export", ExportMenu ); | 2160 | fileMenu->insertItem( "&Export", ExportMenu ); |
2161 | fileMenu->insertItem( i18n("&Change"), changeMenu ); | 2161 | fileMenu->insertItem( i18n("&Change"), changeMenu ); |
2162 | #ifndef DESKTOP_VERSION | 2162 | #ifndef DESKTOP_VERSION |
2163 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); | 2163 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); |
2164 | #endif | 2164 | #endif |
2165 | #if 0 | 2165 | #if 0 |
2166 | // PENDING fix MailVCard | 2166 | // PENDING fix MailVCard |
2167 | fileMenu->insertSeparator(); | 2167 | fileMenu->insertSeparator(); |
2168 | mActionMailVCard->plug( fileMenu ); | 2168 | mActionMailVCard->plug( fileMenu ); |
2169 | #endif | 2169 | #endif |
2170 | #ifndef DESKTOP_VERSION | 2170 | #ifndef DESKTOP_VERSION |
2171 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2171 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2172 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2172 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2173 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2173 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2174 | #endif | 2174 | #endif |
2175 | fileMenu->insertSeparator(); | 2175 | fileMenu->insertSeparator(); |
2176 | mActionQuit->plug( fileMenu ); | 2176 | mActionQuit->plug( fileMenu ); |
2177 | #ifdef _WIN32_ | 2177 | #ifdef _WIN32_ |
2178 | mActionImportOL->plug( ImportMenu ); | 2178 | mActionImportOL->plug( ImportMenu ); |
2179 | #endif | 2179 | #endif |
2180 | // edit menu | 2180 | // edit menu |
2181 | mActionUndo->plug( editMenu ); | 2181 | mActionUndo->plug( editMenu ); |
2182 | mActionRedo->plug( editMenu ); | 2182 | mActionRedo->plug( editMenu ); |
2183 | editMenu->insertSeparator(); | 2183 | editMenu->insertSeparator(); |
2184 | mActionCut->plug( editMenu ); | 2184 | mActionCut->plug( editMenu ); |
2185 | mActionCopy->plug( editMenu ); | 2185 | mActionCopy->plug( editMenu ); |
2186 | mActionPaste->plug( editMenu ); | 2186 | mActionPaste->plug( editMenu ); |
2187 | mActionDelete->plug( editMenu ); | 2187 | mActionDelete->plug( editMenu ); |
2188 | editMenu->insertSeparator(); | 2188 | editMenu->insertSeparator(); |
2189 | mActionSelectAll->plug( editMenu ); | 2189 | mActionSelectAll->plug( editMenu ); |
2190 | 2190 | ||
2191 | mActionSetFormattedName->plug( changeMenu ); | 2191 | mActionSetFormattedName->plug( changeMenu ); |
2192 | mActionRemoveVoice->plug( changeMenu ); | 2192 | mActionRemoveVoice->plug( changeMenu ); |
2193 | // settings menu | 2193 | // settings menu |
2194 | //US special menuentry to configure the addressbook resources. On KDE | 2194 | //US special menuentry to configure the addressbook resources. On KDE |
2195 | // you do that through the control center !!! | 2195 | // you do that through the control center !!! |
2196 | mActionConfigResources->plug( settingsMenu ); | 2196 | mActionConfigResources->plug( settingsMenu ); |
2197 | settingsMenu->insertSeparator(); | 2197 | settingsMenu->insertSeparator(); |
2198 | 2198 | ||
2199 | mActionConfigKAddressbook->plug( settingsMenu ); | 2199 | mActionConfigKAddressbook->plug( settingsMenu ); |
2200 | 2200 | ||
2201 | if ( mIsPart ) { | 2201 | if ( mIsPart ) { |
2202 | //US not implemented yet | 2202 | //US not implemented yet |
2203 | //mActionConfigShortcuts->plug( settingsMenu ); | 2203 | //mActionConfigShortcuts->plug( settingsMenu ); |
2204 | //mActionConfigureToolbars->plug( settingsMenu ); | 2204 | //mActionConfigureToolbars->plug( settingsMenu ); |
2205 | 2205 | ||
2206 | } else { | 2206 | } else { |
2207 | //US not implemented yet | 2207 | //US not implemented yet |
2208 | //mActionKeyBindings->plug( settingsMenu ); | 2208 | //mActionKeyBindings->plug( settingsMenu ); |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | settingsMenu->insertSeparator(); | 2211 | settingsMenu->insertSeparator(); |
2212 | 2212 | ||
2213 | mActionJumpBar->plug( settingsMenu ); | 2213 | mActionJumpBar->plug( settingsMenu ); |
2214 | mActionDetails->plug( settingsMenu ); | 2214 | mActionDetails->plug( settingsMenu ); |
2215 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2215 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2216 | mActionDetails->plug( tb ); | 2216 | mActionDetails->plug( tb ); |
2217 | settingsMenu->insertSeparator(); | 2217 | settingsMenu->insertSeparator(); |
2218 | #ifndef DESKTOP_VERSION | 2218 | #ifndef DESKTOP_VERSION |
2219 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2219 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2220 | #endif | 2220 | #endif |
2221 | settingsMenu->insertSeparator(); | 2221 | settingsMenu->insertSeparator(); |
2222 | 2222 | ||
2223 | mActionWhoAmI->plug( settingsMenu ); | 2223 | mActionWhoAmI->plug( settingsMenu ); |
2224 | mActionEditCategories->plug( settingsMenu ); | 2224 | mActionEditCategories->plug( settingsMenu ); |
2225 | mActionEditCategories->plug( changeMenu ); | 2225 | mActionEditCategories->plug( changeMenu ); |
2226 | mActionCategories->plug( changeMenu ); | 2226 | mActionCategories->plug( changeMenu ); |
2227 | mActionManageCategories->plug( changeMenu ); | 2227 | mActionManageCategories->plug( changeMenu ); |
2228 | 2228 | ||
2229 | mActionCategories->plug( settingsMenu ); | 2229 | mActionCategories->plug( settingsMenu ); |
2230 | mActionManageCategories->plug( settingsMenu ); | 2230 | mActionManageCategories->plug( settingsMenu ); |
2231 | 2231 | ||
2232 | 2232 | ||
2233 | mActionWN->plug( helpMenu ); | 2233 | mActionWN->plug( helpMenu ); |
2234 | mActionSyncHowto->plug( helpMenu ); | 2234 | mActionSyncHowto->plug( helpMenu ); |
2235 | mActionKdeSyncHowto->plug( helpMenu ); | 2235 | mActionKdeSyncHowto->plug( helpMenu ); |
2236 | mActionMultiSyncHowto->plug( helpMenu ); | 2236 | mActionMultiSyncHowto->plug( helpMenu ); |
2237 | mActionFaq->plug( helpMenu ); | 2237 | mActionFaq->plug( helpMenu ); |
2238 | mActionLicence->plug( helpMenu ); | 2238 | mActionLicence->plug( helpMenu ); |
2239 | mActionAboutKAddressbook->plug( helpMenu ); | 2239 | mActionAboutKAddressbook->plug( helpMenu ); |
2240 | 2240 | ||
2241 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2241 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2242 | 2242 | ||
2243 | mActionSave->plug( tb ); | 2243 | mActionSave->plug( tb ); |
2244 | mViewManager->getFilterAction()->plug ( tb); | 2244 | mViewManager->getFilterAction()->plug ( tb); |
2245 | //LR hide filteraction on started in 480x640 | 2245 | //LR hide filteraction on started in 480x640 |
2246 | if (QApplication::desktop()->width() == 480 ) { | 2246 | if (QApplication::desktop()->width() == 480 ) { |
2247 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 2247 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
2248 | } | 2248 | } |
2249 | mActionUndo->plug( tb ); | 2249 | mActionUndo->plug( tb ); |
2250 | mActionDelete->plug( tb ); | 2250 | mActionDelete->plug( tb ); |
2251 | mActionRedo->plug( tb ); | 2251 | mActionRedo->plug( tb ); |
2252 | } else { | 2252 | } else { |
2253 | mActionSave->plug( tb ); | 2253 | mActionSave->plug( tb ); |
2254 | tb->enableMoving(false); | 2254 | tb->enableMoving(false); |
2255 | } | 2255 | } |
2256 | //mActionQuit->plug ( tb ); | 2256 | //mActionQuit->plug ( tb ); |
2257 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2257 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2258 | 2258 | ||
2259 | //US link the searchwidget first to this. | 2259 | //US link the searchwidget first to this. |
2260 | // The real linkage to the toolbar happens later. | 2260 | // The real linkage to the toolbar happens later. |
2261 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2261 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2262 | //US tb->insertItem( mIncSearchWidget ); | 2262 | //US tb->insertItem( mIncSearchWidget ); |
2263 | /*US | 2263 | /*US |
2264 | mIncSearchWidget = new IncSearchWidget( tb ); | 2264 | mIncSearchWidget = new IncSearchWidget( tb ); |
2265 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2265 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2266 | SLOT( incrementalSearch( const QString& ) ) ); | 2266 | SLOT( incrementalSearch( const QString& ) ) ); |
2267 | 2267 | ||
2268 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2268 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2269 | 2269 | ||
2270 | //US topLayout->addWidget( mJumpButtonBar ); | 2270 | //US topLayout->addWidget( mJumpButtonBar ); |
2271 | this->layout()->add( mJumpButtonBar ); | 2271 | this->layout()->add( mJumpButtonBar ); |
2272 | */ | 2272 | */ |
2273 | 2273 | ||
2274 | #endif //KAB_EMBEDDED | 2274 | #endif //KAB_EMBEDDED |
2275 | 2275 | ||
2276 | mActionExport2phone->plug( ExportMenu ); | 2276 | mActionExport2phone->plug( ExportMenu ); |
2277 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2277 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2278 | syncManager->fillSyncMenu(); | 2278 | syncManager->fillSyncMenu(); |
2279 | 2279 | ||
2280 | } | 2280 | } |
2281 | void KABCore::showLicence() | 2281 | void KABCore::showLicence() |
2282 | { | 2282 | { |
2283 | KApplication::showLicence(); | 2283 | KApplication::showLicence(); |
2284 | } | 2284 | } |
2285 | 2285 | ||
2286 | void KABCore::manageCategories( ) | 2286 | void KABCore::manageCategories( ) |
2287 | { | 2287 | { |
2288 | KABCatPrefs* cp = new KABCatPrefs(); | 2288 | KABCatPrefs* cp = new KABCatPrefs(); |
2289 | cp->show(); | 2289 | cp->show(); |
2290 | int w =cp->sizeHint().width() ; | 2290 | int w =cp->sizeHint().width() ; |
2291 | int h = cp->sizeHint().height() ; | 2291 | int h = cp->sizeHint().height() ; |
2292 | int dw = QApplication::desktop()->width(); | 2292 | int dw = QApplication::desktop()->width(); |
2293 | int dh = QApplication::desktop()->height(); | 2293 | int dh = QApplication::desktop()->height(); |
2294 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2294 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2295 | if ( !cp->exec() ) { | 2295 | if ( !cp->exec() ) { |
2296 | delete cp; | 2296 | delete cp; |
2297 | return; | 2297 | return; |
2298 | } | 2298 | } |
2299 | int count = 0; | 2299 | int count = 0; |
2300 | int cc = 0; | ||
2300 | message( i18n("Please wait, processing categories...")); | 2301 | message( i18n("Please wait, processing categories...")); |
2301 | if ( cp->addCat() ) { | 2302 | if ( cp->addCat() ) { |
2302 | KABC::AddressBook::Iterator it; | 2303 | KABC::AddressBook::Iterator it; |
2303 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2304 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2304 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2305 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2306 | ++cc; | ||
2307 | if ( cc %10 == 0) | ||
2308 | message(i18n("Processing contact #%1").arg(cc)); | ||
2305 | QStringList catIncList = (*it).categories(); | 2309 | QStringList catIncList = (*it).categories(); |
2306 | int i; | 2310 | int i; |
2307 | for( i = 0; i< catIncList.count(); ++i ) { | 2311 | for( i = 0; i< catIncList.count(); ++i ) { |
2308 | if ( !catList.contains (catIncList[i])) { | 2312 | if ( !catList.contains (catIncList[i])) { |
2309 | catList.append( catIncList[i] ); | 2313 | catList.append( catIncList[i] ); |
2310 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2314 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2311 | ++count; | 2315 | ++count; |
2312 | } | 2316 | } |
2313 | } | 2317 | } |
2314 | } | 2318 | } |
2315 | catList.sort(); | 2319 | catList.sort(); |
2316 | KABPrefs::instance()->mCustomCategories = catList; | 2320 | KABPrefs::instance()->mCustomCategories = catList; |
2317 | KABPrefs::instance()->writeConfig(); | 2321 | KABPrefs::instance()->writeConfig(); |
2318 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2322 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2319 | } else { | 2323 | } else { |
2320 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2324 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2321 | QStringList catIncList; | 2325 | QStringList catIncList; |
2322 | QStringList newCatList; | 2326 | QStringList newCatList; |
2323 | KABC::AddressBook::Iterator it; | 2327 | KABC::AddressBook::Iterator it; |
2324 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2328 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2329 | ++cc; | ||
2330 | if ( cc %10 == 0) | ||
2331 | message(i18n("Processing contact #%1").arg(cc)); | ||
2325 | QStringList catIncList = (*it).categories(); | 2332 | QStringList catIncList = (*it).categories(); |
2326 | int i; | 2333 | int i; |
2327 | if ( catIncList.count() ) { | 2334 | if ( catIncList.count() ) { |
2328 | newCatList.clear(); | 2335 | newCatList.clear(); |
2329 | for( i = 0; i< catIncList.count(); ++i ) { | 2336 | for( i = 0; i< catIncList.count(); ++i ) { |
2330 | if ( catList.contains (catIncList[i])) { | 2337 | if ( catList.contains (catIncList[i])) { |
2331 | newCatList.append( catIncList[i] ); | 2338 | newCatList.append( catIncList[i] ); |
2332 | } | 2339 | } |
2333 | } | 2340 | } |
2334 | newCatList.sort(); | 2341 | newCatList.sort(); |
2335 | (*it).setCategories( newCatList ); | 2342 | (*it).setCategories( newCatList ); |
2336 | mAddressBook->insertAddressee( (*it) ); | 2343 | mAddressBook->insertAddressee( (*it) ); |
2337 | } | 2344 | } |
2338 | } | 2345 | } |
2339 | setModified( true ); | 2346 | setModified( true ); |
2340 | mViewManager->refreshView(); | 2347 | mViewManager->refreshView(); |
2341 | message( i18n("Removing categories done!")); | 2348 | message( i18n("Removing categories done!")); |
2342 | } | 2349 | } |
2343 | delete cp; | 2350 | delete cp; |
2344 | } | 2351 | } |
2345 | void KABCore::removeVoice() | 2352 | void KABCore::removeVoice() |
2346 | { | 2353 | { |
2347 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2354 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2348 | return; | 2355 | return; |
2349 | KABC::Addressee::List list; | 2356 | KABC::Addressee::List list; |
2350 | XXPortSelectDialog dlg( this, false, this ); | 2357 | XXPortSelectDialog dlg( this, false, this ); |
2351 | if ( dlg.exec() ) | 2358 | if ( dlg.exec() ) |
2352 | list = dlg.contacts(); | 2359 | list = dlg.contacts(); |
2353 | else | 2360 | else |
2354 | return; | 2361 | return; |
2355 | KABC::Addressee::List::Iterator it; | 2362 | KABC::Addressee::List::Iterator it; |
2356 | for ( it = list.begin(); it != list.end(); ++it ) { | 2363 | for ( it = list.begin(); it != list.end(); ++it ) { |
2357 | if ( (*it).removeVoice() ) | 2364 | if ( (*it).removeVoice() ) |
2358 | addrModified((*it), false ); | 2365 | addrModified((*it), false ); |
2359 | } | 2366 | } |
2360 | } | 2367 | } |
2361 | 2368 | ||
2362 | void KABCore::setFormattedName() | 2369 | void KABCore::setFormattedName() |
2363 | { | 2370 | { |
2364 | KABFormatPrefs setpref; | 2371 | KABFormatPrefs setpref; |
2365 | if ( !setpref.exec() ) { | 2372 | if ( !setpref.exec() ) { |
2366 | return; | 2373 | return; |
2367 | } | 2374 | } |
2368 | XXPortSelectDialog dlg( this, false, this ); | 2375 | XXPortSelectDialog dlg( this, false, this ); |
2369 | if ( !dlg.exec() ) | 2376 | if ( !dlg.exec() ) |
2370 | return; | 2377 | return; |
2371 | mAddressBook->setUntagged(); | 2378 | mAddressBook->setUntagged(); |
2372 | dlg.tagSelected(); | 2379 | dlg.tagSelected(); |
2373 | int count = 0; | 2380 | int count = 0; |
2374 | KABC::AddressBook::Iterator it; | 2381 | KABC::AddressBook::Iterator it; |
2375 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2382 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2376 | if ( (*it).tagged() ) { | 2383 | if ( (*it).tagged() ) { |
2377 | message(i18n("Changing contact #%1").arg( ++count ) ); | 2384 | ++count; |
2385 | if ( count %10 == 0 ) | ||
2386 | message(i18n("Changing contact #%1").arg( count ) ); | ||
2378 | qApp->processEvents(); | 2387 | qApp->processEvents(); |
2379 | QString fName; | 2388 | QString fName; |
2380 | if ( setpref.simple->isChecked() ) | 2389 | if ( setpref.simple->isChecked() ) |
2381 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); | 2390 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); |
2382 | else if ( setpref.full->isChecked() ) | 2391 | else if ( setpref.full->isChecked() ) |
2383 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); | 2392 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); |
2384 | else if ( setpref.reverse->isChecked() ) | 2393 | else if ( setpref.reverse->isChecked() ) |
2385 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); | 2394 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); |
2386 | else | 2395 | else |
2387 | fName = (*it).organization(); | 2396 | fName = (*it).organization(); |
2388 | if ( setpref.setCompany->isChecked() ) | 2397 | if ( setpref.setCompany->isChecked() ) |
2389 | if ( fName.isEmpty() || fName =="," ) | 2398 | if ( fName.isEmpty() || fName =="," ) |
2390 | fName = (*it).organization(); | 2399 | fName = (*it).organization(); |
2391 | (*it).setFormattedName( fName ); | 2400 | (*it).setFormattedName( fName ); |
2392 | } | 2401 | } |
2393 | } | 2402 | } |
2394 | message(i18n("Refreshing view...") ); | 2403 | message(i18n("Refreshing view...") ); |
2404 | qApp->processEvents(); | ||
2395 | mViewManager->refreshView( "" ); | 2405 | mViewManager->refreshView( "" ); |
2396 | Addressee add; | 2406 | Addressee add; |
2397 | mDetails->setAddressee( add ); | 2407 | mDetails->setAddressee( add ); |
2398 | message(i18n("Setting formatted name completed!") ); | 2408 | message(i18n("Setting formatted name completed!") ); |
2399 | } | 2409 | } |
2400 | 2410 | ||
2401 | void KABCore::clipboardDataChanged() | 2411 | void KABCore::clipboardDataChanged() |
2402 | { | 2412 | { |
2403 | 2413 | ||
2404 | if ( mReadWrite ) | 2414 | if ( mReadWrite ) |
2405 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2415 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2406 | 2416 | ||
2407 | } | 2417 | } |
2408 | 2418 | ||
2409 | void KABCore::updateActionMenu() | 2419 | void KABCore::updateActionMenu() |
2410 | { | 2420 | { |
2411 | UndoStack *undo = UndoStack::instance(); | 2421 | UndoStack *undo = UndoStack::instance(); |
2412 | RedoStack *redo = RedoStack::instance(); | 2422 | RedoStack *redo = RedoStack::instance(); |
2413 | 2423 | ||
2414 | if ( undo->isEmpty() ) | 2424 | if ( undo->isEmpty() ) |
2415 | mActionUndo->setText( i18n( "Undo" ) ); | 2425 | mActionUndo->setText( i18n( "Undo" ) ); |
2416 | else | 2426 | else |
2417 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2427 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2418 | 2428 | ||
2419 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2429 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2420 | 2430 | ||
2421 | if ( !redo->top() ) | 2431 | if ( !redo->top() ) |
2422 | mActionRedo->setText( i18n( "Redo" ) ); | 2432 | mActionRedo->setText( i18n( "Redo" ) ); |
2423 | else | 2433 | else |
2424 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2434 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2425 | 2435 | ||
2426 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2436 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2427 | } | 2437 | } |
2428 | 2438 | ||
2429 | void KABCore::configureKeyBindings() | 2439 | void KABCore::configureKeyBindings() |
2430 | { | 2440 | { |
2431 | #ifndef KAB_EMBEDDED | 2441 | #ifndef KAB_EMBEDDED |
2432 | KKeyDialog::configure( actionCollection(), true ); | 2442 | KKeyDialog::configure( actionCollection(), true ); |
2433 | #else //KAB_EMBEDDED | 2443 | #else //KAB_EMBEDDED |
2434 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2444 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2435 | #endif //KAB_EMBEDDED | 2445 | #endif //KAB_EMBEDDED |
2436 | } | 2446 | } |
2437 | 2447 | ||
2438 | #ifdef KAB_EMBEDDED | 2448 | #ifdef KAB_EMBEDDED |
2439 | void KABCore::configureResources() | 2449 | void KABCore::configureResources() |
2440 | { | 2450 | { |
2441 | KRES::KCMKResources dlg( this, "" , 0 ); | 2451 | KRES::KCMKResources dlg( this, "" , 0 ); |
2442 | 2452 | ||
2443 | if ( !dlg.exec() ) | 2453 | if ( !dlg.exec() ) |
2444 | return; | 2454 | return; |
2445 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2455 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2446 | } | 2456 | } |
2447 | #endif //KAB_EMBEDDED | 2457 | #endif //KAB_EMBEDDED |
2448 | 2458 | ||
2449 | 2459 | ||
2450 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2460 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2451 | * for the attendees list of an event. | 2461 | * for the attendees list of an event. |
2452 | */ | 2462 | */ |
2453 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2463 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2454 | { | 2464 | { |
2455 | QStringList nameList; | 2465 | QStringList nameList; |
2456 | QStringList emailList; | 2466 | QStringList emailList; |
2457 | QStringList uidList; | 2467 | QStringList uidList; |
2458 | 2468 | ||
2459 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2469 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2460 | uint i=0; | 2470 | uint i=0; |
2461 | for (i=0; i < list.count(); i++) | 2471 | for (i=0; i < list.count(); i++) |
2462 | { | 2472 | { |
2463 | nameList.append(list[i].realName()); | 2473 | nameList.append(list[i].realName()); |
2464 | emailList.append(list[i].preferredEmail()); | 2474 | emailList.append(list[i].preferredEmail()); |
2465 | uidList.append(list[i].uid()); | 2475 | uidList.append(list[i].uid()); |
2466 | } | 2476 | } |
2467 | 2477 | ||
2468 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2478 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2469 | 2479 | ||
2470 | } | 2480 | } |
2471 | 2481 | ||
2472 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2482 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2473 | * to put them into the calendar. | 2483 | * to put them into the calendar. |
2474 | */ | 2484 | */ |
2475 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2485 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2476 | { | 2486 | { |
2477 | // qDebug("KABCore::requestForBirthdayList"); | 2487 | // qDebug("KABCore::requestForBirthdayList"); |
2478 | QStringList birthdayList; | 2488 | QStringList birthdayList; |
2479 | QStringList anniversaryList; | 2489 | QStringList anniversaryList; |
2480 | QStringList realNameList; | 2490 | QStringList realNameList; |
2481 | QStringList preferredEmailList; | 2491 | QStringList preferredEmailList; |
2482 | QStringList assembledNameList; | 2492 | QStringList assembledNameList; |
2483 | QStringList uidList; | 2493 | QStringList uidList; |
2484 | 2494 | ||
2485 | KABC::AddressBook::Iterator it; | 2495 | KABC::AddressBook::Iterator it; |
2486 | 2496 | ||
2487 | int count = 0; | 2497 | int count = 0; |
2488 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2498 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2489 | ++count; | 2499 | ++count; |
2490 | } | 2500 | } |
2491 | QProgressBar bar(count,0 ); | 2501 | QProgressBar bar(count,0 ); |
2492 | int w = 300; | 2502 | int w = 300; |
2493 | if ( QApplication::desktop()->width() < 320 ) | 2503 | if ( QApplication::desktop()->width() < 320 ) |
2494 | w = 220; | 2504 | w = 220; |
2495 | int h = bar.sizeHint().height() ; | 2505 | int h = bar.sizeHint().height() ; |
2496 | int dw = QApplication::desktop()->width(); | 2506 | int dw = QApplication::desktop()->width(); |
2497 | int dh = QApplication::desktop()->height(); | 2507 | int dh = QApplication::desktop()->height(); |
2498 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2508 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2499 | bar.show(); | 2509 | bar.show(); |
2500 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2510 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2501 | qApp->processEvents(); | 2511 | qApp->processEvents(); |
2502 | 2512 | ||
2503 | QDate bday; | 2513 | QDate bday; |
2504 | QString anni; | 2514 | QString anni; |
2505 | QString formattedbday; | 2515 | QString formattedbday; |
2506 | 2516 | ||
2507 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2517 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2508 | { | 2518 | { |
2509 | if ( ! bar.isVisible() ) | 2519 | if ( ! bar.isVisible() ) |
2510 | return; | 2520 | return; |
2511 | bar.setProgress( count++ ); | 2521 | bar.setProgress( count++ ); |
2512 | qApp->processEvents(); | 2522 | qApp->processEvents(); |
2513 | bday = (*it).birthday().date(); | 2523 | bday = (*it).birthday().date(); |
2514 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2524 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2515 | 2525 | ||
2516 | if ( bday.isValid() || !anni.isEmpty()) | 2526 | if ( bday.isValid() || !anni.isEmpty()) |
2517 | { | 2527 | { |
2518 | if (bday.isValid()) | 2528 | if (bday.isValid()) |
2519 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2529 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2520 | else | 2530 | else |
2521 | formattedbday = "NOTVALID"; | 2531 | formattedbday = "NOTVALID"; |
2522 | if (anni.isEmpty()) | 2532 | if (anni.isEmpty()) |
2523 | anni = "INVALID"; | 2533 | anni = "INVALID"; |
2524 | 2534 | ||
2525 | birthdayList.append(formattedbday); | 2535 | birthdayList.append(formattedbday); |
2526 | anniversaryList.append(anni); //should be ISODate | 2536 | anniversaryList.append(anni); //should be ISODate |
2527 | realNameList.append((*it).realName()); | 2537 | realNameList.append((*it).realName()); |
2528 | preferredEmailList.append((*it).preferredEmail()); | 2538 | preferredEmailList.append((*it).preferredEmail()); |
2529 | assembledNameList.append((*it).assembledName()); | 2539 | assembledNameList.append((*it).assembledName()); |
2530 | uidList.append((*it).uid()); | 2540 | uidList.append((*it).uid()); |
2531 | 2541 | ||
2532 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2542 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2533 | } | 2543 | } |
2534 | } | 2544 | } |
2535 | 2545 | ||
2536 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2546 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2537 | 2547 | ||
2538 | } | 2548 | } |
2539 | 2549 | ||
2540 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2550 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2541 | */ | 2551 | */ |
2542 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2552 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2543 | { | 2553 | { |
2544 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2554 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2545 | 2555 | ||
2546 | QString foundUid = QString::null; | 2556 | QString foundUid = QString::null; |
2547 | if ( ! uid.isEmpty() ) { | 2557 | if ( ! uid.isEmpty() ) { |
2548 | Addressee adrr = mAddressBook->findByUid( uid ); | 2558 | Addressee adrr = mAddressBook->findByUid( uid ); |
2549 | if ( !adrr.isEmpty() ) { | 2559 | if ( !adrr.isEmpty() ) { |
2550 | foundUid = uid; | 2560 | foundUid = uid; |
2551 | } | 2561 | } |
2552 | if ( email == "sendbacklist" ) { | 2562 | if ( email == "sendbacklist" ) { |
2553 | //qDebug("ssssssssssssssssssssssend "); | 2563 | //qDebug("ssssssssssssssssssssssend "); |
2554 | QStringList nameList; | 2564 | QStringList nameList; |
2555 | QStringList emailList; | 2565 | QStringList emailList; |
2556 | QStringList uidList; | 2566 | QStringList uidList; |
2557 | nameList.append(adrr.realName()); | 2567 | nameList.append(adrr.realName()); |
2558 | emailList = adrr.emails(); | 2568 | emailList = adrr.emails(); |
2559 | uidList.append( adrr.preferredEmail()); | 2569 | uidList.append( adrr.preferredEmail()); |
2560 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2570 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2561 | return; | 2571 | return; |
2562 | } | 2572 | } |
2563 | 2573 | ||
2564 | } | 2574 | } |
2565 | 2575 | ||
2566 | if ( email == "sendbacklist" ) | 2576 | if ( email == "sendbacklist" ) |
2567 | return; | 2577 | return; |
2568 | if (foundUid.isEmpty()) | 2578 | if (foundUid.isEmpty()) |
2569 | { | 2579 | { |
2570 | //find the uid of the person first | 2580 | //find the uid of the person first |
2571 | Addressee::List namelist; | 2581 | Addressee::List namelist; |
2572 | Addressee::List emaillist; | 2582 | Addressee::List emaillist; |
2573 | 2583 | ||
2574 | if (!name.isEmpty()) | 2584 | if (!name.isEmpty()) |
2575 | namelist = mAddressBook->findByName( name ); | 2585 | namelist = mAddressBook->findByName( name ); |
2576 | 2586 | ||
2577 | if (!email.isEmpty()) | 2587 | if (!email.isEmpty()) |
2578 | emaillist = mAddressBook->findByEmail( email ); | 2588 | emaillist = mAddressBook->findByEmail( email ); |
2579 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2589 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2580 | //check if we have a match in Namelist and Emaillist | 2590 | //check if we have a match in Namelist and Emaillist |
2581 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2591 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2582 | foundUid = emaillist[0].uid(); | 2592 | foundUid = emaillist[0].uid(); |
2583 | } | 2593 | } |
2584 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2594 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2585 | foundUid = namelist[0].uid(); | 2595 | foundUid = namelist[0].uid(); |
2586 | else | 2596 | else |
@@ -3000,285 +3010,296 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
3000 | } | 3010 | } |
3001 | } | 3011 | } |
3002 | } else { | 3012 | } else { |
3003 | ++filteredIN; | 3013 | ++filteredIN; |
3004 | } | 3014 | } |
3005 | } | 3015 | } |
3006 | } | 3016 | } |
3007 | ++incCounter; | 3017 | ++incCounter; |
3008 | } | 3018 | } |
3009 | er.clear(); | 3019 | er.clear(); |
3010 | QStringList el = local->uidList(); | 3020 | QStringList el = local->uidList(); |
3011 | modulo = (el.count()/10)+1; | 3021 | modulo = (el.count()/10)+1; |
3012 | 3022 | ||
3013 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 3023 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
3014 | incCounter = 0; | 3024 | incCounter = 0; |
3015 | while ( incCounter < el.count()) { | 3025 | while ( incCounter < el.count()) { |
3016 | qApp->processEvents(); | 3026 | qApp->processEvents(); |
3017 | if (syncManager->isProgressBarCanceled()) | 3027 | if (syncManager->isProgressBarCanceled()) |
3018 | return false; | 3028 | return false; |
3019 | if ( incCounter % modulo == 0 ) | 3029 | if ( incCounter % modulo == 0 ) |
3020 | syncManager->showProgressBar(incCounter); | 3030 | syncManager->showProgressBar(incCounter); |
3021 | uid = el[ incCounter ]; | 3031 | uid = el[ incCounter ]; |
3022 | bool skipIncidence = false; | 3032 | bool skipIncidence = false; |
3023 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3033 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3024 | skipIncidence = true; | 3034 | skipIncidence = true; |
3025 | if ( !skipIncidence ) { | 3035 | if ( !skipIncidence ) { |
3026 | inL = local->findByUid( uid ); | 3036 | inL = local->findByUid( uid ); |
3027 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3037 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3028 | inR = remote->findByUid( uid ); | 3038 | inR = remote->findByUid( uid ); |
3029 | if ( inR.isEmpty() ){ | 3039 | if ( inR.isEmpty() ){ |
3030 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { | 3040 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { |
3031 | // no conflict ********** add or delete local | 3041 | // no conflict ********** add or delete local |
3032 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3042 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3033 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 3043 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
3034 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3044 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3035 | local->removeAddressee( inL ); | 3045 | local->removeAddressee( inL ); |
3036 | ++deletedAddresseeL; | 3046 | ++deletedAddresseeL; |
3037 | } else { | 3047 | } else { |
3038 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3048 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3039 | inL.removeID(mCurrentSyncDevice ); | 3049 | inL.removeID(mCurrentSyncDevice ); |
3040 | ++addedAddresseeR; | 3050 | ++addedAddresseeR; |
3041 | inL.setRevision( modifiedCalendar ); | 3051 | inL.setRevision( modifiedCalendar ); |
3042 | local->insertAddressee( inL, false ); | 3052 | local->insertAddressee( inL, false ); |
3043 | inR = inL; | 3053 | inR = inL; |
3044 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 3054 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
3045 | inR.setResource( 0 ); | 3055 | inR.setResource( 0 ); |
3046 | remote->insertAddressee( inR, false ); | 3056 | remote->insertAddressee( inR, false ); |
3047 | } | 3057 | } |
3048 | } | 3058 | } |
3049 | } else { | 3059 | } else { |
3050 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 3060 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
3051 | //qDebug("data %s ", inL.revision().toString().latin1()); | 3061 | //qDebug("data %s ", inL.revision().toString().latin1()); |
3052 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3062 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3053 | local->removeAddressee( inL ); | 3063 | local->removeAddressee( inL ); |
3054 | ++deletedAddresseeL; | 3064 | ++deletedAddresseeL; |
3055 | } else { | 3065 | } else { |
3056 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3066 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3057 | ++addedAddresseeR; | 3067 | ++addedAddresseeR; |
3058 | inL.setRevision( modifiedCalendar ); | 3068 | inL.setRevision( modifiedCalendar ); |
3059 | local->insertAddressee( inL, false ); | 3069 | local->insertAddressee( inL, false ); |
3060 | inR = inL; | 3070 | inR = inL; |
3061 | inR.setIDStr( ":" ); | 3071 | inR.setIDStr( ":" ); |
3062 | inR.setResource( 0 ); | 3072 | inR.setResource( 0 ); |
3063 | remote->insertAddressee( inR, false ); | 3073 | remote->insertAddressee( inR, false ); |
3064 | } | 3074 | } |
3065 | } | 3075 | } |
3066 | } | 3076 | } |
3067 | } else { | 3077 | } else { |
3068 | ++filteredOUT; | 3078 | ++filteredOUT; |
3069 | } | 3079 | } |
3070 | } | 3080 | } |
3071 | } | 3081 | } |
3072 | } | 3082 | } |
3073 | ++incCounter; | 3083 | ++incCounter; |
3074 | } | 3084 | } |
3075 | el.clear(); | 3085 | el.clear(); |
3076 | syncManager->hideProgressBar(); | 3086 | syncManager->hideProgressBar(); |
3077 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 3087 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
3078 | // get rid of micro seconds | 3088 | // get rid of micro seconds |
3079 | QTime t = mLastAddressbookSync.time(); | 3089 | QTime t = mLastAddressbookSync.time(); |
3080 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3090 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3081 | addresseeLSync.setRevision( mLastAddressbookSync ); | 3091 | addresseeLSync.setRevision( mLastAddressbookSync ); |
3082 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3092 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3083 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3093 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
3084 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3094 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
3085 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3095 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3086 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3096 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3087 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3097 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3088 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3098 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3089 | addresseeRSync.setNote( "" ) ; | 3099 | addresseeRSync.setNote( "" ) ; |
3090 | addresseeLSync.setNote( "" ); | 3100 | addresseeLSync.setNote( "" ); |
3091 | 3101 | ||
3092 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3102 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3093 | remote->insertAddressee( addresseeRSync, false ); | 3103 | remote->insertAddressee( addresseeRSync, false ); |
3094 | local->insertAddressee( addresseeLSync, false ); | 3104 | local->insertAddressee( addresseeLSync, false ); |
3095 | QString mes; | 3105 | QString mes; |
3096 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); | 3106 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); |
3097 | qDebug( mes ); | 3107 | qDebug( mes ); |
3098 | mes = i18n("Local addressbook changed!\n") +mes; | 3108 | mes = i18n("Local addressbook changed!\n") +mes; |
3099 | if ( syncManager->mShowSyncSummary ) { | 3109 | if ( syncManager->mShowSyncSummary ) { |
3100 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3110 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3101 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3111 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3102 | qDebug("cancelled "); | 3112 | qDebug("cancelled "); |
3103 | return false; | 3113 | return false; |
3104 | } | 3114 | } |
3105 | } | 3115 | } |
3106 | return syncOK; | 3116 | return syncOK; |
3107 | } | 3117 | } |
3108 | 3118 | ||
3109 | 3119 | ||
3110 | //this is a overwritten callbackmethods from the syncinterface | 3120 | //this is a overwritten callbackmethods from the syncinterface |
3111 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 3121 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
3112 | { | 3122 | { |
3113 | 3123 | ||
3114 | //pending prepare addresseeview for output | 3124 | //pending prepare addresseeview for output |
3115 | //pending detect, if remote file has REV field. if not switch to external sync | 3125 | //pending detect, if remote file has REV field. if not switch to external sync |
3116 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3126 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3117 | if ( manager != syncManager ) | 3127 | if ( manager != syncManager ) |
3118 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3128 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3119 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3129 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3120 | 3130 | ||
3121 | AddressBook abLocal(filename,"syncContact"); | 3131 | AddressBook abLocal(filename,"syncContact"); |
3122 | bool syncOK = false; | 3132 | bool syncOK = false; |
3123 | if ( abLocal.load() ) { | 3133 | if ( abLocal.load() ) { |
3124 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3134 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3125 | bool external = false; | 3135 | bool external = false; |
3126 | bool isXML = false; | 3136 | bool isXML = false; |
3127 | if ( filename.right(4) == ".xml") { | 3137 | if ( filename.right(4) == ".xml") { |
3128 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3138 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3129 | isXML = true; | 3139 | isXML = true; |
3130 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3140 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3131 | } else { | 3141 | } else { |
3132 | external = !manager->mIsKapiFile; | 3142 | external = !manager->mIsKapiFile; |
3133 | if ( external ) { | 3143 | if ( external ) { |
3134 | qDebug("Setting vcf mode to external "); | 3144 | qDebug("Setting vcf mode to external "); |
3135 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3145 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3136 | AddressBook::Iterator it; | 3146 | AddressBook::Iterator it; |
3137 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3147 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3138 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3148 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3139 | (*it).computeCsum( mCurrentSyncDevice ); | 3149 | (*it).computeCsum( mCurrentSyncDevice ); |
3140 | } | 3150 | } |
3141 | } | 3151 | } |
3142 | } | 3152 | } |
3143 | //AddressBook::Iterator it; | 3153 | //AddressBook::Iterator it; |
3144 | //QStringList vcards; | 3154 | //QStringList vcards; |
3145 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3155 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3146 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3156 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3147 | //} | 3157 | //} |
3148 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3158 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3149 | if ( syncOK ) { | 3159 | if ( syncOK ) { |
3150 | if ( syncManager->mWriteBackFile ) | 3160 | if ( syncManager->mWriteBackFile ) |
3151 | { | 3161 | { |
3152 | if ( external ) | 3162 | if ( external ) |
3153 | abLocal.removeSyncAddressees( !isXML); | 3163 | abLocal.removeSyncAddressees( !isXML); |
3154 | qDebug("Saving remote AB "); | 3164 | qDebug("Saving remote AB "); |
3155 | if ( ! abLocal.saveAB()) | 3165 | if ( ! abLocal.saveAB()) |
3156 | qDebug("Error writing back AB to file "); | 3166 | qDebug("Error writing back AB to file "); |
3157 | if ( external ) { | 3167 | if ( external ) { |
3158 | // afterwrite processing | 3168 | // afterwrite processing |
3159 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3169 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3160 | } | 3170 | } |
3161 | } | 3171 | } |
3162 | } | 3172 | } |
3163 | setModified(); | 3173 | setModified(); |
3164 | 3174 | ||
3165 | } | 3175 | } |
3166 | abLocal.removeResources(); | 3176 | abLocal.removeResources(); |
3167 | if ( syncOK ) | 3177 | if ( syncOK ) |
3168 | mViewManager->refreshView(); | 3178 | mViewManager->refreshView(); |
3169 | return syncOK; | 3179 | return syncOK; |
3170 | 3180 | ||
3171 | } | 3181 | } |
3172 | void KABCore::removeSyncInfo( QString syncProfile) | 3182 | void KABCore::removeSyncInfo( QString syncProfile) |
3173 | { | 3183 | { |
3174 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3184 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3175 | mAddressBook->removeSyncInfo( syncProfile ); | 3185 | mAddressBook->removeSyncInfo( syncProfile ); |
3176 | setModified(); | 3186 | setModified(); |
3177 | } | 3187 | } |
3178 | 3188 | ||
3179 | 3189 | ||
3180 | //this is a overwritten callbackmethods from the syncinterface | 3190 | //this is a overwritten callbackmethods from the syncinterface |
3181 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3191 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3182 | { | 3192 | { |
3183 | if ( resource == "phone" ) | 3193 | if ( resource == "phone" ) |
3184 | return syncPhone(); | 3194 | return syncPhone(); |
3185 | disableBR( true ); | 3195 | disableBR( true ); |
3186 | if ( manager != syncManager ) | 3196 | if ( manager != syncManager ) |
3187 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3197 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3188 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3198 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3189 | 3199 | ||
3190 | AddressBook abLocal( resource,"syncContact"); | 3200 | AddressBook abLocal( resource,"syncContact"); |
3191 | bool syncOK = false; | 3201 | bool syncOK = false; |
3202 | message(i18n("Loading DTM address data..."), false); | ||
3192 | if ( abLocal.load() ) { | 3203 | if ( abLocal.load() ) { |
3193 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3204 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3194 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3205 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3206 | message(i18n("Sync preprocessing..."),false); | ||
3195 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3207 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3208 | message(i18n("Synchronizing..."),false); | ||
3196 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3209 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3197 | if ( syncOK ) { | 3210 | if ( syncOK ) { |
3198 | if ( syncManager->mWriteBackFile ) { | 3211 | if ( syncManager->mWriteBackFile ) { |
3199 | abLocal.removeSyncAddressees( false ); | 3212 | abLocal.removeSyncAddressees( false ); |
3213 | message(i18n("Saving DTM address data..."),false); | ||
3200 | abLocal.saveAB(); | 3214 | abLocal.saveAB(); |
3215 | message(i18n("Sync postprocessing..."),false); | ||
3201 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3216 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3202 | } | 3217 | } |
3203 | } else | 3218 | } else |
3204 | message( i18n("Sync cancelled or failed.") ); | 3219 | message( i18n("Sync cancelled or failed.") ); |
3205 | setModified(); | 3220 | setModified(); |
3206 | } | 3221 | } |
3207 | abLocal.removeResources(); | 3222 | abLocal.removeResources(); |
3208 | if ( syncOK ) | 3223 | if ( syncOK ) { |
3209 | mViewManager->refreshView(); | 3224 | mViewManager->refreshView(); |
3225 | message(i18n("DTM syncing finished.")); | ||
3226 | } | ||
3210 | disableBR( false ); | 3227 | disableBR( false ); |
3211 | return syncOK; | 3228 | return syncOK; |
3212 | 3229 | ||
3213 | } | 3230 | } |
3214 | void KABCore::message( QString m ) | 3231 | void KABCore::message( QString m, bool startTimer) |
3215 | { | 3232 | { |
3216 | topLevelWidget()->setCaption( m ); | 3233 | topLevelWidget()->setCaption( m ); |
3217 | mMessageTimer->start( 20000, true ); | 3234 | qApp->processEvents(); |
3235 | if ( startTimer ) | ||
3236 | mMessageTimer->start( 15000, true ); | ||
3237 | else | ||
3238 | mMessageTimer->stop(); | ||
3218 | } | 3239 | } |
3219 | bool KABCore::syncPhone() | 3240 | bool KABCore::syncPhone() |
3220 | { | 3241 | { |
3221 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3242 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3222 | QString fileName = getPhoneFile(); | 3243 | QString fileName = getPhoneFile(); |
3223 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3244 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3224 | message(i18n("Phone access failed!")); | 3245 | message(i18n("Phone access failed!")); |
3225 | return false; | 3246 | return false; |
3226 | } | 3247 | } |
3227 | AddressBook abLocal( fileName,"syncContact"); | 3248 | AddressBook abLocal( fileName,"syncContact"); |
3228 | bool syncOK = false; | 3249 | bool syncOK = false; |
3229 | { | 3250 | { |
3230 | abLocal.importFromFile( fileName ); | 3251 | abLocal.importFromFile( fileName ); |
3231 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3252 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3232 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3253 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3233 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3254 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3234 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3255 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3235 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3256 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3236 | if ( syncOK ) { | 3257 | if ( syncOK ) { |
3237 | if ( syncManager->mWriteBackFile ) { | 3258 | if ( syncManager->mWriteBackFile ) { |
3238 | abLocal.removeSyncAddressees( true ); | 3259 | abLocal.removeSyncAddressees( true ); |
3239 | abLocal.saveABphone( fileName ); | 3260 | abLocal.saveABphone( fileName ); |
3240 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3261 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3241 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3262 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3242 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3263 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3243 | } | 3264 | } |
3244 | } | 3265 | } |
3245 | setModified(); | 3266 | setModified(); |
3246 | } | 3267 | } |
3247 | abLocal.removeResources(); | 3268 | abLocal.removeResources(); |
3248 | if ( syncOK ) | 3269 | if ( syncOK ) |
3249 | mViewManager->refreshView(); | 3270 | mViewManager->refreshView(); |
3250 | return syncOK; | 3271 | return syncOK; |
3251 | } | 3272 | } |
3252 | void KABCore::getFile( bool success ) | 3273 | void KABCore::getFile( bool success ) |
3253 | { | 3274 | { |
3254 | if ( ! success ) { | 3275 | if ( ! success ) { |
3255 | message( i18n("Error receiving file. Nothing changed!") ); | 3276 | message( i18n("Error receiving file. Nothing changed!") ); |
3256 | return; | 3277 | return; |
3257 | } | 3278 | } |
3258 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 3279 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
3259 | if ( count ) | 3280 | if ( count ) |
3260 | setModified( true ); | 3281 | setModified( true ); |
3261 | message( i18n("Pi-Sync successful!") ); | 3282 | message( i18n("Pi-Sync successful!") ); |
3262 | mViewManager->refreshView(); | 3283 | mViewManager->refreshView(); |
3263 | } | 3284 | } |
3264 | void KABCore::syncFileRequest() | 3285 | void KABCore::syncFileRequest() |
3265 | { | 3286 | { |
3266 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3287 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3267 | syncManager->slotSyncMenu( 999 ); | 3288 | syncManager->slotSyncMenu( 999 ); |
3268 | } | 3289 | } |
3269 | mAddressBook->export2File( sentSyncFile() ); | 3290 | mAddressBook->export2File( sentSyncFile() ); |
3270 | } | 3291 | } |
3271 | QString KABCore::sentSyncFile() | 3292 | QString KABCore::sentSyncFile() |
3272 | { | 3293 | { |
3273 | #ifdef DESKTOP_VERSION | 3294 | #ifdef DESKTOP_VERSION |
3274 | return locateLocal( "tmp", "copysyncab.vcf" ); | 3295 | return locateLocal( "tmp", "copysyncab.vcf" ); |
3275 | #else | 3296 | #else |
3276 | return QString( "/tmp/copysyncab.vcf" ); | 3297 | return QString( "/tmp/copysyncab.vcf" ); |
3277 | #endif | 3298 | #endif |
3278 | } | 3299 | } |
3279 | 3300 | ||
3280 | void KABCore::setCaptionBack() | 3301 | void KABCore::setCaptionBack() |
3281 | { | 3302 | { |
3282 | mMessageTimer->stop(); | 3303 | mMessageTimer->stop(); |
3283 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 3304 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
3284 | } | 3305 | } |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index ecfe6e9..786549a 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -311,209 +311,209 @@ class KABCore : public QWidget, public KSyncInterface | |||
311 | Shows the edit dialog for the given uid. If the uid is QString::null, | 311 | Shows the edit dialog for the given uid. If the uid is QString::null, |
312 | the method will try to find a selected addressee in the view. | 312 | the method will try to find a selected addressee in the view. |
313 | */ | 313 | */ |
314 | void editContact( const QString &uid /*US = QString::null*/ ); | 314 | void editContact( const QString &uid /*US = QString::null*/ ); |
315 | //US added a second method without defaultparameter | 315 | //US added a second method without defaultparameter |
316 | void editContact2(); | 316 | void editContact2(); |
317 | 317 | ||
318 | /** | 318 | /** |
319 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 319 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
320 | the method will try to find a selected addressee in the view. | 320 | the method will try to find a selected addressee in the view. |
321 | */ | 321 | */ |
322 | void executeContact( const QString &uid /*US = QString::null*/ ); | 322 | void executeContact( const QString &uid /*US = QString::null*/ ); |
323 | 323 | ||
324 | /** | 324 | /** |
325 | Launches the configuration dialog. | 325 | Launches the configuration dialog. |
326 | */ | 326 | */ |
327 | void openConfigDialog(); | 327 | void openConfigDialog(); |
328 | 328 | ||
329 | /** | 329 | /** |
330 | Launches the ldap search dialog. | 330 | Launches the ldap search dialog. |
331 | */ | 331 | */ |
332 | void openLDAPDialog(); | 332 | void openLDAPDialog(); |
333 | 333 | ||
334 | /** | 334 | /** |
335 | Creates a KAddressBookPrinter, which will display the print | 335 | Creates a KAddressBookPrinter, which will display the print |
336 | dialog and do the printing. | 336 | dialog and do the printing. |
337 | */ | 337 | */ |
338 | void print(); | 338 | void print(); |
339 | 339 | ||
340 | /** | 340 | /** |
341 | Registers a new GUI client, so plugins can register its actions. | 341 | Registers a new GUI client, so plugins can register its actions. |
342 | */ | 342 | */ |
343 | void addGUIClient( KXMLGUIClient *client ); | 343 | void addGUIClient( KXMLGUIClient *client ); |
344 | 344 | ||
345 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 345 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
346 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 346 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
347 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); | 347 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); |
348 | 348 | ||
349 | 349 | ||
350 | signals: | 350 | signals: |
351 | void contactSelected( const QString &name ); | 351 | void contactSelected( const QString &name ); |
352 | void contactSelected( const QPixmap &pixmap ); | 352 | void contactSelected( const QPixmap &pixmap ); |
353 | public slots: | 353 | public slots: |
354 | void recieve(QString cmsg ); | 354 | void recieve(QString cmsg ); |
355 | void getFile( bool success ); | 355 | void getFile( bool success ); |
356 | void syncFileRequest(); | 356 | void syncFileRequest(); |
357 | void setDetailsVisible( bool visible ); | 357 | void setDetailsVisible( bool visible ); |
358 | void setDetailsToState(); | 358 | void setDetailsToState(); |
359 | 359 | ||
360 | void saveSettings(); | 360 | void saveSettings(); |
361 | 361 | ||
362 | private slots: | 362 | private slots: |
363 | void updateToolBar(); | 363 | void updateToolBar(); |
364 | void updateMainWindow(); | 364 | void updateMainWindow(); |
365 | void receive( const QCString& cmsg, const QByteArray& data ); | 365 | void receive( const QCString& cmsg, const QByteArray& data ); |
366 | void toggleBeamReceive( ); | 366 | void toggleBeamReceive( ); |
367 | void disableBR(bool); | 367 | void disableBR(bool); |
368 | void setJumpButtonBarVisible( bool visible ); | 368 | void setJumpButtonBarVisible( bool visible ); |
369 | void setCaptionBack(); | 369 | void setCaptionBack(); |
370 | void importFromOL(); | 370 | void importFromOL(); |
371 | void extensionModified( const KABC::Addressee::List &list ); | 371 | void extensionModified( const KABC::Addressee::List &list ); |
372 | void extensionChanged( int id ); | 372 | void extensionChanged( int id ); |
373 | void clipboardDataChanged(); | 373 | void clipboardDataChanged(); |
374 | void updateActionMenu(); | 374 | void updateActionMenu(); |
375 | void configureKeyBindings(); | 375 | void configureKeyBindings(); |
376 | void removeVoice(); | 376 | void removeVoice(); |
377 | void setFormattedName(); | 377 | void setFormattedName(); |
378 | #ifdef KAB_EMBEDDED | 378 | #ifdef KAB_EMBEDDED |
379 | void configureResources(); | 379 | void configureResources(); |
380 | #endif //KAB_EMBEDDED | 380 | #endif //KAB_EMBEDDED |
381 | 381 | ||
382 | void slotEditorDestroyed( const QString &uid ); | 382 | void slotEditorDestroyed( const QString &uid ); |
383 | void configurationChanged(); | 383 | void configurationChanged(); |
384 | void addressBookChanged(); | 384 | void addressBookChanged(); |
385 | 385 | ||
386 | private: | 386 | private: |
387 | void resizeEvent(QResizeEvent* e ); | 387 | void resizeEvent(QResizeEvent* e ); |
388 | bool mBRdisabled; | 388 | bool mBRdisabled; |
389 | #ifndef DESKTOP_VERSION | 389 | #ifndef DESKTOP_VERSION |
390 | QCopChannel* infrared; | 390 | QCopChannel* infrared; |
391 | #endif | 391 | #endif |
392 | QTimer *mMessageTimer; | 392 | QTimer *mMessageTimer; |
393 | void initGUI(); | 393 | void initGUI(); |
394 | void initActions(); | 394 | void initActions(); |
395 | QString getPhoneFile(); | 395 | QString getPhoneFile(); |
396 | 396 | ||
397 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 397 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
398 | const char *name = 0 ); | 398 | const char *name = 0 ); |
399 | 399 | ||
400 | KXMLGUIClient *mGUIClient; | 400 | KXMLGUIClient *mGUIClient; |
401 | 401 | ||
402 | KABC::AddressBook *mAddressBook; | 402 | KABC::AddressBook *mAddressBook; |
403 | 403 | ||
404 | ViewManager *mViewManager; | 404 | ViewManager *mViewManager; |
405 | // QSplitter *mDetailsSplitter; | 405 | // QSplitter *mDetailsSplitter; |
406 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 406 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
407 | ViewContainer *mDetails; | 407 | ViewContainer *mDetails; |
408 | KDGanttMinimizeSplitter* mMiniSplitter; | 408 | KDGanttMinimizeSplitter* mMiniSplitter; |
409 | XXPortManager *mXXPortManager; | 409 | XXPortManager *mXXPortManager; |
410 | JumpButtonBar *mJumpButtonBar; | 410 | JumpButtonBar *mJumpButtonBar; |
411 | IncSearchWidget *mIncSearchWidget; | 411 | IncSearchWidget *mIncSearchWidget; |
412 | ExtensionManager *mExtensionManager; | 412 | ExtensionManager *mExtensionManager; |
413 | 413 | ||
414 | KCMultiDialog *mConfigureDialog; | 414 | KCMultiDialog *mConfigureDialog; |
415 | 415 | ||
416 | #ifndef KAB_EMBEDDED | 416 | #ifndef KAB_EMBEDDED |
417 | LDAPSearchDialog *mLdapSearchDialog; | 417 | LDAPSearchDialog *mLdapSearchDialog; |
418 | #endif //KAB_EMBEDDED | 418 | #endif //KAB_EMBEDDED |
419 | // QDict<AddresseeEditorDialog> mEditorDict; | 419 | // QDict<AddresseeEditorDialog> mEditorDict; |
420 | AddresseeEditorDialog *mEditorDialog; | 420 | AddresseeEditorDialog *mEditorDialog; |
421 | bool mReadWrite; | 421 | bool mReadWrite; |
422 | bool mModified; | 422 | bool mModified; |
423 | bool mIsPart; | 423 | bool mIsPart; |
424 | bool mMultipleViewsAtOnce; | 424 | bool mMultipleViewsAtOnce; |
425 | 425 | ||
426 | 426 | ||
427 | //US file menu | 427 | //US file menu |
428 | KAction *mActionMail; | 428 | KAction *mActionMail; |
429 | KAction *mActionBeam; | 429 | KAction *mActionBeam; |
430 | KToggleAction *mActionBR; | 430 | KToggleAction *mActionBR; |
431 | KAction *mActionExport2phone; | 431 | KAction *mActionExport2phone; |
432 | KAction* mActionPrint; | 432 | KAction* mActionPrint; |
433 | KAction* mActionPrintDetails; | 433 | KAction* mActionPrintDetails; |
434 | KAction* mActionNewContact; | 434 | KAction* mActionNewContact; |
435 | KAction *mActionSave; | 435 | KAction *mActionSave; |
436 | KAction *mActionEditAddressee; | 436 | KAction *mActionEditAddressee; |
437 | KAction *mActionMailVCard; | 437 | KAction *mActionMailVCard; |
438 | KAction *mActionBeamVCard; | 438 | KAction *mActionBeamVCard; |
439 | 439 | ||
440 | KAction *mActionQuit; | 440 | KAction *mActionQuit; |
441 | 441 | ||
442 | //US edit menu | 442 | //US edit menu |
443 | KAction *mActionCopy; | 443 | KAction *mActionCopy; |
444 | KAction *mActionCut; | 444 | KAction *mActionCut; |
445 | KAction *mActionPaste; | 445 | KAction *mActionPaste; |
446 | KAction *mActionSelectAll; | 446 | KAction *mActionSelectAll; |
447 | KAction *mActionUndo; | 447 | KAction *mActionUndo; |
448 | KAction *mActionRedo; | 448 | KAction *mActionRedo; |
449 | KAction *mActionDelete; | 449 | KAction *mActionDelete; |
450 | 450 | ||
451 | //US settings menu | 451 | //US settings menu |
452 | KAction *mActionConfigResources; | 452 | KAction *mActionConfigResources; |
453 | KAction *mActionConfigKAddressbook; | 453 | KAction *mActionConfigKAddressbook; |
454 | KAction *mActionConfigShortcuts; | 454 | KAction *mActionConfigShortcuts; |
455 | KAction *mActionConfigureToolbars; | 455 | KAction *mActionConfigureToolbars; |
456 | KAction *mActionKeyBindings; | 456 | KAction *mActionKeyBindings; |
457 | KToggleAction *mActionJumpBar; | 457 | KToggleAction *mActionJumpBar; |
458 | KToggleAction *mActionDetails; | 458 | KToggleAction *mActionDetails; |
459 | KAction *mActionWhoAmI; | 459 | KAction *mActionWhoAmI; |
460 | KAction *mActionCategories; | 460 | KAction *mActionCategories; |
461 | KAction *mActionEditCategories; | 461 | KAction *mActionEditCategories; |
462 | KAction *mActionManageCategories; | 462 | KAction *mActionManageCategories; |
463 | KAction *mActionAboutKAddressbook; | 463 | KAction *mActionAboutKAddressbook; |
464 | KAction *mActionLicence; | 464 | KAction *mActionLicence; |
465 | KAction *mActionFaq; | 465 | KAction *mActionFaq; |
466 | KAction *mActionWN; | 466 | KAction *mActionWN; |
467 | KAction *mActionSyncHowto; | 467 | KAction *mActionSyncHowto; |
468 | KAction *mActionKdeSyncHowto; | 468 | KAction *mActionKdeSyncHowto; |
469 | KAction *mActionMultiSyncHowto; | 469 | KAction *mActionMultiSyncHowto; |
470 | 470 | ||
471 | KAction *mActionDeleteView; | 471 | KAction *mActionDeleteView; |
472 | 472 | ||
473 | QPopupMenu *viewMenu; | 473 | QPopupMenu *viewMenu; |
474 | QPopupMenu *filterMenu; | 474 | QPopupMenu *filterMenu; |
475 | QPopupMenu *settingsMenu; | 475 | QPopupMenu *settingsMenu; |
476 | QPopupMenu *changeMenu; | 476 | QPopupMenu *changeMenu; |
477 | QPopupMenu *beamMenu; | 477 | QPopupMenu *beamMenu; |
478 | //US QAction *mActionSave; | 478 | //US QAction *mActionSave; |
479 | QPopupMenu *ImportMenu; | 479 | QPopupMenu *ImportMenu; |
480 | QPopupMenu *ExportMenu; | 480 | QPopupMenu *ExportMenu; |
481 | //LR additional methods | 481 | //LR additional methods |
482 | KAction *mActionRemoveVoice; | 482 | KAction *mActionRemoveVoice; |
483 | KAction *mActionSetFormattedName; | 483 | KAction *mActionSetFormattedName; |
484 | KAction * mActionImportOL; | 484 | KAction * mActionImportOL; |
485 | 485 | ||
486 | #ifndef KAB_EMBEDDED | 486 | #ifndef KAB_EMBEDDED |
487 | KAddressBookService *mAddressBookService; | 487 | KAddressBookService *mAddressBookService; |
488 | #endif //KAB_EMBEDDED | 488 | #endif //KAB_EMBEDDED |
489 | 489 | ||
490 | class KABCorePrivate; | 490 | class KABCorePrivate; |
491 | KABCorePrivate *d; | 491 | KABCorePrivate *d; |
492 | //US bool mBlockSaveFlag; | 492 | //US bool mBlockSaveFlag; |
493 | 493 | ||
494 | #ifdef KAB_EMBEDDED | 494 | #ifdef KAB_EMBEDDED |
495 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 495 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
496 | #endif //KAB_EMBEDDED | 496 | #endif //KAB_EMBEDDED |
497 | 497 | ||
498 | //this are the overwritten callbackmethods from the syncinterface | 498 | //this are the overwritten callbackmethods from the syncinterface |
499 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 499 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
500 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 500 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
501 | virtual void removeSyncInfo( QString syncProfile); | 501 | virtual void removeSyncInfo( QString syncProfile); |
502 | bool syncPhone(); | 502 | bool syncPhone(); |
503 | void message( QString m ); | 503 | void message( QString m , bool startTimer = true); |
504 | 504 | ||
505 | // LR ******************************* | 505 | // LR ******************************* |
506 | // sync stuff! | 506 | // sync stuff! |
507 | QString sentSyncFile(); | 507 | QString sentSyncFile(); |
508 | QPopupMenu *syncMenu; | 508 | QPopupMenu *syncMenu; |
509 | KSyncManager* syncManager; | 509 | KSyncManager* syncManager; |
510 | int mGlobalSyncMode; | 510 | int mGlobalSyncMode; |
511 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 511 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
512 | KABC::Addressee getLastSyncAddressee(); | 512 | KABC::Addressee getLastSyncAddressee(); |
513 | QDateTime mLastAddressbookSync; | 513 | QDateTime mLastAddressbookSync; |
514 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 514 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
515 | // ********************* | 515 | // ********************* |
516 | 516 | ||
517 | }; | 517 | }; |
518 | 518 | ||
519 | #endif | 519 | #endif |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 6c1f444..f488a07 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -805,394 +805,395 @@ bool KSyncManager::edit_sync_options() | |||
805 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 805 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
806 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 806 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
807 | QVBoxLayout lay ( &dia ); | 807 | QVBoxLayout lay ( &dia ); |
808 | lay.setSpacing( 2 ); | 808 | lay.setSpacing( 2 ); |
809 | lay.setMargin( 3 ); | 809 | lay.setMargin( 3 ); |
810 | lay.addWidget(&gr); | 810 | lay.addWidget(&gr); |
811 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 811 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
812 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 812 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
813 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 813 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
814 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 814 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
815 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 815 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
816 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 816 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
817 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 817 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
818 | QPushButton pb ( "OK", &dia); | 818 | QPushButton pb ( "OK", &dia); |
819 | lay.addWidget( &pb ); | 819 | lay.addWidget( &pb ); |
820 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 820 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
821 | switch ( mSyncAlgoPrefs ) { | 821 | switch ( mSyncAlgoPrefs ) { |
822 | case 0: | 822 | case 0: |
823 | loc.setChecked( true); | 823 | loc.setChecked( true); |
824 | break; | 824 | break; |
825 | case 1: | 825 | case 1: |
826 | rem.setChecked( true ); | 826 | rem.setChecked( true ); |
827 | break; | 827 | break; |
828 | case 2: | 828 | case 2: |
829 | newest.setChecked( true); | 829 | newest.setChecked( true); |
830 | break; | 830 | break; |
831 | case 3: | 831 | case 3: |
832 | ask.setChecked( true); | 832 | ask.setChecked( true); |
833 | break; | 833 | break; |
834 | case 4: | 834 | case 4: |
835 | f_loc.setChecked( true); | 835 | f_loc.setChecked( true); |
836 | break; | 836 | break; |
837 | case 5: | 837 | case 5: |
838 | f_rem.setChecked( true); | 838 | f_rem.setChecked( true); |
839 | break; | 839 | break; |
840 | case 6: | 840 | case 6: |
841 | // both.setChecked( true); | 841 | // both.setChecked( true); |
842 | break; | 842 | break; |
843 | default: | 843 | default: |
844 | break; | 844 | break; |
845 | } | 845 | } |
846 | if ( dia.exec() ) { | 846 | if ( dia.exec() ) { |
847 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 847 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
848 | return true; | 848 | return true; |
849 | } | 849 | } |
850 | return false; | 850 | return false; |
851 | } | 851 | } |
852 | 852 | ||
853 | QString KSyncManager::getPassword( ) | 853 | QString KSyncManager::getPassword( ) |
854 | { | 854 | { |
855 | QString retfile = ""; | 855 | QString retfile = ""; |
856 | QDialog dia ( mParent, "input-dialog", true ); | 856 | QDialog dia ( mParent, "input-dialog", true ); |
857 | QLineEdit lab ( &dia ); | 857 | QLineEdit lab ( &dia ); |
858 | lab.setEchoMode( QLineEdit::Password ); | 858 | lab.setEchoMode( QLineEdit::Password ); |
859 | QVBoxLayout lay( &dia ); | 859 | QVBoxLayout lay( &dia ); |
860 | lay.setMargin(7); | 860 | lay.setMargin(7); |
861 | lay.setSpacing(7); | 861 | lay.setSpacing(7); |
862 | lay.addWidget( &lab); | 862 | lay.addWidget( &lab); |
863 | dia.setFixedSize( 230,50 ); | 863 | dia.setFixedSize( 230,50 ); |
864 | dia.setCaption( i18n("Enter password") ); | 864 | dia.setCaption( i18n("Enter password") ); |
865 | QPushButton pb ( "OK", &dia); | 865 | QPushButton pb ( "OK", &dia); |
866 | lay.addWidget( &pb ); | 866 | lay.addWidget( &pb ); |
867 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 867 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
868 | dia.show(); | 868 | dia.show(); |
869 | int res = dia.exec(); | 869 | int res = dia.exec(); |
870 | if ( res ) | 870 | if ( res ) |
871 | retfile = lab.text(); | 871 | retfile = lab.text(); |
872 | dia.hide(); | 872 | dia.hide(); |
873 | qApp->processEvents(); | 873 | qApp->processEvents(); |
874 | return retfile; | 874 | return retfile; |
875 | 875 | ||
876 | } | 876 | } |
877 | 877 | ||
878 | 878 | ||
879 | void KSyncManager::confSync() | 879 | void KSyncManager::confSync() |
880 | { | 880 | { |
881 | static KSyncPrefsDialog* sp = 0; | 881 | static KSyncPrefsDialog* sp = 0; |
882 | if ( ! sp ) { | 882 | if ( ! sp ) { |
883 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 883 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
884 | } | 884 | } |
885 | sp->usrReadConfig(); | 885 | sp->usrReadConfig(); |
886 | #ifndef DESKTOP_VERSION | 886 | #ifndef DESKTOP_VERSION |
887 | sp->showMaximized(); | 887 | sp->showMaximized(); |
888 | #else | 888 | #else |
889 | sp->show(); | 889 | sp->show(); |
890 | #endif | 890 | #endif |
891 | sp->exec(); | 891 | sp->exec(); |
892 | QStringList oldSyncProfileNames = mSyncProfileNames; | 892 | QStringList oldSyncProfileNames = mSyncProfileNames; |
893 | mSyncProfileNames = sp->getSyncProfileNames(); | 893 | mSyncProfileNames = sp->getSyncProfileNames(); |
894 | mLocalMachineName = sp->getLocalMachineName (); | 894 | mLocalMachineName = sp->getLocalMachineName (); |
895 | int ii; | 895 | int ii; |
896 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 896 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
897 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 897 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
898 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 898 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
899 | } | 899 | } |
900 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 900 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
901 | } | 901 | } |
902 | void KSyncManager::syncKDE() | 902 | void KSyncManager::syncKDE() |
903 | { | 903 | { |
904 | mSyncWithDesktop = true; | 904 | mSyncWithDesktop = true; |
905 | emit save(); | 905 | emit save(); |
906 | switch(mTargetApp) | 906 | switch(mTargetApp) |
907 | { | 907 | { |
908 | case (KAPI): | 908 | case (KAPI): |
909 | { | 909 | { |
910 | #ifdef DESKTOP_VERSION | 910 | #ifdef DESKTOP_VERSION |
911 | QString command = qApp->applicationDirPath () + "/kdeabdump"; | 911 | QString command = qApp->applicationDirPath () + "/kdeabdump"; |
912 | #else | 912 | #else |
913 | QString command = "kdeabdump"; | 913 | QString command = "kdeabdump"; |
914 | #endif | 914 | #endif |
915 | if ( ! QFile::exists ( command ) ) | 915 | if ( ! QFile::exists ( command ) ) |
916 | command = "kdeabdump"; | 916 | command = "kdeabdump"; |
917 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | 917 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; |
918 | system ( command.latin1()); | 918 | system ( command.latin1()); |
919 | if ( syncWithFile( fileName,true ) ) { | 919 | if ( syncWithFile( fileName,true ) ) { |
920 | if ( mWriteBackFile ) { | 920 | if ( mWriteBackFile ) { |
921 | command += " --read"; | 921 | command += " --read"; |
922 | system ( command.latin1()); | 922 | system ( command.latin1()); |
923 | } | 923 | } |
924 | } | 924 | } |
925 | 925 | ||
926 | } | 926 | } |
927 | break; | 927 | break; |
928 | case (KOPI): | 928 | case (KOPI): |
929 | { | 929 | { |
930 | #ifdef DESKTOP_VERSION | 930 | #ifdef DESKTOP_VERSION |
931 | QString command = qApp->applicationDirPath () + "/kdecaldump"; | 931 | QString command = qApp->applicationDirPath () + "/kdecaldump"; |
932 | #else | 932 | #else |
933 | QString command = "kdecaldump"; | 933 | QString command = "kdecaldump"; |
934 | #endif | 934 | #endif |
935 | if ( ! QFile::exists ( command ) ) | 935 | if ( ! QFile::exists ( command ) ) |
936 | command = "kdecaldump"; | 936 | command = "kdecaldump"; |
937 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 937 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
938 | system ( command.latin1()); | 938 | system ( command.latin1()); |
939 | if ( syncWithFile( fileName,true ) ) { | 939 | if ( syncWithFile( fileName,true ) ) { |
940 | if ( mWriteBackFile ) { | 940 | if ( mWriteBackFile ) { |
941 | command += " --read"; | 941 | command += " --read"; |
942 | system ( command.latin1()); | 942 | system ( command.latin1()); |
943 | } | 943 | } |
944 | } | 944 | } |
945 | 945 | ||
946 | } | 946 | } |
947 | break; | 947 | break; |
948 | case (PWMPI): | 948 | case (PWMPI): |
949 | 949 | ||
950 | break; | 950 | break; |
951 | default: | 951 | default: |
952 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 952 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
953 | break; | 953 | break; |
954 | 954 | ||
955 | } | 955 | } |
956 | } | 956 | } |
957 | 957 | ||
958 | void KSyncManager::syncSharp() | 958 | void KSyncManager::syncSharp() |
959 | { | 959 | { |
960 | 960 | ||
961 | if ( ! syncExternalApplication("sharp") ) | 961 | if ( ! syncExternalApplication("sharp") ) |
962 | qDebug("ERROR sync sharp "); | 962 | qDebug("ERROR sync sharp "); |
963 | } | 963 | } |
964 | 964 | ||
965 | bool KSyncManager::syncExternalApplication(QString resource) | 965 | bool KSyncManager::syncExternalApplication(QString resource) |
966 | { | 966 | { |
967 | 967 | ||
968 | emit save(); | 968 | emit save(); |
969 | 969 | ||
970 | if ( mAskForPreferences ) | 970 | if ( mAskForPreferences ) |
971 | if ( !edit_sync_options()) { | 971 | if ( !edit_sync_options()) { |
972 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 972 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
973 | return false; | 973 | return false; |
974 | } | 974 | } |
975 | 975 | ||
976 | qDebug("Sync extern %s", resource.latin1()); | 976 | qDebug("Sync extern %s", resource.latin1()); |
977 | 977 | ||
978 | bool syncOK = mImplementation->syncExternal(this, resource); | 978 | bool syncOK = mImplementation->syncExternal(this, resource); |
979 | 979 | ||
980 | return syncOK; | 980 | return syncOK; |
981 | 981 | ||
982 | } | 982 | } |
983 | 983 | ||
984 | void KSyncManager::syncPhone() | 984 | void KSyncManager::syncPhone() |
985 | { | 985 | { |
986 | 986 | ||
987 | syncExternalApplication("phone"); | 987 | syncExternalApplication("phone"); |
988 | 988 | ||
989 | } | 989 | } |
990 | 990 | ||
991 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 991 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
992 | { | 992 | { |
993 | if (!bar->isVisible()) | 993 | if (!bar->isVisible()) |
994 | { | 994 | { |
995 | bar->setCaption (caption); | 995 | bar->setCaption (caption); |
996 | bar->setTotalSteps ( total ) ; | 996 | bar->setTotalSteps ( total ) ; |
997 | |||
998 | bar->show(); | 997 | bar->show(); |
999 | } | 998 | } |
1000 | 999 | bar->raise(); | |
1001 | bar->setProgress( percentage ); | 1000 | bar->setProgress( percentage ); |
1001 | qApp->processEvents(); | ||
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | void KSyncManager::hideProgressBar() | 1004 | void KSyncManager::hideProgressBar() |
1005 | { | 1005 | { |
1006 | bar->hide(); | 1006 | bar->hide(); |
1007 | qApp->processEvents(); | ||
1007 | } | 1008 | } |
1008 | 1009 | ||
1009 | bool KSyncManager::isProgressBarCanceled() | 1010 | bool KSyncManager::isProgressBarCanceled() |
1010 | { | 1011 | { |
1011 | return !bar->isVisible(); | 1012 | return !bar->isVisible(); |
1012 | } | 1013 | } |
1013 | 1014 | ||
1014 | QString KSyncManager::syncFileName() | 1015 | QString KSyncManager::syncFileName() |
1015 | { | 1016 | { |
1016 | 1017 | ||
1017 | QString fn = "tempfile"; | 1018 | QString fn = "tempfile"; |
1018 | switch(mTargetApp) | 1019 | switch(mTargetApp) |
1019 | { | 1020 | { |
1020 | case (KAPI): | 1021 | case (KAPI): |
1021 | fn = "tempsyncab.vcf"; | 1022 | fn = "tempsyncab.vcf"; |
1022 | break; | 1023 | break; |
1023 | case (KOPI): | 1024 | case (KOPI): |
1024 | fn = "tempsynccal.ics"; | 1025 | fn = "tempsynccal.ics"; |
1025 | break; | 1026 | break; |
1026 | case (PWMPI): | 1027 | case (PWMPI): |
1027 | fn = "tempsyncpw.pwm"; | 1028 | fn = "tempsyncpw.pwm"; |
1028 | break; | 1029 | break; |
1029 | default: | 1030 | default: |
1030 | break; | 1031 | break; |
1031 | } | 1032 | } |
1032 | #ifdef _WIN32_ | 1033 | #ifdef _WIN32_ |
1033 | return locateLocal( "tmp", fn ); | 1034 | return locateLocal( "tmp", fn ); |
1034 | #else | 1035 | #else |
1035 | return (QString( "/tmp/" )+ fn ); | 1036 | return (QString( "/tmp/" )+ fn ); |
1036 | #endif | 1037 | #endif |
1037 | } | 1038 | } |
1038 | 1039 | ||
1039 | void KSyncManager::syncPi() | 1040 | void KSyncManager::syncPi() |
1040 | { | 1041 | { |
1041 | mIsKapiFile = true; | 1042 | mIsKapiFile = true; |
1042 | mPisyncFinished = false; | 1043 | mPisyncFinished = false; |
1043 | qApp->processEvents(); | 1044 | qApp->processEvents(); |
1044 | if ( mAskForPreferences ) | 1045 | if ( mAskForPreferences ) |
1045 | if ( !edit_pisync_options()) { | 1046 | if ( !edit_pisync_options()) { |
1046 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1047 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1047 | return; | 1048 | return; |
1048 | } | 1049 | } |
1049 | bool ok; | 1050 | bool ok; |
1050 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 1051 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
1051 | if ( ! ok ) { | 1052 | if ( ! ok ) { |
1052 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1053 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1053 | return; | 1054 | return; |
1054 | } | 1055 | } |
1055 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 1056 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
1056 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1057 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1057 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); | 1058 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
1058 | commandSocket->readFile( syncFileName() ); | 1059 | commandSocket->readFile( syncFileName() ); |
1059 | } | 1060 | } |
1060 | 1061 | ||
1061 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 1062 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
1062 | { | 1063 | { |
1063 | //enum { success, errorW, errorR, quiet }; | 1064 | //enum { success, errorW, errorR, quiet }; |
1064 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { | 1065 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { |
1065 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 1066 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
1066 | delete s; | 1067 | delete s; |
1067 | if ( state == KCommandSocket::errorR ) { | 1068 | if ( state == KCommandSocket::errorR ) { |
1068 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 1069 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
1069 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1070 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1070 | commandSocket->sendStop(); | 1071 | commandSocket->sendStop(); |
1071 | } | 1072 | } |
1072 | mPisyncFinished = true; | 1073 | mPisyncFinished = true; |
1073 | return; | 1074 | return; |
1074 | 1075 | ||
1075 | } else if ( state == KCommandSocket::errorW ) { | 1076 | } else if ( state == KCommandSocket::errorW ) { |
1076 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 1077 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
1077 | mPisyncFinished = true; | 1078 | mPisyncFinished = true; |
1078 | 1079 | ||
1079 | } else if ( state == KCommandSocket::successR ) { | 1080 | } else if ( state == KCommandSocket::successR ) { |
1080 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 1081 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
1081 | 1082 | ||
1082 | } else if ( state == KCommandSocket::successW ) { | 1083 | } else if ( state == KCommandSocket::successW ) { |
1083 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1084 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1084 | mPisyncFinished = true; | 1085 | mPisyncFinished = true; |
1085 | } | 1086 | } |
1086 | 1087 | ||
1087 | delete s; | 1088 | delete s; |
1088 | } | 1089 | } |
1089 | 1090 | ||
1090 | void KSyncManager::readFileFromSocket() | 1091 | void KSyncManager::readFileFromSocket() |
1091 | { | 1092 | { |
1092 | QString fileName = syncFileName(); | 1093 | QString fileName = syncFileName(); |
1093 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 1094 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
1094 | if ( ! syncWithFile( fileName , true ) ) { | 1095 | if ( ! syncWithFile( fileName , true ) ) { |
1095 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 1096 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
1096 | mPisyncFinished = true; | 1097 | mPisyncFinished = true; |
1097 | return; | 1098 | return; |
1098 | } | 1099 | } |
1099 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 1100 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
1100 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1101 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1101 | if ( mWriteBackFile ) | 1102 | if ( mWriteBackFile ) |
1102 | commandSocket->writeFile( fileName ); | 1103 | commandSocket->writeFile( fileName ); |
1103 | else { | 1104 | else { |
1104 | commandSocket->sendStop(); | 1105 | commandSocket->sendStop(); |
1105 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1106 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1106 | mPisyncFinished = true; | 1107 | mPisyncFinished = true; |
1107 | } | 1108 | } |
1108 | } | 1109 | } |
1109 | 1110 | ||
1110 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 1111 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
1111 | { | 1112 | { |
1112 | mPassWord = pw; | 1113 | mPassWord = pw; |
1113 | mSocket = 0; | 1114 | mSocket = 0; |
1114 | mSyncActionDialog = 0; | 1115 | mSyncActionDialog = 0; |
1115 | blockRC = false; | 1116 | blockRC = false; |
1116 | }; | 1117 | }; |
1117 | 1118 | ||
1118 | void KServerSocket::newConnection ( int socket ) | 1119 | void KServerSocket::newConnection ( int socket ) |
1119 | { | 1120 | { |
1120 | // qDebug("KServerSocket:New connection %d ", socket); | 1121 | // qDebug("KServerSocket:New connection %d ", socket); |
1121 | if ( mSocket ) { | 1122 | if ( mSocket ) { |
1122 | qDebug("KServerSocket::newConnection Socket deleted! "); | 1123 | qDebug("KServerSocket::newConnection Socket deleted! "); |
1123 | delete mSocket; | 1124 | delete mSocket; |
1124 | mSocket = 0; | 1125 | mSocket = 0; |
1125 | } | 1126 | } |
1126 | mSocket = new QSocket( this ); | 1127 | mSocket = new QSocket( this ); |
1127 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1128 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1128 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1129 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1129 | mSocket->setSocket( socket ); | 1130 | mSocket->setSocket( socket ); |
1130 | } | 1131 | } |
1131 | 1132 | ||
1132 | void KServerSocket::discardClient() | 1133 | void KServerSocket::discardClient() |
1133 | { | 1134 | { |
1134 | //qDebug(" KServerSocket::discardClient()"); | 1135 | //qDebug(" KServerSocket::discardClient()"); |
1135 | if ( mSocket ) { | 1136 | if ( mSocket ) { |
1136 | delete mSocket; | 1137 | delete mSocket; |
1137 | mSocket = 0; | 1138 | mSocket = 0; |
1138 | } | 1139 | } |
1139 | //emit endConnect(); | 1140 | //emit endConnect(); |
1140 | } | 1141 | } |
1141 | void KServerSocket::readClient() | 1142 | void KServerSocket::readClient() |
1142 | { | 1143 | { |
1143 | if ( blockRC ) | 1144 | if ( blockRC ) |
1144 | return; | 1145 | return; |
1145 | if ( mSocket == 0 ) { | 1146 | if ( mSocket == 0 ) { |
1146 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 1147 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); |
1147 | return; | 1148 | return; |
1148 | } | 1149 | } |
1149 | //qDebug("KServerSocket::readClient()"); | 1150 | //qDebug("KServerSocket::readClient()"); |
1150 | if ( mSocket->canReadLine() ) { | 1151 | if ( mSocket->canReadLine() ) { |
1151 | QString line = mSocket->readLine(); | 1152 | QString line = mSocket->readLine(); |
1152 | //qDebug("KServerSocket readline: %s ", line.latin1()); | 1153 | //qDebug("KServerSocket readline: %s ", line.latin1()); |
1153 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 1154 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
1154 | if ( tokens[0] == "GET" ) { | 1155 | if ( tokens[0] == "GET" ) { |
1155 | if ( tokens[1] == mPassWord ) { | 1156 | if ( tokens[1] == mPassWord ) { |
1156 | //emit sendFile( mSocket ); | 1157 | //emit sendFile( mSocket ); |
1157 | bool ok = false; | 1158 | bool ok = false; |
1158 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); | 1159 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); |
1159 | if ( ok ) { | 1160 | if ( ok ) { |
1160 | KSyncManager::mRequestedSyncEvent = dt; | 1161 | KSyncManager::mRequestedSyncEvent = dt; |
1161 | } | 1162 | } |
1162 | else | 1163 | else |
1163 | KSyncManager::mRequestedSyncEvent = QDateTime(); | 1164 | KSyncManager::mRequestedSyncEvent = QDateTime(); |
1164 | send_file(); | 1165 | send_file(); |
1165 | } | 1166 | } |
1166 | else { | 1167 | else { |
1167 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); | 1168 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); |
1168 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 1169 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
1169 | } | 1170 | } |
1170 | } | 1171 | } |
1171 | if ( tokens[0] == "PUT" ) { | 1172 | if ( tokens[0] == "PUT" ) { |
1172 | if ( tokens[1] == mPassWord ) { | 1173 | if ( tokens[1] == mPassWord ) { |
1173 | //emit getFile( mSocket ); | 1174 | //emit getFile( mSocket ); |
1174 | blockRC = true; | 1175 | blockRC = true; |
1175 | get_file(); | 1176 | get_file(); |
1176 | } | 1177 | } |
1177 | else { | 1178 | else { |
1178 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); | 1179 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); |
1179 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 1180 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
1180 | } | 1181 | } |
1181 | } | 1182 | } |
1182 | if ( tokens[0] == "STOP" ) { | 1183 | if ( tokens[0] == "STOP" ) { |
1183 | //emit endConnect(); | 1184 | //emit endConnect(); |
1184 | end_connect(); | 1185 | end_connect(); |
1185 | } | 1186 | } |
1186 | } | 1187 | } |
1187 | } | 1188 | } |
1188 | void KServerSocket::end_connect() | 1189 | void KServerSocket::end_connect() |
1189 | { | 1190 | { |
1190 | delete mSyncActionDialog; | 1191 | delete mSyncActionDialog; |
1191 | mSyncActionDialog = 0; | 1192 | mSyncActionDialog = 0; |
1192 | } | 1193 | } |
1193 | void KServerSocket::send_file() | 1194 | void KServerSocket::send_file() |
1194 | { | 1195 | { |
1195 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 1196 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
1196 | if ( mSyncActionDialog ) | 1197 | if ( mSyncActionDialog ) |
1197 | delete mSyncActionDialog; | 1198 | delete mSyncActionDialog; |
1198 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 1199 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp index 2101bbb..3db58ec 100644 --- a/libkdepim/ksyncprefsdialog.cpp +++ b/libkdepim/ksyncprefsdialog.cpp | |||
@@ -1,380 +1,380 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qgroupbox.h> | 26 | #include <qgroupbox.h> |
27 | #include <qbuttongroup.h> | 27 | #include <qbuttongroup.h> |
28 | #include <qlineedit.h> | 28 | #include <qlineedit.h> |
29 | #include <qfont.h> | 29 | #include <qfont.h> |
30 | #include <qslider.h> | 30 | #include <qslider.h> |
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qvbox.h> | 35 | #include <qvbox.h> |
36 | #include <qhbox.h> | 36 | #include <qhbox.h> |
37 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
38 | #include <qdatetime.h> | 38 | #include <qdatetime.h> |
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qradiobutton.h> | 40 | #include <qradiobutton.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qstrlist.h> | 42 | #include <qstrlist.h> |
43 | #include <qapplication.h> | 43 | #include <qapplication.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qscrollview.h> | 45 | #include <qscrollview.h> |
46 | #include <qvgroupbox.h> | 46 | #include <qvgroupbox.h> |
47 | #include <qhgroupbox.h> | 47 | #include <qhgroupbox.h> |
48 | 48 | ||
49 | #include <kcolorbutton.h> | 49 | #include <kcolorbutton.h> |
50 | #include <kdebug.h> | 50 | #include <kdebug.h> |
51 | #include <klocale.h> | 51 | #include <klocale.h> |
52 | #include <kglobal.h> | 52 | #include <kglobal.h> |
53 | #include <kfontdialog.h> | 53 | #include <kfontdialog.h> |
54 | #include <kmessagebox.h> | 54 | #include <kmessagebox.h> |
55 | #include <kcolordialog.h> | 55 | #include <kcolordialog.h> |
56 | #include <kiconloader.h> | 56 | #include <kiconloader.h> |
57 | #include <kemailsettings.h> | 57 | #include <kemailsettings.h> |
58 | #include <kstandarddirs.h> | 58 | #include <kstandarddirs.h> |
59 | #include <kfiledialog.h> | 59 | #include <kfiledialog.h> |
60 | #include <kmessagebox.h> | 60 | #include <kmessagebox.h> |
61 | 61 | ||
62 | //#include <kurlrequester.h> | 62 | //#include <kurlrequester.h> |
63 | #include <klineedit.h> | 63 | #include <klineedit.h> |
64 | #include "ksyncprofile.h" | 64 | #include "ksyncprofile.h" |
65 | 65 | ||
66 | 66 | ||
67 | //#include "koprefs.h" | 67 | //#include "koprefs.h" |
68 | 68 | ||
69 | #include "ksyncprefsdialog.h" | 69 | #include "ksyncprefsdialog.h" |
70 | //#include "koglobals.h" | 70 | //#include "koglobals.h" |
71 | 71 | ||
72 | 72 | ||
73 | KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : | 73 | KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : |
74 | KDialog(parent,name,true) | 74 | KDialog(parent,name,true) |
75 | { | 75 | { |
76 | 76 | ||
77 | setCaption( i18n("Synchronization Preferences")); | 77 | setCaption( i18n("Synchronization Preferences")); |
78 | 78 | ||
79 | mSyncProfiles.setAutoDelete( true ); | 79 | mSyncProfiles.setAutoDelete( true ); |
80 | setupSyncAlgTab(); | 80 | setupSyncAlgTab(); |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | KSyncPrefsDialog::~KSyncPrefsDialog() | 84 | KSyncPrefsDialog::~KSyncPrefsDialog() |
85 | { | 85 | { |
86 | } | 86 | } |
87 | 87 | ||
88 | void KSyncPrefsDialog::setupSyncAlgTab() | 88 | void KSyncPrefsDialog::setupSyncAlgTab() |
89 | { | 89 | { |
90 | QLabel * lab; | 90 | QLabel * lab; |
91 | //QFrame *page = addPage(i18n("Sync Prefs"),0,0); | 91 | //QFrame *page = addPage(i18n("Sync Prefs"),0,0); |
92 | QVBox * mainbox = new QVBox( this ); | 92 | QVBox * mainbox = new QVBox( this ); |
93 | QScrollView* sv = new QScrollView( mainbox ); | 93 | QScrollView* sv = new QScrollView( mainbox ); |
94 | QHBoxLayout * lay = new QHBoxLayout( this ); | 94 | QHBoxLayout * lay = new QHBoxLayout( this ); |
95 | lay->addWidget( mainbox ); | 95 | lay->addWidget( mainbox ); |
96 | QHBox * b_box = new QHBox( mainbox ); | 96 | QHBox * b_box = new QHBox( mainbox ); |
97 | 97 | ||
98 | QPushButton* button = new QPushButton( i18n("Ok"), b_box ); | 98 | QPushButton* button = new QPushButton( i18n("Ok"), b_box ); |
99 | connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); | 99 | connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); |
100 | button = new QPushButton( i18n("Cancel"), b_box ); | 100 | button = new QPushButton( i18n("Cancel"), b_box ); |
101 | connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); | 101 | connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); |
102 | //QBoxLayout * sl = new QVBoxLayout(this ); | 102 | //QBoxLayout * sl = new QVBoxLayout(this ); |
103 | //sl->addWidget ( sv ); | 103 | //sl->addWidget ( sv ); |
104 | sv->setResizePolicy ( QScrollView::AutoOneFit ); | 104 | sv->setResizePolicy ( QScrollView::AutoOneFit ); |
105 | QFrame *topFrame = new QFrame ( sv ); | 105 | QFrame *topFrame = new QFrame ( sv ); |
106 | sv->addChild( topFrame ); | 106 | sv->addChild( topFrame ); |
107 | mSetupSyncAlgTab = topFrame; | 107 | mSetupSyncAlgTab = topFrame; |
108 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 108 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
109 | topLayout->setSpacing(spacingHint()); | 109 | topLayout->setSpacing(spacingHint()); |
110 | topLayout->setMargin(marginHint()); | 110 | topLayout->setMargin(marginHint()); |
111 | 111 | ||
112 | //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); | 112 | //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); |
113 | int iii = 0; | 113 | int iii = 0; |
114 | //topLayout->addMultiCellWidget(lab , iii,iii,0,1); | 114 | //topLayout->addMultiCellWidget(lab , iii,iii,0,1); |
115 | //++iii; | 115 | //++iii; |
116 | 116 | ||
117 | mMyMachineName = new QLineEdit(topFrame); | 117 | mMyMachineName = new QLineEdit(topFrame); |
118 | lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); | 118 | lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); |
119 | topLayout->addWidget(lab ,iii,0); | 119 | topLayout->addWidget(lab ,iii,0); |
120 | topLayout->addWidget(mMyMachineName,iii,1); | 120 | topLayout->addWidget(mMyMachineName,iii,1); |
121 | ++iii; | 121 | ++iii; |
122 | 122 | ||
123 | QHBox* buttonbox = new QHBox( topFrame); | 123 | QHBox* buttonbox = new QHBox( topFrame); |
124 | topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); | 124 | topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); |
125 | ++iii; | 125 | ++iii; |
126 | button = new QPushButton( i18n("New profile"), buttonbox ); | 126 | button = new QPushButton( i18n("New profile"), buttonbox ); |
127 | connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); | 127 | connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); |
128 | 128 | ||
129 | button = new QPushButton( i18n("Clone profile"), buttonbox ); | 129 | button = new QPushButton( i18n("Clone profile"), buttonbox ); |
130 | connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); | 130 | connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); |
131 | 131 | ||
132 | button = new QPushButton( i18n("Delete profile"), buttonbox ); | 132 | button = new QPushButton( i18n("Delete profile"), buttonbox ); |
133 | connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); | 133 | connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); |
134 | 134 | ||
135 | mProfileBox = new QComboBox(topFrame); | 135 | mProfileBox = new QComboBox(topFrame); |
136 | mProfileBox->setEditable ( true ); | 136 | mProfileBox->setEditable ( true ); |
137 | mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); | 137 | mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); |
138 | connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); | 138 | connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); |
139 | connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); | 139 | connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); |
140 | 140 | ||
141 | lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); | 141 | lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); |
142 | topLayout->addWidget(lab ,iii,0); | 142 | topLayout->addWidget(lab ,iii,0); |
143 | topLayout->addWidget(mProfileBox, iii,1); | 143 | topLayout->addWidget(mProfileBox, iii,1); |
144 | ++iii; | 144 | ++iii; |
145 | 145 | ||
146 | 146 | ||
147 | 147 | ||
148 | QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame); | 148 | QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame); |
149 | new QLabel( i18n("Include in multiple "), iims ); | 149 | new QLabel( i18n("Include in multiple "), iims ); |
150 | mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); | 150 | mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); |
151 | mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); | 151 | mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); |
152 | mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); | 152 | mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); |
153 | new QLabel( i18n(" sync"), iims ); | 153 | new QLabel( i18n(" sync"), iims ); |
154 | topLayout->addMultiCellWidget(iims, iii,iii,0,1); | 154 | topLayout->addMultiCellWidget(iims, iii,iii,0,1); |
155 | ++iii; | 155 | ++iii; |
156 | QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame); | 156 | QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame); |
157 | topLayout->addMultiCellWidget(gb0, iii,iii,0,1); | 157 | topLayout->addMultiCellWidget(gb0, iii,iii,0,1); |
158 | ++iii; | 158 | ++iii; |
159 | QButtonGroup* gr; | 159 | QButtonGroup* gr; |
160 | { | 160 | { |
161 | QVGroupBox* topFrame = gb0; | 161 | QVGroupBox* topFrame = gb0; |
162 | 162 | ||
163 | 163 | ||
164 | 164 | ||
165 | mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); | 165 | mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); |
166 | //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); | 166 | //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); |
167 | //++iii; | 167 | //++iii; |
168 | gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); | 168 | gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); |
169 | //topLayout->addMultiCellWidget(gr, iii,iii,0,1); | 169 | //topLayout->addMultiCellWidget(gr, iii,iii,0,1); |
170 | //++iii; | 170 | //++iii; |
171 | loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); | 171 | loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); |
172 | rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); | 172 | rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); |
173 | newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); | 173 | newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); |
174 | ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); | 174 | ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); |
175 | f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); | 175 | f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); |
176 | f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); | 176 | f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); |
177 | // both = new QRadioButton ( i18n("Take both on conflict"), gr ); | 177 | // both = new QRadioButton ( i18n("Take both on conflict"), gr ); |
178 | 178 | ||
179 | mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); | 179 | mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); |
180 | //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); | 180 | //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); |
181 | //++iii; | 181 | //++iii; |
182 | 182 | ||
183 | QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame); | 183 | QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame); |
184 | QVBox * fibo2 = new QVBox ( gb5 ); | 184 | QVBox * fibo2 = new QVBox ( gb5 ); |
185 | new QLabel ( i18n("Incoming calendar filter:"), fibo2 ); | 185 | new QLabel ( i18n("Incoming calendar filter:"), fibo2 ); |
186 | mFilterInCal = new QComboBox( fibo2 ); | 186 | mFilterInCal = new QComboBox( fibo2 ); |
187 | fibo2 = new QVBox ( gb5 ); | 187 | fibo2 = new QVBox ( gb5 ); |
188 | new QLabel ( i18n("Incoming adressbook filter:"), fibo2 ); | 188 | new QLabel ( i18n("Incoming addressbook filter:"), fibo2 ); |
189 | mFilterInAB = new QComboBox( fibo2 ); | 189 | mFilterInAB = new QComboBox( fibo2 ); |
190 | 190 | ||
191 | mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); | 191 | mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); |
192 | // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); | 192 | // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); |
193 | // ++iii; | 193 | // ++iii; |
194 | 194 | ||
195 | QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame); | 195 | QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame); |
196 | //topLayout->addMultiCellWidget(gb2, iii,iii,0,1); | 196 | //topLayout->addMultiCellWidget(gb2, iii,iii,0,1); |
197 | //++iii; | 197 | //++iii; |
198 | { | 198 | { |
199 | QVGroupBox*topFrame = gb2; | 199 | QVGroupBox*topFrame = gb2; |
200 | mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame ); | 200 | mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame ); |
201 | QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame); | 201 | QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame); |
202 | QVBox * fibo = new QVBox ( gb4 ); | 202 | QVBox * fibo = new QVBox ( gb4 ); |
203 | new QLabel ( i18n("Outgoing calendar filter:"), fibo ); | 203 | new QLabel ( i18n("Outgoing calendar filter:"), fibo ); |
204 | mFilterOutCal = new QComboBox( fibo ); | 204 | mFilterOutCal = new QComboBox( fibo ); |
205 | fibo = new QVBox ( gb4 ); | 205 | fibo = new QVBox ( gb4 ); |
206 | new QLabel ( i18n("Outgoing addressbook filter:"), fibo ); | 206 | new QLabel ( i18n("Outgoing addressbook filter:"), fibo ); |
207 | mFilterOutAB = new QComboBox( fibo ); | 207 | mFilterOutAB = new QComboBox( fibo ); |
208 | //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); | 208 | //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); |
209 | //++iii; | 209 | //++iii; |
210 | mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame ); | 210 | mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame ); |
211 | //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); | 211 | //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); |
212 | //++iii; | 212 | //++iii; |
213 | QHGroupBox* gb3 = new QHGroupBox( i18n("Time period"), topFrame); | 213 | QHGroupBox* gb3 = new QHGroupBox( i18n("Time period"), topFrame); |
214 | connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) ); | 214 | connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) ); |
215 | new QLabel( i18n("From ") , gb3 ); | 215 | new QLabel( i18n("From ") , gb3 ); |
216 | mWriteBackPastWeeks= new QSpinBox(1,104, 1, gb3); | 216 | mWriteBackPastWeeks= new QSpinBox(1,104, 1, gb3); |
217 | new QLabel( i18n(" weeks in the past to ") , gb3 ); | 217 | new QLabel( i18n(" weeks in the past to ") , gb3 ); |
218 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, gb3); | 218 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, gb3); |
219 | new QLabel( i18n(" weeks in the future ") , gb3 ); | 219 | new QLabel( i18n(" weeks in the future ") , gb3 ); |
220 | //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); | 220 | //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); |
221 | //++iii; | 221 | //++iii; |
222 | gb3->setEnabled( false ); | 222 | gb3->setEnabled( false ); |
223 | connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) ); | 223 | connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) ); |
224 | } | 224 | } |
225 | connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) ); | 225 | connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) ); |
226 | 226 | ||
227 | } | 227 | } |
228 | proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); | 228 | proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); |
229 | gr = proGr; | 229 | gr = proGr; |
230 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); | 230 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); |
231 | ++iii; | 231 | ++iii; |
232 | mIsLocal = new QRadioButton ( i18n("Local file"), gr ); | 232 | mIsLocal = new QRadioButton ( i18n("Local file"), gr ); |
233 | mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr ); | 233 | mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr ); |
234 | connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 234 | connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
235 | mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); | 235 | mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); |
236 | connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 236 | connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
237 | mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); | 237 | mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); |
238 | connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 238 | connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
239 | 239 | ||
240 | QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame); | 240 | QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame); |
241 | topLayout->addMultiCellWidget(gb1, iii,iii,0,1); | 241 | topLayout->addMultiCellWidget(gb1, iii,iii,0,1); |
242 | ++iii; | 242 | ++iii; |
243 | 243 | ||
244 | // ****************************************** | 244 | // ****************************************** |
245 | // Profile kind specific settings | 245 | // Profile kind specific settings |
246 | { | 246 | { |
247 | // *** phone ******************************* | 247 | // *** phone ******************************* |
248 | QVGroupBox* topFrame = gb1; | 248 | QVGroupBox* topFrame = gb1; |
249 | phoneWidget = new QVBox( topFrame); | 249 | phoneWidget = new QVBox( topFrame); |
250 | //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); | 250 | //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); |
251 | //++iii; | 251 | //++iii; |
252 | mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); | 252 | mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); |
253 | QHBox* temphb = new QHBox( phoneWidget ); | 253 | QHBox* temphb = new QHBox( phoneWidget ); |
254 | new QLabel( i18n("I/O device: "), temphb ); | 254 | new QLabel( i18n("I/O device: "), temphb ); |
255 | mPhoneDevice = new QLineEdit( temphb); | 255 | mPhoneDevice = new QLineEdit( temphb); |
256 | button = new QPushButton( i18n("Help..."), temphb ); | 256 | button = new QPushButton( i18n("Help..."), temphb ); |
257 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); | 257 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); |
258 | 258 | ||
259 | 259 | ||
260 | temphb = new QHBox( phoneWidget ); | 260 | temphb = new QHBox( phoneWidget ); |
261 | new QLabel( i18n("Connection: "), temphb ); | 261 | new QLabel( i18n("Connection: "), temphb ); |
262 | mPhoneConnection = new QLineEdit( temphb); | 262 | mPhoneConnection = new QLineEdit( temphb); |
263 | button = new QPushButton( i18n("Help..."), temphb ); | 263 | button = new QPushButton( i18n("Help..."), temphb ); |
264 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); | 264 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); |
265 | 265 | ||
266 | 266 | ||
267 | temphb = new QHBox( phoneWidget ); | 267 | temphb = new QHBox( phoneWidget ); |
268 | new QLabel( i18n("Model(opt.): "), temphb ); | 268 | new QLabel( i18n("Model(opt.): "), temphb ); |
269 | mPhoneModel = new QLineEdit( temphb); | 269 | mPhoneModel = new QLineEdit( temphb); |
270 | button = new QPushButton( i18n("Help..."), temphb ); | 270 | button = new QPushButton( i18n("Help..."), temphb ); |
271 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); | 271 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); |
272 | 272 | ||
273 | // *** local******************************* | 273 | // *** local******************************* |
274 | localFileWidget = new QVBox( topFrame); | 274 | localFileWidget = new QVBox( topFrame); |
275 | //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); | 275 | //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); |
276 | //++iii; | 276 | //++iii; |
277 | temphb = new QHBox( localFileWidget ); | 277 | temphb = new QHBox( localFileWidget ); |
278 | 278 | ||
279 | lab = new QLabel( i18n("Local file Cal:"), temphb ); | 279 | lab = new QLabel( i18n("Local file Cal:"), temphb ); |
280 | lab = new QLabel( i18n("Local file ABook:"), temphb ); | 280 | lab = new QLabel( i18n("Local file ABook:"), temphb ); |
281 | lab = new QLabel( i18n("Local file PWMgr:"), temphb ); | 281 | lab = new QLabel( i18n("Local file PWMgr:"), temphb ); |
282 | temphb = new QHBox( localFileWidget ); | 282 | temphb = new QHBox( localFileWidget ); |
283 | button = new QPushButton( i18n("Choose..."), temphb ); | 283 | button = new QPushButton( i18n("Choose..."), temphb ); |
284 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); | 284 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); |
285 | button = new QPushButton( i18n("Choose..."), temphb ); | 285 | button = new QPushButton( i18n("Choose..."), temphb ); |
286 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); | 286 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); |
287 | button = new QPushButton( i18n("Choose..."), temphb ); | 287 | button = new QPushButton( i18n("Choose..."), temphb ); |
288 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); | 288 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); |
289 | temphb = new QHBox( localFileWidget ); | 289 | temphb = new QHBox( localFileWidget ); |
290 | 290 | ||
291 | mRemoteFile = new QLineEdit( temphb); | 291 | mRemoteFile = new QLineEdit( temphb); |
292 | mRemoteFileAB = new QLineEdit( temphb); | 292 | mRemoteFileAB = new QLineEdit( temphb); |
293 | mRemoteFilePWM = new QLineEdit( temphb); | 293 | mRemoteFilePWM = new QLineEdit( temphb); |
294 | mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget ); | 294 | mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget ); |
295 | 295 | ||
296 | 296 | ||
297 | // *** remote******************************* | 297 | // *** remote******************************* |
298 | remoteFileWidget = new QVBox( topFrame); | 298 | remoteFileWidget = new QVBox( topFrame); |
299 | //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); | 299 | //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); |
300 | //++iii; | 300 | //++iii; |
301 | temphb = new QHBox( remoteFileWidget ); | 301 | temphb = new QHBox( remoteFileWidget ); |
302 | new QLabel( i18n("Calendar:"), temphb); | 302 | new QLabel( i18n("Calendar:"), temphb); |
303 | new QLabel( i18n("AddressBook:"), temphb); | 303 | new QLabel( i18n("AddressBook:"), temphb); |
304 | new QLabel( i18n("PWManager:"), temphb); | 304 | new QLabel( i18n("PWManager:"), temphb); |
305 | 305 | ||
306 | lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); | 306 | lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); |
307 | temphb = new QHBox( remoteFileWidget ); | 307 | temphb = new QHBox( remoteFileWidget ); |
308 | mRemotePrecommand = new QLineEdit(temphb); | 308 | mRemotePrecommand = new QLineEdit(temphb); |
309 | mRemotePrecommandAB = new QLineEdit(temphb); | 309 | mRemotePrecommandAB = new QLineEdit(temphb); |
310 | mRemotePrecommandPWM = new QLineEdit(temphb); | 310 | mRemotePrecommandPWM = new QLineEdit(temphb); |
311 | 311 | ||
312 | lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); | 312 | lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); |
313 | temphb = new QHBox( remoteFileWidget ); | 313 | temphb = new QHBox( remoteFileWidget ); |
314 | mLocalTempFile = new QLineEdit(temphb); | 314 | mLocalTempFile = new QLineEdit(temphb); |
315 | mLocalTempFileAB = new QLineEdit(temphb); | 315 | mLocalTempFileAB = new QLineEdit(temphb); |
316 | mLocalTempFilePWM = new QLineEdit(temphb); | 316 | mLocalTempFilePWM = new QLineEdit(temphb); |
317 | 317 | ||
318 | lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); | 318 | lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); |
319 | temphb = new QHBox( remoteFileWidget ); | 319 | temphb = new QHBox( remoteFileWidget ); |
320 | mRemotePostcommand = new QLineEdit(temphb ); | 320 | mRemotePostcommand = new QLineEdit(temphb ); |
321 | mRemotePostcommandAB = new QLineEdit(temphb ); | 321 | mRemotePostcommandAB = new QLineEdit(temphb ); |
322 | mRemotePostcommandPWM = new QLineEdit(temphb ); | 322 | mRemotePostcommandPWM = new QLineEdit(temphb ); |
323 | mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget ); | 323 | mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget ); |
324 | lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); | 324 | lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); |
325 | temphb = new QHBox( remoteFileWidget ); | 325 | temphb = new QHBox( remoteFileWidget ); |
326 | button = new QPushButton( i18n("ssh/scp"), temphb ); | 326 | button = new QPushButton( i18n("ssh/scp"), temphb ); |
327 | connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); | 327 | connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); |
328 | button = new QPushButton( i18n("ftp"), temphb ); | 328 | button = new QPushButton( i18n("ftp"), temphb ); |
329 | connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); | 329 | connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); |
330 | lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); | 330 | lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); |
331 | 331 | ||
332 | // *** pi-sync******************************* | 332 | // *** pi-sync******************************* |
333 | piWidget = new QVBox( topFrame); | 333 | piWidget = new QVBox( topFrame); |
334 | //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); | 334 | //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); |
335 | //++iii; | 335 | //++iii; |
336 | temphb = new QHBox( piWidget ); | 336 | temphb = new QHBox( piWidget ); |
337 | new QLabel( i18n("Calendar:"), temphb); | 337 | new QLabel( i18n("Calendar:"), temphb); |
338 | new QLabel( i18n("AddressBook:"), temphb); | 338 | new QLabel( i18n("AddressBook:"), temphb); |
339 | new QLabel( i18n("PWManager:"), temphb); | 339 | new QLabel( i18n("PWManager:"), temphb); |
340 | 340 | ||
341 | lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); | 341 | lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); |
342 | temphb = new QHBox( piWidget ); | 342 | temphb = new QHBox( piWidget ); |
343 | mRemotePw = new QLineEdit(temphb); | 343 | mRemotePw = new QLineEdit(temphb); |
344 | mRemotePwAB = new QLineEdit(temphb); | 344 | mRemotePwAB = new QLineEdit(temphb); |
345 | mRemotePwPWM = new QLineEdit(temphb); | 345 | mRemotePwPWM = new QLineEdit(temphb); |
346 | 346 | ||
347 | lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); | 347 | lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); |
348 | temphb = new QHBox( piWidget ); | 348 | temphb = new QHBox( piWidget ); |
349 | mRemoteIP = new QLineEdit(temphb); | 349 | mRemoteIP = new QLineEdit(temphb); |
350 | mRemoteIPAB = new QLineEdit(temphb); | 350 | mRemoteIPAB = new QLineEdit(temphb); |
351 | mRemoteIPPWM = new QLineEdit(temphb); | 351 | mRemoteIPPWM = new QLineEdit(temphb); |
352 | 352 | ||
353 | lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); | 353 | lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); |
354 | temphb = new QHBox( piWidget ); | 354 | temphb = new QHBox( piWidget ); |
355 | mRemotePort = new QLineEdit(temphb); | 355 | mRemotePort = new QLineEdit(temphb); |
356 | mRemotePortAB = new QLineEdit(temphb); | 356 | mRemotePortAB = new QLineEdit(temphb); |
357 | mRemotePortPWM = new QLineEdit(temphb); | 357 | mRemotePortPWM = new QLineEdit(temphb); |
358 | } | 358 | } |
359 | // ****************************************** | 359 | // ****************************************** |
360 | // Profile kind specific settings END | 360 | // Profile kind specific settings END |
361 | 361 | ||
362 | } | 362 | } |
363 | 363 | ||
364 | void KSyncPrefsDialog::readFilter() | 364 | void KSyncPrefsDialog::readFilter() |
365 | { | 365 | { |
366 | mFilterKapi.clear(); | 366 | mFilterKapi.clear(); |
367 | mFilterKopi.clear(); | 367 | mFilterKopi.clear(); |
368 | KConfig cfgko(locateLocal("config","korganizerrc")); | 368 | KConfig cfgko(locateLocal("config","korganizerrc")); |
369 | KConfig cfgka(locateLocal("config","kaddressbookrc")); | 369 | KConfig cfgka(locateLocal("config","kaddressbookrc")); |
370 | cfgko.setGroup("General"); | 370 | cfgko.setGroup("General"); |
371 | mFilterKopi = cfgko.readListEntry("CalendarFilters"); | 371 | mFilterKopi = cfgko.readListEntry("CalendarFilters"); |
372 | cfgka.setGroup("Filter"); | 372 | cfgka.setGroup("Filter"); |
373 | int count = cfgka.readNumEntry( "Count", 0 ); | 373 | int count = cfgka.readNumEntry( "Count", 0 ); |
374 | for ( int i = 0; i < count; i++ ) { | 374 | for ( int i = 0; i < count; i++ ) { |
375 | cfgka.setGroup("Filter_"+QString::number( i ) ); | 375 | cfgka.setGroup("Filter_"+QString::number( i ) ); |
376 | mFilterKapi.append( cfgka.readEntry("Name", "internal error") ); | 376 | mFilterKapi.append( cfgka.readEntry("Name", "internal error") ); |
377 | } | 377 | } |
378 | mFilterOutCal->clear(); | 378 | mFilterOutCal->clear(); |
379 | mFilterInCal->clear(); | 379 | mFilterInCal->clear(); |
380 | mFilterOutAB->clear(); | 380 | mFilterOutAB->clear(); |
diff --git a/microkde/kidmanager.cpp b/microkde/kidmanager.cpp index e687e5d..d712771 100644 --- a/microkde/kidmanager.cpp +++ b/microkde/kidmanager.cpp | |||
@@ -1,136 +1,136 @@ | |||
1 | #include "kidmanager.h" | 1 | #include "kidmanager.h" |
2 | 2 | ||
3 | KIdManager::KIdManager() | 3 | KIdManager::KIdManager() |
4 | { | 4 | { |
5 | 5 | ||
6 | } | 6 | } |
7 | // :profilename;12;id_withLen12;123456: | 7 | // :profilename;12;id_withLen12;123456: |
8 | // 123456 is the csum | 8 | // 123456 is the csum |
9 | QString KIdManager::setId (const QString& idString,const QString& prof,const QString& idvalue ) | 9 | const QString KIdManager::setId (const QString& idString,const QString& prof,const QString& idvalue ) |
10 | { | 10 | { |
11 | int startProf; | 11 | int startProf; |
12 | int startIDnum; | 12 | int startIDnum; |
13 | int startIDnumlen; | 13 | int startIDnumlen; |
14 | int startID; | 14 | int startID; |
15 | int lenID; | 15 | int lenID; |
16 | int startCsum; | 16 | int startCsum; |
17 | int lenCsum; | 17 | int lenCsum; |
18 | int endall; | 18 | int endall; |
19 | QString newIDString; | 19 | QString newIDString; |
20 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { | 20 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { |
21 | newIDString = idString.left(startIDnum ) + QString::number( idvalue.length() ) +";"+idvalue+ ";"+idString.mid( startCsum ); | 21 | newIDString = idString.left(startIDnum ) + QString::number( idvalue.length() ) +";"+idvalue+ ";"+idString.mid( startCsum ); |
22 | } else { | 22 | } else { |
23 | newIDString = idString + prof+";"+ QString::number( idvalue.length() ) +";"+idvalue +";0:"; | 23 | newIDString = idString + prof+";"+ QString::number( idvalue.length() ) +";"+idvalue +";0:"; |
24 | } | 24 | } |
25 | //qDebug("setID:profile:%s*retval:%s*idvalue:%s* ", prof.latin1(), newIDString.latin1() ,idvalue.latin1() ); | 25 | //qDebug("setID:profile:%s*retval:%s*idvalue:%s* ", prof.latin1(), newIDString.latin1() ,idvalue.latin1() ); |
26 | return newIDString; | 26 | return newIDString; |
27 | } | 27 | } |
28 | QString KIdManager::getId (const QString& idString,const QString& prof ) | 28 | const QString KIdManager::getId (const QString& idString,const QString& prof ) |
29 | { | 29 | { |
30 | int startProf; | 30 | int startProf; |
31 | int startIDnum; | 31 | int startIDnum; |
32 | int startIDnumlen; | 32 | int startIDnumlen; |
33 | int startID; | 33 | int startID; |
34 | int lenID; | 34 | int lenID; |
35 | int startCsum; | 35 | int startCsum; |
36 | int lenCsum; | 36 | int lenCsum; |
37 | int endall; | 37 | int endall; |
38 | QString idval = ""; | 38 | QString idval = ""; |
39 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) | 39 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) |
40 | idval = idString.mid( startID, lenID ); | 40 | idval = idString.mid( startID, lenID ); |
41 | 41 | ||
42 | //qDebug("getID:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() ); | 42 | //qDebug("getID:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() ); |
43 | return idval; | 43 | return idval; |
44 | 44 | ||
45 | } | 45 | } |
46 | 46 | ||
47 | QString KIdManager::removeId (const QString& idString,const QString& prof ) | 47 | const QString KIdManager::removeId (const QString& idString,const QString& prof ) |
48 | { | 48 | { |
49 | int startProf; | 49 | int startProf; |
50 | int startIDnum; | 50 | int startIDnum; |
51 | int startIDnumlen; | 51 | int startIDnumlen; |
52 | int startID; | 52 | int startID; |
53 | int lenID; | 53 | int lenID; |
54 | int startCsum; | 54 | int startCsum; |
55 | int lenCsum; | 55 | int lenCsum; |
56 | int endall; | 56 | int endall; |
57 | QString newIDString; | 57 | QString newIDString; |
58 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { | 58 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { |
59 | newIDString = idString.left(startProf) + idString.mid( endall+1 ); | 59 | newIDString = idString.left(startProf) + idString.mid( endall+1 ); |
60 | } else { | 60 | } else { |
61 | newIDString = idString; | 61 | newIDString = idString; |
62 | } | 62 | } |
63 | //qDebug("removeID:profile:%s*retval:%s*oldidstring:%s* ", prof.latin1(), newIDString.latin1() ,idString.latin1() ); | 63 | //qDebug("removeID:profile:%s*retval:%s*oldidstring:%s* ", prof.latin1(), newIDString.latin1() ,idString.latin1() ); |
64 | return newIDString; | 64 | return newIDString; |
65 | } | 65 | } |
66 | 66 | ||
67 | QString KIdManager::setCsum (const QString& idString,const QString& prof,const QString& idCsum ) | 67 | const QString KIdManager::setCsum (const QString& idString,const QString& prof,const QString& idCsum ) |
68 | { | 68 | { |
69 | int startProf; | 69 | int startProf; |
70 | int startIDnum; | 70 | int startIDnum; |
71 | int startIDnumlen; | 71 | int startIDnumlen; |
72 | int startID; | 72 | int startID; |
73 | int lenID; | 73 | int lenID; |
74 | int startCsum; | 74 | int startCsum; |
75 | int lenCsum; | 75 | int lenCsum; |
76 | int endall; | 76 | int endall; |
77 | QString newIDString; | 77 | QString newIDString; |
78 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { | 78 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { |
79 | newIDString = idString.left(startCsum) + idCsum+ idString.mid( endall +1); | 79 | newIDString = idString.left(startCsum) + idCsum+ idString.mid( endall +1); |
80 | } else { | 80 | } else { |
81 | newIDString = idString + prof + ";3;_u_;"+ idCsum + ":"; | 81 | newIDString = idString + prof + ";3;_u_;"+ idCsum + ":"; |
82 | } | 82 | } |
83 | //qDebug("setCsum:profile:%s*retval:%s*idCsum:%s* ", prof.latin1(), newIDString.latin1() ,idCsum.latin1() ); | 83 | //qDebug("setCsum:profile:%s*retval:%s*idCsum:%s* ", prof.latin1(), newIDString.latin1() ,idCsum.latin1() ); |
84 | return newIDString; | 84 | return newIDString; |
85 | } | 85 | } |
86 | QString KIdManager::getCsum (const QString& idString,const QString& prof ) | 86 | const QString KIdManager::getCsum (const QString& idString,const QString& prof ) |
87 | { | 87 | { |
88 | int startProf; | 88 | int startProf; |
89 | int startIDnum; | 89 | int startIDnum; |
90 | int startIDnumlen; | 90 | int startIDnumlen; |
91 | int startID; | 91 | int startID; |
92 | int lenID; | 92 | int lenID; |
93 | int startCsum; | 93 | int startCsum; |
94 | int lenCsum; | 94 | int lenCsum; |
95 | int endall; | 95 | int endall; |
96 | QString idval = ""; | 96 | QString idval = ""; |
97 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) | 97 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) |
98 | idval = idString.mid( startCsum, lenCsum ); | 98 | idval = idString.mid( startCsum, lenCsum ); |
99 | 99 | ||
100 | //qDebug("getCsum:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() ); | 100 | //qDebug("getCsum:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() ); |
101 | return idval; | 101 | return idval; |
102 | } | 102 | } |
103 | // :profilename;12;id_withLen12;123456: | 103 | // :profilename;12;id_withLen12;123456: |
104 | bool KIdManager::getNumbers (const QString& idString,const QString& prof, int &startProf, int &startIDnum, int &startIDnumlen,int &startID, int& lenID, int &startCsum, int &lenCsum, int & endall) | 104 | bool KIdManager::getNumbers (const QString& idString,const QString& prof, int &startProf, int &startIDnum, int &startIDnumlen,int &startID, int& lenID, int &startCsum, int &lenCsum, int & endall) |
105 | { | 105 | { |
106 | startProf = idString.find( ":"+prof+";" ); | 106 | startProf = idString.find( ":"+prof+";" ); |
107 | if ( startProf >= 0 ) { | 107 | if ( startProf >= 0 ) { |
108 | startIDnum = prof.length()+2+startProf; | 108 | startIDnum = prof.length()+2+startProf; |
109 | startID = idString.find( ";", startIDnum ) +1; | 109 | startID = idString.find( ";", startIDnum ) +1; |
110 | startIDnumlen = startID - startIDnum - 1; | 110 | startIDnumlen = startID - startIDnum - 1; |
111 | if ( startIDnum > 0 ) { | 111 | if ( startIDnum > 0 ) { |
112 | bool ok; | 112 | bool ok; |
113 | lenID = idString.mid ( startIDnum,startIDnumlen).toInt( &ok ); | 113 | lenID = idString.mid ( startIDnum,startIDnumlen).toInt( &ok ); |
114 | if (ok) { | 114 | if (ok) { |
115 | startCsum = startID+lenID+1; | 115 | startCsum = startID+lenID+1; |
116 | endall = idString.find( ":", startCsum )-1; | 116 | endall = idString.find( ":", startCsum )-1; |
117 | if ( endall < 0 ) { | 117 | if ( endall < 0 ) { |
118 | qDebug("Error getNumbers: andall not found "); | 118 | qDebug("Error getNumbers: andall not found "); |
119 | return false; | 119 | return false; |
120 | } | 120 | } |
121 | lenCsum = endall-startCsum+1; | 121 | lenCsum = endall-startCsum+1; |
122 | } | 122 | } |
123 | else { | 123 | else { |
124 | qDebug("Error getNumbers:length is no number:*%s* ", idString.mid ( startIDnum,startIDnumlen).latin1()); | 124 | qDebug("Error getNumbers:length is no number:*%s* ", idString.mid ( startIDnum,startIDnumlen).latin1()); |
125 | return false; | 125 | return false; |
126 | } | 126 | } |
127 | } else { | 127 | } else { |
128 | qDebug("Error in KIdManager::getNumbers.startIDnum <= 0"); | 128 | qDebug("Error in KIdManager::getNumbers.startIDnum <= 0"); |
129 | return false; | 129 | return false; |
130 | } | 130 | } |
131 | } else { | 131 | } else { |
132 | //qDebug("getnumbers: profile not found *%s* ",prof.latin1() ); | 132 | //qDebug("getnumbers: profile not found *%s* ",prof.latin1() ); |
133 | return false; | 133 | return false; |
134 | } | 134 | } |
135 | return true; | 135 | return true; |
136 | } | 136 | } |
diff --git a/microkde/kidmanager.h b/microkde/kidmanager.h index 00580a0..9786c9f 100644 --- a/microkde/kidmanager.h +++ b/microkde/kidmanager.h | |||
@@ -1,24 +1,24 @@ | |||
1 | #ifndef MINIKDE_KIDMANAGER_H | 1 | #ifndef MINIKDE_KIDMANAGER_H |
2 | #define MINIKDE_KIDMANAGER_H | 2 | #define MINIKDE_KIDMANAGER_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | 5 | ||
6 | #include <qobject.h> | 6 | #include <qobject.h> |
7 | class KIdManager : public QObject | 7 | class KIdManager : public QObject |
8 | { | 8 | { |
9 | Q_OBJECT | 9 | Q_OBJECT |
10 | public: | 10 | public: |
11 | KIdManager( ); | 11 | KIdManager( ); |
12 | static QString setId (const QString& idString,const QString& id,const QString& idvalue ) ; | 12 | static const QString setId (const QString& idString,const QString& id,const QString& idvalue ) ; |
13 | static QString getId (const QString& idString,const QString& id ) ; | 13 | static const QString getId (const QString& idString,const QString& id ) ; |
14 | static QString removeId (const QString& idString,const QString& id ) ; | 14 | static const QString removeId (const QString& idString,const QString& id ) ; |
15 | static QString setCsum (const QString& idString,const QString& id,const QString& idvalue ) ; | 15 | static const QString setCsum (const QString& idString,const QString& id,const QString& idvalue ) ; |
16 | static QString getCsum (const QString& idString,const QString& id ) ; | 16 | static const QString getCsum (const QString& idString,const QString& id ) ; |
17 | static bool getNumbers (const QString& idString,const QString& id, int &startProf, int &startIDnum, int &startIDnumlen,int &startID, int& lenID, int &startCsum, int &lenCsum, int & endall) ; | 17 | static bool getNumbers (const QString& idString,const QString& id, int &startProf, int &startIDnum, int &startIDnumlen,int &startID, int& lenID, int &startCsum, int &lenCsum, int & endall) ; |
18 | private: | 18 | private: |
19 | 19 | ||
20 | private slots: | 20 | private slots: |
21 | }; | 21 | }; |
22 | 22 | ||
23 | 23 | ||
24 | #endif | 24 | #endif |