diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
commit | cc29364f06178f8f6b457384f2ec37a042bd9d43 (patch) | |
tree | 7c77a3184c698bbf9d98cef09fb1ba8124daceba /libkcal/recurrencerule.h | |
parent | 4f6c584bacc8c3c694228f36ada3de77a76614a6 (diff) | |
download | tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.tar.gz tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.zip |
* Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch
* Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed
* Added journal read support to the CalDAV resource
* Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkcal/recurrencerule.h')
-rw-r--r-- | libkcal/recurrencerule.h | 121 |
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; |