summaryrefslogtreecommitdiffstats
path: root/libkcal/recurrencerule.h
diff options
context:
space:
mode:
Diffstat (limited to 'libkcal/recurrencerule.h')
-rw-r--r--libkcal/recurrencerule.h121
1 files changed, 120 insertions, 1 deletions
diff --git a/libkcal/recurrencerule.h b/libkcal/recurrencerule.h
index 049d9c523..86b8ca8ea 100644
--- a/libkcal/recurrencerule.h
+++ b/libkcal/recurrencerule.h
@@ -50,6 +50,109 @@ Q_INLINE_TEMPLATES void qSortUnique( TQValueList<T> &lst )
}
}
+template <class T>
+Q_INLINE_TEMPLATES int findGE( const TQValueList<T> &lst, const T &value, int start )
+{
+ // Do a binary search to find the first item >= value
+ int st = start - 1;
+ int end = lst.count();
+ while ( end - st > 1 ) {
+ int i = ( st + end ) / 2;
+ if ( value <= lst[i] ) {
+ end = i;
+ } else {
+ st = i;
+ }
+ }
+ ++st;
+ return ( st == int( lst.count() ) ) ? -1 : st;
+}
+
+template <class T>
+Q_INLINE_TEMPLATES int findGT( const TQValueList<T> &lst, const T &value, int start )
+{
+ // Do a binary search to find the first item > value
+ int st = start - 1;
+ int end = lst.count();
+ while ( end - st > 1 ) {
+ int i = ( st + end ) / 2;
+ if ( value < lst[i] ) {
+ end = i;
+ } else {
+ st = i;
+ }
+ }
+ ++st;
+ return ( st == int( lst.count() ) ) ? -1 : st;
+}
+
+template <class T>
+Q_INLINE_TEMPLATES int findLE( const TQValueList<T> &lst, const T &value, int start )
+{
+ // Do a binary search to find the last item <= value
+ int st = start - 1;
+ int end = lst.count();
+ while ( end - st > 1 ) {
+ int i = ( st + end ) / 2;
+ if ( value < lst[i] ) {
+ end = i;
+ } else {
+ st = i;
+ }
+ }
+ return ( end > start ) ? st : -1;
+}
+
+template <class T>
+Q_INLINE_TEMPLATES int findLT( const TQValueList<T> &lst, const T &value, int start )
+{
+ // Do a binary search to find the last item < value
+ int st = start - 1;
+ int end = lst.count();
+ while ( end - st > 1 ) {
+ int i = ( st + end ) / 2;
+ if ( value <= lst[i] ) {
+ end = i;
+ } else {
+ st = i;
+ }
+ }
+ return ( end > start ) ? st : -1;
+}
+
+template <class T>
+Q_INLINE_TEMPLATES int findSorted( const TQValueList<T> &lst, const T &value, int start )
+{
+ // Do a binary search to find the item == value
+ int st = start - 1;
+ int end = lst.count();
+ while ( end - st > 1 ) {
+ int i = ( st + end ) / 2;
+ if ( value < lst[i] ) {
+ end = i;
+ } else {
+ st = i;
+ }
+ }
+ return ( end > start && value == lst[st] ) ? st : -1;
+}
+
+template <class T>
+Q_INLINE_TEMPLATES int removeSorted( TQValueList<T> &lst, const T &value, int start )
+{
+ int i = findSorted( lst, value, start );
+ if ( i >= 0 ) {
+ lst.remove( lst.at( i ) );
+ }
+ return i;
+}
+
+template <class T>
+Q_INLINE_TEMPLATES bool containsSorted( const TQValueList<T> &lst, const T &value )
+{
+ return findSorted( lst, value, 0 ) >= 0;
+}
+
namespace KCal {
@@ -188,6 +291,18 @@ class LIBKCAL_EXPORT RecurrenceRule
*/
TimeList recurTimesOn( const TQDate &date ) const;
+ /** Returns a list of all the times at which the recurrence will occur
+ * between two specified times.
+ *
+ * There is a (large) maximum limit to the number of times returned. If due to
+ * this limit the list is incomplete, this is indicated by the last entry being
+ * set to an invalid KDateTime value. If you need further values, call the
+ * method again with a start time set to just after the last valid time returned.
+ * @param start inclusive start of interval
+ * @param end inclusive end of interval
+ * @return list of date/time values
+ */
+ DateTimeList timesInInterval( const TQDateTime &start, const TQDateTime &end ) const;
/** Returns the date and time of the next recurrence, after the specified date/time.
* If the recurrence has no time, the next date after the specified date is returned.
@@ -331,8 +446,12 @@ class LIBKCAL_EXPORT RecurrenceRule
// Cache for duration
mutable DateTimeList mCachedDates;
- mutable bool mCached;
mutable TQDateTime mCachedDateEnd;
+ mutable TQDateTime mCachedLastDate; // when mCachedDateEnd invalid, last date checked
+ mutable bool mCached;
+
+ bool mNoByRules; // no BySeconds, ByMinutes, ... rules exist
+ uint mTimedRepetition; // repeats at a regular number of seconds interval, or 0
class Private;
Private *d;