summaryrefslogtreecommitdiffabout
path: root/libkcal/todo.cpp
authorzautrix <zautrix>2005-02-13 19:07:45 (UTC)
committer zautrix <zautrix>2005-02-13 19:07:45 (UTC)
commit7bd83e913399b8be68a7d37e8f02118ec9eab90e (patch) (unidiff)
tree284d1592687ea4d3e0c220fafd289a702718dee4 /libkcal/todo.cpp
parent293271fe9e6a9061da329183f8f488d79580f7da (diff)
downloadkdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.zip
kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.gz
kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.bz2
todo fixi
Diffstat (limited to 'libkcal/todo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 1f54c2f..39d16b6 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -244,214 +244,214 @@ void Todo::setStatus(const QString &statStr)
244 QString ss(statStr.upper()); 244 QString ss(statStr.upper());
245 245
246 if (ss == "X-ACTION") 246 if (ss == "X-ACTION")
247 mStatus = NEEDS_ACTION; 247 mStatus = NEEDS_ACTION;
248 else if (ss == "NEEDS ACTION") 248 else if (ss == "NEEDS ACTION")
249 mStatus = NEEDS_ACTION; 249 mStatus = NEEDS_ACTION;
250 else if (ss == "ACCEPTED") 250 else if (ss == "ACCEPTED")
251 mStatus = ACCEPTED; 251 mStatus = ACCEPTED;
252 else if (ss == "SENT") 252 else if (ss == "SENT")
253 mStatus = SENT; 253 mStatus = SENT;
254 else if (ss == "TENTATIVE") 254 else if (ss == "TENTATIVE")
255 mStatus = TENTATIVE; 255 mStatus = TENTATIVE;
256 else if (ss == "CONFIRMED") 256 else if (ss == "CONFIRMED")
257 mStatus = CONFIRMED; 257 mStatus = CONFIRMED;
258 else if (ss == "DECLINED") 258 else if (ss == "DECLINED")
259 mStatus = DECLINED; 259 mStatus = DECLINED;
260 else if (ss == "COMPLETED") 260 else if (ss == "COMPLETED")
261 mStatus = COMPLETED; 261 mStatus = COMPLETED;
262 else if (ss == "DELEGATED") 262 else if (ss == "DELEGATED")
263 mStatus = DELEGATED; 263 mStatus = DELEGATED;
264 264
265 updated(); 265 updated();
266} 266}
267 267
268void Todo::setStatus(int status) 268void Todo::setStatus(int status)
269{ 269{
270 if (mReadOnly) return; 270 if (mReadOnly) return;
271 mStatus = status; 271 mStatus = status;
272 updated(); 272 updated();
273} 273}
274 274
275int Todo::status() const 275int Todo::status() const
276{ 276{
277 return mStatus; 277 return mStatus;
278} 278}
279 279
280QString Todo::statusStr() const 280QString Todo::statusStr() const
281{ 281{
282 switch(mStatus) { 282 switch(mStatus) {
283 case NEEDS_ACTION: 283 case NEEDS_ACTION:
284 return QString("NEEDS ACTION"); 284 return QString("NEEDS ACTION");
285 break; 285 break;
286 case ACCEPTED: 286 case ACCEPTED:
287 return QString("ACCEPTED"); 287 return QString("ACCEPTED");
288 break; 288 break;
289 case SENT: 289 case SENT:
290 return QString("SENT"); 290 return QString("SENT");
291 break; 291 break;
292 case TENTATIVE: 292 case TENTATIVE:
293 return QString("TENTATIVE"); 293 return QString("TENTATIVE");
294 break; 294 break;
295 case CONFIRMED: 295 case CONFIRMED:
296 return QString("CONFIRMED"); 296 return QString("CONFIRMED");
297 break; 297 break;
298 case DECLINED: 298 case DECLINED:
299 return QString("DECLINED"); 299 return QString("DECLINED");
300 break; 300 break;
301 case COMPLETED: 301 case COMPLETED:
302 return QString("COMPLETED"); 302 return QString("COMPLETED");
303 break; 303 break;
304 case DELEGATED: 304 case DELEGATED:
305 return QString("DELEGATED"); 305 return QString("DELEGATED");
306 break; 306 break;
307 } 307 }
308 return QString(""); 308 return QString("");
309} 309}
310#endif 310#endif
311 311
312bool Todo::isCompleted() const 312bool Todo::isCompleted() const
313{ 313{
314 if (mPercentComplete == 100) { 314 if (mPercentComplete == 100) {
315 return true; 315 return true;
316 } 316 }
317 else return false; 317 else return false;
318} 318}
319 319
320void Todo::setCompleted(bool completed) 320void Todo::setCompleted(bool completed)
321{ 321{
322 if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { 322 if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) {
323 if ( !setRecurDates() ) 323 if ( !setRecurDates() )
324 completed = false; 324 completed = false;
325 } 325 }
326 if (completed) mPercentComplete = 100; 326 if (completed) mPercentComplete = 100;
327 else { 327 else {
328 mPercentComplete = 0; 328 mPercentComplete = 0;
329 mHasCompletedDate = false; 329 mHasCompletedDate = false;
330 } 330 }
331 updated(); 331 updated();
332} 332}
333 333
334QDateTime Todo::completed() const 334QDateTime Todo::completed() const
335{ 335{
336 return mCompleted; 336 return mCompleted;
337} 337}
338 338
339QString Todo::completedStr( bool shortF ) const 339QString Todo::completedStr( bool shortF ) const
340{ 340{
341 return KGlobal::locale()->formatDateTime(mCompleted, shortF); 341 return KGlobal::locale()->formatDateTime(mCompleted, shortF);
342} 342}
343 343
344void Todo::setCompleted(const QDateTime &completed) 344void Todo::setCompleted(const QDateTime &completed)
345{ 345{
346 //qDebug("Todo::setCompleted "); 346 //qDebug("Todo::setCompleted ");
347 if ( mHasCompletedDate ) { 347 if ( mHasCompletedDate ) {
348 // qDebug("has completed data - return "); 348 // qDebug("has completed data - return ");
349 return; 349 return;
350 } 350 }
351 mHasCompletedDate = true; 351 mHasCompletedDate = true;
352 mPercentComplete = 100; 352 mPercentComplete = 100;
353 mCompleted = getEvenTime(completed); 353 mCompleted = getEvenTime(completed);
354 updated(); 354 updated();
355} 355}
356 356
357bool Todo::hasCompletedDate() const 357bool Todo::hasCompletedDate() const
358{ 358{
359 return mHasCompletedDate; 359 return mHasCompletedDate;
360} 360}
361 361
362int Todo::percentComplete() const 362int Todo::percentComplete() const
363{ 363{
364 return mPercentComplete; 364 return mPercentComplete;
365} 365}
366bool Todo::setRecurDates() 366bool Todo::setRecurDates()
367{ 367{
368 if ( !mHasRecurrenceID ) 368 if ( !mHasRecurrenceID )
369 return true; 369 return true;
370 int secs = mDtStart.secsTo( dtDue() ); 370 int secs = mDtStart.secsTo( dtDue() );
371 bool ok; 371 bool ok;
372 qDebug("--------------------setRecurDates() "); 372 qDebug("T:setRecurDates() ");
373 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 373 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
374 QDateTime next = getNextOccurence( mRecurrenceID, &ok ); 374 QDateTime next = getNextOccurence( mRecurrenceID, &ok );
375 if ( ok ) { 375 if ( ok ) {
376 mRecurrenceID = next; 376 mRecurrenceID = next;
377 mDtStart = next; 377 mDtStart = next;
378 setDtDue( next.addSecs( secs ) ); 378 setDtDue( next.addSecs( secs ) );
379 if ( QDateTime::currentDateTime() > next) 379 if ( QDateTime::currentDateTime() > next)
380 return false; 380 return false;
381 } else { 381 } else {
382 setHasRecurrenceID( false ); 382 setHasRecurrenceID( false );
383 recurrence()->unsetRecurs(); 383 recurrence()->unsetRecurs();
384 } 384 }
385 return true; 385 return true;
386} 386}
387void Todo::setPercentComplete(int v) 387void Todo::setPercentComplete(int v)
388{ 388{
389 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { 389 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) {
390 if ( !setRecurDates() ) 390 if ( !setRecurDates() )
391 v = 0; 391 v = 0;
392 } 392 }
393 mPercentComplete = v; 393 mPercentComplete = v;
394 if ( v != 100 ) 394 if ( v != 100 )
395 mHasCompletedDate = false; 395 mHasCompletedDate = false;
396 updated(); 396 updated();
397} 397}
398QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const 398QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
399{ 399{
400 if ( isCompleted() || ! hasDueDate() || cancelled() ) { 400 if ( isCompleted() || ! hasDueDate() || cancelled() ) {
401 *ok = false; 401 *ok = false;
402 return QDateTime (); 402 return QDateTime ();
403 } 403 }
404 QDateTime incidenceStart; 404 QDateTime incidenceStart;
405 incidenceStart = dtDue(); 405 incidenceStart = dtDue();
406 bool enabled = false; 406 bool enabled = false;
407 Alarm* alarm; 407 Alarm* alarm;
408 int off = 0; 408 int off = 0;
409 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 409 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
410 // if ( QDateTime::currentDateTime() > incidenceStart ){ 410 // if ( QDateTime::currentDateTime() > incidenceStart ){
411// *ok = false; 411// *ok = false;
412// return incidenceStart; 412// return incidenceStart;
413// } 413// }
414 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 414 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
415 if (alarm->enabled()) { 415 if (alarm->enabled()) {
416 if ( alarm->hasTime () ) { 416 if ( alarm->hasTime () ) {
417 if ( alarm->time() < alarmStart ) { 417 if ( alarm->time() < alarmStart ) {
418 alarmStart = alarm->time(); 418 alarmStart = alarm->time();
419 enabled = true; 419 enabled = true;
420 off = alarmStart.secsTo( incidenceStart ); 420 off = alarmStart.secsTo( incidenceStart );
421 } 421 }
422 422
423 } else { 423 } else {
424 int secs = alarm->startOffset().asSeconds(); 424 int secs = alarm->startOffset().asSeconds();
425 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 425 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
426 alarmStart = incidenceStart.addSecs( secs ); 426 alarmStart = incidenceStart.addSecs( secs );
427 enabled = true; 427 enabled = true;
428 off = -secs; 428 off = -secs;
429 } 429 }
430 } 430 }
431 } 431 }
432 } 432 }
433 if ( enabled ) { 433 if ( enabled ) {
434 if ( alarmStart > QDateTime::currentDateTime() ) { 434 if ( alarmStart > QDateTime::currentDateTime() ) {
435 *ok = true; 435 *ok = true;
436 * offset = off; 436 * offset = off;
437 return alarmStart; 437 return alarmStart;
438 } 438 }
439 } 439 }
440 *ok = false; 440 *ok = false;
441 return QDateTime (); 441 return QDateTime ();
442 442
443} 443}
444 444
445void Todo::checkSetCompletedFalse() 445void Todo::checkSetCompletedFalse()
446{ 446{
447 if ( !hasRecurrenceID() ) { 447 if ( !hasRecurrenceID() ) {
448 qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); 448 qDebug("ERROR 1 in Todo::checkSetCompletedFalse");
449 } 449 }
450 // qDebug("Todo::checkSetCompletedFalse()"); 450 // qDebug("Todo::checkSetCompletedFalse()");
451 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 451 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
452 if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) { 452 if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) {
453 qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 453 qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
454 setCompleted( false ); 454 setCompleted( false );
455 qDebug("Todo::checkSetCompletedFalse++++++++++++++++++++++++++++ "); 455 qDebug("Todo::checkSetCompletedFalse ");
456 } 456 }
457} 457}