[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdepim/libkcal
From:       David Jarvie <software () astrojar ! org ! uk>
Date:       2006-05-29 19:18:10
Message-ID: 1148930290.248732.6252.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 546332 by djarvie:

Prevent appendRecurringAlarms() returning alarms earlier than the 'from' date

 M  +12 -6     calendarlocal.cpp  


--- trunk/KDE/kdepim/libkcal/calendarlocal.cpp #546331:546332
@@ -302,8 +302,14 @@
           offset = alarm->endOffset().asSeconds() + endOffset;
         }
 
-        // Adjust the 'from' date/time and find the next recurrence at or after it
-        qdt = incidence->recurrence()->getNextDateTime( from.addSecs(-offset - 1) );
+        // Find the incidence's earliest alarm
+        QDateTime fromStart = incidence->dtStart().addSecs( offset );
+        if ( fromStart > to )
+          continue;
+        if ( from > fromStart )
+          fromStart = from;   // don't look earlier than the earliest alarm
+        // Adjust the 'fromStart' date/time and find the next recurrence at or after it
+        qdt = incidence->recurrence()->getNextDateTime( fromStart.addSecs(-offset - 1) );
         if ( !qdt.isValid()
         ||   (qdt = qdt.addSecs( offset )) > to )    // remove the adjustment to get the alarm time
         {
@@ -313,13 +319,13 @@
           // The alarm has repetitions, so check whether repetitions of previous
           // recurrences fall within the time period.
           bool found = false;
-          qdt = from.addSecs( -offset );
+          qdt = fromStart.addSecs( -offset );
           while ( (qdt = incidence->recurrence()->getPreviousDateTime( qdt )).isValid() ) {
-            int toFrom = qdt.secsTo( from ) - offset;
+            int toFrom = qdt.secsTo( fromStart ) - offset;
             if ( toFrom > alarm->duration() )
               break;     // this recurrence's last repetition is too early, so give up
-            // The last repetition of this recurrence is at or after 'from' time.
-            // Check if a repetition occurs between 'from' and 'to'.
+            // The last repetition of this recurrence is at or after 'fromStart' time.
+            // Check if a repetition occurs between 'fromStart' and 'to'.
             int snooze = alarm->snoozeTime() * 60;   // in seconds
             if ( period >= snooze
             ||   toFrom % snooze == 0
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic