-rw-r--r-- | libkcal/incidence.h | 2 | ||||
-rw-r--r-- | libkcal/todo.cpp | 32 | ||||
-rw-r--r-- | libkcal/todo.h | 12 |
3 files changed, 44 insertions, 2 deletions
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index 1807bc4..de2a381 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -265,8 +265,9 @@ class Incidence : public IncidenceBase | |||
265 | void setCancelled( bool b ); | 265 | void setCancelled( bool b ); |
266 | 266 | ||
267 | protected: | 267 | protected: |
268 | QPtrList<Alarm> mAlarms; | 268 | QPtrList<Alarm> mAlarms; |
269 | QPtrList<Incidence> mRelations; | ||
269 | private: | 270 | private: |
270 | int mRevision; | 271 | int mRevision; |
271 | bool mCancelled; | 272 | bool mCancelled; |
272 | 273 | ||
@@ -276,9 +277,8 @@ protected: | |||
276 | QString mSummary; | 277 | QString mSummary; |
277 | QStringList mCategories; | 278 | QStringList mCategories; |
278 | Incidence *mRelatedTo; | 279 | Incidence *mRelatedTo; |
279 | QString mRelatedToUid; | 280 | QString mRelatedToUid; |
280 | QPtrList<Incidence> mRelations; | ||
281 | DateList mExDates; | 281 | DateList mExDates; |
282 | QPtrList<Attachment> mAttachments; | 282 | QPtrList<Attachment> mAttachments; |
283 | QStringList mResources; | 283 | QStringList mResources; |
284 | bool mHasStartDate; // if todo has associated start date | 284 | bool mHasStartDate; // if todo has associated start date |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 7f1de78..d81a68f 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -192,9 +192,39 @@ QString Todo::dtDueDateStr(bool shortfmt) const | |||
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 | 196 | // retval 0 : no found | |
197 | // 1 : due for date found | ||
198 | // 2 : overdue for date found | ||
199 | int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) | ||
200 | { | ||
201 | int retval = 0; | ||
202 | if ( isCompleted() ) | ||
203 | return 0; | ||
204 | if ( hasDueDate() ) { | ||
205 | if ( dtDue().date() < date ) | ||
206 | return 2; | ||
207 | // we do not return, because we may find an overdue sub todo | ||
208 | if ( dtDue().date() == date ) | ||
209 | retval = 1; | ||
210 | } | ||
211 | if ( checkSubtodos ) { | ||
212 | Incidence *aTodo; | ||
213 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | ||
214 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); | ||
215 | if ( ret == 2 ) | ||
216 | return 2; | ||
217 | if ( ret == 1) | ||
218 | retval = 1; | ||
219 | } | ||
220 | } | ||
221 | return retval; | ||
222 | } | ||
223 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true | ||
224 | { | ||
225 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); | ||
226 | } | ||
197 | bool Todo::hasDueDate() const | 227 | bool Todo::hasDueDate() const |
198 | { | 228 | { |
199 | return mHasDueDate; | 229 | return mHasDueDate; |
200 | } | 230 | } |
diff --git a/libkcal/todo.h b/libkcal/todo.h index 41f5841..137b252 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -61,8 +61,20 @@ class Todo : public Incidence | |||
61 | bool hasDueDate() const; | 61 | bool hasDueDate() const; |
62 | /** sets the event's hasDueDate value. */ | 62 | /** sets the event's hasDueDate value. */ |
63 | void setHasDueDate(bool f); | 63 | void setHasDueDate(bool f); |
64 | 64 | ||
65 | /* | ||
66 | Looks for a subtodo (including itself ) which is not complete and is | ||
67 | - overdue, or | ||
68 | - due today. | ||
69 | It returns 0 for nothing found, | ||
70 | 1 for found a todo which is due today and no overdue found | ||
71 | 2 for found a overdue todo | ||
72 | */ | ||
73 | int hasDueSubTodo( bool checkSubtodos = true ); | ||
74 | /* same as above, but a specific date can be specified*/ | ||
75 | int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ); | ||
76 | |||
65 | 77 | ||
66 | /** sets the event's status to the string specified. The string | 78 | /** sets the event's status to the string specified. The string |
67 | * must be a recognized value for the status field, i.e. a string | 79 | * must be a recognized value for the status field, i.e. a string |
68 | * equivalent of the possible status enumerations previously described. */ | 80 | * equivalent of the possible status enumerations previously described. */ |