libkcal Library API Documentation

KCal::Recurrence Class Reference

This class represents a recurrence rule for a calendar incidence. More...

#include <recurrence.h>

Collaboration diagram for KCal::Recurrence:

Collaboration graph
[legend]
List of all members.

Public Types

enum  {
  rNone = 0, rMinutely = 0x001, rHourly = 0x0002, rDaily = 0x0003,
  rWeekly = 0x0004, rMonthlyPos = 0x0005, rMonthlyDay = 0x0006, rYearlyMonth = 0x0007,
  rYearlyDay = 0x0008, rYearlyPos = 0x0009
}
enum  Feb29Type { rMar1, rFeb28, rFeb29 }

Public Member Functions

 Recurrence (Incidence *parent, int compatVersion=0)
 Recurrence (const Recurrence &, Incidence *parent)
bool operator== (const Recurrence &) const
bool operator!= (const Recurrence &r) const
Incidenceparent ()
QDateTime recurStart () const
void setRecurStart (const QDateTime &start)
void setRecurStart (const QDate &start)
void setFloats (bool f)
bool doesFloat () const
void setRecurReadOnly (bool readOnly)
bool recurReadOnly () const
void setCompatVersion (int version=0)
ushort doesRecur () const
bool recursOnPure (const QDate &qd) const
bool recursAtPure (const QDateTime &) const
void unsetRecurs ()
QValueList< QTimerecurTimesOn (const QDate &date) const
QDate getNextDate (const QDate &preDate, bool *last=0) const
QDateTime getNextDateTime (const QDateTime &preDateTime, bool *last=0) const
QDate getPreviousDate (const QDate &afterDate, bool *last=0) const
QDateTime getPreviousDateTime (const QDateTime &afterDateTime, bool *last=0) const
int frequency () const
void setFrequency (int freq)
int duration () const
void setDuration (int duration)
int durationTo (const QDate &) const
int durationTo (const QDateTime &) const
QDate endDate (bool *result=0) const
QDateTime endDateTime (bool *result=0) const
QString endDateStr (bool shortfmt=true) const
void setEndDate (const QDate &endDate)
void setEndDateTime (const QDateTime &endDateTime)
void setMinutely (int _rFreq, int duration)
void setMinutely (int _rFreq, const QDateTime &endDateTime)
void setHourly (int _rFreq, int duration)
void setHourly (int _rFreq, const QDateTime &endDateTime)
void setDaily (int _rFreq, int duration)
void setDaily (int _rFreq, const QDate &endDate)
void setWeekly (int _rFreq, const QBitArray &_rDays, int duration, int weekStart=1)
void setWeekly (int _rFreq, const QBitArray &_rDays, const QDate &endDate, int weekStart=1)
int weekStart () const
const QBitArraydays () const
void setMonthly (short type, int _rFreq, int duration)
void setMonthly (short type, int _rFreq, const QDate &endDate)
void addMonthlyPos (short _rPos, const QBitArray &_rDays)
void addMonthlyDay (short _rDay)
const QPtrList< rMonthPos > & monthPositions () const
const QPtrList< int > & monthDays () const
void setYearly (int type, int freq, int duration)
void setYearly (int type, int freq, const QDate &endDate)
void setYearlyByDate (Feb29Type type, int freq, int duration)
void setYearlyByDate (Feb29Type type, int freq, const QDate &endDate)
void setYearlyByDate (int day, Feb29Type type, int freq, int duration)
void setYearlyByDate (int day, Feb29Type type, int freq, const QDate &endDate)
void addYearlyNum (short _rNum)
void addYearlyMonthPos (short _rPos, const QBitArray &_rDays)
const QPtrList< int > & yearNums () const
const QPtrList< rMonthPos > & yearMonthPositions () const
Feb29Type feb29YearlyType () const
int countMonthlyPosDays () const
void getMonthlyPosDays (QValueList< int > &list, int daysInMonth, int startDayOfWeek) const
bool getMonthlyDayDays (QValueList< int > &list, int daysInMonth) const
bool getYearlyMonthMonths (int day, QValueList< int > &list, QValueList< int > &leaplist) const
void dump () const

Static Public Member Functions

static void setFeb29YearlyTypeDefault (Feb29Type t)
static Feb29Type setFeb29YearlyTypeDefault ()

Static Public Attributes

static const QDate MAX_DATE

Protected Types

enum  PeriodFunc { END_DATE_AND_COUNT, COUNT_TO_DATE, NEXT_AFTER_DATE }

Protected Member Functions

bool recursSecondly (const QDate &, int secondFreq) const
bool recursMinutelyAt (const QDateTime &dt, int minuteFreq) const
bool recursDaily (const QDate &) const
bool recursWeekly (const QDate &) const
bool recursMonthly (const QDate &) const
bool recursYearlyByMonth (const QDate &) const
bool recursYearlyByPos (const QDate &) const
bool recursYearlyByDay (const QDate &) const
QDate getNextDateNoTime (const QDate &preDate, bool *last) const
QDate getPreviousDateNoTime (const QDate &afterDate, bool *last) const
void addMonthlyPos_ (short _rPos, const QBitArray &_rDays)
void setDailySub (short type, int freq, int duration)
void setYearly_ (short type, Feb29Type, int freq, int duration)
int recurCalc (PeriodFunc, QDate &enddate) const
int recurCalc (PeriodFunc, QDateTime &endtime) const
int secondlyCalc (PeriodFunc, QDateTime &endtime, int freq) const
int dailyCalc (PeriodFunc, QDate &enddate) const
int weeklyCalc (PeriodFunc, QDate &enddate) const
int weeklyCalcEndDate (QDate &enddate, int daysPerWeek) const
int weeklyCalcToDate (const QDate &enddate, int daysPerWeek) const
int weeklyCalcNextAfter (QDate &enddate, int daysPerWeek) const
int monthlyCalc (PeriodFunc, QDate &enddate) const
int monthlyCalcEndDate (QDate &enddate, MonthlyData &) const
int monthlyCalcToDate (const QDate &enddate, MonthlyData &) const
int monthlyCalcNextAfter (QDate &enddate, MonthlyData &) const
int yearlyMonthCalc (PeriodFunc, QDate &enddate) const
int yearlyMonthCalcEndDate (QDate &enddate, YearlyMonthData &) const
int yearlyMonthCalcToDate (const QDate &enddate, YearlyMonthData &) const
int yearlyMonthCalcNextAfter (QDate &enddate, YearlyMonthData &) const
int yearlyPosCalc (PeriodFunc, QDate &enddate) const
int yearlyPosCalcEndDate (QDate &enddate, YearlyPosData &) const
int yearlyPosCalcToDate (const QDate &enddate, YearlyPosData &) const
int yearlyPosCalcNextAfter (QDate &enddate, YearlyPosData &) const
int yearlyDayCalc (PeriodFunc, QDate &enddate) const
int yearlyDayCalcEndDate (QDate &enddate, YearlyDayData &) const
int yearlyDayCalcToDate (const QDate &enddate, YearlyDayData &) const
int yearlyDayCalcNextAfter (QDate &enddate, YearlyDayData &) const

Classes

struct  rMonthPos
 structure for Recurs rMonthlyPos More...

Detailed Description

This class represents a recurrence rule for a calendar incidence.

Definition at line 37 of file recurrence.h.


Member Enumeration Documentation

anonymous enum
 

enumeration for describing how an event recurs, if at all.

Definition at line 41 of file recurrence.h.

enum KCal::Recurrence::Feb29Type
 

Enumeration for specifying what date yearly recurrences of February 29th occur in non-leap years.

Definition at line 47 of file recurrence.h.


Member Function Documentation

QDateTime KCal::Recurrence::recurStart  )  const [inline]
 

Return the start of the recurrence.

Definition at line 70 of file recurrence.h.

void KCal::Recurrence::setRecurStart const QDateTime start  ) 
 

Set start of recurrence, as a date and time.

Referenced by KCal::ResourceKABC::doLoad(), KCal::Incidence::recurrence(), and KCal::Incidence::setDtStart().

void KCal::Recurrence::setRecurStart const QDate start  ) 
 

Set start of recurrence, as a date with no time.

Recurrence types which are sub-daily (e.g. rHourly) always have a time; the time is set to 00:00:00 in these cases.

void KCal::Recurrence::setFloats bool  f  ) 
 

Set whether the recurrence has no time, just a date.

Recurrence types which are sub-daily (e.g. rHourly) always have a time and cannot be set to float. N.B. This property is derived by default from the parent incidence, or according to whether a time is specified in setRecurStart().

bool KCal::Recurrence::doesFloat  )  const [inline]
 

Returns whether the recurrence has no time, just a date.

Definition at line 86 of file recurrence.h.

void KCal::Recurrence::setRecurReadOnly bool  readOnly  )  [inline]
 

Set if recurrence is read-only or can be changed.

Definition at line 89 of file recurrence.h.

Referenced by KCal::Incidence::recurrence(), and KCal::Incidence::setReadOnly().

bool KCal::Recurrence::recurReadOnly  )  const [inline]
 

Returns true if the recurrence is read-only, or false if it can be changed.

Definition at line 91 of file recurrence.h.

void KCal::Recurrence::setCompatVersion int  version = 0  ) 
 

Set the calendar file version for backwards compatibility.

Parameters:
version is the KOrganizer/libkcal version, e.g. 220 for KDE 2.2.0. Specify version = 0 to cancel compatibility mode.

ushort KCal::Recurrence::doesRecur  )  const
 

Returns the event's recurrence status.

See the enumeration at the top of this file for possible values.

Referenced by KCal::Incidence::doesRecur().

bool KCal::Recurrence::recursOnPure const QDate qd  )  const
 

Returns true if the date specified is one on which the event will recur.

Referenced by KCal::Incidence::recursOn().

bool KCal::Recurrence::recursAtPure const QDateTime  )  const
 

Returns true if the date/time specified is one at which the event will recur.

Times are rounded down to the nearest minute to determine the result.

Referenced by KCal::Incidence::recursAt().

void KCal::Recurrence::unsetRecurs  ) 
 

Turns off recurrence for the event.

Referenced by KCal::Calendar::dissociateOccurrence().

QValueList<QTime> KCal::Recurrence::recurTimesOn const QDate date  )  const
 

Returns a list of the times on the specified date at which the recurrence will occur.

Parameters:
date the date for which to find the recurrence times.

QDate KCal::Recurrence::getNextDate const QDate preDate,
bool *  last = 0
const
 

Returns the date of the next recurrence, after the specified date.

Parameters:
preDate the date after which to find the recurrence.
last if non-null, *last is set to true if the next recurrence is the last recurrence, else false. Reply = date of next recurrence, or invalid date if none.

QDateTime KCal::Recurrence::getNextDateTime const QDateTime preDateTime,
bool *  last = 0
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.

Parameters:
preDateTime the date/time after which to find the recurrence.
last if non-null, *last is set to true if the next recurrence is the last recurrence, else false. Reply = date/time of next recurrence, or invalid date if none.

QDate KCal::Recurrence::getPreviousDate const QDate afterDate,
bool *  last = 0
const
 

Returns the date of the last previous recurrence, before the specified date.

Parameters:
afterDate the date before which to find the recurrence.
last if non-null, *last is set to true if the previous recurrence is the last recurrence, else false. Reply = date of previous recurrence, or invalid date if none.

QDateTime KCal::Recurrence::getPreviousDateTime const QDateTime afterDateTime,
bool *  last = 0
const
 

Returns the date and time of the last previous recurrence, before the specified date/time.

If a time later than 00:00:00 is specified and the recurrence has no time, 00:00:00 on the specified date is returned if that date recurs.

Parameters:
afterDateTime the date/time before which to find the recurrence.
last if non-null, *last is set to true if the previous recurrence is the last recurrence, else false. Reply = date/time of previous recurrence, or invalid date if none.

int KCal::Recurrence::frequency  )  const
 

Returns frequency of recurrence, in terms of the recurrence time period type.

void KCal::Recurrence::setFrequency int  freq  ) 
 

Sets the frequency of recurrence, in terms of the recurrence time period type.

int KCal::Recurrence::duration  )  const
 

Returns -1 if the event recurs infinitely, 0 if the end date is set, otherwise the total number of recurrences, including the initial occurrence.

Referenced by KCal::Calendar::dissociateOccurrence().

void KCal::Recurrence::setDuration int  duration  ) 
 

Sets the total number of times the event is to occur, including both the first and last.

Referenced by KCal::Calendar::dissociateOccurrence().

int KCal::Recurrence::durationTo const QDate  )  const
 

Returns the number of recurrences up to and including the date specified.

Referenced by KCal::Calendar::dissociateOccurrence().

int KCal::Recurrence::durationTo const QDateTime  )  const
 

Returns the number of recurrences up to and including the date/time specified.

QDate KCal::Recurrence::endDate bool *  result = 0  )  const
 

Returns the date of the last recurrence.

An invalid date is returned if the recurrence has no end.

Parameters:
result if non-null, *result is updated to true if successful, or false if there is no recurrence.

QDateTime KCal::Recurrence::endDateTime bool *  result = 0  )  const
 

Returns the date and time of the last recurrence.

An invalid date is returned if the recurrence has no end.

Parameters:
result if non-null, *result is updated to true if successful, or false if there is no recurrence.

QString KCal::Recurrence::endDateStr bool  shortfmt = true  )  const
 

Returns a string representing the recurrence end date in the format according to the user's locale settings.

void KCal::Recurrence::setEndDate const QDate endDate  ) 
 

Sets the date of the last recurrence.

The end time is set to the recurrence start time.

Parameters:
endDate the ending date after which to stop recurring.

void KCal::Recurrence::setEndDateTime const QDateTime endDateTime  ) 
 

Sets the date and time of the last recurrence.

Parameters:
endDateTime the ending date/time after which to stop recurring.

void KCal::Recurrence::setMinutely int  _rFreq,
int  duration
 

Sets an event to recur minutely.

Parameters:
_rFreq the frequency to recur, e.g. 2 is every other minute
duration the number of times the event is to occur, or -1 to recur indefinitely.

void KCal::Recurrence::setMinutely int  _rFreq,
const QDateTime endDateTime
 

Sets an event to recur minutely.

Parameters:
_rFreq the frequency to recur, e.g. 2 is every other minute
endDateTime the ending date/time after which to stop recurring

void KCal::Recurrence::setHourly int  _rFreq,
int  duration
 

Sets an event to recur hourly.

Parameters:
_rFreq the frequency to recur, e.g. 2 is every other hour
duration the number of times the event is to occur, or -1 to recur indefinitely.

void KCal::Recurrence::setHourly int  _rFreq,
const QDateTime endDateTime
 

Sets an event to recur hourly.

Parameters:
_rFreq the frequency to recur, e.g. 2 is every other hour
endDateTime the ending date/time after which to stop recurring

void KCal::Recurrence::setDaily int  _rFreq,
int  duration
 

Sets an event to recur daily.

Parameters:
_rFreq the frequency to recur, e.g. 2 is every other day
duration the number of times the event is to occur, or -1 to recur indefinitely.

void KCal::Recurrence::setDaily int  _rFreq,
const QDate endDate
 

Sets an event to recur daily.

Parameters:
_rFreq the frequency to recur, e.g. 2 is every other day
endDate the ending date after which to stop recurring

void KCal::Recurrence::setWeekly int  _rFreq,
const QBitArray _rDays,
int  duration,
int  weekStart = 1
 

Sets an event to recur weekly.

Parameters:
_rFreq the frequency to recur, e.g. every other week etc.
_rDays a 7 bit array indicating which days on which to recur (bit 0 = Monday).
duration the number of times the event is to occur, or -1 to recur indefinitely.
weekStart the first day of the week (Monday=1 .. Sunday=7, default is Monday).

void KCal::Recurrence::setWeekly int  _rFreq,
const QBitArray _rDays,
const QDate endDate,
int  weekStart = 1
 

Sets an event to recur weekly.

Parameters:
_rFreq the frequency to recur, e.g. every other week etc.
_rDays a 7 bit array indicating which days on which to recur (bit 0 = Monday).
endDate the date on which to stop recurring.
weekStart the first day of the week (Monday=1 .. Sunday=7, default is Monday).

int KCal::Recurrence::weekStart  )  const [inline]
 

Returns the first day of the week.

Monday=1 .. Sunday=7.

Definition at line 237 of file recurrence.h.

const QBitArray& KCal::Recurrence::days  )  const
 

Returns week day mask (bit 0 = Monday).

void KCal::Recurrence::setMonthly short  type,
int  _rFreq,
int  duration
 

Sets an event to recur monthly.

Parameters:
type rMonthlyPos or rMonthlyDay
_rFreq the frequency to recur, e.g. 3 for every third month.
duration the number of times the event is to occur, or -1 to recur indefinitely.

void KCal::Recurrence::setMonthly short  type,
int  _rFreq,
const QDate endDate
 

same as above, but with ending date not number of recurrences

void KCal::Recurrence::addMonthlyPos short  _rPos,
const QBitArray _rDays
 

Adds a position to the recursMonthlyPos recurrence rule, if it is set.

Parameters:
_rPos the position in the month for the recurrence, with valid values being 1-5 (5 weeks max in a month).
_rDays the days for the position to recur on (bit 0 = Monday). Example: _rPos = 2, and bits 0 and 2 are set in _rDays: the rule is to repeat every 2nd Monday and Wednesday in the month.

void KCal::Recurrence::addMonthlyDay short  _rDay  ) 
 

Adds a position to the recursMonthlyDay list.

Parameters:
_rDay the date in the month to recur.

const QPtrList<rMonthPos>& KCal::Recurrence::monthPositions  )  const
 

Returns list of day positions in months.

const QPtrList<int>& KCal::Recurrence::monthDays  )  const
 

Returns list of day numbers of a month.

void KCal::Recurrence::setYearly int  type,
int  freq,
int  duration
 

Sets an event to recur yearly.

Parameters:
type rYearlyMonth, rYearlyPos or rYearlyDay
freq the frequency to recur, e.g. 3 for every third year.
duration the number of times the event is to occur, or -1 to recur indefinitely.

Referenced by KCal::ResourceKABC::doLoad().

void KCal::Recurrence::setYearly int  type,
int  freq,
const QDate endDate
 

Sets an event to recur yearly ending at endDate.

void KCal::Recurrence::setYearlyByDate Feb29Type  type,
int  freq,
int  duration
 

Sets an event to recur yearly on a set of months, on the same day of the month as the event start date.

The months must be specified by calling addYearlyNum().

Parameters:
type the way recurrences of February 29th are to be handled in non-leap years.
freq the frequency to recur, e.g. 3 for every third year.
duration the number of times the event is to occur, or -1 to recur indefinitely.

void KCal::Recurrence::setYearlyByDate Feb29Type  type,
int  freq,
const QDate endDate
 

Sets an event to recur yearly ending at endDate.

void KCal::Recurrence::setYearlyByDate int  day,
Feb29Type  type,
int  freq,
int  duration
 

Sets an event to recur yearly of a set of months, on the specified day of the month.

The months must be specified by calling addYearlyNum().

Parameters:
day the day of the month for the event
type the way recurrences of February 29th are to be handled in non-leap years.
freq the frequency to recur, e.g. 3 for every third year.
duration the number of times the event is to occur, or -1 to recur indefinitely.

void KCal::Recurrence::setYearlyByDate int  day,
Feb29Type  type,
int  freq,
const QDate endDate
 

Sets an event to recur yearly ending at endDate.

void KCal::Recurrence::addYearlyNum short  _rNum  ) 
 

Adds position of day or month in year.

N.B. for recursYearlyPos, addYearlyMonthPos() must also be called to add positions within the month.

Referenced by KCal::ResourceKABC::doLoad().

void KCal::Recurrence::addYearlyMonthPos short  _rPos,
const QBitArray _rDays
 

Adds a position to the recursYearlyPos recurrence rule, if it is set.

N.B. addYearlyNum() must also be called to add recurrence months. Parameters are the same as for addMonthlyPos().

const QPtrList<int>& KCal::Recurrence::yearNums  )  const
 

Returns positions of days or months in year.

const QPtrList<rMonthPos>& KCal::Recurrence::yearMonthPositions  )  const
 

Returns list of day positions in months, for a recursYearlyPos recurrence rule.

Feb29Type KCal::Recurrence::feb29YearlyType  )  const [inline]
 

Returns how yearly recurrences of February 29th are handled.

Definition at line 309 of file recurrence.h.

static void KCal::Recurrence::setFeb29YearlyTypeDefault Feb29Type  t  )  [inline, static]
 

Sets the default method for handling yearly recurrences of February 29th.

Definition at line 311 of file recurrence.h.

static Feb29Type KCal::Recurrence::setFeb29YearlyTypeDefault  )  [inline, static]
 

Returns the default method for handling yearly recurrences of February 29th.

Definition at line 313 of file recurrence.h.

int KCal::Recurrence::countMonthlyPosDays  )  const
 

Returns the number of days in the month which recur.

Reply = -1 if the number varies from month to month.

void KCal::Recurrence::getMonthlyPosDays QValueList< int > &  list,
int  daysInMonth,
int  startDayOfWeek
const
 

Returns the days in a specified month which recur, in numerical order.

Parameters:
list receives the list of days which recur
daysInMonth number of days in this month
startDayOfWeek day of week for the first day in this month.

bool KCal::Recurrence::getMonthlyDayDays QValueList< int > &  list,
int  daysInMonth
const
 

Returns the days in a specified month which recur, in numerical order.

Parameters:
list receives the list of days which recur
daysInMonth number of days in this month Reply = true if day numbers varies from month to month.

bool KCal::Recurrence::getYearlyMonthMonths int  day,
QValueList< int > &  list,
QValueList< int > &  leaplist
const
 

Get the months which recur, in numerical order, for both leap years and non-leap years.

N.B. If February 29th recurs on March 1st in non-leap years, February (not March) is included in the non-leap year month list.

Parameters:
day 
list receives the list of months which recur in non-leap years
leaplist receives the list of months which recur in leap years Reply = true if February 29th also recurs.

void KCal::Recurrence::dump  )  const
 

Debug output.


Member Data Documentation

const QDate KCal::Recurrence::MAX_DATE [static]
 

Upper date limit for recurrences.

Definition at line 344 of file recurrence.h.


The documentation for this class was generated from the following file:
KDE Logo
This file is part of the documentation for libkcal Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Aug 23 18:18:56 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003