summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-30 10:57:34 (UTC)
committer zautrix <zautrix>2005-01-30 10:57:34 (UTC)
commit446ea98a9f6550c4a3e64bcfc6aab8e8b58776e8 (patch) (unidiff)
tree26260551e87a4074651a5cdceee5e788f743a02d
parent949c6e28c83668176fd9c29e12668322c6ae627f (diff)
downloadkdepimpi-446ea98a9f6550c4a3e64bcfc6aab8e8b58776e8.zip
kdepimpi-446ea98a9f6550c4a3e64bcfc6aab8e8b58776e8.tar.gz
kdepimpi-446ea98a9f6550c4a3e64bcfc6aab8e8b58776e8.tar.bz2
bugs from last commit fixed
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagenda.cpp11
-rw-r--r--korganizer/koagendaview.cpp31
-rw-r--r--korganizer/koeventviewer.cpp18
-rw-r--r--korganizer/kotodoview.cpp13
-rw-r--r--korganizer/kotodoviewitem.cpp7
-rw-r--r--libkcal/kincidenceformatter.cpp16
-rw-r--r--libkcal/todo.cpp5
-rw-r--r--libkcal/todo.h2
8 files changed, 65 insertions, 38 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 002234d..7c41cab 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1409,25 +1409,25 @@ KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1409 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1409 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1410 if ( item->incidence() == todo ) { 1410 if ( item->incidence() == todo ) {
1411 mItems.remove(); 1411 mItems.remove();
1412 return item; 1412 return item;
1413 } 1413 }
1414 } 1414 }
1415 return 0; 1415 return 0;
1416} 1416}
1417 1417
1418 1418
1419void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1419void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1420{ 1420{
1421 1421 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
1422 KOAgendaItem *item; 1422 KOAgendaItem *item;
1423 item = getItemForTodo ( todo ); 1423 item = getItemForTodo ( todo );
1424 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); 1424 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1425 if ( item ) { 1425 if ( item ) {
1426 blockSignals( true ); 1426 blockSignals( true );
1427 //qDebug("item found "); 1427 //qDebug("item found ");
1428 item->hide(); 1428 item->hide();
1429 item->setCellX(-2, -1 ); 1429 item->setCellX(-2, -1 );
1430 item->select(false); 1430 item->select(false);
1431 mUnusedItems.append( item ); 1431 mUnusedItems.append( item );
1432 mItems.remove( item ); 1432 mItems.remove( item );
1433 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1433 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
@@ -1448,44 +1448,49 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1448 globalFlagBlockAgendaItemUpdate = 1; 1448 globalFlagBlockAgendaItemUpdate = 1;
1449 itemit->repaint(); 1449 itemit->repaint();
1450 } 1450 }
1451 blockSignals( false ); 1451 blockSignals( false );
1452 } 1452 }
1453 if ( remove ) { 1453 if ( remove ) {
1454 //qDebug("remove****************************************** "); 1454 //qDebug("remove****************************************** ");
1455 return; 1455 return;
1456 } 1456 }
1457 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1457 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1458 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1458 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda );
1459 QDate currentDate; 1459 QDate currentDate;
1460 QDateTime dt;
1461 if ( todo->hasCompletedDate() )
1462 dt = todo->completed();
1463 else
1464 dt = todo->dtDue();
1460 if ( overdue ) { 1465 if ( overdue ) {
1461 currentDate = QDate::currentDate(); 1466 currentDate = QDate::currentDate();
1462 days += todo->dtDue().date().daysTo( currentDate ); 1467 days += todo->dtDue().date().daysTo( currentDate );
1463 } 1468 }
1464 else 1469 else
1465 currentDate = todo->dtDue().date(); 1470 currentDate = dt.date();
1466 1471
1467 if ( todo->doesFloat() || overdue ) { 1472 if ( todo->doesFloat() || overdue ) {
1468 if ( ! mAllDayMode ) return; 1473 if ( ! mAllDayMode ) return;
1469 // aldayagenda 1474 // aldayagenda
1470 globalFlagBlockAgendaItemPaint = 1; 1475 globalFlagBlockAgendaItemPaint = 1;
1471 item = insertAllDayItem(todo, currentDate,days, days); 1476 item = insertAllDayItem(todo, currentDate,days, days);
1472 item->show(); 1477 item->show();
1473 1478
1474 } 1479 }
1475 else { 1480 else {
1476 if ( mAllDayMode ) return; 1481 if ( mAllDayMode ) return;
1477 // mAgenda 1482 // mAgenda
1478 globalFlagBlockAgendaItemPaint = 1; 1483 globalFlagBlockAgendaItemPaint = 1;
1479 int endY = timeToY(todo->dtDue().time()) - 1; 1484 int endY = timeToY(dt.time()) - 1;
1480 int hi = 12/KOPrefs::instance()->mHourSize; 1485 int hi = 12/KOPrefs::instance()->mHourSize;
1481 int startY = endY - 1-hi; 1486 int startY = endY - 1-hi;
1482 item = insertItem(todo,currentDate,days,startY,endY); 1487 item = insertItem(todo,currentDate,days,startY,endY);
1483 item->show(); 1488 item->show();
1484 } 1489 }
1485 qApp->processEvents(); 1490 qApp->processEvents();
1486 globalFlagBlockAgendaItemPaint = 0; 1491 globalFlagBlockAgendaItemPaint = 0;
1487 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1492 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1488 KOAgendaItem *itemit; 1493 KOAgendaItem *itemit;
1489 for ( itemit=oldconflictItems.first(); itemit != 0; 1494 for ( itemit=oldconflictItems.first(); itemit != 0;
1490 itemit=oldconflictItems.next() ) { 1495 itemit=oldconflictItems.next() ) {
1491 globalFlagBlockAgendaItemUpdate = 0; 1496 globalFlagBlockAgendaItemUpdate = 0;
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 1864e22..bbc43e4 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -941,40 +941,41 @@ void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
941 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 941 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
942 if (item->lastMultiItem()) { 942 if (item->lastMultiItem()) {
943 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 943 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
944 endDt.setDate(startDate. 944 endDt.setDate(startDate.
945 addDays(item->lastMultiItem()->cellX() - item->cellX())); 945 addDays(item->lastMultiItem()->cellX() - item->cellX()));
946 } else { 946 } else {
947 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 947 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
948 endDt.setDate(startDate); 948 endDt.setDate(startDate);
949 } 949 }
950 } 950 }
951 } else { 951 } else {
952 // todo 952 // todo
953 qDebug("tooooodoooooo ");
953 if (item->lastMultiItem()) { 954 if (item->lastMultiItem()) {
954 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 955 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
955 endDt.setDate(startDate. 956 endDt.setDate(startDate.
956 addDays(item->lastMultiItem()->cellX() - item->cellX())); 957 addDays(item->lastMultiItem()->cellX() - item->cellX()));
957 } else { 958 } else {
958 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 959 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
959 if ( item->cellYBottom() > 0 ) 960 if ( item->cellYBottom() > 0 )
960 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 961 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
961 else 962 else
962 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 963 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
963 endDt.setDate(startDate); 964 endDt.setDate(startDate);
964 } 965 }
965 } 966 }
966 } 967 }
967 968
968 969 qDebug("to888");
969 if ( item->incidence()->type() == "Event" ) { 970 if ( item->incidence()->type() == "Event" ) {
970 item->incidence()->setDtStart(startDt); 971 item->incidence()->setDtStart(startDt);
971 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 972 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
972 } else if ( item->incidence()->type() == "Todo" ) { 973 } else if ( item->incidence()->type() == "Todo" ) {
973 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); 974 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt);
974 } 975 }
975 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 976 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
976 item->incidence()->setRevision(item->incidence()->revision()+1); 977 item->incidence()->setRevision(item->incidence()->revision()+1);
977 item->setItemDate(startDt.date()); 978 item->setItemDate(startDt.date());
978 //item->updateItem(); 979 //item->updateItem();
979 if ( item->incidence()->type() == "Todo" ) { 980 if ( item->incidence()->type() == "Todo" ) {
980 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 981 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
@@ -1046,25 +1047,25 @@ void KOAgendaView::fillAgenda()
1046 //mAgenda->hideUnused(); 1047 //mAgenda->hideUnused();
1047 //mAllDayAgenda->hideUnused(); 1048 //mAllDayAgenda->hideUnused();
1048 1049
1049 // mAgenda->blockNextRepaint( false ); 1050 // mAgenda->blockNextRepaint( false );
1050 // mAgenda->viewport()->repaint(); 1051 // mAgenda->viewport()->repaint();
1051 // mAgenda->blockNextRepaint( true ); 1052 // mAgenda->blockNextRepaint( true );
1052 mMinY.resize(mSelectedDates.count()); 1053 mMinY.resize(mSelectedDates.count());
1053 mMaxY.resize(mSelectedDates.count()); 1054 mMaxY.resize(mSelectedDates.count());
1054 1055
1055 QPtrList<Event> dayEvents; 1056 QPtrList<Event> dayEvents;
1056 1057
1057 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1058 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1058 // Therefore, get all of them. 1059 // Therefore, gtodoset all of them.
1059 QPtrList<Todo> todos = calendar()->todos(); 1060 QPtrList<Todo> todos = calendar()->todos();
1060 1061
1061 mAgenda->setDateList(mSelectedDates); 1062 mAgenda->setDateList(mSelectedDates);
1062 1063
1063 QDate today = QDate::currentDate(); 1064 QDate today = QDate::currentDate();
1064 1065
1065 DateList::ConstIterator dit; 1066 DateList::ConstIterator dit;
1066 int curCol = 0; 1067 int curCol = 0;
1067 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1068 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1068 QDate currentDate = *dit; 1069 QDate currentDate = *dit;
1069 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1070 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1070 // << endl; 1071 // << endl;
@@ -1146,27 +1147,31 @@ void KOAgendaView::fillAgenda()
1146 } 1147 }
1147 // ---------- [display Todos -------------- 1148 // ---------- [display Todos --------------
1148 unsigned int numTodo; 1149 unsigned int numTodo;
1149 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1150 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1150 Todo *todo = todos.at(numTodo); 1151 Todo *todo = todos.at(numTodo);
1151 1152
1152 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1153 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1153 1154
1154 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1155 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1155 // Already completed items can be displayed on their original due date 1156 // Already completed items can be displayed on their original due date
1156 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1157 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1157 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1158 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1158 1159 bool fillIn = false;
1159 if ( ((todo->dtDue().date() == currentDate) && !overdue) || ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| 1160 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1160 ((currentDate == today) && overdue) ) { 1161 fillIn = true;
1162 if ( ! fillIn && !todo->hasCompletedDate() )
1163 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1164 qDebug("refill todo ");
1165 if ( fillIn ) {
1161 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1166 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1162 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1167 if ( KOPrefs::instance()->mShowTodoInAgenda )
1163 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1168 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1164 } 1169 }
1165 else { 1170 else {
1166 QDateTime dt; 1171 QDateTime dt;
1167 if ( todo->hasCompletedDate() ) 1172 if ( todo->hasCompletedDate() )
1168 dt = todo->completed(); 1173 dt = todo->completed();
1169 else 1174 else
1170 dt = todo->dtDue();; 1175 dt = todo->dtDue();;
1171 1176
1172 1177
@@ -1497,43 +1502,49 @@ void KOAgendaView::scrollOneHourDown()
1497 1502
1498void KOAgendaView::setStartHour( int h ) 1503void KOAgendaView::setStartHour( int h )
1499{ 1504{
1500 mAgenda->setStartHour( h ); 1505 mAgenda->setStartHour( h );
1501 1506
1502} 1507}
1503 1508
1504void KOAgendaView::updateTodo( Todo * t, int ) 1509void KOAgendaView::updateTodo( Todo * t, int )
1505{ 1510{
1506 1511
1507 bool remove = false; 1512 bool remove = false;
1508 bool removeAD = false; 1513 bool removeAD = false;
1509 if ( ! t->hasDueDate() ) { 1514 QDate da;
1515 if ( t->hasCompletedDate() )
1516 da = t->completed().date();
1517 else
1518 da = t->dtDue().date();
1519 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1510 remove = true; 1520 remove = true;
1511 removeAD = true; 1521 removeAD = true;
1512 } 1522 }
1513 else { 1523 else {
1514 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1524 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1515 if ( overdue && 1525 if ( overdue &&
1516 QDate::currentDate() >= mSelectedDates.first() && 1526 QDate::currentDate() >= mSelectedDates.first() &&
1517 QDate::currentDate() <= mSelectedDates.last()) { 1527 QDate::currentDate() <= mSelectedDates.last()) {
1518 removeAD = false; 1528 removeAD = false;
1519 remove = true; 1529 remove = true;
1520 } 1530 }
1521 else { 1531 else {
1522 if ( t->dtDue().date() < mSelectedDates.first() || 1532
1523 t->dtDue().date() > mSelectedDates.last() ) { 1533 if ( da < mSelectedDates.first() ||
1534 da > mSelectedDates.last() ) {
1524 remove = true; 1535 remove = true;
1525 removeAD = true; 1536 removeAD = true;
1526 } else { 1537 } else {
1527 remove = t->doesFloat(); 1538 remove = t->doesFloat() && !t->hasCompletedDate();
1528 removeAD = !remove; 1539 removeAD = !remove;
1529 } 1540 }
1530 } 1541 }
1531 } 1542 }
1532 int days = mSelectedDates.first().daysTo( t->dtDue().date() ); 1543 int days = mSelectedDates.first().daysTo( da );
1533 // qDebug("daysto %d ", days ); 1544 // qDebug("daysto %d ", days );
1534 mAgenda->updateTodo( t , days, remove); 1545 mAgenda->updateTodo( t , days, remove);
1535 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1546 if ( KOPrefs::instance()->mShowTodoInAgenda )
1536 mAllDayAgenda->updateTodo( t , days, removeAD); 1547 mAllDayAgenda->updateTodo( t , days, removeAD);
1537 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1548 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1538 1549
1539} 1550}
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index 36a2947..7dc1880 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -338,24 +338,34 @@ void KOEventViewer::appendTodo(Todo *event, int mode )
338 mText +="<font color=\"#B00000\">"; 338 mText +="<font color=\"#B00000\">";
339 } 339 }
340 if ( mode == 1 ) { 340 if ( mode == 1 ) {
341 addTag("h2",i18n( "Local: " ) +event->summary()); 341 addTag("h2",i18n( "Local: " ) +event->summary());
342 } else { 342 } else {
343 addTag("h2",i18n( "Remote: " ) +event->summary()); 343 addTag("h2",i18n( "Remote: " ) +event->summary());
344 } 344 }
345 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 345 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
346 if ( mColorMode ) 346 if ( mColorMode )
347 mText += "</font>"; 347 mText += "</font>";
348 } 348 }
349 mMailSubject += i18n( "Todo " )+ event->summary(); 349 mMailSubject += i18n( "Todo " )+ event->summary();
350
351 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
352 mText +="<font color=\"#B00000\">";
353 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) );
354 mText += "</font>";
355 } else {
356 mText.append(i18n("<p><i>%1 % completed</i></p>")
357 .arg(event->percentComplete()));
358 }
359
350 if (event->cancelled ()) { 360 if (event->cancelled ()) {
351 mText +="<font color=\"#B00000\">"; 361 mText +="<font color=\"#B00000\">";
352 addTag("i",i18n("This todo has been cancelled!")); 362 addTag("i",i18n("This todo has been cancelled!"));
353 mText.append("<br>"); 363 mText.append("<br>");
354 mText += "</font>"; 364 mText += "</font>";
355 mMailSubject += i18n("(cancelled)"); 365 mMailSubject += i18n("(cancelled)");
356 } 366 }
357 367
358 if (!event->location().isEmpty()) { 368 if (!event->location().isEmpty()) {
359 addTag("b",i18n("Location: ")); 369 addTag("b",i18n("Location: "));
360 mText.append(event->location()+"<br>"); 370 mText.append(event->location()+"<br>");
361 mMailSubject += i18n(" at ") + event->location(); 371 mMailSubject += i18n(" at ") + event->location();
@@ -370,32 +380,24 @@ void KOEventViewer::appendTodo(Todo *event, int mode )
370 addTag("b",i18n("Access: ")); 380 addTag("b",i18n("Access: "));
371 mText.append(event->secrecyStr()+"<br>"); 381 mText.append(event->secrecyStr()+"<br>");
372 if (!event->description().isEmpty()) { 382 if (!event->description().isEmpty()) {
373 addTag("p",i18n("<b>Details: </b>")); 383 addTag("p",i18n("<b>Details: </b>"));
374 addTag("p",event->description()); 384 addTag("p",event->description());
375 } 385 }
376 386
377 formatCategories(event); 387 formatCategories(event);
378 388
379 mText.append(i18n("<p><b>Priority:</b> %2</p>") 389 mText.append(i18n("<p><b>Priority:</b> %2</p>")
380 .arg(QString::number(event->priority()))); 390 .arg(QString::number(event->priority())));
381 391
382 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
383 mText.append(i18n("<p><i>Completed on %1</i></p>")
384 .arg( event->completedStr() ));
385 } else {
386 mText.append(i18n("<p><i>%1 % completed</i></p>")
387 .arg(event->percentComplete()));
388 }
389
390 formatReadOnly(event); 392 formatReadOnly(event);
391 formatAttendees(event); 393 formatAttendees(event);
392 if ( event->relatedTo() ) { 394 if ( event->relatedTo() ) {
393 addTag("b",i18n("Parent todo: ")); 395 addTag("b",i18n("Parent todo: "));
394 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); 396 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>");
395 } 397 }
396 QPtrList<Incidence> Relations = event->relations(); 398 QPtrList<Incidence> Relations = event->relations();
397 Incidence *to; 399 Incidence *to;
398 if ( Relations.first() ) 400 if ( Relations.first() )
399 addTag("b",i18n("Sub todos:<br>")); 401 addTag("b",i18n("Sub todos:<br>"));
400 for (to=Relations.first();to;to=Relations.next()) { 402 for (to=Relations.first();to;to=Relations.next()) {
401 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); 403 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>");
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 8c1953d..14e8b5c 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -325,24 +325,25 @@ void KOQuickTodo::focusInEvent(QFocusEvent *ev)
325 325
326void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 326void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
327{ 327{
328 setText(i18n("Click to add a new Todo")); 328 setText(i18n("Click to add a new Todo"));
329 QLineEdit::focusOutEvent(ev); 329 QLineEdit::focusOutEvent(ev);
330} 330}
331 331
332///////////////////////////////////////////////////////////////////////////// 332/////////////////////////////////////////////////////////////////////////////
333 333
334KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 334KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
335 KOrg::BaseView(calendar,parent,name) 335 KOrg::BaseView(calendar,parent,name)
336{ 336{
337 isFlatDisplay = false;
337 mNavigator = 0; 338 mNavigator = 0;
338 QBoxLayout *topLayout = new QVBoxLayout(this); 339 QBoxLayout *topLayout = new QVBoxLayout(this);
339 mName = QString ( name ); 340 mName = QString ( name );
340 mBlockUpdate = false; 341 mBlockUpdate = false;
341 mQuickAdd = new KOQuickTodo(this); 342 mQuickAdd = new KOQuickTodo(this);
342 topLayout->addWidget(mQuickAdd); 343 topLayout->addWidget(mQuickAdd);
343 344
344 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 345 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
345 346
346 mTodoListView = new KOTodoListView(calendar,this, name ); 347 mTodoListView = new KOTodoListView(calendar,this, name );
347 topLayout->addWidget(mTodoListView); 348 topLayout->addWidget(mTodoListView);
348 //mTodoListView->header()->setMaximumHeight(30); 349 //mTodoListView->header()->setMaximumHeight(30);
@@ -943,35 +944,43 @@ void KOTodoView::itemClicked(QListViewItem *item)
943 if ( !allowReparent ) { 944 if ( !allowReparent ) {
944 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 945 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
945 qDebug("Recursive reparenting not possible "); 946 qDebug("Recursive reparenting not possible ");
946 pendingSubtodo = 0; 947 pendingSubtodo = 0;
947 } else { 948 } else {
948 Todo* newParent = todoItem->todo(); 949 Todo* newParent = todoItem->todo();
949 Todo* newSub = pendingSubtodo->todo(); 950 Todo* newSub = pendingSubtodo->todo();
950 pendingSubtodo = 0; 951 pendingSubtodo = 0;
951 emit reparentTodoSignal( newParent,newSub ); 952 emit reparentTodoSignal( newParent,newSub );
952 return; 953 return;
953 } 954 }
954 } 955 }
955 int completed = todoItem->todo()->isCompleted(); // Completed or not? 956#if 0
956 957 // handled by the item itself
958 bool completed = todoItem->todo()->isCompleted(); // Completed or not?
959 qDebug("com %d ",completed );
960 qDebug("itemclicked ");
957 if (todoItem->isOn()) { 961 if (todoItem->isOn()) {
962 qDebug("on ");
958 if (!completed) { 963 if (!completed) {
964 qDebug("set true ");
959 todoItem->todo()->setCompleted(QDateTime::currentDateTime()); 965 todoItem->todo()->setCompleted(QDateTime::currentDateTime());
960 } 966 }
961 } else { 967 } else {
968 qDebug("not on ");
962 if (completed) { 969 if (completed) {
970 qDebug("set false ");
963 todoItem->todo()->setCompleted(false); 971 todoItem->todo()->setCompleted(false);
964 } 972 }
965 } 973 }
974#endif
966} 975}
967 976
968void KOTodoView::setDocumentId( const QString &id ) 977void KOTodoView::setDocumentId( const QString &id )
969{ 978{
970 kdDebug() << "KOTodoView::setDocumentId()" << endl; 979 kdDebug() << "KOTodoView::setDocumentId()" << endl;
971 980
972 mDocPrefs->setDoc( id ); 981 mDocPrefs->setDoc( id );
973} 982}
974 983
975void KOTodoView::itemStateChanged( QListViewItem *item ) 984void KOTodoView::itemStateChanged( QListViewItem *item )
976{ 985{
977 if (!item) return; 986 if (!item) return;
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index 21ecb73..2822237 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -194,31 +194,30 @@ void KOTodoViewItem::setMyPixmap()
194 // } 194 // }
195 if ( pixi.width() > 1 ) { 195 if ( pixi.width() > 1 ) {
196 setPixmap ( 0,pixi ) ; 196 setPixmap ( 0,pixi ) ;
197 } else { 197 } else {
198 setPixmap ( 0,QPixmap() ) ; 198 setPixmap ( 0,QPixmap() ) ;
199 } 199 }
200} 200}
201void KOTodoViewItem::stateChange(bool state) 201void KOTodoViewItem::stateChange(bool state)
202{ 202{
203 // qDebug("KOTodoViewItem::stateChange "); 203 // qDebug("KOTodoViewItem::stateChange ");
204 // do not change setting on startup 204 // do not change setting on startup
205 if ( m_init ) return; 205 if ( m_init ) return;
206 206 qDebug("KOTodoViewItem::stateChange ");
207 kdDebug() << "State changed, modified " << state << endl;
208 QString keyd = "=="; 207 QString keyd = "==";
209 QString keyt = "=="; 208 QString keyt = "==";
210 209
211 if (state) mTodo->setCompleted(state); 210 mTodo->setCompleted(state);
212 else mTodo->setPercentComplete(0); 211 if (state) mTodo->setCompleted(QDateTime::currentDateTime());
213 if (isOn()!=state) { 212 if (isOn()!=state) {
214 setOn(state); 213 setOn(state);
215 } 214 }
216 215
217 if (mTodo->hasDueDate()) { 216 if (mTodo->hasDueDate()) {
218 setText(3, mTodo->dtDueDateStr()); 217 setText(3, mTodo->dtDueDateStr());
219 QDate d = mTodo->dtDue().date(); 218 QDate d = mTodo->dtDue().date();
220 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 219 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
221 setSortKey(3,keyd); 220 setSortKey(3,keyd);
222 if (mTodo->doesFloat()) { 221 if (mTodo->doesFloat()) {
223 setText(4,""); 222 setText(4,"");
224 } 223 }
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index c52f2b3..6d07d4c 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -158,49 +158,49 @@ void KIncidenceFormatter::setTodo(Todo *event )
158 if ( mColorMode == 2 ) { 158 if ( mColorMode == 2 ) {
159 mText +="<font color=\"#B00000\">"; 159 mText +="<font color=\"#B00000\">";
160 } 160 }
161 if ( mode == 1 ) { 161 if ( mode == 1 ) {
162 addTag("h2",i18n( "Local: " ) +event->summary()); 162 addTag("h2",i18n( "Local: " ) +event->summary());
163 } else { 163 } else {
164 addTag("h2",i18n( "Remote: " ) +event->summary()); 164 addTag("h2",i18n( "Remote: " ) +event->summary());
165 } 165 }
166 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 166 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
167 if ( mColorMode ) 167 if ( mColorMode )
168 mText += "</font>"; 168 mText += "</font>";
169 } 169 }
170 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
171 mText +="<font color=\"#B00000\">";
172 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) );
173 mText += "</font>";
174 } else {
175 mText.append(i18n("<p><i>%1 % completed</i></p>")
176 .arg(event->percentComplete()));
177 }
170 if (event->cancelled ()) { 178 if (event->cancelled ()) {
171 mText +="<font color=\"#B00000\">"; 179 mText +="<font color=\"#B00000\">";
172 addTag("i",i18n("This todo has been cancelled!")); 180 addTag("i",i18n("This todo has been cancelled!"));
173 mText.append("<br>"); 181 mText.append("<br>");
174 mText += "</font>"; 182 mText += "</font>";
175 } 183 }
176 184
177 if (!event->location().isEmpty()) { 185 if (!event->location().isEmpty()) {
178 addTag("b",i18n("Location: ")); 186 addTag("b",i18n("Location: "));
179 mText.append(event->location()+"<br>"); 187 mText.append(event->location()+"<br>");
180 } 188 }
181 if (event->hasDueDate()) { 189 if (event->hasDueDate()) {
182 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); 190 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate)));
183 } 191 }
184 mText.append(i18n("<p><b>Priority:</b> %2</p>") 192 mText.append(i18n("<p><b>Priority:</b> %2</p>")
185 .arg(QString::number(event->priority()))); 193 .arg(QString::number(event->priority())));
186 194
187 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
188 mText.append(i18n("<p><i>Completed on %1</i></p>")
189 .arg( event->completedStr() ));
190 } else {
191 mText.append(i18n("<p><i>%1 % completed</i></p>")
192 .arg(event->percentComplete()));
193 }
194
195 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 195 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
196 formatCategories(event); 196 formatCategories(event);
197 if (!event->description().isEmpty()) { 197 if (!event->description().isEmpty()) {
198 addTag("p",i18n("<b>Details: </b>")); 198 addTag("p",i18n("<b>Details: </b>"));
199 addTag("p",event->description()); 199 addTag("p",event->description());
200 } 200 }
201 201
202 202
203 203
204 formatReadOnly(event); 204 formatReadOnly(event);
205 formatAttendees(event); 205 formatAttendees(event);
206 206
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 7362bdf..7d04793 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -291,31 +291,32 @@ void Todo::setCompleted(bool completed)
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() const 303QString Todo::completedStr( bool shortF ) const
304{ 304{
305 return KGlobal::locale()->formatDateTime(mCompleted); 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 mHasCompletedDate = true; 311 mHasCompletedDate = true;
311 mPercentComplete = 100; 312 mPercentComplete = 100;
312 mCompleted = getEvenTime(completed); 313 mCompleted = getEvenTime(completed);
313 updated(); 314 updated();
314} 315}
315 316
316bool Todo::hasCompletedDate() const 317bool Todo::hasCompletedDate() const
317{ 318{
318 return mHasCompletedDate; 319 return mHasCompletedDate;
319} 320}
320 321
321int Todo::percentComplete() const 322int Todo::percentComplete() const
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 0f22c59..41f5841 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -84,25 +84,25 @@ class Todo : public Incidence
84 Return how many percent of the task are completed. Returns a value 84 Return how many percent of the task are completed. Returns a value
85 between 0 and 100. 85 between 0 and 100.
86 */ 86 */
87 int percentComplete() const; 87 int percentComplete() const;
88 /** 88 /**
89 Set how many percent of the task are completed. Valid values are in the 89 Set how many percent of the task are completed. Valid values are in the
90 range from 0 to 100. 90 range from 0 to 100.
91 */ 91 */
92 void setPercentComplete(int); 92 void setPercentComplete(int);
93 93
94 /** return date and time when todo was completed */ 94 /** return date and time when todo was completed */
95 QDateTime completed() const; 95 QDateTime completed() const;
96 QString completedStr() const; 96 QString completedStr(bool shortF = true) const;
97 /** set date and time of completion */ 97 /** set date and time of completion */
98 void setCompleted(const QDateTime &completed); 98 void setCompleted(const QDateTime &completed);
99 99
100 /** Return true, if todo has a date associated with completion */ 100 /** Return true, if todo has a date associated with completion */
101 bool hasCompletedDate() const; 101 bool hasCompletedDate() const;
102 bool contains ( Todo*); 102 bool contains ( Todo*);
103 103
104 private: 104 private:
105 bool accept(Visitor &v) { return v.visit(this); } 105 bool accept(Visitor &v) { return v.visit(this); }
106 106
107 QDateTime mDtDue; // due date of todo 107 QDateTime mDtDue; // due date of todo
108 108