-rw-r--r-- | libkcal/todo.cpp | 10 | ||||
-rw-r--r-- | libkcal/todo.h | 1 |
2 files changed, 10 insertions, 1 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index e98af3c..d062492 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -1,585 +1,593 @@ | |||
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 <kglobalsettings.h> | 22 | #include <kglobalsettings.h> |
23 | #include <klocale.h> | 23 | #include <klocale.h> |
24 | #include <kdebug.h> | 24 | #include <kdebug.h> |
25 | #include <qregexp.h> | 25 | #include <qregexp.h> |
26 | #include <qfileinfo.h> | 26 | #include <qfileinfo.h> |
27 | 27 | ||
28 | #include "calendarlocal.h" | 28 | #include "calendarlocal.h" |
29 | #include "icalformat.h" | 29 | #include "icalformat.h" |
30 | #include "todo.h" | 30 | #include "todo.h" |
31 | 31 | ||
32 | using namespace KCal; | 32 | using namespace KCal; |
33 | 33 | ||
34 | Todo::Todo(): QObject(), Incidence() | 34 | Todo::Todo(): QObject(), Incidence() |
35 | { | 35 | { |
36 | // mStatus = TENTATIVE; | 36 | // mStatus = TENTATIVE; |
37 | 37 | ||
38 | mHasDueDate = false; | 38 | mHasDueDate = false; |
39 | setHasStartDate( false ); | 39 | setHasStartDate( false ); |
40 | mCompleted = getEvenTime(QDateTime::currentDateTime()); | 40 | mCompleted = getEvenTime(QDateTime::currentDateTime()); |
41 | mHasCompletedDate = false; | 41 | mHasCompletedDate = false; |
42 | mPercentComplete = 0; | 42 | mPercentComplete = 0; |
43 | mRunning = false; | 43 | mRunning = false; |
44 | mRunSaveTimer = 0; | 44 | mRunSaveTimer = 0; |
45 | } | 45 | } |
46 | 46 | ||
47 | Todo::Todo(const Todo &t) : QObject(),Incidence(t) | 47 | Todo::Todo(const Todo &t) : QObject(),Incidence(t) |
48 | { | 48 | { |
49 | mDtDue = t.mDtDue; | 49 | mDtDue = t.mDtDue; |
50 | mHasDueDate = t.mHasDueDate; | 50 | mHasDueDate = t.mHasDueDate; |
51 | mCompleted = t.mCompleted; | 51 | mCompleted = t.mCompleted; |
52 | mHasCompletedDate = t.mHasCompletedDate; | 52 | mHasCompletedDate = t.mHasCompletedDate; |
53 | mPercentComplete = t.mPercentComplete; | 53 | mPercentComplete = t.mPercentComplete; |
54 | mRunning = false; | 54 | mRunning = false; |
55 | mRunSaveTimer = 0; | 55 | mRunSaveTimer = 0; |
56 | } | 56 | } |
57 | 57 | ||
58 | Todo::~Todo() | 58 | Todo::~Todo() |
59 | { | 59 | { |
60 | setRunning( false ); | 60 | setRunning( false ); |
61 | //qDebug("Todo::~Todo() "); | 61 | //qDebug("Todo::~Todo() "); |
62 | } | 62 | } |
63 | 63 | ||
64 | void Todo::setRunningFalse( QString s ) | 64 | void Todo::setRunningFalse( QString s ) |
65 | { | 65 | { |
66 | if ( ! mRunning ) | 66 | if ( ! mRunning ) |
67 | return; | 67 | return; |
68 | mRunning = false; | 68 | mRunning = false; |
69 | mRunSaveTimer->stop(); | 69 | mRunSaveTimer->stop(); |
70 | saveRunningInfoToFile( s ); | 70 | saveRunningInfoToFile( s ); |
71 | } | 71 | } |
72 | void Todo::stopRunning() | ||
73 | { | ||
74 | if ( !mRunning ) | ||
75 | return; | ||
76 | if ( mRunSaveTimer ) | ||
77 | mRunSaveTimer->stop(); | ||
78 | mRunning = false; | ||
79 | } | ||
72 | void Todo::setRunning( bool run ) | 80 | void Todo::setRunning( bool run ) |
73 | { | 81 | { |
74 | if ( run == mRunning ) | 82 | if ( run == mRunning ) |
75 | return; | 83 | return; |
76 | //qDebug("Todo::setRunning %d ", run); | 84 | //qDebug("Todo::setRunning %d ", run); |
77 | if ( !mRunSaveTimer ) { | 85 | if ( !mRunSaveTimer ) { |
78 | mRunSaveTimer = new QTimer ( this ); | 86 | mRunSaveTimer = new QTimer ( this ); |
79 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); | 87 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); |
80 | } | 88 | } |
81 | mRunning = run; | 89 | mRunning = run; |
82 | if ( mRunning ) { | 90 | if ( mRunning ) { |
83 | mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min | 91 | mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min |
84 | mRunStart = QDateTime::currentDateTime(); | 92 | mRunStart = QDateTime::currentDateTime(); |
85 | } else { | 93 | } else { |
86 | mRunSaveTimer->stop(); | 94 | mRunSaveTimer->stop(); |
87 | saveRunningInfoToFile(); | 95 | saveRunningInfoToFile(); |
88 | } | 96 | } |
89 | } | 97 | } |
90 | 98 | ||
91 | void Todo::saveRunningInfoToFile() | 99 | void Todo::saveRunningInfoToFile() |
92 | { | 100 | { |
93 | saveRunningInfoToFile( QString::null ); | 101 | saveRunningInfoToFile( QString::null ); |
94 | } | 102 | } |
95 | void Todo::saveRunningInfoToFile( QString comment ) | 103 | void Todo::saveRunningInfoToFile( QString comment ) |
96 | { | 104 | { |
97 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); | 105 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); |
98 | if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) { | 106 | if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 10 ) { |
99 | qDebug("Running time < 30 seconds. Skipped. "); | 107 | qDebug("Running time < 30 seconds. Skipped. "); |
100 | return; | 108 | return; |
101 | } | 109 | } |
102 | QString dir = KGlobalSettings::timeTrackerDir(); | 110 | QString dir = KGlobalSettings::timeTrackerDir(); |
103 | //qDebug("%s ", dir.latin1()); | 111 | //qDebug("%s ", dir.latin1()); |
104 | QString file = "%1%2%3-%4%5%6-"; | 112 | QString file = "%1%2%3-%4%5%6-"; |
105 | file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); | 113 | file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); |
106 | file.replace ( QRegExp (" "), "0" ); | 114 | file.replace ( QRegExp (" "), "0" ); |
107 | file += uid(); | 115 | file += uid(); |
108 | //qDebug("File %s ",file.latin1() ); | 116 | //qDebug("File %s ",file.latin1() ); |
109 | CalendarLocal cal; | 117 | CalendarLocal cal; |
110 | cal.setLocalTime(); | 118 | cal.setLocalTime(); |
111 | Todo * to = (Todo*) clone(); | 119 | Todo * to = (Todo*) clone(); |
112 | to->setFloats( false ); | 120 | to->setFloats( false ); |
113 | to->setDtStart( mRunStart ); | 121 | to->setDtStart( mRunStart ); |
114 | to->setHasStartDate( true ); | 122 | to->setHasStartDate( true ); |
115 | to->setDtDue( QDateTime::currentDateTime() ); | 123 | to->setDtDue( QDateTime::currentDateTime() ); |
116 | to->setHasDueDate( true ); | 124 | to->setHasDueDate( true ); |
117 | to->setUid( file ); | 125 | to->setUid( file ); |
118 | if ( !comment.isEmpty() ) { | 126 | if ( !comment.isEmpty() ) { |
119 | QString des = to->description(); | 127 | QString des = to->description(); |
120 | if ( des.isEmpty () ) | 128 | if ( des.isEmpty () ) |
121 | to->setDescription( "TT-Note: " + comment ); | 129 | to->setDescription( "TT-Note: " + comment ); |
122 | else | 130 | else |
123 | to->setDescription( "TT-Note: " + comment +"\n" + des ); | 131 | to->setDescription( "TT-Note: " + comment +"\n" + des ); |
124 | } | 132 | } |
125 | cal.addIncidence( to ); | 133 | cal.addIncidence( to ); |
126 | ICalFormat format; | 134 | ICalFormat format; |
127 | file = dir +"/" +file +".ics"; | 135 | file = dir +"/" +file +".ics"; |
128 | format.save( &cal, file ); | 136 | format.save( &cal, file ); |
129 | saveParents(); | 137 | saveParents(); |
130 | 138 | ||
131 | } | 139 | } |
132 | void Todo::saveParents() | 140 | void Todo::saveParents() |
133 | { | 141 | { |
134 | if (!relatedTo() ) | 142 | if (!relatedTo() ) |
135 | return; | 143 | return; |
136 | Incidence * inc = relatedTo(); | 144 | Incidence * inc = relatedTo(); |
137 | if ( inc->typeID() != todoID ) | 145 | if ( inc->typeID() != todoID ) |
138 | return; | 146 | return; |
139 | Todo* to = (Todo*)inc; | 147 | Todo* to = (Todo*)inc; |
140 | bool saveTodo = false; | 148 | bool saveTodo = false; |
141 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; | 149 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; |
142 | QFileInfo fi ( file ); | 150 | QFileInfo fi ( file ); |
143 | if ( fi.exists() ) { | 151 | if ( fi.exists() ) { |
144 | if ( fi.lastModified () < to->lastModified ()) | 152 | if ( fi.lastModified () < to->lastModified ()) |
145 | saveTodo = true; | 153 | saveTodo = true; |
146 | } else { | 154 | } else { |
147 | saveTodo = true; | 155 | saveTodo = true; |
148 | } | 156 | } |
149 | if ( saveTodo ) { | 157 | if ( saveTodo ) { |
150 | CalendarLocal cal; | 158 | CalendarLocal cal; |
151 | cal.setLocalTime(); | 159 | cal.setLocalTime(); |
152 | Todo * par = (Todo *) to->clone(); | 160 | Todo * par = (Todo *) to->clone(); |
153 | cal.addIncidence( par ); | 161 | cal.addIncidence( par ); |
154 | ICalFormat format; | 162 | ICalFormat format; |
155 | format.save( &cal, file ); | 163 | format.save( &cal, file ); |
156 | } | 164 | } |
157 | to->saveParents(); | 165 | to->saveParents(); |
158 | } | 166 | } |
159 | 167 | ||
160 | int Todo::runTime() | 168 | int Todo::runTime() |
161 | { | 169 | { |
162 | if ( !mRunning ) | 170 | if ( !mRunning ) |
163 | return 0; | 171 | return 0; |
164 | return mRunStart.secsTo( QDateTime::currentDateTime() ); | 172 | return mRunStart.secsTo( QDateTime::currentDateTime() ); |
165 | } | 173 | } |
166 | bool Todo::hasRunningSub() | 174 | bool Todo::hasRunningSub() |
167 | { | 175 | { |
168 | if ( mRunning ) | 176 | if ( mRunning ) |
169 | return true; | 177 | return true; |
170 | Incidence *aTodo; | 178 | Incidence *aTodo; |
171 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | 179 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { |
172 | if ( ((Todo*)aTodo)->hasRunningSub() ) | 180 | if ( ((Todo*)aTodo)->hasRunningSub() ) |
173 | return true; | 181 | return true; |
174 | } | 182 | } |
175 | return false; | 183 | return false; |
176 | } | 184 | } |
177 | Incidence *Todo::clone() | 185 | Incidence *Todo::clone() |
178 | { | 186 | { |
179 | return new Todo(*this); | 187 | return new Todo(*this); |
180 | } | 188 | } |
181 | 189 | ||
182 | bool Todo::contains ( Todo* from ) | 190 | bool Todo::contains ( Todo* from ) |
183 | { | 191 | { |
184 | 192 | ||
185 | if ( !from->summary().isEmpty() ) | 193 | if ( !from->summary().isEmpty() ) |
186 | if ( !summary().startsWith( from->summary() )) | 194 | if ( !summary().startsWith( from->summary() )) |
187 | return false; | 195 | return false; |
188 | if ( from->hasStartDate() ) { | 196 | if ( from->hasStartDate() ) { |
189 | if ( !hasStartDate() ) | 197 | if ( !hasStartDate() ) |
190 | return false; | 198 | return false; |
191 | if ( from->dtStart() != dtStart()) | 199 | if ( from->dtStart() != dtStart()) |
192 | return false; | 200 | return false; |
193 | } | 201 | } |
194 | if ( from->hasDueDate() ){ | 202 | if ( from->hasDueDate() ){ |
195 | if ( !hasDueDate() ) | 203 | if ( !hasDueDate() ) |
196 | return false; | 204 | return false; |
197 | if ( from->dtDue() != dtDue()) | 205 | if ( from->dtDue() != dtDue()) |
198 | return false; | 206 | return false; |
199 | } | 207 | } |
200 | if ( !from->location().isEmpty() ) | 208 | if ( !from->location().isEmpty() ) |
201 | if ( !location().startsWith( from->location() ) ) | 209 | if ( !location().startsWith( from->location() ) ) |
202 | return false; | 210 | return false; |
203 | if ( !from->description().isEmpty() ) | 211 | if ( !from->description().isEmpty() ) |
204 | if ( !description().startsWith( from->description() )) | 212 | if ( !description().startsWith( from->description() )) |
205 | return false; | 213 | return false; |
206 | if ( from->alarms().count() ) { | 214 | if ( from->alarms().count() ) { |
207 | Alarm *a = from->alarms().first(); | 215 | Alarm *a = from->alarms().first(); |
208 | if ( a->enabled() ){ | 216 | if ( a->enabled() ){ |
209 | if ( !alarms().count() ) | 217 | if ( !alarms().count() ) |
210 | return false; | 218 | return false; |
211 | Alarm *b = alarms().first(); | 219 | Alarm *b = alarms().first(); |
212 | if( ! b->enabled() ) | 220 | if( ! b->enabled() ) |
213 | return false; | 221 | return false; |
214 | if ( ! (a->offset() == b->offset() )) | 222 | if ( ! (a->offset() == b->offset() )) |
215 | return false; | 223 | return false; |
216 | } | 224 | } |
217 | } | 225 | } |
218 | 226 | ||
219 | QStringList cat = categories(); | 227 | QStringList cat = categories(); |
220 | QStringList catFrom = from->categories(); | 228 | QStringList catFrom = from->categories(); |
221 | QString nCat; | 229 | QString nCat; |
222 | unsigned int iii; | 230 | unsigned int iii; |
223 | for ( iii = 0; iii < catFrom.count();++iii ) { | 231 | for ( iii = 0; iii < catFrom.count();++iii ) { |
224 | nCat = catFrom[iii]; | 232 | nCat = catFrom[iii]; |
225 | if ( !nCat.isEmpty() ) | 233 | if ( !nCat.isEmpty() ) |
226 | if ( !cat.contains( nCat )) { | 234 | if ( !cat.contains( nCat )) { |
227 | return false; | 235 | return false; |
228 | } | 236 | } |
229 | } | 237 | } |
230 | if ( from->isCompleted() ) { | 238 | if ( from->isCompleted() ) { |
231 | if ( !isCompleted() ) | 239 | if ( !isCompleted() ) |
232 | return false; | 240 | return false; |
233 | } | 241 | } |
234 | if( priority() != from->priority() ) | 242 | if( priority() != from->priority() ) |
235 | return false; | 243 | return false; |
236 | 244 | ||
237 | 245 | ||
238 | return true; | 246 | return true; |
239 | 247 | ||
240 | } | 248 | } |
241 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) | 249 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) |
242 | { | 250 | { |
243 | 251 | ||
244 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); | 252 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); |
245 | if ( ! ret ) | 253 | if ( ! ret ) |
246 | return false; | 254 | return false; |
247 | if ( t1.hasDueDate() == t2.hasDueDate() ) { | 255 | if ( t1.hasDueDate() == t2.hasDueDate() ) { |
248 | if ( t1.hasDueDate() ) { | 256 | if ( t1.hasDueDate() ) { |
249 | if ( t1.doesFloat() == t2.doesFloat() ) { | 257 | if ( t1.doesFloat() == t2.doesFloat() ) { |
250 | if ( t1.doesFloat() ) { | 258 | if ( t1.doesFloat() ) { |
251 | if ( t1.dtDue().date() != t2.dtDue().date() ) | 259 | if ( t1.dtDue().date() != t2.dtDue().date() ) |
252 | return false; | 260 | return false; |
253 | } else | 261 | } else |
254 | if ( t1.dtDue() != t2.dtDue() ) | 262 | if ( t1.dtDue() != t2.dtDue() ) |
255 | return false; | 263 | return false; |
256 | } else | 264 | } else |
257 | return false;// float != | 265 | return false;// float != |
258 | } | 266 | } |
259 | 267 | ||
260 | } else | 268 | } else |
261 | return false; | 269 | return false; |
262 | if ( t1.percentComplete() != t2.percentComplete() ) | 270 | if ( t1.percentComplete() != t2.percentComplete() ) |
263 | return false; | 271 | return false; |
264 | if ( t1.isCompleted() ) { | 272 | if ( t1.isCompleted() ) { |
265 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { | 273 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { |
266 | if ( t1.hasCompletedDate() ) { | 274 | if ( t1.hasCompletedDate() ) { |
267 | if ( t1.completed() != t2.completed() ) | 275 | if ( t1.completed() != t2.completed() ) |
268 | return false; | 276 | return false; |
269 | } | 277 | } |
270 | 278 | ||
271 | } else | 279 | } else |
272 | return false; | 280 | return false; |
273 | } | 281 | } |
274 | return true; | 282 | return true; |
275 | 283 | ||
276 | } | 284 | } |
277 | 285 | ||
278 | void Todo::setDtDue(const QDateTime &dtDue) | 286 | void Todo::setDtDue(const QDateTime &dtDue) |
279 | { | 287 | { |
280 | //int diffsecs = mDtDue.secsTo(dtDue); | 288 | //int diffsecs = mDtDue.secsTo(dtDue); |
281 | 289 | ||
282 | /*if (mReadOnly) return; | 290 | /*if (mReadOnly) return; |
283 | const QPtrList<Alarm>& alarms = alarms(); | 291 | const QPtrList<Alarm>& alarms = alarms(); |
284 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { | 292 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { |
285 | if (alarm->enabled()) { | 293 | if (alarm->enabled()) { |
286 | alarm->setTime(alarm->time().addSecs(diffsecs)); | 294 | alarm->setTime(alarm->time().addSecs(diffsecs)); |
287 | } | 295 | } |
288 | }*/ | 296 | }*/ |
289 | mDtDue = getEvenTime(dtDue); | 297 | mDtDue = getEvenTime(dtDue); |
290 | 298 | ||
291 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; | 299 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; |
292 | 300 | ||
293 | /*const QPtrList<Alarm>& alarms = alarms(); | 301 | /*const QPtrList<Alarm>& alarms = alarms(); |
294 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) | 302 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) |
295 | alarm->setAlarmStart(mDtDue);*/ | 303 | alarm->setAlarmStart(mDtDue);*/ |
296 | updated(); | 304 | updated(); |
297 | } | 305 | } |
298 | 306 | ||
299 | QDateTime Todo::dtDue() const | 307 | QDateTime Todo::dtDue() const |
300 | { | 308 | { |
301 | return mDtDue; | 309 | return mDtDue; |
302 | } | 310 | } |
303 | 311 | ||
304 | QString Todo::dtDueTimeStr() const | 312 | QString Todo::dtDueTimeStr() const |
305 | { | 313 | { |
306 | return KGlobal::locale()->formatTime(mDtDue.time()); | 314 | return KGlobal::locale()->formatTime(mDtDue.time()); |
307 | } | 315 | } |
308 | 316 | ||
309 | QString Todo::dtDueDateStr(bool shortfmt) const | 317 | QString Todo::dtDueDateStr(bool shortfmt) const |
310 | { | 318 | { |
311 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 319 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
312 | } | 320 | } |
313 | 321 | ||
314 | QString Todo::dtDueStr(bool shortfmt) const | 322 | QString Todo::dtDueStr(bool shortfmt) const |
315 | { | 323 | { |
316 | if ( doesFloat() ) | 324 | if ( doesFloat() ) |
317 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 325 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
318 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); | 326 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); |
319 | } | 327 | } |
320 | // retval 0 : no found | 328 | // retval 0 : no found |
321 | // 1 : due for date found | 329 | // 1 : due for date found |
322 | // 2 : overdue for date found | 330 | // 2 : overdue for date found |
323 | int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) | 331 | int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) |
324 | { | 332 | { |
325 | int retval = 0; | 333 | int retval = 0; |
326 | if ( isCompleted() ) | 334 | if ( isCompleted() ) |
327 | return 0; | 335 | return 0; |
328 | if ( hasDueDate() ) { | 336 | if ( hasDueDate() ) { |
329 | if ( dtDue().date() < date ) | 337 | if ( dtDue().date() < date ) |
330 | return 2; | 338 | return 2; |
331 | // we do not return, because we may find an overdue sub todo | 339 | // we do not return, because we may find an overdue sub todo |
332 | if ( dtDue().date() == date ) | 340 | if ( dtDue().date() == date ) |
333 | retval = 1; | 341 | retval = 1; |
334 | } | 342 | } |
335 | if ( checkSubtodos ) { | 343 | if ( checkSubtodos ) { |
336 | Incidence *aTodo; | 344 | Incidence *aTodo; |
337 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | 345 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { |
338 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); | 346 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); |
339 | if ( ret == 2 ) | 347 | if ( ret == 2 ) |
340 | return 2; | 348 | return 2; |
341 | if ( ret == 1) | 349 | if ( ret == 1) |
342 | retval = 1; | 350 | retval = 1; |
343 | } | 351 | } |
344 | } | 352 | } |
345 | return retval; | 353 | return retval; |
346 | } | 354 | } |
347 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true | 355 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true |
348 | { | 356 | { |
349 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); | 357 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); |
350 | } | 358 | } |
351 | bool Todo::hasDueDate() const | 359 | bool Todo::hasDueDate() const |
352 | { | 360 | { |
353 | return mHasDueDate; | 361 | return mHasDueDate; |
354 | } | 362 | } |
355 | 363 | ||
356 | void Todo::setHasDueDate(bool f) | 364 | void Todo::setHasDueDate(bool f) |
357 | { | 365 | { |
358 | if (mReadOnly) return; | 366 | if (mReadOnly) return; |
359 | mHasDueDate = f; | 367 | mHasDueDate = f; |
360 | updated(); | 368 | updated(); |
361 | } | 369 | } |
362 | 370 | ||
363 | 371 | ||
364 | #if 0 | 372 | #if 0 |
365 | void Todo::setStatus(const QString &statStr) | 373 | void Todo::setStatus(const QString &statStr) |
366 | { | 374 | { |
367 | if (mReadOnly) return; | 375 | if (mReadOnly) return; |
368 | QString ss(statStr.upper()); | 376 | QString ss(statStr.upper()); |
369 | 377 | ||
370 | if (ss == "X-ACTION") | 378 | if (ss == "X-ACTION") |
371 | mStatus = NEEDS_ACTION; | 379 | mStatus = NEEDS_ACTION; |
372 | else if (ss == "NEEDS ACTION") | 380 | else if (ss == "NEEDS ACTION") |
373 | mStatus = NEEDS_ACTION; | 381 | mStatus = NEEDS_ACTION; |
374 | else if (ss == "ACCEPTED") | 382 | else if (ss == "ACCEPTED") |
375 | mStatus = ACCEPTED; | 383 | mStatus = ACCEPTED; |
376 | else if (ss == "SENT") | 384 | else if (ss == "SENT") |
377 | mStatus = SENT; | 385 | mStatus = SENT; |
378 | else if (ss == "TENTATIVE") | 386 | else if (ss == "TENTATIVE") |
379 | mStatus = TENTATIVE; | 387 | mStatus = TENTATIVE; |
380 | else if (ss == "CONFIRMED") | 388 | else if (ss == "CONFIRMED") |
381 | mStatus = CONFIRMED; | 389 | mStatus = CONFIRMED; |
382 | else if (ss == "DECLINED") | 390 | else if (ss == "DECLINED") |
383 | mStatus = DECLINED; | 391 | mStatus = DECLINED; |
384 | else if (ss == "COMPLETED") | 392 | else if (ss == "COMPLETED") |
385 | mStatus = COMPLETED; | 393 | mStatus = COMPLETED; |
386 | else if (ss == "DELEGATED") | 394 | else if (ss == "DELEGATED") |
387 | mStatus = DELEGATED; | 395 | mStatus = DELEGATED; |
388 | 396 | ||
389 | updated(); | 397 | updated(); |
390 | } | 398 | } |
391 | 399 | ||
392 | void Todo::setStatus(int status) | 400 | void Todo::setStatus(int status) |
393 | { | 401 | { |
394 | if (mReadOnly) return; | 402 | if (mReadOnly) return; |
395 | mStatus = status; | 403 | mStatus = status; |
396 | updated(); | 404 | updated(); |
397 | } | 405 | } |
398 | 406 | ||
399 | int Todo::status() const | 407 | int Todo::status() const |
400 | { | 408 | { |
401 | return mStatus; | 409 | return mStatus; |
402 | } | 410 | } |
403 | 411 | ||
404 | QString Todo::statusStr() const | 412 | QString Todo::statusStr() const |
405 | { | 413 | { |
406 | switch(mStatus) { | 414 | switch(mStatus) { |
407 | case NEEDS_ACTION: | 415 | case NEEDS_ACTION: |
408 | return QString("NEEDS ACTION"); | 416 | return QString("NEEDS ACTION"); |
409 | break; | 417 | break; |
410 | case ACCEPTED: | 418 | case ACCEPTED: |
411 | return QString("ACCEPTED"); | 419 | return QString("ACCEPTED"); |
412 | break; | 420 | break; |
413 | case SENT: | 421 | case SENT: |
414 | return QString("SENT"); | 422 | return QString("SENT"); |
415 | break; | 423 | break; |
416 | case TENTATIVE: | 424 | case TENTATIVE: |
417 | return QString("TENTATIVE"); | 425 | return QString("TENTATIVE"); |
418 | break; | 426 | break; |
419 | case CONFIRMED: | 427 | case CONFIRMED: |
420 | return QString("CONFIRMED"); | 428 | return QString("CONFIRMED"); |
421 | break; | 429 | break; |
422 | case DECLINED: | 430 | case DECLINED: |
423 | return QString("DECLINED"); | 431 | return QString("DECLINED"); |
424 | break; | 432 | break; |
425 | case COMPLETED: | 433 | case COMPLETED: |
426 | return QString("COMPLETED"); | 434 | return QString("COMPLETED"); |
427 | break; | 435 | break; |
428 | case DELEGATED: | 436 | case DELEGATED: |
429 | return QString("DELEGATED"); | 437 | return QString("DELEGATED"); |
430 | break; | 438 | break; |
431 | } | 439 | } |
432 | return QString(""); | 440 | return QString(""); |
433 | } | 441 | } |
434 | #endif | 442 | #endif |
435 | 443 | ||
436 | bool Todo::isCompleted() const | 444 | bool Todo::isCompleted() const |
437 | { | 445 | { |
438 | if (mPercentComplete == 100) { | 446 | if (mPercentComplete == 100) { |
439 | return true; | 447 | return true; |
440 | } | 448 | } |
441 | else return false; | 449 | else return false; |
442 | } | 450 | } |
443 | 451 | ||
444 | void Todo::setCompleted(bool completed) | 452 | void Todo::setCompleted(bool completed) |
445 | { | 453 | { |
446 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { | 454 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { |
447 | if ( !setRecurDates() ) | 455 | if ( !setRecurDates() ) |
448 | completed = false; | 456 | completed = false; |
449 | } | 457 | } |
450 | if (completed) mPercentComplete = 100; | 458 | if (completed) mPercentComplete = 100; |
451 | else { | 459 | else { |
452 | mPercentComplete = 0; | 460 | mPercentComplete = 0; |
453 | mHasCompletedDate = false; | 461 | mHasCompletedDate = false; |
454 | } | 462 | } |
455 | updated(); | 463 | updated(); |
456 | } | 464 | } |
457 | 465 | ||
458 | QDateTime Todo::completed() const | 466 | QDateTime Todo::completed() const |
459 | { | 467 | { |
460 | return mCompleted; | 468 | return mCompleted; |
461 | } | 469 | } |
462 | 470 | ||
463 | QString Todo::completedStr( bool shortF ) const | 471 | QString Todo::completedStr( bool shortF ) const |
464 | { | 472 | { |
465 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); | 473 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); |
466 | } | 474 | } |
467 | 475 | ||
468 | void Todo::setCompleted(const QDateTime &completed) | 476 | void Todo::setCompleted(const QDateTime &completed) |
469 | { | 477 | { |
470 | //qDebug("Todo::setCompleted "); | 478 | //qDebug("Todo::setCompleted "); |
471 | if ( mHasCompletedDate ) { | 479 | if ( mHasCompletedDate ) { |
472 | // qDebug("has completed data - return "); | 480 | // qDebug("has completed data - return "); |
473 | return; | 481 | return; |
474 | } | 482 | } |
475 | mHasCompletedDate = true; | 483 | mHasCompletedDate = true; |
476 | mPercentComplete = 100; | 484 | mPercentComplete = 100; |
477 | mCompleted = getEvenTime(completed); | 485 | mCompleted = getEvenTime(completed); |
478 | updated(); | 486 | updated(); |
479 | } | 487 | } |
480 | 488 | ||
481 | bool Todo::hasCompletedDate() const | 489 | bool Todo::hasCompletedDate() const |
482 | { | 490 | { |
483 | return mHasCompletedDate; | 491 | return mHasCompletedDate; |
484 | } | 492 | } |
485 | 493 | ||
486 | int Todo::percentComplete() const | 494 | int Todo::percentComplete() const |
487 | { | 495 | { |
488 | return mPercentComplete; | 496 | return mPercentComplete; |
489 | } | 497 | } |
490 | bool Todo::setRecurDates() | 498 | bool Todo::setRecurDates() |
491 | { | 499 | { |
492 | if ( !mHasRecurrenceID ) | 500 | if ( !mHasRecurrenceID ) |
493 | return true; | 501 | return true; |
494 | int secs = mDtStart.secsTo( dtDue() ); | 502 | int secs = mDtStart.secsTo( dtDue() ); |
495 | bool ok; | 503 | bool ok; |
496 | qDebug("T:setRecurDates() "); | 504 | qDebug("T:setRecurDates() "); |
497 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 505 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
498 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); | 506 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); |
499 | if ( ok ) { | 507 | if ( ok ) { |
500 | mRecurrenceID = next; | 508 | mRecurrenceID = next; |
501 | mDtStart = next; | 509 | mDtStart = next; |
502 | setDtDue( next.addSecs( secs ) ); | 510 | setDtDue( next.addSecs( secs ) ); |
503 | if ( QDateTime::currentDateTime() > next) | 511 | if ( QDateTime::currentDateTime() > next) |
504 | return false; | 512 | return false; |
505 | } else { | 513 | } else { |
506 | setHasRecurrenceID( false ); | 514 | setHasRecurrenceID( false ); |
507 | recurrence()->unsetRecurs(); | 515 | recurrence()->unsetRecurs(); |
508 | } | 516 | } |
509 | return true; | 517 | return true; |
510 | } | 518 | } |
511 | void Todo::setPercentComplete(int v) | 519 | void Todo::setPercentComplete(int v) |
512 | { | 520 | { |
513 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { | 521 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { |
514 | if ( !setRecurDates() ) | 522 | if ( !setRecurDates() ) |
515 | v = 0; | 523 | v = 0; |
516 | } | 524 | } |
517 | mPercentComplete = v; | 525 | mPercentComplete = v; |
518 | if ( v != 100 ) | 526 | if ( v != 100 ) |
519 | mHasCompletedDate = false; | 527 | mHasCompletedDate = false; |
520 | updated(); | 528 | updated(); |
521 | } | 529 | } |
522 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const | 530 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const |
523 | { | 531 | { |
524 | if ( isCompleted() || ! hasDueDate() || cancelled() || !alarmEnabled() ) { | 532 | if ( isCompleted() || ! hasDueDate() || cancelled() || !alarmEnabled() ) { |
525 | *ok = false; | 533 | *ok = false; |
526 | return QDateTime (); | 534 | return QDateTime (); |
527 | } | 535 | } |
528 | QDateTime incidenceStart; | 536 | QDateTime incidenceStart; |
529 | incidenceStart = dtDue(); | 537 | incidenceStart = dtDue(); |
530 | bool enabled = false; | 538 | bool enabled = false; |
531 | Alarm* alarm; | 539 | Alarm* alarm; |
532 | int off = 0; | 540 | int off = 0; |
533 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 541 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
534 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 542 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
535 | // *ok = false; | 543 | // *ok = false; |
536 | // return incidenceStart; | 544 | // return incidenceStart; |
537 | // } | 545 | // } |
538 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 546 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
539 | if (alarm->enabled()) { | 547 | if (alarm->enabled()) { |
540 | if ( alarm->hasTime () ) { | 548 | if ( alarm->hasTime () ) { |
541 | if ( alarm->time() < alarmStart ) { | 549 | if ( alarm->time() < alarmStart ) { |
542 | alarmStart = alarm->time(); | 550 | alarmStart = alarm->time(); |
543 | enabled = true; | 551 | enabled = true; |
544 | off = alarmStart.secsTo( incidenceStart ); | 552 | off = alarmStart.secsTo( incidenceStart ); |
545 | } | 553 | } |
546 | 554 | ||
547 | } else { | 555 | } else { |
548 | int secs = alarm->startOffset().asSeconds(); | 556 | int secs = alarm->startOffset().asSeconds(); |
549 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 557 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
550 | alarmStart = incidenceStart.addSecs( secs ); | 558 | alarmStart = incidenceStart.addSecs( secs ); |
551 | enabled = true; | 559 | enabled = true; |
552 | off = -secs; | 560 | off = -secs; |
553 | } | 561 | } |
554 | } | 562 | } |
555 | } | 563 | } |
556 | } | 564 | } |
557 | if ( enabled ) { | 565 | if ( enabled ) { |
558 | if ( alarmStart > start_dt ) { | 566 | if ( alarmStart > start_dt ) { |
559 | *ok = true; | 567 | *ok = true; |
560 | * offset = off; | 568 | * offset = off; |
561 | return alarmStart; | 569 | return alarmStart; |
562 | } | 570 | } |
563 | } | 571 | } |
564 | *ok = false; | 572 | *ok = false; |
565 | return QDateTime (); | 573 | return QDateTime (); |
566 | 574 | ||
567 | } | 575 | } |
568 | 576 | ||
569 | void Todo::checkSetCompletedFalse() | 577 | void Todo::checkSetCompletedFalse() |
570 | { | 578 | { |
571 | if ( !mHasRecurrenceID ) { | 579 | if ( !mHasRecurrenceID ) { |
572 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); | 580 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); |
573 | return; | 581 | return; |
574 | } | 582 | } |
575 | // qDebug("Todo::checkSetCompletedFalse()"); | 583 | // qDebug("Todo::checkSetCompletedFalse()"); |
576 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 584 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
577 | if ( mPercentComplete == 100 ) { | 585 | if ( mPercentComplete == 100 ) { |
578 | QDateTime dt = QDateTime::currentDateTime(); | 586 | QDateTime dt = QDateTime::currentDateTime(); |
579 | if ( dt > mDtStart && dt > mRecurrenceID ) { | 587 | if ( dt > mDtStart && dt > mRecurrenceID ) { |
580 | qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 588 | qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
581 | setCompleted( false ); | 589 | setCompleted( false ); |
582 | qDebug("Todo::checkSetCompletedFalse "); | 590 | qDebug("Todo::checkSetCompletedFalse "); |
583 | } | 591 | } |
584 | } | 592 | } |
585 | } | 593 | } |
diff --git a/libkcal/todo.h b/libkcal/todo.h index 6fc4d4b..42db025 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -1,152 +1,153 @@ | |||
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 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | 29 | ||
30 | namespace KCal { | 30 | namespace KCal { |
31 | 31 | ||
32 | /** | 32 | /** |
33 | This class provides a Todo in the sense of RFC2445. | 33 | This class provides a Todo in the sense of RFC2445. |
34 | */ | 34 | */ |
35 | class Todo : public QObject,public Incidence | 35 | class Todo : public QObject,public Incidence |
36 | { | 36 | { |
37 | Q_OBJECT | 37 | Q_OBJECT |
38 | public: | 38 | public: |
39 | Todo(); | 39 | Todo(); |
40 | Todo(const Todo &); | 40 | Todo(const Todo &); |
41 | ~Todo(); | 41 | ~Todo(); |
42 | typedef ListBase<Todo> List; | 42 | typedef ListBase<Todo> List; |
43 | QCString type() const { return "Todo"; } | 43 | QCString type() const { return "Todo"; } |
44 | IncTypeID typeID() const { return todoID; } | 44 | IncTypeID typeID() const { return todoID; } |
45 | 45 | ||
46 | /** Return an exact copy of this todo. */ | 46 | /** Return an exact copy of this todo. */ |
47 | Incidence *clone(); | 47 | Incidence *clone(); |
48 | QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const; | 48 | QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const; |
49 | 49 | ||
50 | /** for setting the todo's due date/time with a QDateTime. */ | 50 | /** for setting the todo's due date/time with a QDateTime. */ |
51 | void setDtDue(const QDateTime &dtDue); | 51 | void setDtDue(const QDateTime &dtDue); |
52 | /** returns an event's Due date/time as a QDateTime. */ | 52 | /** returns an event's Due date/time as a QDateTime. */ |
53 | QDateTime dtDue() const; | 53 | QDateTime dtDue() const; |
54 | /** returns an event's due time as a string formatted according to the | 54 | /** returns an event's due time as a string formatted according to the |
55 | users locale settings */ | 55 | users locale settings */ |
56 | QString dtDueTimeStr() const; | 56 | QString dtDueTimeStr() const; |
57 | /** returns an event's due date as a string formatted according to the | 57 | /** returns an event's due date as a string formatted according to the |
58 | users locale settings */ | 58 | users locale settings */ |
59 | QString dtDueDateStr(bool shortfmt=true) const; | 59 | QString dtDueDateStr(bool shortfmt=true) const; |
60 | /** returns an event's due date and time as a string formatted according | 60 | /** returns an event's due date and time as a string formatted according |
61 | to the users locale settings */ | 61 | to the users locale settings */ |
62 | QString dtDueStr(bool shortfmt=true) const; | 62 | QString dtDueStr(bool shortfmt=true) const; |
63 | 63 | ||
64 | /** returns TRUE or FALSE depending on whether the todo has a due date */ | 64 | /** returns TRUE or FALSE depending on whether the todo has a due date */ |
65 | bool hasDueDate() const; | 65 | bool hasDueDate() const; |
66 | /** sets the event's hasDueDate value. */ | 66 | /** sets the event's hasDueDate value. */ |
67 | void setHasDueDate(bool f); | 67 | void setHasDueDate(bool f); |
68 | 68 | ||
69 | /* | 69 | /* |
70 | Looks for a subtodo (including itself ) which is not complete and is | 70 | Looks for a subtodo (including itself ) which is not complete and is |
71 | - overdue, or | 71 | - overdue, or |
72 | - due today. | 72 | - due today. |
73 | It returns 0 for nothing found, | 73 | It returns 0 for nothing found, |
74 | 1 for found a todo which is due today and no overdue found | 74 | 1 for found a todo which is due today and no overdue found |
75 | 2 for found a overdue todo | 75 | 2 for found a overdue todo |
76 | */ | 76 | */ |
77 | int hasDueSubTodo( bool checkSubtodos = true ); | 77 | int hasDueSubTodo( bool checkSubtodos = true ); |
78 | /* same as above, but a specific date can be specified*/ | 78 | /* same as above, but a specific date can be specified*/ |
79 | int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ); | 79 | int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ); |
80 | 80 | ||
81 | 81 | ||
82 | /** sets the event's status to the string specified. The string | 82 | /** sets the event's status to the string specified. The string |
83 | * must be a recognized value for the status field, i.e. a string | 83 | * must be a recognized value for the status field, i.e. a string |
84 | * equivalent of the possible status enumerations previously described. */ | 84 | * equivalent of the possible status enumerations previously described. */ |
85 | // void setStatus(const QString &statStr); | 85 | // void setStatus(const QString &statStr); |
86 | /** sets the event's status to the value specified. See the enumeration | 86 | /** sets the event's status to the value specified. See the enumeration |
87 | * above for possible values. */ | 87 | * above for possible values. */ |
88 | // void setStatus(int); | 88 | // void setStatus(int); |
89 | /** return the event's status. */ | 89 | /** return the event's status. */ |
90 | // int status() const; | 90 | // int status() const; |
91 | /** return the event's status in string format. */ | 91 | /** return the event's status in string format. */ |
92 | // QString statusStr() const; | 92 | // QString statusStr() const; |
93 | 93 | ||
94 | /** return, if this todo is completed */ | 94 | /** return, if this todo is completed */ |
95 | bool isCompleted() const; | 95 | bool isCompleted() const; |
96 | /** set completed state of this todo */ | 96 | /** set completed state of this todo */ |
97 | void setCompleted(bool); | 97 | void setCompleted(bool); |
98 | 98 | ||
99 | /** | 99 | /** |
100 | Return how many percent of the task are completed. Returns a value | 100 | Return how many percent of the task are completed. Returns a value |
101 | between 0 and 100. | 101 | between 0 and 100. |
102 | */ | 102 | */ |
103 | int percentComplete() const; | 103 | int percentComplete() const; |
104 | /** | 104 | /** |
105 | Set how many percent of the task are completed. Valid values are in the | 105 | Set how many percent of the task are completed. Valid values are in the |
106 | range from 0 to 100. | 106 | range from 0 to 100. |
107 | */ | 107 | */ |
108 | void setPercentComplete(int); | 108 | void setPercentComplete(int); |
109 | 109 | ||
110 | /** return date and time when todo was completed */ | 110 | /** return date and time when todo was completed */ |
111 | QDateTime completed() const; | 111 | QDateTime completed() const; |
112 | QString completedStr(bool shortF = true) const; | 112 | QString completedStr(bool shortF = true) const; |
113 | /** set date and time of completion */ | 113 | /** set date and time of completion */ |
114 | void setCompleted(const QDateTime &completed); | 114 | void setCompleted(const QDateTime &completed); |
115 | 115 | ||
116 | /** Return true, if todo has a date associated with completion */ | 116 | /** Return true, if todo has a date associated with completion */ |
117 | bool hasCompletedDate() const; | 117 | bool hasCompletedDate() const; |
118 | bool contains ( Todo*); | 118 | bool contains ( Todo*); |
119 | void checkSetCompletedFalse(); | 119 | void checkSetCompletedFalse(); |
120 | bool setRecurDates(); | 120 | bool setRecurDates(); |
121 | bool isRunning() {return mRunning;} | 121 | bool isRunning() {return mRunning;} |
122 | bool hasRunningSub(); | 122 | bool hasRunningSub(); |
123 | void setRunning( bool ); | 123 | void setRunning( bool ); |
124 | void setRunningFalse( QString ); | 124 | void setRunningFalse( QString ); |
125 | void stopRunning(); | ||
125 | int runTime(); | 126 | int runTime(); |
126 | QDateTime runStart () const { return mRunStart;} | 127 | QDateTime runStart () const { return mRunStart;} |
127 | public slots: | 128 | public slots: |
128 | void saveRunningInfoToFile( QString st ); | 129 | void saveRunningInfoToFile( QString st ); |
129 | void saveRunningInfoToFile( ); | 130 | void saveRunningInfoToFile( ); |
130 | void saveParents(); | 131 | void saveParents(); |
131 | private: | 132 | private: |
132 | bool mRunning; | 133 | bool mRunning; |
133 | QTimer * mRunSaveTimer; | 134 | QTimer * mRunSaveTimer; |
134 | QDateTime mRunStart; | 135 | QDateTime mRunStart; |
135 | bool accept(Visitor &v) { return v.visit(this); } | 136 | bool accept(Visitor &v) { return v.visit(this); } |
136 | 137 | ||
137 | QDateTime mDtDue; // due date of todo | 138 | QDateTime mDtDue; // due date of todo |
138 | 139 | ||
139 | bool mHasDueDate; // if todo has associated due date | 140 | bool mHasDueDate; // if todo has associated due date |
140 | 141 | ||
141 | // int mStatus; // confirmed/delegated/tentative/etc | 142 | // int mStatus; // confirmed/delegated/tentative/etc |
142 | 143 | ||
143 | QDateTime mCompleted; | 144 | QDateTime mCompleted; |
144 | bool mHasCompletedDate; | 145 | bool mHasCompletedDate; |
145 | 146 | ||
146 | int mPercentComplete; | 147 | int mPercentComplete; |
147 | }; | 148 | }; |
148 | 149 | ||
149 | bool operator==( const Todo&, const Todo& ); | 150 | bool operator==( const Todo&, const Todo& ); |
150 | } | 151 | } |
151 | 152 | ||
152 | #endif | 153 | #endif |