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 | |||
@@ -1021,385 +1021,385 @@ Journal *ICalFormatImpl::readJournal(icalcomponent *vjournal) | |||
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); |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 0684af2..708ee6b 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -24,388 +24,396 @@ | |||
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; |
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index 0d9c3f4..cc3088a 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -3,342 +3,354 @@ | |||
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 | |||
@@ -180,278 +180,278 @@ QDateTime Todo::dtDue() const | |||
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 | } |