-rw-r--r-- | korganizer/koagenda.cpp | 11 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 31 | ||||
-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 | 16 | ||||
-rw-r--r-- | libkcal/todo.cpp | 5 | ||||
-rw-r--r-- | libkcal/todo.h | 2 |
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 | |||
@@ -1418,7 +1418,7 @@ KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | |||
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); |
@@ -1457,12 +1457,17 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | |||
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; |
@@ -1476,7 +1481,7 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | |||
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); |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 1864e22..bbc43e4 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -950,6 +950,7 @@ void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | |||
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. |
@@ -965,7 +966,7 @@ void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | |||
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); |
@@ -1055,7 +1056,7 @@ void KOAgendaView::fillAgenda() | |||
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); |
@@ -1155,9 +1156,13 @@ void KOAgendaView::fillAgenda() | |||
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); |
@@ -1506,7 +1511,12 @@ void KOAgendaView::updateTodo( Todo * t, int ) | |||
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 | } |
@@ -1519,17 +1529,18 @@ void KOAgendaView::updateTodo( Todo * t, int ) | |||
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 ) |
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index 36a2947..7dc1880 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -347,6 +347,16 @@ void KOEventViewer::appendTodo(Todo *event, int mode ) | |||
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!")); |
@@ -379,14 +389,6 @@ void KOEventViewer::appendTodo(Todo *event, int mode ) | |||
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() ) { |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 8c1953d..14e8b5c 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -334,6 +334,7 @@ void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | |||
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 ); |
@@ -952,17 +953,25 @@ void KOTodoView::itemClicked(QListViewItem *item) | |||
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 ) |
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 21ecb73..2822237 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -203,13 +203,12 @@ void KOTodoViewItem::stateChange(bool state) | |||
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 | } |
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index c52f2b3..6d07d4c 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -167,6 +167,14 @@ void KIncidenceFormatter::setTodo(Todo *event ) | |||
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!")); |
@@ -184,14 +192,6 @@ void KIncidenceFormatter::setTodo(Todo *event ) | |||
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()) { |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 7362bdf..7d04793 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -300,13 +300,14 @@ QDateTime Todo::completed() const | |||
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); |
diff --git a/libkcal/todo.h b/libkcal/todo.h index 0f22c59..41f5841 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -93,7 +93,7 @@ class Todo : public Incidence | |||
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 | ||