-rw-r--r-- | korganizer/koagenda.cpp | 11 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 33 | ||||
-rw-r--r-- | korganizer/koeventviewer.cpp | 18 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 13 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 7 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 18 | ||||
-rw-r--r-- | libkcal/todo.cpp | 5 | ||||
-rw-r--r-- | libkcal/todo.h | 2 |
8 files changed, 67 insertions, 40 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 002234d..7c41cab 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1417,9 +1417,9 @@ KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | |||
1417 | 1417 | ||
1418 | 1418 | ||
1419 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1419 | void 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 ) { |
@@ -1456,14 +1456,19 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | |||
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 |
@@ -1475,9 +1480,9 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | |||
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(); |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 1864e22..bbc43e4 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -949,8 +949,9 @@ void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | |||
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())); |
@@ -964,9 +965,9 @@ void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | |||
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" ) { |
@@ -1054,9 +1055,9 @@ void KOAgendaView::fillAgenda() | |||
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 | ||
@@ -1154,11 +1155,15 @@ void KOAgendaView::fillAgenda() | |||
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 | } |
@@ -1502,12 +1507,17 @@ void KOAgendaView::setStartHour( int h ) | |||
1502 | } | 1507 | } |
1503 | 1508 | ||
1504 | void KOAgendaView::updateTodo( Todo * t, int ) | 1509 | void 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 { |
@@ -1518,19 +1528,20 @@ void KOAgendaView::updateTodo( Todo * t, int ) | |||
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); |
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index 36a2947..7dc1880 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -346,8 +346,18 @@ void KOEventViewer::appendTodo(Todo *event, int mode ) | |||
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>"); |
@@ -378,16 +388,8 @@ void KOEventViewer::appendTodo(Todo *event, int mode ) | |||
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: ")); |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 8c1953d..14e8b5c 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -333,8 +333,9 @@ void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | |||
333 | 333 | ||
334 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 334 | KOTodoView::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; |
@@ -951,19 +952,27 @@ void KOTodoView::itemClicked(QListViewItem *item) | |||
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 | ||
968 | void KOTodoView::setDocumentId( const QString &id ) | 977 | void KOTodoView::setDocumentId( const QString &id ) |
969 | { | 978 | { |
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 21ecb73..2822237 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -202,15 +202,14 @@ void 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 | ||
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index c52f2b3..6d07d4c 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -166,8 +166,16 @@ void KIncidenceFormatter::setTodo(Todo *event ) | |||
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>"); |
@@ -183,17 +191,9 @@ void KIncidenceFormatter::setTodo(Todo *event ) | |||
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() ) { | 195 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
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() ); | ||
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()); |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 7362bdf..7d04793 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -299,15 +299,16 @@ QDateTime Todo::completed() const | |||
299 | { | 299 | { |
300 | return mCompleted; | 300 | return mCompleted; |
301 | } | 301 | } |
302 | 302 | ||
303 | QString Todo::completedStr() const | 303 | QString Todo::completedStr( bool shortF ) const |
304 | { | 304 | { |
305 | return KGlobal::locale()->formatDateTime(mCompleted); | 305 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); |
306 | } | 306 | } |
307 | 307 | ||
308 | void Todo::setCompleted(const QDateTime &completed) | 308 | void 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(); |
diff --git a/libkcal/todo.h b/libkcal/todo.h index 0f22c59..41f5841 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -92,9 +92,9 @@ class Todo : public Incidence | |||
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 */ |