summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoeditor.cpp
Unidiff
Diffstat (limited to 'korganizer/kotodoeditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoeditor.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp
index 069dda8..9232e09 100644
--- a/korganizer/kotodoeditor.cpp
+++ b/korganizer/kotodoeditor.cpp
@@ -292,93 +292,122 @@ void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay)
292 mGeneral->setCategories (mRelatedTodo->categoriesStr ()); 292 mGeneral->setCategories (mRelatedTodo->categoriesStr ());
293 mGeneral->setSecrecy (mRelatedTodo->secrecy ()); 293 mGeneral->setSecrecy (mRelatedTodo->secrecy ());
294 if ( mRelatedTodo->priority() < 3 ) 294 if ( mRelatedTodo->priority() < 3 )
295 mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); 295 mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1);
296 mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); 296 mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": ");
297 int len = mRelatedTodo->summary().length(); 297 int len = mRelatedTodo->summary().length();
298 mGeneral->mSummaryEdit->lineEdit()->setFocus(); 298 mGeneral->mSummaryEdit->lineEdit()->setFocus();
299 mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); 299 mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 );
300 mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); 300 mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 );
301 301
302 } else 302 } else
303 mGeneral->setFocusOn( 2 ); 303 mGeneral->setFocusOn( 2 );
304 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); 304 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false );
305 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); 305 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true);
306} 306}
307void KOTodoEditor::checkRecurrence() 307void KOTodoEditor::checkRecurrence()
308{ 308{
309 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { 309 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) {
310 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); 310 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true );
311 311
312 if ( mTodo ) 312 if ( mTodo )
313 mRecurrence->readEvent( mTodo ); 313 mRecurrence->readEvent( mTodo );
314 else { 314 else {
315 bool time = mGeneral->mTimeButton->isChecked(); 315 bool time = mGeneral->mTimeButton->isChecked();
316 QDateTime from,to; 316 QDateTime from,to;
317 if ( time ) { 317 if ( time ) {
318 to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; 318 to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ;
319 from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; 319 from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ;
320 } else { 320 } else {
321 to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; 321 to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ;
322 from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; 322 from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ;
323 } 323 }
324 if ( to < from )
325 to = from;
324 mRecurrence->setDefaults(from,to,!time); 326 mRecurrence->setDefaults(from,to,!time);
325 } 327 }
326 } else { 328 } else {
327 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); 329 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false );
328 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); 330 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true);
329 } 331 }
330} 332}
331void KOTodoEditor::readTodo(Todo *todo) 333void KOTodoEditor::readTodo(Todo *todo)
332{ 334{
333 mGeneral->readTodo(todo); 335 mGeneral->readTodo(todo);
334 mDetails->readEvent(todo); 336 mDetails->readEvent(todo);
335 mRelatedTodo = 0;//todo->relatedTo(); 337 mRelatedTodo = 0;//todo->relatedTo();
336 // categories 338 // categories
337 // mCategoryDialog->setSelected(todo->categories()); 339 // mCategoryDialog->setSelected(todo->categories());
338 340
339 // We should handle read-only events here. 341 // We should handle read-only events here.
340} 342}
341 343
342void KOTodoEditor::writeTodo(Todo *event) 344void KOTodoEditor::writeTodo(Todo *event)
343{ 345{
344 mGeneral->writeTodo(event); 346 mGeneral->writeTodo(event);
345 mDetails->writeEvent(event); 347 mDetails->writeEvent(event);
346 348
347 // set related event, i.e. parent to-do in this case. 349 // set related event, i.e. parent to-do in this case.
348 if (mRelatedTodo) { 350 if (mRelatedTodo) {
349 event->setRelatedTo(mRelatedTodo); 351 event->setRelatedTo(mRelatedTodo);
350 } 352 }
351 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { 353 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) {
352 mRecurrence->writeEvent(event); 354 mRecurrence->writeEvent(event);
355 event->setRecurrenceID( event->dtStart().addSecs(-1) );
356 event->setRecurDates();
357#if 0
358 bool ok;
359 QDateTime next = event->getNextOccurence( event->dtStart().addSecs(-1), &ok );
360 if ( ok ) {
361 QDateTime from,to;
362 bool time = mGeneral->mTimeButton->isChecked();
363 if ( time ) {
364 to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ;
365 from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ;
366 } else {
367 to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ;
368 from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ;
369 }
370 if ( to < from )
371 to = from;
372 int secs = from.secsTo( to );
373 event->setRecurrenceID( next );
374 event->setDtStart( next );
375 event->setDtDue( next.addSecs( secs ) );
376 }
377 else {
378 event->setHasRecurrenceID( false );
379 event->recurrence()->unsetRecurs();
380 }
381#endif
353 } else 382 } else
354 event->recurrence()->unsetRecurs(); 383 event->recurrence()->unsetRecurs();
355} 384}
356 385
357bool KOTodoEditor::validateInput() 386bool KOTodoEditor::validateInput()
358{ 387{
359 if (!mGeneral->validateInput()) return false; 388 if (!mGeneral->validateInput()) return false;
360 if (!mDetails->validateInput()) return false; 389 if (!mDetails->validateInput()) return false;
361 return true; 390 return true;
362} 391}
363 392
364int KOTodoEditor::msgItemDelete() 393int KOTodoEditor::msgItemDelete()
365{ 394{
366 return KMessageBox::warningContinueCancel(this, 395 return KMessageBox::warningContinueCancel(this,
367 i18n("This item will be permanently deleted."), 396 i18n("This item will be permanently deleted."),
368 i18n("KOrganizer Confirmation"),i18n("Delete")); 397 i18n("KOrganizer Confirmation"),i18n("Delete"));
369} 398}
370 399
371void KOTodoEditor::modified (int modification) 400void KOTodoEditor::modified (int modification)
372{ 401{
373 if (modification == KOGlobals::CATEGORY_MODIFIED || 402 if (modification == KOGlobals::CATEGORY_MODIFIED ||
374 KOGlobals::UNKNOWN_MODIFIED == modification ) 403 KOGlobals::UNKNOWN_MODIFIED == modification )
375 // mCategoryDialog->setSelected (mTodo->categories ()); 404 // mCategoryDialog->setSelected (mTodo->categories ());
376 mGeneral->modified (mTodo, modification); 405 mGeneral->modified (mTodo, modification);
377 406
378} 407}
379 408
380void KOTodoEditor::slotLoadTemplate() 409void KOTodoEditor::slotLoadTemplate()
381{ 410{
382 411
383 QString fileName =locateLocal( "templates", "todos" ); 412 QString fileName =locateLocal( "templates", "todos" );
384 QDir t_dir; 413 QDir t_dir;