author | zautrix <zautrix> | 2005-02-13 17:05:02 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-13 17:05:02 (UTC) |
commit | 293271fe9e6a9061da329183f8f488d79580f7da (patch) (unidiff) | |
tree | 3a0234eabdf58440a484e960b5eef912a63d0056 /libkcal | |
parent | 0a33f91e166747406ca2ccb5819881feeecfdb40 (diff) | |
download | kdepimpi-293271fe9e6a9061da329183f8f488d79580f7da.zip kdepimpi-293271fe9e6a9061da329183f8f488d79580f7da.tar.gz kdepimpi-293271fe9e6a9061da329183f8f488d79580f7da.tar.bz2 |
todo rec fixes
-rw-r--r-- | libkcal/incidence.cpp | 9 | ||||
-rw-r--r-- | libkcal/incidence.h | 5 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 1 | ||||
-rw-r--r-- | libkcal/incidencebase.h | 4 | ||||
-rw-r--r-- | libkcal/todo.cpp | 51 | ||||
-rw-r--r-- | libkcal/todo.h | 2 |
6 files changed, 64 insertions, 8 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index dbc159c..0684af2 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -626,24 +626,33 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | |||
626 | int year = incidenceStart.date().year(); | 626 | int year = incidenceStart.date().year(); |
627 | // workaround for bug in recurrence | 627 | // workaround for bug in recurrence |
628 | if ( count == 100 || year < 1000 || year > 5000 ) { | 628 | if ( count == 100 || year < 1000 || year > 5000 ) { |
629 | return QDateTime (); | 629 | return QDateTime (); |
630 | } | 630 | } |
631 | incidenceStart = incidenceStart.addSecs( 1 ); | 631 | incidenceStart = incidenceStart.addSecs( 1 ); |
632 | } | 632 | } |
633 | } | 633 | } |
634 | } else { | 634 | } else { |
635 | return QDateTime (); | 635 | return QDateTime (); |
636 | } | 636 | } |
637 | } else { | 637 | } else { |
638 | if ( hasStartDate () ) { | 638 | if ( hasStartDate () ) { |
639 | incidenceStart = dtStart(); | 639 | incidenceStart = dtStart(); |
640 | } | 640 | } |
641 | if ( type() =="Todo" ) { | 641 | if ( type() =="Todo" ) { |
642 | if ( ((Todo*)this)->hasDueDate() ) | 642 | if ( ((Todo*)this)->hasDueDate() ) |
643 | incidenceStart = ((Todo*)this)->dtDue(); | 643 | incidenceStart = ((Todo*)this)->dtDue(); |
644 | } | 644 | } |
645 | } | 645 | } |
646 | if ( incidenceStart > dt ) | 646 | if ( incidenceStart > dt ) |
647 | *ok = true; | 647 | *ok = true; |
648 | return incidenceStart; | 648 | return incidenceStart; |
649 | } | 649 | } |
650 | QDateTime Incidence::dtStart() const | ||
651 | { | ||
652 | if ( doesRecur() ) { | ||
653 | if ( type() == "Todo" ) { | ||
654 | ((Todo*)this)->checkSetCompletedFalse(); | ||
655 | } | ||
656 | } | ||
657 | return mDtStart; | ||
658 | } | ||
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index 38d2aaa..0ae9656 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -248,60 +248,61 @@ class Incidence : public IncidenceBase | |||
248 | Recurrence *recurrence() const; | 248 | Recurrence *recurrence() const; |
249 | void setRecurrence(Recurrence * r); | 249 | void setRecurrence(Recurrence * r); |
250 | /** | 250 | /** |
251 | Forward to Recurrence::doesRecur(). | 251 | Forward to Recurrence::doesRecur(). |
252 | */ | 252 | */ |
253 | ushort doesRecur() const; | 253 | ushort doesRecur() const; |
254 | 254 | ||
255 | /** set the event's/todo's location. Do _not_ use it with journal */ | 255 | /** set the event's/todo's location. Do _not_ use it with journal */ |
256 | void setLocation(const QString &location); | 256 | void setLocation(const QString &location); |
257 | /** return the event's/todo's location. Do _not_ use it with journal */ | 257 | /** return the event's/todo's location. Do _not_ use it with journal */ |
258 | QString location() const; | 258 | QString location() const; |
259 | /** returns TRUE or FALSE depending on whether the todo has a start date */ | 259 | /** returns TRUE or FALSE depending on whether the todo has a start date */ |
260 | bool hasStartDate() const; | 260 | bool hasStartDate() const; |
261 | /** sets the event's hasStartDate value. */ | 261 | /** sets the event's hasStartDate value. */ |
262 | void setHasStartDate(bool f); | 262 | void setHasStartDate(bool f); |
263 | QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; | 263 | QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; |
264 | bool cancelled() const; | 264 | bool cancelled() const; |
265 | void setCancelled( bool b ); | 265 | void setCancelled( bool b ); |
266 | 266 | ||
267 | bool hasRecurrenceID() const; | 267 | bool hasRecurrenceID() const; |
268 | void setHasRecurrenceID( bool b ); | 268 | void setHasRecurrenceID( bool b ); |
269 | 269 | ||
270 | void setRecurrenceID(QDateTime); | 270 | void setRecurrenceID(QDateTime); |
271 | QDateTime recurrenceID () const; | 271 | QDateTime recurrenceID () const; |
272 | QDateTime dtStart() const; | ||
272 | 273 | ||
273 | 274 | ||
274 | protected: | 275 | protected: |
275 | QPtrList<Alarm> mAlarms; | 276 | QPtrList<Alarm> mAlarms; |
276 | QPtrList<Incidence> mRelations; | 277 | QPtrList<Incidence> mRelations; |
278 | QDateTime mRecurrenceID; | ||
279 | bool mHasRecurrenceID; | ||
277 | private: | 280 | private: |
278 | int mRevision; | 281 | int mRevision; |
279 | bool mCancelled; | 282 | bool mCancelled; |
280 | 283 | ||
281 | // base components of jounal, event and todo | 284 | // base components of jounal, event and todo |
282 | QDateTime mRecurrenceID; | ||
283 | bool mHasRecurrenceID; | ||
284 | QDateTime mCreated; | 285 | QDateTime mCreated; |
285 | QString mDescription; | 286 | QString mDescription; |
286 | QString mSummary; | 287 | QString mSummary; |
287 | QStringList mCategories; | 288 | QStringList mCategories; |
288 | Incidence *mRelatedTo; | 289 | Incidence *mRelatedTo; |
289 | QString mRelatedToUid; | 290 | QString mRelatedToUid; |
290 | DateList mExDates; | 291 | DateList mExDates; |
291 | QPtrList<Attachment> mAttachments; | 292 | QPtrList<Attachment> mAttachments; |
292 | QStringList mResources; | 293 | QStringList mResources; |
293 | bool mHasStartDate; // if todo has associated start date | 294 | bool mHasStartDate; // if todo has associated start date |
294 | 295 | ||
295 | int mSecrecy; | 296 | int mSecrecy; |
296 | int mPriority; // 1 = highest, 2 = less, etc. | 297 | int mPriority; // 1 = highest, 2 = less, etc. |
297 | 298 | ||
298 | //QPtrList<Alarm> mAlarms; | 299 | //QPtrList<Alarm> mAlarms; |
299 | Recurrence *mRecurrence; | 300 | Recurrence *mRecurrence; |
300 | 301 | ||
301 | QString mLocation; | 302 | QString mLocation; |
302 | }; | 303 | }; |
303 | 304 | ||
304 | bool operator==( const Incidence&, const Incidence& ); | 305 | bool operator==( const Incidence&, const Incidence& ); |
305 | 306 | ||
306 | } | 307 | } |
307 | 308 | ||
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 7525a4a..51f2e9d 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -158,48 +158,49 @@ void IncidenceBase::setOrganizer(const QString &o) | |||
158 | mOrganizer = o; | 158 | mOrganizer = o; |
159 | if (mOrganizer.left(7).upper() == "MAILTO:") | 159 | if (mOrganizer.left(7).upper() == "MAILTO:") |
160 | mOrganizer = mOrganizer.remove(0,7); | 160 | mOrganizer = mOrganizer.remove(0,7); |
161 | 161 | ||
162 | updated(); | 162 | updated(); |
163 | } | 163 | } |
164 | 164 | ||
165 | QString IncidenceBase::organizer() const | 165 | QString IncidenceBase::organizer() const |
166 | { | 166 | { |
167 | return mOrganizer; | 167 | return mOrganizer; |
168 | } | 168 | } |
169 | 169 | ||
170 | void IncidenceBase::setReadOnly( bool readOnly ) | 170 | void IncidenceBase::setReadOnly( bool readOnly ) |
171 | { | 171 | { |
172 | mReadOnly = readOnly; | 172 | mReadOnly = readOnly; |
173 | } | 173 | } |
174 | 174 | ||
175 | void IncidenceBase::setDtStart(const QDateTime &dtStart) | 175 | void IncidenceBase::setDtStart(const QDateTime &dtStart) |
176 | { | 176 | { |
177 | // if (mReadOnly) return; | 177 | // if (mReadOnly) return; |
178 | mDtStart = getEvenTime(dtStart); | 178 | mDtStart = getEvenTime(dtStart); |
179 | updated(); | 179 | updated(); |
180 | } | 180 | } |
181 | 181 | ||
182 | |||
182 | QDateTime IncidenceBase::dtStart() const | 183 | QDateTime IncidenceBase::dtStart() const |
183 | { | 184 | { |
184 | return mDtStart; | 185 | return mDtStart; |
185 | } | 186 | } |
186 | 187 | ||
187 | QString IncidenceBase::dtStartTimeStr() const | 188 | QString IncidenceBase::dtStartTimeStr() const |
188 | { | 189 | { |
189 | return KGlobal::locale()->formatTime(dtStart().time()); | 190 | return KGlobal::locale()->formatTime(dtStart().time()); |
190 | } | 191 | } |
191 | 192 | ||
192 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const | 193 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const |
193 | { | 194 | { |
194 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); | 195 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); |
195 | } | 196 | } |
196 | 197 | ||
197 | QString IncidenceBase::dtStartStr(bool shortfmt) const | 198 | QString IncidenceBase::dtStartStr(bool shortfmt) const |
198 | { | 199 | { |
199 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); | 200 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); |
200 | } | 201 | } |
201 | 202 | ||
202 | 203 | ||
203 | bool IncidenceBase::doesFloat() const | 204 | bool IncidenceBase::doesFloat() const |
204 | { | 205 | { |
205 | return mFloats; | 206 | return mFloats; |
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index f9a6558..8624786 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h | |||
@@ -53,49 +53,49 @@ class IncidenceBase : public CustomProperties | |||
53 | virtual QCString type() const = 0; | 53 | virtual QCString type() const = 0; |
54 | 54 | ||
55 | /** Set the unique id for the event */ | 55 | /** Set the unique id for the event */ |
56 | void setUid(const QString &); | 56 | void setUid(const QString &); |
57 | /** Return the unique id for the event */ | 57 | /** Return the unique id for the event */ |
58 | QString uid() const; | 58 | QString uid() const; |
59 | 59 | ||
60 | /** Sets the time the incidence was last modified. */ | 60 | /** Sets the time the incidence was last modified. */ |
61 | void setLastModified(const QDateTime &lm); | 61 | void setLastModified(const QDateTime &lm); |
62 | /** Return the time the incidence was last modified. */ | 62 | /** Return the time the incidence was last modified. */ |
63 | QDateTime lastModified() const; | 63 | QDateTime lastModified() const; |
64 | 64 | ||
65 | /** sets the organizer for the event */ | 65 | /** sets the organizer for the event */ |
66 | void setOrganizer(const QString &o); | 66 | void setOrganizer(const QString &o); |
67 | QString organizer() const; | 67 | QString organizer() const; |
68 | 68 | ||
69 | /** Set readonly status. */ | 69 | /** Set readonly status. */ |
70 | virtual void setReadOnly( bool ); | 70 | virtual void setReadOnly( bool ); |
71 | /** Return if the object is read-only. */ | 71 | /** Return if the object is read-only. */ |
72 | bool isReadOnly() const { return mReadOnly; } | 72 | bool isReadOnly() const { return mReadOnly; } |
73 | 73 | ||
74 | /** for setting the event's starting date/time with a QDateTime. */ | 74 | /** for setting the event's starting date/time with a QDateTime. */ |
75 | virtual void setDtStart(const QDateTime &dtStart); | 75 | virtual void setDtStart(const QDateTime &dtStart); |
76 | /** returns an event's starting date/time as a QDateTime. */ | 76 | /** returns an event's starting date/time as a QDateTime. */ |
77 | QDateTime dtStart() const; | 77 | virtual QDateTime dtStart() const; |
78 | /** returns an event's starting time as a string formatted according to the | 78 | /** returns an event's starting time as a string formatted according to the |
79 | users locale settings */ | 79 | users locale settings */ |
80 | QString dtStartTimeStr() const; | 80 | QString dtStartTimeStr() const; |
81 | /** returns an event's starting date as a string formatted according to the | 81 | /** returns an event's starting date as a string formatted according to the |
82 | users locale settings */ | 82 | users locale settings */ |
83 | QString dtStartDateStr(bool shortfmt=true) const; | 83 | QString dtStartDateStr(bool shortfmt=true) const; |
84 | /** returns an event's starting date and time as a string formatted according | 84 | /** returns an event's starting date and time as a string formatted according |
85 | to the users locale settings */ | 85 | to the users locale settings */ |
86 | QString dtStartStr(bool shortfmt=true) const; | 86 | QString dtStartStr(bool shortfmt=true) const; |
87 | 87 | ||
88 | virtual void setDuration(int seconds); | 88 | virtual void setDuration(int seconds); |
89 | int duration() const; | 89 | int duration() const; |
90 | void setHasDuration(bool); | 90 | void setHasDuration(bool); |
91 | bool hasDuration() const; | 91 | bool hasDuration() const; |
92 | 92 | ||
93 | /** Return true or false depending on whether the incidence "floats," | 93 | /** Return true or false depending on whether the incidence "floats," |
94 | * i.e. has a date but no time attached to it. */ | 94 | * i.e. has a date but no time attached to it. */ |
95 | bool doesFloat() const; | 95 | bool doesFloat() const; |
96 | /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ | 96 | /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ |
97 | void setFloats(bool f); | 97 | void setFloats(bool f); |
98 | 98 | ||
99 | /** | 99 | /** |
100 | Add Attendee to this incidence. IncidenceBase takes ownership of the | 100 | Add Attendee to this incidence. IncidenceBase takes ownership of the |
101 | Attendee object. | 101 | Attendee object. |
@@ -120,53 +120,53 @@ class IncidenceBase : public CustomProperties | |||
120 | void setSyncStatus(int stat); | 120 | void setSyncStatus(int stat); |
121 | /** Return synchronisation status. */ | 121 | /** Return synchronisation status. */ |
122 | int syncStatus() const; | 122 | int syncStatus() const; |
123 | 123 | ||
124 | /** Set Pilot Id. */ | 124 | /** Set Pilot Id. */ |
125 | void setPilotId(int id); | 125 | void setPilotId(int id); |
126 | /** Return Pilot Id. */ | 126 | /** Return Pilot Id. */ |
127 | int pilotId() const; | 127 | int pilotId() const; |
128 | 128 | ||
129 | void setTempSyncStat(int id); | 129 | void setTempSyncStat(int id); |
130 | int tempSyncStat() const; | 130 | int tempSyncStat() const; |
131 | void setIDStr( const QString & ); | 131 | void setIDStr( const QString & ); |
132 | QString IDStr() const; | 132 | QString IDStr() const; |
133 | void setID( const QString &, const QString & ); | 133 | void setID( const QString &, const QString & ); |
134 | QString getID( const QString & ); | 134 | QString getID( const QString & ); |
135 | void setCsum( const QString &, const QString & ); | 135 | void setCsum( const QString &, const QString & ); |
136 | QString getCsum( const QString & ); | 136 | QString getCsum( const QString & ); |
137 | void removeID(const QString &); | 137 | void removeID(const QString &); |
138 | 138 | ||
139 | void registerObserver( Observer * ); | 139 | void registerObserver( Observer * ); |
140 | void unRegisterObserver( Observer * ); | 140 | void unRegisterObserver( Observer * ); |
141 | void updated(); | 141 | void updated(); |
142 | 142 | ||
143 | protected: | 143 | protected: |
144 | QDateTime mDtStart; | ||
144 | bool mReadOnly; | 145 | bool mReadOnly; |
145 | QDateTime getEvenTime( QDateTime ); | 146 | QDateTime getEvenTime( QDateTime ); |
146 | 147 | ||
147 | private: | 148 | private: |
148 | // base components | 149 | // base components |
149 | QDateTime mDtStart; | ||
150 | QString mOrganizer; | 150 | QString mOrganizer; |
151 | QString mUid; | 151 | QString mUid; |
152 | QDateTime mLastModified; | 152 | QDateTime mLastModified; |
153 | QPtrList<Attendee> mAttendees; | 153 | QPtrList<Attendee> mAttendees; |
154 | 154 | ||
155 | bool mFloats; | 155 | bool mFloats; |
156 | 156 | ||
157 | int mDuration; | 157 | int mDuration; |
158 | bool mHasDuration; | 158 | bool mHasDuration; |
159 | QString mExternalId; | 159 | QString mExternalId; |
160 | int mTempSyncStat; | 160 | int mTempSyncStat; |
161 | 161 | ||
162 | // PILOT SYNCHRONIZATION STUFF | 162 | // PILOT SYNCHRONIZATION STUFF |
163 | int mPilotId; // unique id for pilot sync | 163 | int mPilotId; // unique id for pilot sync |
164 | int mSyncStatus; // status (for sync) | 164 | int mSyncStatus; // status (for sync) |
165 | 165 | ||
166 | QPtrList<Observer> mObservers; | 166 | QPtrList<Observer> mObservers; |
167 | }; | 167 | }; |
168 | 168 | ||
169 | bool operator==( const IncidenceBase&, const IncidenceBase& ); | 169 | bool operator==( const IncidenceBase&, const IncidenceBase& ); |
170 | } | 170 | } |
171 | 171 | ||
172 | #endif | 172 | #endif |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 9c04a7e..1f54c2f 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -290,97 +290,127 @@ QString Todo::statusStr() const | |||
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) return true; | 314 | if (mPercentComplete == 100) { |
315 | else return false; | 315 | return true; |
316 | } | ||
317 | else return false; | ||
316 | } | 318 | } |
317 | 319 | ||
318 | void Todo::setCompleted(bool completed) | 320 | void Todo::setCompleted(bool completed) |
319 | { | 321 | { |
322 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { | ||
323 | if ( !setRecurDates() ) | ||
324 | completed = false; | ||
325 | } | ||
320 | if (completed) mPercentComplete = 100; | 326 | if (completed) mPercentComplete = 100; |
321 | else { | 327 | else { |
322 | mPercentComplete = 0; | 328 | mPercentComplete = 0; |
323 | mHasCompletedDate = false; | 329 | mHasCompletedDate = false; |
324 | } | 330 | } |
325 | updated(); | 331 | updated(); |
326 | } | 332 | } |
327 | 333 | ||
328 | QDateTime Todo::completed() const | 334 | QDateTime Todo::completed() const |
329 | { | 335 | { |
330 | return mCompleted; | 336 | return mCompleted; |
331 | } | 337 | } |
332 | 338 | ||
333 | QString Todo::completedStr( bool shortF ) const | 339 | QString Todo::completedStr( bool shortF ) const |
334 | { | 340 | { |
335 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); | 341 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); |
336 | } | 342 | } |
337 | 343 | ||
338 | void Todo::setCompleted(const QDateTime &completed) | 344 | void Todo::setCompleted(const QDateTime &completed) |
339 | { | 345 | { |
340 | //qDebug("Todo::setCompleted "); | 346 | //qDebug("Todo::setCompleted "); |
341 | if ( mHasCompletedDate ) { | 347 | if ( mHasCompletedDate ) { |
342 | // qDebug("has completed data - return "); | 348 | // qDebug("has completed data - return "); |
343 | return; | 349 | return; |
344 | } | 350 | } |
345 | mHasCompletedDate = true; | 351 | mHasCompletedDate = true; |
346 | mPercentComplete = 100; | 352 | mPercentComplete = 100; |
347 | mCompleted = getEvenTime(completed); | 353 | mCompleted = getEvenTime(completed); |
348 | updated(); | 354 | updated(); |
349 | } | 355 | } |
350 | 356 | ||
351 | bool Todo::hasCompletedDate() const | 357 | bool Todo::hasCompletedDate() const |
352 | { | 358 | { |
353 | return mHasCompletedDate; | 359 | return mHasCompletedDate; |
354 | } | 360 | } |
355 | 361 | ||
356 | int Todo::percentComplete() const | 362 | int Todo::percentComplete() const |
357 | { | 363 | { |
358 | return mPercentComplete; | 364 | return mPercentComplete; |
359 | } | 365 | } |
360 | 366 | bool Todo::setRecurDates() | |
361 | void Todo::setPercentComplete(int v) | ||
362 | { | 367 | { |
368 | if ( !mHasRecurrenceID ) | ||
369 | return true; | ||
370 | int secs = mDtStart.secsTo( dtDue() ); | ||
371 | bool ok; | ||
372 | qDebug("--------------------setRecurDates() "); | ||
373 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | ||
374 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); | ||
375 | if ( ok ) { | ||
376 | mRecurrenceID = next; | ||
377 | mDtStart = next; | ||
378 | setDtDue( next.addSecs( secs ) ); | ||
379 | if ( QDateTime::currentDateTime() > next) | ||
380 | return false; | ||
381 | } else { | ||
382 | setHasRecurrenceID( false ); | ||
383 | recurrence()->unsetRecurs(); | ||
384 | } | ||
385 | return true; | ||
386 | } | ||
387 | void Todo::setPercentComplete(int v) | ||
388 | { | ||
389 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { | ||
390 | if ( !setRecurDates() ) | ||
391 | v = 0; | ||
392 | } | ||
363 | mPercentComplete = v; | 393 | mPercentComplete = v; |
364 | if ( v != 100 ) | 394 | if ( v != 100 ) |
365 | mHasCompletedDate = false; | 395 | mHasCompletedDate = false; |
366 | updated(); | 396 | updated(); |
367 | } | 397 | } |
368 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | 398 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const |
369 | { | 399 | { |
370 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { | 400 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { |
371 | *ok = false; | 401 | *ok = false; |
372 | return QDateTime (); | 402 | return QDateTime (); |
373 | } | 403 | } |
374 | QDateTime incidenceStart; | 404 | QDateTime incidenceStart; |
375 | incidenceStart = dtDue(); | 405 | incidenceStart = dtDue(); |
376 | bool enabled = false; | 406 | bool enabled = false; |
377 | Alarm* alarm; | 407 | Alarm* alarm; |
378 | int off = 0; | 408 | int off = 0; |
379 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 409 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
380 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 410 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
381 | // *ok = false; | 411 | // *ok = false; |
382 | // return incidenceStart; | 412 | // return incidenceStart; |
383 | // } | 413 | // } |
384 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 414 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
385 | if (alarm->enabled()) { | 415 | if (alarm->enabled()) { |
386 | if ( alarm->hasTime () ) { | 416 | if ( alarm->hasTime () ) { |
@@ -391,24 +421,37 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | |||
391 | } | 421 | } |
392 | 422 | ||
393 | } else { | 423 | } else { |
394 | int secs = alarm->startOffset().asSeconds(); | 424 | int secs = alarm->startOffset().asSeconds(); |
395 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 425 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
396 | alarmStart = incidenceStart.addSecs( secs ); | 426 | alarmStart = incidenceStart.addSecs( secs ); |
397 | enabled = true; | 427 | enabled = true; |
398 | off = -secs; | 428 | off = -secs; |
399 | } | 429 | } |
400 | } | 430 | } |
401 | } | 431 | } |
402 | } | 432 | } |
403 | if ( enabled ) { | 433 | if ( enabled ) { |
404 | if ( alarmStart > QDateTime::currentDateTime() ) { | 434 | if ( alarmStart > QDateTime::currentDateTime() ) { |
405 | *ok = true; | 435 | *ok = true; |
406 | * offset = off; | 436 | * offset = off; |
407 | return alarmStart; | 437 | return alarmStart; |
408 | } | 438 | } |
409 | } | 439 | } |
410 | *ok = false; | 440 | *ok = false; |
411 | return QDateTime (); | 441 | return QDateTime (); |
412 | 442 | ||
413 | } | 443 | } |
414 | 444 | ||
445 | void Todo::checkSetCompletedFalse() | ||
446 | { | ||
447 | if ( !hasRecurrenceID() ) { | ||
448 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); | ||
449 | } | ||
450 | // qDebug("Todo::checkSetCompletedFalse()"); | ||
451 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | ||
452 | if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) { | ||
453 | qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | ||
454 | setCompleted( false ); | ||
455 | qDebug("Todo::checkSetCompletedFalse++++++++++++++++++++++++++++ "); | ||
456 | } | ||
457 | } | ||
diff --git a/libkcal/todo.h b/libkcal/todo.h index 137b252..a22d4b7 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -91,44 +91,46 @@ class Todo : public Incidence | |||
91 | bool isCompleted() const; | 91 | bool isCompleted() const; |
92 | /** set completed state of this todo */ | 92 | /** set completed state of this todo */ |
93 | void setCompleted(bool); | 93 | void setCompleted(bool); |
94 | 94 | ||
95 | /** | 95 | /** |
96 | Return how many percent of the task are completed. Returns a value | 96 | Return how many percent of the task are completed. Returns a value |
97 | between 0 and 100. | 97 | between 0 and 100. |
98 | */ | 98 | */ |
99 | int percentComplete() const; | 99 | int percentComplete() const; |
100 | /** | 100 | /** |
101 | Set how many percent of the task are completed. Valid values are in the | 101 | Set how many percent of the task are completed. Valid values are in the |
102 | range from 0 to 100. | 102 | range from 0 to 100. |
103 | */ | 103 | */ |
104 | void setPercentComplete(int); | 104 | void setPercentComplete(int); |
105 | 105 | ||
106 | /** return date and time when todo was completed */ | 106 | /** return date and time when todo was completed */ |
107 | QDateTime completed() const; | 107 | QDateTime completed() const; |
108 | QString completedStr(bool shortF = true) const; | 108 | QString completedStr(bool shortF = true) const; |
109 | /** set date and time of completion */ | 109 | /** set date and time of completion */ |
110 | void setCompleted(const QDateTime &completed); | 110 | void setCompleted(const QDateTime &completed); |
111 | 111 | ||
112 | /** Return true, if todo has a date associated with completion */ | 112 | /** Return true, if todo has a date associated with completion */ |
113 | bool hasCompletedDate() const; | 113 | bool hasCompletedDate() const; |
114 | bool contains ( Todo*); | 114 | bool contains ( Todo*); |
115 | void checkSetCompletedFalse(); | ||
116 | bool setRecurDates(); | ||
115 | 117 | ||
116 | private: | 118 | private: |
117 | bool accept(Visitor &v) { return v.visit(this); } | 119 | bool accept(Visitor &v) { return v.visit(this); } |
118 | 120 | ||
119 | QDateTime mDtDue; // due date of todo | 121 | QDateTime mDtDue; // due date of todo |
120 | 122 | ||
121 | bool mHasDueDate; // if todo has associated due date | 123 | bool mHasDueDate; // if todo has associated due date |
122 | 124 | ||
123 | // int mStatus; // confirmed/delegated/tentative/etc | 125 | // int mStatus; // confirmed/delegated/tentative/etc |
124 | 126 | ||
125 | QDateTime mCompleted; | 127 | QDateTime mCompleted; |
126 | bool mHasCompletedDate; | 128 | bool mHasCompletedDate; |
127 | 129 | ||
128 | int mPercentComplete; | 130 | int mPercentComplete; |
129 | }; | 131 | }; |
130 | 132 | ||
131 | bool operator==( const Todo&, const Todo& ); | 133 | bool operator==( const Todo&, const Todo& ); |
132 | } | 134 | } |
133 | 135 | ||
134 | #endif | 136 | #endif |