-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 | |||
@@ -237,63 +237,63 @@ class Incidence : public IncidenceBase | |||
237 | /** Remove an alarm that is associated with this incidence */ | 237 | /** Remove an alarm that is associated with this incidence */ |
238 | void removeAlarm(Alarm*); | 238 | void removeAlarm(Alarm*); |
239 | /** Remove all alarms that are associated with this incidence */ | 239 | /** Remove all alarms that are associated with this incidence */ |
240 | void clearAlarms(); | 240 | void clearAlarms(); |
241 | /** return whether any alarm associated with this incidence is enabled */ | 241 | /** return whether any alarm associated with this incidence is enabled */ |
242 | bool isAlarmEnabled() const; | 242 | bool isAlarmEnabled() const; |
243 | 243 | ||
244 | /** | 244 | /** |
245 | Return the recurrence rule associated with this incidence. If there is | 245 | Return the recurrence rule associated with this incidence. If there is |
246 | none, returns an appropriate (non-0) object. | 246 | none, returns an appropriate (non-0) object. |
247 | */ | 247 | */ |
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 | 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 | ||
273 | // base components of jounal, event and todo | 274 | // base components of jounal, event and todo |
274 | QDateTime mCreated; | 275 | QDateTime mCreated; |
275 | QString mDescription; | 276 | QString mDescription; |
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 |
285 | 285 | ||
286 | int mSecrecy; | 286 | int mSecrecy; |
287 | int mPriority; // 1 = highest, 2 = less, etc. | 287 | int mPriority; // 1 = highest, 2 = less, etc. |
288 | 288 | ||
289 | //QPtrList<Alarm> mAlarms; | 289 | //QPtrList<Alarm> mAlarms; |
290 | Recurrence *mRecurrence; | 290 | Recurrence *mRecurrence; |
291 | 291 | ||
292 | QString mLocation; | 292 | QString mLocation; |
293 | }; | 293 | }; |
294 | 294 | ||
295 | bool operator==( const Incidence&, const Incidence& ); | 295 | bool operator==( const Incidence&, const Incidence& ); |
296 | 296 | ||
297 | } | 297 | } |
298 | 298 | ||
299 | #endif | 299 | #endif |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 7f1de78..d81a68f 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -164,65 +164,95 @@ void Todo::setDtDue(const QDateTime &dtDue) | |||
164 | } | 164 | } |
165 | }*/ | 165 | }*/ |
166 | mDtDue = getEvenTime(dtDue); | 166 | mDtDue = getEvenTime(dtDue); |
167 | 167 | ||
168 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; | 168 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; |
169 | 169 | ||
170 | /*const QPtrList<Alarm>& alarms = alarms(); | 170 | /*const QPtrList<Alarm>& alarms = alarms(); |
171 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) | 171 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) |
172 | alarm->setAlarmStart(mDtDue);*/ | 172 | alarm->setAlarmStart(mDtDue);*/ |
173 | 173 | ||
174 | updated(); | 174 | updated(); |
175 | } | 175 | } |
176 | 176 | ||
177 | QDateTime Todo::dtDue() const | 177 | QDateTime Todo::dtDue() const |
178 | { | 178 | { |
179 | return mDtDue; | 179 | return mDtDue; |
180 | } | 180 | } |
181 | 181 | ||
182 | QString Todo::dtDueTimeStr() const | 182 | QString Todo::dtDueTimeStr() const |
183 | { | 183 | { |
184 | return KGlobal::locale()->formatTime(mDtDue.time()); | 184 | return KGlobal::locale()->formatTime(mDtDue.time()); |
185 | } | 185 | } |
186 | 186 | ||
187 | QString Todo::dtDueDateStr(bool shortfmt) const | 187 | QString Todo::dtDueDateStr(bool shortfmt) const |
188 | { | 188 | { |
189 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 189 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
190 | } | 190 | } |
191 | 191 | ||
192 | QString Todo::dtDueStr(bool shortfmt) const | 192 | QString Todo::dtDueStr(bool shortfmt) const |
193 | { | 193 | { |
194 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); | 194 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); |
195 | } | 195 | } |
196 | 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 | } |
201 | 231 | ||
202 | void Todo::setHasDueDate(bool f) | 232 | void Todo::setHasDueDate(bool f) |
203 | { | 233 | { |
204 | if (mReadOnly) return; | 234 | if (mReadOnly) return; |
205 | mHasDueDate = f; | 235 | mHasDueDate = f; |
206 | updated(); | 236 | updated(); |
207 | } | 237 | } |
208 | 238 | ||
209 | 239 | ||
210 | #if 0 | 240 | #if 0 |
211 | void Todo::setStatus(const QString &statStr) | 241 | void Todo::setStatus(const QString &statStr) |
212 | { | 242 | { |
213 | if (mReadOnly) return; | 243 | if (mReadOnly) return; |
214 | QString ss(statStr.upper()); | 244 | QString ss(statStr.upper()); |
215 | 245 | ||
216 | if (ss == "X-ACTION") | 246 | if (ss == "X-ACTION") |
217 | mStatus = NEEDS_ACTION; | 247 | mStatus = NEEDS_ACTION; |
218 | else if (ss == "NEEDS ACTION") | 248 | else if (ss == "NEEDS ACTION") |
219 | mStatus = NEEDS_ACTION; | 249 | mStatus = NEEDS_ACTION; |
220 | else if (ss == "ACCEPTED") | 250 | else if (ss == "ACCEPTED") |
221 | mStatus = ACCEPTED; | 251 | mStatus = ACCEPTED; |
222 | else if (ss == "SENT") | 252 | else if (ss == "SENT") |
223 | mStatus = SENT; | 253 | mStatus = SENT; |
224 | else if (ss == "TENTATIVE") | 254 | else if (ss == "TENTATIVE") |
225 | mStatus = TENTATIVE; | 255 | mStatus = TENTATIVE; |
226 | else if (ss == "CONFIRMED") | 256 | else if (ss == "CONFIRMED") |
227 | mStatus = CONFIRMED; | 257 | mStatus = CONFIRMED; |
228 | else if (ss == "DECLINED") | 258 | else if (ss == "DECLINED") |
diff --git a/libkcal/todo.h b/libkcal/todo.h index 41f5841..137b252 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -33,64 +33,76 @@ namespace KCal { | |||
33 | class Todo : public Incidence | 33 | class Todo : public Incidence |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | Todo(); | 36 | Todo(); |
37 | Todo(const Todo &); | 37 | Todo(const Todo &); |
38 | ~Todo(); | 38 | ~Todo(); |
39 | typedef ListBase<Todo> List; | 39 | typedef ListBase<Todo> List; |
40 | QCString type() const { return "Todo"; } | 40 | QCString type() const { return "Todo"; } |
41 | 41 | ||
42 | /** Return an exact copy of this todo. */ | 42 | /** Return an exact copy of this todo. */ |
43 | Incidence *clone(); | 43 | Incidence *clone(); |
44 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; | 44 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; |
45 | 45 | ||
46 | /** for setting the todo's due date/time with a QDateTime. */ | 46 | /** for setting the todo's due date/time with a QDateTime. */ |
47 | void setDtDue(const QDateTime &dtDue); | 47 | void setDtDue(const QDateTime &dtDue); |
48 | /** returns an event's Due date/time as a QDateTime. */ | 48 | /** returns an event's Due date/time as a QDateTime. */ |
49 | QDateTime dtDue() const; | 49 | QDateTime dtDue() const; |
50 | /** returns an event's due time as a string formatted according to the | 50 | /** returns an event's due time as a string formatted according to the |
51 | users locale settings */ | 51 | users locale settings */ |
52 | QString dtDueTimeStr() const; | 52 | QString dtDueTimeStr() const; |
53 | /** returns an event's due date as a string formatted according to the | 53 | /** returns an event's due date as a string formatted according to the |
54 | users locale settings */ | 54 | users locale settings */ |
55 | QString dtDueDateStr(bool shortfmt=true) const; | 55 | QString dtDueDateStr(bool shortfmt=true) const; |
56 | /** returns an event's due date and time as a string formatted according | 56 | /** returns an event's due date and time as a string formatted according |
57 | to the users locale settings */ | 57 | to the users locale settings */ |
58 | QString dtDueStr(bool shortfmt=true) const; | 58 | QString dtDueStr(bool shortfmt=true) const; |
59 | 59 | ||
60 | /** returns TRUE or FALSE depending on whether the todo has a due date */ | 60 | /** returns TRUE or FALSE depending on whether the todo has a due date */ |
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. */ |
69 | // void setStatus(const QString &statStr); | 81 | // void setStatus(const QString &statStr); |
70 | /** sets the event's status to the value specified. See the enumeration | 82 | /** sets the event's status to the value specified. See the enumeration |
71 | * above for possible values. */ | 83 | * above for possible values. */ |
72 | // void setStatus(int); | 84 | // void setStatus(int); |
73 | /** return the event's status. */ | 85 | /** return the event's status. */ |
74 | // int status() const; | 86 | // int status() const; |
75 | /** return the event's status in string format. */ | 87 | /** return the event's status in string format. */ |
76 | // QString statusStr() const; | 88 | // QString statusStr() const; |
77 | 89 | ||
78 | /** return, if this todo is completed */ | 90 | /** return, if this todo is completed */ |
79 | bool isCompleted() const; | 91 | bool isCompleted() const; |
80 | /** set completed state of this todo */ | 92 | /** set completed state of this todo */ |
81 | void setCompleted(bool); | 93 | void setCompleted(bool); |
82 | 94 | ||
83 | /** | 95 | /** |
84 | 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 |
85 | between 0 and 100. | 97 | between 0 and 100. |
86 | */ | 98 | */ |
87 | int percentComplete() const; | 99 | int percentComplete() const; |
88 | /** | 100 | /** |
89 | 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 |
90 | range from 0 to 100. | 102 | range from 0 to 100. |
91 | */ | 103 | */ |
92 | void setPercentComplete(int); | 104 | void setPercentComplete(int); |
93 | 105 | ||
94 | /** return date and time when todo was completed */ | 106 | /** return date and time when todo was completed */ |
95 | QDateTime completed() const; | 107 | QDateTime completed() const; |
96 | QString completedStr(bool shortF = true) const; | 108 | QString completedStr(bool shortF = true) const; |