summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-01 04:42:26 (UTC)
committer zautrix <zautrix>2005-07-01 04:42:26 (UTC)
commit4a47a69978fd392be65ea67c5153d5e2ade74c19 (patch) (side-by-side diff)
tree4208a2955c206adc826209c7854e0c628c1c5441
parentd401e425af46703a89eb80802606edeea06c9538 (diff)
downloadkdepimpi-4a47a69978fd392be65ea67c5153d5e2ade74c19.zip
kdepimpi-4a47a69978fd392be65ea67c5153d5e2ade74c19.tar.gz
kdepimpi-4a47a69978fd392be65ea67c5153d5e2ade74c19.tar.bz2
alarm fixx
Diffstat (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
@@ -508,68 +508,82 @@ bool Todo::setRecurDates()
if ( !mHasRecurrenceID )
return true;
int secs = mDtStart.secsTo( dtDue() );
bool ok;
qDebug("T:setRecurDates() ");
//qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
QDateTime next = getNextOccurence( mRecurrenceID, &ok );
if ( ok ) {
mRecurrenceID = next;
mDtStart = next;
setDtDue( next.addSecs( secs ) );
if ( QDateTime::currentDateTime() > next)
return false;
} else {
setHasRecurrenceID( false );
recurrence()->unsetRecurs();
}
return true;
}
void Todo::setPercentComplete(int v)
{
if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) {
if ( !setRecurDates() )
v = 0;
}
mPercentComplete = 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 );;
// if ( QDateTime::currentDateTime() > incidenceStart ){
// *ok = false;
// return incidenceStart;
// }
for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
if (alarm->enabled()) {
if ( alarm->hasTime () ) {
if ( alarm->time() < alarmStart ) {
alarmStart = alarm->time();
enabled = true;
off = alarmStart.secsTo( incidenceStart );
}
} else {
int secs = alarm->startOffset().asSeconds();
if ( incidenceStart.addSecs( secs ) < alarmStart ) {
alarmStart = incidenceStart.addSecs( secs );
enabled = true;
off = -secs;
}
}
}
}
if ( enabled ) {
if ( alarmStart > start_dt ) {
*ok = true;