summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/koagendaview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 13d8398..4ff6899 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -990,25 +990,38 @@ void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
if ( item->cellYBottom() > 0 )
endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
else
endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
endDt.setDate(startDate);
}
}
}
if ( item->incidence()->type() == "Event" ) {
item->incidence()->setDtStart(startDt);
(static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
} else if ( item->incidence()->type() == "Todo" ) {
- (static_cast<Todo*>(item->incidence()))->setDtDue(endDt);
+ Todo* to = static_cast<Todo*>(item->incidence());
+
+ int len = 0;
+ if ( to->hasStartDate() && to->hasDueDate() )
+ len = to->dtStart().secsTo( to->dtDue());
+ to->setDtDue(endDt);
+ if ( to->hasStartDate() ) {
+ if ( len>0 )
+ to->setDtStart(to->dtDue().addSecs( -len ));
+ else
+ if (to->dtStart() > to->dtDue() )
+ to->setDtStart(to->dtDue().addDays( -3 ));
+ }
+
}
//qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
item->incidence()->setRevision(item->incidence()->revision()+1);
item->setItemDate(startDt.date());
//item->updateItem();
if ( item->incidence()->type() == "Todo" ) {
emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
}
else
emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
item->updateItem();
@@ -1171,25 +1184,25 @@ void KOAgendaView::fillAgenda()
if (endY < startY) endY = startY;
mAgenda->insertItem(event,currentDate,curCol,startY,endY);
if (startY < mMinY[curCol]) mMinY[curCol] = startY;
if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
}
}
// ---------- [display Todos --------------
unsigned int numTodo;
for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
Todo *todo = todos.at(numTodo);
if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
-
+
// ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
// Already completed items can be displayed on their original due date
//if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
bool fillIn = false;
if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
fillIn = true;
if ( ! fillIn && !todo->hasCompletedDate() )
fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
if ( fillIn ) {
if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
if ( KOPrefs::instance()->mShowTodoInAgenda )