summaryrefslogtreecommitdiffabout
path: root/libkcal/todo.cpp
Side-by-side diff
Diffstat (limited to 'libkcal/todo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 5260051..4ada2d8 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -534,16 +534,30 @@ void Todo::setPercentComplete(int v)
if ( v != 100 )
mHasCompletedDate = false;
updated();
}
QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const
{
- if ( isCompleted() || ! hasDueDate() || cancelled() || !alarmEnabled() ) {
- *ok = false;
+ *ok = false;
+ if ( ! hasDueDate() || cancelled() || !alarmEnabled() ) {
return QDateTime ();
}
+ // if the recurring todo is set to complete and requested time < start time of todo
+ // we want to get the alarm.
+ bool iscompleted = isCompleted();
+ if ( iscompleted && doesRecur() ) {
+ Todo * to = (Todo*) this;
+ to->checkSetCompletedFalse();
+ iscompleted = isCompleted();
+ if ( hasStartDate() && start_dt < dtStart() ){
+ iscompleted = false;
+ }
+ }
+ if ( iscompleted ) {
+ return QDateTime ();
+ }
QDateTime incidenceStart;
incidenceStart = dtDue();
bool enabled = false;
Alarm* alarm;
int off = 0;
QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;