summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-01-30 12:08:19 (UTC)
committer zautrix <zautrix>2005-01-30 12:08:19 (UTC)
commit1bcef8b3f53419e7155e0862ad61e3e419763d70 (patch) (unidiff)
tree166b82db7bc30b7d55b042bd37bb92facea6cdf2 /libkcal
parent446ea98a9f6550c4a3e64bcfc6aab8e8b58776e8 (diff)
downloadkdepimpi-1bcef8b3f53419e7155e0862ad61e3e419763d70.zip
kdepimpi-1bcef8b3f53419e7155e0862ad61e3e419763d70.tar.gz
kdepimpi-1bcef8b3f53419e7155e0862ad61e3e419763d70.tar.bz2
fixes
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 7d04793..7f1de78 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -214,167 +214,171 @@ void Todo::setStatus(const QString &statStr)
214 QString ss(statStr.upper()); 214 QString ss(statStr.upper());
215 215
216 if (ss == "X-ACTION") 216 if (ss == "X-ACTION")
217 mStatus = NEEDS_ACTION; 217 mStatus = NEEDS_ACTION;
218 else if (ss == "NEEDS ACTION") 218 else if (ss == "NEEDS ACTION")
219 mStatus = NEEDS_ACTION; 219 mStatus = NEEDS_ACTION;
220 else if (ss == "ACCEPTED") 220 else if (ss == "ACCEPTED")
221 mStatus = ACCEPTED; 221 mStatus = ACCEPTED;
222 else if (ss == "SENT") 222 else if (ss == "SENT")
223 mStatus = SENT; 223 mStatus = SENT;
224 else if (ss == "TENTATIVE") 224 else if (ss == "TENTATIVE")
225 mStatus = TENTATIVE; 225 mStatus = TENTATIVE;
226 else if (ss == "CONFIRMED") 226 else if (ss == "CONFIRMED")
227 mStatus = CONFIRMED; 227 mStatus = CONFIRMED;
228 else if (ss == "DECLINED") 228 else if (ss == "DECLINED")
229 mStatus = DECLINED; 229 mStatus = DECLINED;
230 else if (ss == "COMPLETED") 230 else if (ss == "COMPLETED")
231 mStatus = COMPLETED; 231 mStatus = COMPLETED;
232 else if (ss == "DELEGATED") 232 else if (ss == "DELEGATED")
233 mStatus = DELEGATED; 233 mStatus = DELEGATED;
234 234
235 updated(); 235 updated();
236} 236}
237 237
238void Todo::setStatus(int status) 238void Todo::setStatus(int status)
239{ 239{
240 if (mReadOnly) return; 240 if (mReadOnly) return;
241 mStatus = status; 241 mStatus = status;
242 updated(); 242 updated();
243} 243}
244 244
245int Todo::status() const 245int Todo::status() const
246{ 246{
247 return mStatus; 247 return mStatus;
248} 248}
249 249
250QString Todo::statusStr() const 250QString Todo::statusStr() const
251{ 251{
252 switch(mStatus) { 252 switch(mStatus) {
253 case NEEDS_ACTION: 253 case NEEDS_ACTION:
254 return QString("NEEDS ACTION"); 254 return QString("NEEDS ACTION");
255 break; 255 break;
256 case ACCEPTED: 256 case ACCEPTED:
257 return QString("ACCEPTED"); 257 return QString("ACCEPTED");
258 break; 258 break;
259 case SENT: 259 case SENT:
260 return QString("SENT"); 260 return QString("SENT");
261 break; 261 break;
262 case TENTATIVE: 262 case TENTATIVE:
263 return QString("TENTATIVE"); 263 return QString("TENTATIVE");
264 break; 264 break;
265 case CONFIRMED: 265 case CONFIRMED:
266 return QString("CONFIRMED"); 266 return QString("CONFIRMED");
267 break; 267 break;
268 case DECLINED: 268 case DECLINED:
269 return QString("DECLINED"); 269 return QString("DECLINED");
270 break; 270 break;
271 case COMPLETED: 271 case COMPLETED:
272 return QString("COMPLETED"); 272 return QString("COMPLETED");
273 break; 273 break;
274 case DELEGATED: 274 case DELEGATED:
275 return QString("DELEGATED"); 275 return QString("DELEGATED");
276 break; 276 break;
277 } 277 }
278 return QString(""); 278 return QString("");
279} 279}
280#endif 280#endif
281 281
282bool Todo::isCompleted() const 282bool Todo::isCompleted() const
283{ 283{
284 if (mPercentComplete == 100) return true; 284 if (mPercentComplete == 100) return true;
285 else return false; 285 else return false;
286} 286}
287 287
288void Todo::setCompleted(bool completed) 288void Todo::setCompleted(bool completed)
289{ 289{
290 if (completed) mPercentComplete = 100; 290 if (completed) mPercentComplete = 100;
291 else { 291 else {
292 mPercentComplete = 0; 292 mPercentComplete = 0;
293 mHasCompletedDate = false; 293 mHasCompletedDate = false;
294 } 294 }
295 updated(); 295 updated();
296} 296}
297 297
298QDateTime Todo::completed() const 298QDateTime Todo::completed() const
299{ 299{
300 return mCompleted; 300 return mCompleted;
301} 301}
302 302
303QString Todo::completedStr( bool shortF ) const 303QString Todo::completedStr( bool shortF ) const
304{ 304{
305 return KGlobal::locale()->formatDateTime(mCompleted, shortF); 305 return KGlobal::locale()->formatDateTime(mCompleted, shortF);
306} 306}
307 307
308void Todo::setCompleted(const QDateTime &completed) 308void Todo::setCompleted(const QDateTime &completed)
309{ 309{
310 qDebug("Todo::setCompleted "); 310 //qDebug("Todo::setCompleted ");
311 if ( mHasCompletedDate ) {
312 // qDebug("has completed data - return ");
313 return;
314 }
311 mHasCompletedDate = true; 315 mHasCompletedDate = true;
312 mPercentComplete = 100; 316 mPercentComplete = 100;
313 mCompleted = getEvenTime(completed); 317 mCompleted = getEvenTime(completed);
314 updated(); 318 updated();
315} 319}
316 320
317bool Todo::hasCompletedDate() const 321bool Todo::hasCompletedDate() const
318{ 322{
319 return mHasCompletedDate; 323 return mHasCompletedDate;
320} 324}
321 325
322int Todo::percentComplete() const 326int Todo::percentComplete() const
323{ 327{
324 return mPercentComplete; 328 return mPercentComplete;
325} 329}
326 330
327void Todo::setPercentComplete(int v) 331void Todo::setPercentComplete(int v)
328{ 332{
329 mPercentComplete = v; 333 mPercentComplete = v;
330 if ( v != 100 ) 334 if ( v != 100 )
331 mHasCompletedDate = false; 335 mHasCompletedDate = false;
332 updated(); 336 updated();
333} 337}
334QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const 338QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
335{ 339{
336 if ( isCompleted() || ! hasDueDate() || cancelled() ) { 340 if ( isCompleted() || ! hasDueDate() || cancelled() ) {
337 *ok = false; 341 *ok = false;
338 return QDateTime (); 342 return QDateTime ();
339 } 343 }
340 QDateTime incidenceStart; 344 QDateTime incidenceStart;
341 incidenceStart = dtDue(); 345 incidenceStart = dtDue();
342 bool enabled = false; 346 bool enabled = false;
343 Alarm* alarm; 347 Alarm* alarm;
344 int off; 348 int off;
345 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 349 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
346 // if ( QDateTime::currentDateTime() > incidenceStart ){ 350 // if ( QDateTime::currentDateTime() > incidenceStart ){
347// *ok = false; 351// *ok = false;
348// return incidenceStart; 352// return incidenceStart;
349// } 353// }
350 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 354 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
351 if (alarm->enabled()) { 355 if (alarm->enabled()) {
352 if ( alarm->hasTime () ) { 356 if ( alarm->hasTime () ) {
353 if ( alarm->time() < alarmStart ) { 357 if ( alarm->time() < alarmStart ) {
354 alarmStart = alarm->time(); 358 alarmStart = alarm->time();
355 enabled = true; 359 enabled = true;
356 off = alarmStart.secsTo( incidenceStart ); 360 off = alarmStart.secsTo( incidenceStart );
357 } 361 }
358 362
359 } else { 363 } else {
360 int secs = alarm->startOffset().asSeconds(); 364 int secs = alarm->startOffset().asSeconds();
361 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 365 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
362 alarmStart = incidenceStart.addSecs( secs ); 366 alarmStart = incidenceStart.addSecs( secs );
363 enabled = true; 367 enabled = true;
364 off = -secs; 368 off = -secs;
365 } 369 }
366 } 370 }
367 } 371 }
368 } 372 }
369 if ( enabled ) { 373 if ( enabled ) {
370 if ( alarmStart > QDateTime::currentDateTime() ) { 374 if ( alarmStart > QDateTime::currentDateTime() ) {
371 *ok = true; 375 *ok = true;
372 * offset = off; 376 * offset = off;
373 return alarmStart; 377 return alarmStart;
374 } 378 }
375 } 379 }
376 *ok = false; 380 *ok = false;
377 return QDateTime (); 381 return QDateTime ();
378 382
379} 383}
380 384