-rw-r--r-- | libkcal/todo.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 70a7711..29f725f 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -1,674 +1,674 @@ | |||
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 | #ifndef DESKTOP_VERSION | 32 | #ifndef DESKTOP_VERSION |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #define SAVETIMER_TIMEOUT_SECONDS 300 | 36 | #define SAVETIMER_TIMEOUT_SECONDS 300 |
37 | //#define SAVETIMER_TIMEOUT_SECONDS 8 | 37 | //#define SAVETIMER_TIMEOUT_SECONDS 8 |
38 | #define SAVETIMER_TIMEOUT_RETRY_SECONDS 5 | 38 | #define SAVETIMER_TIMEOUT_RETRY_SECONDS 5 |
39 | 39 | ||
40 | using namespace KCal; | 40 | using namespace KCal; |
41 | 41 | ||
42 | Todo::Todo(): QObject(), Incidence() | 42 | Todo::Todo(): QObject(), Incidence() |
43 | { | 43 | { |
44 | // mStatus = TENTATIVE; | 44 | // mStatus = TENTATIVE; |
45 | 45 | ||
46 | mHasDueDate = false; | 46 | mHasDueDate = false; |
47 | setHasStartDate( false ); | 47 | setHasStartDate( false ); |
48 | mCompleted = getEvenTime(QDateTime::currentDateTime()); | 48 | mCompleted = getEvenTime(QDateTime::currentDateTime()); |
49 | mHasCompletedDate = false; | 49 | mHasCompletedDate = false; |
50 | mPercentComplete = 0; | 50 | mPercentComplete = 0; |
51 | mRunning = false; | 51 | mRunning = false; |
52 | mRunSaveTimer = 0; | 52 | mRunSaveTimer = 0; |
53 | setFloats( true ); | 53 | setFloats( true ); |
54 | mCurrentTimerDelay = 0; | 54 | mCurrentTimerDelay = 0; |
55 | } | 55 | } |
56 | 56 | ||
57 | Todo::Todo(const Todo &t) : QObject(),Incidence(t) | 57 | Todo::Todo(const Todo &t) : QObject(),Incidence(t) |
58 | { | 58 | { |
59 | mDtDue = t.mDtDue; | 59 | mDtDue = t.mDtDue; |
60 | mHasDueDate = t.mHasDueDate; | 60 | mHasDueDate = t.mHasDueDate; |
61 | mCompleted = t.mCompleted; | 61 | mCompleted = t.mCompleted; |
62 | mHasCompletedDate = t.mHasCompletedDate; | 62 | mHasCompletedDate = t.mHasCompletedDate; |
63 | mPercentComplete = t.mPercentComplete; | 63 | mPercentComplete = t.mPercentComplete; |
64 | mRunning = false; | 64 | mRunning = false; |
65 | mRunSaveTimer = 0; | 65 | mRunSaveTimer = 0; |
66 | mCurrentTimerDelay = 0; | 66 | mCurrentTimerDelay = 0; |
67 | } | 67 | } |
68 | 68 | ||
69 | Todo::~Todo() | 69 | Todo::~Todo() |
70 | { | 70 | { |
71 | setRunning( false ); | 71 | setRunning( false ); |
72 | //qDebug("Todo::~Todo() "); | 72 | //qDebug("Todo::~Todo() "); |
73 | } | 73 | } |
74 | 74 | ||
75 | void Todo::setRunningFalse( QString s ) | 75 | void Todo::setRunningFalse( QString s ) |
76 | { | 76 | { |
77 | if ( ! mRunning ) | 77 | if ( ! mRunning ) |
78 | return; | 78 | return; |
79 | mRunning = false; | 79 | mRunning = false; |
80 | if ( mRunSaveTimer ) | 80 | if ( mRunSaveTimer ) |
81 | mRunSaveTimer->stop(); | 81 | mRunSaveTimer->stop(); |
82 | saveRunningInfoToFile( s ); | 82 | saveRunningInfoToFile( s ); |
83 | } | 83 | } |
84 | void Todo::stopRunning() | 84 | void Todo::stopRunning() |
85 | { | 85 | { |
86 | if ( !mRunning ) | 86 | if ( !mRunning ) |
87 | return; | 87 | return; |
88 | if ( mRunSaveTimer ) | 88 | if ( mRunSaveTimer ) |
89 | mRunSaveTimer->stop(); | 89 | mRunSaveTimer->stop(); |
90 | mRunning = false; | 90 | mRunning = false; |
91 | } | 91 | } |
92 | void Todo::setRunning( bool run ) | 92 | void Todo::setRunning( bool run ) |
93 | { | 93 | { |
94 | if ( run == mRunning ) | 94 | if ( run == mRunning ) |
95 | return; | 95 | return; |
96 | //qDebug("Todo::setRunning %d ", run); | 96 | //qDebug("Todo::setRunning %d ", run); |
97 | if ( !mRunSaveTimer ) { | 97 | if ( !mRunSaveTimer ) { |
98 | mRunSaveTimer = new QTimer ( this ); | 98 | mRunSaveTimer = new QTimer ( this ); |
99 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( timerSlotSaveRunningInfoToFile() ) ); | 99 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( timerSlotSaveRunningInfoToFile() ) ); |
100 | } | 100 | } |
101 | mRunning = run; | 101 | mRunning = run; |
102 | mRunLastSave = QDateTime::currentDateTime(); | 102 | mRunLastSave = QDateTime::currentDateTime(); |
103 | if ( mRunning ) { | 103 | if ( mRunning ) { |
104 | restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); | 104 | restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); |
105 | mRunStart = QDateTime::currentDateTime(); | 105 | mRunStart = QDateTime::currentDateTime(); |
106 | } else { | 106 | } else { |
107 | mRunSaveTimer->stop(); | 107 | mRunSaveTimer->stop(); |
108 | saveRunningInfoToFile(); | 108 | saveRunningInfoToFile(); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) | 111 | void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) |
112 | { | 112 | { |
113 | if ( !mRunning) return; | 113 | if ( !mRunning) return; |
114 | mRunning = false; | 114 | mRunning = false; |
115 | mRunStart = start; | 115 | mRunStart = start; |
116 | mRunEnd = end; | 116 | mRunEnd = end; |
117 | saveRunningInfoToFile( comment ); | 117 | saveRunningInfoToFile( comment ); |
118 | } | 118 | } |
119 | void Todo::restartSaveTimer( int secs ) | 119 | void Todo::restartSaveTimer( int secs ) |
120 | { | 120 | { |
121 | mRunSaveTimer->start( secs * 1000 ); | 121 | mRunSaveTimer->start( secs * 1000 ); |
122 | mRunLastSave = QDateTime::currentDateTime(); | 122 | mRunLastSave = QDateTime::currentDateTime(); |
123 | mCurrentTimerDelay = secs; | 123 | mCurrentTimerDelay = secs; |
124 | } | 124 | } |
125 | void Todo::timerSlotSaveRunningInfoToFile() | 125 | void Todo::timerSlotSaveRunningInfoToFile() |
126 | { | 126 | { |
127 | mRunEnd = QDateTime::currentDateTime(); | 127 | mRunEnd = QDateTime::currentDateTime(); |
128 | int secsTo = mRunLastSave.secsTo( mRunEnd ); | 128 | int secsTo = mRunLastSave.secsTo( mRunEnd ); |
129 | //if( secsTo == 8 ) ++secsTo; | 129 | //if( secsTo == 8 ) ++secsTo; |
130 | qDebug("KO Todo::saveTimerTimeout %d %d", secsTo, mCurrentTimerDelay ); | 130 | qDebug("KO Todo::saveTimerTimeout %d %d", secsTo, mCurrentTimerDelay ); |
131 | if ( secsTo > mCurrentTimerDelay ) { | 131 | if ( secsTo > mCurrentTimerDelay ) { |
132 | qDebug("KO Todo::saveTimerTimeout restart %d ", SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 132 | qDebug("KO Todo::saveTimerTimeout restart %d ", SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
133 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 133 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
134 | return; | 134 | return; |
135 | } | 135 | } |
136 | int msecs = mRunLastSave.time().msecsTo( mRunEnd.time()); | 136 | int msecs = mRunLastSave.time().msecsTo( mRunEnd.time()); |
137 | if ( msecs < 0 ) { | 137 | if ( msecs < 0 ) { |
138 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 138 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
139 | return; | 139 | return; |
140 | } | 140 | } |
141 | // qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); | 141 | // qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); |
142 | if ( msecs > ( ( mCurrentTimerDelay * 1000 ) + 50 )) { | 142 | if ( msecs > ( ( mCurrentTimerDelay * 1000 ) + 50 )) { |
143 | qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); | 143 | qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); |
144 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 144 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
145 | return; | 145 | return; |
146 | } | 146 | } |
147 | restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); | 147 | restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); |
148 | saveRunningInfoToFile( QString::null ); | 148 | saveRunningInfoToFile( QString::null ); |
149 | } | 149 | } |
150 | void Todo::saveRunningInfoToFile() | 150 | void Todo::saveRunningInfoToFile() |
151 | { | 151 | { |
152 | mRunEnd = QDateTime::currentDateTime(); | 152 | mRunEnd = QDateTime::currentDateTime(); |
153 | saveRunningInfoToFile( QString::null ); | 153 | saveRunningInfoToFile( QString::null ); |
154 | } | 154 | } |
155 | void Todo::saveRunningInfoToFile( QString comment ) | 155 | void Todo::saveRunningInfoToFile( QString comment ) |
156 | { | 156 | { |
157 | #ifndef DESKTOP_VERSION | 157 | #ifndef DESKTOP_VERSION |
158 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); | 158 | //QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); |
159 | #endif | 159 | #endif |
160 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); | 160 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); |
161 | if ( mRunStart.secsTo ( mRunEnd) < 15 ) { | 161 | if ( mRunStart.secsTo ( mRunEnd) < 15 ) { |
162 | qDebug("Running time < 15 seconds. Skipped. "); | 162 | qDebug("Running time < 15 seconds. Skipped. "); |
163 | return; | 163 | return; |
164 | } | 164 | } |
165 | QString dir = KGlobalSettings::timeTrackerDir(); | 165 | QString dir = KGlobalSettings::timeTrackerDir(); |
166 | //qDebug("%s ", dir.latin1()); | 166 | //qDebug("%s ", dir.latin1()); |
167 | QString file = "%1%2%3-%4%5%6-"; | 167 | QString file = "%1%2%3-%4%5%6-"; |
168 | 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 ); | 168 | 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 ); |
169 | file.replace ( QRegExp (" "), "0" ); | 169 | file.replace ( QRegExp (" "), "0" ); |
170 | file += uid(); | 170 | file += uid(); |
171 | //qDebug("File %s ",file.latin1() ); | 171 | //qDebug("File %s ",file.latin1() ); |
172 | CalendarLocal cal; | 172 | CalendarLocal cal; |
173 | cal.setLocalTime(); | 173 | cal.setLocalTime(); |
174 | Todo * to = (Todo*) clone(); | 174 | Todo * to = (Todo*) clone(); |
175 | to->setFloats( false ); | 175 | to->setFloats( false ); |
176 | to->setDtStart( mRunStart ); | 176 | to->setDtStart( mRunStart ); |
177 | to->setHasStartDate( true ); | 177 | to->setHasStartDate( true ); |
178 | to->setDtDue( mRunEnd ); | 178 | to->setDtDue( mRunEnd ); |
179 | to->setHasDueDate( true ); | 179 | to->setHasDueDate( true ); |
180 | to->setUid( file ); | 180 | to->setUid( file ); |
181 | if ( !comment.isEmpty() ) { | 181 | if ( !comment.isEmpty() ) { |
182 | QString des = to->description(); | 182 | QString des = to->description(); |
183 | if ( des.isEmpty () ) | 183 | if ( des.isEmpty () ) |
184 | to->setDescription( "TT-Note: " + comment ); | 184 | to->setDescription( "TT-Note: " + comment ); |
185 | else | 185 | else |
186 | to->setDescription( "TT-Note: " + comment +"\n" + des ); | 186 | to->setDescription( "TT-Note: " + comment +"\n" + des ); |
187 | } | 187 | } |
188 | cal.addIncidence( to ); | 188 | cal.addIncidence( to ); |
189 | ICalFormat format( false ); | 189 | ICalFormat format( false ); |
190 | file = dir +"/" +file +".ics"; | 190 | file = dir +"/" +file +".ics"; |
191 | format.save( &cal, file ); | 191 | format.save( &cal, file ); |
192 | saveParents(); | 192 | saveParents(); |
193 | #ifndef DESKTOP_VERSION | 193 | #ifndef DESKTOP_VERSION |
194 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); | 194 | //QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); |
195 | #endif | 195 | #endif |
196 | } | 196 | } |
197 | void Todo::saveParents() | 197 | void Todo::saveParents() |
198 | { | 198 | { |
199 | if (!relatedTo() ) | 199 | if (!relatedTo() ) |
200 | return; | 200 | return; |
201 | Incidence * inc = relatedTo(); | 201 | Incidence * inc = relatedTo(); |
202 | if ( inc->typeID() != todoID ) | 202 | if ( inc->typeID() != todoID ) |
203 | return; | 203 | return; |
204 | Todo* to = (Todo*)inc; | 204 | Todo* to = (Todo*)inc; |
205 | bool saveTodo = false; | 205 | bool saveTodo = false; |
206 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; | 206 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; |
207 | QFileInfo fi ( file ); | 207 | QFileInfo fi ( file ); |
208 | if ( fi.exists() ) { | 208 | if ( fi.exists() ) { |
209 | if ( fi.lastModified () < to->lastModified ()) | 209 | if ( fi.lastModified () < to->lastModified ()) |
210 | saveTodo = true; | 210 | saveTodo = true; |
211 | } else { | 211 | } else { |
212 | saveTodo = true; | 212 | saveTodo = true; |
213 | } | 213 | } |
214 | if ( saveTodo ) { | 214 | if ( saveTodo ) { |
215 | CalendarLocal cal; | 215 | CalendarLocal cal; |
216 | cal.setLocalTime(); | 216 | cal.setLocalTime(); |
217 | Todo * par = (Todo *) to->clone(); | 217 | Todo * par = (Todo *) to->clone(); |
218 | cal.addIncidence( par ); | 218 | cal.addIncidence( par ); |
219 | ICalFormat format( false ); | 219 | ICalFormat format( false ); |
220 | format.save( &cal, file ); | 220 | format.save( &cal, file ); |
221 | } | 221 | } |
222 | to->saveParents(); | 222 | to->saveParents(); |
223 | } | 223 | } |
224 | 224 | ||
225 | int Todo::runTime() | 225 | int Todo::runTime() |
226 | { | 226 | { |
227 | if ( !mRunning ) | 227 | if ( !mRunning ) |
228 | return 0; | 228 | return 0; |
229 | return mRunStart.secsTo( QDateTime::currentDateTime() ); | 229 | return mRunStart.secsTo( QDateTime::currentDateTime() ); |
230 | } | 230 | } |
231 | bool Todo::hasRunningSub() | 231 | bool Todo::hasRunningSub() |
232 | { | 232 | { |
233 | if ( mRunning ) | 233 | if ( mRunning ) |
234 | return true; | 234 | return true; |
235 | Incidence *aTodo; | 235 | Incidence *aTodo; |
236 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | 236 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { |
237 | if ( ((Todo*)aTodo)->hasRunningSub() ) | 237 | if ( ((Todo*)aTodo)->hasRunningSub() ) |
238 | return true; | 238 | return true; |
239 | } | 239 | } |
240 | return false; | 240 | return false; |
241 | } | 241 | } |
242 | Incidence *Todo::clone() | 242 | Incidence *Todo::clone() |
243 | { | 243 | { |
244 | return new Todo(*this); | 244 | return new Todo(*this); |
245 | } | 245 | } |
246 | 246 | ||
247 | bool Todo::contains ( Todo* from ) | 247 | bool Todo::contains ( Todo* from ) |
248 | { | 248 | { |
249 | 249 | ||
250 | if ( !from->summary().isEmpty() ) | 250 | if ( !from->summary().isEmpty() ) |
251 | if ( !summary().startsWith( from->summary() )) | 251 | if ( !summary().startsWith( from->summary() )) |
252 | return false; | 252 | return false; |
253 | if ( from->hasStartDate() ) { | 253 | if ( from->hasStartDate() ) { |
254 | if ( !hasStartDate() ) | 254 | if ( !hasStartDate() ) |
255 | return false; | 255 | return false; |
256 | if ( from->dtStart() != dtStart()) | 256 | if ( from->dtStart() != dtStart()) |
257 | return false; | 257 | return false; |
258 | } | 258 | } |
259 | if ( from->hasDueDate() ){ | 259 | if ( from->hasDueDate() ){ |
260 | if ( !hasDueDate() ) | 260 | if ( !hasDueDate() ) |
261 | return false; | 261 | return false; |
262 | if ( from->dtDue() != dtDue()) | 262 | if ( from->dtDue() != dtDue()) |
263 | return false; | 263 | return false; |
264 | } | 264 | } |
265 | if ( !from->location().isEmpty() ) | 265 | if ( !from->location().isEmpty() ) |
266 | if ( !location().startsWith( from->location() ) ) | 266 | if ( !location().startsWith( from->location() ) ) |
267 | return false; | 267 | return false; |
268 | if ( !from->description().isEmpty() ) | 268 | if ( !from->description().isEmpty() ) |
269 | if ( !description().startsWith( from->description() )) | 269 | if ( !description().startsWith( from->description() )) |
270 | return false; | 270 | return false; |
271 | if ( from->alarms().count() ) { | 271 | if ( from->alarms().count() ) { |
272 | Alarm *a = from->alarms().first(); | 272 | Alarm *a = from->alarms().first(); |
273 | if ( a->enabled() ){ | 273 | if ( a->enabled() ){ |
274 | if ( !alarms().count() ) | 274 | if ( !alarms().count() ) |
275 | return false; | 275 | return false; |
276 | Alarm *b = alarms().first(); | 276 | Alarm *b = alarms().first(); |
277 | if( ! b->enabled() ) | 277 | if( ! b->enabled() ) |
278 | return false; | 278 | return false; |
279 | if ( ! (a->offset() == b->offset() )) | 279 | if ( ! (a->offset() == b->offset() )) |
280 | return false; | 280 | return false; |
281 | } | 281 | } |
282 | } | 282 | } |
283 | 283 | ||
284 | QStringList cat = categories(); | 284 | QStringList cat = categories(); |
285 | QStringList catFrom = from->categories(); | 285 | QStringList catFrom = from->categories(); |
286 | QString nCat; | 286 | QString nCat; |
287 | unsigned int iii; | 287 | unsigned int iii; |
288 | for ( iii = 0; iii < catFrom.count();++iii ) { | 288 | for ( iii = 0; iii < catFrom.count();++iii ) { |
289 | nCat = catFrom[iii]; | 289 | nCat = catFrom[iii]; |
290 | if ( !nCat.isEmpty() ) | 290 | if ( !nCat.isEmpty() ) |
291 | if ( !cat.contains( nCat )) { | 291 | if ( !cat.contains( nCat )) { |
292 | return false; | 292 | return false; |
293 | } | 293 | } |
294 | } | 294 | } |
295 | if ( from->isCompleted() ) { | 295 | if ( from->isCompleted() ) { |
296 | if ( !isCompleted() ) | 296 | if ( !isCompleted() ) |
297 | return false; | 297 | return false; |
298 | } | 298 | } |
299 | if( priority() != from->priority() ) | 299 | if( priority() != from->priority() ) |
300 | return false; | 300 | return false; |
301 | 301 | ||
302 | 302 | ||
303 | return true; | 303 | return true; |
304 | 304 | ||
305 | } | 305 | } |
306 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) | 306 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) |
307 | { | 307 | { |
308 | 308 | ||
309 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); | 309 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); |
310 | if ( ! ret ) | 310 | if ( ! ret ) |
311 | return false; | 311 | return false; |
312 | if ( t1.hasDueDate() == t2.hasDueDate() ) { | 312 | if ( t1.hasDueDate() == t2.hasDueDate() ) { |
313 | if ( t1.hasDueDate() ) { | 313 | if ( t1.hasDueDate() ) { |
314 | if ( t1.doesFloat() == t2.doesFloat() ) { | 314 | if ( t1.doesFloat() == t2.doesFloat() ) { |
315 | if ( t1.doesFloat() ) { | 315 | if ( t1.doesFloat() ) { |
316 | if ( t1.dtDue().date() != t2.dtDue().date() ) | 316 | if ( t1.dtDue().date() != t2.dtDue().date() ) |
317 | return false; | 317 | return false; |
318 | } else | 318 | } else |
319 | if ( t1.dtDue() != t2.dtDue() ) | 319 | if ( t1.dtDue() != t2.dtDue() ) |
320 | return false; | 320 | return false; |
321 | } else | 321 | } else |
322 | return false;// float != | 322 | return false;// float != |
323 | } | 323 | } |
324 | 324 | ||
325 | } else | 325 | } else |
326 | return false; | 326 | return false; |
327 | if ( t1.percentComplete() != t2.percentComplete() ) | 327 | if ( t1.percentComplete() != t2.percentComplete() ) |
328 | return false; | 328 | return false; |
329 | if ( t1.isCompleted() ) { | 329 | if ( t1.isCompleted() ) { |
330 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { | 330 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { |
331 | if ( t1.hasCompletedDate() ) { | 331 | if ( t1.hasCompletedDate() ) { |
332 | if ( t1.completed() != t2.completed() ) | 332 | if ( t1.completed() != t2.completed() ) |
333 | return false; | 333 | return false; |
334 | } | 334 | } |
335 | 335 | ||
336 | } else | 336 | } else |
337 | return false; | 337 | return false; |
338 | } | 338 | } |
339 | return true; | 339 | return true; |
340 | 340 | ||
341 | } | 341 | } |
342 | 342 | ||
343 | void Todo::setDtDue(const QDateTime &dtDue) | 343 | void Todo::setDtDue(const QDateTime &dtDue) |
344 | { | 344 | { |
345 | //int diffsecs = mDtDue.secsTo(dtDue); | 345 | //int diffsecs = mDtDue.secsTo(dtDue); |
346 | 346 | ||
347 | /*if (mReadOnly) return; | 347 | /*if (mReadOnly) return; |
348 | const QPtrList<Alarm>& alarms = alarms(); | 348 | const QPtrList<Alarm>& alarms = alarms(); |
349 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { | 349 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { |
350 | if (alarm->enabled()) { | 350 | if (alarm->enabled()) { |
351 | alarm->setTime(alarm->time().addSecs(diffsecs)); | 351 | alarm->setTime(alarm->time().addSecs(diffsecs)); |
352 | } | 352 | } |
353 | }*/ | 353 | }*/ |
354 | mDtDue = getEvenTime(dtDue); | 354 | mDtDue = getEvenTime(dtDue); |
355 | 355 | ||
356 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; | 356 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; |
357 | 357 | ||
358 | /*const QPtrList<Alarm>& alarms = alarms(); | 358 | /*const QPtrList<Alarm>& alarms = alarms(); |
359 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) | 359 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) |
360 | alarm->setAlarmStart(mDtDue);*/ | 360 | alarm->setAlarmStart(mDtDue);*/ |
361 | updated(); | 361 | updated(); |
362 | } | 362 | } |
363 | 363 | ||
364 | QDateTime Todo::dtDue() const | 364 | QDateTime Todo::dtDue() const |
365 | { | 365 | { |
366 | return mDtDue; | 366 | return mDtDue; |
367 | } | 367 | } |
368 | 368 | ||
369 | QString Todo::dtDueTimeStr() const | 369 | QString Todo::dtDueTimeStr() const |
370 | { | 370 | { |
371 | return KGlobal::locale()->formatTime(mDtDue.time()); | 371 | return KGlobal::locale()->formatTime(mDtDue.time()); |
372 | } | 372 | } |
373 | 373 | ||
374 | QString Todo::dtDueDateStr(bool shortfmt) const | 374 | QString Todo::dtDueDateStr(bool shortfmt) const |
375 | { | 375 | { |
376 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 376 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
377 | } | 377 | } |
378 | 378 | ||
379 | QString Todo::dtDueStr(bool shortfmt) const | 379 | QString Todo::dtDueStr(bool shortfmt) const |
380 | { | 380 | { |
381 | if ( doesFloat() ) | 381 | if ( doesFloat() ) |
382 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 382 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
383 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); | 383 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); |
384 | } | 384 | } |
385 | // retval 0 : no found | 385 | // retval 0 : no found |
386 | // 1 : due for date found | 386 | // 1 : due for date found |
387 | // 2 : overdue for date found | 387 | // 2 : overdue for date found |
388 | int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) | 388 | int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) |
389 | { | 389 | { |
390 | int retval = 0; | 390 | int retval = 0; |
391 | if ( isCompleted() ) | 391 | if ( isCompleted() ) |
392 | return 0; | 392 | return 0; |
393 | if ( hasDueDate() ) { | 393 | if ( hasDueDate() ) { |
394 | if ( dtDue().date() < date ) | 394 | if ( dtDue().date() < date ) |
395 | return 2; | 395 | return 2; |
396 | // we do not return, because we may find an overdue sub todo | 396 | // we do not return, because we may find an overdue sub todo |
397 | if ( dtDue().date() == date ) | 397 | if ( dtDue().date() == date ) |
398 | retval = 1; | 398 | retval = 1; |
399 | } | 399 | } |
400 | if ( checkSubtodos ) { | 400 | if ( checkSubtodos ) { |
401 | Incidence *aTodo; | 401 | Incidence *aTodo; |
402 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | 402 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { |
403 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); | 403 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); |
404 | if ( ret == 2 ) | 404 | if ( ret == 2 ) |
405 | return 2; | 405 | return 2; |
406 | if ( ret == 1) | 406 | if ( ret == 1) |
407 | retval = 1; | 407 | retval = 1; |
408 | } | 408 | } |
409 | } | 409 | } |
410 | return retval; | 410 | return retval; |
411 | } | 411 | } |
412 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true | 412 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true |
413 | { | 413 | { |
414 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); | 414 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); |
415 | } | 415 | } |
416 | bool Todo::hasDueDate() const | 416 | bool Todo::hasDueDate() const |
417 | { | 417 | { |
418 | return mHasDueDate; | 418 | return mHasDueDate; |
419 | } | 419 | } |
420 | 420 | ||
421 | void Todo::setHasDueDate(bool f) | 421 | void Todo::setHasDueDate(bool f) |
422 | { | 422 | { |
423 | if (mReadOnly) return; | 423 | if (mReadOnly) return; |
424 | mHasDueDate = f; | 424 | mHasDueDate = f; |
425 | updated(); | 425 | updated(); |
426 | } | 426 | } |
427 | 427 | ||
428 | 428 | ||
429 | #if 0 | 429 | #if 0 |
430 | void Todo::setStatus(const QString &statStr) | 430 | void Todo::setStatus(const QString &statStr) |
431 | { | 431 | { |
432 | if (mReadOnly) return; | 432 | if (mReadOnly) return; |
433 | QString ss(statStr.upper()); | 433 | QString ss(statStr.upper()); |
434 | 434 | ||
435 | if (ss == "X-ACTION") | 435 | if (ss == "X-ACTION") |
436 | mStatus = NEEDS_ACTION; | 436 | mStatus = NEEDS_ACTION; |
437 | else if (ss == "NEEDS ACTION") | 437 | else if (ss == "NEEDS ACTION") |
438 | mStatus = NEEDS_ACTION; | 438 | mStatus = NEEDS_ACTION; |
439 | else if (ss == "ACCEPTED") | 439 | else if (ss == "ACCEPTED") |
440 | mStatus = ACCEPTED; | 440 | mStatus = ACCEPTED; |
441 | else if (ss == "SENT") | 441 | else if (ss == "SENT") |
442 | mStatus = SENT; | 442 | mStatus = SENT; |
443 | else if (ss == "TENTATIVE") | 443 | else if (ss == "TENTATIVE") |
444 | mStatus = TENTATIVE; | 444 | mStatus = TENTATIVE; |
445 | else if (ss == "CONFIRMED") | 445 | else if (ss == "CONFIRMED") |
446 | mStatus = CONFIRMED; | 446 | mStatus = CONFIRMED; |
447 | else if (ss == "DECLINED") | 447 | else if (ss == "DECLINED") |
448 | mStatus = DECLINED; | 448 | mStatus = DECLINED; |
449 | else if (ss == "COMPLETED") | 449 | else if (ss == "COMPLETED") |
450 | mStatus = COMPLETED; | 450 | mStatus = COMPLETED; |
451 | else if (ss == "DELEGATED") | 451 | else if (ss == "DELEGATED") |
452 | mStatus = DELEGATED; | 452 | mStatus = DELEGATED; |
453 | 453 | ||
454 | updated(); | 454 | updated(); |
455 | } | 455 | } |
456 | 456 | ||
457 | void Todo::setStatus(int status) | 457 | void Todo::setStatus(int status) |
458 | { | 458 | { |
459 | if (mReadOnly) return; | 459 | if (mReadOnly) return; |
460 | mStatus = status; | 460 | mStatus = status; |
461 | updated(); | 461 | updated(); |
462 | } | 462 | } |
463 | 463 | ||
464 | int Todo::status() const | 464 | int Todo::status() const |
465 | { | 465 | { |
466 | return mStatus; | 466 | return mStatus; |
467 | } | 467 | } |
468 | 468 | ||
469 | QString Todo::statusStr() const | 469 | QString Todo::statusStr() const |
470 | { | 470 | { |
471 | switch(mStatus) { | 471 | switch(mStatus) { |
472 | case NEEDS_ACTION: | 472 | case NEEDS_ACTION: |
473 | return QString("NEEDS ACTION"); | 473 | return QString("NEEDS ACTION"); |
474 | break; | 474 | break; |
475 | case ACCEPTED: | 475 | case ACCEPTED: |
476 | return QString("ACCEPTED"); | 476 | return QString("ACCEPTED"); |
477 | break; | 477 | break; |
478 | case SENT: | 478 | case SENT: |
479 | return QString("SENT"); | 479 | return QString("SENT"); |
480 | break; | 480 | break; |
481 | case TENTATIVE: | 481 | case TENTATIVE: |
482 | return QString("TENTATIVE"); | 482 | return QString("TENTATIVE"); |
483 | break; | 483 | break; |
484 | case CONFIRMED: | 484 | case CONFIRMED: |
485 | return QString("CONFIRMED"); | 485 | return QString("CONFIRMED"); |
486 | break; | 486 | break; |
487 | case DECLINED: | 487 | case DECLINED: |
488 | return QString("DECLINED"); | 488 | return QString("DECLINED"); |
489 | break; | 489 | break; |
490 | case COMPLETED: | 490 | case COMPLETED: |
491 | return QString("COMPLETED"); | 491 | return QString("COMPLETED"); |
492 | break; | 492 | break; |
493 | case DELEGATED: | 493 | case DELEGATED: |
494 | return QString("DELEGATED"); | 494 | return QString("DELEGATED"); |
495 | break; | 495 | break; |
496 | } | 496 | } |
497 | return QString(""); | 497 | return QString(""); |
498 | } | 498 | } |
499 | #endif | 499 | #endif |
500 | 500 | ||
501 | bool Todo::isCompleted() const | 501 | bool Todo::isCompleted() const |
502 | { | 502 | { |
503 | if (mPercentComplete == 100) { | 503 | if (mPercentComplete == 100) { |
504 | return true; | 504 | return true; |
505 | } | 505 | } |
506 | else return false; | 506 | else return false; |
507 | } | 507 | } |
508 | 508 | ||
509 | void Todo::setCompleted(bool completed) | 509 | void Todo::setCompleted(bool completed) |
510 | { | 510 | { |
511 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { | 511 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { |
512 | if ( !setRecurDates() ) | 512 | if ( !setRecurDates() ) |
513 | completed = false; | 513 | completed = false; |
514 | } | 514 | } |
515 | if (completed) mPercentComplete = 100; | 515 | if (completed) mPercentComplete = 100; |
516 | else { | 516 | else { |
517 | mPercentComplete = 0; | 517 | mPercentComplete = 0; |
518 | mHasCompletedDate = false; | 518 | mHasCompletedDate = false; |
519 | } | 519 | } |
520 | updated(); | 520 | updated(); |
521 | } | 521 | } |
522 | 522 | ||
523 | QDateTime Todo::completed() const | 523 | QDateTime Todo::completed() const |
524 | { | 524 | { |
525 | return mCompleted; | 525 | return mCompleted; |
526 | } | 526 | } |
527 | 527 | ||
528 | QString Todo::completedStr( bool shortF ) const | 528 | QString Todo::completedStr( bool shortF ) const |
529 | { | 529 | { |
530 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); | 530 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); |
531 | } | 531 | } |
532 | 532 | ||
533 | void Todo::setCompleted(const QDateTime &completed) | 533 | void Todo::setCompleted(const QDateTime &completed) |
534 | { | 534 | { |
535 | //qDebug("Todo::setCompleted "); | 535 | //qDebug("Todo::setCompleted "); |
536 | if ( mHasCompletedDate ) { | 536 | if ( mHasCompletedDate ) { |
537 | // qDebug("has completed data - return "); | 537 | // qDebug("has completed data - return "); |
538 | return; | 538 | return; |
539 | } | 539 | } |
540 | mHasCompletedDate = true; | 540 | mHasCompletedDate = true; |
541 | mPercentComplete = 100; | 541 | mPercentComplete = 100; |
542 | mCompleted = getEvenTime(completed); | 542 | mCompleted = getEvenTime(completed); |
543 | updated(); | 543 | updated(); |
544 | } | 544 | } |
545 | 545 | ||
546 | bool Todo::hasCompletedDate() const | 546 | bool Todo::hasCompletedDate() const |
547 | { | 547 | { |
548 | return mHasCompletedDate; | 548 | return mHasCompletedDate; |
549 | } | 549 | } |
550 | 550 | ||
551 | int Todo::percentComplete() const | 551 | int Todo::percentComplete() const |
552 | { | 552 | { |
553 | return mPercentComplete; | 553 | return mPercentComplete; |
554 | } | 554 | } |
555 | bool Todo::setRecurDates() | 555 | bool Todo::setRecurDates() |
556 | { | 556 | { |
557 | if ( !mHasRecurrenceID ) | 557 | if ( !mHasRecurrenceID ) |
558 | return true; | 558 | return true; |
559 | int secs = mDtStart.secsTo( dtDue() ); | 559 | int secs = mDtStart.secsTo( dtDue() ); |
560 | bool ok; | 560 | bool ok; |
561 | qDebug("T:setRecurDates() "); | 561 | qDebug("T:setRecurDates() "); |
562 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 562 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
563 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); | 563 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); |
564 | if ( ok ) { | 564 | if ( ok ) { |
565 | mRecurrenceID = next; | 565 | mRecurrenceID = next; |
566 | mDtStart = next; | 566 | mDtStart = next; |
567 | setDtDue( next.addSecs( secs ) ); | 567 | setDtDue( next.addSecs( secs ) ); |
568 | if ( QDateTime::currentDateTime() > next) | 568 | if ( QDateTime::currentDateTime() > next) |
569 | return false; | 569 | return false; |
570 | } else { | 570 | } else { |
571 | setHasRecurrenceID( false ); | 571 | setHasRecurrenceID( false ); |
572 | recurrence()->unsetRecurs(); | 572 | recurrence()->unsetRecurs(); |
573 | } | 573 | } |
574 | return true; | 574 | return true; |
575 | } | 575 | } |
576 | void Todo::setPercentComplete(int v) | 576 | void Todo::setPercentComplete(int v) |
577 | { | 577 | { |
578 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { | 578 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { |
579 | if ( !setRecurDates() ) | 579 | if ( !setRecurDates() ) |
580 | v = 0; | 580 | v = 0; |
581 | } | 581 | } |
582 | mPercentComplete = v; | 582 | mPercentComplete = v; |
583 | if ( v != 100 ) | 583 | if ( v != 100 ) |
584 | mHasCompletedDate = false; | 584 | mHasCompletedDate = false; |
585 | updated(); | 585 | updated(); |
586 | } | 586 | } |
587 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const | 587 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const |
588 | { | 588 | { |
589 | *ok = false; | 589 | *ok = false; |
590 | if ( ! hasDueDate() || cancelled() || !alarmEnabled() ) { | 590 | if ( ! hasDueDate() || cancelled() || !alarmEnabled() ) { |
591 | return QDateTime (); | 591 | return QDateTime (); |
592 | } | 592 | } |
593 | // if the recurring todo is set to complete and requested time < start time of todo | 593 | // if the recurring todo is set to complete and requested time < start time of todo |
594 | // we want to get the alarm. | 594 | // we want to get the alarm. |
595 | bool iscompleted = isCompleted(); | 595 | bool iscompleted = isCompleted(); |
596 | if ( iscompleted && doesRecur() ) { | 596 | if ( iscompleted && doesRecur() ) { |
597 | Todo * to = (Todo*) this; | 597 | Todo * to = (Todo*) this; |
598 | to->checkSetCompletedFalse(); | 598 | to->checkSetCompletedFalse(); |
599 | iscompleted = isCompleted(); | 599 | iscompleted = isCompleted(); |
600 | if ( hasStartDate() && start_dt < dtStart() ){ | 600 | if ( hasStartDate() && start_dt < dtStart() ){ |
601 | iscompleted = false; | 601 | iscompleted = false; |
602 | } | 602 | } |
603 | } | 603 | } |
604 | if ( iscompleted ) { | 604 | if ( iscompleted ) { |
605 | return QDateTime (); | 605 | return QDateTime (); |
606 | } | 606 | } |
607 | QDateTime incidenceStart; | 607 | QDateTime incidenceStart; |
608 | incidenceStart = dtDue(); | 608 | incidenceStart = dtDue(); |
609 | bool enabled = false; | 609 | bool enabled = false; |
610 | Alarm* alarm; | 610 | Alarm* alarm; |
611 | int off = 0; | 611 | int off = 0; |
612 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 612 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
613 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 613 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
614 | // *ok = false; | 614 | // *ok = false; |
615 | // return incidenceStart; | 615 | // return incidenceStart; |
616 | // } | 616 | // } |
617 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 617 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
618 | if (alarm->enabled()) { | 618 | if (alarm->enabled()) { |
619 | if ( alarm->hasTime () ) { | 619 | if ( alarm->hasTime () ) { |
620 | if ( alarm->time() < alarmStart ) { | 620 | if ( alarm->time() < alarmStart ) { |
621 | alarmStart = alarm->time(); | 621 | alarmStart = alarm->time(); |
622 | enabled = true; | 622 | enabled = true; |
623 | off = alarmStart.secsTo( incidenceStart ); | 623 | off = alarmStart.secsTo( incidenceStart ); |
624 | } | 624 | } |
625 | 625 | ||
626 | } else { | 626 | } else { |
627 | int secs = alarm->startOffset().asSeconds(); | 627 | int secs = alarm->startOffset().asSeconds(); |
628 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 628 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
629 | alarmStart = incidenceStart.addSecs( secs ); | 629 | alarmStart = incidenceStart.addSecs( secs ); |
630 | enabled = true; | 630 | enabled = true; |
631 | off = -secs; | 631 | off = -secs; |
632 | } | 632 | } |
633 | } | 633 | } |
634 | } | 634 | } |
635 | } | 635 | } |
636 | if ( enabled ) { | 636 | if ( enabled ) { |
637 | if ( alarmStart > start_dt ) { | 637 | if ( alarmStart > start_dt ) { |
638 | *ok = true; | 638 | *ok = true; |
639 | * offset = off; | 639 | * offset = off; |
640 | return alarmStart; | 640 | return alarmStart; |
641 | } | 641 | } |
642 | } | 642 | } |
643 | *ok = false; | 643 | *ok = false; |
644 | return QDateTime (); | 644 | return QDateTime (); |
645 | 645 | ||
646 | } | 646 | } |
647 | 647 | ||
648 | void Todo::checkSetCompletedFalse() | 648 | void Todo::checkSetCompletedFalse() |
649 | { | 649 | { |
650 | if ( !mHasRecurrenceID ) { | 650 | if ( !mHasRecurrenceID ) { |
651 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); | 651 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); |
652 | return; | 652 | return; |
653 | } | 653 | } |
654 | // qDebug("Todo::checkSetCompletedFalse()"); | 654 | // qDebug("Todo::checkSetCompletedFalse()"); |
655 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 655 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
656 | if ( mPercentComplete == 100 ) { | 656 | if ( mPercentComplete == 100 ) { |
657 | QDateTime dt = QDateTime::currentDateTime(); | 657 | QDateTime dt = QDateTime::currentDateTime(); |
658 | if ( dt > mDtStart && dt > mRecurrenceID ) { | 658 | if ( dt > mDtStart && dt > mRecurrenceID ) { |
659 | qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 659 | qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
660 | setCompleted( false ); | 660 | setCompleted( false ); |
661 | qDebug("Todo::checkSetCompletedFalse "); | 661 | qDebug("Todo::checkSetCompletedFalse "); |
662 | } | 662 | } |
663 | } | 663 | } |
664 | } | 664 | } |
665 | QString Todo::durationText() | 665 | QString Todo::durationText() |
666 | { | 666 | { |
667 | if ( mHasDueDate && hasStartDate() ) { | 667 | if ( mHasDueDate && hasStartDate() ) { |
668 | int sec = dtStart().secsTo( dtDue() ); | 668 | int sec = dtStart().secsTo( dtDue() ); |
669 | if ( doesFloat() ) | 669 | if ( doesFloat() ) |
670 | sec += 86400; | 670 | sec += 86400; |
671 | return durationText4Time( sec ); | 671 | return durationText4Time( sec ); |
672 | } | 672 | } |
673 | return "---"; | 673 | return "---"; |
674 | } | 674 | } |