summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-02-22 22:28:12 (UTC)
committer zautrix <zautrix>2005-02-22 22:28:12 (UTC)
commit87a2f1a301beae2a8550c340348741c69f0ac1dd (patch) (unidiff)
tree5fd29a75f50da5ef37a01097c12997a18c56543d /korganizer
parent688723b6cd545ad1fa390d98a74680e912578fe8 (diff)
downloadkdepimpi-87a2f1a301beae2a8550c340348741c69f0ac1dd.zip
kdepimpi-87a2f1a301beae2a8550c340348741c69f0ac1dd.tar.gz
kdepimpi-87a2f1a301beae2a8550c340348741c69f0ac1dd.tar.bz2
todo fixes
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp10
-rw-r--r--korganizer/kotodoeditor.cpp25
2 files changed, 5 insertions, 30 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 4ff6899..db66413 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -956,106 +956,100 @@ void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
956 startDate = (mSelectedDates.first()).addDays(item->cellX()); 956 startDate = (mSelectedDates.first()).addDays(item->cellX());
957 } else { 957 } else {
958 startDate = mSelectedDates[item->cellX()]; 958 startDate = mSelectedDates[item->cellX()];
959 } 959 }
960 } 960 }
961 startDt.setDate(startDate); 961 startDt.setDate(startDate);
962 962
963 if (item->incidence()->doesFloat()) { 963 if (item->incidence()->doesFloat()) {
964 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 964 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
965 } else { 965 } else {
966 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 966 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
967 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 967 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
968 if ( item->incidence()->type() == "Event" ) { 968 if ( item->incidence()->type() == "Event" ) {
969 if ( type == KOAgenda::MOVE ) { 969 if ( type == KOAgenda::MOVE ) {
970 endDt = startDt.addSecs(lenInSecs); 970 endDt = startDt.addSecs(lenInSecs);
971 971
972 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 972 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
973 if (item->lastMultiItem()) { 973 if (item->lastMultiItem()) {
974 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 974 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
975 endDt.setDate(startDate. 975 endDt.setDate(startDate.
976 addDays(item->lastMultiItem()->cellX() - item->cellX())); 976 addDays(item->lastMultiItem()->cellX() - item->cellX()));
977 } else { 977 } else {
978 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 978 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
979 endDt.setDate(startDate); 979 endDt.setDate(startDate);
980 } 980 }
981 } 981 }
982 } else { 982 } else {
983 // todo 983 // todo
984 if (item->lastMultiItem()) { 984 if (item->lastMultiItem()) {
985 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 985 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
986 endDt.setDate(startDate. 986 endDt.setDate(startDate.
987 addDays(item->lastMultiItem()->cellX() - item->cellX())); 987 addDays(item->lastMultiItem()->cellX() - item->cellX()));
988 } else { 988 } else {
989 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 989 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
990 if ( item->cellYBottom() > 0 ) 990 if ( item->cellYBottom() > 0 )
991 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 991 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
992 else 992 else
993 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 993 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
994 endDt.setDate(startDate); 994 endDt.setDate(startDate);
995 } 995 }
996 } 996 }
997 } 997 }
998 if ( item->incidence()->type() == "Event" ) { 998 if ( item->incidence()->type() == "Event" ) {
999 item->incidence()->setDtStart(startDt); 999 item->incidence()->setDtStart(startDt);
1000 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1000 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1001 } else if ( item->incidence()->type() == "Todo" ) { 1001 } else if ( item->incidence()->type() == "Todo" ) {
1002 Todo* to = static_cast<Todo*>(item->incidence()); 1002 Todo* to = static_cast<Todo*>(item->incidence());
1003 1003
1004 int len = 0;
1005 if ( to->hasStartDate() && to->hasDueDate() )
1006 len = to->dtStart().secsTo( to->dtDue());
1007 to->setDtDue(endDt); 1004 to->setDtDue(endDt);
1008 if ( to->hasStartDate() ) { 1005 if ( to->hasStartDate() ) {
1009 if ( len>0 ) 1006 if (to->dtStart() >= to->dtDue() )
1010 to->setDtStart(to->dtDue().addSecs( -len )); 1007 to->setDtStart(to->dtDue().addDays( -2 ));
1011 else
1012 if (to->dtStart() > to->dtDue() )
1013 to->setDtStart(to->dtDue().addDays( -3 ));
1014 } 1008 }
1015 1009
1016 } 1010 }
1017 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1011 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1018 item->incidence()->setRevision(item->incidence()->revision()+1); 1012 item->incidence()->setRevision(item->incidence()->revision()+1);
1019 item->setItemDate(startDt.date()); 1013 item->setItemDate(startDt.date());
1020 //item->updateItem(); 1014 //item->updateItem();
1021 if ( item->incidence()->type() == "Todo" ) { 1015 if ( item->incidence()->type() == "Todo" ) {
1022 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1016 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1023 1017
1024 } 1018 }
1025 else 1019 else
1026 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1020 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1027 item->updateItem(); 1021 item->updateItem();
1028} 1022}
1029 1023
1030void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1024void KOAgendaView::showDates( const QDate &start, const QDate &end )
1031{ 1025{
1032 // kdDebug() << "KOAgendaView::selectDates" << endl; 1026 // kdDebug() << "KOAgendaView::selectDates" << endl;
1033 1027
1034 mSelectedDates.clear(); 1028 mSelectedDates.clear();
1035 // qDebug("KOAgendaView::showDates "); 1029 // qDebug("KOAgendaView::showDates ");
1036 QDate d = start; 1030 QDate d = start;
1037 while (d <= end) { 1031 while (d <= end) {
1038 mSelectedDates.append(d); 1032 mSelectedDates.append(d);
1039 d = d.addDays( 1 ); 1033 d = d.addDays( 1 );
1040 } 1034 }
1041 1035
1042 // and update the view 1036 // and update the view
1043 fillAgenda(); 1037 fillAgenda();
1044} 1038}
1045 1039
1046 1040
1047void KOAgendaView::showEvents(QPtrList<Event>) 1041void KOAgendaView::showEvents(QPtrList<Event>)
1048{ 1042{
1049 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1043 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1050} 1044}
1051 1045
1052void KOAgendaView::changeEventDisplay(Event *, int) 1046void KOAgendaView::changeEventDisplay(Event *, int)
1053{ 1047{
1054 // qDebug("KOAgendaView::changeEventDisplay "); 1048 // qDebug("KOAgendaView::changeEventDisplay ");
1055 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1049 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1056 // this should be re-written to be MUCH smarter. Right now we 1050 // this should be re-written to be MUCH smarter. Right now we
1057 // are just playing dumb. 1051 // are just playing dumb.
1058 fillAgenda(); 1052 fillAgenda();
1059} 1053}
1060 1054
1061void KOAgendaView::fillAgenda(const QDate &) 1055void KOAgendaView::fillAgenda(const QDate &)
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp
index f9f037a..51e2524 100644
--- a/korganizer/kotodoeditor.cpp
+++ b/korganizer/kotodoeditor.cpp
@@ -307,125 +307,106 @@ void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay)
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 ) 324 if ( to < from )
325 to = from; 325 to = from;
326 mRecurrence->setDefaults(from,to,!time); 326 mRecurrence->setDefaults(from,to,!time);
327 } 327 }
328 } else { 328 } else {
329 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); 329 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false );
330 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); 330 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true);
331 } 331 }
332} 332}
333void KOTodoEditor::readTodo(Todo *todo) 333void KOTodoEditor::readTodo(Todo *todo)
334{ 334{
335 mGeneral->readTodo(todo); 335 mGeneral->readTodo(todo);
336 mDetails->readEvent(todo); 336 mDetails->readEvent(todo);
337 mRelatedTodo = 0;//todo->relatedTo(); 337 mRelatedTodo = 0;//todo->relatedTo();
338 // categories 338 // categories
339 // mCategoryDialog->setSelected(todo->categories()); 339 // mCategoryDialog->setSelected(todo->categories());
340 340
341 // We should handle read-only events here. 341 // We should handle read-only events here.
342} 342}
343 343
344void KOTodoEditor::writeTodo(Todo *event) 344void KOTodoEditor::writeTodo(Todo *event)
345{ 345{
346 mGeneral->writeTodo(event); 346 mGeneral->writeTodo(event);
347 mDetails->writeEvent(event); 347 mDetails->writeEvent(event);
348 348
349 // set related event, i.e. parent to-do in this case. 349 // set related event, i.e. parent to-do in this case.
350 if (mRelatedTodo) { 350 if (mRelatedTodo) {
351 event->setRelatedTo(mRelatedTodo); 351 event->setRelatedTo(mRelatedTodo);
352 } 352 }
353 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { 353 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) {
354 mRecurrence->writeEvent(event); 354 mRecurrence->writeEvent(event);
355 if ( event->doesRecur() ) {
355 event->setRecurrenceID( event->dtStart().addSecs(-1) ); 356 event->setRecurrenceID( event->dtStart().addSecs(-1) );
356 event->setRecurDates(); 357 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 { 358 } else {
367 to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; 359 event->setHasRecurrenceID( false );
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 } 360 }
377 else { 361 } else {
378 event->setHasRecurrenceID( false ); 362 event->setHasRecurrenceID( false );
379 event->recurrence()->unsetRecurs(); 363 event->recurrence()->unsetRecurs();
380 } 364 }
381#endif
382 } else
383 event->recurrence()->unsetRecurs();
384} 365}
385 366
386bool KOTodoEditor::validateInput() 367bool KOTodoEditor::validateInput()
387{ 368{
388 if (!mGeneral->validateInput()) return false; 369 if (!mGeneral->validateInput()) return false;
389 if (!mDetails->validateInput()) return false; 370 if (!mDetails->validateInput()) return false;
390 return true; 371 return true;
391} 372}
392 373
393int KOTodoEditor::msgItemDelete() 374int KOTodoEditor::msgItemDelete()
394{ 375{
395 return KMessageBox::warningContinueCancel(this, 376 return KMessageBox::warningContinueCancel(this,
396 i18n("This item will be permanently deleted."), 377 i18n("This item will be permanently deleted."),
397 i18n("KOrganizer Confirmation"),i18n("Delete")); 378 i18n("KOrganizer Confirmation"),i18n("Delete"));
398} 379}
399 380
400void KOTodoEditor::modified (int modification) 381void KOTodoEditor::modified (int modification)
401{ 382{
402 if (modification == KOGlobals::CATEGORY_MODIFIED || 383 if (modification == KOGlobals::CATEGORY_MODIFIED ||
403 KOGlobals::UNKNOWN_MODIFIED == modification ) 384 KOGlobals::UNKNOWN_MODIFIED == modification )
404 // mCategoryDialog->setSelected (mTodo->categories ()); 385 // mCategoryDialog->setSelected (mTodo->categories ());
405 mGeneral->modified (mTodo, modification); 386 mGeneral->modified (mTodo, modification);
406 387
407} 388}
408 389
409void KOTodoEditor::slotLoadTemplate() 390void KOTodoEditor::slotLoadTemplate()
410{ 391{
411 392
412 QString fileName =locateLocal( "templates", "todos" ); 393 QString fileName =locateLocal( "templates", "todos" );
413 QDir t_dir; 394 QDir t_dir;
414 if ( !t_dir.exists(fileName) ) 395 if ( !t_dir.exists(fileName) )
415 t_dir.mkdir ( fileName ); 396 t_dir.mkdir ( fileName );
416 fileName += "/todo"; 397 fileName += "/todo";
417 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); 398 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this );
418 if ( fileName.length() == 0 ) 399 if ( fileName.length() == 0 )
419 return; 400 return;
420 CalendarLocal cal; 401 CalendarLocal cal;
421 ICalFormat format; 402 ICalFormat format;
422 if ( !format.load( &cal, fileName ) ) { 403 if ( !format.load( &cal, fileName ) ) {
423 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 404 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
424 .arg( fileName ) ); 405 .arg( fileName ) );
425 return ; 406 return ;
426 } 407 }
427 QPtrList<Todo> todos = cal.todos(); 408 QPtrList<Todo> todos = cal.todos();
428 Todo * todo = todos.first(); 409 Todo * todo = todos.first();
429 if ( !todo ) { 410 if ( !todo ) {
430 KMessageBox::error( this, 411 KMessageBox::error( this,
431 i18n("Template does not\ncontain a valid Todo.")); 412 i18n("Template does not\ncontain a valid Todo."));