32 files changed, 228 insertions, 54 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp index 96a5f65..a38b62b 100644 --- a/libopie/pim/ocontact.cpp +++ b/libopie/pim/ocontact.cpp | |||
@@ -854,201 +854,192 @@ void OContact::save( QString &buf ) const | |||
854 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 854 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; |
855 | } | 855 | } |
856 | } | 856 | } |
857 | buf += customToXml(); | 857 | buf += customToXml(); |
858 | if ( categories().count() > 0 ) | 858 | if ( categories().count() > 0 ) |
859 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 859 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
860 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 860 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
861 | // You need to close this yourself | 861 | // You need to close this yourself |
862 | } | 862 | } |
863 | 863 | ||
864 | 864 | ||
865 | /*! | 865 | /*! |
866 | \internal | 866 | \internal |
867 | Returns the list of fields belonging to a contact | 867 | Returns the list of fields belonging to a contact |
868 | Never change order of this list ! It has to be regarding | 868 | Never change order of this list ! It has to be regarding |
869 | enum AddressBookFields !! | 869 | enum AddressBookFields !! |
870 | */ | 870 | */ |
871 | QStringList OContact::fields() | 871 | QStringList OContact::fields() |
872 | { | 872 | { |
873 | QStringList list; | 873 | QStringList list; |
874 | 874 | ||
875 | list.append( "Title" ); // Not Used! | 875 | list.append( "Title" ); // Not Used! |
876 | list.append( "FirstName" ); | 876 | list.append( "FirstName" ); |
877 | list.append( "MiddleName" ); | 877 | list.append( "MiddleName" ); |
878 | list.append( "LastName" ); | 878 | list.append( "LastName" ); |
879 | list.append( "Suffix" ); | 879 | list.append( "Suffix" ); |
880 | list.append( "FileAs" ); | 880 | list.append( "FileAs" ); |
881 | 881 | ||
882 | list.append( "JobTitle" ); | 882 | list.append( "JobTitle" ); |
883 | list.append( "Department" ); | 883 | list.append( "Department" ); |
884 | list.append( "Company" ); | 884 | list.append( "Company" ); |
885 | list.append( "BusinessPhone" ); | 885 | list.append( "BusinessPhone" ); |
886 | list.append( "BusinessFax" ); | 886 | list.append( "BusinessFax" ); |
887 | list.append( "BusinessMobile" ); | 887 | list.append( "BusinessMobile" ); |
888 | 888 | ||
889 | list.append( "DefaultEmail" ); | 889 | list.append( "DefaultEmail" ); |
890 | list.append( "Emails" ); | 890 | list.append( "Emails" ); |
891 | 891 | ||
892 | list.append( "HomePhone" ); | 892 | list.append( "HomePhone" ); |
893 | list.append( "HomeFax" ); | 893 | list.append( "HomeFax" ); |
894 | list.append( "HomeMobile" ); | 894 | list.append( "HomeMobile" ); |
895 | 895 | ||
896 | list.append( "BusinessStreet" ); | 896 | list.append( "BusinessStreet" ); |
897 | list.append( "BusinessCity" ); | 897 | list.append( "BusinessCity" ); |
898 | list.append( "BusinessState" ); | 898 | list.append( "BusinessState" ); |
899 | list.append( "BusinessZip" ); | 899 | list.append( "BusinessZip" ); |
900 | list.append( "BusinessCountry" ); | 900 | list.append( "BusinessCountry" ); |
901 | list.append( "BusinessPager" ); | 901 | list.append( "BusinessPager" ); |
902 | list.append( "BusinessWebPage" ); | 902 | list.append( "BusinessWebPage" ); |
903 | 903 | ||
904 | list.append( "Office" ); | 904 | list.append( "Office" ); |
905 | list.append( "Profession" ); | 905 | list.append( "Profession" ); |
906 | list.append( "Assistant" ); | 906 | list.append( "Assistant" ); |
907 | list.append( "Manager" ); | 907 | list.append( "Manager" ); |
908 | 908 | ||
909 | list.append( "HomeStreet" ); | 909 | list.append( "HomeStreet" ); |
910 | list.append( "HomeCity" ); | 910 | list.append( "HomeCity" ); |
911 | list.append( "HomeState" ); | 911 | list.append( "HomeState" ); |
912 | list.append( "HomeZip" ); | 912 | list.append( "HomeZip" ); |
913 | list.append( "HomeCountry" ); | 913 | list.append( "HomeCountry" ); |
914 | list.append( "HomeWebPage" ); | 914 | list.append( "HomeWebPage" ); |
915 | 915 | ||
916 | list.append( "Spouse" ); | 916 | list.append( "Spouse" ); |
917 | list.append( "Gender" ); | 917 | list.append( "Gender" ); |
918 | list.append( "Birthday" ); | 918 | list.append( "Birthday" ); |
919 | list.append( "Anniversary" ); | 919 | list.append( "Anniversary" ); |
920 | list.append( "Nickname" ); | 920 | list.append( "Nickname" ); |
921 | list.append( "Children" ); | 921 | list.append( "Children" ); |
922 | 922 | ||
923 | list.append( "Notes" ); | 923 | list.append( "Notes" ); |
924 | list.append( "Groups" ); | 924 | list.append( "Groups" ); |
925 | 925 | ||
926 | return list; | 926 | return list; |
927 | } | 927 | } |
928 | 928 | ||
929 | 929 | ||
930 | /*! | 930 | /*! |
931 | Sets the list of email address for contact to those contained in \a str. | 931 | Sets the list of email address for contact to those contained in \a str. |
932 | Email address should be separated by ';'s. | 932 | Email address should be separated by ';'s. |
933 | */ | 933 | */ |
934 | void OContact::setEmails( const QString &str ) | 934 | void OContact::setEmails( const QString &str ) |
935 | { | 935 | { |
936 | replace( Qtopia::Emails, str ); | 936 | replace( Qtopia::Emails, str ); |
937 | if ( str.isEmpty() ) | 937 | if ( str.isEmpty() ) |
938 | setDefaultEmail( QString::null ); | 938 | setDefaultEmail( QString::null ); |
939 | } | 939 | } |
940 | 940 | ||
941 | /*! | 941 | /*! |
942 | Sets the list of children for the contact to those contained in \a str. | 942 | Sets the list of children for the contact to those contained in \a str. |
943 | */ | 943 | */ |
944 | void OContact::setChildren( const QString &str ) | 944 | void OContact::setChildren( const QString &str ) |
945 | { | 945 | { |
946 | replace( Qtopia::Children, str ); | 946 | replace( Qtopia::Children, str ); |
947 | } | 947 | } |
948 | 948 | ||
949 | /*! | 949 | /*! |
950 | Returns TRUE if the contact matches the regular expression \a regexp. | ||
951 | Otherwise returns FALSE. | ||
952 | */ | ||
953 | bool OContact::match( const QString ®exp ) const | ||
954 | { | ||
955 | return match(QRegExp(regexp)); | ||
956 | } | ||
957 | |||
958 | /*! | ||
959 | \overload | 950 | \overload |
960 | Returns TRUE if the contact matches the regular expression \a regexp. | 951 | Returns TRUE if the contact matches the regular expression \a regexp. |
961 | Otherwise returns FALSE. | 952 | Otherwise returns FALSE. |
962 | */ | 953 | */ |
963 | bool OContact::match( const QRegExp &r ) const | 954 | bool OContact::match( const QRegExp &r ) const |
964 | { | 955 | { |
965 | bool match; | 956 | bool match; |
966 | match = false; | 957 | match = false; |
967 | QMap<int, QString>::ConstIterator it; | 958 | QMap<int, QString>::ConstIterator it; |
968 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 959 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { |
969 | if ( (*it).find( r ) > -1 ) { | 960 | if ( (*it).find( r ) > -1 ) { |
970 | match = true; | 961 | match = true; |
971 | break; | 962 | break; |
972 | } | 963 | } |
973 | } | 964 | } |
974 | return match; | 965 | return match; |
975 | } | 966 | } |
976 | 967 | ||
977 | 968 | ||
978 | QString OContact::toShortText() const | 969 | QString OContact::toShortText() const |
979 | { | 970 | { |
980 | return ( fullName() ); | 971 | return ( fullName() ); |
981 | } | 972 | } |
982 | QString OContact::type() const | 973 | QString OContact::type() const |
983 | { | 974 | { |
984 | return QString::fromLatin1( "OContact" ); | 975 | return QString::fromLatin1( "OContact" ); |
985 | } | 976 | } |
986 | 977 | ||
987 | // Definition is missing ! (se) | 978 | // Definition is missing ! (se) |
988 | QMap<QString,QString> OContact::toExtraMap() const | 979 | QMap<QString,QString> OContact::toExtraMap() const |
989 | { | 980 | { |
990 | qWarning ("Function not implemented: OContact::toExtraMap()"); | 981 | qWarning ("Function not implemented: OContact::toExtraMap()"); |
991 | QMap <QString,QString> useless; | 982 | QMap <QString,QString> useless; |
992 | return useless; | 983 | return useless; |
993 | } | 984 | } |
994 | 985 | ||
995 | class QString OContact::recordField( int pos ) const | 986 | class QString OContact::recordField( int pos ) const |
996 | { | 987 | { |
997 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 988 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
998 | return SLFIELDS[pos]; | 989 | return SLFIELDS[pos]; |
999 | } | 990 | } |
1000 | 991 | ||
1001 | // In future releases, we should store birthday and anniversary | 992 | // In future releases, we should store birthday and anniversary |
1002 | // internally as QDate instead of QString ! | 993 | // internally as QDate instead of QString ! |
1003 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 994 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
1004 | 995 | ||
1005 | /*! \fn void OContact::setBirthday( const QDate& date ) | 996 | /*! \fn void OContact::setBirthday( const QDate& date ) |
1006 | Sets the birthday for the contact to \a date. If date is null | 997 | Sets the birthday for the contact to \a date. If date is null |
1007 | the current stored date will be removed. | 998 | the current stored date will be removed. |
1008 | */ | 999 | */ |
1009 | void OContact::setBirthday( const QDate &v ) | 1000 | void OContact::setBirthday( const QDate &v ) |
1010 | { | 1001 | { |
1011 | if ( v.isNull() ){ | 1002 | if ( v.isNull() ){ |
1012 | qWarning( "Remove Birthday"); | 1003 | qWarning( "Remove Birthday"); |
1013 | replace( Qtopia::Birthday, QString::null ); | 1004 | replace( Qtopia::Birthday, QString::null ); |
1014 | return; | 1005 | return; |
1015 | } | 1006 | } |
1016 | 1007 | ||
1017 | if ( v.isValid() ) | 1008 | if ( v.isValid() ) |
1018 | replace( Qtopia::Birthday, OConversion::dateToString( v ) ); | 1009 | replace( Qtopia::Birthday, OConversion::dateToString( v ) ); |
1019 | 1010 | ||
1020 | } | 1011 | } |
1021 | 1012 | ||
1022 | 1013 | ||
1023 | /*! \fn void OContact::setAnniversary( const QDate &date ) | 1014 | /*! \fn void OContact::setAnniversary( const QDate &date ) |
1024 | Sets the anniversary of the contact to \a date. If date is | 1015 | Sets the anniversary of the contact to \a date. If date is |
1025 | null, the current stored date will be removed. | 1016 | null, the current stored date will be removed. |
1026 | */ | 1017 | */ |
1027 | void OContact::setAnniversary( const QDate &v ) | 1018 | void OContact::setAnniversary( const QDate &v ) |
1028 | { | 1019 | { |
1029 | if ( v.isNull() ){ | 1020 | if ( v.isNull() ){ |
1030 | qWarning( "Remove Anniversary"); | 1021 | qWarning( "Remove Anniversary"); |
1031 | replace( Qtopia::Anniversary, QString::null ); | 1022 | replace( Qtopia::Anniversary, QString::null ); |
1032 | return; | 1023 | return; |
1033 | } | 1024 | } |
1034 | 1025 | ||
1035 | if ( v.isValid() ) | 1026 | if ( v.isValid() ) |
1036 | replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); | 1027 | replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); |
1037 | } | 1028 | } |
1038 | 1029 | ||
1039 | /*! \fn QDate OContact::birthday() const | 1030 | /*! \fn QDate OContact::birthday() const |
1040 | Returns the birthday of the contact. | 1031 | Returns the birthday of the contact. |
1041 | */ | 1032 | */ |
1042 | QDate OContact::birthday() const | 1033 | QDate OContact::birthday() const |
1043 | { | 1034 | { |
1044 | QString str = find( Qtopia::Birthday ); | 1035 | QString str = find( Qtopia::Birthday ); |
1045 | qWarning ("Birthday %s", str.latin1() ); | 1036 | qWarning ("Birthday %s", str.latin1() ); |
1046 | if ( !str.isEmpty() ) | 1037 | if ( !str.isEmpty() ) |
1047 | return OConversion::dateFromString ( str ); | 1038 | return OConversion::dateFromString ( str ); |
1048 | else | 1039 | else |
1049 | return QDate(); | 1040 | return QDate(); |
1050 | } | 1041 | } |
1051 | 1042 | ||
1052 | 1043 | ||
1053 | /*! \fn QDate OContact::anniversary() const | 1044 | /*! \fn QDate OContact::anniversary() const |
1054 | Returns the anniversary of the contact. | 1045 | Returns the anniversary of the contact. |
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h index 50f6176..0e6cbd2 100644 --- a/libopie/pim/ocontact.h +++ b/libopie/pim/ocontact.h | |||
@@ -18,194 +18,193 @@ | |||
18 | **********************************************************************/ | 18 | **********************************************************************/ |
19 | 19 | ||
20 | #ifndef __OCONTACT_H__ | 20 | #ifndef __OCONTACT_H__ |
21 | #define __OCONTACT_H__ | 21 | #define __OCONTACT_H__ |
22 | 22 | ||
23 | #include <opie/opimrecord.h> | 23 | #include <opie/opimrecord.h> |
24 | #include <qpe/recordfields.h> | 24 | #include <qpe/recordfields.h> |
25 | 25 | ||
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | 28 | ||
29 | #if defined(QPC_TEMPLATEDLL) | 29 | #if defined(QPC_TEMPLATEDLL) |
30 | // MOC_SKIP_BEGIN | 30 | // MOC_SKIP_BEGIN |
31 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; | 31 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; |
32 | // MOC_SKIP_END | 32 | // MOC_SKIP_END |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | class ContactPrivate; | 35 | class ContactPrivate; |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * OContact class represents a specialised PIM Record for contacts. | 38 | * OContact class represents a specialised PIM Record for contacts. |
39 | * It does store all kind of persopn related information. | 39 | * It does store all kind of persopn related information. |
40 | * | 40 | * |
41 | * @short Contact Container | 41 | * @short Contact Container |
42 | * @author TT, Stefan Eiler, Holger Freyther | 42 | * @author TT, Stefan Eiler, Holger Freyther |
43 | */ | 43 | */ |
44 | class QPC_EXPORT OContact : public OPimRecord | 44 | class QPC_EXPORT OContact : public OPimRecord |
45 | { | 45 | { |
46 | friend class DataSet; | 46 | friend class DataSet; |
47 | public: | 47 | public: |
48 | OContact(); | 48 | OContact(); |
49 | OContact( const QMap<int, QString> &fromMap ); | 49 | OContact( const QMap<int, QString> &fromMap ); |
50 | virtual ~OContact(); | 50 | virtual ~OContact(); |
51 | 51 | ||
52 | /* | 52 | /* |
53 | * do we need to inline them | 53 | * do we need to inline them |
54 | * if yes do we need to inline them this way? | 54 | * if yes do we need to inline them this way? |
55 | * -zecke | 55 | * -zecke |
56 | */ | 56 | */ |
57 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } | 57 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } |
58 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } | 58 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } |
59 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } | 59 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } |
60 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } | 60 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } |
61 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } | 61 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } |
62 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } | 62 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } |
63 | void setFileAs(); | 63 | void setFileAs(); |
64 | 64 | ||
65 | // default email address | 65 | // default email address |
66 | void setDefaultEmail( const QString &v ); | 66 | void setDefaultEmail( const QString &v ); |
67 | // inserts email to list and ensure's doesn't already exist | 67 | // inserts email to list and ensure's doesn't already exist |
68 | void insertEmail( const QString &v ); | 68 | void insertEmail( const QString &v ); |
69 | void removeEmail( const QString &v ); | 69 | void removeEmail( const QString &v ); |
70 | void clearEmails(); | 70 | void clearEmails(); |
71 | void insertEmails( const QStringList &v ); | 71 | void insertEmails( const QStringList &v ); |
72 | 72 | ||
73 | // home | 73 | // home |
74 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } | 74 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } |
75 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } | 75 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } |
76 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } | 76 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } |
77 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } | 77 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } |
78 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } | 78 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } |
79 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } | 79 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } |
80 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } | 80 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } |
81 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } | 81 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } |
82 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } | 82 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } |
83 | 83 | ||
84 | // business | 84 | // business |
85 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } | 85 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } |
86 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } | 86 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } |
87 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } | 87 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } |
88 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } | 88 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } |
89 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 89 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
90 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 90 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
91 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 91 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
92 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 92 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
93 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 93 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
94 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 94 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
95 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 95 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
96 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 96 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
97 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 97 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
98 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 98 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
99 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 99 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
100 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 100 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
101 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 101 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
102 | 102 | ||
103 | // personal | 103 | // personal |
104 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 104 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
105 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 105 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
106 | void setBirthday( const QDate &v ); | 106 | void setBirthday( const QDate &v ); |
107 | void setAnniversary( const QDate &v ); | 107 | void setAnniversary( const QDate &v ); |
108 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 108 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
109 | void setChildren( const QString &v ); | 109 | void setChildren( const QString &v ); |
110 | 110 | ||
111 | // other | 111 | // other |
112 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 112 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } |
113 | 113 | ||
114 | bool match( const QString ®exp ) const; | 114 | virtual bool match( const QRegExp ®exp ) const; |
115 | bool match( const QRegExp ®exp ) const; | ||
116 | 115 | ||
117 | // // custom | 116 | // // custom |
118 | // void setCustomField( const QString &key, const QString &v ) | 117 | // void setCustomField( const QString &key, const QString &v ) |
119 | // { replace(Custom- + key, v ); } | 118 | // { replace(Custom- + key, v ); } |
120 | 119 | ||
121 | // name | 120 | // name |
122 | QString fullName() const; | 121 | QString fullName() const; |
123 | QString title() const { return find( Qtopia::Title ); } | 122 | QString title() const { return find( Qtopia::Title ); } |
124 | QString firstName() const { return find( Qtopia::FirstName ); } | 123 | QString firstName() const { return find( Qtopia::FirstName ); } |
125 | QString middleName() const { return find( Qtopia::MiddleName ); } | 124 | QString middleName() const { return find( Qtopia::MiddleName ); } |
126 | QString lastName() const { return find( Qtopia::LastName ); } | 125 | QString lastName() const { return find( Qtopia::LastName ); } |
127 | QString suffix() const { return find( Qtopia::Suffix ); } | 126 | QString suffix() const { return find( Qtopia::Suffix ); } |
128 | QString fileAs() const { return find( Qtopia::FileAs ); } | 127 | QString fileAs() const { return find( Qtopia::FileAs ); } |
129 | 128 | ||
130 | 129 | ||
131 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 130 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
132 | QStringList emailList() const; | 131 | QStringList emailList() const; |
133 | 132 | ||
134 | // home | 133 | // home |
135 | /* | 134 | /* |
136 | * OPimAddress address(enum Location)const; | 135 | * OPimAddress address(enum Location)const; |
137 | * would be some how nicer... | 136 | * would be some how nicer... |
138 | * -zecke | 137 | * -zecke |
139 | */ | 138 | */ |
140 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 139 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
141 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 140 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
142 | QString homeState() const { return find( Qtopia::HomeState ); } | 141 | QString homeState() const { return find( Qtopia::HomeState ); } |
143 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 142 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
144 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 143 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
145 | QString homePhone() const { return find( Qtopia::HomePhone ); } | 144 | QString homePhone() const { return find( Qtopia::HomePhone ); } |
146 | QString homeFax() const { return find( Qtopia::HomeFax ); } | 145 | QString homeFax() const { return find( Qtopia::HomeFax ); } |
147 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } | 146 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } |
148 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } | 147 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } |
149 | /** Multi line string containing all non-empty address info in the form | 148 | /** Multi line string containing all non-empty address info in the form |
150 | * Street | 149 | * Street |
151 | * City, State Zip | 150 | * City, State Zip |
152 | * Country | 151 | * Country |
153 | */ | 152 | */ |
154 | QString displayHomeAddress() const; | 153 | QString displayHomeAddress() const; |
155 | 154 | ||
156 | // business | 155 | // business |
157 | QString company() const { return find( Qtopia::Company ); } | 156 | QString company() const { return find( Qtopia::Company ); } |
158 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } | 157 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } |
159 | QString businessCity() const { return find( Qtopia::BusinessCity ); } | 158 | QString businessCity() const { return find( Qtopia::BusinessCity ); } |
160 | QString businessState() const { return find( Qtopia::BusinessState ); } | 159 | QString businessState() const { return find( Qtopia::BusinessState ); } |
161 | QString businessZip() const { return find( Qtopia::BusinessZip ); } | 160 | QString businessZip() const { return find( Qtopia::BusinessZip ); } |
162 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } | 161 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } |
163 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | 162 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } |
164 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 163 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
165 | QString department() const { return find( Qtopia::Department ); } | 164 | QString department() const { return find( Qtopia::Department ); } |
166 | QString office() const { return find( Qtopia::Office ); } | 165 | QString office() const { return find( Qtopia::Office ); } |
167 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 166 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
168 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 167 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
169 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 168 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
170 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 169 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
171 | QString profession() const { return find( Qtopia::Profession ); } | 170 | QString profession() const { return find( Qtopia::Profession ); } |
172 | QString assistant() const { return find( Qtopia::Assistant ); } | 171 | QString assistant() const { return find( Qtopia::Assistant ); } |
173 | QString manager() const { return find( Qtopia::Manager ); } | 172 | QString manager() const { return find( Qtopia::Manager ); } |
174 | /** Multi line string containing all non-empty address info in the form | 173 | /** Multi line string containing all non-empty address info in the form |
175 | * Street | 174 | * Street |
176 | * City, State Zip | 175 | * City, State Zip |
177 | * Country | 176 | * Country |
178 | */ | 177 | */ |
179 | QString displayBusinessAddress() const; | 178 | QString displayBusinessAddress() const; |
180 | 179 | ||
181 | //personal | 180 | //personal |
182 | QString spouse() const { return find( Qtopia::Spouse ); } | 181 | QString spouse() const { return find( Qtopia::Spouse ); } |
183 | QString gender() const { return find( Qtopia::Gender ); } | 182 | QString gender() const { return find( Qtopia::Gender ); } |
184 | QDate birthday() const; | 183 | QDate birthday() const; |
185 | QDate anniversary() const; | 184 | QDate anniversary() const; |
186 | QString nickname() const { return find( Qtopia::Nickname ); } | 185 | QString nickname() const { return find( Qtopia::Nickname ); } |
187 | QString children() const { return find( Qtopia::Children ); } | 186 | QString children() const { return find( Qtopia::Children ); } |
188 | QStringList childrenList() const; | 187 | QStringList childrenList() const; |
189 | 188 | ||
190 | // other | 189 | // other |
191 | QString notes() const { return find( Qtopia::Notes ); } | 190 | QString notes() const { return find( Qtopia::Notes ); } |
192 | QString groups() const { return find( Qtopia::Groups ); } | 191 | QString groups() const { return find( Qtopia::Groups ); } |
193 | QStringList groupList() const; | 192 | QStringList groupList() const; |
194 | 193 | ||
195 | // // custom | 194 | // // custom |
196 | // const QString &customField( const QString &key ) | 195 | // const QString &customField( const QString &key ) |
197 | // { return find( Custom- + key ); } | 196 | // { return find( Custom- + key ); } |
198 | 197 | ||
199 | 198 | ||
200 | QString toRichText() const; | 199 | QString toRichText() const; |
201 | QMap<int, QString> toMap() const; | 200 | QMap<int, QString> toMap() const; |
202 | QString field( int key ) const { return find( key ); } | 201 | QString field( int key ) const { return find( key ); } |
203 | 202 | ||
204 | 203 | ||
205 | void setUid( int i ); | 204 | void setUid( int i ); |
206 | 205 | ||
207 | QString toShortText()const; | 206 | QString toShortText()const; |
208 | QString OContact::type()const; | 207 | QString OContact::type()const; |
209 | QMap<QString,QString> OContact::toExtraMap() const; | 208 | QMap<QString,QString> OContact::toExtraMap() const; |
210 | class QString OContact::recordField(int) const; | 209 | class QString OContact::recordField(int) const; |
211 | 210 | ||
diff --git a/libopie/pim/ocontactaccess.cpp b/libopie/pim/ocontactaccess.cpp index 9c9338e..2e3ec1f 100644 --- a/libopie/pim/ocontactaccess.cpp +++ b/libopie/pim/ocontactaccess.cpp | |||
@@ -1,169 +1,168 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage the Contacts. | 2 | * Class to manage the Contacts. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 5 | * |
6 | * ===================================================================== | 6 | * ===================================================================== |
7 | *This program is free software; you can redistribute it and/or | 7 | *This program is free software; you can redistribute it and/or |
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; either | 9 | * License as published by the Free Software Foundation; either |
10 | * version 2 of the License, or (at your option) any later version. | 10 | * version 2 of the License, or (at your option) any later version. |
11 | * ===================================================================== | 11 | * ===================================================================== |
12 | * Info: This class could just work with a change in the header-file | 12 | * Info: This class could just work with a change in the header-file |
13 | * of the Contact class ! Therefore our libopie only compiles | 13 | * of the Contact class ! Therefore our libopie only compiles |
14 | * with our version of libqpe | 14 | * with our version of libqpe |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * ToDo: XML-Backend: Automatic reload if something was changed... | 16 | * ToDo: XML-Backend: Automatic reload if something was changed... |
17 | * | 17 | * |
18 | * | 18 | * |
19 | * ===================================================================== | 19 | * ===================================================================== |
20 | * Version: $Id$ | 20 | * Version: $Id$ |
21 | * ===================================================================== | 21 | * ===================================================================== |
22 | * History: | 22 | * History: |
23 | * $Log$ | 23 | * $Log$ |
24 | * Revision 1.8 2003/05/08 13:55:09 tille | ||
25 | * search stuff | ||
26 | * and match, toRichText & toShortText in oevent | ||
27 | * | ||
24 | * Revision 1.7 2002/11/13 14:14:51 eilers | 28 | * Revision 1.7 2002/11/13 14:14:51 eilers |
25 | * Added sorted for Contacts.. | 29 | * Added sorted for Contacts.. |
26 | * | 30 | * |
27 | * Revision 1.6 2002/11/01 15:10:42 eilers | 31 | * Revision 1.6 2002/11/01 15:10:42 eilers |
28 | * Added regExp-search in database for all fields in a contact. | 32 | * Added regExp-search in database for all fields in a contact. |
29 | * | 33 | * |
30 | * Revision 1.5 2002/10/16 10:52:40 eilers | 34 | * Revision 1.5 2002/10/16 10:52:40 eilers |
31 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | 35 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) |
32 | * | 36 | * |
33 | * Revision 1.4 2002/10/14 16:21:54 eilers | 37 | * Revision 1.4 2002/10/14 16:21:54 eilers |
34 | * Some minor interface updates | 38 | * Some minor interface updates |
35 | * | 39 | * |
36 | * Revision 1.3 2002/10/07 17:34:24 eilers | 40 | * Revision 1.3 2002/10/07 17:34:24 eilers |
37 | * added OBackendFactory for advanced backend access | 41 | * added OBackendFactory for advanced backend access |
38 | * | 42 | * |
39 | * Revision 1.2 2002/10/02 16:18:11 eilers | 43 | * Revision 1.2 2002/10/02 16:18:11 eilers |
40 | * debugged and seems to work almost perfectly .. | 44 | * debugged and seems to work almost perfectly .. |
41 | * | 45 | * |
42 | * Revision 1.1 2002/09/27 17:11:44 eilers | 46 | * Revision 1.1 2002/09/27 17:11:44 eilers |
43 | * Added API for accessing the Contact-Database ! It is compiling, but | 47 | * Added API for accessing the Contact-Database ! It is compiling, but |
44 | * please do not expect that anything is working ! | 48 | * please do not expect that anything is working ! |
45 | * I will debug that stuff in the next time .. | 49 | * I will debug that stuff in the next time .. |
46 | * Please read README_COMPILE for compiling ! | 50 | * Please read README_COMPILE for compiling ! |
47 | * | 51 | * |
48 | * | 52 | * |
49 | */ | 53 | */ |
50 | 54 | ||
51 | #include "ocontactaccess.h" | 55 | #include "ocontactaccess.h" |
52 | #include "obackendfactory.h" | 56 | #include "obackendfactory.h" |
53 | 57 | ||
54 | #include <qasciidict.h> | 58 | #include <qasciidict.h> |
55 | #include <qdatetime.h> | 59 | #include <qdatetime.h> |
56 | #include <qfile.h> | 60 | #include <qfile.h> |
57 | #include <qregexp.h> | 61 | #include <qregexp.h> |
58 | #include <qlist.h> | 62 | #include <qlist.h> |
59 | #include <qcopchannel_qws.h> | 63 | #include <qcopchannel_qws.h> |
60 | 64 | ||
61 | //#include <qpe/qcopenvelope_qws.h> | 65 | //#include <qpe/qcopenvelope_qws.h> |
62 | #include <qpe/global.h> | 66 | #include <qpe/global.h> |
63 | 67 | ||
64 | #include <errno.h> | 68 | #include <errno.h> |
65 | #include <fcntl.h> | 69 | #include <fcntl.h> |
66 | #include <unistd.h> | 70 | #include <unistd.h> |
67 | #include <stdlib.h> | 71 | #include <stdlib.h> |
68 | 72 | ||
69 | #include "ocontactaccessbackend_xml.h" | 73 | #include "ocontactaccessbackend_xml.h" |
70 | 74 | ||
71 | 75 | ||
72 | OContactAccess::OContactAccess ( const QString appname, const QString , | 76 | OContactAccess::OContactAccess ( const QString appname, const QString , |
73 | OContactAccessBackend* end, bool autosync ): | 77 | OContactAccessBackend* end, bool autosync ): |
74 | OPimAccessTemplate<OContact>( end ) | 78 | OPimAccessTemplate<OContact>( end ) |
75 | { | 79 | { |
76 | /* take care of the backend. If there is no one defined, we | 80 | /* take care of the backend. If there is no one defined, we |
77 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). | 81 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). |
78 | */ | 82 | */ |
79 | if( end == 0 ) { | 83 | if( end == 0 ) { |
80 | qWarning ("Using BackendFactory !"); | 84 | qWarning ("Using BackendFactory !"); |
81 | end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); | 85 | end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); |
82 | } | 86 | } |
83 | // Set backend locally and in template | 87 | // Set backend locally and in template |
84 | m_backEnd = end; | 88 | m_backEnd = end; |
85 | OPimAccessTemplate<OContact>::setBackEnd (end); | 89 | OPimAccessTemplate<OContact>::setBackEnd (end); |
86 | 90 | ||
87 | 91 | ||
88 | /* Connect signal of external db change to function */ | 92 | /* Connect signal of external db change to function */ |
89 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); | 93 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); |
90 | connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), | 94 | connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), |
91 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); | 95 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); |
92 | if ( autosync ){ | 96 | if ( autosync ){ |
93 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); | 97 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); |
94 | connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), | 98 | connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), |
95 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); | 99 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); |
96 | } | 100 | } |
97 | 101 | ||
98 | 102 | ||
99 | } | 103 | } |
100 | OContactAccess::~OContactAccess () | 104 | OContactAccess::~OContactAccess () |
101 | { | 105 | { |
102 | /* The user may forget to save the changed database, therefore try to | 106 | /* The user may forget to save the changed database, therefore try to |
103 | * do it for him.. | 107 | * do it for him.. |
104 | */ | 108 | */ |
105 | save(); | 109 | save(); |
106 | // delete m_backEnd; is done by template.. | 110 | // delete m_backEnd; is done by template.. |
107 | } | 111 | } |
108 | 112 | ||
109 | 113 | ||
110 | bool OContactAccess::save () | 114 | bool OContactAccess::save () |
111 | { | 115 | { |
112 | /* If the database was changed externally, we could not save the | 116 | /* If the database was changed externally, we could not save the |
113 | * Data. This will remove added items which is unacceptable ! | 117 | * Data. This will remove added items which is unacceptable ! |
114 | * Therefore: Reload database and merge the data... | 118 | * Therefore: Reload database and merge the data... |
115 | */ | 119 | */ |
116 | if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) | 120 | if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) |
117 | reload(); | 121 | reload(); |
118 | 122 | ||
119 | bool status = OPimAccessTemplate<OContact>::save(); | 123 | bool status = OPimAccessTemplate<OContact>::save(); |
120 | if ( !status ) return false; | 124 | if ( !status ) return false; |
121 | 125 | ||
122 | /* Now tell everyone that new data is available. | 126 | /* Now tell everyone that new data is available. |
123 | */ | 127 | */ |
124 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); | 128 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); |
125 | 129 | ||
126 | return true; | 130 | return true; |
127 | } | 131 | } |
128 | 132 | ||
129 | ORecordList<OContact> OContactAccess::matchRegexp( const QRegExp &r ) const{ | ||
130 | QArray<int> matchingContacts = m_backEnd -> matchRegexp( r ); | ||
131 | return ( ORecordList<OContact>(matchingContacts, this) ); | ||
132 | } | ||
133 | |||
134 | const uint OContactAccess::querySettings() | 133 | const uint OContactAccess::querySettings() |
135 | { | 134 | { |
136 | return ( m_backEnd->querySettings() ); | 135 | return ( m_backEnd->querySettings() ); |
137 | } | 136 | } |
138 | 137 | ||
139 | bool OContactAccess::hasQuerySettings ( int querySettings ) const | 138 | bool OContactAccess::hasQuerySettings ( int querySettings ) const |
140 | { | 139 | { |
141 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); | 140 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); |
142 | } | 141 | } |
143 | ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const | 142 | ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const |
144 | { | 143 | { |
145 | QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); | 144 | QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); |
146 | return ( ORecordList<OContact>(matchingContacts, this) ); | 145 | return ( ORecordList<OContact>(matchingContacts, this) ); |
147 | } | 146 | } |
148 | 147 | ||
149 | 148 | ||
150 | bool OContactAccess::wasChangedExternally()const | 149 | bool OContactAccess::wasChangedExternally()const |
151 | { | 150 | { |
152 | return ( m_backEnd->wasChangedExternally() ); | 151 | return ( m_backEnd->wasChangedExternally() ); |
153 | } | 152 | } |
154 | 153 | ||
155 | 154 | ||
156 | void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) | 155 | void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) |
157 | { | 156 | { |
158 | if ( msg == "addressbookUpdated()" ){ | 157 | if ( msg == "addressbookUpdated()" ){ |
159 | qWarning ("OContactAccess: Received addressbokUpdated()"); | 158 | qWarning ("OContactAccess: Received addressbokUpdated()"); |
160 | emit signalChanged ( this ); | 159 | emit signalChanged ( this ); |
161 | } else if ( msg == "flush()" ) { | 160 | } else if ( msg == "flush()" ) { |
162 | qWarning ("OContactAccess: Received flush()"); | 161 | qWarning ("OContactAccess: Received flush()"); |
163 | save (); | 162 | save (); |
164 | } else if ( msg == "reload()" ) { | 163 | } else if ( msg == "reload()" ) { |
165 | qWarning ("OContactAccess: Received reload()"); | 164 | qWarning ("OContactAccess: Received reload()"); |
166 | reload (); | 165 | reload (); |
167 | emit signalChanged ( this ); | 166 | emit signalChanged ( this ); |
168 | } | 167 | } |
169 | } | 168 | } |
diff --git a/libopie/pim/ocontactaccess.h b/libopie/pim/ocontactaccess.h index d7ceaf2..e90db32 100644 --- a/libopie/pim/ocontactaccess.h +++ b/libopie/pim/ocontactaccess.h | |||
@@ -1,168 +1,170 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage the Contacts. | 2 | * Class to manage the Contacts. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) | 5 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) |
6 | * | 6 | * |
7 | * ===================================================================== | 7 | * ===================================================================== |
8 | *This program is free software; you can redistribute it and/or | 8 | *This program is free software; you can redistribute it and/or |
9 | *modify it under the terms of the GNU Library General Public | 9 | *modify it under the terms of the GNU Library General Public |
10 | * License as published by the Free Software Foundation; | 10 | * License as published by the Free Software Foundation; |
11 | * either version 2 of the License, or (at your option) any later | 11 | * either version 2 of the License, or (at your option) any later |
12 | * version. | 12 | * version. |
13 | * ===================================================================== | 13 | * ===================================================================== |
14 | * ToDo: Define enum for query settings | 14 | * ToDo: Define enum for query settings |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * Version: $Id$ | 16 | * Version: $Id$ |
17 | * ===================================================================== | 17 | * ===================================================================== |
18 | * History: | 18 | * History: |
19 | * $Log$ | 19 | * $Log$ |
20 | * Revision 1.8 2003/05/08 13:55:09 tille | ||
21 | * search stuff | ||
22 | * and match, toRichText & toShortText in oevent | ||
23 | * | ||
20 | * Revision 1.7 2003/04/13 18:07:10 zecke | 24 | * Revision 1.7 2003/04/13 18:07:10 zecke |
21 | * More API doc | 25 | * More API doc |
22 | * QString -> const QString& | 26 | * QString -> const QString& |
23 | * QString = 0l -> QString::null | 27 | * QString = 0l -> QString::null |
24 | * | 28 | * |
25 | * Revision 1.6 2003/01/02 14:27:12 eilers | 29 | * Revision 1.6 2003/01/02 14:27:12 eilers |
26 | * Improved query by example: Search by date is possible.. First step | 30 | * Improved query by example: Search by date is possible.. First step |
27 | * for a today plugin for birthdays.. | 31 | * for a today plugin for birthdays.. |
28 | * | 32 | * |
29 | * Revision 1.5 2002/11/13 14:14:51 eilers | 33 | * Revision 1.5 2002/11/13 14:14:51 eilers |
30 | * Added sorted for Contacts.. | 34 | * Added sorted for Contacts.. |
31 | * | 35 | * |
32 | * Revision 1.4 2002/11/01 15:10:42 eilers | 36 | * Revision 1.4 2002/11/01 15:10:42 eilers |
33 | * Added regExp-search in database for all fields in a contact. | 37 | * Added regExp-search in database for all fields in a contact. |
34 | * | 38 | * |
35 | * Revision 1.3 2002/10/16 10:52:40 eilers | 39 | * Revision 1.3 2002/10/16 10:52:40 eilers |
36 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | 40 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) |
37 | * | 41 | * |
38 | * Revision 1.2 2002/10/14 16:21:54 eilers | 42 | * Revision 1.2 2002/10/14 16:21:54 eilers |
39 | * Some minor interface updates | 43 | * Some minor interface updates |
40 | * | 44 | * |
41 | * Revision 1.1 2002/09/27 17:11:44 eilers | 45 | * Revision 1.1 2002/09/27 17:11:44 eilers |
42 | * Added API for accessing the Contact-Database ! It is compiling, but | 46 | * Added API for accessing the Contact-Database ! It is compiling, but |
43 | * please do not expect that anything is working ! | 47 | * please do not expect that anything is working ! |
44 | * I will debug that stuff in the next time .. | 48 | * I will debug that stuff in the next time .. |
45 | * Please read README_COMPILE for compiling ! | 49 | * Please read README_COMPILE for compiling ! |
46 | * | 50 | * |
47 | * ===================================================================== | 51 | * ===================================================================== |
48 | */ | 52 | */ |
49 | #ifndef _OCONTACTACCESS_H | 53 | #ifndef _OCONTACTACCESS_H |
50 | #define _OCONTACTACCESS_H | 54 | #define _OCONTACTACCESS_H |
51 | 55 | ||
52 | #include <qobject.h> | 56 | #include <qobject.h> |
53 | 57 | ||
54 | #include <qpe/qcopenvelope_qws.h> | 58 | #include <qpe/qcopenvelope_qws.h> |
55 | 59 | ||
56 | #include <qvaluelist.h> | 60 | #include <qvaluelist.h> |
57 | #include <qfileinfo.h> | 61 | #include <qfileinfo.h> |
58 | 62 | ||
59 | #include "ocontact.h" | 63 | #include "ocontact.h" |
60 | #include "ocontactaccessbackend.h" | 64 | #include "ocontactaccessbackend.h" |
61 | #include "opimaccesstemplate.h" | 65 | #include "opimaccesstemplate.h" |
62 | 66 | ||
63 | /** | 67 | /** |
64 | * Class to access the contacts database. | 68 | * Class to access the contacts database. |
65 | * This is just a frontend for the real database handling which is | 69 | * This is just a frontend for the real database handling which is |
66 | * done by the backend. | 70 | * done by the backend. |
67 | * This class is used to access the Contacts on a system. This class as any OPIE PIM | 71 | * This class is used to access the Contacts on a system. This class as any OPIE PIM |
68 | * class is backend independent. | 72 | * class is backend independent. |
69 | 73 | ||
70 | * @see OPimAccessTemplate | 74 | * @see OPimAccessTemplate |
71 | */ | 75 | */ |
72 | class OContactAccess: public QObject, public OPimAccessTemplate<OContact> | 76 | class OContactAccess: public QObject, public OPimAccessTemplate<OContact> |
73 | { | 77 | { |
74 | Q_OBJECT | 78 | Q_OBJECT |
75 | 79 | ||
76 | public: | 80 | public: |
77 | /** | 81 | /** |
78 | * Create Database with contacts (addressbook). | 82 | * Create Database with contacts (addressbook). |
79 | * @param appname Name of application which wants access to the database | 83 | * @param appname Name of application which wants access to the database |
80 | * (i.e. "todolist") | 84 | * (i.e. "todolist") |
81 | * @param filename The name of the database file. If not set, the default one | 85 | * @param filename The name of the database file. If not set, the default one |
82 | * is used. | 86 | * is used. |
83 | * @param backend Pointer to an alternative Backend. If not set, we will use | 87 | * @param backend Pointer to an alternative Backend. If not set, we will use |
84 | * the default backend. | 88 | * the default backend. |
85 | * @param handlesync If <b>true</b> the database stores the current state | 89 | * @param handlesync If <b>true</b> the database stores the current state |
86 | * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> | 90 | * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> |
87 | * which are used before and after synchronisation. If the application wants | 91 | * which are used before and after synchronisation. If the application wants |
88 | * to react itself, it should be disabled by setting it to <b>false</b> | 92 | * to react itself, it should be disabled by setting it to <b>false</b> |
89 | * @see OContactAccessBackend | 93 | * @see OContactAccessBackend |
90 | */ | 94 | */ |
91 | OContactAccess (const QString appname, const QString filename = 0l, | 95 | OContactAccess (const QString appname, const QString filename = 0l, |
92 | OContactAccessBackend* backend = 0l, bool handlesync = true); | 96 | OContactAccessBackend* backend = 0l, bool handlesync = true); |
93 | ~OContactAccess (); | 97 | ~OContactAccess (); |
94 | 98 | ||
95 | /** Constants for query. | 99 | /** Constants for query. |
96 | * Use this constants to set the query parameters. | 100 | * Use this constants to set the query parameters. |
97 | * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! | 101 | * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! |
98 | * @see queryByExample() | 102 | * @see queryByExample() |
99 | */ | 103 | */ |
100 | enum QuerySettings { | 104 | enum QuerySettings { |
101 | WildCards = 0x0001, | 105 | WildCards = 0x0001, |
102 | IgnoreCase = 0x0002, | 106 | IgnoreCase = 0x0002, |
103 | RegExp = 0x0004, | 107 | RegExp = 0x0004, |
104 | ExactMatch = 0x0008, | 108 | ExactMatch = 0x0008, |
105 | MatchOne = 0x0010, // Only one Entry must match | 109 | MatchOne = 0x0010, // Only one Entry must match |
106 | DateDiff = 0x0020, // Find all entries from today until given date | 110 | DateDiff = 0x0020, // Find all entries from today until given date |
107 | DateYear = 0x0040, // The year matches | 111 | DateYear = 0x0040, // The year matches |
108 | DateMonth = 0x0080, // The month matches | 112 | DateMonth = 0x0080, // The month matches |
109 | DateDay = 0x0100, // The day matches | 113 | DateDay = 0x0100, // The day matches |
110 | }; | 114 | }; |
111 | 115 | ||
112 | 116 | ||
113 | ORecordList<OContact> matchRegexp( const QRegExp &r )const; | ||
114 | |||
115 | /** Return all Contacts in a sorted manner. | 117 | /** Return all Contacts in a sorted manner. |
116 | * @param ascending true: Sorted in acending order. | 118 | * @param ascending true: Sorted in acending order. |
117 | * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess | 119 | * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess |
118 | * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess | 120 | * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess |
119 | * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess | 121 | * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess |
120 | */ | 122 | */ |
121 | List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; | 123 | List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; |
122 | 124 | ||
123 | /** Return all possible settings. | 125 | /** Return all possible settings. |
124 | * @return All settings provided by the current backend | 126 | * @return All settings provided by the current backend |
125 | * (i.e.: query_WildCards & query_IgnoreCase) | 127 | * (i.e.: query_WildCards & query_IgnoreCase) |
126 | */ | 128 | */ |
127 | const uint querySettings(); | 129 | const uint querySettings(); |
128 | 130 | ||
129 | /** Check whether settings are correct. | 131 | /** Check whether settings are correct. |
130 | * @return <i>true</i> if the given settings are correct and possible. | 132 | * @return <i>true</i> if the given settings are correct and possible. |
131 | */ | 133 | */ |
132 | bool hasQuerySettings ( int querySettings ) const; | 134 | bool hasQuerySettings ( int querySettings ) const; |
133 | 135 | ||
134 | /** | 136 | /** |
135 | * if the resource was changed externally. | 137 | * if the resource was changed externally. |
136 | * You should use the signal instead of polling possible changes ! | 138 | * You should use the signal instead of polling possible changes ! |
137 | */ | 139 | */ |
138 | bool wasChangedExternally()const; | 140 | bool wasChangedExternally()const; |
139 | 141 | ||
140 | 142 | ||
141 | /** Save contacts database. | 143 | /** Save contacts database. |
142 | * Save is more a "commit". After calling this function, all changes are public available. | 144 | * Save is more a "commit". After calling this function, all changes are public available. |
143 | * @return true if successful | 145 | * @return true if successful |
144 | */ | 146 | */ |
145 | bool save(); | 147 | bool save(); |
146 | 148 | ||
147 | signals: | 149 | signals: |
148 | /* Signal is emitted if the database was changed. Therefore | 150 | /* Signal is emitted if the database was changed. Therefore |
149 | * we may need to reload to stay consistent. | 151 | * we may need to reload to stay consistent. |
150 | * @param which Pointer to the database who created this event. This pointer | 152 | * @param which Pointer to the database who created this event. This pointer |
151 | * is useful if an application has to handle multiple databases at the same time. | 153 | * is useful if an application has to handle multiple databases at the same time. |
152 | * @see reload() | 154 | * @see reload() |
153 | */ | 155 | */ |
154 | void signalChanged ( const OContactAccess *which ); | 156 | void signalChanged ( const OContactAccess *which ); |
155 | 157 | ||
156 | 158 | ||
157 | private: | 159 | private: |
158 | // class OContactAccessPrivate; | 160 | // class OContactAccessPrivate; |
159 | // OContactAccessPrivate* d; | 161 | // OContactAccessPrivate* d; |
160 | OContactAccessBackend *m_backEnd; | 162 | OContactAccessBackend *m_backEnd; |
161 | bool m_loading:1; | 163 | bool m_loading:1; |
162 | 164 | ||
163 | private slots: | 165 | private slots: |
164 | void copMessage( const QCString &msg, const QByteArray &data ); | 166 | void copMessage( const QCString &msg, const QByteArray &data ); |
165 | 167 | ||
166 | 168 | ||
167 | }; | 169 | }; |
168 | #endif | 170 | #endif |
diff --git a/libopie/pim/odatebookaccessbackend_xml.cpp b/libopie/pim/odatebookaccessbackend_xml.cpp index a0ae7b7..ab2eea4 100644 --- a/libopie/pim/odatebookaccessbackend_xml.cpp +++ b/libopie/pim/odatebookaccessbackend_xml.cpp | |||
@@ -493,96 +493,114 @@ void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& val | |||
493 | case FDescription: | 493 | case FDescription: |
494 | e.setDescription( value ); | 494 | e.setDescription( value ); |
495 | break; | 495 | break; |
496 | case FLocation: | 496 | case FLocation: |
497 | e.setLocation( value ); | 497 | e.setLocation( value ); |
498 | break; | 498 | break; |
499 | case FCategories: | 499 | case FCategories: |
500 | e.setCategories( e.idsFromString( value ) ); | 500 | e.setCategories( e.idsFromString( value ) ); |
501 | break; | 501 | break; |
502 | case FUid: | 502 | case FUid: |
503 | e.setUid( value.toInt() ); | 503 | e.setUid( value.toInt() ); |
504 | break; | 504 | break; |
505 | case FType: | 505 | case FType: |
506 | if ( value == "AllDay" ) { | 506 | if ( value == "AllDay" ) { |
507 | e.setAllDay( true ); | 507 | e.setAllDay( true ); |
508 | e.setTimeZone( "UTC" ); | 508 | e.setTimeZone( "UTC" ); |
509 | } | 509 | } |
510 | break; | 510 | break; |
511 | case FAlarm: | 511 | case FAlarm: |
512 | alarmTime = value.toInt(); | 512 | alarmTime = value.toInt(); |
513 | break; | 513 | break; |
514 | case FSound: | 514 | case FSound: |
515 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; | 515 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; |
516 | break; | 516 | break; |
517 | // recurrence stuff | 517 | // recurrence stuff |
518 | case FRType: | 518 | case FRType: |
519 | if ( value == "Daily" ) | 519 | if ( value == "Daily" ) |
520 | recur()->setType( ORecur::Daily ); | 520 | recur()->setType( ORecur::Daily ); |
521 | else if ( value == "Weekly" ) | 521 | else if ( value == "Weekly" ) |
522 | recur()->setType( ORecur::Weekly); | 522 | recur()->setType( ORecur::Weekly); |
523 | else if ( value == "MonthlyDay" ) | 523 | else if ( value == "MonthlyDay" ) |
524 | recur()->setType( ORecur::MonthlyDay ); | 524 | recur()->setType( ORecur::MonthlyDay ); |
525 | else if ( value == "MonthlyDate" ) | 525 | else if ( value == "MonthlyDate" ) |
526 | recur()->setType( ORecur::MonthlyDate ); | 526 | recur()->setType( ORecur::MonthlyDate ); |
527 | else if ( value == "Yearly" ) | 527 | else if ( value == "Yearly" ) |
528 | recur()->setType( ORecur::Yearly ); | 528 | recur()->setType( ORecur::Yearly ); |
529 | else | 529 | else |
530 | recur()->setType( ORecur::NoRepeat ); | 530 | recur()->setType( ORecur::NoRepeat ); |
531 | break; | 531 | break; |
532 | case FRWeekdays: | 532 | case FRWeekdays: |
533 | recur()->setDays( value.toInt() ); | 533 | recur()->setDays( value.toInt() ); |
534 | break; | 534 | break; |
535 | case FRPosition: | 535 | case FRPosition: |
536 | recur()->setPosition( value.toInt() ); | 536 | recur()->setPosition( value.toInt() ); |
537 | break; | 537 | break; |
538 | case FRFreq: | 538 | case FRFreq: |
539 | recur()->setFrequency( value.toInt() ); | 539 | recur()->setFrequency( value.toInt() ); |
540 | break; | 540 | break; |
541 | case FRHasEndDate: | 541 | case FRHasEndDate: |
542 | recur()->setHasEndDate( value.toInt() ); | 542 | recur()->setHasEndDate( value.toInt() ); |
543 | break; | 543 | break; |
544 | case FREndDate: { | 544 | case FREndDate: { |
545 | rp_end = (time_t) value.toLong(); | 545 | rp_end = (time_t) value.toLong(); |
546 | break; | 546 | break; |
547 | } | 547 | } |
548 | case FRStart: { | 548 | case FRStart: { |
549 | start = (time_t) value.toLong(); | 549 | start = (time_t) value.toLong(); |
550 | break; | 550 | break; |
551 | } | 551 | } |
552 | case FREnd: { | 552 | case FREnd: { |
553 | end = ( (time_t) value.toLong() ); | 553 | end = ( (time_t) value.toLong() ); |
554 | break; | 554 | break; |
555 | } | 555 | } |
556 | case FNote: | 556 | case FNote: |
557 | e.setNote( value ); | 557 | e.setNote( value ); |
558 | break; | 558 | break; |
559 | case FCreated: | 559 | case FCreated: |
560 | created = value.toInt(); | 560 | created = value.toInt(); |
561 | break; | 561 | break; |
562 | case FRecParent: | 562 | case FRecParent: |
563 | e.setParent( value.toInt() ); | 563 | e.setParent( value.toInt() ); |
564 | break; | 564 | break; |
565 | case FRecChildren:{ | 565 | case FRecChildren:{ |
566 | QStringList list = QStringList::split(' ', value ); | 566 | QStringList list = QStringList::split(' ', value ); |
567 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 567 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
568 | e.addChild( (*it).toInt() ); | 568 | e.addChild( (*it).toInt() ); |
569 | } | 569 | } |
570 | } | 570 | } |
571 | break; | 571 | break; |
572 | case FExceptions:{ | 572 | case FExceptions:{ |
573 | QStringList list = QStringList::split(' ', value ); | 573 | QStringList list = QStringList::split(' ', value ); |
574 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 574 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
575 | QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() ); | 575 | QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() ); |
576 | qWarning("adding exception %s", date.toString().latin1() ); | 576 | qWarning("adding exception %s", date.toString().latin1() ); |
577 | recur()->exceptions().append( date ); | 577 | recur()->exceptions().append( date ); |
578 | } | 578 | } |
579 | } | 579 | } |
580 | break; | 580 | break; |
581 | case FTimeZone: | 581 | case FTimeZone: |
582 | if ( value != "None" ) | 582 | if ( value != "None" ) |
583 | e.setTimeZone( value ); | 583 | e.setTimeZone( value ); |
584 | break; | 584 | break; |
585 | default: | 585 | default: |
586 | break; | 586 | break; |
587 | } | 587 | } |
588 | } | 588 | } |
589 | QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const | ||
590 | { | ||
591 | QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() ); | ||
592 | uint arraycounter = 0; | ||
593 | QMap<int, OEvent>::ConstIterator it; | ||
594 | |||
595 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) | ||
596 | if ( it.data().match( r ) ) | ||
597 | m_currentQuery[arraycounter++] = it.data().uid(); | ||
598 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) | ||
599 | if ( it.data().match( r ) ) | ||
600 | m_currentQuery[arraycounter++] = it.data().uid(); | ||
601 | |||
602 | // Shrink to fit.. | ||
603 | m_currentQuery.resize(arraycounter); | ||
604 | |||
605 | return m_currentQuery; | ||
606 | } | ||
diff --git a/libopie/pim/odatebookaccessbackend_xml.h b/libopie/pim/odatebookaccessbackend_xml.h index 7848f7c..a5cc0fc 100644 --- a/libopie/pim/odatebookaccessbackend_xml.h +++ b/libopie/pim/odatebookaccessbackend_xml.h | |||
@@ -1,54 +1,55 @@ | |||
1 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H | 1 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H |
2 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H | 2 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H |
3 | 3 | ||
4 | #include <qmap.h> | 4 | #include <qmap.h> |
5 | 5 | ||
6 | #include "odatebookaccessbackend.h" | 6 | #include "odatebookaccessbackend.h" |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * This is the default XML implementation for DateBoook XML storage | 9 | * This is the default XML implementation for DateBoook XML storage |
10 | * It fully implements the interface | 10 | * It fully implements the interface |
11 | * @see ODateBookAccessBackend | 11 | * @see ODateBookAccessBackend |
12 | * @see OPimAccessBackend | 12 | * @see OPimAccessBackend |
13 | */ | 13 | */ |
14 | class ODateBookAccessBackend_XML : public ODateBookAccessBackend { | 14 | class ODateBookAccessBackend_XML : public ODateBookAccessBackend { |
15 | public: | 15 | public: |
16 | ODateBookAccessBackend_XML( const QString& appName, | 16 | ODateBookAccessBackend_XML( const QString& appName, |
17 | const QString& fileName = QString::null); | 17 | const QString& fileName = QString::null); |
18 | ~ODateBookAccessBackend_XML(); | 18 | ~ODateBookAccessBackend_XML(); |
19 | 19 | ||
20 | bool load(); | 20 | bool load(); |
21 | bool reload(); | 21 | bool reload(); |
22 | bool save(); | 22 | bool save(); |
23 | 23 | ||
24 | QArray<int> allRecords()const; | 24 | QArray<int> allRecords()const; |
25 | QArray<int> matchRegexp(const QRegExp &r) const; | ||
25 | QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); | 26 | QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); |
26 | OEvent find( int uid )const; | 27 | OEvent find( int uid )const; |
27 | void clear(); | 28 | void clear(); |
28 | bool add( const OEvent& ev ); | 29 | bool add( const OEvent& ev ); |
29 | bool remove( int uid ); | 30 | bool remove( int uid ); |
30 | bool replace( const OEvent& ev ); | 31 | bool replace( const OEvent& ev ); |
31 | 32 | ||
32 | QArray<UID> rawEvents()const; | 33 | QArray<UID> rawEvents()const; |
33 | QArray<UID> rawRepeats()const; | 34 | QArray<UID> rawRepeats()const; |
34 | QArray<UID> nonRepeats()const; | 35 | QArray<UID> nonRepeats()const; |
35 | 36 | ||
36 | OEvent::ValueList directNonRepeats(); | 37 | OEvent::ValueList directNonRepeats(); |
37 | OEvent::ValueList directRawRepeats(); | 38 | OEvent::ValueList directRawRepeats(); |
38 | 39 | ||
39 | private: | 40 | private: |
40 | bool m_changed :1 ; | 41 | bool m_changed :1 ; |
41 | bool loadFile(); | 42 | bool loadFile(); |
42 | inline void finalizeRecord( OEvent& ev ); | 43 | inline void finalizeRecord( OEvent& ev ); |
43 | inline void setField( OEvent&, int field, const QString& val ); | 44 | inline void setField( OEvent&, int field, const QString& val ); |
44 | QString m_name; | 45 | QString m_name; |
45 | QMap<int, OEvent> m_raw; | 46 | QMap<int, OEvent> m_raw; |
46 | QMap<int, OEvent> m_rep; | 47 | QMap<int, OEvent> m_rep; |
47 | 48 | ||
48 | struct Data; | 49 | struct Data; |
49 | Data* data; | 50 | Data* data; |
50 | class Private; | 51 | class Private; |
51 | Private *d; | 52 | Private *d; |
52 | }; | 53 | }; |
53 | 54 | ||
54 | #endif | 55 | #endif |
diff --git a/libopie/pim/oevent.cpp b/libopie/pim/oevent.cpp index 3ba8a52..28cf873 100644 --- a/libopie/pim/oevent.cpp +++ b/libopie/pim/oevent.cpp | |||
@@ -1,100 +1,101 @@ | |||
1 | #include <qshared.h> | 1 | #include <qshared.h> |
2 | 2 | ||
3 | #include <qpe/palmtopuidgen.h> | 3 | #include <qpe/palmtopuidgen.h> |
4 | #include <qpe/categories.h> | 4 | #include <qpe/categories.h> |
5 | #include <qpe/stringutil.h> | ||
5 | 6 | ||
6 | #include "orecur.h" | 7 | #include "orecur.h" |
7 | #include "opimresolver.h" | 8 | #include "opimresolver.h" |
8 | #include "opimnotifymanager.h" | 9 | #include "opimnotifymanager.h" |
9 | 10 | ||
10 | #include "oevent.h" | 11 | #include "oevent.h" |
11 | 12 | ||
12 | int OCalendarHelper::week( const QDate& date) { | 13 | int OCalendarHelper::week( const QDate& date) { |
13 | // Calculates the week this date is in within that | 14 | // Calculates the week this date is in within that |
14 | // month. Equals the "row" is is in in the month view | 15 | // month. Equals the "row" is is in in the month view |
15 | int week = 1; | 16 | int week = 1; |
16 | QDate tmp( date.year(), date.month(), 1 ); | 17 | QDate tmp( date.year(), date.month(), 1 ); |
17 | if ( date.dayOfWeek() < tmp.dayOfWeek() ) | 18 | if ( date.dayOfWeek() < tmp.dayOfWeek() ) |
18 | ++week; | 19 | ++week; |
19 | 20 | ||
20 | week += ( date.day() - 1 ) / 7; | 21 | week += ( date.day() - 1 ) / 7; |
21 | 22 | ||
22 | return week; | 23 | return week; |
23 | } | 24 | } |
24 | int OCalendarHelper::ocurrence( const QDate& date) { | 25 | int OCalendarHelper::ocurrence( const QDate& date) { |
25 | // calculates the number of occurrances of this day of the | 26 | // calculates the number of occurrances of this day of the |
26 | // week till the given date (e.g 3rd Wednesday of the month) | 27 | // week till the given date (e.g 3rd Wednesday of the month) |
27 | return ( date.day() - 1 ) / 7 + 1; | 28 | return ( date.day() - 1 ) / 7 + 1; |
28 | } | 29 | } |
29 | int OCalendarHelper::dayOfWeek( char day ) { | 30 | int OCalendarHelper::dayOfWeek( char day ) { |
30 | int dayOfWeek = 1; | 31 | int dayOfWeek = 1; |
31 | char i = ORecur::MON; | 32 | char i = ORecur::MON; |
32 | while ( !( i & day ) && i <= ORecur::SUN ) { | 33 | while ( !( i & day ) && i <= ORecur::SUN ) { |
33 | i <<= 1; | 34 | i <<= 1; |
34 | ++dayOfWeek; | 35 | ++dayOfWeek; |
35 | } | 36 | } |
36 | return dayOfWeek; | 37 | return dayOfWeek; |
37 | } | 38 | } |
38 | int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { | 39 | int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { |
39 | return ( second.year() - first.year() ) * 12 + | 40 | return ( second.year() - first.year() ) * 12 + |
40 | second.month() - first.month(); | 41 | second.month() - first.month(); |
41 | } | 42 | } |
42 | 43 | ||
43 | struct OEvent::Data : public QShared { | 44 | struct OEvent::Data : public QShared { |
44 | Data() : QShared() { | 45 | Data() : QShared() { |
45 | child = 0; | 46 | child = 0; |
46 | recur = 0; | 47 | recur = 0; |
47 | manager = 0; | 48 | manager = 0; |
48 | isAllDay = false; | 49 | isAllDay = false; |
49 | parent = 0; | 50 | parent = 0; |
50 | } | 51 | } |
51 | ~Data() { | 52 | ~Data() { |
52 | delete manager; | 53 | delete manager; |
53 | delete recur; | 54 | delete recur; |
54 | } | 55 | } |
55 | QString description; | 56 | QString description; |
56 | QString location; | 57 | QString location; |
57 | OPimNotifyManager* manager; | 58 | OPimNotifyManager* manager; |
58 | ORecur* recur; | 59 | ORecur* recur; |
59 | QString note; | 60 | QString note; |
60 | QDateTime created; | 61 | QDateTime created; |
61 | QDateTime start; | 62 | QDateTime start; |
62 | QDateTime end; | 63 | QDateTime end; |
63 | bool isAllDay : 1; | 64 | bool isAllDay : 1; |
64 | QString timezone; | 65 | QString timezone; |
65 | QArray<int>* child; | 66 | QArray<int>* child; |
66 | int parent; | 67 | int parent; |
67 | }; | 68 | }; |
68 | 69 | ||
69 | OEvent::OEvent( int uid ) | 70 | OEvent::OEvent( int uid ) |
70 | : OPimRecord( uid ) { | 71 | : OPimRecord( uid ) { |
71 | data = new Data; | 72 | data = new Data; |
72 | } | 73 | } |
73 | OEvent::OEvent( const OEvent& ev) | 74 | OEvent::OEvent( const OEvent& ev) |
74 | : OPimRecord( ev ), data( ev.data ) | 75 | : OPimRecord( ev ), data( ev.data ) |
75 | { | 76 | { |
76 | data->ref(); | 77 | data->ref(); |
77 | } | 78 | } |
78 | OEvent::~OEvent() { | 79 | OEvent::~OEvent() { |
79 | if ( data->deref() ) { | 80 | if ( data->deref() ) { |
80 | delete data; | 81 | delete data; |
81 | data = 0; | 82 | data = 0; |
82 | } | 83 | } |
83 | } | 84 | } |
84 | OEvent& OEvent::operator=( const OEvent& ev) { | 85 | OEvent& OEvent::operator=( const OEvent& ev) { |
85 | if ( this == &ev ) return *this; | 86 | if ( this == &ev ) return *this; |
86 | 87 | ||
87 | OPimRecord::operator=( ev ); | 88 | OPimRecord::operator=( ev ); |
88 | ev.data->ref(); | 89 | ev.data->ref(); |
89 | deref(); | 90 | deref(); |
90 | data = ev.data; | 91 | data = ev.data; |
91 | 92 | ||
92 | 93 | ||
93 | return *this; | 94 | return *this; |
94 | } | 95 | } |
95 | QString OEvent::description()const { | 96 | QString OEvent::description()const { |
96 | return data->description; | 97 | return data->description; |
97 | } | 98 | } |
98 | void OEvent::setDescription( const QString& description ) { | 99 | void OEvent::setDescription( const QString& description ) { |
99 | changeOrModify(); | 100 | changeOrModify(); |
100 | data->description = description; | 101 | data->description = description; |
@@ -117,202 +118,232 @@ OPimNotifyManager &OEvent::notifiers()const { | |||
117 | } | 118 | } |
118 | bool OEvent::hasNotifiers()const { | 119 | bool OEvent::hasNotifiers()const { |
119 | if (!data->manager ) | 120 | if (!data->manager ) |
120 | return false; | 121 | return false; |
121 | if (data->manager->reminders().isEmpty() && | 122 | if (data->manager->reminders().isEmpty() && |
122 | data->manager->alarms().isEmpty() ) | 123 | data->manager->alarms().isEmpty() ) |
123 | return false; | 124 | return false; |
124 | 125 | ||
125 | return true; | 126 | return true; |
126 | } | 127 | } |
127 | ORecur OEvent::recurrence()const { | 128 | ORecur OEvent::recurrence()const { |
128 | if (!data->recur) | 129 | if (!data->recur) |
129 | data->recur = new ORecur; | 130 | data->recur = new ORecur; |
130 | 131 | ||
131 | return *data->recur; | 132 | return *data->recur; |
132 | } | 133 | } |
133 | void OEvent::setRecurrence( const ORecur& rec) { | 134 | void OEvent::setRecurrence( const ORecur& rec) { |
134 | changeOrModify(); | 135 | changeOrModify(); |
135 | if (data->recur ) | 136 | if (data->recur ) |
136 | (*data->recur) = rec; | 137 | (*data->recur) = rec; |
137 | else | 138 | else |
138 | data->recur = new ORecur( rec ); | 139 | data->recur = new ORecur( rec ); |
139 | } | 140 | } |
140 | bool OEvent::hasRecurrence()const { | 141 | bool OEvent::hasRecurrence()const { |
141 | if (!data->recur ) return false; | 142 | if (!data->recur ) return false; |
142 | return data->recur->doesRecur(); | 143 | return data->recur->doesRecur(); |
143 | } | 144 | } |
144 | QString OEvent::note()const { | 145 | QString OEvent::note()const { |
145 | return data->note; | 146 | return data->note; |
146 | } | 147 | } |
147 | void OEvent::setNote( const QString& note ) { | 148 | void OEvent::setNote( const QString& note ) { |
148 | changeOrModify(); | 149 | changeOrModify(); |
149 | data->note = note; | 150 | data->note = note; |
150 | } | 151 | } |
151 | QDateTime OEvent::createdDateTime()const { | 152 | QDateTime OEvent::createdDateTime()const { |
152 | return data->created; | 153 | return data->created; |
153 | } | 154 | } |
154 | void OEvent::setCreatedDateTime( const QDateTime& time ) { | 155 | void OEvent::setCreatedDateTime( const QDateTime& time ) { |
155 | changeOrModify(); | 156 | changeOrModify(); |
156 | data->created = time; | 157 | data->created = time; |
157 | } | 158 | } |
158 | QDateTime OEvent::startDateTime()const { | 159 | QDateTime OEvent::startDateTime()const { |
159 | if ( data->isAllDay ) | 160 | if ( data->isAllDay ) |
160 | return QDateTime( data->start.date(), QTime(0, 0, 0 ) ); | 161 | return QDateTime( data->start.date(), QTime(0, 0, 0 ) ); |
161 | return data->start; | 162 | return data->start; |
162 | } | 163 | } |
163 | QDateTime OEvent::startDateTimeInZone()const { | 164 | QDateTime OEvent::startDateTimeInZone()const { |
164 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 165 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
165 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); | 166 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); |
166 | 167 | ||
167 | OTimeZone zone(data->timezone ); | 168 | OTimeZone zone(data->timezone ); |
168 | return zone.toDateTime( data->start, OTimeZone::current() ); | 169 | return zone.toDateTime( data->start, OTimeZone::current() ); |
169 | } | 170 | } |
170 | void OEvent::setStartDateTime( const QDateTime& dt ) { | 171 | void OEvent::setStartDateTime( const QDateTime& dt ) { |
171 | changeOrModify(); | 172 | changeOrModify(); |
172 | data->start = dt; | 173 | data->start = dt; |
173 | } | 174 | } |
174 | QDateTime OEvent::endDateTime()const { | 175 | QDateTime OEvent::endDateTime()const { |
175 | /* | 176 | /* |
176 | * if all Day event the end time needs | 177 | * if all Day event the end time needs |
177 | * to be on the same day as the start | 178 | * to be on the same day as the start |
178 | */ | 179 | */ |
179 | if ( data->isAllDay ) | 180 | if ( data->isAllDay ) |
180 | return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); | 181 | return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); |
181 | return data->end; | 182 | return data->end; |
182 | } | 183 | } |
183 | QDateTime OEvent::endDateTimeInZone()const { | 184 | QDateTime OEvent::endDateTimeInZone()const { |
184 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 185 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
185 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); | 186 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); |
186 | 187 | ||
187 | OTimeZone zone(data->timezone ); | 188 | OTimeZone zone(data->timezone ); |
188 | return zone.toDateTime( data->end, OTimeZone::current() ); | 189 | return zone.toDateTime( data->end, OTimeZone::current() ); |
189 | } | 190 | } |
190 | void OEvent::setEndDateTime( const QDateTime& dt ) { | 191 | void OEvent::setEndDateTime( const QDateTime& dt ) { |
191 | changeOrModify(); | 192 | changeOrModify(); |
192 | data->end = dt; | 193 | data->end = dt; |
193 | } | 194 | } |
194 | bool OEvent::isMultipleDay()const { | 195 | bool OEvent::isMultipleDay()const { |
195 | return data->end.date().day() - data->start.date().day(); | 196 | return data->end.date().day() - data->start.date().day(); |
196 | } | 197 | } |
197 | bool OEvent::isAllDay()const { | 198 | bool OEvent::isAllDay()const { |
198 | return data->isAllDay; | 199 | return data->isAllDay; |
199 | } | 200 | } |
200 | void OEvent::setAllDay( bool allDay ) { | 201 | void OEvent::setAllDay( bool allDay ) { |
201 | changeOrModify(); | 202 | changeOrModify(); |
202 | data->isAllDay = allDay; | 203 | data->isAllDay = allDay; |
203 | if (allDay ) data->timezone = "UTC"; | 204 | if (allDay ) data->timezone = "UTC"; |
204 | } | 205 | } |
205 | void OEvent::setTimeZone( const QString& tz ) { | 206 | void OEvent::setTimeZone( const QString& tz ) { |
206 | changeOrModify(); | 207 | changeOrModify(); |
207 | data->timezone = tz; | 208 | data->timezone = tz; |
208 | } | 209 | } |
209 | QString OEvent::timeZone()const { | 210 | QString OEvent::timeZone()const { |
210 | if (data->isAllDay ) return QString::fromLatin1("UTC"); | 211 | if (data->isAllDay ) return QString::fromLatin1("UTC"); |
211 | return data->timezone; | 212 | return data->timezone; |
212 | } | 213 | } |
213 | bool OEvent::match( const QRegExp& )const { | 214 | bool OEvent::match( const QRegExp& re )const { |
214 | // FIXME | 215 | if (data->description.contains( re ) ) |
216 | return true; | ||
217 | if ( data->note.contains( re ) ) | ||
218 | return true; | ||
219 | if ( data->location.contains( re ) ) | ||
220 | return true; | ||
221 | if ( data->start.toString().contains( re ) ) | ||
222 | return true; | ||
223 | if ( data->end.toString().contains( re ) ) | ||
224 | return true; | ||
215 | return false; | 225 | return false; |
216 | } | 226 | } |
217 | QString OEvent::toRichText()const { | 227 | QString OEvent::toRichText()const { |
218 | // FIXME | 228 | QString text; |
219 | return "OEvent test"; | 229 | if ( !description().isEmpty() ) { |
230 | text += "<b>" + QObject::tr( "Description:") + "</b><br>"; | ||
231 | text += Qtopia::escapeString(description() ). | ||
232 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
233 | } | ||
234 | if ( startDateTime().isValid() ) { | ||
235 | text += "<b>" + QObject::tr( "Start:") + "</b> "; | ||
236 | text += Qtopia::escapeString(startDateTime().toString() ). | ||
237 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
238 | } | ||
239 | if ( endDateTime().isValid() ) { | ||
240 | text += "<b>" + QObject::tr( "End:") + "</b> "; | ||
241 | text += Qtopia::escapeString(endDateTime().toString() ). | ||
242 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
243 | } | ||
244 | if ( !note().isEmpty() ) { | ||
245 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; | ||
246 | text += note(); | ||
247 | // text += Qtopia::escapeString(note() ). | ||
248 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
249 | } | ||
250 | return text; | ||
220 | } | 251 | } |
221 | QString OEvent::toShortText()const { | 252 | QString OEvent::toShortText()const { |
222 | return "OEvent shotText"; | 253 | return description(); |
223 | } | 254 | } |
224 | QString OEvent::type()const { | 255 | QString OEvent::type()const { |
225 | return QString::fromLatin1("OEvent"); | 256 | return QString::fromLatin1("OEvent"); |
226 | } | 257 | } |
227 | QString OEvent::recordField( int /*id */ )const { | 258 | QString OEvent::recordField( int /*id */ )const { |
228 | return QString::null; | 259 | return QString::null; |
229 | } | 260 | } |
230 | int OEvent::rtti() { | 261 | int OEvent::rtti() { |
231 | return OPimResolver::DateBook; | 262 | return OPimResolver::DateBook; |
232 | } | 263 | } |
233 | bool OEvent::loadFromStream( QDataStream& ) { | 264 | bool OEvent::loadFromStream( QDataStream& ) { |
234 | return true; | 265 | return true; |
235 | } | 266 | } |
236 | bool OEvent::saveToStream( QDataStream& )const { | 267 | bool OEvent::saveToStream( QDataStream& )const { |
237 | return true; | 268 | return true; |
238 | } | 269 | } |
239 | void OEvent::changeOrModify() { | 270 | void OEvent::changeOrModify() { |
240 | if ( data->count != 1 ) { | 271 | if ( data->count != 1 ) { |
241 | data->deref(); | 272 | data->deref(); |
242 | Data* d2 = new Data; | 273 | Data* d2 = new Data; |
243 | d2->description = data->description; | 274 | d2->description = data->description; |
244 | d2->location = data->location; | 275 | d2->location = data->location; |
245 | 276 | ||
246 | if (data->manager ) | 277 | if (data->manager ) |
247 | d2->manager = new OPimNotifyManager( *data->manager ); | 278 | d2->manager = new OPimNotifyManager( *data->manager ); |
248 | 279 | ||
249 | if ( data->recur ) | 280 | if ( data->recur ) |
250 | d2->recur = new ORecur( *data->recur ); | 281 | d2->recur = new ORecur( *data->recur ); |
251 | 282 | ||
252 | d2->note = data->note; | 283 | d2->note = data->note; |
253 | d2->created = data->created; | 284 | d2->created = data->created; |
254 | d2->start = data->start; | 285 | d2->start = data->start; |
255 | d2->end = data->end; | 286 | d2->end = data->end; |
256 | d2->isAllDay = data->isAllDay; | 287 | d2->isAllDay = data->isAllDay; |
257 | d2->timezone = data->timezone; | 288 | d2->timezone = data->timezone; |
258 | d2->parent = data->parent; | 289 | d2->parent = data->parent; |
259 | 290 | ||
260 | if ( data->child ) { | 291 | if ( data->child ) { |
261 | d2->child = new QArray<int>( *data->child ); | 292 | d2->child = new QArray<int>( *data->child ); |
262 | d2->child->detach(); | 293 | d2->child->detach(); |
263 | } | 294 | } |
264 | 295 | ||
265 | data = d2; | 296 | data = d2; |
266 | } | 297 | } |
267 | } | 298 | } |
268 | void OEvent::deref() { | 299 | void OEvent::deref() { |
269 | if ( data->deref() ) { | 300 | if ( data->deref() ) { |
270 | delete data; | 301 | delete data; |
271 | data = 0; | 302 | data = 0; |
272 | } | 303 | } |
273 | } | 304 | } |
274 | // FIXME | 305 | // FIXME |
275 | QMap<int, QString> OEvent::toMap()const { | 306 | QMap<int, QString> OEvent::toMap()const { |
276 | return QMap<int, QString>(); | 307 | return QMap<int, QString>(); |
277 | } | 308 | } |
278 | QMap<QString, QString> OEvent::toExtraMap()const { | 309 | QMap<QString, QString> OEvent::toExtraMap()const { |
279 | return QMap<QString, QString>(); | 310 | return QMap<QString, QString>(); |
280 | } | 311 | } |
281 | int OEvent::parent()const { | 312 | int OEvent::parent()const { |
282 | return data->parent; | 313 | return data->parent; |
283 | } | 314 | } |
284 | void OEvent::setParent( int uid ) { | 315 | void OEvent::setParent( int uid ) { |
285 | changeOrModify(); | 316 | changeOrModify(); |
286 | data->parent = uid; | 317 | data->parent = uid; |
287 | } | 318 | } |
288 | QArray<int> OEvent::children() const{ | 319 | QArray<int> OEvent::children() const{ |
289 | if (!data->child) return QArray<int>(); | 320 | if (!data->child) return QArray<int>(); |
290 | else | 321 | else |
291 | return data->child->copy(); | 322 | return data->child->copy(); |
292 | } | 323 | } |
293 | void OEvent::setChildren( const QArray<int>& arr ) { | 324 | void OEvent::setChildren( const QArray<int>& arr ) { |
294 | changeOrModify(); | 325 | changeOrModify(); |
295 | if (data->child) delete data->child; | 326 | if (data->child) delete data->child; |
296 | 327 | ||
297 | data->child = new QArray<int>( arr ); | 328 | data->child = new QArray<int>( arr ); |
298 | data->child->detach(); | 329 | data->child->detach(); |
299 | } | 330 | } |
300 | void OEvent::addChild( int uid ) { | 331 | void OEvent::addChild( int uid ) { |
301 | changeOrModify(); | 332 | changeOrModify(); |
302 | if (!data->child ) { | 333 | if (!data->child ) { |
303 | data->child = new QArray<int>(1); | 334 | data->child = new QArray<int>(1); |
304 | (*data->child)[0] = uid; | 335 | (*data->child)[0] = uid; |
305 | }else{ | 336 | }else{ |
306 | int count = data->child->count(); | 337 | int count = data->child->count(); |
307 | data->child->resize( count + 1 ); | 338 | data->child->resize( count + 1 ); |
308 | (*data->child)[count] = uid; | 339 | (*data->child)[count] = uid; |
309 | } | 340 | } |
310 | } | 341 | } |
311 | void OEvent::removeChild( int uid ) { | 342 | void OEvent::removeChild( int uid ) { |
312 | if (!data->child || !data->child->contains( uid ) ) return; | 343 | if (!data->child || !data->child->contains( uid ) ) return; |
313 | changeOrModify(); | 344 | changeOrModify(); |
314 | QArray<int> newAr( data->child->count() - 1 ); | 345 | QArray<int> newAr( data->child->count() - 1 ); |
315 | int j = 0; | 346 | int j = 0; |
316 | uint count = data->child->count(); | 347 | uint count = data->child->count(); |
317 | for ( uint i = 0; i < count; i++ ) { | 348 | for ( uint i = 0; i < count; i++ ) { |
318 | if ( (*data->child)[i] != uid ) { | 349 | if ( (*data->child)[i] != uid ) { |
diff --git a/libopie/pim/oevent.h b/libopie/pim/oevent.h index 57d32d0..b696d81 100644 --- a/libopie/pim/oevent.h +++ b/libopie/pim/oevent.h | |||
@@ -20,193 +20,193 @@ struct OCalendarHelper { | |||
20 | static int ocurrence( const QDate& ); | 20 | static int ocurrence( const QDate& ); |
21 | 21 | ||
22 | // returns the dayOfWeek for the *first* day it finds (ignores | 22 | // returns the dayOfWeek for the *first* day it finds (ignores |
23 | // any further days!). Returns 1 (Monday) if there isn't any day found | 23 | // any further days!). Returns 1 (Monday) if there isn't any day found |
24 | static int dayOfWeek( char day ); | 24 | static int dayOfWeek( char day ); |
25 | 25 | ||
26 | /** returns the diff of month */ | 26 | /** returns the diff of month */ |
27 | static int monthDiff( const QDate& first, const QDate& second ); | 27 | static int monthDiff( const QDate& first, const QDate& second ); |
28 | 28 | ||
29 | }; | 29 | }; |
30 | 30 | ||
31 | class OPimNotifyManager; | 31 | class OPimNotifyManager; |
32 | class ORecur; | 32 | class ORecur; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * This is the container for all Events. It encapsules all | 35 | * This is the container for all Events. It encapsules all |
36 | * available information for a single Event | 36 | * available information for a single Event |
37 | * @short container for events. | 37 | * @short container for events. |
38 | */ | 38 | */ |
39 | class OEvent : public OPimRecord { | 39 | class OEvent : public OPimRecord { |
40 | public: | 40 | public: |
41 | typedef QValueList<OEvent> ValueList; | 41 | typedef QValueList<OEvent> ValueList; |
42 | /** | 42 | /** |
43 | * RecordFields contain possible attributes | 43 | * RecordFields contain possible attributes |
44 | */ | 44 | */ |
45 | enum RecordFields { | 45 | enum RecordFields { |
46 | Uid = Qtopia::UID_ID, | 46 | Uid = Qtopia::UID_ID, |
47 | Category = Qtopia::CATEGORY_ID, | 47 | Category = Qtopia::CATEGORY_ID, |
48 | Description, | 48 | Description, |
49 | Location, | 49 | Location, |
50 | Alarm, | 50 | Alarm, |
51 | Reminder, | 51 | Reminder, |
52 | Recurrence, | 52 | Recurrence, |
53 | Note, | 53 | Note, |
54 | Created, | 54 | Created, |
55 | StartDate, | 55 | StartDate, |
56 | EndDate, | 56 | EndDate, |
57 | AllDay, | 57 | AllDay, |
58 | TimeZone | 58 | TimeZone |
59 | }; | 59 | }; |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * Start with an Empty OEvent. UID == 0 means that it is empty | 62 | * Start with an Empty OEvent. UID == 0 means that it is empty |
63 | */ | 63 | */ |
64 | OEvent(int uid = 0); | 64 | OEvent(int uid = 0); |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * copy c'tor | 67 | * copy c'tor |
68 | */ | 68 | */ |
69 | OEvent( const OEvent& ); | 69 | OEvent( const OEvent& ); |
70 | ~OEvent(); | 70 | ~OEvent(); |
71 | OEvent &operator=( const OEvent& ); | 71 | OEvent &operator=( const OEvent& ); |
72 | 72 | ||
73 | QString description()const; | 73 | QString description()const; |
74 | void setDescription( const QString& description ); | 74 | void setDescription( const QString& description ); |
75 | 75 | ||
76 | QString location()const; | 76 | QString location()const; |
77 | void setLocation( const QString& loc ); | 77 | void setLocation( const QString& loc ); |
78 | 78 | ||
79 | bool hasNotifiers()const; | 79 | bool hasNotifiers()const; |
80 | OPimNotifyManager ¬ifiers()const; | 80 | OPimNotifyManager ¬ifiers()const; |
81 | 81 | ||
82 | ORecur recurrence()const; | 82 | ORecur recurrence()const; |
83 | void setRecurrence( const ORecur& ); | 83 | void setRecurrence( const ORecur& ); |
84 | bool hasRecurrence()const; | 84 | bool hasRecurrence()const; |
85 | 85 | ||
86 | QString note()const; | 86 | QString note()const; |
87 | void setNote( const QString& note ); | 87 | void setNote( const QString& note ); |
88 | 88 | ||
89 | 89 | ||
90 | QDateTime createdDateTime()const; | 90 | QDateTime createdDateTime()const; |
91 | void setCreatedDateTime( const QDateTime& dt); | 91 | void setCreatedDateTime( const QDateTime& dt); |
92 | 92 | ||
93 | /** set the date to dt. dt is the QDateTime in localtime */ | 93 | /** set the date to dt. dt is the QDateTime in localtime */ |
94 | void setStartDateTime( const QDateTime& ); | 94 | void setStartDateTime( const QDateTime& ); |
95 | /** returns the datetime in the local timeZone */ | 95 | /** returns the datetime in the local timeZone */ |
96 | QDateTime startDateTime()const; | 96 | QDateTime startDateTime()const; |
97 | 97 | ||
98 | /** returns the start datetime in the current zone */ | 98 | /** returns the start datetime in the current zone */ |
99 | QDateTime startDateTimeInZone()const; | 99 | QDateTime startDateTimeInZone()const; |
100 | 100 | ||
101 | /** in current timezone */ | 101 | /** in current timezone */ |
102 | void setEndDateTime( const QDateTime& ); | 102 | void setEndDateTime( const QDateTime& ); |
103 | /** in current timezone */ | 103 | /** in current timezone */ |
104 | QDateTime endDateTime()const; | 104 | QDateTime endDateTime()const; |
105 | QDateTime endDateTimeInZone()const; | 105 | QDateTime endDateTimeInZone()const; |
106 | 106 | ||
107 | bool isMultipleDay()const; | 107 | bool isMultipleDay()const; |
108 | bool isAllDay()const; | 108 | bool isAllDay()const; |
109 | void setAllDay( bool isAllDay ); | 109 | void setAllDay( bool isAllDay ); |
110 | 110 | ||
111 | /* pin this event to a timezone! FIXME */ | 111 | /* pin this event to a timezone! FIXME */ |
112 | void setTimeZone( const QString& timeZone ); | 112 | void setTimeZone( const QString& timeZone ); |
113 | QString timeZone()const; | 113 | QString timeZone()const; |
114 | 114 | ||
115 | 115 | ||
116 | bool match( const QRegExp& )const; | 116 | virtual bool match( const QRegExp& )const; |
117 | 117 | ||
118 | /** For exception to recurrence here is a list of children... */ | 118 | /** For exception to recurrence here is a list of children... */ |
119 | QArray<int> children()const; | 119 | QArray<int> children()const; |
120 | void setChildren( const QArray<int>& ); | 120 | void setChildren( const QArray<int>& ); |
121 | void addChild( int uid ); | 121 | void addChild( int uid ); |
122 | void removeChild( int uid ); | 122 | void removeChild( int uid ); |
123 | 123 | ||
124 | /** return the parent OEvent */ | 124 | /** return the parent OEvent */ |
125 | int parent()const; | 125 | int parent()const; |
126 | void setParent( int uid ); | 126 | void setParent( int uid ); |
127 | 127 | ||
128 | 128 | ||
129 | /* needed reimp */ | 129 | /* needed reimp */ |
130 | QString toRichText()const; | 130 | QString toRichText()const; |
131 | QString toShortText()const; | 131 | QString toShortText()const; |
132 | QString type()const; | 132 | QString type()const; |
133 | 133 | ||
134 | QMap<int, QString> toMap()const; | 134 | QMap<int, QString> toMap()const; |
135 | QMap<QString, QString> toExtraMap()const; | 135 | QMap<QString, QString> toExtraMap()const; |
136 | QString recordField(int )const; | 136 | QString recordField(int )const; |
137 | 137 | ||
138 | static int rtti(); | 138 | static int rtti(); |
139 | 139 | ||
140 | bool loadFromStream( QDataStream& ); | 140 | bool loadFromStream( QDataStream& ); |
141 | bool saveToStream( QDataStream& )const; | 141 | bool saveToStream( QDataStream& )const; |
142 | 142 | ||
143 | /* bool operator==( const OEvent& ); | 143 | /* bool operator==( const OEvent& ); |
144 | bool operator!=( const OEvent& ); | 144 | bool operator!=( const OEvent& ); |
145 | bool operator<( const OEvent& ); | 145 | bool operator<( const OEvent& ); |
146 | bool operator<=( const OEvent& ); | 146 | bool operator<=( const OEvent& ); |
147 | bool operator>( const OEvent& ); | 147 | bool operator>( const OEvent& ); |
148 | bool operator>=(const OEvent& ); | 148 | bool operator>=(const OEvent& ); |
149 | */ | 149 | */ |
150 | private: | 150 | private: |
151 | inline void changeOrModify(); | 151 | inline void changeOrModify(); |
152 | void deref(); | 152 | void deref(); |
153 | struct Data; | 153 | struct Data; |
154 | Data* data; | 154 | Data* data; |
155 | class Private; | 155 | class Private; |
156 | Private* priv; | 156 | Private* priv; |
157 | 157 | ||
158 | }; | 158 | }; |
159 | 159 | ||
160 | /** | 160 | /** |
161 | * AN Event can span through multiple days. We split up a multiday eve | 161 | * AN Event can span through multiple days. We split up a multiday eve |
162 | */ | 162 | */ |
163 | class OEffectiveEvent { | 163 | class OEffectiveEvent { |
164 | public: | 164 | public: |
165 | typedef QValueList<OEffectiveEvent> ValueList; | 165 | typedef QValueList<OEffectiveEvent> ValueList; |
166 | enum Position { MidWay, Start, End, StartEnd }; | 166 | enum Position { MidWay, Start, End, StartEnd }; |
167 | // If we calculate the effective event of a multi-day event | 167 | // If we calculate the effective event of a multi-day event |
168 | // we have to figure out whether we are at the first day, | 168 | // we have to figure out whether we are at the first day, |
169 | // at the end, or anywhere else ("middle"). This is important | 169 | // at the end, or anywhere else ("middle"). This is important |
170 | // for the start/end times (00:00/23:59) | 170 | // for the start/end times (00:00/23:59) |
171 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- | 171 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- |
172 | // day event | 172 | // day event |
173 | // Start: start time -> 23:59 | 173 | // Start: start time -> 23:59 |
174 | // End: 00:00 -> end time | 174 | // End: 00:00 -> end time |
175 | // Start | End == StartEnd: for single-day events (default) | 175 | // Start | End == StartEnd: for single-day events (default) |
176 | // here we draw start time -> end time | 176 | // here we draw start time -> end time |
177 | OEffectiveEvent(); | 177 | OEffectiveEvent(); |
178 | OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd ); | 178 | OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd ); |
179 | OEffectiveEvent( const OEffectiveEvent& ); | 179 | OEffectiveEvent( const OEffectiveEvent& ); |
180 | OEffectiveEvent &operator=(const OEffectiveEvent& ); | 180 | OEffectiveEvent &operator=(const OEffectiveEvent& ); |
181 | ~OEffectiveEvent(); | 181 | ~OEffectiveEvent(); |
182 | 182 | ||
183 | void setStartTime( const QTime& ); | 183 | void setStartTime( const QTime& ); |
184 | void setEndTime( const QTime& ); | 184 | void setEndTime( const QTime& ); |
185 | void setEvent( const OEvent& ); | 185 | void setEvent( const OEvent& ); |
186 | void setDate( const QDate& ); | 186 | void setDate( const QDate& ); |
187 | 187 | ||
188 | void setEffectiveDates( const QDate& from, const QDate& to ); | 188 | void setEffectiveDates( const QDate& from, const QDate& to ); |
189 | 189 | ||
190 | QString description()const; | 190 | QString description()const; |
191 | QString location()const; | 191 | QString location()const; |
192 | QString note()const; | 192 | QString note()const; |
193 | OEvent event()const; | 193 | OEvent event()const; |
194 | QTime startTime()const; | 194 | QTime startTime()const; |
195 | QTime endTime()const; | 195 | QTime endTime()const; |
196 | QDate date()const; | 196 | QDate date()const; |
197 | 197 | ||
198 | /* return the length in hours */ | 198 | /* return the length in hours */ |
199 | int length()const; | 199 | int length()const; |
200 | int size()const; | 200 | int size()const; |
201 | 201 | ||
202 | QDate startDate()const; | 202 | QDate startDate()const; |
203 | QDate endDate()const; | 203 | QDate endDate()const; |
204 | 204 | ||
205 | bool operator<( const OEffectiveEvent &e ) const; | 205 | bool operator<( const OEffectiveEvent &e ) const; |
206 | bool operator<=( const OEffectiveEvent &e ) const; | 206 | bool operator<=( const OEffectiveEvent &e ) const; |
207 | bool operator==( const OEffectiveEvent &e ) const; | 207 | bool operator==( const OEffectiveEvent &e ) const; |
208 | bool operator!=( const OEffectiveEvent &e ) const; | 208 | bool operator!=( const OEffectiveEvent &e ) const; |
209 | bool operator>( const OEffectiveEvent &e ) const; | 209 | bool operator>( const OEffectiveEvent &e ) const; |
210 | bool operator>= ( const OEffectiveEvent &e ) const; | 210 | bool operator>= ( const OEffectiveEvent &e ) const; |
211 | 211 | ||
212 | private: | 212 | private: |
diff --git a/libopie/pim/opimaccessbackend.h b/libopie/pim/opimaccessbackend.h index 01a0c86..f4bbe35 100644 --- a/libopie/pim/opimaccessbackend.h +++ b/libopie/pim/opimaccessbackend.h | |||
@@ -1,144 +1,150 @@ | |||
1 | #ifndef OPIE_PIM_ACCESS_BACKEND | 1 | #ifndef OPIE_PIM_ACCESS_BACKEND |
2 | #define OPIE_PIM_ACCESS_BACKEND | 2 | #define OPIE_PIM_ACCESS_BACKEND |
3 | 3 | ||
4 | #include <qarray.h> | 4 | #include <qarray.h> |
5 | 5 | ||
6 | #include <opie/otemplatebase.h> | 6 | #include <opie/otemplatebase.h> |
7 | #include <opie/opimrecord.h> | 7 | #include <opie/opimrecord.h> |
8 | 8 | ||
9 | 9 | ||
10 | /** | 10 | /** |
11 | * OPimAccessBackend is the base class | 11 | * OPimAccessBackend is the base class |
12 | * for all private backends | 12 | * for all private backends |
13 | * it operates on OPimRecord as the base class | 13 | * it operates on OPimRecord as the base class |
14 | * and it's responsible for fast manipulating | 14 | * and it's responsible for fast manipulating |
15 | * the resource the implementation takes care | 15 | * the resource the implementation takes care |
16 | * of | 16 | * of |
17 | */ | 17 | */ |
18 | template <class T = OPimRecord> | 18 | template <class T = OPimRecord> |
19 | class OPimAccessBackend { | 19 | class OPimAccessBackend { |
20 | public: | 20 | public: |
21 | typedef OTemplateBase<T> Frontend; | 21 | typedef OTemplateBase<T> Frontend; |
22 | 22 | ||
23 | /** The access hint from the frontend */ | 23 | /** The access hint from the frontend */ |
24 | OPimAccessBackend(int access = 0); | 24 | OPimAccessBackend(int access = 0); |
25 | virtual ~OPimAccessBackend(); | 25 | virtual ~OPimAccessBackend(); |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * load the resource | 28 | * load the resource |
29 | */ | 29 | */ |
30 | virtual bool load() = 0; | 30 | virtual bool load() = 0; |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * reload the resource | 33 | * reload the resource |
34 | */ | 34 | */ |
35 | virtual bool reload() = 0; | 35 | virtual bool reload() = 0; |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * save the resource and | 38 | * save the resource and |
39 | * all it's changes | 39 | * all it's changes |
40 | */ | 40 | */ |
41 | virtual bool save() = 0; | 41 | virtual bool save() = 0; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * return an array of | 44 | * return an array of |
45 | * all available uids | 45 | * all available uids |
46 | */ | 46 | */ |
47 | virtual QArray<int> allRecords()const = 0; | 47 | virtual QArray<int> allRecords()const = 0; |
48 | 48 | ||
49 | /** | ||
50 | * return a List of records | ||
51 | * that match the regex | ||
52 | */ | ||
53 | virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; | ||
54 | |||
49 | /** | 55 | /** |
50 | * queryByExample for T with the given Settings | 56 | * queryByExample for T with the given Settings |
51 | * | 57 | * |
52 | */ | 58 | */ |
53 | virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; | 59 | virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; |
54 | 60 | ||
55 | /** | 61 | /** |
56 | * find the OPimRecord with uid @param uid | 62 | * find the OPimRecord with uid @param uid |
57 | * returns T and T.isEmpty() if nothing was found | 63 | * returns T and T.isEmpty() if nothing was found |
58 | */ | 64 | */ |
59 | virtual T find(int uid )const = 0; | 65 | virtual T find(int uid )const = 0; |
60 | 66 | ||
61 | virtual T find(int uid, const QArray<int>& items, | 67 | virtual T find(int uid, const QArray<int>& items, |
62 | uint current, typename Frontend::CacheDirection )const ; | 68 | uint current, typename Frontend::CacheDirection )const ; |
63 | /** | 69 | /** |
64 | * clear the back end | 70 | * clear the back end |
65 | */ | 71 | */ |
66 | virtual void clear() = 0; | 72 | virtual void clear() = 0; |
67 | 73 | ||
68 | /** | 74 | /** |
69 | * add T | 75 | * add T |
70 | */ | 76 | */ |
71 | virtual bool add( const T& t ) = 0; | 77 | virtual bool add( const T& t ) = 0; |
72 | 78 | ||
73 | /** | 79 | /** |
74 | * remove | 80 | * remove |
75 | */ | 81 | */ |
76 | virtual bool remove( int uid ) = 0; | 82 | virtual bool remove( int uid ) = 0; |
77 | 83 | ||
78 | /** | 84 | /** |
79 | * replace a record with T.uid() | 85 | * replace a record with T.uid() |
80 | */ | 86 | */ |
81 | virtual bool replace( const T& t ) = 0; | 87 | virtual bool replace( const T& t ) = 0; |
82 | 88 | ||
83 | /* | 89 | /* |
84 | * setTheFrontEnd!!! | 90 | * setTheFrontEnd!!! |
85 | */ | 91 | */ |
86 | void setFrontend( Frontend* front ); | 92 | void setFrontend( Frontend* front ); |
87 | 93 | ||
88 | /** | 94 | /** |
89 | * set the read ahead count | 95 | * set the read ahead count |
90 | */ | 96 | */ |
91 | void setReadAhead( uint count ); | 97 | void setReadAhead( uint count ); |
92 | protected: | 98 | protected: |
93 | int access()const; | 99 | int access()const; |
94 | void cache( const T& t )const; | 100 | void cache( const T& t )const; |
95 | 101 | ||
96 | /** | 102 | /** |
97 | * use a prime number here! | 103 | * use a prime number here! |
98 | */ | 104 | */ |
99 | void setSaneCacheSize( int ); | 105 | void setSaneCacheSize( int ); |
100 | 106 | ||
101 | uint readAhead()const; | 107 | uint readAhead()const; |
102 | 108 | ||
103 | private: | 109 | private: |
104 | class Private; | 110 | class Private; |
105 | Private* d; | 111 | Private* d; |
106 | Frontend* m_front; | 112 | Frontend* m_front; |
107 | uint m_read; | 113 | uint m_read; |
108 | int m_acc; | 114 | int m_acc; |
109 | 115 | ||
110 | }; | 116 | }; |
111 | 117 | ||
112 | template <class T> | 118 | template <class T> |
113 | OPimAccessBackend<T>::OPimAccessBackend(int acc) | 119 | OPimAccessBackend<T>::OPimAccessBackend(int acc) |
114 | : m_acc( acc ) | 120 | : m_acc( acc ) |
115 | { | 121 | { |
116 | m_front = 0l; | 122 | m_front = 0l; |
117 | } | 123 | } |
118 | template <class T> | 124 | template <class T> |
119 | OPimAccessBackend<T>::~OPimAccessBackend() { | 125 | OPimAccessBackend<T>::~OPimAccessBackend() { |
120 | 126 | ||
121 | } | 127 | } |
122 | template <class T> | 128 | template <class T> |
123 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { | 129 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { |
124 | m_front = fr; | 130 | m_front = fr; |
125 | } | 131 | } |
126 | template <class T> | 132 | template <class T> |
127 | void OPimAccessBackend<T>::cache( const T& t )const { | 133 | void OPimAccessBackend<T>::cache( const T& t )const { |
128 | if (m_front ) | 134 | if (m_front ) |
129 | m_front->cache( t ); | 135 | m_front->cache( t ); |
130 | } | 136 | } |
131 | template <class T> | 137 | template <class T> |
132 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { | 138 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { |
133 | if (m_front ) | 139 | if (m_front ) |
134 | m_front->setSaneCacheSize( size ); | 140 | m_front->setSaneCacheSize( size ); |
135 | } | 141 | } |
136 | template <class T> | 142 | template <class T> |
137 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, | 143 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, |
138 | uint, typename Frontend::CacheDirection )const { | 144 | uint, typename Frontend::CacheDirection )const { |
139 | return find( uid ); | 145 | return find( uid ); |
140 | } | 146 | } |
141 | template <class T> | 147 | template <class T> |
142 | void OPimAccessBackend<T>::setReadAhead( uint count ) { | 148 | void OPimAccessBackend<T>::setReadAhead( uint count ) { |
143 | m_read = count; | 149 | m_read = count; |
144 | } | 150 | } |
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h index 6a3a0db..8ff205c 100644 --- a/libopie/pim/opimaccesstemplate.h +++ b/libopie/pim/opimaccesstemplate.h | |||
@@ -1,279 +1,291 @@ | |||
1 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H | 1 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H |
2 | #define OPIE_PIM_ACCESS_TEMPLATE_H | 2 | #define OPIE_PIM_ACCESS_TEMPLATE_H |
3 | 3 | ||
4 | #include <qarray.h> | 4 | #include <qarray.h> |
5 | 5 | ||
6 | #include <opie/opimrecord.h> | 6 | #include <opie/opimrecord.h> |
7 | #include <opie/opimaccessbackend.h> | 7 | #include <opie/opimaccessbackend.h> |
8 | #include <opie/orecordlist.h> | 8 | #include <opie/orecordlist.h> |
9 | 9 | ||
10 | #include "opimcache.h" | 10 | #include "opimcache.h" |
11 | #include "otemplatebase.h" | 11 | #include "otemplatebase.h" |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * Thats the frontend to our OPIE PIM | 14 | * Thats the frontend to our OPIE PIM |
15 | * Library. Either you want to use it's | 15 | * Library. Either you want to use it's |
16 | * interface or you want to implement | 16 | * interface or you want to implement |
17 | * your own Access lib | 17 | * your own Access lib |
18 | * Just create a OPimRecord and inherit from | 18 | * Just create a OPimRecord and inherit from |
19 | * the plugins | 19 | * the plugins |
20 | */ | 20 | */ |
21 | 21 | ||
22 | template <class T = OPimRecord > | 22 | template <class T = OPimRecord > |
23 | class OPimAccessTemplate : public OTemplateBase<T> { | 23 | class OPimAccessTemplate : public OTemplateBase<T> { |
24 | public: | 24 | public: |
25 | enum Access { | 25 | enum Access { |
26 | Random = 0, | 26 | Random = 0, |
27 | SortedAccess | 27 | SortedAccess |
28 | }; | 28 | }; |
29 | typedef ORecordList<T> List; | 29 | typedef ORecordList<T> List; |
30 | typedef OPimAccessBackend<T> BackEnd; | 30 | typedef OPimAccessBackend<T> BackEnd; |
31 | typedef OPimCache<T> Cache; | 31 | typedef OPimCache<T> Cache; |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * c'tor BackEnd | 34 | * c'tor BackEnd |
35 | * enum Access a small hint on how to handle the backend | 35 | * enum Access a small hint on how to handle the backend |
36 | */ | 36 | */ |
37 | OPimAccessTemplate( BackEnd* end); | 37 | OPimAccessTemplate( BackEnd* end); |
38 | 38 | ||
39 | virtual ~OPimAccessTemplate(); | 39 | virtual ~OPimAccessTemplate(); |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * load from the backend | 42 | * load from the backend |
43 | */ | 43 | */ |
44 | bool load(); | 44 | bool load(); |
45 | 45 | ||
46 | /** Reload database. | 46 | /** Reload database. |
47 | * You should execute this function if the external database | 47 | * You should execute this function if the external database |
48 | * was changed. | 48 | * was changed. |
49 | * This function will load the external database and afterwards | 49 | * This function will load the external database and afterwards |
50 | * rejoin the local changes. Therefore the local database will be set consistent. | 50 | * rejoin the local changes. Therefore the local database will be set consistent. |
51 | */ | 51 | */ |
52 | virtual bool reload(); | 52 | virtual bool reload(); |
53 | 53 | ||
54 | /** Save contacts database. | 54 | /** Save contacts database. |
55 | * Save is more a "commit". After calling this function, all changes are public available. | 55 | * Save is more a "commit". After calling this function, all changes are public available. |
56 | * @return true if successful | 56 | * @return true if successful |
57 | */ | 57 | */ |
58 | bool save(); | 58 | bool save(); |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * if the resource was changed externally | 61 | * if the resource was changed externally |
62 | * You should use the signal handling instead of polling possible changes ! | 62 | * You should use the signal handling instead of polling possible changes ! |
63 | * zecke: Do you implement a signal for otodoaccess ? | 63 | * zecke: Do you implement a signal for otodoaccess ? |
64 | */ | 64 | */ |
65 | bool wasChangedExternally()const; | 65 | bool wasChangedExternally()const; |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * return a List of records | 68 | * return a List of records |
69 | * you can iterate over them | 69 | * you can iterate over them |
70 | */ | 70 | */ |
71 | virtual List allRecords()const; | 71 | virtual List allRecords()const; |
72 | |||
73 | /** | ||
74 | * return a List of records | ||
75 | * that match the regex | ||
76 | */ | ||
77 | virtual List matchRegexp( const QRegExp &r ) const; | ||
72 | 78 | ||
73 | /** | 79 | /** |
74 | * queryByExample. | 80 | * queryByExample. |
75 | * @see otodoaccess, ocontactaccess | 81 | * @see otodoaccess, ocontactaccess |
76 | */ | 82 | */ |
77 | virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); | 83 | virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); |
78 | 84 | ||
79 | /** | 85 | /** |
80 | * find the OPimRecord uid | 86 | * find the OPimRecord uid |
81 | */ | 87 | */ |
82 | virtual T find( int uid )const; | 88 | virtual T find( int uid )const; |
83 | 89 | ||
84 | /** | 90 | /** |
85 | * read ahead cache find method ;) | 91 | * read ahead cache find method ;) |
86 | */ | 92 | */ |
87 | virtual T find( int uid, const QArray<int>&, | 93 | virtual T find( int uid, const QArray<int>&, |
88 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; | 94 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; |
89 | 95 | ||
90 | /* invalidate cache here */ | 96 | /* invalidate cache here */ |
91 | /** | 97 | /** |
92 | * clears the backend and invalidates the backend | 98 | * clears the backend and invalidates the backend |
93 | */ | 99 | */ |
94 | void clear() ; | 100 | void clear() ; |
95 | 101 | ||
96 | /** | 102 | /** |
97 | * add T to the backend | 103 | * add T to the backend |
98 | * @param t The item to add. | 104 | * @param t The item to add. |
99 | * @return <i>true</i> if added successfully. | 105 | * @return <i>true</i> if added successfully. |
100 | */ | 106 | */ |
101 | virtual bool add( const T& t ) ; | 107 | virtual bool add( const T& t ) ; |
102 | bool add( const OPimRecord& ); | 108 | bool add( const OPimRecord& ); |
103 | 109 | ||
104 | /* only the uid matters */ | 110 | /* only the uid matters */ |
105 | /** | 111 | /** |
106 | * remove T from the backend | 112 | * remove T from the backend |
107 | * @param t The item to remove | 113 | * @param t The item to remove |
108 | * @return <i>true</i> if successful. | 114 | * @return <i>true</i> if successful. |
109 | */ | 115 | */ |
110 | virtual bool remove( const T& t ); | 116 | virtual bool remove( const T& t ); |
111 | 117 | ||
112 | /** | 118 | /** |
113 | * remove the OPimRecord with uid | 119 | * remove the OPimRecord with uid |
114 | * @param uid The ID of the item to remove | 120 | * @param uid The ID of the item to remove |
115 | * @return <i>true</i> if successful. | 121 | * @return <i>true</i> if successful. |
116 | */ | 122 | */ |
117 | bool remove( int uid ); | 123 | bool remove( int uid ); |
118 | bool remove( const OPimRecord& ); | 124 | bool remove( const OPimRecord& ); |
119 | 125 | ||
120 | /** | 126 | /** |
121 | * replace T from backend | 127 | * replace T from backend |
122 | * @param t The item to replace | 128 | * @param t The item to replace |
123 | * @return <i>true</i> if successful. | 129 | * @return <i>true</i> if successful. |
124 | */ | 130 | */ |
125 | virtual bool replace( const T& t) ; | 131 | virtual bool replace( const T& t) ; |
126 | 132 | ||
127 | void setReadAhead( uint count ); | 133 | void setReadAhead( uint count ); |
128 | /** | 134 | /** |
129 | * @internal | 135 | * @internal |
130 | */ | 136 | */ |
131 | void cache( const T& )const; | 137 | void cache( const T& )const; |
132 | void setSaneCacheSize( int ); | 138 | void setSaneCacheSize( int ); |
133 | 139 | ||
134 | QArray<int> records()const; | 140 | QArray<int> records()const; |
135 | protected: | 141 | protected: |
136 | /** | 142 | /** |
137 | * invalidate the cache | 143 | * invalidate the cache |
138 | */ | 144 | */ |
139 | void invalidateCache(); | 145 | void invalidateCache(); |
140 | 146 | ||
141 | void setBackEnd( BackEnd* end ); | 147 | void setBackEnd( BackEnd* end ); |
142 | /** | 148 | /** |
143 | * returns the backend | 149 | * returns the backend |
144 | */ | 150 | */ |
145 | BackEnd* backEnd(); | 151 | BackEnd* backEnd(); |
146 | BackEnd* m_backEnd; | 152 | BackEnd* m_backEnd; |
147 | Cache m_cache; | 153 | Cache m_cache; |
148 | 154 | ||
149 | }; | 155 | }; |
150 | 156 | ||
151 | template <class T> | 157 | template <class T> |
152 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) | 158 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) |
153 | : OTemplateBase<T>(), m_backEnd( end ) | 159 | : OTemplateBase<T>(), m_backEnd( end ) |
154 | { | 160 | { |
155 | if (end ) | 161 | if (end ) |
156 | end->setFrontend( this ); | 162 | end->setFrontend( this ); |
157 | } | 163 | } |
158 | template <class T> | 164 | template <class T> |
159 | OPimAccessTemplate<T>::~OPimAccessTemplate() { | 165 | OPimAccessTemplate<T>::~OPimAccessTemplate() { |
160 | qWarning("~OPimAccessTemplate<T>"); | 166 | qWarning("~OPimAccessTemplate<T>"); |
161 | delete m_backEnd; | 167 | delete m_backEnd; |
162 | } | 168 | } |
163 | template <class T> | 169 | template <class T> |
164 | bool OPimAccessTemplate<T>::load() { | 170 | bool OPimAccessTemplate<T>::load() { |
165 | invalidateCache(); | 171 | invalidateCache(); |
166 | return m_backEnd->load(); | 172 | return m_backEnd->load(); |
167 | } | 173 | } |
168 | template <class T> | 174 | template <class T> |
169 | bool OPimAccessTemplate<T>::reload() { | 175 | bool OPimAccessTemplate<T>::reload() { |
170 | invalidateCache(); // zecke: I think this should be added (se) | 176 | invalidateCache(); // zecke: I think this should be added (se) |
171 | return m_backEnd->reload(); | 177 | return m_backEnd->reload(); |
172 | } | 178 | } |
173 | template <class T> | 179 | template <class T> |
174 | bool OPimAccessTemplate<T>::save() { | 180 | bool OPimAccessTemplate<T>::save() { |
175 | return m_backEnd->save(); | 181 | return m_backEnd->save(); |
176 | } | 182 | } |
177 | template <class T> | 183 | template <class T> |
178 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { | 184 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { |
179 | QArray<int> ints = m_backEnd->allRecords(); | 185 | QArray<int> ints = m_backEnd->allRecords(); |
180 | List lis(ints, this ); | 186 | List lis(ints, this ); |
181 | return lis; | 187 | return lis; |
182 | } | 188 | } |
183 | template <class T> | 189 | template <class T> |
190 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const { | ||
191 | QArray<int> ints = m_backEnd->matchRegexp( r ); | ||
192 | List lis(ints, this ); | ||
193 | return lis; | ||
194 | } | ||
195 | template <class T> | ||
184 | QArray<int> OPimAccessTemplate<T>::records()const { | 196 | QArray<int> OPimAccessTemplate<T>::records()const { |
185 | return m_backEnd->allRecords(); | 197 | return m_backEnd->allRecords(); |
186 | } | 198 | } |
187 | template <class T> | 199 | template <class T> |
188 | typename OPimAccessTemplate<T>::List | 200 | typename OPimAccessTemplate<T>::List |
189 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { | 201 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { |
190 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); | 202 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); |
191 | 203 | ||
192 | List lis(ints, this ); | 204 | List lis(ints, this ); |
193 | return lis; | 205 | return lis; |
194 | } | 206 | } |
195 | template <class T> | 207 | template <class T> |
196 | T OPimAccessTemplate<T>::find( int uid ) const{ | 208 | T OPimAccessTemplate<T>::find( int uid ) const{ |
197 | T t = m_backEnd->find( uid ); | 209 | T t = m_backEnd->find( uid ); |
198 | cache( t ); | 210 | cache( t ); |
199 | return t; | 211 | return t; |
200 | } | 212 | } |
201 | template <class T> | 213 | template <class T> |
202 | T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, | 214 | T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, |
203 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { | 215 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { |
204 | /* | 216 | /* |
205 | * better do T.isEmpty() | 217 | * better do T.isEmpty() |
206 | * after a find this way we would | 218 | * after a find this way we would |
207 | * avoid two finds in QCache... | 219 | * avoid two finds in QCache... |
208 | */ | 220 | */ |
209 | // qWarning("find it now %d", uid ); | 221 | // qWarning("find it now %d", uid ); |
210 | if (m_cache.contains( uid ) ) { | 222 | if (m_cache.contains( uid ) ) { |
211 | return m_cache.find( uid ); | 223 | return m_cache.find( uid ); |
212 | } | 224 | } |
213 | 225 | ||
214 | T t = m_backEnd->find( uid, ar, current, dir ); | 226 | T t = m_backEnd->find( uid, ar, current, dir ); |
215 | cache( t ); | 227 | cache( t ); |
216 | return t; | 228 | return t; |
217 | } | 229 | } |
218 | template <class T> | 230 | template <class T> |
219 | void OPimAccessTemplate<T>::clear() { | 231 | void OPimAccessTemplate<T>::clear() { |
220 | invalidateCache(); | 232 | invalidateCache(); |
221 | m_backEnd->clear(); | 233 | m_backEnd->clear(); |
222 | } | 234 | } |
223 | template <class T> | 235 | template <class T> |
224 | bool OPimAccessTemplate<T>::add( const T& t ) { | 236 | bool OPimAccessTemplate<T>::add( const T& t ) { |
225 | cache( t ); | 237 | cache( t ); |
226 | return m_backEnd->add( t ); | 238 | return m_backEnd->add( t ); |
227 | } | 239 | } |
228 | template <class T> | 240 | template <class T> |
229 | bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { | 241 | bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { |
230 | /* same type */ | 242 | /* same type */ |
231 | if ( rec.rtti() == T::rtti() ) { | 243 | if ( rec.rtti() == T::rtti() ) { |
232 | const T &t = static_cast<const T&>(rec); | 244 | const T &t = static_cast<const T&>(rec); |
233 | return add(t); | 245 | return add(t); |
234 | } | 246 | } |
235 | return false; | 247 | return false; |
236 | } | 248 | } |
237 | template <class T> | 249 | template <class T> |
238 | bool OPimAccessTemplate<T>::remove( const T& t ) { | 250 | bool OPimAccessTemplate<T>::remove( const T& t ) { |
239 | return remove( t.uid() ); | 251 | return remove( t.uid() ); |
240 | } | 252 | } |
241 | template <class T> | 253 | template <class T> |
242 | bool OPimAccessTemplate<T>::remove( int uid ) { | 254 | bool OPimAccessTemplate<T>::remove( int uid ) { |
243 | m_cache.remove( uid ); | 255 | m_cache.remove( uid ); |
244 | return m_backEnd->remove( uid ); | 256 | return m_backEnd->remove( uid ); |
245 | } | 257 | } |
246 | template <class T> | 258 | template <class T> |
247 | bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { | 259 | bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { |
248 | return remove( rec.uid() ); | 260 | return remove( rec.uid() ); |
249 | } | 261 | } |
250 | template <class T> | 262 | template <class T> |
251 | bool OPimAccessTemplate<T>::replace( const T& t ) { | 263 | bool OPimAccessTemplate<T>::replace( const T& t ) { |
252 | m_cache.replace( t ); | 264 | m_cache.replace( t ); |
253 | return m_backEnd->replace( t ); | 265 | return m_backEnd->replace( t ); |
254 | } | 266 | } |
255 | template <class T> | 267 | template <class T> |
256 | void OPimAccessTemplate<T>::invalidateCache() { | 268 | void OPimAccessTemplate<T>::invalidateCache() { |
257 | m_cache.invalidate(); | 269 | m_cache.invalidate(); |
258 | } | 270 | } |
259 | template <class T> | 271 | template <class T> |
260 | typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { | 272 | typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { |
261 | return m_backEnd; | 273 | return m_backEnd; |
262 | } | 274 | } |
263 | template <class T> | 275 | template <class T> |
264 | bool OPimAccessTemplate<T>::wasChangedExternally()const { | 276 | bool OPimAccessTemplate<T>::wasChangedExternally()const { |
265 | return false; | 277 | return false; |
266 | } | 278 | } |
267 | template <class T> | 279 | template <class T> |
268 | void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) { | 280 | void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) { |
269 | m_backEnd = end; | 281 | m_backEnd = end; |
270 | if (m_backEnd ) | 282 | if (m_backEnd ) |
271 | m_backEnd->setFrontend( this ); | 283 | m_backEnd->setFrontend( this ); |
272 | } | 284 | } |
273 | template <class T> | 285 | template <class T> |
274 | void OPimAccessTemplate<T>::cache( const T& t ) const{ | 286 | void OPimAccessTemplate<T>::cache( const T& t ) const{ |
275 | /* hacky we need to work around the const*/ | 287 | /* hacky we need to work around the const*/ |
276 | ((OPimAccessTemplate<T>*)this)->m_cache.add( t ); | 288 | ((OPimAccessTemplate<T>*)this)->m_cache.add( t ); |
277 | } | 289 | } |
278 | template <class T> | 290 | template <class T> |
279 | void OPimAccessTemplate<T>::setSaneCacheSize( int size ) { | 291 | void OPimAccessTemplate<T>::setSaneCacheSize( int size ) { |
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h index c7f9460..de2d9f4 100644 --- a/libopie/pim/opimrecord.h +++ b/libopie/pim/opimrecord.h | |||
@@ -1,134 +1,140 @@ | |||
1 | #ifndef OPIE_PIM_RECORD_H | 1 | #ifndef OPIE_PIM_RECORD_H |
2 | #define OPIE_PIM_RECORD_H | 2 | #define OPIE_PIM_RECORD_H |
3 | 3 | ||
4 | #include <qdatastream.h> | 4 | #include <qdatastream.h> |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qstringlist.h> | 7 | #include <qstringlist.h> |
8 | 8 | ||
9 | #include <qpe/palmtoprecord.h> | 9 | #include <qpe/palmtoprecord.h> |
10 | 10 | ||
11 | #include <opie/opimxrefmanager.h> | 11 | #include <opie/opimxrefmanager.h> |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * This is the base class for | 14 | * This is the base class for |
15 | * all PIM Records | 15 | * all PIM Records |
16 | * | 16 | * |
17 | */ | 17 | */ |
18 | class OPimRecord : public Qtopia::Record { | 18 | class OPimRecord : public Qtopia::Record { |
19 | public: | 19 | public: |
20 | /** | 20 | /** |
21 | * c'tor | 21 | * c'tor |
22 | * uid of 0 isEmpty | 22 | * uid of 0 isEmpty |
23 | * uid of 1 will be assigned a new one | 23 | * uid of 1 will be assigned a new one |
24 | */ | 24 | */ |
25 | OPimRecord(int uid = 0); | 25 | OPimRecord(int uid = 0); |
26 | ~OPimRecord(); | 26 | ~OPimRecord(); |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * copy c'tor | 29 | * copy c'tor |
30 | */ | 30 | */ |
31 | OPimRecord( const OPimRecord& rec ); | 31 | OPimRecord( const OPimRecord& rec ); |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * copy operator | 34 | * copy operator |
35 | */ | 35 | */ |
36 | OPimRecord &operator=( const OPimRecord& ); | 36 | OPimRecord &operator=( const OPimRecord& ); |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * category names resolved | 39 | * category names resolved |
40 | */ | 40 | */ |
41 | QStringList categoryNames( const QString& appname )const; | 41 | QStringList categoryNames( const QString& appname )const; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * set category names they will be resolved | 44 | * set category names they will be resolved |
45 | */ | 45 | */ |
46 | void setCategoryNames( const QStringList& ); | 46 | void setCategoryNames( const QStringList& ); |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * addCategoryName adds a name | 49 | * addCategoryName adds a name |
50 | * to the internal category list | 50 | * to the internal category list |
51 | */ | 51 | */ |
52 | void addCategoryName( const QString& ); | 52 | void addCategoryName( const QString& ); |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * if a Record isEmpty | 55 | * if a Record isEmpty |
56 | * it's empty if it's 0 | 56 | * it's empty if it's 0 |
57 | */ | 57 | */ |
58 | virtual bool isEmpty()const; | 58 | virtual bool isEmpty()const; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * toRichText summary | 61 | * toRichText summary |
62 | */ | 62 | */ |
63 | virtual QString toRichText()const = 0; | 63 | virtual QString toRichText()const = 0; |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * a small one line summary | 66 | * a small one line summary |
67 | */ | 67 | */ |
68 | virtual QString toShortText()const = 0; | 68 | virtual QString toShortText()const = 0; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * the name of the Record | 71 | * the name of the Record |
72 | */ | 72 | */ |
73 | virtual QString type()const = 0; | 73 | virtual QString type()const = 0; |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * matches the Records the regular expression? | ||
77 | */ | ||
78 | virtual bool match( const QString ®exp ) const {return match(QRegExp(regexp));}; | ||
79 | virtual bool match( const QRegExp ®exp ) const = 0; | ||
80 | |||
81 | /** | ||
76 | * converts the internal structure to a map | 82 | * converts the internal structure to a map |
77 | */ | 83 | */ |
78 | virtual QMap<int, QString> toMap()const = 0; | 84 | virtual QMap<int, QString> toMap()const = 0; |
79 | 85 | ||
80 | /** | 86 | /** |
81 | * key value representation of extra items | 87 | * key value representation of extra items |
82 | */ | 88 | */ |
83 | virtual QMap<QString, QString> toExtraMap()const = 0; | 89 | virtual QMap<QString, QString> toExtraMap()const = 0; |
84 | 90 | ||
85 | /** | 91 | /** |
86 | * the name for a recordField | 92 | * the name for a recordField |
87 | */ | 93 | */ |
88 | virtual QString recordField(int)const = 0; | 94 | virtual QString recordField(int)const = 0; |
89 | 95 | ||
90 | /** | 96 | /** |
91 | * returns a reference of the | 97 | * returns a reference of the |
92 | * Cross Reference Manager | 98 | * Cross Reference Manager |
93 | * Partner 'One' is THIS PIM RECORD! | 99 | * Partner 'One' is THIS PIM RECORD! |
94 | * 'Two' is the Partner where we link to | 100 | * 'Two' is the Partner where we link to |
95 | */ | 101 | */ |
96 | OPimXRefManager& xrefmanager(); | 102 | OPimXRefManager& xrefmanager(); |
97 | 103 | ||
98 | /** | 104 | /** |
99 | * set the uid | 105 | * set the uid |
100 | */ | 106 | */ |
101 | virtual void setUid( int uid ); | 107 | virtual void setUid( int uid ); |
102 | 108 | ||
103 | /* | 109 | /* |
104 | * used inside the Templates for casting | 110 | * used inside the Templates for casting |
105 | * REIMPLEMENT in your .... | 111 | * REIMPLEMENT in your .... |
106 | */ | 112 | */ |
107 | static int rtti(); | 113 | static int rtti(); |
108 | 114 | ||
109 | /** | 115 | /** |
110 | * some marshalling and de marshalling code | 116 | * some marshalling and de marshalling code |
111 | * saves the OPimRecord | 117 | * saves the OPimRecord |
112 | * to and from a DataStream | 118 | * to and from a DataStream |
113 | */ | 119 | */ |
114 | virtual bool loadFromStream(QDataStream& ); | 120 | virtual bool loadFromStream(QDataStream& ); |
115 | virtual bool saveToStream( QDataStream& stream )const; | 121 | virtual bool saveToStream( QDataStream& stream )const; |
116 | 122 | ||
117 | protected: | 123 | protected: |
118 | Qtopia::UidGen &uidGen(); | 124 | Qtopia::UidGen &uidGen(); |
119 | // QString crossToString()const; | 125 | // QString crossToString()const; |
120 | 126 | ||
121 | private: | 127 | private: |
122 | class OPimRecordPrivate; | 128 | class OPimRecordPrivate; |
123 | OPimRecordPrivate *d; | 129 | OPimRecordPrivate *d; |
124 | OPimXRefManager m_xrefman; | 130 | OPimXRefManager m_xrefman; |
125 | static Qtopia::UidGen m_uidGen; | 131 | static Qtopia::UidGen m_uidGen; |
126 | 132 | ||
127 | private: | 133 | private: |
128 | void flush( const OPimXRefPartner&, QDataStream& stream )const; | 134 | void flush( const OPimXRefPartner&, QDataStream& stream )const; |
129 | OPimXRefPartner partner( QDataStream& ); | 135 | OPimXRefPartner partner( QDataStream& ); |
130 | }; | 136 | }; |
131 | 137 | ||
132 | 138 | ||
133 | 139 | ||
134 | #endif | 140 | #endif |
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h index a58d9aa..0e7c73f 100644 --- a/libopie/pim/otodo.h +++ b/libopie/pim/otodo.h | |||
@@ -165,125 +165,125 @@ public: | |||
165 | /** | 165 | /** |
166 | * A small summary of the todo | 166 | * A small summary of the todo |
167 | */ | 167 | */ |
168 | QString summary() const; | 168 | QString summary() const; |
169 | 169 | ||
170 | /** | 170 | /** |
171 | * @reimplemented | 171 | * @reimplemented |
172 | * Return this todoevent in a RichText formatted QString | 172 | * Return this todoevent in a RichText formatted QString |
173 | */ | 173 | */ |
174 | QString toRichText() const; | 174 | QString toRichText() const; |
175 | 175 | ||
176 | bool hasNotifiers()const; | 176 | bool hasNotifiers()const; |
177 | /* | 177 | /* |
178 | * check if the sharing is still fine!! -zecke | 178 | * check if the sharing is still fine!! -zecke |
179 | */ | 179 | */ |
180 | /** | 180 | /** |
181 | * return a reference to our notifiers... | 181 | * return a reference to our notifiers... |
182 | */ | 182 | */ |
183 | OPimNotifyManager ¬ifiers(); | 183 | OPimNotifyManager ¬ifiers(); |
184 | 184 | ||
185 | /** | 185 | /** |
186 | * reimplementations | 186 | * reimplementations |
187 | */ | 187 | */ |
188 | QString type()const; | 188 | QString type()const; |
189 | QString toShortText()const; | 189 | QString toShortText()const; |
190 | QMap<QString, QString> toExtraMap()const; | 190 | QMap<QString, QString> toExtraMap()const; |
191 | QString recordField(int id )const; | 191 | QString recordField(int id )const; |
192 | 192 | ||
193 | /** | 193 | /** |
194 | * toMap puts all data into the map. int relates | 194 | * toMap puts all data into the map. int relates |
195 | * to ToDoEvent RecordFields enum | 195 | * to ToDoEvent RecordFields enum |
196 | */ | 196 | */ |
197 | QMap<int, QString> toMap()const; | 197 | QMap<int, QString> toMap()const; |
198 | 198 | ||
199 | /** | 199 | /** |
200 | * Set if this Todo is completed | 200 | * Set if this Todo is completed |
201 | */ | 201 | */ |
202 | void setCompleted(bool completed ); | 202 | void setCompleted(bool completed ); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | * set if this todo got an end data | 205 | * set if this todo got an end data |
206 | */ | 206 | */ |
207 | void setHasDueDate( bool hasDate ); | 207 | void setHasDueDate( bool hasDate ); |
208 | // FIXME we do not have these for start, completed | 208 | // FIXME we do not have these for start, completed |
209 | // cause we'll use the isNull() of QDate for figuring | 209 | // cause we'll use the isNull() of QDate for figuring |
210 | // out if it's has a date... | 210 | // out if it's has a date... |
211 | // decide what to do here? -zecke | 211 | // decide what to do here? -zecke |
212 | 212 | ||
213 | /** | 213 | /** |
214 | * Set the priority of the Todo | 214 | * Set the priority of the Todo |
215 | */ | 215 | */ |
216 | void setPriority(int priority ); | 216 | void setPriority(int priority ); |
217 | 217 | ||
218 | /** | 218 | /** |
219 | * Set the progress. | 219 | * Set the progress. |
220 | */ | 220 | */ |
221 | void setProgress( ushort progress ); | 221 | void setProgress( ushort progress ); |
222 | 222 | ||
223 | /** | 223 | /** |
224 | * set the end date | 224 | * set the end date |
225 | */ | 225 | */ |
226 | void setDueDate( const QDate& date ); | 226 | void setDueDate( const QDate& date ); |
227 | 227 | ||
228 | /** | 228 | /** |
229 | * set the start date | 229 | * set the start date |
230 | */ | 230 | */ |
231 | void setStartDate( const QDate& date ); | 231 | void setStartDate( const QDate& date ); |
232 | 232 | ||
233 | /** | 233 | /** |
234 | * set the completed date | 234 | * set the completed date |
235 | */ | 235 | */ |
236 | void setCompletedDate( const QDate& date ); | 236 | void setCompletedDate( const QDate& date ); |
237 | 237 | ||
238 | void setRecurrence( const ORecur& ); | 238 | void setRecurrence( const ORecur& ); |
239 | /** | 239 | /** |
240 | * set the alarm time | 240 | * set the alarm time |
241 | */ | 241 | */ |
242 | void setAlarmDateTime ( const QDateTime& alarm ); | 242 | void setAlarmDateTime ( const QDateTime& alarm ); |
243 | 243 | ||
244 | void setDescription(const QString& ); | 244 | void setDescription(const QString& ); |
245 | void setSummary(const QString& ); | 245 | void setSummary(const QString& ); |
246 | 246 | ||
247 | /** | 247 | /** |
248 | * set the state of a Todo | 248 | * set the state of a Todo |
249 | * @param state State what the todo should take | 249 | * @param state State what the todo should take |
250 | */ | 250 | */ |
251 | void setState( const OPimState& state); | 251 | void setState( const OPimState& state); |
252 | 252 | ||
253 | /** | 253 | /** |
254 | * set the Maintainer Mode | 254 | * set the Maintainer Mode |
255 | */ | 255 | */ |
256 | void setMaintainer( const OPimMaintainer& ); | 256 | void setMaintainer( const OPimMaintainer& ); |
257 | 257 | ||
258 | bool isOverdue(); | 258 | bool isOverdue(); |
259 | 259 | ||
260 | 260 | ||
261 | bool match( const QRegExp &r )const; | 261 | virtual bool match( const QRegExp &r )const; |
262 | 262 | ||
263 | bool operator<(const OTodo &toDoEvent )const; | 263 | bool operator<(const OTodo &toDoEvent )const; |
264 | bool operator<=(const OTodo &toDoEvent )const; | 264 | bool operator<=(const OTodo &toDoEvent )const; |
265 | bool operator!=(const OTodo &toDoEvent )const; | 265 | bool operator!=(const OTodo &toDoEvent )const; |
266 | bool operator>(const OTodo &toDoEvent )const; | 266 | bool operator>(const OTodo &toDoEvent )const; |
267 | bool operator>=(const OTodo &toDoEvent)const; | 267 | bool operator>=(const OTodo &toDoEvent)const; |
268 | bool operator==(const OTodo &toDoEvent )const; | 268 | bool operator==(const OTodo &toDoEvent )const; |
269 | OTodo &operator=(const OTodo &toDoEvent ); | 269 | OTodo &operator=(const OTodo &toDoEvent ); |
270 | 270 | ||
271 | static int rtti(); | 271 | static int rtti(); |
272 | 272 | ||
273 | private: | 273 | private: |
274 | class OTodoPrivate; | 274 | class OTodoPrivate; |
275 | struct OTodoData; | 275 | struct OTodoData; |
276 | 276 | ||
277 | void deref(); | 277 | void deref(); |
278 | inline void changeOrModify(); | 278 | inline void changeOrModify(); |
279 | void copy( OTodoData* src, OTodoData* dest ); | 279 | void copy( OTodoData* src, OTodoData* dest ); |
280 | OTodoPrivate *d; | 280 | OTodoPrivate *d; |
281 | OTodoData *data; | 281 | OTodoData *data; |
282 | 282 | ||
283 | }; | 283 | }; |
284 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { | 284 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { |
285 | return !(*this == toDoEvent); | 285 | return !(*this == toDoEvent); |
286 | } | 286 | } |
287 | 287 | ||
288 | 288 | ||
289 | #endif | 289 | #endif |
diff --git a/libopie/pim/otodoaccessvcal.cpp b/libopie/pim/otodoaccessvcal.cpp index 9bc16c6..3577e14 100644 --- a/libopie/pim/otodoaccessvcal.cpp +++ b/libopie/pim/otodoaccessvcal.cpp | |||
@@ -92,130 +92,134 @@ OTodoAccessVCal::~OTodoAccessVCal() { | |||
92 | bool OTodoAccessVCal::load() { | 92 | bool OTodoAccessVCal::load() { |
93 | m_map.clear(); | 93 | m_map.clear(); |
94 | m_dirty = false; | 94 | m_dirty = false; |
95 | 95 | ||
96 | VObject* vcal = 0l; | 96 | VObject* vcal = 0l; |
97 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); | 97 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); |
98 | if (!vcal ) | 98 | if (!vcal ) |
99 | return false; | 99 | return false; |
100 | 100 | ||
101 | // Iterate over the list | 101 | // Iterate over the list |
102 | VObjectIterator it; | 102 | VObjectIterator it; |
103 | VObject* vobj; | 103 | VObject* vobj; |
104 | 104 | ||
105 | initPropIterator(&it, vcal); | 105 | initPropIterator(&it, vcal); |
106 | 106 | ||
107 | while( moreIteration( &it ) ) { | 107 | while( moreIteration( &it ) ) { |
108 | vobj = ::nextVObject( &it ); | 108 | vobj = ::nextVObject( &it ); |
109 | QCString name = ::vObjectName( vobj ); | 109 | QCString name = ::vObjectName( vobj ); |
110 | if( name == VCTodoProp ){ | 110 | if( name == VCTodoProp ){ |
111 | OTodo to = eventByVObj( vobj ); | 111 | OTodo to = eventByVObj( vobj ); |
112 | m_map.insert( to.uid(), to ); | 112 | m_map.insert( to.uid(), to ); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | // Should I do a delete vcal? | 116 | // Should I do a delete vcal? |
117 | 117 | ||
118 | return true; | 118 | return true; |
119 | } | 119 | } |
120 | bool OTodoAccessVCal::reload() { | 120 | bool OTodoAccessVCal::reload() { |
121 | return load(); | 121 | return load(); |
122 | } | 122 | } |
123 | bool OTodoAccessVCal::save() { | 123 | bool OTodoAccessVCal::save() { |
124 | if (!m_dirty ) | 124 | if (!m_dirty ) |
125 | return true; | 125 | return true; |
126 | 126 | ||
127 | QFileDirect file( m_file ); | 127 | QFileDirect file( m_file ); |
128 | if (!file.open(IO_WriteOnly ) ) | 128 | if (!file.open(IO_WriteOnly ) ) |
129 | return false; | 129 | return false; |
130 | 130 | ||
131 | VObject *obj; | 131 | VObject *obj; |
132 | obj = newVObject( VCCalProp ); | 132 | obj = newVObject( VCCalProp ); |
133 | addPropValue( obj, VCVersionProp, "1.0" ); | 133 | addPropValue( obj, VCVersionProp, "1.0" ); |
134 | VObject *vo; | 134 | VObject *vo; |
135 | for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ | 135 | for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ |
136 | vo = vobjByEvent( it.data() ); | 136 | vo = vobjByEvent( it.data() ); |
137 | addVObjectProp(obj, vo ); | 137 | addVObjectProp(obj, vo ); |
138 | } | 138 | } |
139 | writeVObject( file.directHandle(), obj ); | 139 | writeVObject( file.directHandle(), obj ); |
140 | cleanVObject( obj ); | 140 | cleanVObject( obj ); |
141 | cleanStrTbl(); | 141 | cleanStrTbl(); |
142 | 142 | ||
143 | m_dirty = false; | 143 | m_dirty = false; |
144 | return true; | 144 | return true; |
145 | } | 145 | } |
146 | void OTodoAccessVCal::clear() { | 146 | void OTodoAccessVCal::clear() { |
147 | m_map.clear(); | 147 | m_map.clear(); |
148 | m_dirty = true; | 148 | m_dirty = true; |
149 | } | 149 | } |
150 | bool OTodoAccessVCal::add( const OTodo& to ) { | 150 | bool OTodoAccessVCal::add( const OTodo& to ) { |
151 | m_map.insert( to.uid(), to ); | 151 | m_map.insert( to.uid(), to ); |
152 | m_dirty = true; | 152 | m_dirty = true; |
153 | return true; | 153 | return true; |
154 | } | 154 | } |
155 | bool OTodoAccessVCal::remove( int uid ) { | 155 | bool OTodoAccessVCal::remove( int uid ) { |
156 | m_map.remove( uid ); | 156 | m_map.remove( uid ); |
157 | m_dirty = true; | 157 | m_dirty = true; |
158 | return true; | 158 | return true; |
159 | } | 159 | } |
160 | void OTodoAccessVCal::removeAllCompleted() { | 160 | void OTodoAccessVCal::removeAllCompleted() { |
161 | for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { | 161 | for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { |
162 | if ( (*it).isCompleted() ) | 162 | if ( (*it).isCompleted() ) |
163 | m_map.remove( it ); | 163 | m_map.remove( it ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | bool OTodoAccessVCal::replace( const OTodo& to ) { | 166 | bool OTodoAccessVCal::replace( const OTodo& to ) { |
167 | m_map.replace( to.uid(), to ); | 167 | m_map.replace( to.uid(), to ); |
168 | m_dirty = true; | 168 | m_dirty = true; |
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | OTodo OTodoAccessVCal::find(int uid )const { | 171 | OTodo OTodoAccessVCal::find(int uid )const { |
172 | return m_map[uid]; | 172 | return m_map[uid]; |
173 | } | 173 | } |
174 | QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { | 174 | QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { |
175 | QArray<int> ar(0); | 175 | QArray<int> ar(0); |
176 | return ar; | 176 | return ar; |
177 | } | 177 | } |
178 | QArray<int> OTodoAccessVCal::allRecords()const { | 178 | QArray<int> OTodoAccessVCal::allRecords()const { |
179 | QArray<int> ar( m_map.count() ); | 179 | QArray<int> ar( m_map.count() ); |
180 | QMap<int, OTodo>::ConstIterator it; | 180 | QMap<int, OTodo>::ConstIterator it; |
181 | int i = 0; | 181 | int i = 0; |
182 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | 182 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { |
183 | ar[i] = it.key(); | 183 | ar[i] = it.key(); |
184 | i++; | 184 | i++; |
185 | } | 185 | } |
186 | return ar; | 186 | return ar; |
187 | } | 187 | } |
188 | QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp &r)const { | ||
189 | QArray<int> ar(0); | ||
190 | return ar; | ||
191 | } | ||
188 | QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { | 192 | QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { |
189 | QArray<int> ar(0); | 193 | QArray<int> ar(0); |
190 | return ar; | 194 | return ar; |
191 | } | 195 | } |
192 | QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , | 196 | QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , |
193 | const QDate& , | 197 | const QDate& , |
194 | bool ) { | 198 | bool ) { |
195 | QArray<int> ar(0); | 199 | QArray<int> ar(0); |
196 | return ar; | 200 | return ar; |
197 | } | 201 | } |
198 | QArray<int> OTodoAccessVCal::overDue() { | 202 | QArray<int> OTodoAccessVCal::overDue() { |
199 | QArray<int> ar(0); | 203 | QArray<int> ar(0); |
200 | return ar; | 204 | return ar; |
201 | } | 205 | } |
202 | QBitArray OTodoAccessVCal::supports()const { | 206 | QBitArray OTodoAccessVCal::supports()const { |
203 | static QBitArray ar = sup(); | 207 | static QBitArray ar = sup(); |
204 | 208 | ||
205 | return ar; | 209 | return ar; |
206 | } | 210 | } |
207 | QBitArray OTodoAccessVCal::sup() { | 211 | QBitArray OTodoAccessVCal::sup() { |
208 | QBitArray ar ( OTodo::CompletedDate +1 ); | 212 | QBitArray ar ( OTodo::CompletedDate +1 ); |
209 | ar.fill( true ); | 213 | ar.fill( true ); |
210 | 214 | ||
211 | ar[OTodo::CrossReference] = false; | 215 | ar[OTodo::CrossReference] = false; |
212 | ar[OTodo::State ] = false; | 216 | ar[OTodo::State ] = false; |
213 | ar[OTodo::Reminders] = false; | 217 | ar[OTodo::Reminders] = false; |
214 | ar[OTodo::Notifiers] = false; | 218 | ar[OTodo::Notifiers] = false; |
215 | ar[OTodo::Maintainer] = false; | 219 | ar[OTodo::Maintainer] = false; |
216 | ar[OTodo::Progress] = false; | 220 | ar[OTodo::Progress] = false; |
217 | ar[OTodo::Alarms ] = false; | 221 | ar[OTodo::Alarms ] = false; |
218 | ar[OTodo::Recurrence] = false; | 222 | ar[OTodo::Recurrence] = false; |
219 | 223 | ||
220 | return ar; | 224 | return ar; |
221 | } | 225 | } |
diff --git a/libopie/pim/otodoaccessvcal.h b/libopie/pim/otodoaccessvcal.h index 489416b..2b17147 100644 --- a/libopie/pim/otodoaccessvcal.h +++ b/libopie/pim/otodoaccessvcal.h | |||
@@ -1,39 +1,40 @@ | |||
1 | #ifndef OPIE_OTODO_ACCESS_VCAL_H | 1 | #ifndef OPIE_OTODO_ACCESS_VCAL_H |
2 | #define OPIE_OTODO_ACCESS_VCAL_H | 2 | #define OPIE_OTODO_ACCESS_VCAL_H |
3 | 3 | ||
4 | #include "otodoaccessbackend.h" | 4 | #include "otodoaccessbackend.h" |
5 | 5 | ||
6 | class OTodoAccessVCal : public OTodoAccessBackend { | 6 | class OTodoAccessVCal : public OTodoAccessBackend { |
7 | public: | 7 | public: |
8 | OTodoAccessVCal(const QString& ); | 8 | OTodoAccessVCal(const QString& ); |
9 | ~OTodoAccessVCal(); | 9 | ~OTodoAccessVCal(); |
10 | 10 | ||
11 | bool load(); | 11 | bool load(); |
12 | bool reload(); | 12 | bool reload(); |
13 | bool save(); | 13 | bool save(); |
14 | 14 | ||
15 | QArray<int> allRecords()const; | 15 | QArray<int> allRecords()const; |
16 | QArray<int> matchRegexp(const QRegExp &r) const; | ||
16 | QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() ); | 17 | QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() ); |
17 | QArray<int> effectiveToDos( const QDate& start, | 18 | QArray<int> effectiveToDos( const QDate& start, |
18 | const QDate& end, | 19 | const QDate& end, |
19 | bool includeNoDates ); | 20 | bool includeNoDates ); |
20 | QArray<int> overDue(); | 21 | QArray<int> overDue(); |
21 | QArray<int> sorted( bool asc, int sortOrder, int sortFilter, | 22 | QArray<int> sorted( bool asc, int sortOrder, int sortFilter, |
22 | int cat ); | 23 | int cat ); |
23 | OTodo find(int uid)const; | 24 | OTodo find(int uid)const; |
24 | void clear(); | 25 | void clear(); |
25 | bool add( const OTodo& ); | 26 | bool add( const OTodo& ); |
26 | bool remove( int uid ); | 27 | bool remove( int uid ); |
27 | bool replace( const OTodo& ); | 28 | bool replace( const OTodo& ); |
28 | 29 | ||
29 | void removeAllCompleted(); | 30 | void removeAllCompleted(); |
30 | virtual QBitArray supports()const; | 31 | virtual QBitArray supports()const; |
31 | 32 | ||
32 | private: | 33 | private: |
33 | static QBitArray sup(); | 34 | static QBitArray sup(); |
34 | bool m_dirty : 1; | 35 | bool m_dirty : 1; |
35 | QString m_file; | 36 | QString m_file; |
36 | QMap<int, OTodo> m_map; | 37 | QMap<int, OTodo> m_map; |
37 | }; | 38 | }; |
38 | 39 | ||
39 | #endif | 40 | #endif |
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp index 285d2b8..69b7ab4 100644 --- a/libopie/pim/otodoaccessxml.cpp +++ b/libopie/pim/otodoaccessxml.cpp | |||
@@ -681,96 +681,112 @@ public: | |||
681 | return ret; | 681 | return ret; |
682 | } | 682 | } |
683 | } | 683 | } |
684 | if (!seDesc ) { | 684 | if (!seDesc ) { |
685 | if ( (ret = description(con1->todo, con2->todo ) ) ) { | 685 | if ( (ret = description(con1->todo, con2->todo ) ) ) { |
686 | if (!m_asc) ret *= -1; | 686 | if (!m_asc) ret *= -1; |
687 | return ret; | 687 | return ret; |
688 | } | 688 | } |
689 | } | 689 | } |
690 | if (!seDeadline) { | 690 | if (!seDeadline) { |
691 | if ( (ret = deadline( con1->todo, con2->todo ) ) ) { | 691 | if ( (ret = deadline( con1->todo, con2->todo ) ) ) { |
692 | if (!m_asc) ret *= -1; | 692 | if (!m_asc) ret *= -1; |
693 | return ret; | 693 | return ret; |
694 | } | 694 | } |
695 | } | 695 | } |
696 | 696 | ||
697 | return 0; | 697 | return 0; |
698 | } | 698 | } |
699 | private: | 699 | private: |
700 | bool m_asc; | 700 | bool m_asc; |
701 | int m_sort; | 701 | int m_sort; |
702 | 702 | ||
703 | }; | 703 | }; |
704 | 704 | ||
705 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, | 705 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, |
706 | int sortFilter, int cat ) { | 706 | int sortFilter, int cat ) { |
707 | qWarning("sorted! %d cat", cat); | 707 | qWarning("sorted! %d cat", cat); |
708 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); | 708 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); |
709 | QMap<int, OTodo>::Iterator it; | 709 | QMap<int, OTodo>::Iterator it; |
710 | int item = 0; | 710 | int item = 0; |
711 | 711 | ||
712 | bool bCat = sortFilter & 1 ? true : false; | 712 | bool bCat = sortFilter & 1 ? true : false; |
713 | bool bOnly = sortFilter & 2 ? true : false; | 713 | bool bOnly = sortFilter & 2 ? true : false; |
714 | bool comp = sortFilter & 4 ? true : false; | 714 | bool comp = sortFilter & 4 ? true : false; |
715 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 715 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
716 | 716 | ||
717 | /* show category */ | 717 | /* show category */ |
718 | if ( bCat && cat != 0) | 718 | if ( bCat && cat != 0) |
719 | if (!(*it).categories().contains( cat ) ) { | 719 | if (!(*it).categories().contains( cat ) ) { |
720 | qWarning("category mis match"); | 720 | qWarning("category mis match"); |
721 | continue; | 721 | continue; |
722 | } | 722 | } |
723 | /* isOverdue but we should not show overdue - why?*/ | 723 | /* isOverdue but we should not show overdue - why?*/ |
724 | /* if ( (*it).isOverdue() && !bOnly ) { | 724 | /* if ( (*it).isOverdue() && !bOnly ) { |
725 | qWarning("item is overdue but !bOnly"); | 725 | qWarning("item is overdue but !bOnly"); |
726 | continue; | 726 | continue; |
727 | } | 727 | } |
728 | */ | 728 | */ |
729 | if ( !(*it).isOverdue() && bOnly ) { | 729 | if ( !(*it).isOverdue() && bOnly ) { |
730 | qWarning("item is not overdue but bOnly checked"); | 730 | qWarning("item is not overdue but bOnly checked"); |
731 | continue; | 731 | continue; |
732 | } | 732 | } |
733 | 733 | ||
734 | if ((*it).isCompleted() && comp ) { | 734 | if ((*it).isCompleted() && comp ) { |
735 | qWarning("completed continue!"); | 735 | qWarning("completed continue!"); |
736 | continue; | 736 | continue; |
737 | } | 737 | } |
738 | 738 | ||
739 | 739 | ||
740 | OTodoXMLContainer* con = new OTodoXMLContainer(); | 740 | OTodoXMLContainer* con = new OTodoXMLContainer(); |
741 | con->todo = (*it); | 741 | con->todo = (*it); |
742 | vector.insert(item, con ); | 742 | vector.insert(item, con ); |
743 | item++; | 743 | item++; |
744 | } | 744 | } |
745 | qWarning("XXX %d Items added", item); | 745 | qWarning("XXX %d Items added", item); |
746 | vector.resize( item ); | 746 | vector.resize( item ); |
747 | /* sort it now */ | 747 | /* sort it now */ |
748 | vector.sort(); | 748 | vector.sort(); |
749 | /* now get the uids */ | 749 | /* now get the uids */ |
750 | QArray<int> array( vector.count() ); | 750 | QArray<int> array( vector.count() ); |
751 | for (uint i= 0; i < vector.count(); i++ ) { | 751 | for (uint i= 0; i < vector.count(); i++ ) { |
752 | array[i] = ( vector.at(i) )->todo.uid(); | 752 | array[i] = ( vector.at(i) )->todo.uid(); |
753 | } | 753 | } |
754 | return array; | 754 | return array; |
755 | }; | 755 | }; |
756 | void OTodoAccessXML::removeAllCompleted() { | 756 | void OTodoAccessXML::removeAllCompleted() { |
757 | for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { | 757 | for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { |
758 | if ( (*it).isCompleted() ) | 758 | if ( (*it).isCompleted() ) |
759 | m_events.remove( it ); | 759 | m_events.remove( it ); |
760 | } | 760 | } |
761 | } | 761 | } |
762 | QBitArray OTodoAccessXML::supports()const { | 762 | QBitArray OTodoAccessXML::supports()const { |
763 | static QBitArray ar = sup(); | 763 | static QBitArray ar = sup(); |
764 | return ar; | 764 | return ar; |
765 | } | 765 | } |
766 | QBitArray OTodoAccessXML::sup() { | 766 | QBitArray OTodoAccessXML::sup() { |
767 | QBitArray ar( OTodo::CompletedDate +1 ); | 767 | QBitArray ar( OTodo::CompletedDate +1 ); |
768 | ar.fill( true ); | 768 | ar.fill( true ); |
769 | ar[OTodo::CrossReference] = false; | 769 | ar[OTodo::CrossReference] = false; |
770 | ar[OTodo::State ] = false; | 770 | ar[OTodo::State ] = false; |
771 | ar[OTodo::Reminders] = false; | 771 | ar[OTodo::Reminders] = false; |
772 | ar[OTodo::Notifiers] = false; | 772 | ar[OTodo::Notifiers] = false; |
773 | ar[OTodo::Maintainer] = false; | 773 | ar[OTodo::Maintainer] = false; |
774 | 774 | ||
775 | return ar; | 775 | return ar; |
776 | } | 776 | } |
777 | QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const | ||
778 | { | ||
779 | QArray<int> m_currentQuery( m_events.count() ); | ||
780 | uint arraycounter = 0; | ||
781 | |||
782 | QMap<int, OTodo>::ConstIterator it; | ||
783 | for (it = m_events.begin(); it != m_events.end(); ++it ) { | ||
784 | if ( it.data().match( r ) ) | ||
785 | m_currentQuery[arraycounter++] = it.data().uid(); | ||
786 | |||
787 | } | ||
788 | // Shrink to fit.. | ||
789 | m_currentQuery.resize(arraycounter); | ||
790 | |||
791 | return m_currentQuery; | ||
792 | } | ||
diff --git a/libopie/pim/otodoaccessxml.h b/libopie/pim/otodoaccessxml.h index cc4a16f..e4850a1 100644 --- a/libopie/pim/otodoaccessxml.h +++ b/libopie/pim/otodoaccessxml.h | |||
@@ -1,59 +1,60 @@ | |||
1 | #ifndef OPIE_TODO_ACCESS_XML_H | 1 | #ifndef OPIE_TODO_ACCESS_XML_H |
2 | #define OPIE_TODO_ACCESS_XML_H | 2 | #define OPIE_TODO_ACCESS_XML_H |
3 | 3 | ||
4 | #include <qasciidict.h> | 4 | #include <qasciidict.h> |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | 6 | ||
7 | #include "otodoaccessbackend.h" | 7 | #include "otodoaccessbackend.h" |
8 | 8 | ||
9 | namespace Opie { | 9 | namespace Opie { |
10 | class XMLElement; | 10 | class XMLElement; |
11 | }; | 11 | }; |
12 | 12 | ||
13 | class OTodoAccessXML : public OTodoAccessBackend { | 13 | class OTodoAccessXML : public OTodoAccessBackend { |
14 | public: | 14 | public: |
15 | /** | 15 | /** |
16 | * fileName if Empty we will use the default path | 16 | * fileName if Empty we will use the default path |
17 | */ | 17 | */ |
18 | OTodoAccessXML( const QString& appName, | 18 | OTodoAccessXML( const QString& appName, |
19 | const QString& fileName = QString::null ); | 19 | const QString& fileName = QString::null ); |
20 | ~OTodoAccessXML(); | 20 | ~OTodoAccessXML(); |
21 | 21 | ||
22 | bool load(); | 22 | bool load(); |
23 | bool reload(); | 23 | bool reload(); |
24 | bool save(); | 24 | bool save(); |
25 | 25 | ||
26 | QArray<int> allRecords()const; | 26 | QArray<int> allRecords()const; |
27 | QArray<int> matchRegexp(const QRegExp &r) const; | ||
27 | QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() ); | 28 | QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() ); |
28 | OTodo find( int uid )const; | 29 | OTodo find( int uid )const; |
29 | void clear(); | 30 | void clear(); |
30 | bool add( const OTodo& ); | 31 | bool add( const OTodo& ); |
31 | bool remove( int uid ); | 32 | bool remove( int uid ); |
32 | void removeAllCompleted(); | 33 | void removeAllCompleted(); |
33 | bool replace( const OTodo& ); | 34 | bool replace( const OTodo& ); |
34 | 35 | ||
35 | /* our functions */ | 36 | /* our functions */ |
36 | QArray<int> effectiveToDos( const QDate& start, | 37 | QArray<int> effectiveToDos( const QDate& start, |
37 | const QDate& end, | 38 | const QDate& end, |
38 | bool includeNoDates ); | 39 | bool includeNoDates ); |
39 | QArray<int> overDue(); | 40 | QArray<int> overDue(); |
40 | QArray<int> sorted( bool asc, int sortOrder, | 41 | QArray<int> sorted( bool asc, int sortOrder, |
41 | int sortFilter, int cat ); | 42 | int sortFilter, int cat ); |
42 | QBitArray supports()const; | 43 | QBitArray supports()const; |
43 | private: | 44 | private: |
44 | static QBitArray sup(); | 45 | static QBitArray sup(); |
45 | void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& ); | 46 | void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& ); |
46 | QString toString( const OTodo& )const; | 47 | QString toString( const OTodo& )const; |
47 | QString toString( const QArray<int>& ints ) const; | 48 | QString toString( const QArray<int>& ints ) const; |
48 | QMap<int, OTodo> m_events; | 49 | QMap<int, OTodo> m_events; |
49 | QString m_file; | 50 | QString m_file; |
50 | QString m_app; | 51 | QString m_app; |
51 | bool m_opened : 1; | 52 | bool m_opened : 1; |
52 | bool m_changed : 1; | 53 | bool m_changed : 1; |
53 | class OTodoAccessXMLPrivate; | 54 | class OTodoAccessXMLPrivate; |
54 | OTodoAccessXMLPrivate* d; | 55 | OTodoAccessXMLPrivate* d; |
55 | int m_year, m_month, m_day; | 56 | int m_year, m_month, m_day; |
56 | 57 | ||
57 | }; | 58 | }; |
58 | 59 | ||
59 | #endif | 60 | #endif |
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp index a0ae7b7..ab2eea4 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp | |||
@@ -493,96 +493,114 @@ void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& val | |||
493 | case FDescription: | 493 | case FDescription: |
494 | e.setDescription( value ); | 494 | e.setDescription( value ); |
495 | break; | 495 | break; |
496 | case FLocation: | 496 | case FLocation: |
497 | e.setLocation( value ); | 497 | e.setLocation( value ); |
498 | break; | 498 | break; |
499 | case FCategories: | 499 | case FCategories: |
500 | e.setCategories( e.idsFromString( value ) ); | 500 | e.setCategories( e.idsFromString( value ) ); |
501 | break; | 501 | break; |
502 | case FUid: | 502 | case FUid: |
503 | e.setUid( value.toInt() ); | 503 | e.setUid( value.toInt() ); |
504 | break; | 504 | break; |
505 | case FType: | 505 | case FType: |
506 | if ( value == "AllDay" ) { | 506 | if ( value == "AllDay" ) { |
507 | e.setAllDay( true ); | 507 | e.setAllDay( true ); |
508 | e.setTimeZone( "UTC" ); | 508 | e.setTimeZone( "UTC" ); |
509 | } | 509 | } |
510 | break; | 510 | break; |
511 | case FAlarm: | 511 | case FAlarm: |
512 | alarmTime = value.toInt(); | 512 | alarmTime = value.toInt(); |
513 | break; | 513 | break; |
514 | case FSound: | 514 | case FSound: |
515 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; | 515 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; |
516 | break; | 516 | break; |
517 | // recurrence stuff | 517 | // recurrence stuff |
518 | case FRType: | 518 | case FRType: |
519 | if ( value == "Daily" ) | 519 | if ( value == "Daily" ) |
520 | recur()->setType( ORecur::Daily ); | 520 | recur()->setType( ORecur::Daily ); |
521 | else if ( value == "Weekly" ) | 521 | else if ( value == "Weekly" ) |
522 | recur()->setType( ORecur::Weekly); | 522 | recur()->setType( ORecur::Weekly); |
523 | else if ( value == "MonthlyDay" ) | 523 | else if ( value == "MonthlyDay" ) |
524 | recur()->setType( ORecur::MonthlyDay ); | 524 | recur()->setType( ORecur::MonthlyDay ); |
525 | else if ( value == "MonthlyDate" ) | 525 | else if ( value == "MonthlyDate" ) |
526 | recur()->setType( ORecur::MonthlyDate ); | 526 | recur()->setType( ORecur::MonthlyDate ); |
527 | else if ( value == "Yearly" ) | 527 | else if ( value == "Yearly" ) |
528 | recur()->setType( ORecur::Yearly ); | 528 | recur()->setType( ORecur::Yearly ); |
529 | else | 529 | else |
530 | recur()->setType( ORecur::NoRepeat ); | 530 | recur()->setType( ORecur::NoRepeat ); |
531 | break; | 531 | break; |
532 | case FRWeekdays: | 532 | case FRWeekdays: |
533 | recur()->setDays( value.toInt() ); | 533 | recur()->setDays( value.toInt() ); |
534 | break; | 534 | break; |
535 | case FRPosition: | 535 | case FRPosition: |
536 | recur()->setPosition( value.toInt() ); | 536 | recur()->setPosition( value.toInt() ); |
537 | break; | 537 | break; |
538 | case FRFreq: | 538 | case FRFreq: |
539 | recur()->setFrequency( value.toInt() ); | 539 | recur()->setFrequency( value.toInt() ); |
540 | break; | 540 | break; |
541 | case FRHasEndDate: | 541 | case FRHasEndDate: |
542 | recur()->setHasEndDate( value.toInt() ); | 542 | recur()->setHasEndDate( value.toInt() ); |
543 | break; | 543 | break; |
544 | case FREndDate: { | 544 | case FREndDate: { |
545 | rp_end = (time_t) value.toLong(); | 545 | rp_end = (time_t) value.toLong(); |
546 | break; | 546 | break; |
547 | } | 547 | } |
548 | case FRStart: { | 548 | case FRStart: { |
549 | start = (time_t) value.toLong(); | 549 | start = (time_t) value.toLong(); |
550 | break; | 550 | break; |
551 | } | 551 | } |
552 | case FREnd: { | 552 | case FREnd: { |
553 | end = ( (time_t) value.toLong() ); | 553 | end = ( (time_t) value.toLong() ); |
554 | break; | 554 | break; |
555 | } | 555 | } |
556 | case FNote: | 556 | case FNote: |
557 | e.setNote( value ); | 557 | e.setNote( value ); |
558 | break; | 558 | break; |
559 | case FCreated: | 559 | case FCreated: |
560 | created = value.toInt(); | 560 | created = value.toInt(); |
561 | break; | 561 | break; |
562 | case FRecParent: | 562 | case FRecParent: |
563 | e.setParent( value.toInt() ); | 563 | e.setParent( value.toInt() ); |
564 | break; | 564 | break; |
565 | case FRecChildren:{ | 565 | case FRecChildren:{ |
566 | QStringList list = QStringList::split(' ', value ); | 566 | QStringList list = QStringList::split(' ', value ); |
567 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 567 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
568 | e.addChild( (*it).toInt() ); | 568 | e.addChild( (*it).toInt() ); |
569 | } | 569 | } |
570 | } | 570 | } |
571 | break; | 571 | break; |
572 | case FExceptions:{ | 572 | case FExceptions:{ |
573 | QStringList list = QStringList::split(' ', value ); | 573 | QStringList list = QStringList::split(' ', value ); |
574 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 574 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
575 | QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() ); | 575 | QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() ); |
576 | qWarning("adding exception %s", date.toString().latin1() ); | 576 | qWarning("adding exception %s", date.toString().latin1() ); |
577 | recur()->exceptions().append( date ); | 577 | recur()->exceptions().append( date ); |
578 | } | 578 | } |
579 | } | 579 | } |
580 | break; | 580 | break; |
581 | case FTimeZone: | 581 | case FTimeZone: |
582 | if ( value != "None" ) | 582 | if ( value != "None" ) |
583 | e.setTimeZone( value ); | 583 | e.setTimeZone( value ); |
584 | break; | 584 | break; |
585 | default: | 585 | default: |
586 | break; | 586 | break; |
587 | } | 587 | } |
588 | } | 588 | } |
589 | QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const | ||
590 | { | ||
591 | QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() ); | ||
592 | uint arraycounter = 0; | ||
593 | QMap<int, OEvent>::ConstIterator it; | ||
594 | |||
595 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) | ||
596 | if ( it.data().match( r ) ) | ||
597 | m_currentQuery[arraycounter++] = it.data().uid(); | ||
598 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) | ||
599 | if ( it.data().match( r ) ) | ||
600 | m_currentQuery[arraycounter++] = it.data().uid(); | ||
601 | |||
602 | // Shrink to fit.. | ||
603 | m_currentQuery.resize(arraycounter); | ||
604 | |||
605 | return m_currentQuery; | ||
606 | } | ||
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h index 7848f7c..a5cc0fc 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h +++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h | |||
@@ -1,54 +1,55 @@ | |||
1 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H | 1 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H |
2 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H | 2 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H |
3 | 3 | ||
4 | #include <qmap.h> | 4 | #include <qmap.h> |
5 | 5 | ||
6 | #include "odatebookaccessbackend.h" | 6 | #include "odatebookaccessbackend.h" |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * This is the default XML implementation for DateBoook XML storage | 9 | * This is the default XML implementation for DateBoook XML storage |
10 | * It fully implements the interface | 10 | * It fully implements the interface |
11 | * @see ODateBookAccessBackend | 11 | * @see ODateBookAccessBackend |
12 | * @see OPimAccessBackend | 12 | * @see OPimAccessBackend |
13 | */ | 13 | */ |
14 | class ODateBookAccessBackend_XML : public ODateBookAccessBackend { | 14 | class ODateBookAccessBackend_XML : public ODateBookAccessBackend { |
15 | public: | 15 | public: |
16 | ODateBookAccessBackend_XML( const QString& appName, | 16 | ODateBookAccessBackend_XML( const QString& appName, |
17 | const QString& fileName = QString::null); | 17 | const QString& fileName = QString::null); |
18 | ~ODateBookAccessBackend_XML(); | 18 | ~ODateBookAccessBackend_XML(); |
19 | 19 | ||
20 | bool load(); | 20 | bool load(); |
21 | bool reload(); | 21 | bool reload(); |
22 | bool save(); | 22 | bool save(); |
23 | 23 | ||
24 | QArray<int> allRecords()const; | 24 | QArray<int> allRecords()const; |
25 | QArray<int> matchRegexp(const QRegExp &r) const; | ||
25 | QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); | 26 | QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); |
26 | OEvent find( int uid )const; | 27 | OEvent find( int uid )const; |
27 | void clear(); | 28 | void clear(); |
28 | bool add( const OEvent& ev ); | 29 | bool add( const OEvent& ev ); |
29 | bool remove( int uid ); | 30 | bool remove( int uid ); |
30 | bool replace( const OEvent& ev ); | 31 | bool replace( const OEvent& ev ); |
31 | 32 | ||
32 | QArray<UID> rawEvents()const; | 33 | QArray<UID> rawEvents()const; |
33 | QArray<UID> rawRepeats()const; | 34 | QArray<UID> rawRepeats()const; |
34 | QArray<UID> nonRepeats()const; | 35 | QArray<UID> nonRepeats()const; |
35 | 36 | ||
36 | OEvent::ValueList directNonRepeats(); | 37 | OEvent::ValueList directNonRepeats(); |
37 | OEvent::ValueList directRawRepeats(); | 38 | OEvent::ValueList directRawRepeats(); |
38 | 39 | ||
39 | private: | 40 | private: |
40 | bool m_changed :1 ; | 41 | bool m_changed :1 ; |
41 | bool loadFile(); | 42 | bool loadFile(); |
42 | inline void finalizeRecord( OEvent& ev ); | 43 | inline void finalizeRecord( OEvent& ev ); |
43 | inline void setField( OEvent&, int field, const QString& val ); | 44 | inline void setField( OEvent&, int field, const QString& val ); |
44 | QString m_name; | 45 | QString m_name; |
45 | QMap<int, OEvent> m_raw; | 46 | QMap<int, OEvent> m_raw; |
46 | QMap<int, OEvent> m_rep; | 47 | QMap<int, OEvent> m_rep; |
47 | 48 | ||
48 | struct Data; | 49 | struct Data; |
49 | Data* data; | 50 | Data* data; |
50 | class Private; | 51 | class Private; |
51 | Private *d; | 52 | Private *d; |
52 | }; | 53 | }; |
53 | 54 | ||
54 | #endif | 55 | #endif |
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h index 01a0c86..f4bbe35 100644 --- a/libopie2/opiepim/backend/opimaccessbackend.h +++ b/libopie2/opiepim/backend/opimaccessbackend.h | |||
@@ -1,144 +1,150 @@ | |||
1 | #ifndef OPIE_PIM_ACCESS_BACKEND | 1 | #ifndef OPIE_PIM_ACCESS_BACKEND |
2 | #define OPIE_PIM_ACCESS_BACKEND | 2 | #define OPIE_PIM_ACCESS_BACKEND |
3 | 3 | ||
4 | #include <qarray.h> | 4 | #include <qarray.h> |
5 | 5 | ||
6 | #include <opie/otemplatebase.h> | 6 | #include <opie/otemplatebase.h> |
7 | #include <opie/opimrecord.h> | 7 | #include <opie/opimrecord.h> |
8 | 8 | ||
9 | 9 | ||
10 | /** | 10 | /** |
11 | * OPimAccessBackend is the base class | 11 | * OPimAccessBackend is the base class |
12 | * for all private backends | 12 | * for all private backends |
13 | * it operates on OPimRecord as the base class | 13 | * it operates on OPimRecord as the base class |
14 | * and it's responsible for fast manipulating | 14 | * and it's responsible for fast manipulating |
15 | * the resource the implementation takes care | 15 | * the resource the implementation takes care |
16 | * of | 16 | * of |
17 | */ | 17 | */ |
18 | template <class T = OPimRecord> | 18 | template <class T = OPimRecord> |
19 | class OPimAccessBackend { | 19 | class OPimAccessBackend { |
20 | public: | 20 | public: |
21 | typedef OTemplateBase<T> Frontend; | 21 | typedef OTemplateBase<T> Frontend; |
22 | 22 | ||
23 | /** The access hint from the frontend */ | 23 | /** The access hint from the frontend */ |
24 | OPimAccessBackend(int access = 0); | 24 | OPimAccessBackend(int access = 0); |
25 | virtual ~OPimAccessBackend(); | 25 | virtual ~OPimAccessBackend(); |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * load the resource | 28 | * load the resource |
29 | */ | 29 | */ |
30 | virtual bool load() = 0; | 30 | virtual bool load() = 0; |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * reload the resource | 33 | * reload the resource |
34 | */ | 34 | */ |
35 | virtual bool reload() = 0; | 35 | virtual bool reload() = 0; |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * save the resource and | 38 | * save the resource and |
39 | * all it's changes | 39 | * all it's changes |
40 | */ | 40 | */ |
41 | virtual bool save() = 0; | 41 | virtual bool save() = 0; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * return an array of | 44 | * return an array of |
45 | * all available uids | 45 | * all available uids |
46 | */ | 46 | */ |
47 | virtual QArray<int> allRecords()const = 0; | 47 | virtual QArray<int> allRecords()const = 0; |
48 | 48 | ||
49 | /** | ||
50 | * return a List of records | ||
51 | * that match the regex | ||
52 | */ | ||
53 | virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; | ||
54 | |||
49 | /** | 55 | /** |
50 | * queryByExample for T with the given Settings | 56 | * queryByExample for T with the given Settings |
51 | * | 57 | * |
52 | */ | 58 | */ |
53 | virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; | 59 | virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; |
54 | 60 | ||
55 | /** | 61 | /** |
56 | * find the OPimRecord with uid @param uid | 62 | * find the OPimRecord with uid @param uid |
57 | * returns T and T.isEmpty() if nothing was found | 63 | * returns T and T.isEmpty() if nothing was found |
58 | */ | 64 | */ |
59 | virtual T find(int uid )const = 0; | 65 | virtual T find(int uid )const = 0; |
60 | 66 | ||
61 | virtual T find(int uid, const QArray<int>& items, | 67 | virtual T find(int uid, const QArray<int>& items, |
62 | uint current, typename Frontend::CacheDirection )const ; | 68 | uint current, typename Frontend::CacheDirection )const ; |
63 | /** | 69 | /** |
64 | * clear the back end | 70 | * clear the back end |
65 | */ | 71 | */ |
66 | virtual void clear() = 0; | 72 | virtual void clear() = 0; |
67 | 73 | ||
68 | /** | 74 | /** |
69 | * add T | 75 | * add T |
70 | */ | 76 | */ |
71 | virtual bool add( const T& t ) = 0; | 77 | virtual bool add( const T& t ) = 0; |
72 | 78 | ||
73 | /** | 79 | /** |
74 | * remove | 80 | * remove |
75 | */ | 81 | */ |
76 | virtual bool remove( int uid ) = 0; | 82 | virtual bool remove( int uid ) = 0; |
77 | 83 | ||
78 | /** | 84 | /** |
79 | * replace a record with T.uid() | 85 | * replace a record with T.uid() |
80 | */ | 86 | */ |
81 | virtual bool replace( const T& t ) = 0; | 87 | virtual bool replace( const T& t ) = 0; |
82 | 88 | ||
83 | /* | 89 | /* |
84 | * setTheFrontEnd!!! | 90 | * setTheFrontEnd!!! |
85 | */ | 91 | */ |
86 | void setFrontend( Frontend* front ); | 92 | void setFrontend( Frontend* front ); |
87 | 93 | ||
88 | /** | 94 | /** |
89 | * set the read ahead count | 95 | * set the read ahead count |
90 | */ | 96 | */ |
91 | void setReadAhead( uint count ); | 97 | void setReadAhead( uint count ); |
92 | protected: | 98 | protected: |
93 | int access()const; | 99 | int access()const; |
94 | void cache( const T& t )const; | 100 | void cache( const T& t )const; |
95 | 101 | ||
96 | /** | 102 | /** |
97 | * use a prime number here! | 103 | * use a prime number here! |
98 | */ | 104 | */ |
99 | void setSaneCacheSize( int ); | 105 | void setSaneCacheSize( int ); |
100 | 106 | ||
101 | uint readAhead()const; | 107 | uint readAhead()const; |
102 | 108 | ||
103 | private: | 109 | private: |
104 | class Private; | 110 | class Private; |
105 | Private* d; | 111 | Private* d; |
106 | Frontend* m_front; | 112 | Frontend* m_front; |
107 | uint m_read; | 113 | uint m_read; |
108 | int m_acc; | 114 | int m_acc; |
109 | 115 | ||
110 | }; | 116 | }; |
111 | 117 | ||
112 | template <class T> | 118 | template <class T> |
113 | OPimAccessBackend<T>::OPimAccessBackend(int acc) | 119 | OPimAccessBackend<T>::OPimAccessBackend(int acc) |
114 | : m_acc( acc ) | 120 | : m_acc( acc ) |
115 | { | 121 | { |
116 | m_front = 0l; | 122 | m_front = 0l; |
117 | } | 123 | } |
118 | template <class T> | 124 | template <class T> |
119 | OPimAccessBackend<T>::~OPimAccessBackend() { | 125 | OPimAccessBackend<T>::~OPimAccessBackend() { |
120 | 126 | ||
121 | } | 127 | } |
122 | template <class T> | 128 | template <class T> |
123 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { | 129 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { |
124 | m_front = fr; | 130 | m_front = fr; |
125 | } | 131 | } |
126 | template <class T> | 132 | template <class T> |
127 | void OPimAccessBackend<T>::cache( const T& t )const { | 133 | void OPimAccessBackend<T>::cache( const T& t )const { |
128 | if (m_front ) | 134 | if (m_front ) |
129 | m_front->cache( t ); | 135 | m_front->cache( t ); |
130 | } | 136 | } |
131 | template <class T> | 137 | template <class T> |
132 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { | 138 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { |
133 | if (m_front ) | 139 | if (m_front ) |
134 | m_front->setSaneCacheSize( size ); | 140 | m_front->setSaneCacheSize( size ); |
135 | } | 141 | } |
136 | template <class T> | 142 | template <class T> |
137 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, | 143 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, |
138 | uint, typename Frontend::CacheDirection )const { | 144 | uint, typename Frontend::CacheDirection )const { |
139 | return find( uid ); | 145 | return find( uid ); |
140 | } | 146 | } |
141 | template <class T> | 147 | template <class T> |
142 | void OPimAccessBackend<T>::setReadAhead( uint count ) { | 148 | void OPimAccessBackend<T>::setReadAhead( uint count ) { |
143 | m_read = count; | 149 | m_read = count; |
144 | } | 150 | } |
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp index 9bc16c6..3577e14 100644 --- a/libopie2/opiepim/backend/otodoaccessvcal.cpp +++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp | |||
@@ -92,130 +92,134 @@ OTodoAccessVCal::~OTodoAccessVCal() { | |||
92 | bool OTodoAccessVCal::load() { | 92 | bool OTodoAccessVCal::load() { |
93 | m_map.clear(); | 93 | m_map.clear(); |
94 | m_dirty = false; | 94 | m_dirty = false; |
95 | 95 | ||
96 | VObject* vcal = 0l; | 96 | VObject* vcal = 0l; |
97 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); | 97 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); |
98 | if (!vcal ) | 98 | if (!vcal ) |
99 | return false; | 99 | return false; |
100 | 100 | ||
101 | // Iterate over the list | 101 | // Iterate over the list |
102 | VObjectIterator it; | 102 | VObjectIterator it; |
103 | VObject* vobj; | 103 | VObject* vobj; |
104 | 104 | ||
105 | initPropIterator(&it, vcal); | 105 | initPropIterator(&it, vcal); |
106 | 106 | ||
107 | while( moreIteration( &it ) ) { | 107 | while( moreIteration( &it ) ) { |
108 | vobj = ::nextVObject( &it ); | 108 | vobj = ::nextVObject( &it ); |
109 | QCString name = ::vObjectName( vobj ); | 109 | QCString name = ::vObjectName( vobj ); |
110 | if( name == VCTodoProp ){ | 110 | if( name == VCTodoProp ){ |
111 | OTodo to = eventByVObj( vobj ); | 111 | OTodo to = eventByVObj( vobj ); |
112 | m_map.insert( to.uid(), to ); | 112 | m_map.insert( to.uid(), to ); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | // Should I do a delete vcal? | 116 | // Should I do a delete vcal? |
117 | 117 | ||
118 | return true; | 118 | return true; |
119 | } | 119 | } |
120 | bool OTodoAccessVCal::reload() { | 120 | bool OTodoAccessVCal::reload() { |
121 | return load(); | 121 | return load(); |
122 | } | 122 | } |
123 | bool OTodoAccessVCal::save() { | 123 | bool OTodoAccessVCal::save() { |
124 | if (!m_dirty ) | 124 | if (!m_dirty ) |
125 | return true; | 125 | return true; |
126 | 126 | ||
127 | QFileDirect file( m_file ); | 127 | QFileDirect file( m_file ); |
128 | if (!file.open(IO_WriteOnly ) ) | 128 | if (!file.open(IO_WriteOnly ) ) |
129 | return false; | 129 | return false; |
130 | 130 | ||
131 | VObject *obj; | 131 | VObject *obj; |
132 | obj = newVObject( VCCalProp ); | 132 | obj = newVObject( VCCalProp ); |
133 | addPropValue( obj, VCVersionProp, "1.0" ); | 133 | addPropValue( obj, VCVersionProp, "1.0" ); |
134 | VObject *vo; | 134 | VObject *vo; |
135 | for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ | 135 | for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ |
136 | vo = vobjByEvent( it.data() ); | 136 | vo = vobjByEvent( it.data() ); |
137 | addVObjectProp(obj, vo ); | 137 | addVObjectProp(obj, vo ); |
138 | } | 138 | } |
139 | writeVObject( file.directHandle(), obj ); | 139 | writeVObject( file.directHandle(), obj ); |
140 | cleanVObject( obj ); | 140 | cleanVObject( obj ); |
141 | cleanStrTbl(); | 141 | cleanStrTbl(); |
142 | 142 | ||
143 | m_dirty = false; | 143 | m_dirty = false; |
144 | return true; | 144 | return true; |
145 | } | 145 | } |
146 | void OTodoAccessVCal::clear() { | 146 | void OTodoAccessVCal::clear() { |
147 | m_map.clear(); | 147 | m_map.clear(); |
148 | m_dirty = true; | 148 | m_dirty = true; |
149 | } | 149 | } |
150 | bool OTodoAccessVCal::add( const OTodo& to ) { | 150 | bool OTodoAccessVCal::add( const OTodo& to ) { |
151 | m_map.insert( to.uid(), to ); | 151 | m_map.insert( to.uid(), to ); |
152 | m_dirty = true; | 152 | m_dirty = true; |
153 | return true; | 153 | return true; |
154 | } | 154 | } |
155 | bool OTodoAccessVCal::remove( int uid ) { | 155 | bool OTodoAccessVCal::remove( int uid ) { |
156 | m_map.remove( uid ); | 156 | m_map.remove( uid ); |
157 | m_dirty = true; | 157 | m_dirty = true; |
158 | return true; | 158 | return true; |
159 | } | 159 | } |
160 | void OTodoAccessVCal::removeAllCompleted() { | 160 | void OTodoAccessVCal::removeAllCompleted() { |
161 | for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { | 161 | for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { |
162 | if ( (*it).isCompleted() ) | 162 | if ( (*it).isCompleted() ) |
163 | m_map.remove( it ); | 163 | m_map.remove( it ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | bool OTodoAccessVCal::replace( const OTodo& to ) { | 166 | bool OTodoAccessVCal::replace( const OTodo& to ) { |
167 | m_map.replace( to.uid(), to ); | 167 | m_map.replace( to.uid(), to ); |
168 | m_dirty = true; | 168 | m_dirty = true; |
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | OTodo OTodoAccessVCal::find(int uid )const { | 171 | OTodo OTodoAccessVCal::find(int uid )const { |
172 | return m_map[uid]; | 172 | return m_map[uid]; |
173 | } | 173 | } |
174 | QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { | 174 | QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { |
175 | QArray<int> ar(0); | 175 | QArray<int> ar(0); |
176 | return ar; | 176 | return ar; |
177 | } | 177 | } |
178 | QArray<int> OTodoAccessVCal::allRecords()const { | 178 | QArray<int> OTodoAccessVCal::allRecords()const { |
179 | QArray<int> ar( m_map.count() ); | 179 | QArray<int> ar( m_map.count() ); |
180 | QMap<int, OTodo>::ConstIterator it; | 180 | QMap<int, OTodo>::ConstIterator it; |
181 | int i = 0; | 181 | int i = 0; |
182 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | 182 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { |
183 | ar[i] = it.key(); | 183 | ar[i] = it.key(); |
184 | i++; | 184 | i++; |
185 | } | 185 | } |
186 | return ar; | 186 | return ar; |
187 | } | 187 | } |
188 | QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp &r)const { | ||
189 | QArray<int> ar(0); | ||
190 | return ar; | ||
191 | } | ||
188 | QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { | 192 | QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { |
189 | QArray<int> ar(0); | 193 | QArray<int> ar(0); |
190 | return ar; | 194 | return ar; |
191 | } | 195 | } |
192 | QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , | 196 | QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , |
193 | const QDate& , | 197 | const QDate& , |
194 | bool ) { | 198 | bool ) { |
195 | QArray<int> ar(0); | 199 | QArray<int> ar(0); |
196 | return ar; | 200 | return ar; |
197 | } | 201 | } |
198 | QArray<int> OTodoAccessVCal::overDue() { | 202 | QArray<int> OTodoAccessVCal::overDue() { |
199 | QArray<int> ar(0); | 203 | QArray<int> ar(0); |
200 | return ar; | 204 | return ar; |
201 | } | 205 | } |
202 | QBitArray OTodoAccessVCal::supports()const { | 206 | QBitArray OTodoAccessVCal::supports()const { |
203 | static QBitArray ar = sup(); | 207 | static QBitArray ar = sup(); |
204 | 208 | ||
205 | return ar; | 209 | return ar; |
206 | } | 210 | } |
207 | QBitArray OTodoAccessVCal::sup() { | 211 | QBitArray OTodoAccessVCal::sup() { |
208 | QBitArray ar ( OTodo::CompletedDate +1 ); | 212 | QBitArray ar ( OTodo::CompletedDate +1 ); |
209 | ar.fill( true ); | 213 | ar.fill( true ); |
210 | 214 | ||
211 | ar[OTodo::CrossReference] = false; | 215 | ar[OTodo::CrossReference] = false; |
212 | ar[OTodo::State ] = false; | 216 | ar[OTodo::State ] = false; |
213 | ar[OTodo::Reminders] = false; | 217 | ar[OTodo::Reminders] = false; |
214 | ar[OTodo::Notifiers] = false; | 218 | ar[OTodo::Notifiers] = false; |
215 | ar[OTodo::Maintainer] = false; | 219 | ar[OTodo::Maintainer] = false; |
216 | ar[OTodo::Progress] = false; | 220 | ar[OTodo::Progress] = false; |
217 | ar[OTodo::Alarms ] = false; | 221 | ar[OTodo::Alarms ] = false; |
218 | ar[OTodo::Recurrence] = false; | 222 | ar[OTodo::Recurrence] = false; |
219 | 223 | ||
220 | return ar; | 224 | return ar; |
221 | } | 225 | } |
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.h b/libopie2/opiepim/backend/otodoaccessvcal.h index 489416b..2b17147 100644 --- a/libopie2/opiepim/backend/otodoaccessvcal.h +++ b/libopie2/opiepim/backend/otodoaccessvcal.h | |||
@@ -1,39 +1,40 @@ | |||
1 | #ifndef OPIE_OTODO_ACCESS_VCAL_H | 1 | #ifndef OPIE_OTODO_ACCESS_VCAL_H |
2 | #define OPIE_OTODO_ACCESS_VCAL_H | 2 | #define OPIE_OTODO_ACCESS_VCAL_H |
3 | 3 | ||
4 | #include "otodoaccessbackend.h" | 4 | #include "otodoaccessbackend.h" |
5 | 5 | ||
6 | class OTodoAccessVCal : public OTodoAccessBackend { | 6 | class OTodoAccessVCal : public OTodoAccessBackend { |
7 | public: | 7 | public: |
8 | OTodoAccessVCal(const QString& ); | 8 | OTodoAccessVCal(const QString& ); |
9 | ~OTodoAccessVCal(); | 9 | ~OTodoAccessVCal(); |
10 | 10 | ||
11 | bool load(); | 11 | bool load(); |
12 | bool reload(); | 12 | bool reload(); |
13 | bool save(); | 13 | bool save(); |
14 | 14 | ||
15 | QArray<int> allRecords()const; | 15 | QArray<int> allRecords()const; |
16 | QArray<int> matchRegexp(const QRegExp &r) const; | ||
16 | QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() ); | 17 | QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() ); |
17 | QArray<int> effectiveToDos( const QDate& start, | 18 | QArray<int> effectiveToDos( const QDate& start, |
18 | const QDate& end, | 19 | const QDate& end, |
19 | bool includeNoDates ); | 20 | bool includeNoDates ); |
20 | QArray<int> overDue(); | 21 | QArray<int> overDue(); |
21 | QArray<int> sorted( bool asc, int sortOrder, int sortFilter, | 22 | QArray<int> sorted( bool asc, int sortOrder, int sortFilter, |
22 | int cat ); | 23 | int cat ); |
23 | OTodo find(int uid)const; | 24 | OTodo find(int uid)const; |
24 | void clear(); | 25 | void clear(); |
25 | bool add( const OTodo& ); | 26 | bool add( const OTodo& ); |
26 | bool remove( int uid ); | 27 | bool remove( int uid ); |
27 | bool replace( const OTodo& ); | 28 | bool replace( const OTodo& ); |
28 | 29 | ||
29 | void removeAllCompleted(); | 30 | void removeAllCompleted(); |
30 | virtual QBitArray supports()const; | 31 | virtual QBitArray supports()const; |
31 | 32 | ||
32 | private: | 33 | private: |
33 | static QBitArray sup(); | 34 | static QBitArray sup(); |
34 | bool m_dirty : 1; | 35 | bool m_dirty : 1; |
35 | QString m_file; | 36 | QString m_file; |
36 | QMap<int, OTodo> m_map; | 37 | QMap<int, OTodo> m_map; |
37 | }; | 38 | }; |
38 | 39 | ||
39 | #endif | 40 | #endif |
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index 285d2b8..69b7ab4 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp | |||
@@ -681,96 +681,112 @@ public: | |||
681 | return ret; | 681 | return ret; |
682 | } | 682 | } |
683 | } | 683 | } |
684 | if (!seDesc ) { | 684 | if (!seDesc ) { |
685 | if ( (ret = description(con1->todo, con2->todo ) ) ) { | 685 | if ( (ret = description(con1->todo, con2->todo ) ) ) { |
686 | if (!m_asc) ret *= -1; | 686 | if (!m_asc) ret *= -1; |
687 | return ret; | 687 | return ret; |
688 | } | 688 | } |
689 | } | 689 | } |
690 | if (!seDeadline) { | 690 | if (!seDeadline) { |
691 | if ( (ret = deadline( con1->todo, con2->todo ) ) ) { | 691 | if ( (ret = deadline( con1->todo, con2->todo ) ) ) { |
692 | if (!m_asc) ret *= -1; | 692 | if (!m_asc) ret *= -1; |
693 | return ret; | 693 | return ret; |
694 | } | 694 | } |
695 | } | 695 | } |
696 | 696 | ||
697 | return 0; | 697 | return 0; |
698 | } | 698 | } |
699 | private: | 699 | private: |
700 | bool m_asc; | 700 | bool m_asc; |
701 | int m_sort; | 701 | int m_sort; |
702 | 702 | ||
703 | }; | 703 | }; |
704 | 704 | ||
705 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, | 705 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, |
706 | int sortFilter, int cat ) { | 706 | int sortFilter, int cat ) { |
707 | qWarning("sorted! %d cat", cat); | 707 | qWarning("sorted! %d cat", cat); |
708 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); | 708 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); |
709 | QMap<int, OTodo>::Iterator it; | 709 | QMap<int, OTodo>::Iterator it; |
710 | int item = 0; | 710 | int item = 0; |
711 | 711 | ||
712 | bool bCat = sortFilter & 1 ? true : false; | 712 | bool bCat = sortFilter & 1 ? true : false; |
713 | bool bOnly = sortFilter & 2 ? true : false; | 713 | bool bOnly = sortFilter & 2 ? true : false; |
714 | bool comp = sortFilter & 4 ? true : false; | 714 | bool comp = sortFilter & 4 ? true : false; |
715 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 715 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
716 | 716 | ||
717 | /* show category */ | 717 | /* show category */ |
718 | if ( bCat && cat != 0) | 718 | if ( bCat && cat != 0) |
719 | if (!(*it).categories().contains( cat ) ) { | 719 | if (!(*it).categories().contains( cat ) ) { |
720 | qWarning("category mis match"); | 720 | qWarning("category mis match"); |
721 | continue; | 721 | continue; |
722 | } | 722 | } |
723 | /* isOverdue but we should not show overdue - why?*/ | 723 | /* isOverdue but we should not show overdue - why?*/ |
724 | /* if ( (*it).isOverdue() && !bOnly ) { | 724 | /* if ( (*it).isOverdue() && !bOnly ) { |
725 | qWarning("item is overdue but !bOnly"); | 725 | qWarning("item is overdue but !bOnly"); |
726 | continue; | 726 | continue; |
727 | } | 727 | } |
728 | */ | 728 | */ |
729 | if ( !(*it).isOverdue() && bOnly ) { | 729 | if ( !(*it).isOverdue() && bOnly ) { |
730 | qWarning("item is not overdue but bOnly checked"); | 730 | qWarning("item is not overdue but bOnly checked"); |
731 | continue; | 731 | continue; |
732 | } | 732 | } |
733 | 733 | ||
734 | if ((*it).isCompleted() && comp ) { | 734 | if ((*it).isCompleted() && comp ) { |
735 | qWarning("completed continue!"); | 735 | qWarning("completed continue!"); |
736 | continue; | 736 | continue; |
737 | } | 737 | } |
738 | 738 | ||
739 | 739 | ||
740 | OTodoXMLContainer* con = new OTodoXMLContainer(); | 740 | OTodoXMLContainer* con = new OTodoXMLContainer(); |
741 | con->todo = (*it); | 741 | con->todo = (*it); |
742 | vector.insert(item, con ); | 742 | vector.insert(item, con ); |
743 | item++; | 743 | item++; |
744 | } | 744 | } |
745 | qWarning("XXX %d Items added", item); | 745 | qWarning("XXX %d Items added", item); |
746 | vector.resize( item ); | 746 | vector.resize( item ); |
747 | /* sort it now */ | 747 | /* sort it now */ |
748 | vector.sort(); | 748 | vector.sort(); |
749 | /* now get the uids */ | 749 | /* now get the uids */ |
750 | QArray<int> array( vector.count() ); | 750 | QArray<int> array( vector.count() ); |
751 | for (uint i= 0; i < vector.count(); i++ ) { | 751 | for (uint i= 0; i < vector.count(); i++ ) { |
752 | array[i] = ( vector.at(i) )->todo.uid(); | 752 | array[i] = ( vector.at(i) )->todo.uid(); |
753 | } | 753 | } |
754 | return array; | 754 | return array; |
755 | }; | 755 | }; |
756 | void OTodoAccessXML::removeAllCompleted() { | 756 | void OTodoAccessXML::removeAllCompleted() { |
757 | for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { | 757 | for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { |
758 | if ( (*it).isCompleted() ) | 758 | if ( (*it).isCompleted() ) |
759 | m_events.remove( it ); | 759 | m_events.remove( it ); |
760 | } | 760 | } |
761 | } | 761 | } |
762 | QBitArray OTodoAccessXML::supports()const { | 762 | QBitArray OTodoAccessXML::supports()const { |
763 | static QBitArray ar = sup(); | 763 | static QBitArray ar = sup(); |
764 | return ar; | 764 | return ar; |
765 | } | 765 | } |
766 | QBitArray OTodoAccessXML::sup() { | 766 | QBitArray OTodoAccessXML::sup() { |
767 | QBitArray ar( OTodo::CompletedDate +1 ); | 767 | QBitArray ar( OTodo::CompletedDate +1 ); |
768 | ar.fill( true ); | 768 | ar.fill( true ); |
769 | ar[OTodo::CrossReference] = false; | 769 | ar[OTodo::CrossReference] = false; |
770 | ar[OTodo::State ] = false; | 770 | ar[OTodo::State ] = false; |
771 | ar[OTodo::Reminders] = false; | 771 | ar[OTodo::Reminders] = false; |
772 | ar[OTodo::Notifiers] = false; | 772 | ar[OTodo::Notifiers] = false; |
773 | ar[OTodo::Maintainer] = false; | 773 | ar[OTodo::Maintainer] = false; |
774 | 774 | ||
775 | return ar; | 775 | return ar; |
776 | } | 776 | } |
777 | QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const | ||
778 | { | ||
779 | QArray<int> m_currentQuery( m_events.count() ); | ||
780 | uint arraycounter = 0; | ||
781 | |||
782 | QMap<int, OTodo>::ConstIterator it; | ||
783 | for (it = m_events.begin(); it != m_events.end(); ++it ) { | ||
784 | if ( it.data().match( r ) ) | ||
785 | m_currentQuery[arraycounter++] = it.data().uid(); | ||
786 | |||
787 | } | ||
788 | // Shrink to fit.. | ||
789 | m_currentQuery.resize(arraycounter); | ||
790 | |||
791 | return m_currentQuery; | ||
792 | } | ||
diff --git a/libopie2/opiepim/backend/otodoaccessxml.h b/libopie2/opiepim/backend/otodoaccessxml.h index cc4a16f..e4850a1 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.h +++ b/libopie2/opiepim/backend/otodoaccessxml.h | |||
@@ -1,59 +1,60 @@ | |||
1 | #ifndef OPIE_TODO_ACCESS_XML_H | 1 | #ifndef OPIE_TODO_ACCESS_XML_H |
2 | #define OPIE_TODO_ACCESS_XML_H | 2 | #define OPIE_TODO_ACCESS_XML_H |
3 | 3 | ||
4 | #include <qasciidict.h> | 4 | #include <qasciidict.h> |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | 6 | ||
7 | #include "otodoaccessbackend.h" | 7 | #include "otodoaccessbackend.h" |
8 | 8 | ||
9 | namespace Opie { | 9 | namespace Opie { |
10 | class XMLElement; | 10 | class XMLElement; |
11 | }; | 11 | }; |
12 | 12 | ||
13 | class OTodoAccessXML : public OTodoAccessBackend { | 13 | class OTodoAccessXML : public OTodoAccessBackend { |
14 | public: | 14 | public: |
15 | /** | 15 | /** |
16 | * fileName if Empty we will use the default path | 16 | * fileName if Empty we will use the default path |
17 | */ | 17 | */ |
18 | OTodoAccessXML( const QString& appName, | 18 | OTodoAccessXML( const QString& appName, |
19 | const QString& fileName = QString::null ); | 19 | const QString& fileName = QString::null ); |
20 | ~OTodoAccessXML(); | 20 | ~OTodoAccessXML(); |
21 | 21 | ||
22 | bool load(); | 22 | bool load(); |
23 | bool reload(); | 23 | bool reload(); |
24 | bool save(); | 24 | bool save(); |
25 | 25 | ||
26 | QArray<int> allRecords()const; | 26 | QArray<int> allRecords()const; |
27 | QArray<int> matchRegexp(const QRegExp &r) const; | ||
27 | QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() ); | 28 | QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() ); |
28 | OTodo find( int uid )const; | 29 | OTodo find( int uid )const; |
29 | void clear(); | 30 | void clear(); |
30 | bool add( const OTodo& ); | 31 | bool add( const OTodo& ); |
31 | bool remove( int uid ); | 32 | bool remove( int uid ); |
32 | void removeAllCompleted(); | 33 | void removeAllCompleted(); |
33 | bool replace( const OTodo& ); | 34 | bool replace( const OTodo& ); |
34 | 35 | ||
35 | /* our functions */ | 36 | /* our functions */ |
36 | QArray<int> effectiveToDos( const QDate& start, | 37 | QArray<int> effectiveToDos( const QDate& start, |
37 | const QDate& end, | 38 | const QDate& end, |
38 | bool includeNoDates ); | 39 | bool includeNoDates ); |
39 | QArray<int> overDue(); | 40 | QArray<int> overDue(); |
40 | QArray<int> sorted( bool asc, int sortOrder, | 41 | QArray<int> sorted( bool asc, int sortOrder, |
41 | int sortFilter, int cat ); | 42 | int sortFilter, int cat ); |
42 | QBitArray supports()const; | 43 | QBitArray supports()const; |
43 | private: | 44 | private: |
44 | static QBitArray sup(); | 45 | static QBitArray sup(); |
45 | void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& ); | 46 | void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& ); |
46 | QString toString( const OTodo& )const; | 47 | QString toString( const OTodo& )const; |
47 | QString toString( const QArray<int>& ints ) const; | 48 | QString toString( const QArray<int>& ints ) const; |
48 | QMap<int, OTodo> m_events; | 49 | QMap<int, OTodo> m_events; |
49 | QString m_file; | 50 | QString m_file; |
50 | QString m_app; | 51 | QString m_app; |
51 | bool m_opened : 1; | 52 | bool m_opened : 1; |
52 | bool m_changed : 1; | 53 | bool m_changed : 1; |
53 | class OTodoAccessXMLPrivate; | 54 | class OTodoAccessXMLPrivate; |
54 | OTodoAccessXMLPrivate* d; | 55 | OTodoAccessXMLPrivate* d; |
55 | int m_year, m_month, m_day; | 56 | int m_year, m_month, m_day; |
56 | 57 | ||
57 | }; | 58 | }; |
58 | 59 | ||
59 | #endif | 60 | #endif |
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp index 9c9338e..2e3ec1f 100644 --- a/libopie2/opiepim/core/ocontactaccess.cpp +++ b/libopie2/opiepim/core/ocontactaccess.cpp | |||
@@ -1,169 +1,168 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage the Contacts. | 2 | * Class to manage the Contacts. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 5 | * |
6 | * ===================================================================== | 6 | * ===================================================================== |
7 | *This program is free software; you can redistribute it and/or | 7 | *This program is free software; you can redistribute it and/or |
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; either | 9 | * License as published by the Free Software Foundation; either |
10 | * version 2 of the License, or (at your option) any later version. | 10 | * version 2 of the License, or (at your option) any later version. |
11 | * ===================================================================== | 11 | * ===================================================================== |
12 | * Info: This class could just work with a change in the header-file | 12 | * Info: This class could just work with a change in the header-file |
13 | * of the Contact class ! Therefore our libopie only compiles | 13 | * of the Contact class ! Therefore our libopie only compiles |
14 | * with our version of libqpe | 14 | * with our version of libqpe |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * ToDo: XML-Backend: Automatic reload if something was changed... | 16 | * ToDo: XML-Backend: Automatic reload if something was changed... |
17 | * | 17 | * |
18 | * | 18 | * |
19 | * ===================================================================== | 19 | * ===================================================================== |
20 | * Version: $Id$ | 20 | * Version: $Id$ |
21 | * ===================================================================== | 21 | * ===================================================================== |
22 | * History: | 22 | * History: |
23 | * $Log$ | 23 | * $Log$ |
24 | * Revision 1.8 2003/05/08 13:55:09 tille | ||
25 | * search stuff | ||
26 | * and match, toRichText & toShortText in oevent | ||
27 | * | ||
24 | * Revision 1.7 2002/11/13 14:14:51 eilers | 28 | * Revision 1.7 2002/11/13 14:14:51 eilers |
25 | * Added sorted for Contacts.. | 29 | * Added sorted for Contacts.. |
26 | * | 30 | * |
27 | * Revision 1.6 2002/11/01 15:10:42 eilers | 31 | * Revision 1.6 2002/11/01 15:10:42 eilers |
28 | * Added regExp-search in database for all fields in a contact. | 32 | * Added regExp-search in database for all fields in a contact. |
29 | * | 33 | * |
30 | * Revision 1.5 2002/10/16 10:52:40 eilers | 34 | * Revision 1.5 2002/10/16 10:52:40 eilers |
31 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | 35 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) |
32 | * | 36 | * |
33 | * Revision 1.4 2002/10/14 16:21:54 eilers | 37 | * Revision 1.4 2002/10/14 16:21:54 eilers |
34 | * Some minor interface updates | 38 | * Some minor interface updates |
35 | * | 39 | * |
36 | * Revision 1.3 2002/10/07 17:34:24 eilers | 40 | * Revision 1.3 2002/10/07 17:34:24 eilers |
37 | * added OBackendFactory for advanced backend access | 41 | * added OBackendFactory for advanced backend access |
38 | * | 42 | * |
39 | * Revision 1.2 2002/10/02 16:18:11 eilers | 43 | * Revision 1.2 2002/10/02 16:18:11 eilers |
40 | * debugged and seems to work almost perfectly .. | 44 | * debugged and seems to work almost perfectly .. |
41 | * | 45 | * |
42 | * Revision 1.1 2002/09/27 17:11:44 eilers | 46 | * Revision 1.1 2002/09/27 17:11:44 eilers |
43 | * Added API for accessing the Contact-Database ! It is compiling, but | 47 | * Added API for accessing the Contact-Database ! It is compiling, but |
44 | * please do not expect that anything is working ! | 48 | * please do not expect that anything is working ! |
45 | * I will debug that stuff in the next time .. | 49 | * I will debug that stuff in the next time .. |
46 | * Please read README_COMPILE for compiling ! | 50 | * Please read README_COMPILE for compiling ! |
47 | * | 51 | * |
48 | * | 52 | * |
49 | */ | 53 | */ |
50 | 54 | ||
51 | #include "ocontactaccess.h" | 55 | #include "ocontactaccess.h" |
52 | #include "obackendfactory.h" | 56 | #include "obackendfactory.h" |
53 | 57 | ||
54 | #include <qasciidict.h> | 58 | #include <qasciidict.h> |
55 | #include <qdatetime.h> | 59 | #include <qdatetime.h> |
56 | #include <qfile.h> | 60 | #include <qfile.h> |
57 | #include <qregexp.h> | 61 | #include <qregexp.h> |
58 | #include <qlist.h> | 62 | #include <qlist.h> |
59 | #include <qcopchannel_qws.h> | 63 | #include <qcopchannel_qws.h> |
60 | 64 | ||
61 | //#include <qpe/qcopenvelope_qws.h> | 65 | //#include <qpe/qcopenvelope_qws.h> |
62 | #include <qpe/global.h> | 66 | #include <qpe/global.h> |
63 | 67 | ||
64 | #include <errno.h> | 68 | #include <errno.h> |
65 | #include <fcntl.h> | 69 | #include <fcntl.h> |
66 | #include <unistd.h> | 70 | #include <unistd.h> |
67 | #include <stdlib.h> | 71 | #include <stdlib.h> |
68 | 72 | ||
69 | #include "ocontactaccessbackend_xml.h" | 73 | #include "ocontactaccessbackend_xml.h" |
70 | 74 | ||
71 | 75 | ||
72 | OContactAccess::OContactAccess ( const QString appname, const QString , | 76 | OContactAccess::OContactAccess ( const QString appname, const QString , |
73 | OContactAccessBackend* end, bool autosync ): | 77 | OContactAccessBackend* end, bool autosync ): |
74 | OPimAccessTemplate<OContact>( end ) | 78 | OPimAccessTemplate<OContact>( end ) |
75 | { | 79 | { |
76 | /* take care of the backend. If there is no one defined, we | 80 | /* take care of the backend. If there is no one defined, we |
77 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). | 81 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). |
78 | */ | 82 | */ |
79 | if( end == 0 ) { | 83 | if( end == 0 ) { |
80 | qWarning ("Using BackendFactory !"); | 84 | qWarning ("Using BackendFactory !"); |
81 | end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); | 85 | end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); |
82 | } | 86 | } |
83 | // Set backend locally and in template | 87 | // Set backend locally and in template |
84 | m_backEnd = end; | 88 | m_backEnd = end; |
85 | OPimAccessTemplate<OContact>::setBackEnd (end); | 89 | OPimAccessTemplate<OContact>::setBackEnd (end); |
86 | 90 | ||
87 | 91 | ||
88 | /* Connect signal of external db change to function */ | 92 | /* Connect signal of external db change to function */ |
89 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); | 93 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); |
90 | connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), | 94 | connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), |
91 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); | 95 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); |
92 | if ( autosync ){ | 96 | if ( autosync ){ |
93 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); | 97 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); |
94 | connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), | 98 | connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), |
95 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); | 99 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); |
96 | } | 100 | } |
97 | 101 | ||
98 | 102 | ||
99 | } | 103 | } |
100 | OContactAccess::~OContactAccess () | 104 | OContactAccess::~OContactAccess () |
101 | { | 105 | { |
102 | /* The user may forget to save the changed database, therefore try to | 106 | /* The user may forget to save the changed database, therefore try to |
103 | * do it for him.. | 107 | * do it for him.. |
104 | */ | 108 | */ |
105 | save(); | 109 | save(); |
106 | // delete m_backEnd; is done by template.. | 110 | // delete m_backEnd; is done by template.. |
107 | } | 111 | } |
108 | 112 | ||
109 | 113 | ||
110 | bool OContactAccess::save () | 114 | bool OContactAccess::save () |
111 | { | 115 | { |
112 | /* If the database was changed externally, we could not save the | 116 | /* If the database was changed externally, we could not save the |
113 | * Data. This will remove added items which is unacceptable ! | 117 | * Data. This will remove added items which is unacceptable ! |
114 | * Therefore: Reload database and merge the data... | 118 | * Therefore: Reload database and merge the data... |
115 | */ | 119 | */ |
116 | if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) | 120 | if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) |
117 | reload(); | 121 | reload(); |
118 | 122 | ||
119 | bool status = OPimAccessTemplate<OContact>::save(); | 123 | bool status = OPimAccessTemplate<OContact>::save(); |
120 | if ( !status ) return false; | 124 | if ( !status ) return false; |
121 | 125 | ||
122 | /* Now tell everyone that new data is available. | 126 | /* Now tell everyone that new data is available. |
123 | */ | 127 | */ |
124 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); | 128 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); |
125 | 129 | ||
126 | return true; | 130 | return true; |
127 | } | 131 | } |
128 | 132 | ||
129 | ORecordList<OContact> OContactAccess::matchRegexp( const QRegExp &r ) const{ | ||
130 | QArray<int> matchingContacts = m_backEnd -> matchRegexp( r ); | ||
131 | return ( ORecordList<OContact>(matchingContacts, this) ); | ||
132 | } | ||
133 | |||
134 | const uint OContactAccess::querySettings() | 133 | const uint OContactAccess::querySettings() |
135 | { | 134 | { |
136 | return ( m_backEnd->querySettings() ); | 135 | return ( m_backEnd->querySettings() ); |
137 | } | 136 | } |
138 | 137 | ||
139 | bool OContactAccess::hasQuerySettings ( int querySettings ) const | 138 | bool OContactAccess::hasQuerySettings ( int querySettings ) const |
140 | { | 139 | { |
141 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); | 140 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); |
142 | } | 141 | } |
143 | ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const | 142 | ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const |
144 | { | 143 | { |
145 | QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); | 144 | QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); |
146 | return ( ORecordList<OContact>(matchingContacts, this) ); | 145 | return ( ORecordList<OContact>(matchingContacts, this) ); |
147 | } | 146 | } |
148 | 147 | ||
149 | 148 | ||
150 | bool OContactAccess::wasChangedExternally()const | 149 | bool OContactAccess::wasChangedExternally()const |
151 | { | 150 | { |
152 | return ( m_backEnd->wasChangedExternally() ); | 151 | return ( m_backEnd->wasChangedExternally() ); |
153 | } | 152 | } |
154 | 153 | ||
155 | 154 | ||
156 | void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) | 155 | void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) |
157 | { | 156 | { |
158 | if ( msg == "addressbookUpdated()" ){ | 157 | if ( msg == "addressbookUpdated()" ){ |
159 | qWarning ("OContactAccess: Received addressbokUpdated()"); | 158 | qWarning ("OContactAccess: Received addressbokUpdated()"); |
160 | emit signalChanged ( this ); | 159 | emit signalChanged ( this ); |
161 | } else if ( msg == "flush()" ) { | 160 | } else if ( msg == "flush()" ) { |
162 | qWarning ("OContactAccess: Received flush()"); | 161 | qWarning ("OContactAccess: Received flush()"); |
163 | save (); | 162 | save (); |
164 | } else if ( msg == "reload()" ) { | 163 | } else if ( msg == "reload()" ) { |
165 | qWarning ("OContactAccess: Received reload()"); | 164 | qWarning ("OContactAccess: Received reload()"); |
166 | reload (); | 165 | reload (); |
167 | emit signalChanged ( this ); | 166 | emit signalChanged ( this ); |
168 | } | 167 | } |
169 | } | 168 | } |
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h index d7ceaf2..e90db32 100644 --- a/libopie2/opiepim/core/ocontactaccess.h +++ b/libopie2/opiepim/core/ocontactaccess.h | |||
@@ -1,168 +1,170 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage the Contacts. | 2 | * Class to manage the Contacts. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) | 5 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) |
6 | * | 6 | * |
7 | * ===================================================================== | 7 | * ===================================================================== |
8 | *This program is free software; you can redistribute it and/or | 8 | *This program is free software; you can redistribute it and/or |
9 | *modify it under the terms of the GNU Library General Public | 9 | *modify it under the terms of the GNU Library General Public |
10 | * License as published by the Free Software Foundation; | 10 | * License as published by the Free Software Foundation; |
11 | * either version 2 of the License, or (at your option) any later | 11 | * either version 2 of the License, or (at your option) any later |
12 | * version. | 12 | * version. |
13 | * ===================================================================== | 13 | * ===================================================================== |
14 | * ToDo: Define enum for query settings | 14 | * ToDo: Define enum for query settings |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * Version: $Id$ | 16 | * Version: $Id$ |
17 | * ===================================================================== | 17 | * ===================================================================== |
18 | * History: | 18 | * History: |
19 | * $Log$ | 19 | * $Log$ |
20 | * Revision 1.8 2003/05/08 13:55:09 tille | ||
21 | * search stuff | ||
22 | * and match, toRichText & toShortText in oevent | ||
23 | * | ||
20 | * Revision 1.7 2003/04/13 18:07:10 zecke | 24 | * Revision 1.7 2003/04/13 18:07:10 zecke |
21 | * More API doc | 25 | * More API doc |
22 | * QString -> const QString& | 26 | * QString -> const QString& |
23 | * QString = 0l -> QString::null | 27 | * QString = 0l -> QString::null |
24 | * | 28 | * |
25 | * Revision 1.6 2003/01/02 14:27:12 eilers | 29 | * Revision 1.6 2003/01/02 14:27:12 eilers |
26 | * Improved query by example: Search by date is possible.. First step | 30 | * Improved query by example: Search by date is possible.. First step |
27 | * for a today plugin for birthdays.. | 31 | * for a today plugin for birthdays.. |
28 | * | 32 | * |
29 | * Revision 1.5 2002/11/13 14:14:51 eilers | 33 | * Revision 1.5 2002/11/13 14:14:51 eilers |
30 | * Added sorted for Contacts.. | 34 | * Added sorted for Contacts.. |
31 | * | 35 | * |
32 | * Revision 1.4 2002/11/01 15:10:42 eilers | 36 | * Revision 1.4 2002/11/01 15:10:42 eilers |
33 | * Added regExp-search in database for all fields in a contact. | 37 | * Added regExp-search in database for all fields in a contact. |
34 | * | 38 | * |
35 | * Revision 1.3 2002/10/16 10:52:40 eilers | 39 | * Revision 1.3 2002/10/16 10:52:40 eilers |
36 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | 40 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) |
37 | * | 41 | * |
38 | * Revision 1.2 2002/10/14 16:21:54 eilers | 42 | * Revision 1.2 2002/10/14 16:21:54 eilers |
39 | * Some minor interface updates | 43 | * Some minor interface updates |
40 | * | 44 | * |
41 | * Revision 1.1 2002/09/27 17:11:44 eilers | 45 | * Revision 1.1 2002/09/27 17:11:44 eilers |
42 | * Added API for accessing the Contact-Database ! It is compiling, but | 46 | * Added API for accessing the Contact-Database ! It is compiling, but |
43 | * please do not expect that anything is working ! | 47 | * please do not expect that anything is working ! |
44 | * I will debug that stuff in the next time .. | 48 | * I will debug that stuff in the next time .. |
45 | * Please read README_COMPILE for compiling ! | 49 | * Please read README_COMPILE for compiling ! |
46 | * | 50 | * |
47 | * ===================================================================== | 51 | * ===================================================================== |
48 | */ | 52 | */ |
49 | #ifndef _OCONTACTACCESS_H | 53 | #ifndef _OCONTACTACCESS_H |
50 | #define _OCONTACTACCESS_H | 54 | #define _OCONTACTACCESS_H |
51 | 55 | ||
52 | #include <qobject.h> | 56 | #include <qobject.h> |
53 | 57 | ||
54 | #include <qpe/qcopenvelope_qws.h> | 58 | #include <qpe/qcopenvelope_qws.h> |
55 | 59 | ||
56 | #include <qvaluelist.h> | 60 | #include <qvaluelist.h> |
57 | #include <qfileinfo.h> | 61 | #include <qfileinfo.h> |
58 | 62 | ||
59 | #include "ocontact.h" | 63 | #include "ocontact.h" |
60 | #include "ocontactaccessbackend.h" | 64 | #include "ocontactaccessbackend.h" |
61 | #include "opimaccesstemplate.h" | 65 | #include "opimaccesstemplate.h" |
62 | 66 | ||
63 | /** | 67 | /** |
64 | * Class to access the contacts database. | 68 | * Class to access the contacts database. |
65 | * This is just a frontend for the real database handling which is | 69 | * This is just a frontend for the real database handling which is |
66 | * done by the backend. | 70 | * done by the backend. |
67 | * This class is used to access the Contacts on a system. This class as any OPIE PIM | 71 | * This class is used to access the Contacts on a system. This class as any OPIE PIM |
68 | * class is backend independent. | 72 | * class is backend independent. |
69 | 73 | ||
70 | * @see OPimAccessTemplate | 74 | * @see OPimAccessTemplate |
71 | */ | 75 | */ |
72 | class OContactAccess: public QObject, public OPimAccessTemplate<OContact> | 76 | class OContactAccess: public QObject, public OPimAccessTemplate<OContact> |
73 | { | 77 | { |
74 | Q_OBJECT | 78 | Q_OBJECT |
75 | 79 | ||
76 | public: | 80 | public: |
77 | /** | 81 | /** |
78 | * Create Database with contacts (addressbook). | 82 | * Create Database with contacts (addressbook). |
79 | * @param appname Name of application which wants access to the database | 83 | * @param appname Name of application which wants access to the database |
80 | * (i.e. "todolist") | 84 | * (i.e. "todolist") |
81 | * @param filename The name of the database file. If not set, the default one | 85 | * @param filename The name of the database file. If not set, the default one |
82 | * is used. | 86 | * is used. |
83 | * @param backend Pointer to an alternative Backend. If not set, we will use | 87 | * @param backend Pointer to an alternative Backend. If not set, we will use |
84 | * the default backend. | 88 | * the default backend. |
85 | * @param handlesync If <b>true</b> the database stores the current state | 89 | * @param handlesync If <b>true</b> the database stores the current state |
86 | * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> | 90 | * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> |
87 | * which are used before and after synchronisation. If the application wants | 91 | * which are used before and after synchronisation. If the application wants |
88 | * to react itself, it should be disabled by setting it to <b>false</b> | 92 | * to react itself, it should be disabled by setting it to <b>false</b> |
89 | * @see OContactAccessBackend | 93 | * @see OContactAccessBackend |
90 | */ | 94 | */ |
91 | OContactAccess (const QString appname, const QString filename = 0l, | 95 | OContactAccess (const QString appname, const QString filename = 0l, |
92 | OContactAccessBackend* backend = 0l, bool handlesync = true); | 96 | OContactAccessBackend* backend = 0l, bool handlesync = true); |
93 | ~OContactAccess (); | 97 | ~OContactAccess (); |
94 | 98 | ||
95 | /** Constants for query. | 99 | /** Constants for query. |
96 | * Use this constants to set the query parameters. | 100 | * Use this constants to set the query parameters. |
97 | * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! | 101 | * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! |
98 | * @see queryByExample() | 102 | * @see queryByExample() |
99 | */ | 103 | */ |
100 | enum QuerySettings { | 104 | enum QuerySettings { |
101 | WildCards = 0x0001, | 105 | WildCards = 0x0001, |
102 | IgnoreCase = 0x0002, | 106 | IgnoreCase = 0x0002, |
103 | RegExp = 0x0004, | 107 | RegExp = 0x0004, |
104 | ExactMatch = 0x0008, | 108 | ExactMatch = 0x0008, |
105 | MatchOne = 0x0010, // Only one Entry must match | 109 | MatchOne = 0x0010, // Only one Entry must match |
106 | DateDiff = 0x0020, // Find all entries from today until given date | 110 | DateDiff = 0x0020, // Find all entries from today until given date |
107 | DateYear = 0x0040, // The year matches | 111 | DateYear = 0x0040, // The year matches |
108 | DateMonth = 0x0080, // The month matches | 112 | DateMonth = 0x0080, // The month matches |
109 | DateDay = 0x0100, // The day matches | 113 | DateDay = 0x0100, // The day matches |
110 | }; | 114 | }; |
111 | 115 | ||
112 | 116 | ||
113 | ORecordList<OContact> matchRegexp( const QRegExp &r )const; | ||
114 | |||
115 | /** Return all Contacts in a sorted manner. | 117 | /** Return all Contacts in a sorted manner. |
116 | * @param ascending true: Sorted in acending order. | 118 | * @param ascending true: Sorted in acending order. |
117 | * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess | 119 | * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess |
118 | * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess | 120 | * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess |
119 | * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess | 121 | * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess |
120 | */ | 122 | */ |
121 | List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; | 123 | List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; |
122 | 124 | ||
123 | /** Return all possible settings. | 125 | /** Return all possible settings. |
124 | * @return All settings provided by the current backend | 126 | * @return All settings provided by the current backend |
125 | * (i.e.: query_WildCards & query_IgnoreCase) | 127 | * (i.e.: query_WildCards & query_IgnoreCase) |
126 | */ | 128 | */ |
127 | const uint querySettings(); | 129 | const uint querySettings(); |
128 | 130 | ||
129 | /** Check whether settings are correct. | 131 | /** Check whether settings are correct. |
130 | * @return <i>true</i> if the given settings are correct and possible. | 132 | * @return <i>true</i> if the given settings are correct and possible. |
131 | */ | 133 | */ |
132 | bool hasQuerySettings ( int querySettings ) const; | 134 | bool hasQuerySettings ( int querySettings ) const; |
133 | 135 | ||
134 | /** | 136 | /** |
135 | * if the resource was changed externally. | 137 | * if the resource was changed externally. |
136 | * You should use the signal instead of polling possible changes ! | 138 | * You should use the signal instead of polling possible changes ! |
137 | */ | 139 | */ |
138 | bool wasChangedExternally()const; | 140 | bool wasChangedExternally()const; |
139 | 141 | ||
140 | 142 | ||
141 | /** Save contacts database. | 143 | /** Save contacts database. |
142 | * Save is more a "commit". After calling this function, all changes are public available. | 144 | * Save is more a "commit". After calling this function, all changes are public available. |
143 | * @return true if successful | 145 | * @return true if successful |
144 | */ | 146 | */ |
145 | bool save(); | 147 | bool save(); |
146 | 148 | ||
147 | signals: | 149 | signals: |
148 | /* Signal is emitted if the database was changed. Therefore | 150 | /* Signal is emitted if the database was changed. Therefore |
149 | * we may need to reload to stay consistent. | 151 | * we may need to reload to stay consistent. |
150 | * @param which Pointer to the database who created this event. This pointer | 152 | * @param which Pointer to the database who created this event. This pointer |
151 | * is useful if an application has to handle multiple databases at the same time. | 153 | * is useful if an application has to handle multiple databases at the same time. |
152 | * @see reload() | 154 | * @see reload() |
153 | */ | 155 | */ |
154 | void signalChanged ( const OContactAccess *which ); | 156 | void signalChanged ( const OContactAccess *which ); |
155 | 157 | ||
156 | 158 | ||
157 | private: | 159 | private: |
158 | // class OContactAccessPrivate; | 160 | // class OContactAccessPrivate; |
159 | // OContactAccessPrivate* d; | 161 | // OContactAccessPrivate* d; |
160 | OContactAccessBackend *m_backEnd; | 162 | OContactAccessBackend *m_backEnd; |
161 | bool m_loading:1; | 163 | bool m_loading:1; |
162 | 164 | ||
163 | private slots: | 165 | private slots: |
164 | void copMessage( const QCString &msg, const QByteArray &data ); | 166 | void copMessage( const QCString &msg, const QByteArray &data ); |
165 | 167 | ||
166 | 168 | ||
167 | }; | 169 | }; |
168 | #endif | 170 | #endif |
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index 6a3a0db..8ff205c 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h | |||
@@ -1,279 +1,291 @@ | |||
1 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H | 1 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H |
2 | #define OPIE_PIM_ACCESS_TEMPLATE_H | 2 | #define OPIE_PIM_ACCESS_TEMPLATE_H |
3 | 3 | ||
4 | #include <qarray.h> | 4 | #include <qarray.h> |
5 | 5 | ||
6 | #include <opie/opimrecord.h> | 6 | #include <opie/opimrecord.h> |
7 | #include <opie/opimaccessbackend.h> | 7 | #include <opie/opimaccessbackend.h> |
8 | #include <opie/orecordlist.h> | 8 | #include <opie/orecordlist.h> |
9 | 9 | ||
10 | #include "opimcache.h" | 10 | #include "opimcache.h" |
11 | #include "otemplatebase.h" | 11 | #include "otemplatebase.h" |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * Thats the frontend to our OPIE PIM | 14 | * Thats the frontend to our OPIE PIM |
15 | * Library. Either you want to use it's | 15 | * Library. Either you want to use it's |
16 | * interface or you want to implement | 16 | * interface or you want to implement |
17 | * your own Access lib | 17 | * your own Access lib |
18 | * Just create a OPimRecord and inherit from | 18 | * Just create a OPimRecord and inherit from |
19 | * the plugins | 19 | * the plugins |
20 | */ | 20 | */ |
21 | 21 | ||
22 | template <class T = OPimRecord > | 22 | template <class T = OPimRecord > |
23 | class OPimAccessTemplate : public OTemplateBase<T> { | 23 | class OPimAccessTemplate : public OTemplateBase<T> { |
24 | public: | 24 | public: |
25 | enum Access { | 25 | enum Access { |
26 | Random = 0, | 26 | Random = 0, |
27 | SortedAccess | 27 | SortedAccess |
28 | }; | 28 | }; |
29 | typedef ORecordList<T> List; | 29 | typedef ORecordList<T> List; |
30 | typedef OPimAccessBackend<T> BackEnd; | 30 | typedef OPimAccessBackend<T> BackEnd; |
31 | typedef OPimCache<T> Cache; | 31 | typedef OPimCache<T> Cache; |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * c'tor BackEnd | 34 | * c'tor BackEnd |
35 | * enum Access a small hint on how to handle the backend | 35 | * enum Access a small hint on how to handle the backend |
36 | */ | 36 | */ |
37 | OPimAccessTemplate( BackEnd* end); | 37 | OPimAccessTemplate( BackEnd* end); |
38 | 38 | ||
39 | virtual ~OPimAccessTemplate(); | 39 | virtual ~OPimAccessTemplate(); |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * load from the backend | 42 | * load from the backend |
43 | */ | 43 | */ |
44 | bool load(); | 44 | bool load(); |
45 | 45 | ||
46 | /** Reload database. | 46 | /** Reload database. |
47 | * You should execute this function if the external database | 47 | * You should execute this function if the external database |
48 | * was changed. | 48 | * was changed. |
49 | * This function will load the external database and afterwards | 49 | * This function will load the external database and afterwards |
50 | * rejoin the local changes. Therefore the local database will be set consistent. | 50 | * rejoin the local changes. Therefore the local database will be set consistent. |
51 | */ | 51 | */ |
52 | virtual bool reload(); | 52 | virtual bool reload(); |
53 | 53 | ||
54 | /** Save contacts database. | 54 | /** Save contacts database. |
55 | * Save is more a "commit". After calling this function, all changes are public available. | 55 | * Save is more a "commit". After calling this function, all changes are public available. |
56 | * @return true if successful | 56 | * @return true if successful |
57 | */ | 57 | */ |
58 | bool save(); | 58 | bool save(); |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * if the resource was changed externally | 61 | * if the resource was changed externally |
62 | * You should use the signal handling instead of polling possible changes ! | 62 | * You should use the signal handling instead of polling possible changes ! |
63 | * zecke: Do you implement a signal for otodoaccess ? | 63 | * zecke: Do you implement a signal for otodoaccess ? |
64 | */ | 64 | */ |
65 | bool wasChangedExternally()const; | 65 | bool wasChangedExternally()const; |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * return a List of records | 68 | * return a List of records |
69 | * you can iterate over them | 69 | * you can iterate over them |
70 | */ | 70 | */ |
71 | virtual List allRecords()const; | 71 | virtual List allRecords()const; |
72 | |||
73 | /** | ||
74 | * return a List of records | ||
75 | * that match the regex | ||
76 | */ | ||
77 | virtual List matchRegexp( const QRegExp &r ) const; | ||
72 | 78 | ||
73 | /** | 79 | /** |
74 | * queryByExample. | 80 | * queryByExample. |
75 | * @see otodoaccess, ocontactaccess | 81 | * @see otodoaccess, ocontactaccess |
76 | */ | 82 | */ |
77 | virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); | 83 | virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); |
78 | 84 | ||
79 | /** | 85 | /** |
80 | * find the OPimRecord uid | 86 | * find the OPimRecord uid |
81 | */ | 87 | */ |
82 | virtual T find( int uid )const; | 88 | virtual T find( int uid )const; |
83 | 89 | ||
84 | /** | 90 | /** |
85 | * read ahead cache find method ;) | 91 | * read ahead cache find method ;) |
86 | */ | 92 | */ |
87 | virtual T find( int uid, const QArray<int>&, | 93 | virtual T find( int uid, const QArray<int>&, |
88 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; | 94 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; |
89 | 95 | ||
90 | /* invalidate cache here */ | 96 | /* invalidate cache here */ |
91 | /** | 97 | /** |
92 | * clears the backend and invalidates the backend | 98 | * clears the backend and invalidates the backend |
93 | */ | 99 | */ |
94 | void clear() ; | 100 | void clear() ; |
95 | 101 | ||
96 | /** | 102 | /** |
97 | * add T to the backend | 103 | * add T to the backend |
98 | * @param t The item to add. | 104 | * @param t The item to add. |
99 | * @return <i>true</i> if added successfully. | 105 | * @return <i>true</i> if added successfully. |
100 | */ | 106 | */ |
101 | virtual bool add( const T& t ) ; | 107 | virtual bool add( const T& t ) ; |
102 | bool add( const OPimRecord& ); | 108 | bool add( const OPimRecord& ); |
103 | 109 | ||
104 | /* only the uid matters */ | 110 | /* only the uid matters */ |
105 | /** | 111 | /** |
106 | * remove T from the backend | 112 | * remove T from the backend |
107 | * @param t The item to remove | 113 | * @param t The item to remove |
108 | * @return <i>true</i> if successful. | 114 | * @return <i>true</i> if successful. |
109 | */ | 115 | */ |
110 | virtual bool remove( const T& t ); | 116 | virtual bool remove( const T& t ); |
111 | 117 | ||
112 | /** | 118 | /** |
113 | * remove the OPimRecord with uid | 119 | * remove the OPimRecord with uid |
114 | * @param uid The ID of the item to remove | 120 | * @param uid The ID of the item to remove |
115 | * @return <i>true</i> if successful. | 121 | * @return <i>true</i> if successful. |
116 | */ | 122 | */ |
117 | bool remove( int uid ); | 123 | bool remove( int uid ); |
118 | bool remove( const OPimRecord& ); | 124 | bool remove( const OPimRecord& ); |
119 | 125 | ||
120 | /** | 126 | /** |
121 | * replace T from backend | 127 | * replace T from backend |
122 | * @param t The item to replace | 128 | * @param t The item to replace |
123 | * @return <i>true</i> if successful. | 129 | * @return <i>true</i> if successful. |
124 | */ | 130 | */ |
125 | virtual bool replace( const T& t) ; | 131 | virtual bool replace( const T& t) ; |
126 | 132 | ||
127 | void setReadAhead( uint count ); | 133 | void setReadAhead( uint count ); |
128 | /** | 134 | /** |
129 | * @internal | 135 | * @internal |
130 | */ | 136 | */ |
131 | void cache( const T& )const; | 137 | void cache( const T& )const; |
132 | void setSaneCacheSize( int ); | 138 | void setSaneCacheSize( int ); |
133 | 139 | ||
134 | QArray<int> records()const; | 140 | QArray<int> records()const; |
135 | protected: | 141 | protected: |
136 | /** | 142 | /** |
137 | * invalidate the cache | 143 | * invalidate the cache |
138 | */ | 144 | */ |
139 | void invalidateCache(); | 145 | void invalidateCache(); |
140 | 146 | ||
141 | void setBackEnd( BackEnd* end ); | 147 | void setBackEnd( BackEnd* end ); |
142 | /** | 148 | /** |
143 | * returns the backend | 149 | * returns the backend |
144 | */ | 150 | */ |
145 | BackEnd* backEnd(); | 151 | BackEnd* backEnd(); |
146 | BackEnd* m_backEnd; | 152 | BackEnd* m_backEnd; |
147 | Cache m_cache; | 153 | Cache m_cache; |
148 | 154 | ||
149 | }; | 155 | }; |
150 | 156 | ||
151 | template <class T> | 157 | template <class T> |
152 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) | 158 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) |
153 | : OTemplateBase<T>(), m_backEnd( end ) | 159 | : OTemplateBase<T>(), m_backEnd( end ) |
154 | { | 160 | { |
155 | if (end ) | 161 | if (end ) |
156 | end->setFrontend( this ); | 162 | end->setFrontend( this ); |
157 | } | 163 | } |
158 | template <class T> | 164 | template <class T> |
159 | OPimAccessTemplate<T>::~OPimAccessTemplate() { | 165 | OPimAccessTemplate<T>::~OPimAccessTemplate() { |
160 | qWarning("~OPimAccessTemplate<T>"); | 166 | qWarning("~OPimAccessTemplate<T>"); |
161 | delete m_backEnd; | 167 | delete m_backEnd; |
162 | } | 168 | } |
163 | template <class T> | 169 | template <class T> |
164 | bool OPimAccessTemplate<T>::load() { | 170 | bool OPimAccessTemplate<T>::load() { |
165 | invalidateCache(); | 171 | invalidateCache(); |
166 | return m_backEnd->load(); | 172 | return m_backEnd->load(); |
167 | } | 173 | } |
168 | template <class T> | 174 | template <class T> |
169 | bool OPimAccessTemplate<T>::reload() { | 175 | bool OPimAccessTemplate<T>::reload() { |
170 | invalidateCache(); // zecke: I think this should be added (se) | 176 | invalidateCache(); // zecke: I think this should be added (se) |
171 | return m_backEnd->reload(); | 177 | return m_backEnd->reload(); |
172 | } | 178 | } |
173 | template <class T> | 179 | template <class T> |
174 | bool OPimAccessTemplate<T>::save() { | 180 | bool OPimAccessTemplate<T>::save() { |
175 | return m_backEnd->save(); | 181 | return m_backEnd->save(); |
176 | } | 182 | } |
177 | template <class T> | 183 | template <class T> |
178 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { | 184 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { |
179 | QArray<int> ints = m_backEnd->allRecords(); | 185 | QArray<int> ints = m_backEnd->allRecords(); |
180 | List lis(ints, this ); | 186 | List lis(ints, this ); |
181 | return lis; | 187 | return lis; |
182 | } | 188 | } |
183 | template <class T> | 189 | template <class T> |
190 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const { | ||
191 | QArray<int> ints = m_backEnd->matchRegexp( r ); | ||
192 | List lis(ints, this ); | ||
193 | return lis; | ||
194 | } | ||
195 | template <class T> | ||
184 | QArray<int> OPimAccessTemplate<T>::records()const { | 196 | QArray<int> OPimAccessTemplate<T>::records()const { |
185 | return m_backEnd->allRecords(); | 197 | return m_backEnd->allRecords(); |
186 | } | 198 | } |
187 | template <class T> | 199 | template <class T> |
188 | typename OPimAccessTemplate<T>::List | 200 | typename OPimAccessTemplate<T>::List |
189 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { | 201 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { |
190 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); | 202 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); |
191 | 203 | ||
192 | List lis(ints, this ); | 204 | List lis(ints, this ); |
193 | return lis; | 205 | return lis; |
194 | } | 206 | } |
195 | template <class T> | 207 | template <class T> |
196 | T OPimAccessTemplate<T>::find( int uid ) const{ | 208 | T OPimAccessTemplate<T>::find( int uid ) const{ |
197 | T t = m_backEnd->find( uid ); | 209 | T t = m_backEnd->find( uid ); |
198 | cache( t ); | 210 | cache( t ); |
199 | return t; | 211 | return t; |
200 | } | 212 | } |
201 | template <class T> | 213 | template <class T> |
202 | T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, | 214 | T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, |
203 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { | 215 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { |
204 | /* | 216 | /* |
205 | * better do T.isEmpty() | 217 | * better do T.isEmpty() |
206 | * after a find this way we would | 218 | * after a find this way we would |
207 | * avoid two finds in QCache... | 219 | * avoid two finds in QCache... |
208 | */ | 220 | */ |
209 | // qWarning("find it now %d", uid ); | 221 | // qWarning("find it now %d", uid ); |
210 | if (m_cache.contains( uid ) ) { | 222 | if (m_cache.contains( uid ) ) { |
211 | return m_cache.find( uid ); | 223 | return m_cache.find( uid ); |
212 | } | 224 | } |
213 | 225 | ||
214 | T t = m_backEnd->find( uid, ar, current, dir ); | 226 | T t = m_backEnd->find( uid, ar, current, dir ); |
215 | cache( t ); | 227 | cache( t ); |
216 | return t; | 228 | return t; |
217 | } | 229 | } |
218 | template <class T> | 230 | template <class T> |
219 | void OPimAccessTemplate<T>::clear() { | 231 | void OPimAccessTemplate<T>::clear() { |
220 | invalidateCache(); | 232 | invalidateCache(); |
221 | m_backEnd->clear(); | 233 | m_backEnd->clear(); |
222 | } | 234 | } |
223 | template <class T> | 235 | template <class T> |
224 | bool OPimAccessTemplate<T>::add( const T& t ) { | 236 | bool OPimAccessTemplate<T>::add( const T& t ) { |
225 | cache( t ); | 237 | cache( t ); |
226 | return m_backEnd->add( t ); | 238 | return m_backEnd->add( t ); |
227 | } | 239 | } |
228 | template <class T> | 240 | template <class T> |
229 | bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { | 241 | bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { |
230 | /* same type */ | 242 | /* same type */ |
231 | if ( rec.rtti() == T::rtti() ) { | 243 | if ( rec.rtti() == T::rtti() ) { |
232 | const T &t = static_cast<const T&>(rec); | 244 | const T &t = static_cast<const T&>(rec); |
233 | return add(t); | 245 | return add(t); |
234 | } | 246 | } |
235 | return false; | 247 | return false; |
236 | } | 248 | } |
237 | template <class T> | 249 | template <class T> |
238 | bool OPimAccessTemplate<T>::remove( const T& t ) { | 250 | bool OPimAccessTemplate<T>::remove( const T& t ) { |
239 | return remove( t.uid() ); | 251 | return remove( t.uid() ); |
240 | } | 252 | } |
241 | template <class T> | 253 | template <class T> |
242 | bool OPimAccessTemplate<T>::remove( int uid ) { | 254 | bool OPimAccessTemplate<T>::remove( int uid ) { |
243 | m_cache.remove( uid ); | 255 | m_cache.remove( uid ); |
244 | return m_backEnd->remove( uid ); | 256 | return m_backEnd->remove( uid ); |
245 | } | 257 | } |
246 | template <class T> | 258 | template <class T> |
247 | bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { | 259 | bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { |
248 | return remove( rec.uid() ); | 260 | return remove( rec.uid() ); |
249 | } | 261 | } |
250 | template <class T> | 262 | template <class T> |
251 | bool OPimAccessTemplate<T>::replace( const T& t ) { | 263 | bool OPimAccessTemplate<T>::replace( const T& t ) { |
252 | m_cache.replace( t ); | 264 | m_cache.replace( t ); |
253 | return m_backEnd->replace( t ); | 265 | return m_backEnd->replace( t ); |
254 | } | 266 | } |
255 | template <class T> | 267 | template <class T> |
256 | void OPimAccessTemplate<T>::invalidateCache() { | 268 | void OPimAccessTemplate<T>::invalidateCache() { |
257 | m_cache.invalidate(); | 269 | m_cache.invalidate(); |
258 | } | 270 | } |
259 | template <class T> | 271 | template <class T> |
260 | typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { | 272 | typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { |
261 | return m_backEnd; | 273 | return m_backEnd; |
262 | } | 274 | } |
263 | template <class T> | 275 | template <class T> |
264 | bool OPimAccessTemplate<T>::wasChangedExternally()const { | 276 | bool OPimAccessTemplate<T>::wasChangedExternally()const { |
265 | return false; | 277 | return false; |
266 | } | 278 | } |
267 | template <class T> | 279 | template <class T> |
268 | void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) { | 280 | void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) { |
269 | m_backEnd = end; | 281 | m_backEnd = end; |
270 | if (m_backEnd ) | 282 | if (m_backEnd ) |
271 | m_backEnd->setFrontend( this ); | 283 | m_backEnd->setFrontend( this ); |
272 | } | 284 | } |
273 | template <class T> | 285 | template <class T> |
274 | void OPimAccessTemplate<T>::cache( const T& t ) const{ | 286 | void OPimAccessTemplate<T>::cache( const T& t ) const{ |
275 | /* hacky we need to work around the const*/ | 287 | /* hacky we need to work around the const*/ |
276 | ((OPimAccessTemplate<T>*)this)->m_cache.add( t ); | 288 | ((OPimAccessTemplate<T>*)this)->m_cache.add( t ); |
277 | } | 289 | } |
278 | template <class T> | 290 | template <class T> |
279 | void OPimAccessTemplate<T>::setSaneCacheSize( int size ) { | 291 | void OPimAccessTemplate<T>::setSaneCacheSize( int size ) { |
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h index c7f9460..de2d9f4 100644 --- a/libopie2/opiepim/core/opimrecord.h +++ b/libopie2/opiepim/core/opimrecord.h | |||
@@ -1,134 +1,140 @@ | |||
1 | #ifndef OPIE_PIM_RECORD_H | 1 | #ifndef OPIE_PIM_RECORD_H |
2 | #define OPIE_PIM_RECORD_H | 2 | #define OPIE_PIM_RECORD_H |
3 | 3 | ||
4 | #include <qdatastream.h> | 4 | #include <qdatastream.h> |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qstringlist.h> | 7 | #include <qstringlist.h> |
8 | 8 | ||
9 | #include <qpe/palmtoprecord.h> | 9 | #include <qpe/palmtoprecord.h> |
10 | 10 | ||
11 | #include <opie/opimxrefmanager.h> | 11 | #include <opie/opimxrefmanager.h> |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * This is the base class for | 14 | * This is the base class for |
15 | * all PIM Records | 15 | * all PIM Records |
16 | * | 16 | * |
17 | */ | 17 | */ |
18 | class OPimRecord : public Qtopia::Record { | 18 | class OPimRecord : public Qtopia::Record { |
19 | public: | 19 | public: |
20 | /** | 20 | /** |
21 | * c'tor | 21 | * c'tor |
22 | * uid of 0 isEmpty | 22 | * uid of 0 isEmpty |
23 | * uid of 1 will be assigned a new one | 23 | * uid of 1 will be assigned a new one |
24 | */ | 24 | */ |
25 | OPimRecord(int uid = 0); | 25 | OPimRecord(int uid = 0); |
26 | ~OPimRecord(); | 26 | ~OPimRecord(); |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * copy c'tor | 29 | * copy c'tor |
30 | */ | 30 | */ |
31 | OPimRecord( const OPimRecord& rec ); | 31 | OPimRecord( const OPimRecord& rec ); |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * copy operator | 34 | * copy operator |
35 | */ | 35 | */ |
36 | OPimRecord &operator=( const OPimRecord& ); | 36 | OPimRecord &operator=( const OPimRecord& ); |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * category names resolved | 39 | * category names resolved |
40 | */ | 40 | */ |
41 | QStringList categoryNames( const QString& appname )const; | 41 | QStringList categoryNames( const QString& appname )const; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * set category names they will be resolved | 44 | * set category names they will be resolved |
45 | */ | 45 | */ |
46 | void setCategoryNames( const QStringList& ); | 46 | void setCategoryNames( const QStringList& ); |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * addCategoryName adds a name | 49 | * addCategoryName adds a name |
50 | * to the internal category list | 50 | * to the internal category list |
51 | */ | 51 | */ |
52 | void addCategoryName( const QString& ); | 52 | void addCategoryName( const QString& ); |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * if a Record isEmpty | 55 | * if a Record isEmpty |
56 | * it's empty if it's 0 | 56 | * it's empty if it's 0 |
57 | */ | 57 | */ |
58 | virtual bool isEmpty()const; | 58 | virtual bool isEmpty()const; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * toRichText summary | 61 | * toRichText summary |
62 | */ | 62 | */ |
63 | virtual QString toRichText()const = 0; | 63 | virtual QString toRichText()const = 0; |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * a small one line summary | 66 | * a small one line summary |
67 | */ | 67 | */ |
68 | virtual QString toShortText()const = 0; | 68 | virtual QString toShortText()const = 0; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * the name of the Record | 71 | * the name of the Record |
72 | */ | 72 | */ |
73 | virtual QString type()const = 0; | 73 | virtual QString type()const = 0; |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * matches the Records the regular expression? | ||
77 | */ | ||
78 | virtual bool match( const QString ®exp ) const {return match(QRegExp(regexp));}; | ||
79 | virtual bool match( const QRegExp ®exp ) const = 0; | ||
80 | |||
81 | /** | ||
76 | * converts the internal structure to a map | 82 | * converts the internal structure to a map |
77 | */ | 83 | */ |
78 | virtual QMap<int, QString> toMap()const = 0; | 84 | virtual QMap<int, QString> toMap()const = 0; |
79 | 85 | ||
80 | /** | 86 | /** |
81 | * key value representation of extra items | 87 | * key value representation of extra items |
82 | */ | 88 | */ |
83 | virtual QMap<QString, QString> toExtraMap()const = 0; | 89 | virtual QMap<QString, QString> toExtraMap()const = 0; |
84 | 90 | ||
85 | /** | 91 | /** |
86 | * the name for a recordField | 92 | * the name for a recordField |
87 | */ | 93 | */ |
88 | virtual QString recordField(int)const = 0; | 94 | virtual QString recordField(int)const = 0; |
89 | 95 | ||
90 | /** | 96 | /** |
91 | * returns a reference of the | 97 | * returns a reference of the |
92 | * Cross Reference Manager | 98 | * Cross Reference Manager |
93 | * Partner 'One' is THIS PIM RECORD! | 99 | * Partner 'One' is THIS PIM RECORD! |
94 | * 'Two' is the Partner where we link to | 100 | * 'Two' is the Partner where we link to |
95 | */ | 101 | */ |
96 | OPimXRefManager& xrefmanager(); | 102 | OPimXRefManager& xrefmanager(); |
97 | 103 | ||
98 | /** | 104 | /** |
99 | * set the uid | 105 | * set the uid |
100 | */ | 106 | */ |
101 | virtual void setUid( int uid ); | 107 | virtual void setUid( int uid ); |
102 | 108 | ||
103 | /* | 109 | /* |
104 | * used inside the Templates for casting | 110 | * used inside the Templates for casting |
105 | * REIMPLEMENT in your .... | 111 | * REIMPLEMENT in your .... |
106 | */ | 112 | */ |
107 | static int rtti(); | 113 | static int rtti(); |
108 | 114 | ||
109 | /** | 115 | /** |
110 | * some marshalling and de marshalling code | 116 | * some marshalling and de marshalling code |
111 | * saves the OPimRecord | 117 | * saves the OPimRecord |
112 | * to and from a DataStream | 118 | * to and from a DataStream |
113 | */ | 119 | */ |
114 | virtual bool loadFromStream(QDataStream& ); | 120 | virtual bool loadFromStream(QDataStream& ); |
115 | virtual bool saveToStream( QDataStream& stream )const; | 121 | virtual bool saveToStream( QDataStream& stream )const; |
116 | 122 | ||
117 | protected: | 123 | protected: |
118 | Qtopia::UidGen &uidGen(); | 124 | Qtopia::UidGen &uidGen(); |
119 | // QString crossToString()const; | 125 | // QString crossToString()const; |
120 | 126 | ||
121 | private: | 127 | private: |
122 | class OPimRecordPrivate; | 128 | class OPimRecordPrivate; |
123 | OPimRecordPrivate *d; | 129 | OPimRecordPrivate *d; |
124 | OPimXRefManager m_xrefman; | 130 | OPimXRefManager m_xrefman; |
125 | static Qtopia::UidGen m_uidGen; | 131 | static Qtopia::UidGen m_uidGen; |
126 | 132 | ||
127 | private: | 133 | private: |
128 | void flush( const OPimXRefPartner&, QDataStream& stream )const; | 134 | void flush( const OPimXRefPartner&, QDataStream& stream )const; |
129 | OPimXRefPartner partner( QDataStream& ); | 135 | OPimXRefPartner partner( QDataStream& ); |
130 | }; | 136 | }; |
131 | 137 | ||
132 | 138 | ||
133 | 139 | ||
134 | #endif | 140 | #endif |
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index 96a5f65..a38b62b 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp | |||
@@ -854,201 +854,192 @@ void OContact::save( QString &buf ) const | |||
854 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 854 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; |
855 | } | 855 | } |
856 | } | 856 | } |
857 | buf += customToXml(); | 857 | buf += customToXml(); |
858 | if ( categories().count() > 0 ) | 858 | if ( categories().count() > 0 ) |
859 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 859 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
860 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 860 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
861 | // You need to close this yourself | 861 | // You need to close this yourself |
862 | } | 862 | } |
863 | 863 | ||
864 | 864 | ||
865 | /*! | 865 | /*! |
866 | \internal | 866 | \internal |
867 | Returns the list of fields belonging to a contact | 867 | Returns the list of fields belonging to a contact |
868 | Never change order of this list ! It has to be regarding | 868 | Never change order of this list ! It has to be regarding |
869 | enum AddressBookFields !! | 869 | enum AddressBookFields !! |
870 | */ | 870 | */ |
871 | QStringList OContact::fields() | 871 | QStringList OContact::fields() |
872 | { | 872 | { |
873 | QStringList list; | 873 | QStringList list; |
874 | 874 | ||
875 | list.append( "Title" ); // Not Used! | 875 | list.append( "Title" ); // Not Used! |
876 | list.append( "FirstName" ); | 876 | list.append( "FirstName" ); |
877 | list.append( "MiddleName" ); | 877 | list.append( "MiddleName" ); |
878 | list.append( "LastName" ); | 878 | list.append( "LastName" ); |
879 | list.append( "Suffix" ); | 879 | list.append( "Suffix" ); |
880 | list.append( "FileAs" ); | 880 | list.append( "FileAs" ); |
881 | 881 | ||
882 | list.append( "JobTitle" ); | 882 | list.append( "JobTitle" ); |
883 | list.append( "Department" ); | 883 | list.append( "Department" ); |
884 | list.append( "Company" ); | 884 | list.append( "Company" ); |
885 | list.append( "BusinessPhone" ); | 885 | list.append( "BusinessPhone" ); |
886 | list.append( "BusinessFax" ); | 886 | list.append( "BusinessFax" ); |
887 | list.append( "BusinessMobile" ); | 887 | list.append( "BusinessMobile" ); |
888 | 888 | ||
889 | list.append( "DefaultEmail" ); | 889 | list.append( "DefaultEmail" ); |
890 | list.append( "Emails" ); | 890 | list.append( "Emails" ); |
891 | 891 | ||
892 | list.append( "HomePhone" ); | 892 | list.append( "HomePhone" ); |
893 | list.append( "HomeFax" ); | 893 | list.append( "HomeFax" ); |
894 | list.append( "HomeMobile" ); | 894 | list.append( "HomeMobile" ); |
895 | 895 | ||
896 | list.append( "BusinessStreet" ); | 896 | list.append( "BusinessStreet" ); |
897 | list.append( "BusinessCity" ); | 897 | list.append( "BusinessCity" ); |
898 | list.append( "BusinessState" ); | 898 | list.append( "BusinessState" ); |
899 | list.append( "BusinessZip" ); | 899 | list.append( "BusinessZip" ); |
900 | list.append( "BusinessCountry" ); | 900 | list.append( "BusinessCountry" ); |
901 | list.append( "BusinessPager" ); | 901 | list.append( "BusinessPager" ); |
902 | list.append( "BusinessWebPage" ); | 902 | list.append( "BusinessWebPage" ); |
903 | 903 | ||
904 | list.append( "Office" ); | 904 | list.append( "Office" ); |
905 | list.append( "Profession" ); | 905 | list.append( "Profession" ); |
906 | list.append( "Assistant" ); | 906 | list.append( "Assistant" ); |
907 | list.append( "Manager" ); | 907 | list.append( "Manager" ); |
908 | 908 | ||
909 | list.append( "HomeStreet" ); | 909 | list.append( "HomeStreet" ); |
910 | list.append( "HomeCity" ); | 910 | list.append( "HomeCity" ); |
911 | list.append( "HomeState" ); | 911 | list.append( "HomeState" ); |
912 | list.append( "HomeZip" ); | 912 | list.append( "HomeZip" ); |
913 | list.append( "HomeCountry" ); | 913 | list.append( "HomeCountry" ); |
914 | list.append( "HomeWebPage" ); | 914 | list.append( "HomeWebPage" ); |
915 | 915 | ||
916 | list.append( "Spouse" ); | 916 | list.append( "Spouse" ); |
917 | list.append( "Gender" ); | 917 | list.append( "Gender" ); |
918 | list.append( "Birthday" ); | 918 | list.append( "Birthday" ); |
919 | list.append( "Anniversary" ); | 919 | list.append( "Anniversary" ); |
920 | list.append( "Nickname" ); | 920 | list.append( "Nickname" ); |
921 | list.append( "Children" ); | 921 | list.append( "Children" ); |
922 | 922 | ||
923 | list.append( "Notes" ); | 923 | list.append( "Notes" ); |
924 | list.append( "Groups" ); | 924 | list.append( "Groups" ); |
925 | 925 | ||
926 | return list; | 926 | return list; |
927 | } | 927 | } |
928 | 928 | ||
929 | 929 | ||
930 | /*! | 930 | /*! |
931 | Sets the list of email address for contact to those contained in \a str. | 931 | Sets the list of email address for contact to those contained in \a str. |
932 | Email address should be separated by ';'s. | 932 | Email address should be separated by ';'s. |
933 | */ | 933 | */ |
934 | void OContact::setEmails( const QString &str ) | 934 | void OContact::setEmails( const QString &str ) |
935 | { | 935 | { |
936 | replace( Qtopia::Emails, str ); | 936 | replace( Qtopia::Emails, str ); |
937 | if ( str.isEmpty() ) | 937 | if ( str.isEmpty() ) |
938 | setDefaultEmail( QString::null ); | 938 | setDefaultEmail( QString::null ); |
939 | } | 939 | } |
940 | 940 | ||
941 | /*! | 941 | /*! |
942 | Sets the list of children for the contact to those contained in \a str. | 942 | Sets the list of children for the contact to those contained in \a str. |
943 | */ | 943 | */ |
944 | void OContact::setChildren( const QString &str ) | 944 | void OContact::setChildren( const QString &str ) |
945 | { | 945 | { |
946 | replace( Qtopia::Children, str ); | 946 | replace( Qtopia::Children, str ); |
947 | } | 947 | } |
948 | 948 | ||
949 | /*! | 949 | /*! |
950 | Returns TRUE if the contact matches the regular expression \a regexp. | ||
951 | Otherwise returns FALSE. | ||
952 | */ | ||
953 | bool OContact::match( const QString ®exp ) const | ||
954 | { | ||
955 | return match(QRegExp(regexp)); | ||
956 | } | ||
957 | |||
958 | /*! | ||
959 | \overload | 950 | \overload |
960 | Returns TRUE if the contact matches the regular expression \a regexp. | 951 | Returns TRUE if the contact matches the regular expression \a regexp. |
961 | Otherwise returns FALSE. | 952 | Otherwise returns FALSE. |
962 | */ | 953 | */ |
963 | bool OContact::match( const QRegExp &r ) const | 954 | bool OContact::match( const QRegExp &r ) const |
964 | { | 955 | { |
965 | bool match; | 956 | bool match; |
966 | match = false; | 957 | match = false; |
967 | QMap<int, QString>::ConstIterator it; | 958 | QMap<int, QString>::ConstIterator it; |
968 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 959 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { |
969 | if ( (*it).find( r ) > -1 ) { | 960 | if ( (*it).find( r ) > -1 ) { |
970 | match = true; | 961 | match = true; |
971 | break; | 962 | break; |
972 | } | 963 | } |
973 | } | 964 | } |
974 | return match; | 965 | return match; |
975 | } | 966 | } |
976 | 967 | ||
977 | 968 | ||
978 | QString OContact::toShortText() const | 969 | QString OContact::toShortText() const |
979 | { | 970 | { |
980 | return ( fullName() ); | 971 | return ( fullName() ); |
981 | } | 972 | } |
982 | QString OContact::type() const | 973 | QString OContact::type() const |
983 | { | 974 | { |
984 | return QString::fromLatin1( "OContact" ); | 975 | return QString::fromLatin1( "OContact" ); |
985 | } | 976 | } |
986 | 977 | ||
987 | // Definition is missing ! (se) | 978 | // Definition is missing ! (se) |
988 | QMap<QString,QString> OContact::toExtraMap() const | 979 | QMap<QString,QString> OContact::toExtraMap() const |
989 | { | 980 | { |
990 | qWarning ("Function not implemented: OContact::toExtraMap()"); | 981 | qWarning ("Function not implemented: OContact::toExtraMap()"); |
991 | QMap <QString,QString> useless; | 982 | QMap <QString,QString> useless; |
992 | return useless; | 983 | return useless; |
993 | } | 984 | } |
994 | 985 | ||
995 | class QString OContact::recordField( int pos ) const | 986 | class QString OContact::recordField( int pos ) const |
996 | { | 987 | { |
997 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 988 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
998 | return SLFIELDS[pos]; | 989 | return SLFIELDS[pos]; |
999 | } | 990 | } |
1000 | 991 | ||
1001 | // In future releases, we should store birthday and anniversary | 992 | // In future releases, we should store birthday and anniversary |
1002 | // internally as QDate instead of QString ! | 993 | // internally as QDate instead of QString ! |
1003 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 994 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
1004 | 995 | ||
1005 | /*! \fn void OContact::setBirthday( const QDate& date ) | 996 | /*! \fn void OContact::setBirthday( const QDate& date ) |
1006 | Sets the birthday for the contact to \a date. If date is null | 997 | Sets the birthday for the contact to \a date. If date is null |
1007 | the current stored date will be removed. | 998 | the current stored date will be removed. |
1008 | */ | 999 | */ |
1009 | void OContact::setBirthday( const QDate &v ) | 1000 | void OContact::setBirthday( const QDate &v ) |
1010 | { | 1001 | { |
1011 | if ( v.isNull() ){ | 1002 | if ( v.isNull() ){ |
1012 | qWarning( "Remove Birthday"); | 1003 | qWarning( "Remove Birthday"); |
1013 | replace( Qtopia::Birthday, QString::null ); | 1004 | replace( Qtopia::Birthday, QString::null ); |
1014 | return; | 1005 | return; |
1015 | } | 1006 | } |
1016 | 1007 | ||
1017 | if ( v.isValid() ) | 1008 | if ( v.isValid() ) |
1018 | replace( Qtopia::Birthday, OConversion::dateToString( v ) ); | 1009 | replace( Qtopia::Birthday, OConversion::dateToString( v ) ); |
1019 | 1010 | ||
1020 | } | 1011 | } |
1021 | 1012 | ||
1022 | 1013 | ||
1023 | /*! \fn void OContact::setAnniversary( const QDate &date ) | 1014 | /*! \fn void OContact::setAnniversary( const QDate &date ) |
1024 | Sets the anniversary of the contact to \a date. If date is | 1015 | Sets the anniversary of the contact to \a date. If date is |
1025 | null, the current stored date will be removed. | 1016 | null, the current stored date will be removed. |
1026 | */ | 1017 | */ |
1027 | void OContact::setAnniversary( const QDate &v ) | 1018 | void OContact::setAnniversary( const QDate &v ) |
1028 | { | 1019 | { |
1029 | if ( v.isNull() ){ | 1020 | if ( v.isNull() ){ |
1030 | qWarning( "Remove Anniversary"); | 1021 | qWarning( "Remove Anniversary"); |
1031 | replace( Qtopia::Anniversary, QString::null ); | 1022 | replace( Qtopia::Anniversary, QString::null ); |
1032 | return; | 1023 | return; |
1033 | } | 1024 | } |
1034 | 1025 | ||
1035 | if ( v.isValid() ) | 1026 | if ( v.isValid() ) |
1036 | replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); | 1027 | replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); |
1037 | } | 1028 | } |
1038 | 1029 | ||
1039 | /*! \fn QDate OContact::birthday() const | 1030 | /*! \fn QDate OContact::birthday() const |
1040 | Returns the birthday of the contact. | 1031 | Returns the birthday of the contact. |
1041 | */ | 1032 | */ |
1042 | QDate OContact::birthday() const | 1033 | QDate OContact::birthday() const |
1043 | { | 1034 | { |
1044 | QString str = find( Qtopia::Birthday ); | 1035 | QString str = find( Qtopia::Birthday ); |
1045 | qWarning ("Birthday %s", str.latin1() ); | 1036 | qWarning ("Birthday %s", str.latin1() ); |
1046 | if ( !str.isEmpty() ) | 1037 | if ( !str.isEmpty() ) |
1047 | return OConversion::dateFromString ( str ); | 1038 | return OConversion::dateFromString ( str ); |
1048 | else | 1039 | else |
1049 | return QDate(); | 1040 | return QDate(); |
1050 | } | 1041 | } |
1051 | 1042 | ||
1052 | 1043 | ||
1053 | /*! \fn QDate OContact::anniversary() const | 1044 | /*! \fn QDate OContact::anniversary() const |
1054 | Returns the anniversary of the contact. | 1045 | Returns the anniversary of the contact. |
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h index 50f6176..0e6cbd2 100644 --- a/libopie2/opiepim/ocontact.h +++ b/libopie2/opiepim/ocontact.h | |||
@@ -18,194 +18,193 @@ | |||
18 | **********************************************************************/ | 18 | **********************************************************************/ |
19 | 19 | ||
20 | #ifndef __OCONTACT_H__ | 20 | #ifndef __OCONTACT_H__ |
21 | #define __OCONTACT_H__ | 21 | #define __OCONTACT_H__ |
22 | 22 | ||
23 | #include <opie/opimrecord.h> | 23 | #include <opie/opimrecord.h> |
24 | #include <qpe/recordfields.h> | 24 | #include <qpe/recordfields.h> |
25 | 25 | ||
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | 28 | ||
29 | #if defined(QPC_TEMPLATEDLL) | 29 | #if defined(QPC_TEMPLATEDLL) |
30 | // MOC_SKIP_BEGIN | 30 | // MOC_SKIP_BEGIN |
31 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; | 31 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; |
32 | // MOC_SKIP_END | 32 | // MOC_SKIP_END |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | class ContactPrivate; | 35 | class ContactPrivate; |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * OContact class represents a specialised PIM Record for contacts. | 38 | * OContact class represents a specialised PIM Record for contacts. |
39 | * It does store all kind of persopn related information. | 39 | * It does store all kind of persopn related information. |
40 | * | 40 | * |
41 | * @short Contact Container | 41 | * @short Contact Container |
42 | * @author TT, Stefan Eiler, Holger Freyther | 42 | * @author TT, Stefan Eiler, Holger Freyther |
43 | */ | 43 | */ |
44 | class QPC_EXPORT OContact : public OPimRecord | 44 | class QPC_EXPORT OContact : public OPimRecord |
45 | { | 45 | { |
46 | friend class DataSet; | 46 | friend class DataSet; |
47 | public: | 47 | public: |
48 | OContact(); | 48 | OContact(); |
49 | OContact( const QMap<int, QString> &fromMap ); | 49 | OContact( const QMap<int, QString> &fromMap ); |
50 | virtual ~OContact(); | 50 | virtual ~OContact(); |
51 | 51 | ||
52 | /* | 52 | /* |
53 | * do we need to inline them | 53 | * do we need to inline them |
54 | * if yes do we need to inline them this way? | 54 | * if yes do we need to inline them this way? |
55 | * -zecke | 55 | * -zecke |
56 | */ | 56 | */ |
57 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } | 57 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } |
58 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } | 58 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } |
59 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } | 59 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } |
60 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } | 60 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } |
61 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } | 61 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } |
62 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } | 62 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } |
63 | void setFileAs(); | 63 | void setFileAs(); |
64 | 64 | ||
65 | // default email address | 65 | // default email address |
66 | void setDefaultEmail( const QString &v ); | 66 | void setDefaultEmail( const QString &v ); |
67 | // inserts email to list and ensure's doesn't already exist | 67 | // inserts email to list and ensure's doesn't already exist |
68 | void insertEmail( const QString &v ); | 68 | void insertEmail( const QString &v ); |
69 | void removeEmail( const QString &v ); | 69 | void removeEmail( const QString &v ); |
70 | void clearEmails(); | 70 | void clearEmails(); |
71 | void insertEmails( const QStringList &v ); | 71 | void insertEmails( const QStringList &v ); |
72 | 72 | ||
73 | // home | 73 | // home |
74 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } | 74 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } |
75 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } | 75 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } |
76 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } | 76 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } |
77 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } | 77 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } |
78 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } | 78 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } |
79 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } | 79 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } |
80 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } | 80 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } |
81 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } | 81 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } |
82 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } | 82 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } |
83 | 83 | ||
84 | // business | 84 | // business |
85 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } | 85 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } |
86 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } | 86 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } |
87 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } | 87 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } |
88 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } | 88 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } |
89 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 89 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
90 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 90 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
91 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 91 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
92 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 92 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
93 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 93 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
94 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 94 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
95 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 95 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
96 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 96 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
97 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 97 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
98 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 98 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
99 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 99 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
100 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 100 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
101 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 101 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
102 | 102 | ||
103 | // personal | 103 | // personal |
104 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 104 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
105 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 105 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
106 | void setBirthday( const QDate &v ); | 106 | void setBirthday( const QDate &v ); |
107 | void setAnniversary( const QDate &v ); | 107 | void setAnniversary( const QDate &v ); |
108 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 108 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
109 | void setChildren( const QString &v ); | 109 | void setChildren( const QString &v ); |
110 | 110 | ||
111 | // other | 111 | // other |
112 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 112 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } |
113 | 113 | ||
114 | bool match( const QString ®exp ) const; | 114 | virtual bool match( const QRegExp ®exp ) const; |
115 | bool match( const QRegExp ®exp ) const; | ||
116 | 115 | ||
117 | // // custom | 116 | // // custom |
118 | // void setCustomField( const QString &key, const QString &v ) | 117 | // void setCustomField( const QString &key, const QString &v ) |
119 | // { replace(Custom- + key, v ); } | 118 | // { replace(Custom- + key, v ); } |
120 | 119 | ||
121 | // name | 120 | // name |
122 | QString fullName() const; | 121 | QString fullName() const; |
123 | QString title() const { return find( Qtopia::Title ); } | 122 | QString title() const { return find( Qtopia::Title ); } |
124 | QString firstName() const { return find( Qtopia::FirstName ); } | 123 | QString firstName() const { return find( Qtopia::FirstName ); } |
125 | QString middleName() const { return find( Qtopia::MiddleName ); } | 124 | QString middleName() const { return find( Qtopia::MiddleName ); } |
126 | QString lastName() const { return find( Qtopia::LastName ); } | 125 | QString lastName() const { return find( Qtopia::LastName ); } |
127 | QString suffix() const { return find( Qtopia::Suffix ); } | 126 | QString suffix() const { return find( Qtopia::Suffix ); } |
128 | QString fileAs() const { return find( Qtopia::FileAs ); } | 127 | QString fileAs() const { return find( Qtopia::FileAs ); } |
129 | 128 | ||
130 | 129 | ||
131 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 130 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
132 | QStringList emailList() const; | 131 | QStringList emailList() const; |
133 | 132 | ||
134 | // home | 133 | // home |
135 | /* | 134 | /* |
136 | * OPimAddress address(enum Location)const; | 135 | * OPimAddress address(enum Location)const; |
137 | * would be some how nicer... | 136 | * would be some how nicer... |
138 | * -zecke | 137 | * -zecke |
139 | */ | 138 | */ |
140 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 139 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
141 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 140 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
142 | QString homeState() const { return find( Qtopia::HomeState ); } | 141 | QString homeState() const { return find( Qtopia::HomeState ); } |
143 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 142 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
144 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 143 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
145 | QString homePhone() const { return find( Qtopia::HomePhone ); } | 144 | QString homePhone() const { return find( Qtopia::HomePhone ); } |
146 | QString homeFax() const { return find( Qtopia::HomeFax ); } | 145 | QString homeFax() const { return find( Qtopia::HomeFax ); } |
147 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } | 146 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } |
148 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } | 147 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } |
149 | /** Multi line string containing all non-empty address info in the form | 148 | /** Multi line string containing all non-empty address info in the form |
150 | * Street | 149 | * Street |
151 | * City, State Zip | 150 | * City, State Zip |
152 | * Country | 151 | * Country |
153 | */ | 152 | */ |
154 | QString displayHomeAddress() const; | 153 | QString displayHomeAddress() const; |
155 | 154 | ||
156 | // business | 155 | // business |
157 | QString company() const { return find( Qtopia::Company ); } | 156 | QString company() const { return find( Qtopia::Company ); } |
158 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } | 157 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } |
159 | QString businessCity() const { return find( Qtopia::BusinessCity ); } | 158 | QString businessCity() const { return find( Qtopia::BusinessCity ); } |
160 | QString businessState() const { return find( Qtopia::BusinessState ); } | 159 | QString businessState() const { return find( Qtopia::BusinessState ); } |
161 | QString businessZip() const { return find( Qtopia::BusinessZip ); } | 160 | QString businessZip() const { return find( Qtopia::BusinessZip ); } |
162 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } | 161 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } |
163 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | 162 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } |
164 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 163 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
165 | QString department() const { return find( Qtopia::Department ); } | 164 | QString department() const { return find( Qtopia::Department ); } |
166 | QString office() const { return find( Qtopia::Office ); } | 165 | QString office() const { return find( Qtopia::Office ); } |
167 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 166 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
168 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 167 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
169 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 168 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
170 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 169 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
171 | QString profession() const { return find( Qtopia::Profession ); } | 170 | QString profession() const { return find( Qtopia::Profession ); } |
172 | QString assistant() const { return find( Qtopia::Assistant ); } | 171 | QString assistant() const { return find( Qtopia::Assistant ); } |
173 | QString manager() const { return find( Qtopia::Manager ); } | 172 | QString manager() const { return find( Qtopia::Manager ); } |
174 | /** Multi line string containing all non-empty address info in the form | 173 | /** Multi line string containing all non-empty address info in the form |
175 | * Street | 174 | * Street |
176 | * City, State Zip | 175 | * City, State Zip |
177 | * Country | 176 | * Country |
178 | */ | 177 | */ |
179 | QString displayBusinessAddress() const; | 178 | QString displayBusinessAddress() const; |
180 | 179 | ||
181 | //personal | 180 | //personal |
182 | QString spouse() const { return find( Qtopia::Spouse ); } | 181 | QString spouse() const { return find( Qtopia::Spouse ); } |
183 | QString gender() const { return find( Qtopia::Gender ); } | 182 | QString gender() const { return find( Qtopia::Gender ); } |
184 | QDate birthday() const; | 183 | QDate birthday() const; |
185 | QDate anniversary() const; | 184 | QDate anniversary() const; |
186 | QString nickname() const { return find( Qtopia::Nickname ); } | 185 | QString nickname() const { return find( Qtopia::Nickname ); } |
187 | QString children() const { return find( Qtopia::Children ); } | 186 | QString children() const { return find( Qtopia::Children ); } |
188 | QStringList childrenList() const; | 187 | QStringList childrenList() const; |
189 | 188 | ||
190 | // other | 189 | // other |
191 | QString notes() const { return find( Qtopia::Notes ); } | 190 | QString notes() const { return find( Qtopia::Notes ); } |
192 | QString groups() const { return find( Qtopia::Groups ); } | 191 | QString groups() const { return find( Qtopia::Groups ); } |
193 | QStringList groupList() const; | 192 | QStringList groupList() const; |
194 | 193 | ||
195 | // // custom | 194 | // // custom |
196 | // const QString &customField( const QString &key ) | 195 | // const QString &customField( const QString &key ) |
197 | // { return find( Custom- + key ); } | 196 | // { return find( Custom- + key ); } |
198 | 197 | ||
199 | 198 | ||
200 | QString toRichText() const; | 199 | QString toRichText() const; |
201 | QMap<int, QString> toMap() const; | 200 | QMap<int, QString> toMap() const; |
202 | QString field( int key ) const { return find( key ); } | 201 | QString field( int key ) const { return find( key ); } |
203 | 202 | ||
204 | 203 | ||
205 | void setUid( int i ); | 204 | void setUid( int i ); |
206 | 205 | ||
207 | QString toShortText()const; | 206 | QString toShortText()const; |
208 | QString OContact::type()const; | 207 | QString OContact::type()const; |
209 | QMap<QString,QString> OContact::toExtraMap() const; | 208 | QMap<QString,QString> OContact::toExtraMap() const; |
210 | class QString OContact::recordField(int) const; | 209 | class QString OContact::recordField(int) const; |
211 | 210 | ||
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp index 3ba8a52..28cf873 100644 --- a/libopie2/opiepim/oevent.cpp +++ b/libopie2/opiepim/oevent.cpp | |||
@@ -1,100 +1,101 @@ | |||
1 | #include <qshared.h> | 1 | #include <qshared.h> |
2 | 2 | ||
3 | #include <qpe/palmtopuidgen.h> | 3 | #include <qpe/palmtopuidgen.h> |
4 | #include <qpe/categories.h> | 4 | #include <qpe/categories.h> |
5 | #include <qpe/stringutil.h> | ||
5 | 6 | ||
6 | #include "orecur.h" | 7 | #include "orecur.h" |
7 | #include "opimresolver.h" | 8 | #include "opimresolver.h" |
8 | #include "opimnotifymanager.h" | 9 | #include "opimnotifymanager.h" |
9 | 10 | ||
10 | #include "oevent.h" | 11 | #include "oevent.h" |
11 | 12 | ||
12 | int OCalendarHelper::week( const QDate& date) { | 13 | int OCalendarHelper::week( const QDate& date) { |
13 | // Calculates the week this date is in within that | 14 | // Calculates the week this date is in within that |
14 | // month. Equals the "row" is is in in the month view | 15 | // month. Equals the "row" is is in in the month view |
15 | int week = 1; | 16 | int week = 1; |
16 | QDate tmp( date.year(), date.month(), 1 ); | 17 | QDate tmp( date.year(), date.month(), 1 ); |
17 | if ( date.dayOfWeek() < tmp.dayOfWeek() ) | 18 | if ( date.dayOfWeek() < tmp.dayOfWeek() ) |
18 | ++week; | 19 | ++week; |
19 | 20 | ||
20 | week += ( date.day() - 1 ) / 7; | 21 | week += ( date.day() - 1 ) / 7; |
21 | 22 | ||
22 | return week; | 23 | return week; |
23 | } | 24 | } |
24 | int OCalendarHelper::ocurrence( const QDate& date) { | 25 | int OCalendarHelper::ocurrence( const QDate& date) { |
25 | // calculates the number of occurrances of this day of the | 26 | // calculates the number of occurrances of this day of the |
26 | // week till the given date (e.g 3rd Wednesday of the month) | 27 | // week till the given date (e.g 3rd Wednesday of the month) |
27 | return ( date.day() - 1 ) / 7 + 1; | 28 | return ( date.day() - 1 ) / 7 + 1; |
28 | } | 29 | } |
29 | int OCalendarHelper::dayOfWeek( char day ) { | 30 | int OCalendarHelper::dayOfWeek( char day ) { |
30 | int dayOfWeek = 1; | 31 | int dayOfWeek = 1; |
31 | char i = ORecur::MON; | 32 | char i = ORecur::MON; |
32 | while ( !( i & day ) && i <= ORecur::SUN ) { | 33 | while ( !( i & day ) && i <= ORecur::SUN ) { |
33 | i <<= 1; | 34 | i <<= 1; |
34 | ++dayOfWeek; | 35 | ++dayOfWeek; |
35 | } | 36 | } |
36 | return dayOfWeek; | 37 | return dayOfWeek; |
37 | } | 38 | } |
38 | int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { | 39 | int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { |
39 | return ( second.year() - first.year() ) * 12 + | 40 | return ( second.year() - first.year() ) * 12 + |
40 | second.month() - first.month(); | 41 | second.month() - first.month(); |
41 | } | 42 | } |
42 | 43 | ||
43 | struct OEvent::Data : public QShared { | 44 | struct OEvent::Data : public QShared { |
44 | Data() : QShared() { | 45 | Data() : QShared() { |
45 | child = 0; | 46 | child = 0; |
46 | recur = 0; | 47 | recur = 0; |
47 | manager = 0; | 48 | manager = 0; |
48 | isAllDay = false; | 49 | isAllDay = false; |
49 | parent = 0; | 50 | parent = 0; |
50 | } | 51 | } |
51 | ~Data() { | 52 | ~Data() { |
52 | delete manager; | 53 | delete manager; |
53 | delete recur; | 54 | delete recur; |
54 | } | 55 | } |
55 | QString description; | 56 | QString description; |
56 | QString location; | 57 | QString location; |
57 | OPimNotifyManager* manager; | 58 | OPimNotifyManager* manager; |
58 | ORecur* recur; | 59 | ORecur* recur; |
59 | QString note; | 60 | QString note; |
60 | QDateTime created; | 61 | QDateTime created; |
61 | QDateTime start; | 62 | QDateTime start; |
62 | QDateTime end; | 63 | QDateTime end; |
63 | bool isAllDay : 1; | 64 | bool isAllDay : 1; |
64 | QString timezone; | 65 | QString timezone; |
65 | QArray<int>* child; | 66 | QArray<int>* child; |
66 | int parent; | 67 | int parent; |
67 | }; | 68 | }; |
68 | 69 | ||
69 | OEvent::OEvent( int uid ) | 70 | OEvent::OEvent( int uid ) |
70 | : OPimRecord( uid ) { | 71 | : OPimRecord( uid ) { |
71 | data = new Data; | 72 | data = new Data; |
72 | } | 73 | } |
73 | OEvent::OEvent( const OEvent& ev) | 74 | OEvent::OEvent( const OEvent& ev) |
74 | : OPimRecord( ev ), data( ev.data ) | 75 | : OPimRecord( ev ), data( ev.data ) |
75 | { | 76 | { |
76 | data->ref(); | 77 | data->ref(); |
77 | } | 78 | } |
78 | OEvent::~OEvent() { | 79 | OEvent::~OEvent() { |
79 | if ( data->deref() ) { | 80 | if ( data->deref() ) { |
80 | delete data; | 81 | delete data; |
81 | data = 0; | 82 | data = 0; |
82 | } | 83 | } |
83 | } | 84 | } |
84 | OEvent& OEvent::operator=( const OEvent& ev) { | 85 | OEvent& OEvent::operator=( const OEvent& ev) { |
85 | if ( this == &ev ) return *this; | 86 | if ( this == &ev ) return *this; |
86 | 87 | ||
87 | OPimRecord::operator=( ev ); | 88 | OPimRecord::operator=( ev ); |
88 | ev.data->ref(); | 89 | ev.data->ref(); |
89 | deref(); | 90 | deref(); |
90 | data = ev.data; | 91 | data = ev.data; |
91 | 92 | ||
92 | 93 | ||
93 | return *this; | 94 | return *this; |
94 | } | 95 | } |
95 | QString OEvent::description()const { | 96 | QString OEvent::description()const { |
96 | return data->description; | 97 | return data->description; |
97 | } | 98 | } |
98 | void OEvent::setDescription( const QString& description ) { | 99 | void OEvent::setDescription( const QString& description ) { |
99 | changeOrModify(); | 100 | changeOrModify(); |
100 | data->description = description; | 101 | data->description = description; |
@@ -117,202 +118,232 @@ OPimNotifyManager &OEvent::notifiers()const { | |||
117 | } | 118 | } |
118 | bool OEvent::hasNotifiers()const { | 119 | bool OEvent::hasNotifiers()const { |
119 | if (!data->manager ) | 120 | if (!data->manager ) |
120 | return false; | 121 | return false; |
121 | if (data->manager->reminders().isEmpty() && | 122 | if (data->manager->reminders().isEmpty() && |
122 | data->manager->alarms().isEmpty() ) | 123 | data->manager->alarms().isEmpty() ) |
123 | return false; | 124 | return false; |
124 | 125 | ||
125 | return true; | 126 | return true; |
126 | } | 127 | } |
127 | ORecur OEvent::recurrence()const { | 128 | ORecur OEvent::recurrence()const { |
128 | if (!data->recur) | 129 | if (!data->recur) |
129 | data->recur = new ORecur; | 130 | data->recur = new ORecur; |
130 | 131 | ||
131 | return *data->recur; | 132 | return *data->recur; |
132 | } | 133 | } |
133 | void OEvent::setRecurrence( const ORecur& rec) { | 134 | void OEvent::setRecurrence( const ORecur& rec) { |
134 | changeOrModify(); | 135 | changeOrModify(); |
135 | if (data->recur ) | 136 | if (data->recur ) |
136 | (*data->recur) = rec; | 137 | (*data->recur) = rec; |
137 | else | 138 | else |
138 | data->recur = new ORecur( rec ); | 139 | data->recur = new ORecur( rec ); |
139 | } | 140 | } |
140 | bool OEvent::hasRecurrence()const { | 141 | bool OEvent::hasRecurrence()const { |
141 | if (!data->recur ) return false; | 142 | if (!data->recur ) return false; |
142 | return data->recur->doesRecur(); | 143 | return data->recur->doesRecur(); |
143 | } | 144 | } |
144 | QString OEvent::note()const { | 145 | QString OEvent::note()const { |
145 | return data->note; | 146 | return data->note; |
146 | } | 147 | } |
147 | void OEvent::setNote( const QString& note ) { | 148 | void OEvent::setNote( const QString& note ) { |
148 | changeOrModify(); | 149 | changeOrModify(); |
149 | data->note = note; | 150 | data->note = note; |
150 | } | 151 | } |
151 | QDateTime OEvent::createdDateTime()const { | 152 | QDateTime OEvent::createdDateTime()const { |
152 | return data->created; | 153 | return data->created; |
153 | } | 154 | } |
154 | void OEvent::setCreatedDateTime( const QDateTime& time ) { | 155 | void OEvent::setCreatedDateTime( const QDateTime& time ) { |
155 | changeOrModify(); | 156 | changeOrModify(); |
156 | data->created = time; | 157 | data->created = time; |
157 | } | 158 | } |
158 | QDateTime OEvent::startDateTime()const { | 159 | QDateTime OEvent::startDateTime()const { |
159 | if ( data->isAllDay ) | 160 | if ( data->isAllDay ) |
160 | return QDateTime( data->start.date(), QTime(0, 0, 0 ) ); | 161 | return QDateTime( data->start.date(), QTime(0, 0, 0 ) ); |
161 | return data->start; | 162 | return data->start; |
162 | } | 163 | } |
163 | QDateTime OEvent::startDateTimeInZone()const { | 164 | QDateTime OEvent::startDateTimeInZone()const { |
164 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 165 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
165 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); | 166 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); |
166 | 167 | ||
167 | OTimeZone zone(data->timezone ); | 168 | OTimeZone zone(data->timezone ); |
168 | return zone.toDateTime( data->start, OTimeZone::current() ); | 169 | return zone.toDateTime( data->start, OTimeZone::current() ); |
169 | } | 170 | } |
170 | void OEvent::setStartDateTime( const QDateTime& dt ) { | 171 | void OEvent::setStartDateTime( const QDateTime& dt ) { |
171 | changeOrModify(); | 172 | changeOrModify(); |
172 | data->start = dt; | 173 | data->start = dt; |
173 | } | 174 | } |
174 | QDateTime OEvent::endDateTime()const { | 175 | QDateTime OEvent::endDateTime()const { |
175 | /* | 176 | /* |
176 | * if all Day event the end time needs | 177 | * if all Day event the end time needs |
177 | * to be on the same day as the start | 178 | * to be on the same day as the start |
178 | */ | 179 | */ |
179 | if ( data->isAllDay ) | 180 | if ( data->isAllDay ) |
180 | return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); | 181 | return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); |
181 | return data->end; | 182 | return data->end; |
182 | } | 183 | } |
183 | QDateTime OEvent::endDateTimeInZone()const { | 184 | QDateTime OEvent::endDateTimeInZone()const { |
184 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 185 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
185 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); | 186 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); |
186 | 187 | ||
187 | OTimeZone zone(data->timezone ); | 188 | OTimeZone zone(data->timezone ); |
188 | return zone.toDateTime( data->end, OTimeZone::current() ); | 189 | return zone.toDateTime( data->end, OTimeZone::current() ); |
189 | } | 190 | } |
190 | void OEvent::setEndDateTime( const QDateTime& dt ) { | 191 | void OEvent::setEndDateTime( const QDateTime& dt ) { |
191 | changeOrModify(); | 192 | changeOrModify(); |
192 | data->end = dt; | 193 | data->end = dt; |
193 | } | 194 | } |
194 | bool OEvent::isMultipleDay()const { | 195 | bool OEvent::isMultipleDay()const { |
195 | return data->end.date().day() - data->start.date().day(); | 196 | return data->end.date().day() - data->start.date().day(); |
196 | } | 197 | } |
197 | bool OEvent::isAllDay()const { | 198 | bool OEvent::isAllDay()const { |
198 | return data->isAllDay; | 199 | return data->isAllDay; |
199 | } | 200 | } |
200 | void OEvent::setAllDay( bool allDay ) { | 201 | void OEvent::setAllDay( bool allDay ) { |
201 | changeOrModify(); | 202 | changeOrModify(); |
202 | data->isAllDay = allDay; | 203 | data->isAllDay = allDay; |
203 | if (allDay ) data->timezone = "UTC"; | 204 | if (allDay ) data->timezone = "UTC"; |
204 | } | 205 | } |
205 | void OEvent::setTimeZone( const QString& tz ) { | 206 | void OEvent::setTimeZone( const QString& tz ) { |
206 | changeOrModify(); | 207 | changeOrModify(); |
207 | data->timezone = tz; | 208 | data->timezone = tz; |
208 | } | 209 | } |
209 | QString OEvent::timeZone()const { | 210 | QString OEvent::timeZone()const { |
210 | if (data->isAllDay ) return QString::fromLatin1("UTC"); | 211 | if (data->isAllDay ) return QString::fromLatin1("UTC"); |
211 | return data->timezone; | 212 | return data->timezone; |
212 | } | 213 | } |
213 | bool OEvent::match( const QRegExp& )const { | 214 | bool OEvent::match( const QRegExp& re )const { |
214 | // FIXME | 215 | if (data->description.contains( re ) ) |
216 | return true; | ||
217 | if ( data->note.contains( re ) ) | ||
218 | return true; | ||
219 | if ( data->location.contains( re ) ) | ||
220 | return true; | ||
221 | if ( data->start.toString().contains( re ) ) | ||
222 | return true; | ||
223 | if ( data->end.toString().contains( re ) ) | ||
224 | return true; | ||
215 | return false; | 225 | return false; |
216 | } | 226 | } |
217 | QString OEvent::toRichText()const { | 227 | QString OEvent::toRichText()const { |
218 | // FIXME | 228 | QString text; |
219 | return "OEvent test"; | 229 | if ( !description().isEmpty() ) { |
230 | text += "<b>" + QObject::tr( "Description:") + "</b><br>"; | ||
231 | text += Qtopia::escapeString(description() ). | ||
232 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
233 | } | ||
234 | if ( startDateTime().isValid() ) { | ||
235 | text += "<b>" + QObject::tr( "Start:") + "</b> "; | ||
236 | text += Qtopia::escapeString(startDateTime().toString() ). | ||
237 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
238 | } | ||
239 | if ( endDateTime().isValid() ) { | ||
240 | text += "<b>" + QObject::tr( "End:") + "</b> "; | ||
241 | text += Qtopia::escapeString(endDateTime().toString() ). | ||
242 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
243 | } | ||
244 | if ( !note().isEmpty() ) { | ||
245 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; | ||
246 | text += note(); | ||
247 | // text += Qtopia::escapeString(note() ). | ||
248 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
249 | } | ||
250 | return text; | ||
220 | } | 251 | } |
221 | QString OEvent::toShortText()const { | 252 | QString OEvent::toShortText()const { |
222 | return "OEvent shotText"; | 253 | return description(); |
223 | } | 254 | } |
224 | QString OEvent::type()const { | 255 | QString OEvent::type()const { |
225 | return QString::fromLatin1("OEvent"); | 256 | return QString::fromLatin1("OEvent"); |
226 | } | 257 | } |
227 | QString OEvent::recordField( int /*id */ )const { | 258 | QString OEvent::recordField( int /*id */ )const { |
228 | return QString::null; | 259 | return QString::null; |
229 | } | 260 | } |
230 | int OEvent::rtti() { | 261 | int OEvent::rtti() { |
231 | return OPimResolver::DateBook; | 262 | return OPimResolver::DateBook; |
232 | } | 263 | } |
233 | bool OEvent::loadFromStream( QDataStream& ) { | 264 | bool OEvent::loadFromStream( QDataStream& ) { |
234 | return true; | 265 | return true; |
235 | } | 266 | } |
236 | bool OEvent::saveToStream( QDataStream& )const { | 267 | bool OEvent::saveToStream( QDataStream& )const { |
237 | return true; | 268 | return true; |
238 | } | 269 | } |
239 | void OEvent::changeOrModify() { | 270 | void OEvent::changeOrModify() { |
240 | if ( data->count != 1 ) { | 271 | if ( data->count != 1 ) { |
241 | data->deref(); | 272 | data->deref(); |
242 | Data* d2 = new Data; | 273 | Data* d2 = new Data; |
243 | d2->description = data->description; | 274 | d2->description = data->description; |
244 | d2->location = data->location; | 275 | d2->location = data->location; |
245 | 276 | ||
246 | if (data->manager ) | 277 | if (data->manager ) |
247 | d2->manager = new OPimNotifyManager( *data->manager ); | 278 | d2->manager = new OPimNotifyManager( *data->manager ); |
248 | 279 | ||
249 | if ( data->recur ) | 280 | if ( data->recur ) |
250 | d2->recur = new ORecur( *data->recur ); | 281 | d2->recur = new ORecur( *data->recur ); |
251 | 282 | ||
252 | d2->note = data->note; | 283 | d2->note = data->note; |
253 | d2->created = data->created; | 284 | d2->created = data->created; |
254 | d2->start = data->start; | 285 | d2->start = data->start; |
255 | d2->end = data->end; | 286 | d2->end = data->end; |
256 | d2->isAllDay = data->isAllDay; | 287 | d2->isAllDay = data->isAllDay; |
257 | d2->timezone = data->timezone; | 288 | d2->timezone = data->timezone; |
258 | d2->parent = data->parent; | 289 | d2->parent = data->parent; |
259 | 290 | ||
260 | if ( data->child ) { | 291 | if ( data->child ) { |
261 | d2->child = new QArray<int>( *data->child ); | 292 | d2->child = new QArray<int>( *data->child ); |
262 | d2->child->detach(); | 293 | d2->child->detach(); |
263 | } | 294 | } |
264 | 295 | ||
265 | data = d2; | 296 | data = d2; |
266 | } | 297 | } |
267 | } | 298 | } |
268 | void OEvent::deref() { | 299 | void OEvent::deref() { |
269 | if ( data->deref() ) { | 300 | if ( data->deref() ) { |
270 | delete data; | 301 | delete data; |
271 | data = 0; | 302 | data = 0; |
272 | } | 303 | } |
273 | } | 304 | } |
274 | // FIXME | 305 | // FIXME |
275 | QMap<int, QString> OEvent::toMap()const { | 306 | QMap<int, QString> OEvent::toMap()const { |
276 | return QMap<int, QString>(); | 307 | return QMap<int, QString>(); |
277 | } | 308 | } |
278 | QMap<QString, QString> OEvent::toExtraMap()const { | 309 | QMap<QString, QString> OEvent::toExtraMap()const { |
279 | return QMap<QString, QString>(); | 310 | return QMap<QString, QString>(); |
280 | } | 311 | } |
281 | int OEvent::parent()const { | 312 | int OEvent::parent()const { |
282 | return data->parent; | 313 | return data->parent; |
283 | } | 314 | } |
284 | void OEvent::setParent( int uid ) { | 315 | void OEvent::setParent( int uid ) { |
285 | changeOrModify(); | 316 | changeOrModify(); |
286 | data->parent = uid; | 317 | data->parent = uid; |
287 | } | 318 | } |
288 | QArray<int> OEvent::children() const{ | 319 | QArray<int> OEvent::children() const{ |
289 | if (!data->child) return QArray<int>(); | 320 | if (!data->child) return QArray<int>(); |
290 | else | 321 | else |
291 | return data->child->copy(); | 322 | return data->child->copy(); |
292 | } | 323 | } |
293 | void OEvent::setChildren( const QArray<int>& arr ) { | 324 | void OEvent::setChildren( const QArray<int>& arr ) { |
294 | changeOrModify(); | 325 | changeOrModify(); |
295 | if (data->child) delete data->child; | 326 | if (data->child) delete data->child; |
296 | 327 | ||
297 | data->child = new QArray<int>( arr ); | 328 | data->child = new QArray<int>( arr ); |
298 | data->child->detach(); | 329 | data->child->detach(); |
299 | } | 330 | } |
300 | void OEvent::addChild( int uid ) { | 331 | void OEvent::addChild( int uid ) { |
301 | changeOrModify(); | 332 | changeOrModify(); |
302 | if (!data->child ) { | 333 | if (!data->child ) { |
303 | data->child = new QArray<int>(1); | 334 | data->child = new QArray<int>(1); |
304 | (*data->child)[0] = uid; | 335 | (*data->child)[0] = uid; |
305 | }else{ | 336 | }else{ |
306 | int count = data->child->count(); | 337 | int count = data->child->count(); |
307 | data->child->resize( count + 1 ); | 338 | data->child->resize( count + 1 ); |
308 | (*data->child)[count] = uid; | 339 | (*data->child)[count] = uid; |
309 | } | 340 | } |
310 | } | 341 | } |
311 | void OEvent::removeChild( int uid ) { | 342 | void OEvent::removeChild( int uid ) { |
312 | if (!data->child || !data->child->contains( uid ) ) return; | 343 | if (!data->child || !data->child->contains( uid ) ) return; |
313 | changeOrModify(); | 344 | changeOrModify(); |
314 | QArray<int> newAr( data->child->count() - 1 ); | 345 | QArray<int> newAr( data->child->count() - 1 ); |
315 | int j = 0; | 346 | int j = 0; |
316 | uint count = data->child->count(); | 347 | uint count = data->child->count(); |
317 | for ( uint i = 0; i < count; i++ ) { | 348 | for ( uint i = 0; i < count; i++ ) { |
318 | if ( (*data->child)[i] != uid ) { | 349 | if ( (*data->child)[i] != uid ) { |
diff --git a/libopie2/opiepim/oevent.h b/libopie2/opiepim/oevent.h index 57d32d0..b696d81 100644 --- a/libopie2/opiepim/oevent.h +++ b/libopie2/opiepim/oevent.h | |||
@@ -20,193 +20,193 @@ struct OCalendarHelper { | |||
20 | static int ocurrence( const QDate& ); | 20 | static int ocurrence( const QDate& ); |
21 | 21 | ||
22 | // returns the dayOfWeek for the *first* day it finds (ignores | 22 | // returns the dayOfWeek for the *first* day it finds (ignores |
23 | // any further days!). Returns 1 (Monday) if there isn't any day found | 23 | // any further days!). Returns 1 (Monday) if there isn't any day found |
24 | static int dayOfWeek( char day ); | 24 | static int dayOfWeek( char day ); |
25 | 25 | ||
26 | /** returns the diff of month */ | 26 | /** returns the diff of month */ |
27 | static int monthDiff( const QDate& first, const QDate& second ); | 27 | static int monthDiff( const QDate& first, const QDate& second ); |
28 | 28 | ||
29 | }; | 29 | }; |
30 | 30 | ||
31 | class OPimNotifyManager; | 31 | class OPimNotifyManager; |
32 | class ORecur; | 32 | class ORecur; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * This is the container for all Events. It encapsules all | 35 | * This is the container for all Events. It encapsules all |
36 | * available information for a single Event | 36 | * available information for a single Event |
37 | * @short container for events. | 37 | * @short container for events. |
38 | */ | 38 | */ |
39 | class OEvent : public OPimRecord { | 39 | class OEvent : public OPimRecord { |
40 | public: | 40 | public: |
41 | typedef QValueList<OEvent> ValueList; | 41 | typedef QValueList<OEvent> ValueList; |
42 | /** | 42 | /** |
43 | * RecordFields contain possible attributes | 43 | * RecordFields contain possible attributes |
44 | */ | 44 | */ |
45 | enum RecordFields { | 45 | enum RecordFields { |
46 | Uid = Qtopia::UID_ID, | 46 | Uid = Qtopia::UID_ID, |
47 | Category = Qtopia::CATEGORY_ID, | 47 | Category = Qtopia::CATEGORY_ID, |
48 | Description, | 48 | Description, |
49 | Location, | 49 | Location, |
50 | Alarm, | 50 | Alarm, |
51 | Reminder, | 51 | Reminder, |
52 | Recurrence, | 52 | Recurrence, |
53 | Note, | 53 | Note, |
54 | Created, | 54 | Created, |
55 | StartDate, | 55 | StartDate, |
56 | EndDate, | 56 | EndDate, |
57 | AllDay, | 57 | AllDay, |
58 | TimeZone | 58 | TimeZone |
59 | }; | 59 | }; |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * Start with an Empty OEvent. UID == 0 means that it is empty | 62 | * Start with an Empty OEvent. UID == 0 means that it is empty |
63 | */ | 63 | */ |
64 | OEvent(int uid = 0); | 64 | OEvent(int uid = 0); |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * copy c'tor | 67 | * copy c'tor |
68 | */ | 68 | */ |
69 | OEvent( const OEvent& ); | 69 | OEvent( const OEvent& ); |
70 | ~OEvent(); | 70 | ~OEvent(); |
71 | OEvent &operator=( const OEvent& ); | 71 | OEvent &operator=( const OEvent& ); |
72 | 72 | ||
73 | QString description()const; | 73 | QString description()const; |
74 | void setDescription( const QString& description ); | 74 | void setDescription( const QString& description ); |
75 | 75 | ||
76 | QString location()const; | 76 | QString location()const; |
77 | void setLocation( const QString& loc ); | 77 | void setLocation( const QString& loc ); |
78 | 78 | ||
79 | bool hasNotifiers()const; | 79 | bool hasNotifiers()const; |
80 | OPimNotifyManager ¬ifiers()const; | 80 | OPimNotifyManager ¬ifiers()const; |
81 | 81 | ||
82 | ORecur recurrence()const; | 82 | ORecur recurrence()const; |
83 | void setRecurrence( const ORecur& ); | 83 | void setRecurrence( const ORecur& ); |
84 | bool hasRecurrence()const; | 84 | bool hasRecurrence()const; |
85 | 85 | ||
86 | QString note()const; | 86 | QString note()const; |
87 | void setNote( const QString& note ); | 87 | void setNote( const QString& note ); |
88 | 88 | ||
89 | 89 | ||
90 | QDateTime createdDateTime()const; | 90 | QDateTime createdDateTime()const; |
91 | void setCreatedDateTime( const QDateTime& dt); | 91 | void setCreatedDateTime( const QDateTime& dt); |
92 | 92 | ||
93 | /** set the date to dt. dt is the QDateTime in localtime */ | 93 | /** set the date to dt. dt is the QDateTime in localtime */ |
94 | void setStartDateTime( const QDateTime& ); | 94 | void setStartDateTime( const QDateTime& ); |
95 | /** returns the datetime in the local timeZone */ | 95 | /** returns the datetime in the local timeZone */ |
96 | QDateTime startDateTime()const; | 96 | QDateTime startDateTime()const; |
97 | 97 | ||
98 | /** returns the start datetime in the current zone */ | 98 | /** returns the start datetime in the current zone */ |
99 | QDateTime startDateTimeInZone()const; | 99 | QDateTime startDateTimeInZone()const; |
100 | 100 | ||
101 | /** in current timezone */ | 101 | /** in current timezone */ |
102 | void setEndDateTime( const QDateTime& ); | 102 | void setEndDateTime( const QDateTime& ); |
103 | /** in current timezone */ | 103 | /** in current timezone */ |
104 | QDateTime endDateTime()const; | 104 | QDateTime endDateTime()const; |
105 | QDateTime endDateTimeInZone()const; | 105 | QDateTime endDateTimeInZone()const; |
106 | 106 | ||
107 | bool isMultipleDay()const; | 107 | bool isMultipleDay()const; |
108 | bool isAllDay()const; | 108 | bool isAllDay()const; |
109 | void setAllDay( bool isAllDay ); | 109 | void setAllDay( bool isAllDay ); |
110 | 110 | ||
111 | /* pin this event to a timezone! FIXME */ | 111 | /* pin this event to a timezone! FIXME */ |
112 | void setTimeZone( const QString& timeZone ); | 112 | void setTimeZone( const QString& timeZone ); |
113 | QString timeZone()const; | 113 | QString timeZone()const; |
114 | 114 | ||
115 | 115 | ||
116 | bool match( const QRegExp& )const; | 116 | virtual bool match( const QRegExp& )const; |
117 | 117 | ||
118 | /** For exception to recurrence here is a list of children... */ | 118 | /** For exception to recurrence here is a list of children... */ |
119 | QArray<int> children()const; | 119 | QArray<int> children()const; |
120 | void setChildren( const QArray<int>& ); | 120 | void setChildren( const QArray<int>& ); |
121 | void addChild( int uid ); | 121 | void addChild( int uid ); |
122 | void removeChild( int uid ); | 122 | void removeChild( int uid ); |
123 | 123 | ||
124 | /** return the parent OEvent */ | 124 | /** return the parent OEvent */ |
125 | int parent()const; | 125 | int parent()const; |
126 | void setParent( int uid ); | 126 | void setParent( int uid ); |
127 | 127 | ||
128 | 128 | ||
129 | /* needed reimp */ | 129 | /* needed reimp */ |
130 | QString toRichText()const; | 130 | QString toRichText()const; |
131 | QString toShortText()const; | 131 | QString toShortText()const; |
132 | QString type()const; | 132 | QString type()const; |
133 | 133 | ||
134 | QMap<int, QString> toMap()const; | 134 | QMap<int, QString> toMap()const; |
135 | QMap<QString, QString> toExtraMap()const; | 135 | QMap<QString, QString> toExtraMap()const; |
136 | QString recordField(int )const; | 136 | QString recordField(int )const; |
137 | 137 | ||
138 | static int rtti(); | 138 | static int rtti(); |
139 | 139 | ||
140 | bool loadFromStream( QDataStream& ); | 140 | bool loadFromStream( QDataStream& ); |
141 | bool saveToStream( QDataStream& )const; | 141 | bool saveToStream( QDataStream& )const; |
142 | 142 | ||
143 | /* bool operator==( const OEvent& ); | 143 | /* bool operator==( const OEvent& ); |
144 | bool operator!=( const OEvent& ); | 144 | bool operator!=( const OEvent& ); |
145 | bool operator<( const OEvent& ); | 145 | bool operator<( const OEvent& ); |
146 | bool operator<=( const OEvent& ); | 146 | bool operator<=( const OEvent& ); |
147 | bool operator>( const OEvent& ); | 147 | bool operator>( const OEvent& ); |
148 | bool operator>=(const OEvent& ); | 148 | bool operator>=(const OEvent& ); |
149 | */ | 149 | */ |
150 | private: | 150 | private: |
151 | inline void changeOrModify(); | 151 | inline void changeOrModify(); |
152 | void deref(); | 152 | void deref(); |
153 | struct Data; | 153 | struct Data; |
154 | Data* data; | 154 | Data* data; |
155 | class Private; | 155 | class Private; |
156 | Private* priv; | 156 | Private* priv; |
157 | 157 | ||
158 | }; | 158 | }; |
159 | 159 | ||
160 | /** | 160 | /** |
161 | * AN Event can span through multiple days. We split up a multiday eve | 161 | * AN Event can span through multiple days. We split up a multiday eve |
162 | */ | 162 | */ |
163 | class OEffectiveEvent { | 163 | class OEffectiveEvent { |
164 | public: | 164 | public: |
165 | typedef QValueList<OEffectiveEvent> ValueList; | 165 | typedef QValueList<OEffectiveEvent> ValueList; |
166 | enum Position { MidWay, Start, End, StartEnd }; | 166 | enum Position { MidWay, Start, End, StartEnd }; |
167 | // If we calculate the effective event of a multi-day event | 167 | // If we calculate the effective event of a multi-day event |
168 | // we have to figure out whether we are at the first day, | 168 | // we have to figure out whether we are at the first day, |
169 | // at the end, or anywhere else ("middle"). This is important | 169 | // at the end, or anywhere else ("middle"). This is important |
170 | // for the start/end times (00:00/23:59) | 170 | // for the start/end times (00:00/23:59) |
171 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- | 171 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- |
172 | // day event | 172 | // day event |
173 | // Start: start time -> 23:59 | 173 | // Start: start time -> 23:59 |
174 | // End: 00:00 -> end time | 174 | // End: 00:00 -> end time |
175 | // Start | End == StartEnd: for single-day events (default) | 175 | // Start | End == StartEnd: for single-day events (default) |
176 | // here we draw start time -> end time | 176 | // here we draw start time -> end time |
177 | OEffectiveEvent(); | 177 | OEffectiveEvent(); |
178 | OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd ); | 178 | OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd ); |
179 | OEffectiveEvent( const OEffectiveEvent& ); | 179 | OEffectiveEvent( const OEffectiveEvent& ); |
180 | OEffectiveEvent &operator=(const OEffectiveEvent& ); | 180 | OEffectiveEvent &operator=(const OEffectiveEvent& ); |
181 | ~OEffectiveEvent(); | 181 | ~OEffectiveEvent(); |
182 | 182 | ||
183 | void setStartTime( const QTime& ); | 183 | void setStartTime( const QTime& ); |
184 | void setEndTime( const QTime& ); | 184 | void setEndTime( const QTime& ); |
185 | void setEvent( const OEvent& ); | 185 | void setEvent( const OEvent& ); |
186 | void setDate( const QDate& ); | 186 | void setDate( const QDate& ); |
187 | 187 | ||
188 | void setEffectiveDates( const QDate& from, const QDate& to ); | 188 | void setEffectiveDates( const QDate& from, const QDate& to ); |
189 | 189 | ||
190 | QString description()const; | 190 | QString description()const; |
191 | QString location()const; | 191 | QString location()const; |
192 | QString note()const; | 192 | QString note()const; |
193 | OEvent event()const; | 193 | OEvent event()const; |
194 | QTime startTime()const; | 194 | QTime startTime()const; |
195 | QTime endTime()const; | 195 | QTime endTime()const; |
196 | QDate date()const; | 196 | QDate date()const; |
197 | 197 | ||
198 | /* return the length in hours */ | 198 | /* return the length in hours */ |
199 | int length()const; | 199 | int length()const; |
200 | int size()const; | 200 | int size()const; |
201 | 201 | ||
202 | QDate startDate()const; | 202 | QDate startDate()const; |
203 | QDate endDate()const; | 203 | QDate endDate()const; |
204 | 204 | ||
205 | bool operator<( const OEffectiveEvent &e ) const; | 205 | bool operator<( const OEffectiveEvent &e ) const; |
206 | bool operator<=( const OEffectiveEvent &e ) const; | 206 | bool operator<=( const OEffectiveEvent &e ) const; |
207 | bool operator==( const OEffectiveEvent &e ) const; | 207 | bool operator==( const OEffectiveEvent &e ) const; |
208 | bool operator!=( const OEffectiveEvent &e ) const; | 208 | bool operator!=( const OEffectiveEvent &e ) const; |
209 | bool operator>( const OEffectiveEvent &e ) const; | 209 | bool operator>( const OEffectiveEvent &e ) const; |
210 | bool operator>= ( const OEffectiveEvent &e ) const; | 210 | bool operator>= ( const OEffectiveEvent &e ) const; |
211 | 211 | ||
212 | private: | 212 | private: |
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h index a58d9aa..0e7c73f 100644 --- a/libopie2/opiepim/otodo.h +++ b/libopie2/opiepim/otodo.h | |||
@@ -165,125 +165,125 @@ public: | |||
165 | /** | 165 | /** |
166 | * A small summary of the todo | 166 | * A small summary of the todo |
167 | */ | 167 | */ |
168 | QString summary() const; | 168 | QString summary() const; |
169 | 169 | ||
170 | /** | 170 | /** |
171 | * @reimplemented | 171 | * @reimplemented |
172 | * Return this todoevent in a RichText formatted QString | 172 | * Return this todoevent in a RichText formatted QString |
173 | */ | 173 | */ |
174 | QString toRichText() const; | 174 | QString toRichText() const; |
175 | 175 | ||
176 | bool hasNotifiers()const; | 176 | bool hasNotifiers()const; |
177 | /* | 177 | /* |
178 | * check if the sharing is still fine!! -zecke | 178 | * check if the sharing is still fine!! -zecke |
179 | */ | 179 | */ |
180 | /** | 180 | /** |
181 | * return a reference to our notifiers... | 181 | * return a reference to our notifiers... |
182 | */ | 182 | */ |
183 | OPimNotifyManager ¬ifiers(); | 183 | OPimNotifyManager ¬ifiers(); |
184 | 184 | ||
185 | /** | 185 | /** |
186 | * reimplementations | 186 | * reimplementations |
187 | */ | 187 | */ |
188 | QString type()const; | 188 | QString type()const; |
189 | QString toShortText()const; | 189 | QString toShortText()const; |
190 | QMap<QString, QString> toExtraMap()const; | 190 | QMap<QString, QString> toExtraMap()const; |
191 | QString recordField(int id )const; | 191 | QString recordField(int id )const; |
192 | 192 | ||
193 | /** | 193 | /** |
194 | * toMap puts all data into the map. int relates | 194 | * toMap puts all data into the map. int relates |
195 | * to ToDoEvent RecordFields enum | 195 | * to ToDoEvent RecordFields enum |
196 | */ | 196 | */ |
197 | QMap<int, QString> toMap()const; | 197 | QMap<int, QString> toMap()const; |
198 | 198 | ||
199 | /** | 199 | /** |
200 | * Set if this Todo is completed | 200 | * Set if this Todo is completed |
201 | */ | 201 | */ |
202 | void setCompleted(bool completed ); | 202 | void setCompleted(bool completed ); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | * set if this todo got an end data | 205 | * set if this todo got an end data |
206 | */ | 206 | */ |
207 | void setHasDueDate( bool hasDate ); | 207 | void setHasDueDate( bool hasDate ); |
208 | // FIXME we do not have these for start, completed | 208 | // FIXME we do not have these for start, completed |
209 | // cause we'll use the isNull() of QDate for figuring | 209 | // cause we'll use the isNull() of QDate for figuring |
210 | // out if it's has a date... | 210 | // out if it's has a date... |
211 | // decide what to do here? -zecke | 211 | // decide what to do here? -zecke |
212 | 212 | ||
213 | /** | 213 | /** |
214 | * Set the priority of the Todo | 214 | * Set the priority of the Todo |
215 | */ | 215 | */ |
216 | void setPriority(int priority ); | 216 | void setPriority(int priority ); |
217 | 217 | ||
218 | /** | 218 | /** |
219 | * Set the progress. | 219 | * Set the progress. |
220 | */ | 220 | */ |
221 | void setProgress( ushort progress ); | 221 | void setProgress( ushort progress ); |
222 | 222 | ||
223 | /** | 223 | /** |
224 | * set the end date | 224 | * set the end date |
225 | */ | 225 | */ |
226 | void setDueDate( const QDate& date ); | 226 | void setDueDate( const QDate& date ); |
227 | 227 | ||
228 | /** | 228 | /** |
229 | * set the start date | 229 | * set the start date |
230 | */ | 230 | */ |
231 | void setStartDate( const QDate& date ); | 231 | void setStartDate( const QDate& date ); |
232 | 232 | ||
233 | /** | 233 | /** |
234 | * set the completed date | 234 | * set the completed date |
235 | */ | 235 | */ |
236 | void setCompletedDate( const QDate& date ); | 236 | void setCompletedDate( const QDate& date ); |
237 | 237 | ||
238 | void setRecurrence( const ORecur& ); | 238 | void setRecurrence( const ORecur& ); |
239 | /** | 239 | /** |
240 | * set the alarm time | 240 | * set the alarm time |
241 | */ | 241 | */ |
242 | void setAlarmDateTime ( const QDateTime& alarm ); | 242 | void setAlarmDateTime ( const QDateTime& alarm ); |
243 | 243 | ||
244 | void setDescription(const QString& ); | 244 | void setDescription(const QString& ); |
245 | void setSummary(const QString& ); | 245 | void setSummary(const QString& ); |
246 | 246 | ||
247 | /** | 247 | /** |
248 | * set the state of a Todo | 248 | * set the state of a Todo |
249 | * @param state State what the todo should take | 249 | * @param state State what the todo should take |
250 | */ | 250 | */ |
251 | void setState( const OPimState& state); | 251 | void setState( const OPimState& state); |
252 | 252 | ||
253 | /** | 253 | /** |
254 | * set the Maintainer Mode | 254 | * set the Maintainer Mode |
255 | */ | 255 | */ |
256 | void setMaintainer( const OPimMaintainer& ); | 256 | void setMaintainer( const OPimMaintainer& ); |
257 | 257 | ||
258 | bool isOverdue(); | 258 | bool isOverdue(); |
259 | 259 | ||
260 | 260 | ||
261 | bool match( const QRegExp &r )const; | 261 | virtual bool match( const QRegExp &r )const; |
262 | 262 | ||
263 | bool operator<(const OTodo &toDoEvent )const; | 263 | bool operator<(const OTodo &toDoEvent )const; |
264 | bool operator<=(const OTodo &toDoEvent )const; | 264 | bool operator<=(const OTodo &toDoEvent )const; |
265 | bool operator!=(const OTodo &toDoEvent )const; | 265 | bool operator!=(const OTodo &toDoEvent )const; |
266 | bool operator>(const OTodo &toDoEvent )const; | 266 | bool operator>(const OTodo &toDoEvent )const; |
267 | bool operator>=(const OTodo &toDoEvent)const; | 267 | bool operator>=(const OTodo &toDoEvent)const; |
268 | bool operator==(const OTodo &toDoEvent )const; | 268 | bool operator==(const OTodo &toDoEvent )const; |
269 | OTodo &operator=(const OTodo &toDoEvent ); | 269 | OTodo &operator=(const OTodo &toDoEvent ); |
270 | 270 | ||
271 | static int rtti(); | 271 | static int rtti(); |
272 | 272 | ||
273 | private: | 273 | private: |
274 | class OTodoPrivate; | 274 | class OTodoPrivate; |
275 | struct OTodoData; | 275 | struct OTodoData; |
276 | 276 | ||
277 | void deref(); | 277 | void deref(); |
278 | inline void changeOrModify(); | 278 | inline void changeOrModify(); |
279 | void copy( OTodoData* src, OTodoData* dest ); | 279 | void copy( OTodoData* src, OTodoData* dest ); |
280 | OTodoPrivate *d; | 280 | OTodoPrivate *d; |
281 | OTodoData *data; | 281 | OTodoData *data; |
282 | 282 | ||
283 | }; | 283 | }; |
284 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { | 284 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { |
285 | return !(*this == toDoEvent); | 285 | return !(*this == toDoEvent); |
286 | } | 286 | } |
287 | 287 | ||
288 | 288 | ||
289 | #endif | 289 | #endif |