author | zautrix <zautrix> | 2005-02-13 19:07:45 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-13 19:07:45 (UTC) |
commit | 7bd83e913399b8be68a7d37e8f02118ec9eab90e (patch) (unidiff) | |
tree | 284d1592687ea4d3e0c220fafd289a702718dee4 /libkcal | |
parent | 293271fe9e6a9061da329183f8f488d79580f7da (diff) | |
download | kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.zip kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.gz kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.bz2 |
todo fixi
-rw-r--r-- | libkcal/icalformatimpl.cpp | 2 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 16 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 12 | ||||
-rw-r--r-- | libkcal/todo.cpp | 4 |
4 files changed, 27 insertions, 7 deletions
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index bb9cb29..2e38ae3 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp | |||
@@ -829,769 +829,769 @@ Todo *ICalFormatImpl::readTodo(icalcomponent *vtodo) | |||
829 | } | 829 | } |
830 | 830 | ||
831 | p = icalcomponent_get_next_property(vtodo,ICAL_ANY_PROPERTY); | 831 | p = icalcomponent_get_next_property(vtodo,ICAL_ANY_PROPERTY); |
832 | } | 832 | } |
833 | 833 | ||
834 | return todo; | 834 | return todo; |
835 | } | 835 | } |
836 | 836 | ||
837 | Event *ICalFormatImpl::readEvent(icalcomponent *vevent) | 837 | Event *ICalFormatImpl::readEvent(icalcomponent *vevent) |
838 | { | 838 | { |
839 | Event *event = new Event; | 839 | Event *event = new Event; |
840 | event->setFloats(false); | 840 | event->setFloats(false); |
841 | 841 | ||
842 | readIncidence(vevent,event); | 842 | readIncidence(vevent,event); |
843 | 843 | ||
844 | icalproperty *p = icalcomponent_get_first_property(vevent,ICAL_ANY_PROPERTY); | 844 | icalproperty *p = icalcomponent_get_first_property(vevent,ICAL_ANY_PROPERTY); |
845 | 845 | ||
846 | // int intvalue; | 846 | // int intvalue; |
847 | icaltimetype icaltime; | 847 | icaltimetype icaltime; |
848 | 848 | ||
849 | QStringList categories; | 849 | QStringList categories; |
850 | QString transparency; | 850 | QString transparency; |
851 | 851 | ||
852 | while (p) { | 852 | while (p) { |
853 | icalproperty_kind kind = icalproperty_isa(p); | 853 | icalproperty_kind kind = icalproperty_isa(p); |
854 | switch (kind) { | 854 | switch (kind) { |
855 | 855 | ||
856 | case ICAL_DTEND_PROPERTY: // start date and time | 856 | case ICAL_DTEND_PROPERTY: // start date and time |
857 | icaltime = icalproperty_get_dtend(p); | 857 | icaltime = icalproperty_get_dtend(p); |
858 | if (icaltime.is_date) { | 858 | if (icaltime.is_date) { |
859 | event->setFloats( true ); | 859 | event->setFloats( true ); |
860 | // End date is non-inclusive | 860 | // End date is non-inclusive |
861 | QDate endDate = readICalDate( icaltime ).addDays( -1 ); | 861 | QDate endDate = readICalDate( icaltime ).addDays( -1 ); |
862 | mCompat->fixFloatingEnd( endDate ); | 862 | mCompat->fixFloatingEnd( endDate ); |
863 | if ( endDate < event->dtStart().date() ) { | 863 | if ( endDate < event->dtStart().date() ) { |
864 | endDate = event->dtStart().date(); | 864 | endDate = event->dtStart().date(); |
865 | } | 865 | } |
866 | event->setDtEnd( QDateTime( endDate, QTime( 0, 0, 0 ) ) ); | 866 | event->setDtEnd( QDateTime( endDate, QTime( 0, 0, 0 ) ) ); |
867 | } else { | 867 | } else { |
868 | event->setDtEnd(readICalDateTime(icaltime)); | 868 | event->setDtEnd(readICalDateTime(icaltime)); |
869 | } | 869 | } |
870 | break; | 870 | break; |
871 | 871 | ||
872 | // TODO: | 872 | // TODO: |
873 | // at this point, there should be at least a start or end time. | 873 | // at this point, there should be at least a start or end time. |
874 | // fix up for events that take up no time but have a time associated | 874 | // fix up for events that take up no time but have a time associated |
875 | #if 0 | 875 | #if 0 |
876 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) | 876 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) |
877 | anEvent->setDtStart(anEvent->dtEnd()); | 877 | anEvent->setDtStart(anEvent->dtEnd()); |
878 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) | 878 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) |
879 | anEvent->setDtEnd(anEvent->dtStart()); | 879 | anEvent->setDtEnd(anEvent->dtStart()); |
880 | #endif | 880 | #endif |
881 | 881 | ||
882 | // TODO: exdates | 882 | // TODO: exdates |
883 | #if 0 | 883 | #if 0 |
884 | // recurrence exceptions | 884 | // recurrence exceptions |
885 | if ((vo = isAPropertyOf(vevent, VCExDateProp)) != 0) { | 885 | if ((vo = isAPropertyOf(vevent, VCExDateProp)) != 0) { |
886 | anEvent->setExDates(s = fakeCString(vObjectUStringZValue(vo))); | 886 | anEvent->setExDates(s = fakeCString(vObjectUStringZValue(vo))); |
887 | deleteStr(s); | 887 | deleteStr(s); |
888 | } | 888 | } |
889 | #endif | 889 | #endif |
890 | 890 | ||
891 | #if 0 | 891 | #if 0 |
892 | // secrecy | 892 | // secrecy |
893 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { | 893 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { |
894 | anEvent->setSecrecy(s = fakeCString(vObjectUStringZValue(vo))); | 894 | anEvent->setSecrecy(s = fakeCString(vObjectUStringZValue(vo))); |
895 | deleteStr(s); | 895 | deleteStr(s); |
896 | } | 896 | } |
897 | else | 897 | else |
898 | anEvent->setSecrecy("PUBLIC"); | 898 | anEvent->setSecrecy("PUBLIC"); |
899 | 899 | ||
900 | // attachments | 900 | // attachments |
901 | tmpStrList.clear(); | 901 | tmpStrList.clear(); |
902 | initPropIterator(&voi, vevent); | 902 | initPropIterator(&voi, vevent); |
903 | while (moreIteration(&voi)) { | 903 | while (moreIteration(&voi)) { |
904 | vo = nextVObject(&voi); | 904 | vo = nextVObject(&voi); |
905 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { | 905 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { |
906 | tmpStrList.append(s = fakeCString(vObjectUStringZValue(vo))); | 906 | tmpStrList.append(s = fakeCString(vObjectUStringZValue(vo))); |
907 | deleteStr(s); | 907 | deleteStr(s); |
908 | } | 908 | } |
909 | } | 909 | } |
910 | anEvent->setAttachments(tmpStrList); | 910 | anEvent->setAttachments(tmpStrList); |
911 | 911 | ||
912 | // resources | 912 | // resources |
913 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { | 913 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { |
914 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); | 914 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); |
915 | deleteStr(s); | 915 | deleteStr(s); |
916 | tmpStrList.clear(); | 916 | tmpStrList.clear(); |
917 | index1 = 0; | 917 | index1 = 0; |
918 | index2 = 0; | 918 | index2 = 0; |
919 | QString resource; | 919 | QString resource; |
920 | while ((index2 = resources.find(';', index1)) != -1) { | 920 | while ((index2 = resources.find(';', index1)) != -1) { |
921 | resource = resources.mid(index1, (index2 - index1)); | 921 | resource = resources.mid(index1, (index2 - index1)); |
922 | tmpStrList.append(resource); | 922 | tmpStrList.append(resource); |
923 | index1 = index2; | 923 | index1 = index2; |
924 | } | 924 | } |
925 | anEvent->setResources(tmpStrList); | 925 | anEvent->setResources(tmpStrList); |
926 | } | 926 | } |
927 | #endif | 927 | #endif |
928 | 928 | ||
929 | case ICAL_RELATEDTO_PROPERTY: // releated event (parent) | 929 | case ICAL_RELATEDTO_PROPERTY: // releated event (parent) |
930 | event->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); | 930 | event->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); |
931 | mEventsRelate.append(event); | 931 | mEventsRelate.append(event); |
932 | break; | 932 | break; |
933 | 933 | ||
934 | case ICAL_TRANSP_PROPERTY: // Transparency | 934 | case ICAL_TRANSP_PROPERTY: // Transparency |
935 | if(icalproperty_get_transp(p) == ICAL_TRANSP_TRANSPARENT ) | 935 | if(icalproperty_get_transp(p) == ICAL_TRANSP_TRANSPARENT ) |
936 | event->setTransparency( Event::Transparent ); | 936 | event->setTransparency( Event::Transparent ); |
937 | else | 937 | else |
938 | event->setTransparency( Event::Opaque ); | 938 | event->setTransparency( Event::Opaque ); |
939 | break; | 939 | break; |
940 | 940 | ||
941 | default: | 941 | default: |
942 | // kdDebug(5800) << "ICALFormat::readEvent(): Unknown property: " << kind | 942 | // kdDebug(5800) << "ICALFormat::readEvent(): Unknown property: " << kind |
943 | // << endl; | 943 | // << endl; |
944 | break; | 944 | break; |
945 | } | 945 | } |
946 | 946 | ||
947 | p = icalcomponent_get_next_property(vevent,ICAL_ANY_PROPERTY); | 947 | p = icalcomponent_get_next_property(vevent,ICAL_ANY_PROPERTY); |
948 | } | 948 | } |
949 | 949 | ||
950 | QString msade = event->nonKDECustomProperty("X-MICROSOFT-CDO-ALLDAYEVENT"); | 950 | QString msade = event->nonKDECustomProperty("X-MICROSOFT-CDO-ALLDAYEVENT"); |
951 | if (!msade.isNull()) { | 951 | if (!msade.isNull()) { |
952 | bool floats = (msade == QString::fromLatin1("TRUE")); | 952 | bool floats = (msade == QString::fromLatin1("TRUE")); |
953 | kdDebug(5800) << "ICALFormat::readEvent(): all day event: " << floats << endl; | 953 | kdDebug(5800) << "ICALFormat::readEvent(): all day event: " << floats << endl; |
954 | event->setFloats(floats); | 954 | event->setFloats(floats); |
955 | if (floats) { | 955 | if (floats) { |
956 | QDateTime endDate = event->dtEnd(); | 956 | QDateTime endDate = event->dtEnd(); |
957 | event->setDtEnd(endDate.addDays(-1)); | 957 | event->setDtEnd(endDate.addDays(-1)); |
958 | } | 958 | } |
959 | } | 959 | } |
960 | 960 | ||
961 | // some stupid vCal exporters ignore the standard and use Description | 961 | // some stupid vCal exporters ignore the standard and use Description |
962 | // instead of Summary for the default field. Correct for this. | 962 | // instead of Summary for the default field. Correct for this. |
963 | if (event->summary().isEmpty() && | 963 | if (event->summary().isEmpty() && |
964 | !(event->description().isEmpty())) { | 964 | !(event->description().isEmpty())) { |
965 | QString tmpStr = event->description().simplifyWhiteSpace(); | 965 | QString tmpStr = event->description().simplifyWhiteSpace(); |
966 | event->setDescription(""); | 966 | event->setDescription(""); |
967 | event->setSummary(tmpStr); | 967 | event->setSummary(tmpStr); |
968 | } | 968 | } |
969 | 969 | ||
970 | return event; | 970 | return event; |
971 | } | 971 | } |
972 | 972 | ||
973 | FreeBusy *ICalFormatImpl::readFreeBusy(icalcomponent *vfreebusy) | 973 | FreeBusy *ICalFormatImpl::readFreeBusy(icalcomponent *vfreebusy) |
974 | { | 974 | { |
975 | FreeBusy *freebusy = new FreeBusy; | 975 | FreeBusy *freebusy = new FreeBusy; |
976 | 976 | ||
977 | readIncidenceBase(vfreebusy,freebusy); | 977 | readIncidenceBase(vfreebusy,freebusy); |
978 | 978 | ||
979 | icalproperty *p = icalcomponent_get_first_property(vfreebusy,ICAL_ANY_PROPERTY); | 979 | icalproperty *p = icalcomponent_get_first_property(vfreebusy,ICAL_ANY_PROPERTY); |
980 | 980 | ||
981 | icaltimetype icaltime; | 981 | icaltimetype icaltime; |
982 | icalperiodtype icalperiod; | 982 | icalperiodtype icalperiod; |
983 | QDateTime period_start, period_end; | 983 | QDateTime period_start, period_end; |
984 | 984 | ||
985 | while (p) { | 985 | while (p) { |
986 | icalproperty_kind kind = icalproperty_isa(p); | 986 | icalproperty_kind kind = icalproperty_isa(p); |
987 | switch (kind) { | 987 | switch (kind) { |
988 | 988 | ||
989 | case ICAL_DTSTART_PROPERTY: // start date and time | 989 | case ICAL_DTSTART_PROPERTY: // start date and time |
990 | icaltime = icalproperty_get_dtstart(p); | 990 | icaltime = icalproperty_get_dtstart(p); |
991 | freebusy->setDtStart(readICalDateTime(icaltime)); | 991 | freebusy->setDtStart(readICalDateTime(icaltime)); |
992 | break; | 992 | break; |
993 | 993 | ||
994 | case ICAL_DTEND_PROPERTY: // start End Date and Time | 994 | case ICAL_DTEND_PROPERTY: // start End Date and Time |
995 | icaltime = icalproperty_get_dtend(p); | 995 | icaltime = icalproperty_get_dtend(p); |
996 | freebusy->setDtEnd(readICalDateTime(icaltime)); | 996 | freebusy->setDtEnd(readICalDateTime(icaltime)); |
997 | break; | 997 | break; |
998 | 998 | ||
999 | case ICAL_FREEBUSY_PROPERTY: //Any FreeBusy Times | 999 | case ICAL_FREEBUSY_PROPERTY: //Any FreeBusy Times |
1000 | icalperiod = icalproperty_get_freebusy(p); | 1000 | icalperiod = icalproperty_get_freebusy(p); |
1001 | period_start = readICalDateTime(icalperiod.start); | 1001 | period_start = readICalDateTime(icalperiod.start); |
1002 | period_end = readICalDateTime(icalperiod.end); | 1002 | period_end = readICalDateTime(icalperiod.end); |
1003 | freebusy->addPeriod(period_start, period_end); | 1003 | freebusy->addPeriod(period_start, period_end); |
1004 | break; | 1004 | break; |
1005 | 1005 | ||
1006 | default: | 1006 | default: |
1007 | kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind | 1007 | kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind |
1008 | << endl; | 1008 | << endl; |
1009 | break; | 1009 | break; |
1010 | } | 1010 | } |
1011 | p = icalcomponent_get_next_property(vfreebusy,ICAL_ANY_PROPERTY); | 1011 | p = icalcomponent_get_next_property(vfreebusy,ICAL_ANY_PROPERTY); |
1012 | } | 1012 | } |
1013 | 1013 | ||
1014 | return freebusy; | 1014 | return freebusy; |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | Journal *ICalFormatImpl::readJournal(icalcomponent *vjournal) | 1017 | Journal *ICalFormatImpl::readJournal(icalcomponent *vjournal) |
1018 | { | 1018 | { |
1019 | Journal *journal = new Journal; | 1019 | Journal *journal = new Journal; |
1020 | 1020 | ||
1021 | readIncidence(vjournal,journal); | 1021 | readIncidence(vjournal,journal); |
1022 | 1022 | ||
1023 | return journal; | 1023 | return journal; |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | Attendee *ICalFormatImpl::readAttendee(icalproperty *attendee) | 1026 | Attendee *ICalFormatImpl::readAttendee(icalproperty *attendee) |
1027 | { | 1027 | { |
1028 | icalparameter *p = 0; | 1028 | icalparameter *p = 0; |
1029 | 1029 | ||
1030 | QString email = QString::fromUtf8(icalproperty_get_attendee(attendee)); | 1030 | QString email = QString::fromUtf8(icalproperty_get_attendee(attendee)); |
1031 | 1031 | ||
1032 | QString name; | 1032 | QString name; |
1033 | QString uid = QString::null; | 1033 | QString uid = QString::null; |
1034 | p = icalproperty_get_first_parameter(attendee,ICAL_CN_PARAMETER); | 1034 | p = icalproperty_get_first_parameter(attendee,ICAL_CN_PARAMETER); |
1035 | if (p) { | 1035 | if (p) { |
1036 | name = QString::fromUtf8(icalparameter_get_cn(p)); | 1036 | name = QString::fromUtf8(icalparameter_get_cn(p)); |
1037 | } else { | 1037 | } else { |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | bool rsvp=false; | 1040 | bool rsvp=false; |
1041 | p = icalproperty_get_first_parameter(attendee,ICAL_RSVP_PARAMETER); | 1041 | p = icalproperty_get_first_parameter(attendee,ICAL_RSVP_PARAMETER); |
1042 | if (p) { | 1042 | if (p) { |
1043 | icalparameter_rsvp rsvpParameter = icalparameter_get_rsvp(p); | 1043 | icalparameter_rsvp rsvpParameter = icalparameter_get_rsvp(p); |
1044 | if (rsvpParameter == ICAL_RSVP_TRUE) rsvp = true; | 1044 | if (rsvpParameter == ICAL_RSVP_TRUE) rsvp = true; |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | Attendee::PartStat status = Attendee::NeedsAction; | 1047 | Attendee::PartStat status = Attendee::NeedsAction; |
1048 | p = icalproperty_get_first_parameter(attendee,ICAL_PARTSTAT_PARAMETER); | 1048 | p = icalproperty_get_first_parameter(attendee,ICAL_PARTSTAT_PARAMETER); |
1049 | if (p) { | 1049 | if (p) { |
1050 | icalparameter_partstat partStatParameter = icalparameter_get_partstat(p); | 1050 | icalparameter_partstat partStatParameter = icalparameter_get_partstat(p); |
1051 | switch(partStatParameter) { | 1051 | switch(partStatParameter) { |
1052 | default: | 1052 | default: |
1053 | case ICAL_PARTSTAT_NEEDSACTION: | 1053 | case ICAL_PARTSTAT_NEEDSACTION: |
1054 | status = Attendee::NeedsAction; | 1054 | status = Attendee::NeedsAction; |
1055 | break; | 1055 | break; |
1056 | case ICAL_PARTSTAT_ACCEPTED: | 1056 | case ICAL_PARTSTAT_ACCEPTED: |
1057 | status = Attendee::Accepted; | 1057 | status = Attendee::Accepted; |
1058 | break; | 1058 | break; |
1059 | case ICAL_PARTSTAT_DECLINED: | 1059 | case ICAL_PARTSTAT_DECLINED: |
1060 | status = Attendee::Declined; | 1060 | status = Attendee::Declined; |
1061 | break; | 1061 | break; |
1062 | case ICAL_PARTSTAT_TENTATIVE: | 1062 | case ICAL_PARTSTAT_TENTATIVE: |
1063 | status = Attendee::Tentative; | 1063 | status = Attendee::Tentative; |
1064 | break; | 1064 | break; |
1065 | case ICAL_PARTSTAT_DELEGATED: | 1065 | case ICAL_PARTSTAT_DELEGATED: |
1066 | status = Attendee::Delegated; | 1066 | status = Attendee::Delegated; |
1067 | break; | 1067 | break; |
1068 | case ICAL_PARTSTAT_COMPLETED: | 1068 | case ICAL_PARTSTAT_COMPLETED: |
1069 | status = Attendee::Completed; | 1069 | status = Attendee::Completed; |
1070 | break; | 1070 | break; |
1071 | case ICAL_PARTSTAT_INPROCESS: | 1071 | case ICAL_PARTSTAT_INPROCESS: |
1072 | status = Attendee::InProcess; | 1072 | status = Attendee::InProcess; |
1073 | break; | 1073 | break; |
1074 | } | 1074 | } |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | Attendee::Role role = Attendee::ReqParticipant; | 1077 | Attendee::Role role = Attendee::ReqParticipant; |
1078 | p = icalproperty_get_first_parameter(attendee,ICAL_ROLE_PARAMETER); | 1078 | p = icalproperty_get_first_parameter(attendee,ICAL_ROLE_PARAMETER); |
1079 | if (p) { | 1079 | if (p) { |
1080 | icalparameter_role roleParameter = icalparameter_get_role(p); | 1080 | icalparameter_role roleParameter = icalparameter_get_role(p); |
1081 | switch(roleParameter) { | 1081 | switch(roleParameter) { |
1082 | case ICAL_ROLE_CHAIR: | 1082 | case ICAL_ROLE_CHAIR: |
1083 | role = Attendee::Chair; | 1083 | role = Attendee::Chair; |
1084 | break; | 1084 | break; |
1085 | default: | 1085 | default: |
1086 | case ICAL_ROLE_REQPARTICIPANT: | 1086 | case ICAL_ROLE_REQPARTICIPANT: |
1087 | role = Attendee::ReqParticipant; | 1087 | role = Attendee::ReqParticipant; |
1088 | break; | 1088 | break; |
1089 | case ICAL_ROLE_OPTPARTICIPANT: | 1089 | case ICAL_ROLE_OPTPARTICIPANT: |
1090 | role = Attendee::OptParticipant; | 1090 | role = Attendee::OptParticipant; |
1091 | break; | 1091 | break; |
1092 | case ICAL_ROLE_NONPARTICIPANT: | 1092 | case ICAL_ROLE_NONPARTICIPANT: |
1093 | role = Attendee::NonParticipant; | 1093 | role = Attendee::NonParticipant; |
1094 | break; | 1094 | break; |
1095 | } | 1095 | } |
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | p = icalproperty_get_first_parameter(attendee,ICAL_X_PARAMETER); | 1098 | p = icalproperty_get_first_parameter(attendee,ICAL_X_PARAMETER); |
1099 | uid = icalparameter_get_xvalue(p); | 1099 | uid = icalparameter_get_xvalue(p); |
1100 | // This should be added, but there seems to be a libical bug here. | 1100 | // This should be added, but there seems to be a libical bug here. |
1101 | /*while (p) { | 1101 | /*while (p) { |
1102 | // if (icalparameter_get_xname(p) == "X-UID") { | 1102 | // if (icalparameter_get_xname(p) == "X-UID") { |
1103 | uid = icalparameter_get_xvalue(p); | 1103 | uid = icalparameter_get_xvalue(p); |
1104 | p = icalproperty_get_next_parameter(attendee,ICAL_X_PARAMETER); | 1104 | p = icalproperty_get_next_parameter(attendee,ICAL_X_PARAMETER); |
1105 | } */ | 1105 | } */ |
1106 | 1106 | ||
1107 | return new Attendee( name, email, rsvp, status, role, uid ); | 1107 | return new Attendee( name, email, rsvp, status, role, uid ); |
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) | 1110 | Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) |
1111 | { | 1111 | { |
1112 | icalattach *a = icalproperty_get_attach(attach); | 1112 | icalattach *a = icalproperty_get_attach(attach); |
1113 | icalparameter_value v = ICAL_VALUE_NONE; | 1113 | icalparameter_value v = ICAL_VALUE_NONE; |
1114 | icalparameter_encoding e = ICAL_ENCODING_NONE; | 1114 | icalparameter_encoding e = ICAL_ENCODING_NONE; |
1115 | 1115 | ||
1116 | Attachment *attachment = 0; | 1116 | Attachment *attachment = 0; |
1117 | /* | 1117 | /* |
1118 | icalparameter *vp = icalproperty_get_first_parameter(attach, ICAL_VALUE_PARAMETER); | 1118 | icalparameter *vp = icalproperty_get_first_parameter(attach, ICAL_VALUE_PARAMETER); |
1119 | if (vp) | 1119 | if (vp) |
1120 | v = icalparameter_get_value(vp); | 1120 | v = icalparameter_get_value(vp); |
1121 | 1121 | ||
1122 | icalparameter *ep = icalproperty_get_first_parameter(attach, ICAL_ENCODING_PARAMETER); | 1122 | icalparameter *ep = icalproperty_get_first_parameter(attach, ICAL_ENCODING_PARAMETER); |
1123 | if (ep) | 1123 | if (ep) |
1124 | e = icalparameter_get_encoding(ep); | 1124 | e = icalparameter_get_encoding(ep); |
1125 | */ | 1125 | */ |
1126 | int isurl = icalattach_get_is_url (a); | 1126 | int isurl = icalattach_get_is_url (a); |
1127 | if (isurl == 0) | 1127 | if (isurl == 0) |
1128 | attachment = new Attachment((const char*)icalattach_get_data(a)); | 1128 | attachment = new Attachment((const char*)icalattach_get_data(a)); |
1129 | else { | 1129 | else { |
1130 | attachment = new Attachment(QString(icalattach_get_url(a))); | 1130 | attachment = new Attachment(QString(icalattach_get_url(a))); |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER); | 1133 | icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER); |
1134 | if (p) | 1134 | if (p) |
1135 | attachment->setMimeType(QString(icalparameter_get_fmttype(p))); | 1135 | attachment->setMimeType(QString(icalparameter_get_fmttype(p))); |
1136 | 1136 | ||
1137 | return attachment; | 1137 | return attachment; |
1138 | } | 1138 | } |
1139 | #include <qtextcodec.h> | 1139 | #include <qtextcodec.h> |
1140 | void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) | 1140 | void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) |
1141 | { | 1141 | { |
1142 | readIncidenceBase(parent,incidence); | 1142 | readIncidenceBase(parent,incidence); |
1143 | 1143 | ||
1144 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); | 1144 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); |
1145 | bool readrec = false; | 1145 | bool readrec = false; |
1146 | const char *text; | 1146 | const char *text; |
1147 | int intvalue; | 1147 | int intvalue; |
1148 | icaltimetype icaltime; | 1148 | icaltimetype icaltime; |
1149 | icaldurationtype icalduration; | 1149 | icaldurationtype icalduration; |
1150 | struct icalrecurrencetype rectype; | 1150 | struct icalrecurrencetype rectype; |
1151 | QStringList categories; | 1151 | QStringList categories; |
1152 | 1152 | ||
1153 | while (p) { | 1153 | while (p) { |
1154 | icalproperty_kind kind = icalproperty_isa(p); | 1154 | icalproperty_kind kind = icalproperty_isa(p); |
1155 | switch (kind) { | 1155 | switch (kind) { |
1156 | 1156 | ||
1157 | case ICAL_CREATED_PROPERTY: | 1157 | case ICAL_CREATED_PROPERTY: |
1158 | icaltime = icalproperty_get_created(p); | 1158 | icaltime = icalproperty_get_created(p); |
1159 | incidence->setCreated(readICalDateTime(icaltime)); | 1159 | incidence->setCreated(readICalDateTime(icaltime)); |
1160 | break; | 1160 | break; |
1161 | 1161 | ||
1162 | case ICAL_SEQUENCE_PROPERTY: // sequence | 1162 | case ICAL_SEQUENCE_PROPERTY: // sequence |
1163 | intvalue = icalproperty_get_sequence(p); | 1163 | intvalue = icalproperty_get_sequence(p); |
1164 | incidence->setRevision(intvalue); | 1164 | incidence->setRevision(intvalue); |
1165 | break; | 1165 | break; |
1166 | 1166 | ||
1167 | case ICAL_LASTMODIFIED_PROPERTY: // last modification date | 1167 | case ICAL_LASTMODIFIED_PROPERTY: // last modification date |
1168 | icaltime = icalproperty_get_lastmodified(p); | 1168 | icaltime = icalproperty_get_lastmodified(p); |
1169 | incidence->setLastModified(readICalDateTime(icaltime)); | 1169 | incidence->setLastModified(readICalDateTime(icaltime)); |
1170 | break; | 1170 | break; |
1171 | 1171 | ||
1172 | case ICAL_DTSTART_PROPERTY: // start date and time | 1172 | case ICAL_DTSTART_PROPERTY: // start date and time |
1173 | icaltime = icalproperty_get_dtstart(p); | 1173 | icaltime = icalproperty_get_dtstart(p); |
1174 | if (icaltime.is_date) { | 1174 | if (icaltime.is_date) { |
1175 | incidence->setDtStart(QDateTime(readICalDate(icaltime),QTime(0,0,0))); | 1175 | incidence->setDtStart(QDateTime(readICalDate(icaltime),QTime(0,0,0))); |
1176 | incidence->setFloats(true); | 1176 | incidence->setFloats(true); |
1177 | } else { | 1177 | } else { |
1178 | incidence->setDtStart(readICalDateTime(icaltime)); | 1178 | incidence->setDtStart(readICalDateTime(icaltime)); |
1179 | } | 1179 | } |
1180 | break; | 1180 | break; |
1181 | 1181 | ||
1182 | case ICAL_DURATION_PROPERTY: // start date and time | 1182 | case ICAL_DURATION_PROPERTY: // start date and time |
1183 | icalduration = icalproperty_get_duration(p); | 1183 | icalduration = icalproperty_get_duration(p); |
1184 | incidence->setDuration(readICalDuration(icalduration)); | 1184 | incidence->setDuration(readICalDuration(icalduration)); |
1185 | break; | 1185 | break; |
1186 | 1186 | ||
1187 | case ICAL_DESCRIPTION_PROPERTY: // description | 1187 | case ICAL_DESCRIPTION_PROPERTY: // description |
1188 | text = icalproperty_get_description(p); | 1188 | text = icalproperty_get_description(p); |
1189 | incidence->setDescription(QString::fromUtf8(text)); | 1189 | incidence->setDescription(QString::fromUtf8(text)); |
1190 | break; | 1190 | break; |
1191 | 1191 | ||
1192 | case ICAL_SUMMARY_PROPERTY: // summary | 1192 | case ICAL_SUMMARY_PROPERTY: // summary |
1193 | { | 1193 | { |
1194 | text = icalproperty_get_summary(p); | 1194 | text = icalproperty_get_summary(p); |
1195 | incidence->setSummary(QString::fromUtf8(text)); | 1195 | incidence->setSummary(QString::fromUtf8(text)); |
1196 | } | 1196 | } |
1197 | break; | 1197 | break; |
1198 | case ICAL_STATUS_PROPERTY: // summary | 1198 | case ICAL_STATUS_PROPERTY: // summary |
1199 | { | 1199 | { |
1200 | if ( ICAL_STATUS_CANCELLED == icalproperty_get_status(p) ) | 1200 | if ( ICAL_STATUS_CANCELLED == icalproperty_get_status(p) ) |
1201 | incidence->setCancelled( true ); | 1201 | incidence->setCancelled( true ); |
1202 | } | 1202 | } |
1203 | break; | 1203 | break; |
1204 | 1204 | ||
1205 | case ICAL_LOCATION_PROPERTY: // location | 1205 | case ICAL_LOCATION_PROPERTY: // location |
1206 | text = icalproperty_get_location(p); | 1206 | text = icalproperty_get_location(p); |
1207 | incidence->setLocation(QString::fromUtf8(text)); | 1207 | incidence->setLocation(QString::fromUtf8(text)); |
1208 | break; | 1208 | break; |
1209 | 1209 | ||
1210 | case ICAL_RECURRENCEID_PROPERTY: | 1210 | case ICAL_RECURRENCEID_PROPERTY: |
1211 | icaltime = icalproperty_get_recurrenceid(p); | 1211 | icaltime = icalproperty_get_recurrenceid(p); |
1212 | incidence->setRecurrenceID( readICalDateTime(icaltime) ); | 1212 | incidence->setRecurrenceID( readICalDateTime(icaltime) ); |
1213 | qDebug(" RecurrenceID %s",incidence->recurrenceID().toString().latin1() ); | 1213 | //qDebug(" RecurrenceID %s",incidence->recurrenceID().toString().latin1() ); |
1214 | break; | 1214 | break; |
1215 | #if 0 | 1215 | #if 0 |
1216 | // status | 1216 | // status |
1217 | if ((vo = isAPropertyOf(vincidence, VCStatusProp)) != 0) { | 1217 | if ((vo = isAPropertyOf(vincidence, VCStatusProp)) != 0) { |
1218 | incidence->setStatus(s = fakeCString(vObjectUStringZValue(vo))); | 1218 | incidence->setStatus(s = fakeCString(vObjectUStringZValue(vo))); |
1219 | deleteStr(s); | 1219 | deleteStr(s); |
1220 | } | 1220 | } |
1221 | else | 1221 | else |
1222 | incidence->setStatus("NEEDS ACTION"); | 1222 | incidence->setStatus("NEEDS ACTION"); |
1223 | #endif | 1223 | #endif |
1224 | 1224 | ||
1225 | case ICAL_PRIORITY_PROPERTY: // priority | 1225 | case ICAL_PRIORITY_PROPERTY: // priority |
1226 | intvalue = icalproperty_get_priority(p); | 1226 | intvalue = icalproperty_get_priority(p); |
1227 | incidence->setPriority(intvalue); | 1227 | incidence->setPriority(intvalue); |
1228 | break; | 1228 | break; |
1229 | 1229 | ||
1230 | case ICAL_CATEGORIES_PROPERTY: // categories | 1230 | case ICAL_CATEGORIES_PROPERTY: // categories |
1231 | text = icalproperty_get_categories(p); | 1231 | text = icalproperty_get_categories(p); |
1232 | categories.append(QString::fromUtf8(text)); | 1232 | categories.append(QString::fromUtf8(text)); |
1233 | break; | 1233 | break; |
1234 | //******************************************* | 1234 | //******************************************* |
1235 | case ICAL_RRULE_PROPERTY: | 1235 | case ICAL_RRULE_PROPERTY: |
1236 | // we do need (maybe )start datetime of incidence for recurrence | 1236 | // we do need (maybe )start datetime of incidence for recurrence |
1237 | // such that we can read recurrence only after we read incidence completely | 1237 | // such that we can read recurrence only after we read incidence completely |
1238 | readrec = true; | 1238 | readrec = true; |
1239 | rectype = icalproperty_get_rrule(p); | 1239 | rectype = icalproperty_get_rrule(p); |
1240 | break; | 1240 | break; |
1241 | 1241 | ||
1242 | case ICAL_EXDATE_PROPERTY: | 1242 | case ICAL_EXDATE_PROPERTY: |
1243 | icaltime = icalproperty_get_exdate(p); | 1243 | icaltime = icalproperty_get_exdate(p); |
1244 | incidence->addExDate(readICalDate(icaltime)); | 1244 | incidence->addExDate(readICalDate(icaltime)); |
1245 | break; | 1245 | break; |
1246 | 1246 | ||
1247 | case ICAL_CLASS_PROPERTY: { | 1247 | case ICAL_CLASS_PROPERTY: { |
1248 | int inttext = icalproperty_get_class(p); | 1248 | int inttext = icalproperty_get_class(p); |
1249 | if (inttext == ICAL_CLASS_PUBLIC ) { | 1249 | if (inttext == ICAL_CLASS_PUBLIC ) { |
1250 | incidence->setSecrecy(Incidence::SecrecyPublic); | 1250 | incidence->setSecrecy(Incidence::SecrecyPublic); |
1251 | } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { | 1251 | } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { |
1252 | incidence->setSecrecy(Incidence::SecrecyConfidential); | 1252 | incidence->setSecrecy(Incidence::SecrecyConfidential); |
1253 | } else { | 1253 | } else { |
1254 | incidence->setSecrecy(Incidence::SecrecyPrivate); | 1254 | incidence->setSecrecy(Incidence::SecrecyPrivate); |
1255 | } | 1255 | } |
1256 | } | 1256 | } |
1257 | break; | 1257 | break; |
1258 | 1258 | ||
1259 | case ICAL_ATTACH_PROPERTY: // attachments | 1259 | case ICAL_ATTACH_PROPERTY: // attachments |
1260 | incidence->addAttachment(readAttachment(p)); | 1260 | incidence->addAttachment(readAttachment(p)); |
1261 | break; | 1261 | break; |
1262 | 1262 | ||
1263 | default: | 1263 | default: |
1264 | // kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind | 1264 | // kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind |
1265 | // << endl; | 1265 | // << endl; |
1266 | break; | 1266 | break; |
1267 | } | 1267 | } |
1268 | 1268 | ||
1269 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); | 1269 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); |
1270 | } | 1270 | } |
1271 | if ( readrec ) { | 1271 | if ( readrec ) { |
1272 | readRecurrenceRule(rectype,incidence); | 1272 | readRecurrenceRule(rectype,incidence); |
1273 | } | 1273 | } |
1274 | // kpilot stuff | 1274 | // kpilot stuff |
1275 | // TODO: move this application-specific code to kpilot | 1275 | // TODO: move this application-specific code to kpilot |
1276 | QString kp = incidence->nonKDECustomProperty("X-PILOTID"); | 1276 | QString kp = incidence->nonKDECustomProperty("X-PILOTID"); |
1277 | if (!kp.isNull()) { | 1277 | if (!kp.isNull()) { |
1278 | incidence->setPilotId(kp.toInt()); | 1278 | incidence->setPilotId(kp.toInt()); |
1279 | } | 1279 | } |
1280 | kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); | 1280 | kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); |
1281 | if (!kp.isNull()) { | 1281 | if (!kp.isNull()) { |
1282 | incidence->setSyncStatus(kp.toInt()); | 1282 | incidence->setSyncStatus(kp.toInt()); |
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | 1285 | ||
1286 | kp = incidence->nonKDECustomProperty("X-KOPIEXTID"); | 1286 | kp = incidence->nonKDECustomProperty("X-KOPIEXTID"); |
1287 | if (!kp.isNull()) { | 1287 | if (!kp.isNull()) { |
1288 | incidence->setIDStr(kp); | 1288 | incidence->setIDStr(kp); |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | // Cancel backwards compatibility mode for subsequent changes by the application | 1291 | // Cancel backwards compatibility mode for subsequent changes by the application |
1292 | incidence->recurrence()->setCompatVersion(); | 1292 | incidence->recurrence()->setCompatVersion(); |
1293 | 1293 | ||
1294 | // add categories | 1294 | // add categories |
1295 | incidence->setCategories(categories); | 1295 | incidence->setCategories(categories); |
1296 | 1296 | ||
1297 | // iterate through all alarms | 1297 | // iterate through all alarms |
1298 | for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); | 1298 | for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); |
1299 | alarm; | 1299 | alarm; |
1300 | alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { | 1300 | alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { |
1301 | readAlarm(alarm,incidence); | 1301 | readAlarm(alarm,incidence); |
1302 | } | 1302 | } |
1303 | } | 1303 | } |
1304 | 1304 | ||
1305 | void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) | 1305 | void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) |
1306 | { | 1306 | { |
1307 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); | 1307 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); |
1308 | 1308 | ||
1309 | while (p) { | 1309 | while (p) { |
1310 | icalproperty_kind kind = icalproperty_isa(p); | 1310 | icalproperty_kind kind = icalproperty_isa(p); |
1311 | switch (kind) { | 1311 | switch (kind) { |
1312 | 1312 | ||
1313 | case ICAL_UID_PROPERTY: // unique id | 1313 | case ICAL_UID_PROPERTY: // unique id |
1314 | incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); | 1314 | incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); |
1315 | break; | 1315 | break; |
1316 | 1316 | ||
1317 | case ICAL_ORGANIZER_PROPERTY: // organizer | 1317 | case ICAL_ORGANIZER_PROPERTY: // organizer |
1318 | incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); | 1318 | incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); |
1319 | break; | 1319 | break; |
1320 | 1320 | ||
1321 | case ICAL_ATTENDEE_PROPERTY: // attendee | 1321 | case ICAL_ATTENDEE_PROPERTY: // attendee |
1322 | incidenceBase->addAttendee(readAttendee(p)); | 1322 | incidenceBase->addAttendee(readAttendee(p)); |
1323 | break; | 1323 | break; |
1324 | 1324 | ||
1325 | default: | 1325 | default: |
1326 | break; | 1326 | break; |
1327 | } | 1327 | } |
1328 | 1328 | ||
1329 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); | 1329 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); |
1330 | } | 1330 | } |
1331 | 1331 | ||
1332 | // custom properties | 1332 | // custom properties |
1333 | readCustomProperties(parent, incidenceBase); | 1333 | readCustomProperties(parent, incidenceBase); |
1334 | } | 1334 | } |
1335 | 1335 | ||
1336 | void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) | 1336 | void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) |
1337 | { | 1337 | { |
1338 | QMap<QCString, QString> customProperties; | 1338 | QMap<QCString, QString> customProperties; |
1339 | 1339 | ||
1340 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); | 1340 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); |
1341 | 1341 | ||
1342 | while (p) { | 1342 | while (p) { |
1343 | QString value = QString::fromUtf8(icalproperty_get_x(p)); | 1343 | QString value = QString::fromUtf8(icalproperty_get_x(p)); |
1344 | customProperties[icalproperty_get_x_name(p)] = value; | 1344 | customProperties[icalproperty_get_x_name(p)] = value; |
1345 | //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); | 1345 | //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); |
1346 | 1346 | ||
1347 | p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); | 1347 | p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); |
1348 | } | 1348 | } |
1349 | 1349 | ||
1350 | properties->setCustomProperties(customProperties); | 1350 | properties->setCustomProperties(customProperties); |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) | 1353 | void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) |
1354 | { | 1354 | { |
1355 | // kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl; | 1355 | // kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl; |
1356 | 1356 | ||
1357 | Recurrence *recur = incidence->recurrence(); | 1357 | Recurrence *recur = incidence->recurrence(); |
1358 | recur->setCompatVersion(mCalendarVersion); | 1358 | recur->setCompatVersion(mCalendarVersion); |
1359 | recur->unsetRecurs(); | 1359 | recur->unsetRecurs(); |
1360 | 1360 | ||
1361 | struct icalrecurrencetype r = rrule; | 1361 | struct icalrecurrencetype r = rrule; |
1362 | 1362 | ||
1363 | dumpIcalRecurrence(r); | 1363 | dumpIcalRecurrence(r); |
1364 | readRecurrence( r, recur, incidence); | 1364 | readRecurrence( r, recur, incidence); |
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence) | 1367 | void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence) |
1368 | { | 1368 | { |
1369 | int wkst; | 1369 | int wkst; |
1370 | int index = 0; | 1370 | int index = 0; |
1371 | short day = 0; | 1371 | short day = 0; |
1372 | QBitArray qba(7); | 1372 | QBitArray qba(7); |
1373 | int frequ = r.freq; | 1373 | int frequ = r.freq; |
1374 | int interv = r.interval; | 1374 | int interv = r.interval; |
1375 | // preprocessing for odd recurrence definitions | 1375 | // preprocessing for odd recurrence definitions |
1376 | 1376 | ||
1377 | if ( r.freq == ICAL_MONTHLY_RECURRENCE ) { | 1377 | if ( r.freq == ICAL_MONTHLY_RECURRENCE ) { |
1378 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1378 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1379 | interv = 12; | 1379 | interv = 12; |
1380 | } | 1380 | } |
1381 | } | 1381 | } |
1382 | if ( r.freq == ICAL_YEARLY_RECURRENCE ) { | 1382 | if ( r.freq == ICAL_YEARLY_RECURRENCE ) { |
1383 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) { | 1383 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) { |
1384 | frequ = ICAL_MONTHLY_RECURRENCE; | 1384 | frequ = ICAL_MONTHLY_RECURRENCE; |
1385 | interv = 12* r.interval; | 1385 | interv = 12* r.interval; |
1386 | } | 1386 | } |
1387 | } | 1387 | } |
1388 | 1388 | ||
1389 | switch (frequ) { | 1389 | switch (frequ) { |
1390 | case ICAL_MINUTELY_RECURRENCE: | 1390 | case ICAL_MINUTELY_RECURRENCE: |
1391 | if (!icaltime_is_null_time(r.until)) { | 1391 | if (!icaltime_is_null_time(r.until)) { |
1392 | recur->setMinutely(interv,readICalDateTime(r.until)); | 1392 | recur->setMinutely(interv,readICalDateTime(r.until)); |
1393 | } else { | 1393 | } else { |
1394 | if (r.count == 0) | 1394 | if (r.count == 0) |
1395 | recur->setMinutely(interv,-1); | 1395 | recur->setMinutely(interv,-1); |
1396 | else | 1396 | else |
1397 | recur->setMinutely(interv,r.count); | 1397 | recur->setMinutely(interv,r.count); |
1398 | } | 1398 | } |
1399 | break; | 1399 | break; |
1400 | case ICAL_HOURLY_RECURRENCE: | 1400 | case ICAL_HOURLY_RECURRENCE: |
1401 | if (!icaltime_is_null_time(r.until)) { | 1401 | if (!icaltime_is_null_time(r.until)) { |
1402 | recur->setHourly(interv,readICalDateTime(r.until)); | 1402 | recur->setHourly(interv,readICalDateTime(r.until)); |
1403 | } else { | 1403 | } else { |
1404 | if (r.count == 0) | 1404 | if (r.count == 0) |
1405 | recur->setHourly(interv,-1); | 1405 | recur->setHourly(interv,-1); |
1406 | else | 1406 | else |
1407 | recur->setHourly(interv,r.count); | 1407 | recur->setHourly(interv,r.count); |
1408 | } | 1408 | } |
1409 | break; | 1409 | break; |
1410 | case ICAL_DAILY_RECURRENCE: | 1410 | case ICAL_DAILY_RECURRENCE: |
1411 | if (!icaltime_is_null_time(r.until)) { | 1411 | if (!icaltime_is_null_time(r.until)) { |
1412 | recur->setDaily(interv,readICalDate(r.until)); | 1412 | recur->setDaily(interv,readICalDate(r.until)); |
1413 | } else { | 1413 | } else { |
1414 | if (r.count == 0) | 1414 | if (r.count == 0) |
1415 | recur->setDaily(interv,-1); | 1415 | recur->setDaily(interv,-1); |
1416 | else | 1416 | else |
1417 | recur->setDaily(interv,r.count); | 1417 | recur->setDaily(interv,r.count); |
1418 | } | 1418 | } |
1419 | break; | 1419 | break; |
1420 | case ICAL_WEEKLY_RECURRENCE: | 1420 | case ICAL_WEEKLY_RECURRENCE: |
1421 | // kdDebug(5800) << "WEEKLY_RECURRENCE" << endl; | 1421 | // kdDebug(5800) << "WEEKLY_RECURRENCE" << endl; |
1422 | wkst = (r.week_start + 5)%7 + 1; | 1422 | wkst = (r.week_start + 5)%7 + 1; |
1423 | if (!icaltime_is_null_time(r.until)) { | 1423 | if (!icaltime_is_null_time(r.until)) { |
1424 | recur->setWeekly(interv,qba,readICalDate(r.until),wkst); | 1424 | recur->setWeekly(interv,qba,readICalDate(r.until),wkst); |
1425 | } else { | 1425 | } else { |
1426 | if (r.count == 0) | 1426 | if (r.count == 0) |
1427 | recur->setWeekly(interv,qba,-1,wkst); | 1427 | recur->setWeekly(interv,qba,-1,wkst); |
1428 | else | 1428 | else |
1429 | recur->setWeekly(interv,qba,r.count,wkst); | 1429 | recur->setWeekly(interv,qba,r.count,wkst); |
1430 | } | 1430 | } |
1431 | if ( r.by_day[0] == ICAL_RECURRENCE_ARRAY_MAX) { | 1431 | if ( r.by_day[0] == ICAL_RECURRENCE_ARRAY_MAX) { |
1432 | int wday = incidence->dtStart().date().dayOfWeek ()-1; | 1432 | int wday = incidence->dtStart().date().dayOfWeek ()-1; |
1433 | //qDebug("weekly error found "); | 1433 | //qDebug("weekly error found "); |
1434 | qba.setBit(wday); | 1434 | qba.setBit(wday); |
1435 | } else { | 1435 | } else { |
1436 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1436 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1437 | // kdDebug(5800) << " " << day << endl; | 1437 | // kdDebug(5800) << " " << day << endl; |
1438 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1438 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1439 | } | 1439 | } |
1440 | } | 1440 | } |
1441 | break; | 1441 | break; |
1442 | case ICAL_MONTHLY_RECURRENCE: | 1442 | case ICAL_MONTHLY_RECURRENCE: |
1443 | 1443 | ||
1444 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1444 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1445 | if (!icaltime_is_null_time(r.until)) { | 1445 | if (!icaltime_is_null_time(r.until)) { |
1446 | recur->setMonthly(Recurrence::rMonthlyPos,interv, | 1446 | recur->setMonthly(Recurrence::rMonthlyPos,interv, |
1447 | readICalDate(r.until)); | 1447 | readICalDate(r.until)); |
1448 | } else { | 1448 | } else { |
1449 | if (r.count == 0) | 1449 | if (r.count == 0) |
1450 | recur->setMonthly(Recurrence::rMonthlyPos,interv,-1); | 1450 | recur->setMonthly(Recurrence::rMonthlyPos,interv,-1); |
1451 | else | 1451 | else |
1452 | recur->setMonthly(Recurrence::rMonthlyPos,interv,r.count); | 1452 | recur->setMonthly(Recurrence::rMonthlyPos,interv,r.count); |
1453 | } | 1453 | } |
1454 | bool useSetPos = false; | 1454 | bool useSetPos = false; |
1455 | short pos = 0; | 1455 | short pos = 0; |
1456 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1456 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1457 | // kdDebug(5800) << "----a " << index << ": " << day << endl; | 1457 | // kdDebug(5800) << "----a " << index << ": " << day << endl; |
1458 | pos = icalrecurrencetype_day_position(day); | 1458 | pos = icalrecurrencetype_day_position(day); |
1459 | if (pos) { | 1459 | if (pos) { |
1460 | day = icalrecurrencetype_day_day_of_week(day); | 1460 | day = icalrecurrencetype_day_day_of_week(day); |
1461 | QBitArray ba(7); // don't wipe qba | 1461 | QBitArray ba(7); // don't wipe qba |
1462 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1462 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1463 | recur->addMonthlyPos(pos,ba); | 1463 | recur->addMonthlyPos(pos,ba); |
1464 | } else { | 1464 | } else { |
1465 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1465 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1466 | useSetPos = true; | 1466 | useSetPos = true; |
1467 | } | 1467 | } |
1468 | } | 1468 | } |
1469 | if (useSetPos) { | 1469 | if (useSetPos) { |
1470 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1470 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1471 | recur->addMonthlyPos(r.by_set_pos[0],qba); | 1471 | recur->addMonthlyPos(r.by_set_pos[0],qba); |
1472 | } | 1472 | } |
1473 | } | 1473 | } |
1474 | } else if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1474 | } else if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1475 | if (!icaltime_is_null_time(r.until)) { | 1475 | if (!icaltime_is_null_time(r.until)) { |
1476 | recur->setMonthly(Recurrence::rMonthlyDay,interv, | 1476 | recur->setMonthly(Recurrence::rMonthlyDay,interv, |
1477 | readICalDate(r.until)); | 1477 | readICalDate(r.until)); |
1478 | } else { | 1478 | } else { |
1479 | if (r.count == 0) | 1479 | if (r.count == 0) |
1480 | recur->setMonthly(Recurrence::rMonthlyDay,interv,-1); | 1480 | recur->setMonthly(Recurrence::rMonthlyDay,interv,-1); |
1481 | else | 1481 | else |
1482 | recur->setMonthly(Recurrence::rMonthlyDay,interv,r.count); | 1482 | recur->setMonthly(Recurrence::rMonthlyDay,interv,r.count); |
1483 | } | 1483 | } |
1484 | while((day = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1484 | while((day = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1485 | // kdDebug(5800) << "----b " << day << endl; | 1485 | // kdDebug(5800) << "----b " << day << endl; |
1486 | recur->addMonthlyDay(day); | 1486 | recur->addMonthlyDay(day); |
1487 | } | 1487 | } |
1488 | } | 1488 | } |
1489 | break; | 1489 | break; |
1490 | case ICAL_YEARLY_RECURRENCE: | 1490 | case ICAL_YEARLY_RECURRENCE: |
1491 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1491 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1492 | //qDebug(" YEARLY DAY OF YEAR"); | 1492 | //qDebug(" YEARLY DAY OF YEAR"); |
1493 | if (!icaltime_is_null_time(r.until)) { | 1493 | if (!icaltime_is_null_time(r.until)) { |
1494 | recur->setYearly(Recurrence::rYearlyDay,interv, | 1494 | recur->setYearly(Recurrence::rYearlyDay,interv, |
1495 | readICalDate(r.until)); | 1495 | readICalDate(r.until)); |
1496 | } else { | 1496 | } else { |
1497 | if (r.count == 0) | 1497 | if (r.count == 0) |
1498 | recur->setYearly(Recurrence::rYearlyDay,interv,-1); | 1498 | recur->setYearly(Recurrence::rYearlyDay,interv,-1); |
1499 | else | 1499 | else |
1500 | recur->setYearly(Recurrence::rYearlyDay,interv,r.count); | 1500 | recur->setYearly(Recurrence::rYearlyDay,interv,r.count); |
1501 | } | 1501 | } |
1502 | while((day = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1502 | while((day = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1503 | recur->addYearlyNum(day); | 1503 | recur->addYearlyNum(day); |
1504 | } | 1504 | } |
1505 | } else if ( true /*r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX*/) { | 1505 | } else if ( true /*r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX*/) { |
1506 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1506 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1507 | qDebug("YEARLY POS NOT SUPPORTED BY GUI"); | 1507 | qDebug("YEARLY POS NOT SUPPORTED BY GUI"); |
1508 | if (!icaltime_is_null_time(r.until)) { | 1508 | if (!icaltime_is_null_time(r.until)) { |
1509 | recur->setYearly(Recurrence::rYearlyPos,interv, | 1509 | recur->setYearly(Recurrence::rYearlyPos,interv, |
1510 | readICalDate(r.until)); | 1510 | readICalDate(r.until)); |
1511 | } else { | 1511 | } else { |
1512 | if (r.count == 0) | 1512 | if (r.count == 0) |
1513 | recur->setYearly(Recurrence::rYearlyPos,interv,-1); | 1513 | recur->setYearly(Recurrence::rYearlyPos,interv,-1); |
1514 | else | 1514 | else |
1515 | recur->setYearly(Recurrence::rYearlyPos,interv,r.count); | 1515 | recur->setYearly(Recurrence::rYearlyPos,interv,r.count); |
1516 | } | 1516 | } |
1517 | bool useSetPos = false; | 1517 | bool useSetPos = false; |
1518 | short pos = 0; | 1518 | short pos = 0; |
1519 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1519 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1520 | // kdDebug(5800) << "----a " << index << ": " << day << endl; | 1520 | // kdDebug(5800) << "----a " << index << ": " << day << endl; |
1521 | pos = icalrecurrencetype_day_position(day); | 1521 | pos = icalrecurrencetype_day_position(day); |
1522 | if (pos) { | 1522 | if (pos) { |
1523 | day = icalrecurrencetype_day_day_of_week(day); | 1523 | day = icalrecurrencetype_day_day_of_week(day); |
1524 | QBitArray ba(7); // don't wipe qba | 1524 | QBitArray ba(7); // don't wipe qba |
1525 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1525 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1526 | recur->addYearlyMonthPos(pos,ba); | 1526 | recur->addYearlyMonthPos(pos,ba); |
1527 | } else { | 1527 | } else { |
1528 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1528 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1529 | useSetPos = true; | 1529 | useSetPos = true; |
1530 | } | 1530 | } |
1531 | } | 1531 | } |
1532 | if (useSetPos) { | 1532 | if (useSetPos) { |
1533 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1533 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1534 | recur->addYearlyMonthPos(r.by_set_pos[0],qba); | 1534 | recur->addYearlyMonthPos(r.by_set_pos[0],qba); |
1535 | } | 1535 | } |
1536 | } | 1536 | } |
1537 | } else { | 1537 | } else { |
1538 | //qDebug("YEARLY MONTH "); | 1538 | //qDebug("YEARLY MONTH "); |
1539 | if (!icaltime_is_null_time(r.until)) { | 1539 | if (!icaltime_is_null_time(r.until)) { |
1540 | recur->setYearly(Recurrence::rYearlyMonth,interv, | 1540 | recur->setYearly(Recurrence::rYearlyMonth,interv, |
1541 | readICalDate(r.until)); | 1541 | readICalDate(r.until)); |
1542 | } else { | 1542 | } else { |
1543 | if (r.count == 0) | 1543 | if (r.count == 0) |
1544 | recur->setYearly(Recurrence::rYearlyMonth,interv,-1); | 1544 | recur->setYearly(Recurrence::rYearlyMonth,interv,-1); |
1545 | else | 1545 | else |
1546 | recur->setYearly(Recurrence::rYearlyMonth,interv,r.count); | 1546 | recur->setYearly(Recurrence::rYearlyMonth,interv,r.count); |
1547 | } | 1547 | } |
1548 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX ) { | 1548 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX ) { |
1549 | index = 0; | 1549 | index = 0; |
1550 | while((day = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1550 | while((day = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1551 | recur->addYearlyNum(day); | 1551 | recur->addYearlyNum(day); |
1552 | } | 1552 | } |
1553 | } else { | 1553 | } else { |
1554 | recur->addYearlyNum(incidence->dtStart().date().month()); | 1554 | recur->addYearlyNum(incidence->dtStart().date().month()); |
1555 | } | 1555 | } |
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | } | 1558 | } |
1559 | break; | 1559 | break; |
1560 | default: | 1560 | default: |
1561 | ; | 1561 | ; |
1562 | break; | 1562 | break; |
1563 | } | 1563 | } |
1564 | } | 1564 | } |
1565 | 1565 | ||
1566 | void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence) | 1566 | void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence) |
1567 | { | 1567 | { |
1568 | //kdDebug(5800) << "Read alarm for " << incidence->summary() << endl; | 1568 | //kdDebug(5800) << "Read alarm for " << incidence->summary() << endl; |
1569 | 1569 | ||
1570 | Alarm* ialarm = incidence->newAlarm(); | 1570 | Alarm* ialarm = incidence->newAlarm(); |
1571 | ialarm->setRepeatCount(0); | 1571 | ialarm->setRepeatCount(0); |
1572 | ialarm->setEnabled(true); | 1572 | ialarm->setEnabled(true); |
1573 | 1573 | ||
1574 | // Determine the alarm's action type | 1574 | // Determine the alarm's action type |
1575 | icalproperty *p = icalcomponent_get_first_property(alarm,ICAL_ACTION_PROPERTY); | 1575 | icalproperty *p = icalcomponent_get_first_property(alarm,ICAL_ACTION_PROPERTY); |
1576 | if ( !p ) { | 1576 | if ( !p ) { |
1577 | return; | 1577 | return; |
1578 | } | 1578 | } |
1579 | 1579 | ||
1580 | icalproperty_action action = icalproperty_get_action(p); | 1580 | icalproperty_action action = icalproperty_get_action(p); |
1581 | Alarm::Type type = Alarm::Display; | 1581 | Alarm::Type type = Alarm::Display; |
1582 | switch ( action ) { | 1582 | switch ( action ) { |
1583 | case ICAL_ACTION_DISPLAY: type = Alarm::Display; break; | 1583 | case ICAL_ACTION_DISPLAY: type = Alarm::Display; break; |
1584 | case ICAL_ACTION_AUDIO: type = Alarm::Audio; break; | 1584 | case ICAL_ACTION_AUDIO: type = Alarm::Audio; break; |
1585 | case ICAL_ACTION_PROCEDURE: type = Alarm::Procedure; break; | 1585 | case ICAL_ACTION_PROCEDURE: type = Alarm::Procedure; break; |
1586 | case ICAL_ACTION_EMAIL: type = Alarm::Email; break; | 1586 | case ICAL_ACTION_EMAIL: type = Alarm::Email; break; |
1587 | default: | 1587 | default: |
1588 | ; | 1588 | ; |
1589 | return; | 1589 | return; |
1590 | } | 1590 | } |
1591 | ialarm->setType(type); | 1591 | ialarm->setType(type); |
1592 | 1592 | ||
1593 | p = icalcomponent_get_first_property(alarm,ICAL_ANY_PROPERTY); | 1593 | p = icalcomponent_get_first_property(alarm,ICAL_ANY_PROPERTY); |
1594 | while (p) { | 1594 | while (p) { |
1595 | icalproperty_kind kind = icalproperty_isa(p); | 1595 | icalproperty_kind kind = icalproperty_isa(p); |
1596 | 1596 | ||
1597 | switch (kind) { | 1597 | switch (kind) { |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 0684af2..708ee6b 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -1,603 +1,611 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | #include "incidence.h" | 27 | #include "incidence.h" |
28 | #include "todo.h" | 28 | #include "todo.h" |
29 | 29 | ||
30 | using namespace KCal; | 30 | using namespace KCal; |
31 | 31 | ||
32 | Incidence::Incidence() : | 32 | Incidence::Incidence() : |
33 | IncidenceBase(), | 33 | IncidenceBase(), |
34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) | 34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) |
35 | { | 35 | { |
36 | mRecurrence = new Recurrence(this); | 36 | mRecurrence = new Recurrence(this); |
37 | mCancelled = false; | 37 | mCancelled = false; |
38 | recreate(); | 38 | recreate(); |
39 | mHasStartDate = true; | 39 | mHasStartDate = true; |
40 | mAlarms.setAutoDelete(true); | 40 | mAlarms.setAutoDelete(true); |
41 | mAttachments.setAutoDelete(true); | 41 | mAttachments.setAutoDelete(true); |
42 | mHasRecurrenceID = false; | 42 | mHasRecurrenceID = false; |
43 | } | 43 | } |
44 | 44 | ||
45 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) | 45 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) |
46 | { | 46 | { |
47 | // TODO: reenable attributes currently commented out. | 47 | // TODO: reenable attributes currently commented out. |
48 | mRevision = i.mRevision; | 48 | mRevision = i.mRevision; |
49 | mCreated = i.mCreated; | 49 | mCreated = i.mCreated; |
50 | mDescription = i.mDescription; | 50 | mDescription = i.mDescription; |
51 | mSummary = i.mSummary; | 51 | mSummary = i.mSummary; |
52 | mCategories = i.mCategories; | 52 | mCategories = i.mCategories; |
53 | // Incidence *mRelatedTo; Incidence *mRelatedTo; | 53 | // Incidence *mRelatedTo; Incidence *mRelatedTo; |
54 | mRelatedTo = 0; | 54 | mRelatedTo = 0; |
55 | mRelatedToUid = i.mRelatedToUid; | 55 | mRelatedToUid = i.mRelatedToUid; |
56 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; | 56 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; |
57 | mExDates = i.mExDates; | 57 | mExDates = i.mExDates; |
58 | mAttachments = i.mAttachments; | 58 | mAttachments = i.mAttachments; |
59 | mResources = i.mResources; | 59 | mResources = i.mResources; |
60 | mSecrecy = i.mSecrecy; | 60 | mSecrecy = i.mSecrecy; |
61 | mPriority = i.mPriority; | 61 | mPriority = i.mPriority; |
62 | mLocation = i.mLocation; | 62 | mLocation = i.mLocation; |
63 | mCancelled = i.mCancelled; | 63 | mCancelled = i.mCancelled; |
64 | mHasStartDate = i.mHasStartDate; | 64 | mHasStartDate = i.mHasStartDate; |
65 | QPtrListIterator<Alarm> it( i.mAlarms ); | 65 | QPtrListIterator<Alarm> it( i.mAlarms ); |
66 | const Alarm *a; | 66 | const Alarm *a; |
67 | while( (a = it.current()) ) { | 67 | while( (a = it.current()) ) { |
68 | Alarm *b = new Alarm( *a ); | 68 | Alarm *b = new Alarm( *a ); |
69 | b->setParent( this ); | 69 | b->setParent( this ); |
70 | mAlarms.append( b ); | 70 | mAlarms.append( b ); |
71 | 71 | ||
72 | ++it; | 72 | ++it; |
73 | } | 73 | } |
74 | mAlarms.setAutoDelete(true); | 74 | mAlarms.setAutoDelete(true); |
75 | mHasRecurrenceID = i.mHasRecurrenceID; | 75 | mHasRecurrenceID = i.mHasRecurrenceID; |
76 | mRecurrenceID = i.mRecurrenceID; | 76 | mRecurrenceID = i.mRecurrenceID; |
77 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | 77 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); |
78 | } | 78 | } |
79 | 79 | ||
80 | Incidence::~Incidence() | 80 | Incidence::~Incidence() |
81 | { | 81 | { |
82 | 82 | ||
83 | Incidence *ev; | 83 | Incidence *ev; |
84 | QPtrList<Incidence> Relations = relations(); | 84 | QPtrList<Incidence> Relations = relations(); |
85 | for (ev=Relations.first();ev;ev=Relations.next()) { | 85 | for (ev=Relations.first();ev;ev=Relations.next()) { |
86 | if (ev->relatedTo() == this) ev->setRelatedTo(0); | 86 | if (ev->relatedTo() == this) ev->setRelatedTo(0); |
87 | } | 87 | } |
88 | if (relatedTo()) relatedTo()->removeRelation(this); | 88 | if (relatedTo()) relatedTo()->removeRelation(this); |
89 | delete mRecurrence; | 89 | delete mRecurrence; |
90 | 90 | ||
91 | } | 91 | } |
92 | bool Incidence::hasRecurrenceID() const | 92 | bool Incidence::hasRecurrenceID() const |
93 | { | 93 | { |
94 | return mHasRecurrenceID; | 94 | return mHasRecurrenceID; |
95 | } | 95 | } |
96 | 96 | ||
97 | void Incidence::setHasRecurrenceID( bool b ) | 97 | void Incidence::setHasRecurrenceID( bool b ) |
98 | { | 98 | { |
99 | mHasRecurrenceID = b; | 99 | mHasRecurrenceID = b; |
100 | } | 100 | } |
101 | 101 | ||
102 | void Incidence::setRecurrenceID(QDateTime d) | 102 | void Incidence::setRecurrenceID(QDateTime d) |
103 | { | 103 | { |
104 | mRecurrenceID = d; | 104 | mRecurrenceID = d; |
105 | mHasRecurrenceID = true; | 105 | mHasRecurrenceID = true; |
106 | updated(); | 106 | updated(); |
107 | } | 107 | } |
108 | QDateTime Incidence::recurrenceID () const | 108 | QDateTime Incidence::recurrenceID () const |
109 | { | 109 | { |
110 | return mRecurrenceID; | 110 | return mRecurrenceID; |
111 | } | 111 | } |
112 | 112 | ||
113 | bool Incidence::cancelled() const | 113 | bool Incidence::cancelled() const |
114 | { | 114 | { |
115 | return mCancelled; | 115 | return mCancelled; |
116 | } | 116 | } |
117 | void Incidence::setCancelled( bool b ) | 117 | void Incidence::setCancelled( bool b ) |
118 | { | 118 | { |
119 | mCancelled = b; | 119 | mCancelled = b; |
120 | updated(); | 120 | updated(); |
121 | } | 121 | } |
122 | bool Incidence::hasStartDate() const | 122 | bool Incidence::hasStartDate() const |
123 | { | 123 | { |
124 | return mHasStartDate; | 124 | return mHasStartDate; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Incidence::setHasStartDate(bool f) | 127 | void Incidence::setHasStartDate(bool f) |
128 | { | 128 | { |
129 | if (mReadOnly) return; | 129 | if (mReadOnly) return; |
130 | mHasStartDate = f; | 130 | mHasStartDate = f; |
131 | updated(); | 131 | updated(); |
132 | } | 132 | } |
133 | 133 | ||
134 | // A string comparison that considers that null and empty are the same | 134 | // A string comparison that considers that null and empty are the same |
135 | static bool stringCompare( const QString& s1, const QString& s2 ) | 135 | static bool stringCompare( const QString& s1, const QString& s2 ) |
136 | { | 136 | { |
137 | if ( s1.isEmpty() && s2.isEmpty() ) | 137 | if ( s1.isEmpty() && s2.isEmpty() ) |
138 | return true; | 138 | return true; |
139 | return s1 == s2; | 139 | return s1 == s2; |
140 | } | 140 | } |
141 | 141 | ||
142 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | 142 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) |
143 | { | 143 | { |
144 | 144 | ||
145 | if( i1.alarms().count() != i2.alarms().count() ) { | 145 | if( i1.alarms().count() != i2.alarms().count() ) { |
146 | return false; // no need to check further | 146 | return false; // no need to check further |
147 | } | 147 | } |
148 | if ( i1.alarms().count() > 0 ) { | 148 | if ( i1.alarms().count() > 0 ) { |
149 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) | 149 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) |
150 | { | 150 | { |
151 | qDebug("alarm not equal "); | 151 | qDebug("alarm not equal "); |
152 | return false; | 152 | return false; |
153 | } | 153 | } |
154 | } | 154 | } |
155 | #if 0 | 155 | #if 0 |
156 | QPtrListIterator<Alarm> a1( i1.alarms() ); | 156 | QPtrListIterator<Alarm> a1( i1.alarms() ); |
157 | QPtrListIterator<Alarm> a2( i2.alarms() ); | 157 | QPtrListIterator<Alarm> a2( i2.alarms() ); |
158 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { | 158 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { |
159 | if( *a1.current() == *a2.current() ) { | 159 | if( *a1.current() == *a2.current() ) { |
160 | continue; | 160 | continue; |
161 | } | 161 | } |
162 | else { | 162 | else { |
163 | return false; | 163 | return false; |
164 | } | 164 | } |
165 | } | 165 | } |
166 | #endif | 166 | #endif |
167 | 167 | ||
168 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { | 168 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { |
169 | if ( i1.hasRecurrenceID() ) { | 169 | if ( i1.hasRecurrenceID() ) { |
170 | if ( i1.recurrenceID() != i2.recurrenceID() ) | 170 | if ( i1.recurrenceID() != i2.recurrenceID() ) |
171 | return false; | 171 | return false; |
172 | } | 172 | } |
173 | 173 | ||
174 | } else { | 174 | } else { |
175 | return false; | 175 | return false; |
176 | } | 176 | } |
177 | 177 | ||
178 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) | 178 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) |
179 | return false; | 179 | return false; |
180 | if ( i1.hasStartDate() == i2.hasStartDate() ) { | 180 | if ( i1.hasStartDate() == i2.hasStartDate() ) { |
181 | if ( i1.hasStartDate() ) { | 181 | if ( i1.hasStartDate() ) { |
182 | if ( i1.dtStart() != i2.dtStart() ) | 182 | if ( i1.dtStart() != i2.dtStart() ) |
183 | return false; | 183 | return false; |
184 | } | 184 | } |
185 | } else { | 185 | } else { |
186 | return false; | 186 | return false; |
187 | } | 187 | } |
188 | if (!( *i1.recurrence() == *i2.recurrence()) ) { | 188 | if (!( *i1.recurrence() == *i2.recurrence()) ) { |
189 | qDebug("recurrence is NOT equal "); | 189 | qDebug("recurrence is NOT equal "); |
190 | return false; | 190 | return false; |
191 | } | 191 | } |
192 | return | 192 | return |
193 | // i1.created() == i2.created() && | 193 | // i1.created() == i2.created() && |
194 | stringCompare( i1.description(), i2.description() ) && | 194 | stringCompare( i1.description(), i2.description() ) && |
195 | stringCompare( i1.summary(), i2.summary() ) && | 195 | stringCompare( i1.summary(), i2.summary() ) && |
196 | i1.categories() == i2.categories() && | 196 | i1.categories() == i2.categories() && |
197 | // no need to compare mRelatedTo | 197 | // no need to compare mRelatedTo |
198 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && | 198 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && |
199 | // i1.relations() == i2.relations() && | 199 | // i1.relations() == i2.relations() && |
200 | i1.exDates() == i2.exDates() && | 200 | i1.exDates() == i2.exDates() && |
201 | i1.attachments() == i2.attachments() && | 201 | i1.attachments() == i2.attachments() && |
202 | i1.resources() == i2.resources() && | 202 | i1.resources() == i2.resources() && |
203 | i1.secrecy() == i2.secrecy() && | 203 | i1.secrecy() == i2.secrecy() && |
204 | i1.priority() == i2.priority() && | 204 | i1.priority() == i2.priority() && |
205 | i1.cancelled() == i2.cancelled() && | 205 | i1.cancelled() == i2.cancelled() && |
206 | stringCompare( i1.location(), i2.location() ); | 206 | stringCompare( i1.location(), i2.location() ); |
207 | } | 207 | } |
208 | 208 | ||
209 | Incidence* Incidence::recreateCloneException( QDate d ) | 209 | Incidence* Incidence::recreateCloneException( QDate d ) |
210 | { | 210 | { |
211 | Incidence* newInc = clone(); | 211 | Incidence* newInc = clone(); |
212 | newInc->recreate(); | 212 | newInc->recreate(); |
213 | if ( doesRecur() ) { | 213 | if ( doesRecur() ) { |
214 | addExDate( d ); | 214 | addExDate( d ); |
215 | newInc->recurrence()->unsetRecurs(); | 215 | newInc->recurrence()->unsetRecurs(); |
216 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); | 216 | if ( type() == "Event") { |
217 | QTime tim = dtStart().time(); | 217 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); |
218 | newInc->setDtStart( QDateTime(d, tim) ); | 218 | QTime tim = dtStart().time(); |
219 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 219 | newInc->setDtStart( QDateTime(d, tim) ); |
220 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | ||
221 | } else { | ||
222 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); | ||
223 | QTime tim = ((Todo*)this)->dtDue().time(); | ||
224 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); | ||
225 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); | ||
226 | ((Todo*)this)->setRecurDates(); | ||
227 | } | ||
220 | } | 228 | } |
221 | return newInc; | 229 | return newInc; |
222 | } | 230 | } |
223 | 231 | ||
224 | void Incidence::recreate() | 232 | void Incidence::recreate() |
225 | { | 233 | { |
226 | setCreated(QDateTime::currentDateTime()); | 234 | setCreated(QDateTime::currentDateTime()); |
227 | 235 | ||
228 | setUid(CalFormat::createUniqueId()); | 236 | setUid(CalFormat::createUniqueId()); |
229 | 237 | ||
230 | setRevision(0); | 238 | setRevision(0); |
231 | setIDStr( ":" ); | 239 | setIDStr( ":" ); |
232 | setLastModified(QDateTime::currentDateTime()); | 240 | setLastModified(QDateTime::currentDateTime()); |
233 | } | 241 | } |
234 | 242 | ||
235 | void Incidence::setReadOnly( bool readOnly ) | 243 | void Incidence::setReadOnly( bool readOnly ) |
236 | { | 244 | { |
237 | IncidenceBase::setReadOnly( readOnly ); | 245 | IncidenceBase::setReadOnly( readOnly ); |
238 | recurrence()->setRecurReadOnly( readOnly); | 246 | recurrence()->setRecurReadOnly( readOnly); |
239 | } | 247 | } |
240 | 248 | ||
241 | void Incidence::setCreated(QDateTime created) | 249 | void Incidence::setCreated(QDateTime created) |
242 | { | 250 | { |
243 | if (mReadOnly) return; | 251 | if (mReadOnly) return; |
244 | mCreated = getEvenTime(created); | 252 | mCreated = getEvenTime(created); |
245 | } | 253 | } |
246 | 254 | ||
247 | QDateTime Incidence::created() const | 255 | QDateTime Incidence::created() const |
248 | { | 256 | { |
249 | return mCreated; | 257 | return mCreated; |
250 | } | 258 | } |
251 | 259 | ||
252 | void Incidence::setRevision(int rev) | 260 | void Incidence::setRevision(int rev) |
253 | { | 261 | { |
254 | if (mReadOnly) return; | 262 | if (mReadOnly) return; |
255 | mRevision = rev; | 263 | mRevision = rev; |
256 | 264 | ||
257 | updated(); | 265 | updated(); |
258 | } | 266 | } |
259 | 267 | ||
260 | int Incidence::revision() const | 268 | int Incidence::revision() const |
261 | { | 269 | { |
262 | return mRevision; | 270 | return mRevision; |
263 | } | 271 | } |
264 | 272 | ||
265 | void Incidence::setDtStart(const QDateTime &dtStart) | 273 | void Incidence::setDtStart(const QDateTime &dtStart) |
266 | { | 274 | { |
267 | 275 | ||
268 | QDateTime dt = getEvenTime(dtStart); | 276 | QDateTime dt = getEvenTime(dtStart); |
269 | recurrence()->setRecurStart( dt); | 277 | recurrence()->setRecurStart( dt); |
270 | IncidenceBase::setDtStart( dt ); | 278 | IncidenceBase::setDtStart( dt ); |
271 | } | 279 | } |
272 | 280 | ||
273 | void Incidence::setDescription(const QString &description) | 281 | void Incidence::setDescription(const QString &description) |
274 | { | 282 | { |
275 | if (mReadOnly) return; | 283 | if (mReadOnly) return; |
276 | mDescription = description; | 284 | mDescription = description; |
277 | updated(); | 285 | updated(); |
278 | } | 286 | } |
279 | 287 | ||
280 | QString Incidence::description() const | 288 | QString Incidence::description() const |
281 | { | 289 | { |
282 | return mDescription; | 290 | return mDescription; |
283 | } | 291 | } |
284 | 292 | ||
285 | 293 | ||
286 | void Incidence::setSummary(const QString &summary) | 294 | void Incidence::setSummary(const QString &summary) |
287 | { | 295 | { |
288 | if (mReadOnly) return; | 296 | if (mReadOnly) return; |
289 | mSummary = summary; | 297 | mSummary = summary; |
290 | updated(); | 298 | updated(); |
291 | } | 299 | } |
292 | 300 | ||
293 | QString Incidence::summary() const | 301 | QString Incidence::summary() const |
294 | { | 302 | { |
295 | return mSummary; | 303 | return mSummary; |
296 | } | 304 | } |
297 | 305 | ||
298 | void Incidence::setCategories(const QStringList &categories) | 306 | void Incidence::setCategories(const QStringList &categories) |
299 | { | 307 | { |
300 | if (mReadOnly) return; | 308 | if (mReadOnly) return; |
301 | mCategories = categories; | 309 | mCategories = categories; |
302 | updated(); | 310 | updated(); |
303 | } | 311 | } |
304 | 312 | ||
305 | // TODO: remove setCategories(QString) function | 313 | // TODO: remove setCategories(QString) function |
306 | void Incidence::setCategories(const QString &catStr) | 314 | void Incidence::setCategories(const QString &catStr) |
307 | { | 315 | { |
308 | if (mReadOnly) return; | 316 | if (mReadOnly) return; |
309 | mCategories.clear(); | 317 | mCategories.clear(); |
310 | 318 | ||
311 | if (catStr.isEmpty()) return; | 319 | if (catStr.isEmpty()) return; |
312 | 320 | ||
313 | mCategories = QStringList::split(",",catStr); | 321 | mCategories = QStringList::split(",",catStr); |
314 | 322 | ||
315 | QStringList::Iterator it; | 323 | QStringList::Iterator it; |
316 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 324 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
317 | *it = (*it).stripWhiteSpace(); | 325 | *it = (*it).stripWhiteSpace(); |
318 | } | 326 | } |
319 | 327 | ||
320 | updated(); | 328 | updated(); |
321 | } | 329 | } |
322 | 330 | ||
323 | QStringList Incidence::categories() const | 331 | QStringList Incidence::categories() const |
324 | { | 332 | { |
325 | return mCategories; | 333 | return mCategories; |
326 | } | 334 | } |
327 | 335 | ||
328 | QString Incidence::categoriesStr() | 336 | QString Incidence::categoriesStr() |
329 | { | 337 | { |
330 | return mCategories.join(","); | 338 | return mCategories.join(","); |
331 | } | 339 | } |
332 | 340 | ||
333 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 341 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
334 | { | 342 | { |
335 | if (mReadOnly) return; | 343 | if (mReadOnly) return; |
336 | mRelatedToUid = relatedToUid; | 344 | mRelatedToUid = relatedToUid; |
337 | } | 345 | } |
338 | 346 | ||
339 | QString Incidence::relatedToUid() const | 347 | QString Incidence::relatedToUid() const |
340 | { | 348 | { |
341 | return mRelatedToUid; | 349 | return mRelatedToUid; |
342 | } | 350 | } |
343 | 351 | ||
344 | void Incidence::setRelatedTo(Incidence *relatedTo) | 352 | void Incidence::setRelatedTo(Incidence *relatedTo) |
345 | { | 353 | { |
346 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 354 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
347 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 355 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
348 | if (mReadOnly || mRelatedTo == relatedTo) return; | 356 | if (mReadOnly || mRelatedTo == relatedTo) return; |
349 | if(mRelatedTo) { | 357 | if(mRelatedTo) { |
350 | // updated(); | 358 | // updated(); |
351 | mRelatedTo->removeRelation(this); | 359 | mRelatedTo->removeRelation(this); |
352 | } | 360 | } |
353 | mRelatedTo = relatedTo; | 361 | mRelatedTo = relatedTo; |
354 | if (mRelatedTo) mRelatedTo->addRelation(this); | 362 | if (mRelatedTo) mRelatedTo->addRelation(this); |
355 | } | 363 | } |
356 | 364 | ||
357 | Incidence *Incidence::relatedTo() const | 365 | Incidence *Incidence::relatedTo() const |
358 | { | 366 | { |
359 | return mRelatedTo; | 367 | return mRelatedTo; |
360 | } | 368 | } |
361 | 369 | ||
362 | QPtrList<Incidence> Incidence::relations() const | 370 | QPtrList<Incidence> Incidence::relations() const |
363 | { | 371 | { |
364 | return mRelations; | 372 | return mRelations; |
365 | } | 373 | } |
366 | 374 | ||
367 | void Incidence::addRelation(Incidence *event) | 375 | void Incidence::addRelation(Incidence *event) |
368 | { | 376 | { |
369 | if( mRelations.findRef( event ) == -1 ) { | 377 | if( mRelations.findRef( event ) == -1 ) { |
370 | mRelations.append(event); | 378 | mRelations.append(event); |
371 | //updated(); | 379 | //updated(); |
372 | } | 380 | } |
373 | } | 381 | } |
374 | 382 | ||
375 | void Incidence::removeRelation(Incidence *event) | 383 | void Incidence::removeRelation(Incidence *event) |
376 | { | 384 | { |
377 | 385 | ||
378 | mRelations.removeRef(event); | 386 | mRelations.removeRef(event); |
379 | 387 | ||
380 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 388 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
381 | } | 389 | } |
382 | 390 | ||
383 | bool Incidence::recursOn(const QDate &qd) const | 391 | bool Incidence::recursOn(const QDate &qd) const |
384 | { | 392 | { |
385 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 393 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; |
386 | else return false; | 394 | else return false; |
387 | } | 395 | } |
388 | 396 | ||
389 | void Incidence::setExDates(const DateList &exDates) | 397 | void Incidence::setExDates(const DateList &exDates) |
390 | { | 398 | { |
391 | if (mReadOnly) return; | 399 | if (mReadOnly) return; |
392 | mExDates = exDates; | 400 | mExDates = exDates; |
393 | 401 | ||
394 | recurrence()->setRecurExDatesCount(mExDates.count()); | 402 | recurrence()->setRecurExDatesCount(mExDates.count()); |
395 | 403 | ||
396 | updated(); | 404 | updated(); |
397 | } | 405 | } |
398 | 406 | ||
399 | void Incidence::addExDate(const QDate &date) | 407 | void Incidence::addExDate(const QDate &date) |
400 | { | 408 | { |
401 | if (mReadOnly) return; | 409 | if (mReadOnly) return; |
402 | mExDates.append(date); | 410 | mExDates.append(date); |
403 | 411 | ||
404 | recurrence()->setRecurExDatesCount(mExDates.count()); | 412 | recurrence()->setRecurExDatesCount(mExDates.count()); |
405 | 413 | ||
406 | updated(); | 414 | updated(); |
407 | } | 415 | } |
408 | 416 | ||
409 | DateList Incidence::exDates() const | 417 | DateList Incidence::exDates() const |
410 | { | 418 | { |
411 | return mExDates; | 419 | return mExDates; |
412 | } | 420 | } |
413 | 421 | ||
414 | bool Incidence::isException(const QDate &date) const | 422 | bool Incidence::isException(const QDate &date) const |
415 | { | 423 | { |
416 | DateList::ConstIterator it; | 424 | DateList::ConstIterator it; |
417 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 425 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
418 | if ( (*it) == date ) { | 426 | if ( (*it) == date ) { |
419 | return true; | 427 | return true; |
420 | } | 428 | } |
421 | } | 429 | } |
422 | 430 | ||
423 | return false; | 431 | return false; |
424 | } | 432 | } |
425 | 433 | ||
426 | void Incidence::addAttachment(Attachment *attachment) | 434 | void Incidence::addAttachment(Attachment *attachment) |
427 | { | 435 | { |
428 | if (mReadOnly || !attachment) return; | 436 | if (mReadOnly || !attachment) return; |
429 | mAttachments.append(attachment); | 437 | mAttachments.append(attachment); |
430 | updated(); | 438 | updated(); |
431 | } | 439 | } |
432 | 440 | ||
433 | void Incidence::deleteAttachment(Attachment *attachment) | 441 | void Incidence::deleteAttachment(Attachment *attachment) |
434 | { | 442 | { |
435 | mAttachments.removeRef(attachment); | 443 | mAttachments.removeRef(attachment); |
436 | } | 444 | } |
437 | 445 | ||
438 | void Incidence::deleteAttachments(const QString& mime) | 446 | void Incidence::deleteAttachments(const QString& mime) |
439 | { | 447 | { |
440 | Attachment *at = mAttachments.first(); | 448 | Attachment *at = mAttachments.first(); |
441 | while (at) { | 449 | while (at) { |
442 | if (at->mimeType() == mime) | 450 | if (at->mimeType() == mime) |
443 | mAttachments.remove(); | 451 | mAttachments.remove(); |
444 | else | 452 | else |
445 | at = mAttachments.next(); | 453 | at = mAttachments.next(); |
446 | } | 454 | } |
447 | } | 455 | } |
448 | 456 | ||
449 | QPtrList<Attachment> Incidence::attachments() const | 457 | QPtrList<Attachment> Incidence::attachments() const |
450 | { | 458 | { |
451 | return mAttachments; | 459 | return mAttachments; |
452 | } | 460 | } |
453 | 461 | ||
454 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 462 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
455 | { | 463 | { |
456 | QPtrList<Attachment> attachments; | 464 | QPtrList<Attachment> attachments; |
457 | QPtrListIterator<Attachment> it( mAttachments ); | 465 | QPtrListIterator<Attachment> it( mAttachments ); |
458 | Attachment *at; | 466 | Attachment *at; |
459 | while ( (at = it.current()) ) { | 467 | while ( (at = it.current()) ) { |
460 | if (at->mimeType() == mime) | 468 | if (at->mimeType() == mime) |
461 | attachments.append(at); | 469 | attachments.append(at); |
462 | ++it; | 470 | ++it; |
463 | } | 471 | } |
464 | 472 | ||
465 | return attachments; | 473 | return attachments; |
466 | } | 474 | } |
467 | 475 | ||
468 | void Incidence::setResources(const QStringList &resources) | 476 | void Incidence::setResources(const QStringList &resources) |
469 | { | 477 | { |
470 | if (mReadOnly) return; | 478 | if (mReadOnly) return; |
471 | mResources = resources; | 479 | mResources = resources; |
472 | updated(); | 480 | updated(); |
473 | } | 481 | } |
474 | 482 | ||
475 | QStringList Incidence::resources() const | 483 | QStringList Incidence::resources() const |
476 | { | 484 | { |
477 | return mResources; | 485 | return mResources; |
478 | } | 486 | } |
479 | 487 | ||
480 | 488 | ||
481 | void Incidence::setPriority(int priority) | 489 | void Incidence::setPriority(int priority) |
482 | { | 490 | { |
483 | if (mReadOnly) return; | 491 | if (mReadOnly) return; |
484 | mPriority = priority; | 492 | mPriority = priority; |
485 | updated(); | 493 | updated(); |
486 | } | 494 | } |
487 | 495 | ||
488 | int Incidence::priority() const | 496 | int Incidence::priority() const |
489 | { | 497 | { |
490 | return mPriority; | 498 | return mPriority; |
491 | } | 499 | } |
492 | 500 | ||
493 | void Incidence::setSecrecy(int sec) | 501 | void Incidence::setSecrecy(int sec) |
494 | { | 502 | { |
495 | if (mReadOnly) return; | 503 | if (mReadOnly) return; |
496 | mSecrecy = sec; | 504 | mSecrecy = sec; |
497 | updated(); | 505 | updated(); |
498 | } | 506 | } |
499 | 507 | ||
500 | int Incidence::secrecy() const | 508 | int Incidence::secrecy() const |
501 | { | 509 | { |
502 | return mSecrecy; | 510 | return mSecrecy; |
503 | } | 511 | } |
504 | 512 | ||
505 | QString Incidence::secrecyStr() const | 513 | QString Incidence::secrecyStr() const |
506 | { | 514 | { |
507 | return secrecyName(mSecrecy); | 515 | return secrecyName(mSecrecy); |
508 | } | 516 | } |
509 | 517 | ||
510 | QString Incidence::secrecyName(int secrecy) | 518 | QString Incidence::secrecyName(int secrecy) |
511 | { | 519 | { |
512 | switch (secrecy) { | 520 | switch (secrecy) { |
513 | case SecrecyPublic: | 521 | case SecrecyPublic: |
514 | return i18n("Public"); | 522 | return i18n("Public"); |
515 | break; | 523 | break; |
516 | case SecrecyPrivate: | 524 | case SecrecyPrivate: |
517 | return i18n("Private"); | 525 | return i18n("Private"); |
518 | break; | 526 | break; |
519 | case SecrecyConfidential: | 527 | case SecrecyConfidential: |
520 | return i18n("Confidential"); | 528 | return i18n("Confidential"); |
521 | break; | 529 | break; |
522 | default: | 530 | default: |
523 | return i18n("Undefined"); | 531 | return i18n("Undefined"); |
524 | break; | 532 | break; |
525 | } | 533 | } |
526 | } | 534 | } |
527 | 535 | ||
528 | QStringList Incidence::secrecyList() | 536 | QStringList Incidence::secrecyList() |
529 | { | 537 | { |
530 | QStringList list; | 538 | QStringList list; |
531 | list << secrecyName(SecrecyPublic); | 539 | list << secrecyName(SecrecyPublic); |
532 | list << secrecyName(SecrecyPrivate); | 540 | list << secrecyName(SecrecyPrivate); |
533 | list << secrecyName(SecrecyConfidential); | 541 | list << secrecyName(SecrecyConfidential); |
534 | 542 | ||
535 | return list; | 543 | return list; |
536 | } | 544 | } |
537 | 545 | ||
538 | 546 | ||
539 | QPtrList<Alarm> Incidence::alarms() const | 547 | QPtrList<Alarm> Incidence::alarms() const |
540 | { | 548 | { |
541 | return mAlarms; | 549 | return mAlarms; |
542 | } | 550 | } |
543 | 551 | ||
544 | Alarm* Incidence::newAlarm() | 552 | Alarm* Incidence::newAlarm() |
545 | { | 553 | { |
546 | Alarm* alarm = new Alarm(this); | 554 | Alarm* alarm = new Alarm(this); |
547 | mAlarms.append(alarm); | 555 | mAlarms.append(alarm); |
548 | // updated(); | 556 | // updated(); |
549 | return alarm; | 557 | return alarm; |
550 | } | 558 | } |
551 | 559 | ||
552 | void Incidence::addAlarm(Alarm *alarm) | 560 | void Incidence::addAlarm(Alarm *alarm) |
553 | { | 561 | { |
554 | mAlarms.append(alarm); | 562 | mAlarms.append(alarm); |
555 | updated(); | 563 | updated(); |
556 | } | 564 | } |
557 | 565 | ||
558 | void Incidence::removeAlarm(Alarm *alarm) | 566 | void Incidence::removeAlarm(Alarm *alarm) |
559 | { | 567 | { |
560 | mAlarms.removeRef(alarm); | 568 | mAlarms.removeRef(alarm); |
561 | updated(); | 569 | updated(); |
562 | } | 570 | } |
563 | 571 | ||
564 | void Incidence::clearAlarms() | 572 | void Incidence::clearAlarms() |
565 | { | 573 | { |
566 | mAlarms.clear(); | 574 | mAlarms.clear(); |
567 | updated(); | 575 | updated(); |
568 | } | 576 | } |
569 | 577 | ||
570 | bool Incidence::isAlarmEnabled() const | 578 | bool Incidence::isAlarmEnabled() const |
571 | { | 579 | { |
572 | Alarm* alarm; | 580 | Alarm* alarm; |
573 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 581 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
574 | if (alarm->enabled()) | 582 | if (alarm->enabled()) |
575 | return true; | 583 | return true; |
576 | } | 584 | } |
577 | return false; | 585 | return false; |
578 | } | 586 | } |
579 | 587 | ||
580 | Recurrence *Incidence::recurrence() const | 588 | Recurrence *Incidence::recurrence() const |
581 | { | 589 | { |
582 | return mRecurrence; | 590 | return mRecurrence; |
583 | } | 591 | } |
584 | void Incidence::setRecurrence( Recurrence * r) | 592 | void Incidence::setRecurrence( Recurrence * r) |
585 | { | 593 | { |
586 | delete mRecurrence; | 594 | delete mRecurrence; |
587 | mRecurrence = r; | 595 | mRecurrence = r; |
588 | } | 596 | } |
589 | 597 | ||
590 | void Incidence::setLocation(const QString &location) | 598 | void Incidence::setLocation(const QString &location) |
591 | { | 599 | { |
592 | if (mReadOnly) return; | 600 | if (mReadOnly) return; |
593 | mLocation = location; | 601 | mLocation = location; |
594 | updated(); | 602 | updated(); |
595 | } | 603 | } |
596 | 604 | ||
597 | QString Incidence::location() const | 605 | QString Incidence::location() const |
598 | { | 606 | { |
599 | return mLocation; | 607 | return mLocation; |
600 | } | 608 | } |
601 | 609 | ||
602 | ushort Incidence::doesRecur() const | 610 | ushort Incidence::doesRecur() const |
603 | { | 611 | { |
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index 0d9c3f4..cc3088a 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -1,344 +1,356 @@ | |||
1 | #include "kincidenceformatter.h" | 1 | #include "kincidenceformatter.h" |
2 | #include <kstaticdeleter.h> | 2 | #include <kstaticdeleter.h> |
3 | #include <kglobal.h> | 3 | #include <kglobal.h> |
4 | #include <klocale.h> | 4 | #include <klocale.h> |
5 | #ifdef DEKTOP_VERSION | 5 | #ifdef DEKTOP_VERSION |
6 | #include <kabc/stdaddressbook.h> | 6 | #include <kabc/stdaddressbook.h> |
7 | #define size count | 7 | #define size count |
8 | #endif | 8 | #endif |
9 | 9 | ||
10 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; | 10 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; |
11 | static KStaticDeleter<KIncidenceFormatter> insd; | 11 | static KStaticDeleter<KIncidenceFormatter> insd; |
12 | 12 | ||
13 | QString KIncidenceFormatter::getFormattedText( Incidence * inc ) | 13 | QString KIncidenceFormatter::getFormattedText( Incidence * inc ) |
14 | { | 14 | { |
15 | // #ifndef QT_NO_INPUTDIALOG | 15 | // #ifndef QT_NO_INPUTDIALOG |
16 | // return QInputDialog::getItem( caption, label, items, current, editable ); | 16 | // return QInputDialog::getItem( caption, label, items, current, editable ); |
17 | // #else | 17 | // #else |
18 | // return QString::null; | 18 | // return QString::null; |
19 | // #endif | 19 | // #endif |
20 | mText = ""; | 20 | mText = ""; |
21 | if ( inc->type() == "Event" ) | 21 | if ( inc->type() == "Event" ) |
22 | setEvent((Event *) inc ); | 22 | setEvent((Event *) inc ); |
23 | else if ( inc->type() == "Todo" ) | 23 | else if ( inc->type() == "Todo" ) |
24 | setTodo((Todo *) inc ); | 24 | setTodo((Todo *) inc ); |
25 | return mText; | 25 | return mText; |
26 | } | 26 | } |
27 | 27 | ||
28 | KIncidenceFormatter* KIncidenceFormatter::instance() | 28 | KIncidenceFormatter* KIncidenceFormatter::instance() |
29 | { | 29 | { |
30 | if (!mInstance) { | 30 | if (!mInstance) { |
31 | mInstance = insd.setObject(new KIncidenceFormatter()); | 31 | mInstance = insd.setObject(new KIncidenceFormatter()); |
32 | } | 32 | } |
33 | return mInstance; | 33 | return mInstance; |
34 | } | 34 | } |
35 | KIncidenceFormatter::~KIncidenceFormatter() | 35 | KIncidenceFormatter::~KIncidenceFormatter() |
36 | { | 36 | { |
37 | if (mInstance == this) | 37 | if (mInstance == this) |
38 | mInstance = insd.setObject(0); | 38 | mInstance = insd.setObject(0); |
39 | //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); | 39 | //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); |
40 | } | 40 | } |
41 | KIncidenceFormatter::KIncidenceFormatter() | 41 | KIncidenceFormatter::KIncidenceFormatter() |
42 | { | 42 | { |
43 | mColorMode = 0; | 43 | mColorMode = 0; |
44 | } | 44 | } |
45 | void KIncidenceFormatter::setEvent(Event *event) | 45 | void KIncidenceFormatter::setEvent(Event *event) |
46 | { | 46 | { |
47 | int mode = 0; | 47 | int mode = 0; |
48 | mCurrentIncidence = event; | 48 | mCurrentIncidence = event; |
49 | bool shortDate = true; | 49 | bool shortDate = true; |
50 | if ( mode == 0 ) { | 50 | if ( mode == 0 ) { |
51 | addTag("h3",event->summary()); | 51 | addTag("h3",event->summary()); |
52 | } | 52 | } |
53 | else { | 53 | else { |
54 | if ( mColorMode == 1 ) { | 54 | if ( mColorMode == 1 ) { |
55 | mText +="<font color=\"#00A000\">"; | 55 | mText +="<font color=\"#00A000\">"; |
56 | } | 56 | } |
57 | if ( mColorMode == 2 ) { | 57 | if ( mColorMode == 2 ) { |
58 | mText +="<font color=\"#C00000\">"; | 58 | mText +="<font color=\"#C00000\">"; |
59 | } | 59 | } |
60 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 60 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
61 | if ( mode == 1 ) { | 61 | if ( mode == 1 ) { |
62 | addTag("h2",i18n( "Local: " ) +event->summary()); | 62 | addTag("h2",i18n( "Local: " ) +event->summary()); |
63 | } else { | 63 | } else { |
64 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 64 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
65 | } | 65 | } |
66 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 66 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
67 | if ( mColorMode ) | 67 | if ( mColorMode ) |
68 | mText += "</font>"; | 68 | mText += "</font>"; |
69 | } | 69 | } |
70 | if (event->cancelled ()) { | 70 | if (event->cancelled ()) { |
71 | mText +="<font color=\"#B00000\">"; | 71 | mText +="<font color=\"#B00000\">"; |
72 | addTag("i",i18n("This event has been cancelled!")); | 72 | addTag("i",i18n("This event has been cancelled!")); |
73 | mText.append("<br>"); | 73 | mText.append("<br>"); |
74 | mText += "</font>"; | 74 | mText += "</font>"; |
75 | } | 75 | } |
76 | if (!event->location().isEmpty()) { | 76 | if (!event->location().isEmpty()) { |
77 | addTag("b",i18n("Location: ")); | 77 | addTag("b",i18n("Location: ")); |
78 | mText.append(event->location()+"<br>"); | 78 | mText.append(event->location()+"<br>"); |
79 | } | 79 | } |
80 | if (event->doesFloat()) { | 80 | if (event->doesFloat()) { |
81 | if (event->isMultiDay()) { | 81 | if (event->isMultiDay()) { |
82 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") | 82 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") |
83 | .arg(event->dtStartDateStr(shortDate)) | 83 | .arg(event->dtStartDateStr(shortDate)) |
84 | .arg(event->dtEndDateStr(shortDate))); | 84 | .arg(event->dtEndDateStr(shortDate))); |
85 | } else { | 85 | } else { |
86 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 86 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
87 | } | 87 | } |
88 | } else { | 88 | } else { |
89 | if (event->isMultiDay()) { | 89 | if (event->isMultiDay()) { |
90 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 90 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
91 | .arg(event->dtStartStr( shortDate))); | 91 | .arg(event->dtStartStr( shortDate))); |
92 | mText.append(i18n("<p><b>To:</b> %1</p>") | 92 | mText.append(i18n("<p><b>To:</b> %1</p>") |
93 | .arg(event->dtEndStr(shortDate))); | 93 | .arg(event->dtEndStr(shortDate))); |
94 | } else { | 94 | } else { |
95 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 95 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
96 | .arg(event->dtStartDateStr( shortDate ))); | 96 | .arg(event->dtStartDateStr( shortDate ))); |
97 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 97 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
98 | .arg(event->dtStartTimeStr()) | 98 | .arg(event->dtStartTimeStr()) |
99 | .arg(event->dtEndTimeStr())); | 99 | .arg(event->dtEndTimeStr())); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | if (event->recurrence()->doesRecur()) { | 103 | if (event->recurrence()->doesRecur()) { |
104 | 104 | ||
105 | QString recurText = event->recurrence()->recurrenceText(); | 105 | QString recurText = event->recurrence()->recurrenceText(); |
106 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 106 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
107 | 107 | ||
108 | bool ok; | 108 | bool ok; |
109 | QDate start = QDate::currentDate(); | 109 | QDate start = QDate::currentDate(); |
110 | QDateTime next; | 110 | QDateTime next; |
111 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); | 111 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); |
112 | if ( ok ) { | 112 | if ( ok ) { |
113 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 113 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
114 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); | 114 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); |
115 | 115 | ||
116 | } else { | 116 | } else { |
117 | bool last; | 117 | bool last; |
118 | QDate nextd; | 118 | QDate nextd; |
119 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); | 119 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); |
120 | if ( last ) { | 120 | if ( last ) { |
121 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 121 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
122 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); | 122 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
128 | if (event->isAlarmEnabled()) { | 128 | if (event->isAlarmEnabled()) { |
129 | Alarm *alarm =event->alarms().first() ; | 129 | Alarm *alarm =event->alarms().first() ; |
130 | QDateTime t = alarm->time(); | 130 | QDateTime t = alarm->time(); |
131 | int min = t.secsTo( event->dtStart() )/60; | 131 | int min = t.secsTo( event->dtStart() )/60; |
132 | QString s =i18n("(%1 min before)").arg( min ); | 132 | QString s =i18n("(%1 min before)").arg( min ); |
133 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); | 133 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); |
134 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 134 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
135 | //addTag("p",s); | 135 | //addTag("p",s); |
136 | } | 136 | } |
137 | 137 | ||
138 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 138 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
139 | // mText.append(event->secrecyStr()+"<br>"); | 139 | // mText.append(event->secrecyStr()+"<br>"); |
140 | formatCategories(event); | 140 | formatCategories(event); |
141 | if (!event->description().isEmpty()) { | 141 | if (!event->description().isEmpty()) { |
142 | addTag("p",i18n("<b>Details: </b>")); | 142 | addTag("p",i18n("<b>Details: </b>")); |
143 | addTag("p",event->description()); | 143 | addTag("p",event->description()); |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | formatReadOnly(event); | 147 | formatReadOnly(event); |
148 | formatAttendees(event); | 148 | formatAttendees(event); |
149 | 149 | ||
150 | 150 | ||
151 | } | 151 | } |
152 | 152 | ||
153 | void KIncidenceFormatter::setTodo(Todo *event ) | 153 | void KIncidenceFormatter::setTodo(Todo *event ) |
154 | { | 154 | { |
155 | int mode = 0; | 155 | int mode = 0; |
156 | mCurrentIncidence = event; | 156 | mCurrentIncidence = event; |
157 | bool shortDate = true; | 157 | bool shortDate = true; |
158 | if (mode == 0 ) | 158 | if (mode == 0 ) |
159 | addTag("h3",event->summary()); | 159 | addTag("h3",event->summary()); |
160 | else { | 160 | else { |
161 | if ( mColorMode == 1 ) { | 161 | if ( mColorMode == 1 ) { |
162 | mText +="<font color=\"#00A000\">"; | 162 | mText +="<font color=\"#00A000\">"; |
163 | } | 163 | } |
164 | if ( mColorMode == 2 ) { | 164 | if ( mColorMode == 2 ) { |
165 | mText +="<font color=\"#B00000\">"; | 165 | mText +="<font color=\"#B00000\">"; |
166 | } | 166 | } |
167 | if ( mode == 1 ) { | 167 | if ( mode == 1 ) { |
168 | addTag("h2",i18n( "Local: " ) +event->summary()); | 168 | addTag("h2",i18n( "Local: " ) +event->summary()); |
169 | } else { | 169 | } else { |
170 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 170 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
171 | } | 171 | } |
172 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 172 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
173 | if ( mColorMode ) | 173 | if ( mColorMode ) |
174 | mText += "</font>"; | 174 | mText += "</font>"; |
175 | } | 175 | } |
176 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 176 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { |
177 | mText +="<font color=\"#B00000\">"; | 177 | mText +="<font color=\"#B00000\">"; |
178 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); | 178 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); |
179 | mText += "</font>"; | 179 | mText += "</font>"; |
180 | } else { | 180 | } else { |
181 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 181 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
182 | .arg(event->percentComplete())); | 182 | .arg(event->percentComplete())); |
183 | } | 183 | } |
184 | if (event->cancelled ()) { | 184 | if (event->cancelled ()) { |
185 | mText +="<font color=\"#B00000\">"; | 185 | mText +="<font color=\"#B00000\">"; |
186 | addTag("i",i18n("This todo has been cancelled!")); | 186 | addTag("i",i18n("This todo has been cancelled!")); |
187 | mText.append("<br>"); | 187 | mText.append("<br>"); |
188 | mText += "</font>"; | 188 | mText += "</font>"; |
189 | } | 189 | } |
190 | 190 | ||
191 | if (!event->location().isEmpty()) { | 191 | if (!event->location().isEmpty()) { |
192 | addTag("b",i18n("Location: ")); | 192 | addTag("b",i18n("Location: ")); |
193 | mText.append(event->location()+"<br>"); | 193 | mText.append(event->location()+"<br>"); |
194 | } | 194 | } |
195 | |||
196 | if (event->recurrence()->doesRecur()) { | ||
197 | |||
198 | QString recurText = event->recurrence()->recurrenceText(); | ||
199 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); | ||
200 | } | ||
201 | |||
202 | if (event->hasStartDate()) { | ||
203 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); | ||
204 | } | ||
205 | |||
206 | |||
195 | if (event->hasDueDate()) { | 207 | if (event->hasDueDate()) { |
196 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); | 208 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); |
197 | } | 209 | } |
198 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 210 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
199 | .arg(QString::number(event->priority()))); | 211 | .arg(QString::number(event->priority()))); |
200 | 212 | ||
201 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 213 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
202 | formatCategories(event); | 214 | formatCategories(event); |
203 | if (!event->description().isEmpty()) { | 215 | if (!event->description().isEmpty()) { |
204 | addTag("p",i18n("<b>Details: </b>")); | 216 | addTag("p",i18n("<b>Details: </b>")); |
205 | addTag("p",event->description()); | 217 | addTag("p",event->description()); |
206 | } | 218 | } |
207 | 219 | ||
208 | 220 | ||
209 | 221 | ||
210 | formatReadOnly(event); | 222 | formatReadOnly(event); |
211 | formatAttendees(event); | 223 | formatAttendees(event); |
212 | 224 | ||
213 | } | 225 | } |
214 | 226 | ||
215 | void KIncidenceFormatter::setJournal(Journal* ) | 227 | void KIncidenceFormatter::setJournal(Journal* ) |
216 | { | 228 | { |
217 | 229 | ||
218 | } | 230 | } |
219 | 231 | ||
220 | void KIncidenceFormatter::formatCategories(Incidence *event) | 232 | void KIncidenceFormatter::formatCategories(Incidence *event) |
221 | { | 233 | { |
222 | if (!event->categoriesStr().isEmpty()) { | 234 | if (!event->categoriesStr().isEmpty()) { |
223 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); | 235 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); |
224 | //mText.append(event->categoriesStr()); | 236 | //mText.append(event->categoriesStr()); |
225 | } | 237 | } |
226 | } | 238 | } |
227 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) | 239 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) |
228 | { | 240 | { |
229 | int number=text.contains("\n"); | 241 | int number=text.contains("\n"); |
230 | QString str = "<" + tag + ">"; | 242 | QString str = "<" + tag + ">"; |
231 | QString tmpText=text; | 243 | QString tmpText=text; |
232 | QString tmpStr=str; | 244 | QString tmpStr=str; |
233 | if(number !=-1) | 245 | if(number !=-1) |
234 | { | 246 | { |
235 | if (number > 0) { | 247 | if (number > 0) { |
236 | int pos=0; | 248 | int pos=0; |
237 | QString tmp; | 249 | QString tmp; |
238 | for(int i=0;i<=number;i++) { | 250 | for(int i=0;i<=number;i++) { |
239 | pos=tmpText.find("\n"); | 251 | pos=tmpText.find("\n"); |
240 | tmp=tmpText.left(pos); | 252 | tmp=tmpText.left(pos); |
241 | tmpText=tmpText.right(tmpText.length()-pos-1); | 253 | tmpText=tmpText.right(tmpText.length()-pos-1); |
242 | tmpStr+=tmp+"<br>"; | 254 | tmpStr+=tmp+"<br>"; |
243 | } | 255 | } |
244 | } | 256 | } |
245 | else tmpStr += tmpText; | 257 | else tmpStr += tmpText; |
246 | tmpStr+="</" + tag + ">"; | 258 | tmpStr+="</" + tag + ">"; |
247 | mText.append(tmpStr); | 259 | mText.append(tmpStr); |
248 | } | 260 | } |
249 | else | 261 | else |
250 | { | 262 | { |
251 | str += text + "</" + tag + ">"; | 263 | str += text + "</" + tag + ">"; |
252 | mText.append(str); | 264 | mText.append(str); |
253 | } | 265 | } |
254 | } | 266 | } |
255 | 267 | ||
256 | void KIncidenceFormatter::formatAttendees(Incidence *event) | 268 | void KIncidenceFormatter::formatAttendees(Incidence *event) |
257 | { | 269 | { |
258 | QPtrList<Attendee> attendees = event->attendees(); | 270 | QPtrList<Attendee> attendees = event->attendees(); |
259 | if (attendees.count()) { | 271 | if (attendees.count()) { |
260 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 272 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
261 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 273 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
262 | addTag("h3",i18n("Organizer")); | 274 | addTag("h3",i18n("Organizer")); |
263 | mText.append("<ul><li>"); | 275 | mText.append("<ul><li>"); |
264 | #if 0 | 276 | #if 0 |
265 | //ndef KORG_NOKABC | 277 | //ndef KORG_NOKABC |
266 | 278 | ||
267 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 279 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
268 | KABC::Addressee::List addressList; | 280 | KABC::Addressee::List addressList; |
269 | addressList = add_book->findByEmail(event->organizer()); | 281 | addressList = add_book->findByEmail(event->organizer()); |
270 | KABC::Addressee o = addressList.first(); | 282 | KABC::Addressee o = addressList.first(); |
271 | if (!o.isEmpty() && addressList.size()<2) { | 283 | if (!o.isEmpty() && addressList.size()<2) { |
272 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 284 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
273 | mText += o.formattedName(); | 285 | mText += o.formattedName(); |
274 | mText += "</a>\n"; | 286 | mText += "</a>\n"; |
275 | } else { | 287 | } else { |
276 | mText.append(event->organizer()); | 288 | mText.append(event->organizer()); |
277 | } | 289 | } |
278 | #else | 290 | #else |
279 | mText.append(event->organizer()); | 291 | mText.append(event->organizer()); |
280 | #endif | 292 | #endif |
281 | if (iconPath) { | 293 | if (iconPath) { |
282 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 294 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
283 | mText += "<IMG src=\"" + iconPath + "\">"; | 295 | mText += "<IMG src=\"" + iconPath + "\">"; |
284 | mText += "</a>\n"; | 296 | mText += "</a>\n"; |
285 | } | 297 | } |
286 | mText.append("</li></ul>"); | 298 | mText.append("</li></ul>"); |
287 | 299 | ||
288 | addTag("h3",i18n("Attendees")); | 300 | addTag("h3",i18n("Attendees")); |
289 | Attendee *a; | 301 | Attendee *a; |
290 | mText.append("<ul>"); | 302 | mText.append("<ul>"); |
291 | for(a=attendees.first();a;a=attendees.next()) { | 303 | for(a=attendees.first();a;a=attendees.next()) { |
292 | #if 0 | 304 | #if 0 |
293 | //ndef KORG_NOKABC | 305 | //ndef KORG_NOKABC |
294 | if (a->name().isEmpty()) { | 306 | if (a->name().isEmpty()) { |
295 | addressList = add_book->findByEmail(a->email()); | 307 | addressList = add_book->findByEmail(a->email()); |
296 | KABC::Addressee o = addressList.first(); | 308 | KABC::Addressee o = addressList.first(); |
297 | if (!o.isEmpty() && addressList.size()<2) { | 309 | if (!o.isEmpty() && addressList.size()<2) { |
298 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 310 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
299 | mText += o.formattedName(); | 311 | mText += o.formattedName(); |
300 | mText += "</a>\n"; | 312 | mText += "</a>\n"; |
301 | } else { | 313 | } else { |
302 | mText += "<li>"; | 314 | mText += "<li>"; |
303 | mText.append(a->email()); | 315 | mText.append(a->email()); |
304 | mText += "\n"; | 316 | mText += "\n"; |
305 | } | 317 | } |
306 | } else { | 318 | } else { |
307 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 319 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
308 | if (!a->name().isEmpty()) mText += a->name(); | 320 | if (!a->name().isEmpty()) mText += a->name(); |
309 | else mText += a->email(); | 321 | else mText += a->email(); |
310 | mText += "</a>\n"; | 322 | mText += "</a>\n"; |
311 | } | 323 | } |
312 | #else | 324 | #else |
313 | //qDebug("nokabc "); | 325 | //qDebug("nokabc "); |
314 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 326 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
315 | if (!a->name().isEmpty()) mText += a->name(); | 327 | if (!a->name().isEmpty()) mText += a->name(); |
316 | else mText += a->email(); | 328 | else mText += a->email(); |
317 | mText += "</a>\n"; | 329 | mText += "</a>\n"; |
318 | #endif | 330 | #endif |
319 | 331 | ||
320 | if (!a->email().isEmpty()) { | 332 | if (!a->email().isEmpty()) { |
321 | if (iconPath) { | 333 | if (iconPath) { |
322 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; | 334 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; |
323 | if ( a->RSVP() ) | 335 | if ( a->RSVP() ) |
324 | mText += "<IMG src=\"" + iconPath + "\">"; | 336 | mText += "<IMG src=\"" + iconPath + "\">"; |
325 | else | 337 | else |
326 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 338 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
327 | mText += "</a>\n"; | 339 | mText += "</a>\n"; |
328 | } | 340 | } |
329 | } | 341 | } |
330 | if (a->status() != Attendee::NeedsAction ) | 342 | if (a->status() != Attendee::NeedsAction ) |
331 | mText +="[" + a->statusStr() + "] "; | 343 | mText +="[" + a->statusStr() + "] "; |
332 | if (a->role() == Attendee::Chair ) | 344 | if (a->role() == Attendee::Chair ) |
333 | mText +="(" + a->roleStr().left(1) + ".)"; | 345 | mText +="(" + a->roleStr().left(1) + ".)"; |
334 | } | 346 | } |
335 | mText.append("</li></ul>"); | 347 | mText.append("</li></ul>"); |
336 | } | 348 | } |
337 | } | 349 | } |
338 | 350 | ||
339 | void KIncidenceFormatter::formatReadOnly(Incidence *event) | 351 | void KIncidenceFormatter::formatReadOnly(Incidence *event) |
340 | { | 352 | { |
341 | if (event->isReadOnly()) { | 353 | if (event->isReadOnly()) { |
342 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 354 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
343 | } | 355 | } |
344 | } | 356 | } |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 1f54c2f..39d16b6 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -1,457 +1,457 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "todo.h" | 25 | #include "todo.h" |
26 | 26 | ||
27 | using namespace KCal; | 27 | using namespace KCal; |
28 | 28 | ||
29 | Todo::Todo(): Incidence() | 29 | Todo::Todo(): Incidence() |
30 | { | 30 | { |
31 | // mStatus = TENTATIVE; | 31 | // mStatus = TENTATIVE; |
32 | 32 | ||
33 | mHasDueDate = false; | 33 | mHasDueDate = false; |
34 | setHasStartDate( false ); | 34 | setHasStartDate( false ); |
35 | mCompleted = getEvenTime(QDateTime::currentDateTime()); | 35 | mCompleted = getEvenTime(QDateTime::currentDateTime()); |
36 | mHasCompletedDate = false; | 36 | mHasCompletedDate = false; |
37 | mPercentComplete = 0; | 37 | mPercentComplete = 0; |
38 | } | 38 | } |
39 | 39 | ||
40 | Todo::Todo(const Todo &t) : Incidence(t) | 40 | Todo::Todo(const Todo &t) : Incidence(t) |
41 | { | 41 | { |
42 | mDtDue = t.mDtDue; | 42 | mDtDue = t.mDtDue; |
43 | mHasDueDate = t.mHasDueDate; | 43 | mHasDueDate = t.mHasDueDate; |
44 | mCompleted = t.mCompleted; | 44 | mCompleted = t.mCompleted; |
45 | mHasCompletedDate = t.mHasCompletedDate; | 45 | mHasCompletedDate = t.mHasCompletedDate; |
46 | mPercentComplete = t.mPercentComplete; | 46 | mPercentComplete = t.mPercentComplete; |
47 | } | 47 | } |
48 | 48 | ||
49 | Todo::~Todo() | 49 | Todo::~Todo() |
50 | { | 50 | { |
51 | 51 | ||
52 | } | 52 | } |
53 | 53 | ||
54 | Incidence *Todo::clone() | 54 | Incidence *Todo::clone() |
55 | { | 55 | { |
56 | return new Todo(*this); | 56 | return new Todo(*this); |
57 | } | 57 | } |
58 | 58 | ||
59 | bool Todo::contains ( Todo* from ) | 59 | bool Todo::contains ( Todo* from ) |
60 | { | 60 | { |
61 | 61 | ||
62 | if ( !from->summary().isEmpty() ) | 62 | if ( !from->summary().isEmpty() ) |
63 | if ( !summary().startsWith( from->summary() )) | 63 | if ( !summary().startsWith( from->summary() )) |
64 | return false; | 64 | return false; |
65 | if ( from->hasStartDate() ) { | 65 | if ( from->hasStartDate() ) { |
66 | if ( !hasStartDate() ) | 66 | if ( !hasStartDate() ) |
67 | return false; | 67 | return false; |
68 | if ( from->dtStart() != dtStart()) | 68 | if ( from->dtStart() != dtStart()) |
69 | return false; | 69 | return false; |
70 | } | 70 | } |
71 | if ( from->hasDueDate() ){ | 71 | if ( from->hasDueDate() ){ |
72 | if ( !hasDueDate() ) | 72 | if ( !hasDueDate() ) |
73 | return false; | 73 | return false; |
74 | if ( from->dtDue() != dtDue()) | 74 | if ( from->dtDue() != dtDue()) |
75 | return false; | 75 | return false; |
76 | } | 76 | } |
77 | if ( !from->location().isEmpty() ) | 77 | if ( !from->location().isEmpty() ) |
78 | if ( !location().startsWith( from->location() ) ) | 78 | if ( !location().startsWith( from->location() ) ) |
79 | return false; | 79 | return false; |
80 | if ( !from->description().isEmpty() ) | 80 | if ( !from->description().isEmpty() ) |
81 | if ( !description().startsWith( from->description() )) | 81 | if ( !description().startsWith( from->description() )) |
82 | return false; | 82 | return false; |
83 | if ( from->alarms().count() ) { | 83 | if ( from->alarms().count() ) { |
84 | Alarm *a = from->alarms().first(); | 84 | Alarm *a = from->alarms().first(); |
85 | if ( a->enabled() ){ | 85 | if ( a->enabled() ){ |
86 | if ( !alarms().count() ) | 86 | if ( !alarms().count() ) |
87 | return false; | 87 | return false; |
88 | Alarm *b = alarms().first(); | 88 | Alarm *b = alarms().first(); |
89 | if( ! b->enabled() ) | 89 | if( ! b->enabled() ) |
90 | return false; | 90 | return false; |
91 | if ( ! (a->offset() == b->offset() )) | 91 | if ( ! (a->offset() == b->offset() )) |
92 | return false; | 92 | return false; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | QStringList cat = categories(); | 96 | QStringList cat = categories(); |
97 | QStringList catFrom = from->categories(); | 97 | QStringList catFrom = from->categories(); |
98 | QString nCat; | 98 | QString nCat; |
99 | unsigned int iii; | 99 | unsigned int iii; |
100 | for ( iii = 0; iii < catFrom.count();++iii ) { | 100 | for ( iii = 0; iii < catFrom.count();++iii ) { |
101 | nCat = catFrom[iii]; | 101 | nCat = catFrom[iii]; |
102 | if ( !nCat.isEmpty() ) | 102 | if ( !nCat.isEmpty() ) |
103 | if ( !cat.contains( nCat )) { | 103 | if ( !cat.contains( nCat )) { |
104 | return false; | 104 | return false; |
105 | } | 105 | } |
106 | } | 106 | } |
107 | if ( from->isCompleted() ) { | 107 | if ( from->isCompleted() ) { |
108 | if ( !isCompleted() ) | 108 | if ( !isCompleted() ) |
109 | return false; | 109 | return false; |
110 | } | 110 | } |
111 | if( priority() != from->priority() ) | 111 | if( priority() != from->priority() ) |
112 | return false; | 112 | return false; |
113 | 113 | ||
114 | 114 | ||
115 | return true; | 115 | return true; |
116 | 116 | ||
117 | } | 117 | } |
118 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) | 118 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) |
119 | { | 119 | { |
120 | 120 | ||
121 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); | 121 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); |
122 | if ( ! ret ) | 122 | if ( ! ret ) |
123 | return false; | 123 | return false; |
124 | if ( t1.hasDueDate() == t2.hasDueDate() ) { | 124 | if ( t1.hasDueDate() == t2.hasDueDate() ) { |
125 | if ( t1.hasDueDate() ) { | 125 | if ( t1.hasDueDate() ) { |
126 | if ( t1.doesFloat() == t2.doesFloat() ) { | 126 | if ( t1.doesFloat() == t2.doesFloat() ) { |
127 | if ( t1.doesFloat() ) { | 127 | if ( t1.doesFloat() ) { |
128 | if ( t1.dtDue().date() != t2.dtDue().date() ) | 128 | if ( t1.dtDue().date() != t2.dtDue().date() ) |
129 | return false; | 129 | return false; |
130 | } else | 130 | } else |
131 | if ( t1.dtDue() != t2.dtDue() ) | 131 | if ( t1.dtDue() != t2.dtDue() ) |
132 | return false; | 132 | return false; |
133 | } else | 133 | } else |
134 | return false;// float != | 134 | return false;// float != |
135 | } | 135 | } |
136 | 136 | ||
137 | } else | 137 | } else |
138 | return false; | 138 | return false; |
139 | if ( t1.percentComplete() != t2.percentComplete() ) | 139 | if ( t1.percentComplete() != t2.percentComplete() ) |
140 | return false; | 140 | return false; |
141 | if ( t1.isCompleted() ) { | 141 | if ( t1.isCompleted() ) { |
142 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { | 142 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { |
143 | if ( t1.hasCompletedDate() ) { | 143 | if ( t1.hasCompletedDate() ) { |
144 | if ( t1.completed() != t2.completed() ) | 144 | if ( t1.completed() != t2.completed() ) |
145 | return false; | 145 | return false; |
146 | } | 146 | } |
147 | 147 | ||
148 | } else | 148 | } else |
149 | return false; | 149 | return false; |
150 | } | 150 | } |
151 | return true; | 151 | return true; |
152 | 152 | ||
153 | } | 153 | } |
154 | 154 | ||
155 | void Todo::setDtDue(const QDateTime &dtDue) | 155 | void Todo::setDtDue(const QDateTime &dtDue) |
156 | { | 156 | { |
157 | //int diffsecs = mDtDue.secsTo(dtDue); | 157 | //int diffsecs = mDtDue.secsTo(dtDue); |
158 | 158 | ||
159 | /*if (mReadOnly) return; | 159 | /*if (mReadOnly) return; |
160 | const QPtrList<Alarm>& alarms = alarms(); | 160 | const QPtrList<Alarm>& alarms = alarms(); |
161 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { | 161 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { |
162 | if (alarm->enabled()) { | 162 | if (alarm->enabled()) { |
163 | alarm->setTime(alarm->time().addSecs(diffsecs)); | 163 | alarm->setTime(alarm->time().addSecs(diffsecs)); |
164 | } | 164 | } |
165 | }*/ | 165 | }*/ |
166 | mDtDue = getEvenTime(dtDue); | 166 | mDtDue = getEvenTime(dtDue); |
167 | 167 | ||
168 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; | 168 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; |
169 | 169 | ||
170 | /*const QPtrList<Alarm>& alarms = alarms(); | 170 | /*const QPtrList<Alarm>& alarms = alarms(); |
171 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) | 171 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) |
172 | alarm->setAlarmStart(mDtDue);*/ | 172 | alarm->setAlarmStart(mDtDue);*/ |
173 | 173 | ||
174 | updated(); | 174 | updated(); |
175 | } | 175 | } |
176 | 176 | ||
177 | QDateTime Todo::dtDue() const | 177 | QDateTime Todo::dtDue() const |
178 | { | 178 | { |
179 | return mDtDue; | 179 | return mDtDue; |
180 | } | 180 | } |
181 | 181 | ||
182 | QString Todo::dtDueTimeStr() const | 182 | QString Todo::dtDueTimeStr() const |
183 | { | 183 | { |
184 | return KGlobal::locale()->formatTime(mDtDue.time()); | 184 | return KGlobal::locale()->formatTime(mDtDue.time()); |
185 | } | 185 | } |
186 | 186 | ||
187 | QString Todo::dtDueDateStr(bool shortfmt) const | 187 | QString Todo::dtDueDateStr(bool shortfmt) const |
188 | { | 188 | { |
189 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 189 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
190 | } | 190 | } |
191 | 191 | ||
192 | QString Todo::dtDueStr(bool shortfmt) const | 192 | QString Todo::dtDueStr(bool shortfmt) const |
193 | { | 193 | { |
194 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); | 194 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); |
195 | } | 195 | } |
196 | // retval 0 : no found | 196 | // retval 0 : no found |
197 | // 1 : due for date found | 197 | // 1 : due for date found |
198 | // 2 : overdue for date found | 198 | // 2 : overdue for date found |
199 | int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) | 199 | int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) |
200 | { | 200 | { |
201 | int retval = 0; | 201 | int retval = 0; |
202 | if ( isCompleted() ) | 202 | if ( isCompleted() ) |
203 | return 0; | 203 | return 0; |
204 | if ( hasDueDate() ) { | 204 | if ( hasDueDate() ) { |
205 | if ( dtDue().date() < date ) | 205 | if ( dtDue().date() < date ) |
206 | return 2; | 206 | return 2; |
207 | // we do not return, because we may find an overdue sub todo | 207 | // we do not return, because we may find an overdue sub todo |
208 | if ( dtDue().date() == date ) | 208 | if ( dtDue().date() == date ) |
209 | retval = 1; | 209 | retval = 1; |
210 | } | 210 | } |
211 | if ( checkSubtodos ) { | 211 | if ( checkSubtodos ) { |
212 | Incidence *aTodo; | 212 | Incidence *aTodo; |
213 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | 213 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { |
214 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); | 214 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); |
215 | if ( ret == 2 ) | 215 | if ( ret == 2 ) |
216 | return 2; | 216 | return 2; |
217 | if ( ret == 1) | 217 | if ( ret == 1) |
218 | retval = 1; | 218 | retval = 1; |
219 | } | 219 | } |
220 | } | 220 | } |
221 | return retval; | 221 | return retval; |
222 | } | 222 | } |
223 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true | 223 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true |
224 | { | 224 | { |
225 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); | 225 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); |
226 | } | 226 | } |
227 | bool Todo::hasDueDate() const | 227 | bool Todo::hasDueDate() const |
228 | { | 228 | { |
229 | return mHasDueDate; | 229 | return mHasDueDate; |
230 | } | 230 | } |
231 | 231 | ||
232 | void Todo::setHasDueDate(bool f) | 232 | void Todo::setHasDueDate(bool f) |
233 | { | 233 | { |
234 | if (mReadOnly) return; | 234 | if (mReadOnly) return; |
235 | mHasDueDate = f; | 235 | mHasDueDate = f; |
236 | updated(); | 236 | updated(); |
237 | } | 237 | } |
238 | 238 | ||
239 | 239 | ||
240 | #if 0 | 240 | #if 0 |
241 | void Todo::setStatus(const QString &statStr) | 241 | void Todo::setStatus(const QString &statStr) |
242 | { | 242 | { |
243 | if (mReadOnly) return; | 243 | if (mReadOnly) return; |
244 | QString ss(statStr.upper()); | 244 | QString ss(statStr.upper()); |
245 | 245 | ||
246 | if (ss == "X-ACTION") | 246 | if (ss == "X-ACTION") |
247 | mStatus = NEEDS_ACTION; | 247 | mStatus = NEEDS_ACTION; |
248 | else if (ss == "NEEDS ACTION") | 248 | else if (ss == "NEEDS ACTION") |
249 | mStatus = NEEDS_ACTION; | 249 | mStatus = NEEDS_ACTION; |
250 | else if (ss == "ACCEPTED") | 250 | else if (ss == "ACCEPTED") |
251 | mStatus = ACCEPTED; | 251 | mStatus = ACCEPTED; |
252 | else if (ss == "SENT") | 252 | else if (ss == "SENT") |
253 | mStatus = SENT; | 253 | mStatus = SENT; |
254 | else if (ss == "TENTATIVE") | 254 | else if (ss == "TENTATIVE") |
255 | mStatus = TENTATIVE; | 255 | mStatus = TENTATIVE; |
256 | else if (ss == "CONFIRMED") | 256 | else if (ss == "CONFIRMED") |
257 | mStatus = CONFIRMED; | 257 | mStatus = CONFIRMED; |
258 | else if (ss == "DECLINED") | 258 | else if (ss == "DECLINED") |
259 | mStatus = DECLINED; | 259 | mStatus = DECLINED; |
260 | else if (ss == "COMPLETED") | 260 | else if (ss == "COMPLETED") |
261 | mStatus = COMPLETED; | 261 | mStatus = COMPLETED; |
262 | else if (ss == "DELEGATED") | 262 | else if (ss == "DELEGATED") |
263 | mStatus = DELEGATED; | 263 | mStatus = DELEGATED; |
264 | 264 | ||
265 | updated(); | 265 | updated(); |
266 | } | 266 | } |
267 | 267 | ||
268 | void Todo::setStatus(int status) | 268 | void Todo::setStatus(int status) |
269 | { | 269 | { |
270 | if (mReadOnly) return; | 270 | if (mReadOnly) return; |
271 | mStatus = status; | 271 | mStatus = status; |
272 | updated(); | 272 | updated(); |
273 | } | 273 | } |
274 | 274 | ||
275 | int Todo::status() const | 275 | int Todo::status() const |
276 | { | 276 | { |
277 | return mStatus; | 277 | return mStatus; |
278 | } | 278 | } |
279 | 279 | ||
280 | QString Todo::statusStr() const | 280 | QString Todo::statusStr() const |
281 | { | 281 | { |
282 | switch(mStatus) { | 282 | switch(mStatus) { |
283 | case NEEDS_ACTION: | 283 | case NEEDS_ACTION: |
284 | return QString("NEEDS ACTION"); | 284 | return QString("NEEDS ACTION"); |
285 | break; | 285 | break; |
286 | case ACCEPTED: | 286 | case ACCEPTED: |
287 | return QString("ACCEPTED"); | 287 | return QString("ACCEPTED"); |
288 | break; | 288 | break; |
289 | case SENT: | 289 | case SENT: |
290 | return QString("SENT"); | 290 | return QString("SENT"); |
291 | break; | 291 | break; |
292 | case TENTATIVE: | 292 | case TENTATIVE: |
293 | return QString("TENTATIVE"); | 293 | return QString("TENTATIVE"); |
294 | break; | 294 | break; |
295 | case CONFIRMED: | 295 | case CONFIRMED: |
296 | return QString("CONFIRMED"); | 296 | return QString("CONFIRMED"); |
297 | break; | 297 | break; |
298 | case DECLINED: | 298 | case DECLINED: |
299 | return QString("DECLINED"); | 299 | return QString("DECLINED"); |
300 | break; | 300 | break; |
301 | case COMPLETED: | 301 | case COMPLETED: |
302 | return QString("COMPLETED"); | 302 | return QString("COMPLETED"); |
303 | break; | 303 | break; |
304 | case DELEGATED: | 304 | case DELEGATED: |
305 | return QString("DELEGATED"); | 305 | return QString("DELEGATED"); |
306 | break; | 306 | break; |
307 | } | 307 | } |
308 | return QString(""); | 308 | return QString(""); |
309 | } | 309 | } |
310 | #endif | 310 | #endif |
311 | 311 | ||
312 | bool Todo::isCompleted() const | 312 | bool Todo::isCompleted() const |
313 | { | 313 | { |
314 | if (mPercentComplete == 100) { | 314 | if (mPercentComplete == 100) { |
315 | return true; | 315 | return true; |
316 | } | 316 | } |
317 | else return false; | 317 | else return false; |
318 | } | 318 | } |
319 | 319 | ||
320 | void Todo::setCompleted(bool completed) | 320 | void Todo::setCompleted(bool completed) |
321 | { | 321 | { |
322 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { | 322 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { |
323 | if ( !setRecurDates() ) | 323 | if ( !setRecurDates() ) |
324 | completed = false; | 324 | completed = false; |
325 | } | 325 | } |
326 | if (completed) mPercentComplete = 100; | 326 | if (completed) mPercentComplete = 100; |
327 | else { | 327 | else { |
328 | mPercentComplete = 0; | 328 | mPercentComplete = 0; |
329 | mHasCompletedDate = false; | 329 | mHasCompletedDate = false; |
330 | } | 330 | } |
331 | updated(); | 331 | updated(); |
332 | } | 332 | } |
333 | 333 | ||
334 | QDateTime Todo::completed() const | 334 | QDateTime Todo::completed() const |
335 | { | 335 | { |
336 | return mCompleted; | 336 | return mCompleted; |
337 | } | 337 | } |
338 | 338 | ||
339 | QString Todo::completedStr( bool shortF ) const | 339 | QString Todo::completedStr( bool shortF ) const |
340 | { | 340 | { |
341 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); | 341 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); |
342 | } | 342 | } |
343 | 343 | ||
344 | void Todo::setCompleted(const QDateTime &completed) | 344 | void Todo::setCompleted(const QDateTime &completed) |
345 | { | 345 | { |
346 | //qDebug("Todo::setCompleted "); | 346 | //qDebug("Todo::setCompleted "); |
347 | if ( mHasCompletedDate ) { | 347 | if ( mHasCompletedDate ) { |
348 | // qDebug("has completed data - return "); | 348 | // qDebug("has completed data - return "); |
349 | return; | 349 | return; |
350 | } | 350 | } |
351 | mHasCompletedDate = true; | 351 | mHasCompletedDate = true; |
352 | mPercentComplete = 100; | 352 | mPercentComplete = 100; |
353 | mCompleted = getEvenTime(completed); | 353 | mCompleted = getEvenTime(completed); |
354 | updated(); | 354 | updated(); |
355 | } | 355 | } |
356 | 356 | ||
357 | bool Todo::hasCompletedDate() const | 357 | bool Todo::hasCompletedDate() const |
358 | { | 358 | { |
359 | return mHasCompletedDate; | 359 | return mHasCompletedDate; |
360 | } | 360 | } |
361 | 361 | ||
362 | int Todo::percentComplete() const | 362 | int Todo::percentComplete() const |
363 | { | 363 | { |
364 | return mPercentComplete; | 364 | return mPercentComplete; |
365 | } | 365 | } |
366 | bool Todo::setRecurDates() | 366 | bool Todo::setRecurDates() |
367 | { | 367 | { |
368 | if ( !mHasRecurrenceID ) | 368 | if ( !mHasRecurrenceID ) |
369 | return true; | 369 | return true; |
370 | int secs = mDtStart.secsTo( dtDue() ); | 370 | int secs = mDtStart.secsTo( dtDue() ); |
371 | bool ok; | 371 | bool ok; |
372 | qDebug("--------------------setRecurDates() "); | 372 | qDebug("T:setRecurDates() "); |
373 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 373 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
374 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); | 374 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); |
375 | if ( ok ) { | 375 | if ( ok ) { |
376 | mRecurrenceID = next; | 376 | mRecurrenceID = next; |
377 | mDtStart = next; | 377 | mDtStart = next; |
378 | setDtDue( next.addSecs( secs ) ); | 378 | setDtDue( next.addSecs( secs ) ); |
379 | if ( QDateTime::currentDateTime() > next) | 379 | if ( QDateTime::currentDateTime() > next) |
380 | return false; | 380 | return false; |
381 | } else { | 381 | } else { |
382 | setHasRecurrenceID( false ); | 382 | setHasRecurrenceID( false ); |
383 | recurrence()->unsetRecurs(); | 383 | recurrence()->unsetRecurs(); |
384 | } | 384 | } |
385 | return true; | 385 | return true; |
386 | } | 386 | } |
387 | void Todo::setPercentComplete(int v) | 387 | void Todo::setPercentComplete(int v) |
388 | { | 388 | { |
389 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { | 389 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { |
390 | if ( !setRecurDates() ) | 390 | if ( !setRecurDates() ) |
391 | v = 0; | 391 | v = 0; |
392 | } | 392 | } |
393 | mPercentComplete = v; | 393 | mPercentComplete = v; |
394 | if ( v != 100 ) | 394 | if ( v != 100 ) |
395 | mHasCompletedDate = false; | 395 | mHasCompletedDate = false; |
396 | updated(); | 396 | updated(); |
397 | } | 397 | } |
398 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | 398 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const |
399 | { | 399 | { |
400 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { | 400 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { |
401 | *ok = false; | 401 | *ok = false; |
402 | return QDateTime (); | 402 | return QDateTime (); |
403 | } | 403 | } |
404 | QDateTime incidenceStart; | 404 | QDateTime incidenceStart; |
405 | incidenceStart = dtDue(); | 405 | incidenceStart = dtDue(); |
406 | bool enabled = false; | 406 | bool enabled = false; |
407 | Alarm* alarm; | 407 | Alarm* alarm; |
408 | int off = 0; | 408 | int off = 0; |
409 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 409 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
410 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 410 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
411 | // *ok = false; | 411 | // *ok = false; |
412 | // return incidenceStart; | 412 | // return incidenceStart; |
413 | // } | 413 | // } |
414 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 414 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
415 | if (alarm->enabled()) { | 415 | if (alarm->enabled()) { |
416 | if ( alarm->hasTime () ) { | 416 | if ( alarm->hasTime () ) { |
417 | if ( alarm->time() < alarmStart ) { | 417 | if ( alarm->time() < alarmStart ) { |
418 | alarmStart = alarm->time(); | 418 | alarmStart = alarm->time(); |
419 | enabled = true; | 419 | enabled = true; |
420 | off = alarmStart.secsTo( incidenceStart ); | 420 | off = alarmStart.secsTo( incidenceStart ); |
421 | } | 421 | } |
422 | 422 | ||
423 | } else { | 423 | } else { |
424 | int secs = alarm->startOffset().asSeconds(); | 424 | int secs = alarm->startOffset().asSeconds(); |
425 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 425 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
426 | alarmStart = incidenceStart.addSecs( secs ); | 426 | alarmStart = incidenceStart.addSecs( secs ); |
427 | enabled = true; | 427 | enabled = true; |
428 | off = -secs; | 428 | off = -secs; |
429 | } | 429 | } |
430 | } | 430 | } |
431 | } | 431 | } |
432 | } | 432 | } |
433 | if ( enabled ) { | 433 | if ( enabled ) { |
434 | if ( alarmStart > QDateTime::currentDateTime() ) { | 434 | if ( alarmStart > QDateTime::currentDateTime() ) { |
435 | *ok = true; | 435 | *ok = true; |
436 | * offset = off; | 436 | * offset = off; |
437 | return alarmStart; | 437 | return alarmStart; |
438 | } | 438 | } |
439 | } | 439 | } |
440 | *ok = false; | 440 | *ok = false; |
441 | return QDateTime (); | 441 | return QDateTime (); |
442 | 442 | ||
443 | } | 443 | } |
444 | 444 | ||
445 | void Todo::checkSetCompletedFalse() | 445 | void Todo::checkSetCompletedFalse() |
446 | { | 446 | { |
447 | if ( !hasRecurrenceID() ) { | 447 | if ( !hasRecurrenceID() ) { |
448 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); | 448 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); |
449 | } | 449 | } |
450 | // qDebug("Todo::checkSetCompletedFalse()"); | 450 | // qDebug("Todo::checkSetCompletedFalse()"); |
451 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 451 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
452 | if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) { | 452 | if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) { |
453 | qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 453 | qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
454 | setCompleted( false ); | 454 | setCompleted( false ); |
455 | qDebug("Todo::checkSetCompletedFalse++++++++++++++++++++++++++++ "); | 455 | qDebug("Todo::checkSetCompletedFalse "); |
456 | } | 456 | } |
457 | } | 457 | } |