summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoeditor.cpp
Unidiff
Diffstat (limited to 'korganizer/kotodoeditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoeditor.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp
index 100a81b..682f83b 100644
--- a/korganizer/kotodoeditor.cpp
+++ b/korganizer/kotodoeditor.cpp
@@ -332,97 +332,98 @@ void KOTodoEditor::checkRecurrence()
332 from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; 332 from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ;
333 } 333 }
334 if ( to < from ) 334 if ( to < from )
335 to = from; 335 to = from;
336 mRecurrence->setDefaults(from,to); 336 mRecurrence->setDefaults(from,to);
337 } 337 }
338 } else { 338 } else {
339 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); 339 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false );
340 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); 340 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ));
341 } 341 }
342} 342}
343void KOTodoEditor::readTodo(Todo *todo) 343void KOTodoEditor::readTodo(Todo *todo)
344{ 344{
345 mGeneral->readTodo(todo); 345 mGeneral->readTodo(todo);
346 mDetails->readEvent(todo); 346 mDetails->readEvent(todo);
347 mRelatedTodo = 0;//todo->relatedTo(); 347 mRelatedTodo = 0;//todo->relatedTo();
348 // categories 348 // categories
349 // mCategoryDialog->setSelected(todo->categories()); 349 // mCategoryDialog->setSelected(todo->categories());
350 350
351 // We should handle read-only events here. 351 // We should handle read-only events here.
352} 352}
353 353
354void KOTodoEditor::writeTodo(Todo *event) 354void KOTodoEditor::writeTodo(Todo *event)
355{ 355{
356 bool maybeComputeRecurrenceTime = false; 356 bool maybeComputeRecurrenceTime = false;
357 if( event->hasRecurrenceID() && event->percentComplete() < 100) 357 if( event->hasRecurrenceID() && event->percentComplete() < 100)
358 maybeComputeRecurrenceTime = true; 358 maybeComputeRecurrenceTime = true;
359 event->setHasRecurrenceID( false ); 359 event->setHasRecurrenceID( false );
360 mGeneral->writeTodo(event); 360 mGeneral->writeTodo(event);
361 mDetails->writeEvent(event); 361 mDetails->writeEvent(event);
362 362
363 // set related event, i.e. parent to-do in this case. 363 // set related event, i.e. parent to-do in this case.
364 if (mRelatedTodo) { 364 if (mRelatedTodo) {
365 event->setRelatedTo(mRelatedTodo); 365 event->setRelatedTo(mRelatedTodo);
366 } 366 }
367 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { 367 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) {
368 mRecurrence->writeEvent(event); 368 mRecurrence->writeEvent(event);
369 if ( event->doesRecur() ) { 369 if ( event->doesRecur() ) {
370 int addSec = -1 ; 370 int addSec = -1 ;
371 if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 ) 371 if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 )
372 addSec = 1; 372 addSec = 1;
373 event->setRecurrenceID( event->dtStart().addSecs( addSec ) ); 373 event->setRecurrenceID( event->dtStart().addSecs( addSec ) );
374 event->setRecurDates(); 374 event->setRecurDates();
375 } else { 375 } else {
376 event->setHasRecurrenceID( false ); 376 event->setHasRecurrenceID( false );
377 } 377 }
378 } else { 378 } else {
379 event->setHasRecurrenceID( false ); 379 event->setHasRecurrenceID( false );
380 event->recurrence()->unsetRecurs(); 380 if ( event->doesRecur() )
381 event->recurrence()->unsetRecurs();
381 } 382 }
382} 383}
383 384
384bool KOTodoEditor::validateInput() 385bool KOTodoEditor::validateInput()
385{ 386{
386 if (!mGeneral->validateInput()) return false; 387 if (!mGeneral->validateInput()) return false;
387 if (!mDetails->validateInput()) return false; 388 if (!mDetails->validateInput()) return false;
388 return true; 389 return true;
389} 390}
390 391
391int KOTodoEditor::msgItemDelete() 392int KOTodoEditor::msgItemDelete()
392{ 393{
393 return KMessageBox::warningContinueCancel(this, 394 return KMessageBox::warningContinueCancel(this,
394 i18n("This item will be permanently deleted."), 395 i18n("This item will be permanently deleted."),
395 i18n("KOrganizer Confirmation"),i18n("Delete")); 396 i18n("KOrganizer Confirmation"),i18n("Delete"));
396} 397}
397 398
398void KOTodoEditor::modified (int modification) 399void KOTodoEditor::modified (int modification)
399{ 400{
400 if (modification == KOGlobals::CATEGORY_MODIFIED || 401 if (modification == KOGlobals::CATEGORY_MODIFIED ||
401 KOGlobals::UNKNOWN_MODIFIED == modification ) 402 KOGlobals::UNKNOWN_MODIFIED == modification )
402 // mCategoryDialog->setSelected (mTodo->categories ()); 403 // mCategoryDialog->setSelected (mTodo->categories ());
403 mGeneral->modified (mTodo, modification); 404 mGeneral->modified (mTodo, modification);
404 405
405} 406}
406 407
407void KOTodoEditor::slotLoadTemplate() 408void KOTodoEditor::slotLoadTemplate()
408{ 409{
409 410
410 QString fileName =locateLocal( "templates", "todos" ); 411 QString fileName =locateLocal( "templates", "todos" );
411 QDir t_dir; 412 QDir t_dir;
412 if ( !t_dir.exists(fileName) ) 413 if ( !t_dir.exists(fileName) )
413 t_dir.mkdir ( fileName ); 414 t_dir.mkdir ( fileName );
414 fileName += "/todo"; 415 fileName += "/todo";
415 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); 416 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this );
416 if ( fileName.length() == 0 ) 417 if ( fileName.length() == 0 )
417 return; 418 return;
418 CalendarLocal cal; 419 CalendarLocal cal;
419 ICalFormat format; 420 ICalFormat format;
420 if ( !format.load( &cal, fileName ) ) { 421 if ( !format.load( &cal, fileName ) ) {
421 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 422 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
422 .arg( fileName ) ); 423 .arg( fileName ) );
423 return ; 424 return ;
424 } 425 }
425 QPtrList<Todo> todos = cal.todos(); 426 QPtrList<Todo> todos = cal.todos();
426 Todo * todo = todos.first(); 427 Todo * todo = todos.first();
427 if ( !todo ) { 428 if ( !todo ) {
428 KMessageBox::error( this, 429 KMessageBox::error( this,