author | zautrix <zautrix> | 2005-06-13 23:07:29 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-13 23:07:29 (UTC) |
commit | b3743f5abe0a95c9ffeadf6701c9943f604febd6 (patch) (unidiff) | |
tree | ca7b4fa180795d5d6fb7b212eea74e0ddf2e73ad /libkcal | |
parent | 35d40d945aed8c9e7c3389182014a2d99edb5254 (diff) | |
download | kdepimpi-b3743f5abe0a95c9ffeadf6701c9943f604febd6.zip kdepimpi-b3743f5abe0a95c9ffeadf6701c9943f604febd6.tar.gz kdepimpi-b3743f5abe0a95c9ffeadf6701c9943f604febd6.tar.bz2 |
fixxx
-rw-r--r-- | libkcal/todo.cpp | 4 | ||||
-rw-r--r-- | libkcal/todo.h | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 42274ff..e98af3c 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -1,282 +1,286 @@ | |||
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::setRunning( bool run ) | 72 | void Todo::setRunning( bool run ) |
73 | { | 73 | { |
74 | if ( run == mRunning ) | 74 | if ( run == mRunning ) |
75 | return; | 75 | return; |
76 | //qDebug("Todo::setRunning %d ", run); | 76 | //qDebug("Todo::setRunning %d ", run); |
77 | if ( !mRunSaveTimer ) { | 77 | if ( !mRunSaveTimer ) { |
78 | mRunSaveTimer = new QTimer ( this ); | 78 | mRunSaveTimer = new QTimer ( this ); |
79 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); | 79 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); |
80 | } | 80 | } |
81 | mRunning = run; | 81 | mRunning = run; |
82 | if ( mRunning ) { | 82 | if ( mRunning ) { |
83 | mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min | 83 | mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min |
84 | mRunStart = QDateTime::currentDateTime(); | 84 | mRunStart = QDateTime::currentDateTime(); |
85 | } else { | 85 | } else { |
86 | mRunSaveTimer->stop(); | 86 | mRunSaveTimer->stop(); |
87 | saveRunningInfoToFile(); | 87 | saveRunningInfoToFile(); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | void Todo::saveRunningInfoToFile() | ||
92 | { | ||
93 | saveRunningInfoToFile( QString::null ); | ||
94 | } | ||
91 | void Todo::saveRunningInfoToFile( QString comment ) | 95 | void Todo::saveRunningInfoToFile( QString comment ) |
92 | { | 96 | { |
93 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); | 97 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); |
94 | if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) { | 98 | if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) { |
95 | qDebug("Running time < 30 seconds. Skipped. "); | 99 | qDebug("Running time < 30 seconds. Skipped. "); |
96 | return; | 100 | return; |
97 | } | 101 | } |
98 | QString dir = KGlobalSettings::timeTrackerDir(); | 102 | QString dir = KGlobalSettings::timeTrackerDir(); |
99 | //qDebug("%s ", dir.latin1()); | 103 | //qDebug("%s ", dir.latin1()); |
100 | QString file = "%1%2%3-%4%5%6-"; | 104 | QString file = "%1%2%3-%4%5%6-"; |
101 | 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 ); | 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 ); |
102 | file.replace ( QRegExp (" "), "0" ); | 106 | file.replace ( QRegExp (" "), "0" ); |
103 | file += uid(); | 107 | file += uid(); |
104 | //qDebug("File %s ",file.latin1() ); | 108 | //qDebug("File %s ",file.latin1() ); |
105 | CalendarLocal cal; | 109 | CalendarLocal cal; |
106 | cal.setLocalTime(); | 110 | cal.setLocalTime(); |
107 | Todo * to = (Todo*) clone(); | 111 | Todo * to = (Todo*) clone(); |
108 | to->setFloats( false ); | 112 | to->setFloats( false ); |
109 | to->setDtStart( mRunStart ); | 113 | to->setDtStart( mRunStart ); |
110 | to->setHasStartDate( true ); | 114 | to->setHasStartDate( true ); |
111 | to->setDtDue( QDateTime::currentDateTime() ); | 115 | to->setDtDue( QDateTime::currentDateTime() ); |
112 | to->setHasDueDate( true ); | 116 | to->setHasDueDate( true ); |
113 | to->setUid( file ); | 117 | to->setUid( file ); |
114 | if ( !comment.isEmpty() ) { | 118 | if ( !comment.isEmpty() ) { |
115 | QString des = to->description(); | 119 | QString des = to->description(); |
116 | if ( des.isEmpty () ) | 120 | if ( des.isEmpty () ) |
117 | to->setDescription( "TT-Note: " + comment ); | 121 | to->setDescription( "TT-Note: " + comment ); |
118 | else | 122 | else |
119 | to->setDescription( "TT-Note: " + comment +"\n" + des ); | 123 | to->setDescription( "TT-Note: " + comment +"\n" + des ); |
120 | } | 124 | } |
121 | cal.addIncidence( to ); | 125 | cal.addIncidence( to ); |
122 | ICalFormat format; | 126 | ICalFormat format; |
123 | file = dir +"/" +file +".ics"; | 127 | file = dir +"/" +file +".ics"; |
124 | format.save( &cal, file ); | 128 | format.save( &cal, file ); |
125 | saveParents(); | 129 | saveParents(); |
126 | 130 | ||
127 | } | 131 | } |
128 | void Todo::saveParents() | 132 | void Todo::saveParents() |
129 | { | 133 | { |
130 | if (!relatedTo() ) | 134 | if (!relatedTo() ) |
131 | return; | 135 | return; |
132 | Incidence * inc = relatedTo(); | 136 | Incidence * inc = relatedTo(); |
133 | if ( inc->typeID() != todoID ) | 137 | if ( inc->typeID() != todoID ) |
134 | return; | 138 | return; |
135 | Todo* to = (Todo*)inc; | 139 | Todo* to = (Todo*)inc; |
136 | bool saveTodo = false; | 140 | bool saveTodo = false; |
137 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; | 141 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; |
138 | QFileInfo fi ( file ); | 142 | QFileInfo fi ( file ); |
139 | if ( fi.exists() ) { | 143 | if ( fi.exists() ) { |
140 | if ( fi.lastModified () < to->lastModified ()) | 144 | if ( fi.lastModified () < to->lastModified ()) |
141 | saveTodo = true; | 145 | saveTodo = true; |
142 | } else { | 146 | } else { |
143 | saveTodo = true; | 147 | saveTodo = true; |
144 | } | 148 | } |
145 | if ( saveTodo ) { | 149 | if ( saveTodo ) { |
146 | CalendarLocal cal; | 150 | CalendarLocal cal; |
147 | cal.setLocalTime(); | 151 | cal.setLocalTime(); |
148 | Todo * par = (Todo *) to->clone(); | 152 | Todo * par = (Todo *) to->clone(); |
149 | cal.addIncidence( par ); | 153 | cal.addIncidence( par ); |
150 | ICalFormat format; | 154 | ICalFormat format; |
151 | format.save( &cal, file ); | 155 | format.save( &cal, file ); |
152 | } | 156 | } |
153 | to->saveParents(); | 157 | to->saveParents(); |
154 | } | 158 | } |
155 | 159 | ||
156 | int Todo::runTime() | 160 | int Todo::runTime() |
157 | { | 161 | { |
158 | if ( !mRunning ) | 162 | if ( !mRunning ) |
159 | return 0; | 163 | return 0; |
160 | return mRunStart.secsTo( QDateTime::currentDateTime() ); | 164 | return mRunStart.secsTo( QDateTime::currentDateTime() ); |
161 | } | 165 | } |
162 | bool Todo::hasRunningSub() | 166 | bool Todo::hasRunningSub() |
163 | { | 167 | { |
164 | if ( mRunning ) | 168 | if ( mRunning ) |
165 | return true; | 169 | return true; |
166 | Incidence *aTodo; | 170 | Incidence *aTodo; |
167 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | 171 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { |
168 | if ( ((Todo*)aTodo)->hasRunningSub() ) | 172 | if ( ((Todo*)aTodo)->hasRunningSub() ) |
169 | return true; | 173 | return true; |
170 | } | 174 | } |
171 | return false; | 175 | return false; |
172 | } | 176 | } |
173 | Incidence *Todo::clone() | 177 | Incidence *Todo::clone() |
174 | { | 178 | { |
175 | return new Todo(*this); | 179 | return new Todo(*this); |
176 | } | 180 | } |
177 | 181 | ||
178 | bool Todo::contains ( Todo* from ) | 182 | bool Todo::contains ( Todo* from ) |
179 | { | 183 | { |
180 | 184 | ||
181 | if ( !from->summary().isEmpty() ) | 185 | if ( !from->summary().isEmpty() ) |
182 | if ( !summary().startsWith( from->summary() )) | 186 | if ( !summary().startsWith( from->summary() )) |
183 | return false; | 187 | return false; |
184 | if ( from->hasStartDate() ) { | 188 | if ( from->hasStartDate() ) { |
185 | if ( !hasStartDate() ) | 189 | if ( !hasStartDate() ) |
186 | return false; | 190 | return false; |
187 | if ( from->dtStart() != dtStart()) | 191 | if ( from->dtStart() != dtStart()) |
188 | return false; | 192 | return false; |
189 | } | 193 | } |
190 | if ( from->hasDueDate() ){ | 194 | if ( from->hasDueDate() ){ |
191 | if ( !hasDueDate() ) | 195 | if ( !hasDueDate() ) |
192 | return false; | 196 | return false; |
193 | if ( from->dtDue() != dtDue()) | 197 | if ( from->dtDue() != dtDue()) |
194 | return false; | 198 | return false; |
195 | } | 199 | } |
196 | if ( !from->location().isEmpty() ) | 200 | if ( !from->location().isEmpty() ) |
197 | if ( !location().startsWith( from->location() ) ) | 201 | if ( !location().startsWith( from->location() ) ) |
198 | return false; | 202 | return false; |
199 | if ( !from->description().isEmpty() ) | 203 | if ( !from->description().isEmpty() ) |
200 | if ( !description().startsWith( from->description() )) | 204 | if ( !description().startsWith( from->description() )) |
201 | return false; | 205 | return false; |
202 | if ( from->alarms().count() ) { | 206 | if ( from->alarms().count() ) { |
203 | Alarm *a = from->alarms().first(); | 207 | Alarm *a = from->alarms().first(); |
204 | if ( a->enabled() ){ | 208 | if ( a->enabled() ){ |
205 | if ( !alarms().count() ) | 209 | if ( !alarms().count() ) |
206 | return false; | 210 | return false; |
207 | Alarm *b = alarms().first(); | 211 | Alarm *b = alarms().first(); |
208 | if( ! b->enabled() ) | 212 | if( ! b->enabled() ) |
209 | return false; | 213 | return false; |
210 | if ( ! (a->offset() == b->offset() )) | 214 | if ( ! (a->offset() == b->offset() )) |
211 | return false; | 215 | return false; |
212 | } | 216 | } |
213 | } | 217 | } |
214 | 218 | ||
215 | QStringList cat = categories(); | 219 | QStringList cat = categories(); |
216 | QStringList catFrom = from->categories(); | 220 | QStringList catFrom = from->categories(); |
217 | QString nCat; | 221 | QString nCat; |
218 | unsigned int iii; | 222 | unsigned int iii; |
219 | for ( iii = 0; iii < catFrom.count();++iii ) { | 223 | for ( iii = 0; iii < catFrom.count();++iii ) { |
220 | nCat = catFrom[iii]; | 224 | nCat = catFrom[iii]; |
221 | if ( !nCat.isEmpty() ) | 225 | if ( !nCat.isEmpty() ) |
222 | if ( !cat.contains( nCat )) { | 226 | if ( !cat.contains( nCat )) { |
223 | return false; | 227 | return false; |
224 | } | 228 | } |
225 | } | 229 | } |
226 | if ( from->isCompleted() ) { | 230 | if ( from->isCompleted() ) { |
227 | if ( !isCompleted() ) | 231 | if ( !isCompleted() ) |
228 | return false; | 232 | return false; |
229 | } | 233 | } |
230 | if( priority() != from->priority() ) | 234 | if( priority() != from->priority() ) |
231 | return false; | 235 | return false; |
232 | 236 | ||
233 | 237 | ||
234 | return true; | 238 | return true; |
235 | 239 | ||
236 | } | 240 | } |
237 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) | 241 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) |
238 | { | 242 | { |
239 | 243 | ||
240 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); | 244 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); |
241 | if ( ! ret ) | 245 | if ( ! ret ) |
242 | return false; | 246 | return false; |
243 | if ( t1.hasDueDate() == t2.hasDueDate() ) { | 247 | if ( t1.hasDueDate() == t2.hasDueDate() ) { |
244 | if ( t1.hasDueDate() ) { | 248 | if ( t1.hasDueDate() ) { |
245 | if ( t1.doesFloat() == t2.doesFloat() ) { | 249 | if ( t1.doesFloat() == t2.doesFloat() ) { |
246 | if ( t1.doesFloat() ) { | 250 | if ( t1.doesFloat() ) { |
247 | if ( t1.dtDue().date() != t2.dtDue().date() ) | 251 | if ( t1.dtDue().date() != t2.dtDue().date() ) |
248 | return false; | 252 | return false; |
249 | } else | 253 | } else |
250 | if ( t1.dtDue() != t2.dtDue() ) | 254 | if ( t1.dtDue() != t2.dtDue() ) |
251 | return false; | 255 | return false; |
252 | } else | 256 | } else |
253 | return false;// float != | 257 | return false;// float != |
254 | } | 258 | } |
255 | 259 | ||
256 | } else | 260 | } else |
257 | return false; | 261 | return false; |
258 | if ( t1.percentComplete() != t2.percentComplete() ) | 262 | if ( t1.percentComplete() != t2.percentComplete() ) |
259 | return false; | 263 | return false; |
260 | if ( t1.isCompleted() ) { | 264 | if ( t1.isCompleted() ) { |
261 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { | 265 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { |
262 | if ( t1.hasCompletedDate() ) { | 266 | if ( t1.hasCompletedDate() ) { |
263 | if ( t1.completed() != t2.completed() ) | 267 | if ( t1.completed() != t2.completed() ) |
264 | return false; | 268 | return false; |
265 | } | 269 | } |
266 | 270 | ||
267 | } else | 271 | } else |
268 | return false; | 272 | return false; |
269 | } | 273 | } |
270 | return true; | 274 | return true; |
271 | 275 | ||
272 | } | 276 | } |
273 | 277 | ||
274 | void Todo::setDtDue(const QDateTime &dtDue) | 278 | void Todo::setDtDue(const QDateTime &dtDue) |
275 | { | 279 | { |
276 | //int diffsecs = mDtDue.secsTo(dtDue); | 280 | //int diffsecs = mDtDue.secsTo(dtDue); |
277 | 281 | ||
278 | /*if (mReadOnly) return; | 282 | /*if (mReadOnly) return; |
279 | const QPtrList<Alarm>& alarms = alarms(); | 283 | const QPtrList<Alarm>& alarms = alarms(); |
280 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { | 284 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { |
281 | if (alarm->enabled()) { | 285 | if (alarm->enabled()) { |
282 | alarm->setTime(alarm->time().addSecs(diffsecs)); | 286 | alarm->setTime(alarm->time().addSecs(diffsecs)); |
diff --git a/libkcal/todo.h b/libkcal/todo.h index 501c2ba..6fc4d4b 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -1,151 +1,152 @@ | |||
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 | int runTime(); | 125 | int runTime(); |
126 | QDateTime runStart () const { return mRunStart;} | 126 | QDateTime runStart () const { return mRunStart;} |
127 | public slots: | 127 | public slots: |
128 | void saveRunningInfoToFile( QString st = QString::null ); | 128 | void saveRunningInfoToFile( QString st ); |
129 | void saveRunningInfoToFile( ); | ||
129 | void saveParents(); | 130 | void saveParents(); |
130 | private: | 131 | private: |
131 | bool mRunning; | 132 | bool mRunning; |
132 | QTimer * mRunSaveTimer; | 133 | QTimer * mRunSaveTimer; |
133 | QDateTime mRunStart; | 134 | QDateTime mRunStart; |
134 | bool accept(Visitor &v) { return v.visit(this); } | 135 | bool accept(Visitor &v) { return v.visit(this); } |
135 | 136 | ||
136 | QDateTime mDtDue; // due date of todo | 137 | QDateTime mDtDue; // due date of todo |
137 | 138 | ||
138 | bool mHasDueDate; // if todo has associated due date | 139 | bool mHasDueDate; // if todo has associated due date |
139 | 140 | ||
140 | // int mStatus; // confirmed/delegated/tentative/etc | 141 | // int mStatus; // confirmed/delegated/tentative/etc |
141 | 142 | ||
142 | QDateTime mCompleted; | 143 | QDateTime mCompleted; |
143 | bool mHasCompletedDate; | 144 | bool mHasCompletedDate; |
144 | 145 | ||
145 | int mPercentComplete; | 146 | int mPercentComplete; |
146 | }; | 147 | }; |
147 | 148 | ||
148 | bool operator==( const Todo&, const Todo& ); | 149 | bool operator==( const Todo&, const Todo& ); |
149 | } | 150 | } |
150 | 151 | ||
151 | #endif | 152 | #endif |