summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-02-13 19:07:45 (UTC)
committer zautrix <zautrix>2005-02-13 19:07:45 (UTC)
commit7bd83e913399b8be68a7d37e8f02118ec9eab90e (patch) (unidiff)
tree284d1592687ea4d3e0c220fafd289a702718dee4 /libkcal
parent293271fe9e6a9061da329183f8f488d79580f7da (diff)
downloadkdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.zip
kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.gz
kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.bz2
todo fixi
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/icalformatimpl.cpp2
-rw-r--r--libkcal/incidence.cpp16
-rw-r--r--libkcal/kincidenceformatter.cpp12
-rw-r--r--libkcal/todo.cpp4
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
@@ -1165,97 +1165,97 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence)
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;
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 0684af2..708ee6b 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -168,100 +168,108 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
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
209Incidence* Incidence::recreateCloneException( QDate d ) 209Incidence* 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
224void Incidence::recreate() 232void 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
235void Incidence::setReadOnly( bool readOnly ) 243void 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
241void Incidence::setCreated(QDateTime created) 249void 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
247QDateTime Incidence::created() const 255QDateTime Incidence::created() const
248{ 256{
249 return mCreated; 257 return mCreated;
250} 258}
251 259
252void Incidence::setRevision(int rev) 260void 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
260int Incidence::revision() const 268int Incidence::revision() const
261{ 269{
262 return mRevision; 270 return mRevision;
263} 271}
264 272
265void Incidence::setDtStart(const QDateTime &dtStart) 273void Incidence::setDtStart(const QDateTime &dtStart)
266{ 274{
267 275
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index 0d9c3f4..cc3088a 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -147,96 +147,108 @@ void KIncidenceFormatter::setEvent(Event *event)
147 formatReadOnly(event); 147 formatReadOnly(event);
148 formatAttendees(event); 148 formatAttendees(event);
149 149
150 150
151} 151}
152 152
153void KIncidenceFormatter::setTodo(Todo *event ) 153void 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
215void KIncidenceFormatter::setJournal(Journal* ) 227void KIncidenceFormatter::setJournal(Journal* )
216{ 228{
217 229
218} 230}
219 231
220void KIncidenceFormatter::formatCategories(Incidence *event) 232void 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}
227void KIncidenceFormatter::addTag(const QString & tag,const QString & text) 239void 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>";
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 1f54c2f..39d16b6 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -324,134 +324,134 @@ void Todo::setCompleted(bool completed)
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
334QDateTime Todo::completed() const 334QDateTime Todo::completed() const
335{ 335{
336 return mCompleted; 336 return mCompleted;
337} 337}
338 338
339QString Todo::completedStr( bool shortF ) const 339QString 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
344void Todo::setCompleted(const QDateTime &completed) 344void 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
357bool Todo::hasCompletedDate() const 357bool Todo::hasCompletedDate() const
358{ 358{
359 return mHasCompletedDate; 359 return mHasCompletedDate;
360} 360}
361 361
362int Todo::percentComplete() const 362int Todo::percentComplete() const
363{ 363{
364 return mPercentComplete; 364 return mPercentComplete;
365} 365}
366bool Todo::setRecurDates() 366bool 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}
387void Todo::setPercentComplete(int v) 387void 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}
398QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const 398QDateTime 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
445void Todo::checkSetCompletedFalse() 445void 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}