-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 | |||
@@ -13,287 +13,287 @@ | |||
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | #ifndef INCIDENCE_H | 20 | #ifndef INCIDENCE_H |
21 | #define INCIDENCE_H | 21 | #define INCIDENCE_H |
22 | // | 22 | // |
23 | // Incidence - base class of calendaring components | 23 | // Incidence - base class of calendaring components |
24 | // | 24 | // |
25 | 25 | ||
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | #include <qvaluelist.h> | 28 | #include <qvaluelist.h> |
29 | 29 | ||
30 | #include "recurrence.h" | 30 | #include "recurrence.h" |
31 | #include "alarm.h" | 31 | #include "alarm.h" |
32 | #include "attachment.h" | 32 | #include "attachment.h" |
33 | #include "listbase.h" | 33 | #include "listbase.h" |
34 | #include "incidencebase.h" | 34 | #include "incidencebase.h" |
35 | 35 | ||
36 | namespace KCal { | 36 | namespace KCal { |
37 | 37 | ||
38 | class Event; | 38 | class Event; |
39 | class Todo; | 39 | class Todo; |
40 | class Journal; | 40 | class Journal; |
41 | 41 | ||
42 | /** | 42 | /** |
43 | This class provides the base class common to all calendar components. | 43 | This class provides the base class common to all calendar components. |
44 | */ | 44 | */ |
45 | class Incidence : public IncidenceBase | 45 | class Incidence : public IncidenceBase |
46 | { | 46 | { |
47 | public: | 47 | public: |
48 | /** | 48 | /** |
49 | This class provides the interface for a visitor of calendar components. It | 49 | This class provides the interface for a visitor of calendar components. It |
50 | serves as base class for concrete visitors, which implement certain actions on | 50 | serves as base class for concrete visitors, which implement certain actions on |
51 | calendar components. It allows to add functions, which operate on the concrete | 51 | calendar components. It allows to add functions, which operate on the concrete |
52 | types of calendar components, without changing the calendar component classes. | 52 | types of calendar components, without changing the calendar component classes. |
53 | */ | 53 | */ |
54 | class Visitor | 54 | class Visitor |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | /** Destruct Incidence::Visitor */ | 57 | /** Destruct Incidence::Visitor */ |
58 | virtual ~Visitor() {} | 58 | virtual ~Visitor() {} |
59 | 59 | ||
60 | /** | 60 | /** |
61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
62 | on an Event object. | 62 | on an Event object. |
63 | */ | 63 | */ |
64 | virtual bool visit(Event *) { return false; } | 64 | virtual bool visit(Event *) { return false; } |
65 | /** | 65 | /** |
66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
67 | on an Todo object. | 67 | on an Todo object. |
68 | */ | 68 | */ |
69 | virtual bool visit(Todo *) { return false; } | 69 | virtual bool visit(Todo *) { return false; } |
70 | /** | 70 | /** |
71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
72 | on an Journal object. | 72 | on an Journal object. |
73 | */ | 73 | */ |
74 | virtual bool visit(Journal *) { return false; } | 74 | virtual bool visit(Journal *) { return false; } |
75 | 75 | ||
76 | protected: | 76 | protected: |
77 | /** Constructor is protected to prevent direct creation of visitor base class. */ | 77 | /** Constructor is protected to prevent direct creation of visitor base class. */ |
78 | Visitor() {} | 78 | Visitor() {} |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | This class implements a visitor for adding an Incidence to a resource | 82 | This class implements a visitor for adding an Incidence to a resource |
83 | supporting addEvent(), addTodo() and addJournal() calls. | 83 | supporting addEvent(), addTodo() and addJournal() calls. |
84 | */ | 84 | */ |
85 | template<class T> | 85 | template<class T> |
86 | class AddVisitor : public Visitor | 86 | class AddVisitor : public Visitor |
87 | { | 87 | { |
88 | public: | 88 | public: |
89 | AddVisitor( T *r ) : mResource( r ) {} | 89 | AddVisitor( T *r ) : mResource( r ) {} |
90 | bool visit( Event *e ) { return mResource->addEvent( e ); } | 90 | bool visit( Event *e ) { return mResource->addEvent( e ); } |
91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } | 91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } |
92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } | 92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } |
93 | 93 | ||
94 | private: | 94 | private: |
95 | T *mResource; | 95 | T *mResource; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | /** enumeration for describing an event's secrecy. */ | 98 | /** enumeration for describing an event's secrecy. */ |
99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; | 99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; |
100 | typedef ListBase<Incidence> List; | 100 | typedef ListBase<Incidence> List; |
101 | Incidence(); | 101 | Incidence(); |
102 | Incidence(const Incidence &); | 102 | Incidence(const Incidence &); |
103 | ~Incidence(); | 103 | ~Incidence(); |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to | 106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to |
107 | provide this implementation: | 107 | provide this implementation: |
108 | <pre> | 108 | <pre> |
109 | bool accept(Visitor &v) { return v.visit(this); } | 109 | bool accept(Visitor &v) { return v.visit(this); } |
110 | </pre> | 110 | </pre> |
111 | */ | 111 | */ |
112 | virtual bool accept(Visitor &) { return false; } | 112 | virtual bool accept(Visitor &) { return false; } |
113 | 113 | ||
114 | virtual Incidence *clone() = 0; | 114 | virtual Incidence *clone() = 0; |
115 | 115 | ||
116 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; | 116 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; |
117 | void setReadOnly( bool ); | 117 | void setReadOnly( bool ); |
118 | 118 | ||
119 | /** | 119 | /** |
120 | Recreate event. The event is made a new unique event, but already stored | 120 | Recreate event. The event is made a new unique event, but already stored |
121 | event information is preserved. Sets uniquie id, creation date, last | 121 | event information is preserved. Sets uniquie id, creation date, last |
122 | modification date and revision number. | 122 | modification date and revision number. |
123 | */ | 123 | */ |
124 | void recreate(); | 124 | void recreate(); |
125 | Incidence* recreateCloneException(QDate); | 125 | Incidence* recreateCloneException(QDate); |
126 | 126 | ||
127 | /** set creation date */ | 127 | /** set creation date */ |
128 | void setCreated(QDateTime); | 128 | void setCreated(QDateTime); |
129 | /** return time and date of creation. */ | 129 | /** return time and date of creation. */ |
130 | QDateTime created() const; | 130 | QDateTime created() const; |
131 | 131 | ||
132 | /** set the number of revisions this event has seen */ | 132 | /** set the number of revisions this event has seen */ |
133 | void setRevision(int rev); | 133 | void setRevision(int rev); |
134 | /** return the number of revisions this event has seen */ | 134 | /** return the number of revisions this event has seen */ |
135 | int revision() const; | 135 | int revision() const; |
136 | 136 | ||
137 | /** Set starting date/time. */ | 137 | /** Set starting date/time. */ |
138 | virtual void setDtStart(const QDateTime &dtStart); | 138 | virtual void setDtStart(const QDateTime &dtStart); |
139 | /** Return the incidence's ending date/time as a QDateTime. */ | 139 | /** Return the incidence's ending date/time as a QDateTime. */ |
140 | virtual QDateTime dtEnd() const { return QDateTime(); } | 140 | virtual QDateTime dtEnd() const { return QDateTime(); } |
141 | 141 | ||
142 | /** sets the event's lengthy description. */ | 142 | /** sets the event's lengthy description. */ |
143 | void setDescription(const QString &description); | 143 | void setDescription(const QString &description); |
144 | /** returns a reference to the event's description. */ | 144 | /** returns a reference to the event's description. */ |
145 | QString description() const; | 145 | QString description() const; |
146 | 146 | ||
147 | /** sets the event's short summary. */ | 147 | /** sets the event's short summary. */ |
148 | void setSummary(const QString &summary); | 148 | void setSummary(const QString &summary); |
149 | /** returns a reference to the event's summary. */ | 149 | /** returns a reference to the event's summary. */ |
150 | QString summary() const; | 150 | QString summary() const; |
151 | 151 | ||
152 | /** set event's applicable categories */ | 152 | /** set event's applicable categories */ |
153 | void setCategories(const QStringList &categories); | 153 | void setCategories(const QStringList &categories); |
154 | /** set event's categories based on a comma delimited string */ | 154 | /** set event's categories based on a comma delimited string */ |
155 | void setCategories(const QString &catStr); | 155 | void setCategories(const QString &catStr); |
156 | /** return categories in a list */ | 156 | /** return categories in a list */ |
157 | QStringList categories() const; | 157 | QStringList categories() const; |
158 | /** return categories as a comma separated string */ | 158 | /** return categories as a comma separated string */ |
159 | QString categoriesStr(); | 159 | QString categoriesStr(); |
160 | 160 | ||
161 | /** point at some other event to which the event relates. This function should | 161 | /** point at some other event to which the event relates. This function should |
162 | * only be used when constructing a calendar before the related Event | 162 | * only be used when constructing a calendar before the related Event |
163 | * exists. */ | 163 | * exists. */ |
164 | void setRelatedToUid(const QString &); | 164 | void setRelatedToUid(const QString &); |
165 | /** what event does this one relate to? This function should | 165 | /** what event does this one relate to? This function should |
166 | * only be used when constructing a calendar before the related Event | 166 | * only be used when constructing a calendar before the related Event |
167 | * exists. */ | 167 | * exists. */ |
168 | QString relatedToUid() const; | 168 | QString relatedToUid() const; |
169 | /** point at some other event to which the event relates */ | 169 | /** point at some other event to which the event relates */ |
170 | void setRelatedTo(Incidence *relatedTo); | 170 | void setRelatedTo(Incidence *relatedTo); |
171 | /** what event does this one relate to? */ | 171 | /** what event does this one relate to? */ |
172 | Incidence *relatedTo() const; | 172 | Incidence *relatedTo() const; |
173 | /** All events that are related to this event */ | 173 | /** All events that are related to this event */ |
174 | QPtrList<Incidence> relations() const; | 174 | QPtrList<Incidence> relations() const; |
175 | /** Add an event which is related to this event */ | 175 | /** Add an event which is related to this event */ |
176 | void addRelation(Incidence *); | 176 | void addRelation(Incidence *); |
177 | /** Remove event that is related to this event */ | 177 | /** Remove event that is related to this event */ |
178 | void removeRelation(Incidence *); | 178 | void removeRelation(Incidence *); |
179 | 179 | ||
180 | /** returns the list of dates which are exceptions to the recurrence rule */ | 180 | /** returns the list of dates which are exceptions to the recurrence rule */ |
181 | DateList exDates() const; | 181 | DateList exDates() const; |
182 | /** sets the list of dates which are exceptions to the recurrence rule */ | 182 | /** sets the list of dates which are exceptions to the recurrence rule */ |
183 | void setExDates(const DateList &_exDates); | 183 | void setExDates(const DateList &_exDates); |
184 | void setExDates(const char *dates); | 184 | void setExDates(const char *dates); |
185 | /** Add a date to the list of exceptions of the recurrence rule. */ | 185 | /** Add a date to the list of exceptions of the recurrence rule. */ |
186 | void addExDate(const QDate &date); | 186 | void addExDate(const QDate &date); |
187 | 187 | ||
188 | /** returns true if there is an exception for this date in the recurrence | 188 | /** returns true if there is an exception for this date in the recurrence |
189 | rule set, or false otherwise. */ | 189 | rule set, or false otherwise. */ |
190 | bool isException(const QDate &qd) const; | 190 | bool isException(const QDate &qd) const; |
191 | 191 | ||
192 | /** add attachment to this event */ | 192 | /** add attachment to this event */ |
193 | void addAttachment(Attachment *attachment); | 193 | void addAttachment(Attachment *attachment); |
194 | /** remove and delete a specific attachment */ | 194 | /** remove and delete a specific attachment */ |
195 | void deleteAttachment(Attachment *attachment); | 195 | void deleteAttachment(Attachment *attachment); |
196 | /** remove and delete all attachments with this mime type */ | 196 | /** remove and delete all attachments with this mime type */ |
197 | void deleteAttachments(const QString& mime); | 197 | void deleteAttachments(const QString& mime); |
198 | /** return list of all associated attachments */ | 198 | /** return list of all associated attachments */ |
199 | QPtrList<Attachment> attachments() const; | 199 | QPtrList<Attachment> attachments() const; |
200 | /** find a list of attachments with this mime type */ | 200 | /** find a list of attachments with this mime type */ |
201 | QPtrList<Attachment> attachments(const QString& mime) const; | 201 | QPtrList<Attachment> attachments(const QString& mime) const; |
202 | 202 | ||
203 | /** sets the event's status the value specified. See the enumeration | 203 | /** sets the event's status the value specified. See the enumeration |
204 | * above for possible values. */ | 204 | * above for possible values. */ |
205 | void setSecrecy(int); | 205 | void setSecrecy(int); |
206 | /** return the event's secrecy. */ | 206 | /** return the event's secrecy. */ |
207 | int secrecy() const; | 207 | int secrecy() const; |
208 | /** return the event's secrecy in string format. */ | 208 | /** return the event's secrecy in string format. */ |
209 | QString secrecyStr() const; | 209 | QString secrecyStr() const; |
210 | /** return list of all availbale secrecy classes */ | 210 | /** return list of all availbale secrecy classes */ |
211 | static QStringList secrecyList(); | 211 | static QStringList secrecyList(); |
212 | /** return human-readable name of secrecy class */ | 212 | /** return human-readable name of secrecy class */ |
213 | static QString secrecyName(int); | 213 | static QString secrecyName(int); |
214 | 214 | ||
215 | /** returns TRUE if the date specified is one on which the event will | 215 | /** returns TRUE if the date specified is one on which the event will |
216 | * recur. */ | 216 | * recur. */ |
217 | bool recursOn(const QDate &qd) const; | 217 | bool recursOn(const QDate &qd) const; |
218 | 218 | ||
219 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): | 219 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): |
220 | 220 | ||
221 | /** set resources used, such as Office, Car, etc. */ | 221 | /** set resources used, such as Office, Car, etc. */ |
222 | void setResources(const QStringList &resources); | 222 | void setResources(const QStringList &resources); |
223 | /** return list of current resources */ | 223 | /** return list of current resources */ |
224 | QStringList resources() const; | 224 | QStringList resources() const; |
225 | 225 | ||
226 | /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ | 226 | /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ |
227 | void setPriority(int priority); | 227 | void setPriority(int priority); |
228 | /** get the event's priority */ | 228 | /** get the event's priority */ |
229 | int priority() const; | 229 | int priority() const; |
230 | 230 | ||
231 | /** All alarms that are associated with this incidence */ | 231 | /** All alarms that are associated with this incidence */ |
232 | QPtrList<Alarm> alarms() const; | 232 | QPtrList<Alarm> alarms() const; |
233 | /** Create a new alarm which is associated with this incidence */ | 233 | /** Create a new alarm which is associated with this incidence */ |
234 | Alarm* newAlarm(); | 234 | Alarm* newAlarm(); |
235 | /** Add an alarm which is associated with this incidence */ | 235 | /** Add an alarm which is associated with this incidence */ |
236 | void addAlarm(Alarm*); | 236 | void addAlarm(Alarm*); |
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 | |||
@@ -1,384 +1,414 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "todo.h" | 25 | #include "todo.h" |
26 | 26 | ||
27 | using namespace KCal; | 27 | using namespace KCal; |
28 | 28 | ||
29 | Todo::Todo(): Incidence() | 29 | Todo::Todo(): Incidence() |
30 | { | 30 | { |
31 | // mStatus = TENTATIVE; | 31 | // mStatus = TENTATIVE; |
32 | 32 | ||
33 | mHasDueDate = false; | 33 | mHasDueDate = false; |
34 | setHasStartDate( false ); | 34 | setHasStartDate( false ); |
35 | mCompleted = getEvenTime(QDateTime::currentDateTime()); | 35 | mCompleted = getEvenTime(QDateTime::currentDateTime()); |
36 | mHasCompletedDate = false; | 36 | mHasCompletedDate = false; |
37 | mPercentComplete = 0; | 37 | mPercentComplete = 0; |
38 | } | 38 | } |
39 | 39 | ||
40 | Todo::Todo(const Todo &t) : Incidence(t) | 40 | Todo::Todo(const Todo &t) : Incidence(t) |
41 | { | 41 | { |
42 | mDtDue = t.mDtDue; | 42 | mDtDue = t.mDtDue; |
43 | mHasDueDate = t.mHasDueDate; | 43 | mHasDueDate = t.mHasDueDate; |
44 | mCompleted = t.mCompleted; | 44 | mCompleted = t.mCompleted; |
45 | mHasCompletedDate = t.mHasCompletedDate; | 45 | mHasCompletedDate = t.mHasCompletedDate; |
46 | mPercentComplete = t.mPercentComplete; | 46 | mPercentComplete = t.mPercentComplete; |
47 | } | 47 | } |
48 | 48 | ||
49 | Todo::~Todo() | 49 | Todo::~Todo() |
50 | { | 50 | { |
51 | 51 | ||
52 | } | 52 | } |
53 | 53 | ||
54 | Incidence *Todo::clone() | 54 | Incidence *Todo::clone() |
55 | { | 55 | { |
56 | return new Todo(*this); | 56 | return new Todo(*this); |
57 | } | 57 | } |
58 | 58 | ||
59 | bool Todo::contains ( Todo* from ) | 59 | bool Todo::contains ( Todo* from ) |
60 | { | 60 | { |
61 | 61 | ||
62 | if ( !from->summary().isEmpty() ) | 62 | if ( !from->summary().isEmpty() ) |
63 | if ( !summary().startsWith( from->summary() )) | 63 | if ( !summary().startsWith( from->summary() )) |
64 | return false; | 64 | return false; |
65 | if ( from->hasStartDate() ) { | 65 | if ( from->hasStartDate() ) { |
66 | if ( !hasStartDate() ) | 66 | if ( !hasStartDate() ) |
67 | return false; | 67 | return false; |
68 | if ( from->dtStart() != dtStart()) | 68 | if ( from->dtStart() != dtStart()) |
69 | return false; | 69 | return false; |
70 | } | 70 | } |
71 | if ( from->hasDueDate() ){ | 71 | if ( from->hasDueDate() ){ |
72 | if ( !hasDueDate() ) | 72 | if ( !hasDueDate() ) |
73 | return false; | 73 | return false; |
74 | if ( from->dtDue() != dtDue()) | 74 | if ( from->dtDue() != dtDue()) |
75 | return false; | 75 | return false; |
76 | } | 76 | } |
77 | if ( !from->location().isEmpty() ) | 77 | if ( !from->location().isEmpty() ) |
78 | if ( !location().startsWith( from->location() ) ) | 78 | if ( !location().startsWith( from->location() ) ) |
79 | return false; | 79 | return false; |
80 | if ( !from->description().isEmpty() ) | 80 | if ( !from->description().isEmpty() ) |
81 | if ( !description().startsWith( from->description() )) | 81 | if ( !description().startsWith( from->description() )) |
82 | return false; | 82 | return false; |
83 | if ( from->alarms().count() ) { | 83 | if ( from->alarms().count() ) { |
84 | Alarm *a = from->alarms().first(); | 84 | Alarm *a = from->alarms().first(); |
85 | if ( a->enabled() ){ | 85 | if ( a->enabled() ){ |
86 | if ( !alarms().count() ) | 86 | if ( !alarms().count() ) |
87 | return false; | 87 | return false; |
88 | Alarm *b = alarms().first(); | 88 | Alarm *b = alarms().first(); |
89 | if( ! b->enabled() ) | 89 | if( ! b->enabled() ) |
90 | return false; | 90 | return false; |
91 | if ( ! (a->offset() == b->offset() )) | 91 | if ( ! (a->offset() == b->offset() )) |
92 | return false; | 92 | return false; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | QStringList cat = categories(); | 96 | QStringList cat = categories(); |
97 | QStringList catFrom = from->categories(); | 97 | QStringList catFrom = from->categories(); |
98 | QString nCat; | 98 | QString nCat; |
99 | int iii; | 99 | int iii; |
100 | for ( iii = 0; iii < catFrom.count();++iii ) { | 100 | for ( iii = 0; iii < catFrom.count();++iii ) { |
101 | nCat = catFrom[iii]; | 101 | nCat = catFrom[iii]; |
102 | if ( !nCat.isEmpty() ) | 102 | if ( !nCat.isEmpty() ) |
103 | if ( !cat.contains( nCat )) { | 103 | if ( !cat.contains( nCat )) { |
104 | return false; | 104 | return false; |
105 | } | 105 | } |
106 | } | 106 | } |
107 | if ( from->isCompleted() ) { | 107 | if ( from->isCompleted() ) { |
108 | if ( !isCompleted() ) | 108 | if ( !isCompleted() ) |
109 | return false; | 109 | return false; |
110 | } | 110 | } |
111 | if( priority() != from->priority() ) | 111 | if( priority() != from->priority() ) |
112 | return false; | 112 | return false; |
113 | 113 | ||
114 | 114 | ||
115 | return true; | 115 | return true; |
116 | 116 | ||
117 | } | 117 | } |
118 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) | 118 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) |
119 | { | 119 | { |
120 | 120 | ||
121 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); | 121 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); |
122 | if ( ! ret ) | 122 | if ( ! ret ) |
123 | return false; | 123 | return false; |
124 | if ( t1.hasDueDate() == t2.hasDueDate() ) { | 124 | if ( t1.hasDueDate() == t2.hasDueDate() ) { |
125 | if ( t1.hasDueDate() ) { | 125 | if ( t1.hasDueDate() ) { |
126 | if ( t1.doesFloat() == t2.doesFloat() ) { | 126 | if ( t1.doesFloat() == t2.doesFloat() ) { |
127 | if ( t1.doesFloat() ) { | 127 | if ( t1.doesFloat() ) { |
128 | if ( t1.dtDue().date() != t2.dtDue().date() ) | 128 | if ( t1.dtDue().date() != t2.dtDue().date() ) |
129 | return false; | 129 | return false; |
130 | } else | 130 | } else |
131 | if ( t1.dtDue() != t2.dtDue() ) | 131 | if ( t1.dtDue() != t2.dtDue() ) |
132 | return false; | 132 | return false; |
133 | } else | 133 | } else |
134 | return false;// float != | 134 | return false;// float != |
135 | } | 135 | } |
136 | 136 | ||
137 | } else | 137 | } else |
138 | return false; | 138 | return false; |
139 | if ( t1.percentComplete() != t2.percentComplete() ) | 139 | if ( t1.percentComplete() != t2.percentComplete() ) |
140 | return false; | 140 | return false; |
141 | if ( t1.isCompleted() ) { | 141 | if ( t1.isCompleted() ) { |
142 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { | 142 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { |
143 | if ( t1.hasCompletedDate() ) { | 143 | if ( t1.hasCompletedDate() ) { |
144 | if ( t1.completed() != t2.completed() ) | 144 | if ( t1.completed() != t2.completed() ) |
145 | return false; | 145 | return false; |
146 | } | 146 | } |
147 | 147 | ||
148 | } else | 148 | } else |
149 | return false; | 149 | return false; |
150 | } | 150 | } |
151 | return true; | 151 | return true; |
152 | 152 | ||
153 | } | 153 | } |
154 | 154 | ||
155 | void Todo::setDtDue(const QDateTime &dtDue) | 155 | void Todo::setDtDue(const QDateTime &dtDue) |
156 | { | 156 | { |
157 | //int diffsecs = mDtDue.secsTo(dtDue); | 157 | //int diffsecs = mDtDue.secsTo(dtDue); |
158 | 158 | ||
159 | /*if (mReadOnly) return; | 159 | /*if (mReadOnly) return; |
160 | const QPtrList<Alarm>& alarms = alarms(); | 160 | const QPtrList<Alarm>& alarms = alarms(); |
161 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { | 161 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { |
162 | if (alarm->enabled()) { | 162 | if (alarm->enabled()) { |
163 | alarm->setTime(alarm->time().addSecs(diffsecs)); | 163 | alarm->setTime(alarm->time().addSecs(diffsecs)); |
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") |
229 | mStatus = DECLINED; | 259 | mStatus = DECLINED; |
230 | else if (ss == "COMPLETED") | 260 | else if (ss == "COMPLETED") |
231 | mStatus = COMPLETED; | 261 | mStatus = COMPLETED; |
232 | else if (ss == "DELEGATED") | 262 | else if (ss == "DELEGATED") |
233 | mStatus = DELEGATED; | 263 | mStatus = DELEGATED; |
234 | 264 | ||
235 | updated(); | 265 | updated(); |
236 | } | 266 | } |
237 | 267 | ||
238 | void Todo::setStatus(int status) | 268 | void Todo::setStatus(int status) |
239 | { | 269 | { |
240 | if (mReadOnly) return; | 270 | if (mReadOnly) return; |
241 | mStatus = status; | 271 | mStatus = status; |
242 | updated(); | 272 | updated(); |
243 | } | 273 | } |
244 | 274 | ||
245 | int Todo::status() const | 275 | int Todo::status() const |
246 | { | 276 | { |
247 | return mStatus; | 277 | return mStatus; |
248 | } | 278 | } |
249 | 279 | ||
250 | QString Todo::statusStr() const | 280 | QString Todo::statusStr() const |
251 | { | 281 | { |
252 | switch(mStatus) { | 282 | switch(mStatus) { |
253 | case NEEDS_ACTION: | 283 | case NEEDS_ACTION: |
254 | return QString("NEEDS ACTION"); | 284 | return QString("NEEDS ACTION"); |
255 | break; | 285 | break; |
256 | case ACCEPTED: | 286 | case ACCEPTED: |
257 | return QString("ACCEPTED"); | 287 | return QString("ACCEPTED"); |
258 | break; | 288 | break; |
259 | case SENT: | 289 | case SENT: |
260 | return QString("SENT"); | 290 | return QString("SENT"); |
261 | break; | 291 | break; |
262 | case TENTATIVE: | 292 | case TENTATIVE: |
263 | return QString("TENTATIVE"); | 293 | return QString("TENTATIVE"); |
264 | break; | 294 | break; |
265 | case CONFIRMED: | 295 | case CONFIRMED: |
266 | return QString("CONFIRMED"); | 296 | return QString("CONFIRMED"); |
267 | break; | 297 | break; |
268 | case DECLINED: | 298 | case DECLINED: |
269 | return QString("DECLINED"); | 299 | return QString("DECLINED"); |
270 | break; | 300 | break; |
271 | case COMPLETED: | 301 | case COMPLETED: |
272 | return QString("COMPLETED"); | 302 | return QString("COMPLETED"); |
273 | break; | 303 | break; |
274 | case DELEGATED: | 304 | case DELEGATED: |
275 | return QString("DELEGATED"); | 305 | return QString("DELEGATED"); |
276 | break; | 306 | break; |
277 | } | 307 | } |
278 | return QString(""); | 308 | return QString(""); |
279 | } | 309 | } |
280 | #endif | 310 | #endif |
281 | 311 | ||
282 | bool Todo::isCompleted() const | 312 | bool Todo::isCompleted() const |
283 | { | 313 | { |
284 | if (mPercentComplete == 100) return true; | 314 | if (mPercentComplete == 100) return true; |
285 | else return false; | 315 | else return false; |
286 | } | 316 | } |
287 | 317 | ||
288 | void Todo::setCompleted(bool completed) | 318 | void Todo::setCompleted(bool completed) |
289 | { | 319 | { |
290 | if (completed) mPercentComplete = 100; | 320 | if (completed) mPercentComplete = 100; |
291 | else { | 321 | else { |
292 | mPercentComplete = 0; | 322 | mPercentComplete = 0; |
293 | mHasCompletedDate = false; | 323 | mHasCompletedDate = false; |
294 | } | 324 | } |
295 | updated(); | 325 | updated(); |
296 | } | 326 | } |
297 | 327 | ||
298 | QDateTime Todo::completed() const | 328 | QDateTime Todo::completed() const |
299 | { | 329 | { |
300 | return mCompleted; | 330 | return mCompleted; |
301 | } | 331 | } |
302 | 332 | ||
303 | QString Todo::completedStr( bool shortF ) const | 333 | QString Todo::completedStr( bool shortF ) const |
304 | { | 334 | { |
305 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); | 335 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); |
306 | } | 336 | } |
307 | 337 | ||
308 | void Todo::setCompleted(const QDateTime &completed) | 338 | void Todo::setCompleted(const QDateTime &completed) |
309 | { | 339 | { |
310 | //qDebug("Todo::setCompleted "); | 340 | //qDebug("Todo::setCompleted "); |
311 | if ( mHasCompletedDate ) { | 341 | if ( mHasCompletedDate ) { |
312 | // qDebug("has completed data - return "); | 342 | // qDebug("has completed data - return "); |
313 | return; | 343 | return; |
314 | } | 344 | } |
315 | mHasCompletedDate = true; | 345 | mHasCompletedDate = true; |
316 | mPercentComplete = 100; | 346 | mPercentComplete = 100; |
317 | mCompleted = getEvenTime(completed); | 347 | mCompleted = getEvenTime(completed); |
318 | updated(); | 348 | updated(); |
319 | } | 349 | } |
320 | 350 | ||
321 | bool Todo::hasCompletedDate() const | 351 | bool Todo::hasCompletedDate() const |
322 | { | 352 | { |
323 | return mHasCompletedDate; | 353 | return mHasCompletedDate; |
324 | } | 354 | } |
325 | 355 | ||
326 | int Todo::percentComplete() const | 356 | int Todo::percentComplete() const |
327 | { | 357 | { |
328 | return mPercentComplete; | 358 | return mPercentComplete; |
329 | } | 359 | } |
330 | 360 | ||
331 | void Todo::setPercentComplete(int v) | 361 | void Todo::setPercentComplete(int v) |
332 | { | 362 | { |
333 | mPercentComplete = v; | 363 | mPercentComplete = v; |
334 | if ( v != 100 ) | 364 | if ( v != 100 ) |
335 | mHasCompletedDate = false; | 365 | mHasCompletedDate = false; |
336 | updated(); | 366 | updated(); |
337 | } | 367 | } |
338 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | 368 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const |
339 | { | 369 | { |
340 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { | 370 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { |
341 | *ok = false; | 371 | *ok = false; |
342 | return QDateTime (); | 372 | return QDateTime (); |
343 | } | 373 | } |
344 | QDateTime incidenceStart; | 374 | QDateTime incidenceStart; |
345 | incidenceStart = dtDue(); | 375 | incidenceStart = dtDue(); |
346 | bool enabled = false; | 376 | bool enabled = false; |
347 | Alarm* alarm; | 377 | Alarm* alarm; |
348 | int off; | 378 | int off; |
349 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 379 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
350 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 380 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
351 | // *ok = false; | 381 | // *ok = false; |
352 | // return incidenceStart; | 382 | // return incidenceStart; |
353 | // } | 383 | // } |
354 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 384 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
355 | if (alarm->enabled()) { | 385 | if (alarm->enabled()) { |
356 | if ( alarm->hasTime () ) { | 386 | if ( alarm->hasTime () ) { |
357 | if ( alarm->time() < alarmStart ) { | 387 | if ( alarm->time() < alarmStart ) { |
358 | alarmStart = alarm->time(); | 388 | alarmStart = alarm->time(); |
359 | enabled = true; | 389 | enabled = true; |
360 | off = alarmStart.secsTo( incidenceStart ); | 390 | off = alarmStart.secsTo( incidenceStart ); |
361 | } | 391 | } |
362 | 392 | ||
363 | } else { | 393 | } else { |
364 | int secs = alarm->startOffset().asSeconds(); | 394 | int secs = alarm->startOffset().asSeconds(); |
365 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 395 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
366 | alarmStart = incidenceStart.addSecs( secs ); | 396 | alarmStart = incidenceStart.addSecs( secs ); |
367 | enabled = true; | 397 | enabled = true; |
368 | off = -secs; | 398 | off = -secs; |
369 | } | 399 | } |
370 | } | 400 | } |
371 | } | 401 | } |
372 | } | 402 | } |
373 | if ( enabled ) { | 403 | if ( enabled ) { |
374 | if ( alarmStart > QDateTime::currentDateTime() ) { | 404 | if ( alarmStart > QDateTime::currentDateTime() ) { |
375 | *ok = true; | 405 | *ok = true; |
376 | * offset = off; | 406 | * offset = off; |
377 | return alarmStart; | 407 | return alarmStart; |
378 | } | 408 | } |
379 | } | 409 | } |
380 | *ok = false; | 410 | *ok = false; |
381 | return QDateTime (); | 411 | return QDateTime (); |
382 | 412 | ||
383 | } | 413 | } |
384 | 414 | ||
diff --git a/libkcal/todo.h b/libkcal/todo.h index 41f5841..137b252 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -1,122 +1,134 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | #ifndef TODO_H | 20 | #ifndef TODO_H |
21 | #define TODO_H | 21 | #define TODO_H |
22 | // | 22 | // |
23 | // Todo component, representing a VTODO object | 23 | // Todo component, representing a VTODO object |
24 | // | 24 | // |
25 | 25 | ||
26 | #include "incidence.h" | 26 | #include "incidence.h" |
27 | 27 | ||
28 | namespace KCal { | 28 | namespace KCal { |
29 | 29 | ||
30 | /** | 30 | /** |
31 | This class provides a Todo in the sense of RFC2445. | 31 | This class provides a Todo in the sense of RFC2445. |
32 | */ | 32 | */ |
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; |
97 | /** set date and time of completion */ | 109 | /** set date and time of completion */ |
98 | void setCompleted(const QDateTime &completed); | 110 | void setCompleted(const QDateTime &completed); |
99 | 111 | ||
100 | /** Return true, if todo has a date associated with completion */ | 112 | /** Return true, if todo has a date associated with completion */ |
101 | bool hasCompletedDate() const; | 113 | bool hasCompletedDate() const; |
102 | bool contains ( Todo*); | 114 | bool contains ( Todo*); |
103 | 115 | ||
104 | private: | 116 | private: |
105 | bool accept(Visitor &v) { return v.visit(this); } | 117 | bool accept(Visitor &v) { return v.visit(this); } |
106 | 118 | ||
107 | QDateTime mDtDue; // due date of todo | 119 | QDateTime mDtDue; // due date of todo |
108 | 120 | ||
109 | bool mHasDueDate; // if todo has associated due date | 121 | bool mHasDueDate; // if todo has associated due date |
110 | 122 | ||
111 | // int mStatus; // confirmed/delegated/tentative/etc | 123 | // int mStatus; // confirmed/delegated/tentative/etc |
112 | 124 | ||
113 | QDateTime mCompleted; | 125 | QDateTime mCompleted; |
114 | bool mHasCompletedDate; | 126 | bool mHasCompletedDate; |
115 | 127 | ||
116 | int mPercentComplete; | 128 | int mPercentComplete; |
117 | }; | 129 | }; |
118 | 130 | ||
119 | bool operator==( const Todo&, const Todo& ); | 131 | bool operator==( const Todo&, const Todo& ); |
120 | } | 132 | } |
121 | 133 | ||
122 | #endif | 134 | #endif |