summaryrefslogtreecommitdiffabout
path: root/libkcal/recurrence.cpp
Side-by-side diff
Diffstat (limited to 'libkcal/recurrence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/recurrence.cpp187
1 files changed, 95 insertions, 92 deletions
diff --git a/libkcal/recurrence.cpp b/libkcal/recurrence.cpp
index 6ee5499..9a4e540 100644
--- a/libkcal/recurrence.cpp
+++ b/libkcal/recurrence.cpp
@@ -20,24 +20,27 @@
Boston, MA 02111-1307, USA.
*/
#include <limits.h>
#include <kdebug.h>
#include <kglobal.h>
#include <klocale.h>
#include "incidence.h"
#include "recurrence.h"
+//Added by qt3to4:
+#include <Q3ValueList>
+#include <Q3PtrList>
using namespace KCal;
Recurrence::Feb29Type Recurrence::mFeb29YearlyDefaultType = Recurrence::rMar1;
Recurrence::Recurrence(Incidence *parent, int compatVersion)
: recurs(rNone), // by default, it's not a recurring event
rWeekStart(1), // default is Monday
rDays(7),
mFloats(parent ? parent->doesFloat() : false),
mRecurReadOnly(false),
@@ -47,51 +50,51 @@ Recurrence::Recurrence(Incidence *parent, int compatVersion)
mCompatRecurs(rNone),
mCompatDuration(0),
mParent(parent)
{
rMonthDays.setAutoDelete( true );
rMonthPositions.setAutoDelete( true );
rYearNums.setAutoDelete( true );
}
Recurrence::Recurrence(const Recurrence &r, Incidence *parent)
: recurs(r.recurs),
rWeekStart(r.rWeekStart),
- rDays(r.rDays.copy()),
+ rDays(r.rDays),
rFreq(r.rFreq),
rDuration(r.rDuration),
rEndDateTime(r.rEndDateTime),
mRecurStart(r.mRecurStart),
mFloats(r.mFloats),
mRecurReadOnly(r.mRecurReadOnly),
mRecurExDatesCount(r.mRecurExDatesCount),
mFeb29YearlyType(r.mFeb29YearlyType),
mCompatVersion(r.mCompatVersion),
mCompatRecurs(r.mCompatRecurs),
mCompatDuration(r.mCompatDuration),
mParent(parent)
{
- for (QPtrListIterator<rMonthPos> mp(r.rMonthPositions); mp.current(); ++mp) {
+ for (Q3PtrListIterator<rMonthPos> mp(r.rMonthPositions); mp.current(); ++mp) {
rMonthPos *tmp = new rMonthPos;
tmp->rPos = mp.current()->rPos;
tmp->negative = mp.current()->negative;
- tmp->rDays = mp.current()->rDays.copy();
+ tmp->rDays = mp.current()->rDays;
rMonthPositions.append(tmp);
}
- for (QPtrListIterator<int> md(r.rMonthDays); md.current(); ++md) {
+ for (Q3PtrListIterator<int> md(r.rMonthDays); md.current(); ++md) {
int *tmp = new int;
*tmp = *md.current();
rMonthDays.append(tmp);
}
- for (QPtrListIterator<int> yn(r.rYearNums); yn.current(); ++yn) {
+ for (Q3PtrListIterator<int> yn(r.rYearNums); yn.current(); ++yn) {
int *tmp = new int;
*tmp = *yn.current();
rYearNums.append(tmp);
}
rMonthDays.setAutoDelete( true );
rMonthPositions.setAutoDelete( true );
rYearNums.setAutoDelete( true );
}
Recurrence::~Recurrence()
{
}
@@ -115,64 +118,64 @@ bool Recurrence::operator==( const Recurrence& r2 ) const
|| mFloats != r2.mFloats
|| mRecurReadOnly != r2.mRecurReadOnly
|| mRecurExDatesCount != r2.mRecurExDatesCount )
return false;
// no need to compare mCompat* and mParent
// OK to compare the pointers
switch ( recurs )
{
case rWeekly:
return rDays == r2.rDays
&& rWeekStart == r2.rWeekStart;
case rMonthlyPos: {
- QPtrList<rMonthPos> MonthPositions = rMonthPositions;
- QPtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions;
+ Q3PtrList<rMonthPos> MonthPositions = rMonthPositions;
+ Q3PtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions;
if ( !MonthPositions.count() )
return false;
if ( !MonthPositions2.count() )
return false;
return MonthPositions.first()->rPos == MonthPositions2.first()->rPos;
}
case rMonthlyDay: {
- QPtrList<int> MonthDays = rMonthDays ;
- QPtrList<int> MonthDays2 = r2.rMonthDays ;
+ Q3PtrList<int> MonthDays = rMonthDays ;
+ Q3PtrList<int> MonthDays2 = r2.rMonthDays ;
if ( !MonthDays.count() )
return false;
if ( !MonthDays2.count() )
return false;
return *MonthDays.first() == *MonthDays2.first() ;
}
case rYearlyPos: {
- QPtrList<int> YearNums = rYearNums;
- QPtrList<int> YearNums2 = r2.rYearNums;
+ Q3PtrList<int> YearNums = rYearNums;
+ Q3PtrList<int> YearNums2 = r2.rYearNums;
if ( *YearNums.first() != *YearNums2.first() )
return false;
- QPtrList<rMonthPos> MonthPositions = rMonthPositions;
- QPtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions;
+ Q3PtrList<rMonthPos> MonthPositions = rMonthPositions;
+ Q3PtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions;
if ( !MonthPositions.count() )
return false;
if ( !MonthPositions2.count() )
return false;
return MonthPositions.first()->rPos == MonthPositions2.first()->rPos;
}
case rYearlyMonth: {
- QPtrList<int> YearNums = rYearNums;
- QPtrList<int> YearNums2 = r2.rYearNums;
+ Q3PtrList<int> YearNums = rYearNums;
+ Q3PtrList<int> YearNums2 = r2.rYearNums;
return ( *YearNums.first() == *YearNums2.first() && mFeb29YearlyType == r2.mFeb29YearlyType);
}
case rYearlyDay: {
- QPtrList<int> YearNums = rYearNums;
- QPtrList<int> YearNums2 = r2.rYearNums;
+ Q3PtrList<int> YearNums = rYearNums;
+ Q3PtrList<int> YearNums2 = r2.rYearNums;
return ( *YearNums.first() == *YearNums2.first() );
}
case rNone:
case rMinutely:
case rHourly:
case rDaily:
default:
return true;
}
}
/*
bool Recurrence::compareLists( const QPtrList<int> &l1 ,const QPtrList<int> &l2)
@@ -348,25 +351,25 @@ QDateTime Recurrence::endDateTime() const
if (rDuration == 0)
return rEndDateTime;
// The end date is determined by the recurrence count
QDate dStart = mRecurStart.date();
switch (recurs)
{
case rMinutely:
return mRecurStart.addSecs((rDuration-1+mRecurExDatesCount)*rFreq*60);
case rHourly:
return mRecurStart.addSecs((rDuration-1+mRecurExDatesCount)*rFreq*3600);
case rDaily:
- return dStart.addDays((rDuration-1+mRecurExDatesCount)*rFreq);
+ return (QDateTime)dStart.addDays((rDuration-1+mRecurExDatesCount)*rFreq);
case rWeekly:
count = weeklyCalc(END_DATE_AND_COUNT, end);
break;
case rMonthlyPos:
case rMonthlyDay:
count = monthlyCalc(END_DATE_AND_COUNT, end);
break;
case rYearlyMonth:
count = yearlyMonthCalc(END_DATE_AND_COUNT, end);
break;
case rYearlyDay:
@@ -497,35 +500,35 @@ void Recurrence::setDuration(int _rDuration)
}
QString Recurrence::endDateStr(bool shortfmt) const
{
return KGlobal::locale()->formatDate(rEndDateTime.date(),shortfmt);
}
const QBitArray &Recurrence::days() const
{
return rDays;
}
-const QPtrList<Recurrence::rMonthPos> &Recurrence::monthPositions() const
+const Q3PtrList<Recurrence::rMonthPos> &Recurrence::monthPositions() const
{
return rMonthPositions;
}
-const QPtrList<Recurrence::rMonthPos> &Recurrence::yearMonthPositions() const
+const Q3PtrList<Recurrence::rMonthPos> &Recurrence::yearMonthPositions() const
{
return rMonthPositions;
}
-const QPtrList<int> &Recurrence::monthDays() const
+const Q3PtrList<int> &Recurrence::monthDays() const
{
return rMonthDays;
}
void Recurrence::setMinutely(int _rFreq, int _rDuration)
{
if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1)
return;
setDailySub(rMinutely, _rFreq, _rDuration);
}
void Recurrence::setMinutely(int _rFreq, const QDateTime &_rEndDateTime)
@@ -750,25 +753,25 @@ void Recurrence::setYearlyByDate(Feb29Type type, int _rFreq, const QDate &_rEndD
rEndDateTime.setDate(_rEndDate);
rEndDateTime.setTime(mRecurStart.time());
mCompatDuration = 0;
setYearly_(rYearlyMonth, type, _rFreq, 0);
}
void Recurrence::addYearlyMonthPos(short _rPos, const QBitArray &_rDays)
{
if (recurs == rYearlyPos)
addMonthlyPos_(_rPos, _rDays);
}
-const QPtrList<int> &Recurrence::yearNums() const
+const Q3PtrList<int> &Recurrence::yearNums() const
{
return rYearNums;
}
void Recurrence::addYearlyMonth(short _rPos )
{
if (mRecurReadOnly || recurs != rYearlyMonth) // invalid day/month number
return;
rMonthPos *tmpPos = new rMonthPos;
if ( _rPos > 0) {
tmpPos->rPos = _rPos;
tmpPos->negative = false;
} else {
@@ -1038,31 +1041,31 @@ bool Recurrence::recursMonthly(const QDate &qd) const
int month = qd.month();
int day = qd.day();
// calculate how many months ahead this date is from the original
// event's date
int monthsAhead = (year - dStart.year()) * 12 + (month - dStart.month());
if ((monthsAhead % rFreq) == 0) {
// The date is in a month which recurs
if (qd >= dStart
&& ((rDuration > 0 && qd <= endDate()) ||
(rDuration == 0 && qd <= rEndDateTime.date()) ||
rDuration == -1)) {
// The date queried falls within the range of the event.
- QValueList<int> days;
+ Q3ValueList<int> days;
int daysInMonth = qd.daysInMonth();
if (recurs == rMonthlyDay)
getMonthlyDayDays(days, daysInMonth);
else if (recurs == rMonthlyPos)
getMonthlyPosDays(days, daysInMonth, QDate(year, month, 1).dayOfWeek());
- for (QValueList<int>::Iterator it = days.begin(); it != days.end(); ++it) {
+ for (Q3ValueList<int>::Iterator it = days.begin(); it != days.end(); ++it) {
if (*it == day)
return true;
}
// no dates matched
}
}
return false;
}
bool Recurrence::recursYearlyByMonth(const QDate &qd) const
{
QDate dStart = mRecurStart.date();
@@ -1092,25 +1095,25 @@ bool Recurrence::recursYearlyByMonth(const QDate &qd) const
if (match) {
// The day of the month matches. Calculate how many years ahead
// this date is from the original event's date.
int yearsAhead = (qyear - dStart.year());
if (yearsAhead % rFreq == 0) {
// The date is in a year which recurs
if (qd >= dStart
&& ((rDuration > 0 && qd <= endDate()) ||
(rDuration == 0 && qd <= rEndDateTime.date()) ||
rDuration == -1)) {
// The date queried falls within the range of the event.
int i = qmonth;
- for (QPtrListIterator<int> qlin(rYearNums); qlin.current(); ++qlin) {
+ for (Q3PtrListIterator<int> qlin(rYearNums); qlin.current(); ++qlin) {
if (i == *qlin.current())
return true;
}
}
}
}
return false;
}
bool Recurrence::recursYearlyByPos(const QDate &qd) const
{
QDate dStart = mRecurStart.date();
@@ -1118,55 +1121,55 @@ bool Recurrence::recursYearlyByPos(const QDate &qd) const
int month = qd.month();
int day = qd.day();
// calculate how many years ahead this date is from the original
// event's date
int yearsAhead = (year - dStart.year());
if (yearsAhead % rFreq == 0) {
// The date is in a year which recurs
if (qd >= dStart
&& ((rDuration > 0 && qd <= endDate()) ||
(rDuration == 0 && qd <= rEndDateTime.date()) ||
rDuration == -1)) {
// The date queried falls within the range of the event.
- for (QPtrListIterator<int> qlin(rYearNums); qlin.current(); ++qlin) {
+ for (Q3PtrListIterator<int> qlin(rYearNums); qlin.current(); ++qlin) {
if (month == *qlin.current()) {
// The month recurs
- QValueList<int> days;
+ Q3ValueList<int> days;
getMonthlyPosDays(days, qd.daysInMonth(), QDate(year, month, 1).dayOfWeek());
- for (QValueList<int>::Iterator it = days.begin(); it != days.end(); ++it) {
+ for (Q3ValueList<int>::Iterator it = days.begin(); it != days.end(); ++it) {
if (*it == day)
return true;
}
}
}
}
}
return false;
}
bool Recurrence::recursYearlyByDay(const QDate &qd) const
{
QDate dStart = mRecurStart.date();
// calculate how many years ahead this date is from the original
// event's date
int yearsAhead = (qd.year() - dStart.year());
if (yearsAhead % rFreq == 0) {
// The date is in a year which recurs
if (qd >= dStart
&& ((rDuration > 0 && qd <= endDate()) ||
(rDuration == 0 && qd <= rEndDateTime.date()) ||
rDuration == -1)) {
// The date queried falls within the range of the event.
int i = qd.dayOfYear();
- for (QPtrListIterator<int> qlin(rYearNums); qlin.current(); ++qlin) {
+ for (Q3PtrListIterator<int> qlin(rYearNums); qlin.current(); ++qlin) {
if (i == *qlin.current())
return true;
}
}
}
return false;
}
/* Get the date of the next recurrence, after the specified date.
* If 'last' is 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.
@@ -1540,25 +1543,25 @@ int Recurrence::recurCalc(PeriodFunc func, QDate &enddate) const
break;
case rYearlyDay:
count = yearlyDayCalc(func, enddate);
break;
default:
break;
}
switch (func) {
case END_DATE_AND_COUNT:
case NEXT_AFTER_DATE:
if (count == 0)
- endtime = QDate();
+ endtime = QDateTime();
else if (timed)
enddate = endtime.date();
break;
case COUNT_TO_DATE:
break;
}
return count;
}
/* Find count and, depending on 'func', the end date/time of a secondly recurrence.
* Reply = total number of occurrences up to 'endtime', or 0 if error.
* If 'func' = END_DATE_AND_COUNT or NEXT_AFTER_DATE, 'endtime' is updated to the
@@ -1784,42 +1787,42 @@ ex:
/* Find count and, depending on 'func', the end date of a monthly recurrence.
* Reply = total number of occurrences up to 'enddate', or 0 if error.
* If 'func' = END_DATE_AND_COUNT or NEXT_AFTER_DATE, 'enddate' is updated to the
* recurrence end date.
*/
struct Recurrence::MonthlyData {
const Recurrence *recurrence;
int year; // current year
int month; // current month 0..11
int day; // current day of month 1..31
bool varies; // true if recurring days vary between different months
private:
- QValueList<int> days28, days29, days30, days31; // recurring days in months of each length
- QValueList<int> *recurDays[4];
+ Q3ValueList<int> days28, days29, days30, days31; // recurring days in months of each length
+ Q3ValueList<int> *recurDays[4];
public:
MonthlyData(const Recurrence* r, const QDate &date)
: recurrence(r), year(date.year()), month(date.month()-1), day(date.day())
{ recurDays[0] = &days28;
recurDays[1] = &days29;
recurDays[2] = &days30;
recurDays[3] = &days31;
varies = (recurrence->recurs == rMonthlyPos)
? true : recurrence->getMonthlyDayDays(days31, 31);
}
- const QValueList<int>* dayList() const {
+ const Q3ValueList<int>* dayList() const {
if (!varies)
return &days31;
QDate startOfMonth(year, month + 1, 1);
int daysInMonth = startOfMonth.daysInMonth();
- QValueList<int>* days = recurDays[daysInMonth - 28];
+ Q3ValueList<int>* days = recurDays[daysInMonth - 28];
if (recurrence->recurs == rMonthlyPos)
recurrence->getMonthlyPosDays(*days, daysInMonth, startOfMonth.dayOfWeek());
else if (days->isEmpty())
recurrence->getMonthlyDayDays(*days, daysInMonth);
return days;
}
int yearMonth() const { return year*12 + month; }
void addMonths(int diff) { month += diff; year += month / 12; month %= 12; }
QDate date() const { return QDate(year, month + 1, day); }
};
int Recurrence::monthlyCalc(PeriodFunc func, QDate &enddate) const
@@ -1835,26 +1838,26 @@ int Recurrence::monthlyCalc(PeriodFunc func, QDate &enddate) const
case COUNT_TO_DATE:
return monthlyCalcToDate(enddate, data);
case NEXT_AFTER_DATE:
return monthlyCalcNextAfter(enddate, data);
}
return 0;
}
int Recurrence::monthlyCalcEndDate(QDate &enddate, MonthlyData &data) const
{
uint countTogo = rDuration + mRecurExDatesCount;
int countGone = 0;
- QValueList<int>::ConstIterator it;
- const QValueList<int>* days = data.dayList();
+ Q3ValueList<int>::ConstIterator it;
+ const Q3ValueList<int>* days = data.dayList();
if (data.day > 1) {
// Check what remains of the start month
for (it = days->begin(); it != days->end(); ++it) {
if (*it >= data.day) {
++countGone;
if (--countTogo == 0) {
data.day = *it;
break;
}
}
}
@@ -1901,26 +1904,26 @@ int Recurrence::monthlyCalcEndDate(QDate &enddate, MonthlyData &data) const
enddate = data.date();
return countGone;
}
int Recurrence::monthlyCalcToDate(const QDate &enddate, MonthlyData &data) const
{
int countGone = 0;
int countMax = (rDuration > 0) ? rDuration + mRecurExDatesCount : INT_MAX;
int endYear = enddate.year();
int endMonth = enddate.month() - 1; // zero-based
int endDay = enddate.day();
int endYearMonth = endYear*12 + endMonth;
- QValueList<int>::ConstIterator it;
- const QValueList<int>* days = data.dayList();
+ Q3ValueList<int>::ConstIterator it;
+ const Q3ValueList<int>* days = data.dayList();
if (data.day > 1) {
// Check what remains of the start month
for (it = days->begin(); it != days->end(); ++it) {
if (*it >= data.day) {
if (data.yearMonth() == endYearMonth && *it > endDay)
return countGone;
if (++countGone >= countMax)
return countMax;
}
}
data.day = 1;
@@ -1960,26 +1963,26 @@ int Recurrence::monthlyCalcToDate(const QDate &enddate, MonthlyData &data) const
return countMax;
}
return countGone;
}
int Recurrence::monthlyCalcNextAfter(QDate &enddate, MonthlyData &data) const
{
uint countTogo = (rDuration > 0) ? rDuration + mRecurExDatesCount : UINT_MAX;
int countGone = 0;
int endYear = enddate.year();
int endDay = enddate.day();
int endYearMonth = endYear*12 + enddate.month() - 1;
- QValueList<int>::ConstIterator it;
- const QValueList<int>* days = data.dayList();
+ Q3ValueList<int>::ConstIterator it;
+ const Q3ValueList<int>* days = data.dayList();
if (data.day > 1) {
// Check what remains of the start month
for (it = days->begin(); it != days->end(); ++it) {
if (*it >= data.day) {
++countGone;
if (data.yearMonth() == endYearMonth && *it > endDay) {
data.day = *it;
goto ex;
}
if (--countTogo == 0)
return 0;
@@ -2043,35 +2046,35 @@ ex:
* Reply = total number of occurrences up to 'enddate', or 0 if error.
* If 'func' = END_DATE_AND_COUNT or NEXT_AFTER_DATE, 'enddate' is updated to the
* recurrence end date.
*/
struct Recurrence::YearlyMonthData {
const Recurrence *recurrence;
int year; // current year
int month; // current month 1..12
int day; // current day of month 1..31
bool leapyear; // true if February 29th recurs and current year is a leap year
bool feb29; // true if February 29th recurs
private:
- QValueList<int> months; // recurring months in non-leap years 1..12
- QValueList<int> leapMonths; // recurring months in leap years 1..12
+ Q3ValueList<int> months; // recurring months in non-leap years 1..12
+ Q3ValueList<int> leapMonths; // recurring months in leap years 1..12
public:
YearlyMonthData(const Recurrence* r, const QDate &date)
: recurrence(r), year(date.year()), month(date.month()), day(date.day())
{ feb29 = recurrence->getYearlyMonthMonths(day, months, leapMonths);
leapyear = feb29 && QDate::leapYear(year);
}
- const QValueList<int>* monthList() const
+ const Q3ValueList<int>* monthList() const
{ return leapyear ? &leapMonths : &months; }
- const QValueList<int>* leapMonthList() const { return &leapMonths; }
+ const Q3ValueList<int>* leapMonthList() const { return &leapMonths; }
QDate date() const { return QDate(year, month, day); }
};
int Recurrence::yearlyMonthCalc(PeriodFunc func, QDate &enddate) const
{
if (rYearNums.isEmpty())
return 0;
YearlyMonthData data(this, mRecurStart.date());
switch (func) {
case END_DATE_AND_COUNT:
return yearlyMonthCalcEndDate(enddate, data);
case COUNT_TO_DATE:
@@ -2079,26 +2082,26 @@ int Recurrence::yearlyMonthCalc(PeriodFunc func, QDate &enddate) const
case NEXT_AFTER_DATE:
return yearlyMonthCalcNextAfter(enddate, data);
}
return 0;
}
// Find total count and end date of an annual recurrence by date.
// Reply = total number of occurrences.
int Recurrence::yearlyMonthCalcEndDate(QDate &enddate, YearlyMonthData &data) const
{
uint countTogo = rDuration + mRecurExDatesCount;
int countGone = 0;
- QValueList<int>::ConstIterator it;
- const QValueList<int>* mons = data.monthList(); // get recurring months for this year
+ Q3ValueList<int>::ConstIterator it;
+ const Q3ValueList<int>* mons = data.monthList(); // get recurring months for this year
if (data.month > 1) {
// Check what remains of the start year
for (it = mons->begin(); it != mons->end(); ++it) {
if (*it >= data.month) {
++countGone;
if (--countTogo == 0) {
data.month = *it;
if (data.month == 2 && data.feb29 && !data.leapyear) {
// The recurrence should end on February 29th, but it's a non-leap year
switch (mFeb29YearlyType) {
case rFeb28:
@@ -2190,26 +2193,26 @@ int Recurrence::yearlyMonthCalcToDate(const QDate &enddate, YearlyMonthData &dat
* if enddate is Feb 28th on a non-leap year.
* 2) it recurs on Mar 1st in non-leap years, allow the end month to be
* adjusted to February, to simplify calculations.
*/
if (data.feb29 && !QDate::leapYear(endYear)
&& mFeb29YearlyType == rFeb28 && endDay == 28 && endMonth == 2) {
}
else if (--endMonth == 0) {
endMonth = 12;
--endYear;
}
}
- QValueList<int>::ConstIterator it;
- const QValueList<int>* mons = data.monthList();
+ Q3ValueList<int>::ConstIterator it;
+ const Q3ValueList<int>* mons = data.monthList();
if (data.month > 1) {
// Check what remains of the start year
for (it = mons->begin(); it != mons->end(); ++it) {
if (*it >= data.month) {
if (data.year == endYear && *it > endMonth)
return countGone;
if (++countGone >= countMax)
return countMax;
}
}
data.month = 1;
@@ -2261,26 +2264,26 @@ int Recurrence::yearlyMonthCalcNextAfter(QDate &enddate, YearlyMonthData &data)
bool mar1TooEarly = false;
bool feb28ok = false;
if (endDay < data.day) {
if (data.feb29 && mFeb29YearlyType == rMar1 && endMonth == 3)
mar1TooEarly = true;
if (data.feb29 && mFeb29YearlyType == rFeb28 && endMonth == 2 && endDay == 28)
feb28ok = true;
else if (--endMonth == 0) {
endMonth = 12;
--endYear;
}
}
- QValueList<int>::ConstIterator it;
- const QValueList<int>* mons = data.monthList();
+ Q3ValueList<int>::ConstIterator it;
+ const Q3ValueList<int>* mons = data.monthList();
if (data.month > 1) {
// Check what remains of the start year
for (it = mons->begin(); it != mons->end(); ++it) {
if (*it >= data.month) {
++countGone;
if (data.year == endYear
&& ( *it > endMonth && (*it > 3 || !mar1TooEarly)
|| *it == 2 && feb28ok && data.leapyear)) {
if (*it == 2 && data.feb29 && !data.leapyear) {
// The next recurrence should be on February 29th, but it's a non-leap year
switch (mFeb29YearlyType) {
@@ -2381,33 +2384,33 @@ ex:
* If 'func' = END_DATE_AND_COUNT or NEXT_AFTER_DATE, 'enddate' is updated to the
* recurrence end date.
*/
struct Recurrence::YearlyPosData {
const Recurrence *recurrence;
int year; // current year
int month; // current month 1..12
int day; // current day of month 1..31
int daysPerMonth; // number of days which recur each month, or -1 if variable
int count; // number of days which recur each year, or -1 if variable
bool varies; // true if number of days varies from year to year
private:
- mutable QValueList<int> days;
+ mutable Q3ValueList<int> days;
public:
YearlyPosData(const Recurrence* r, const QDate &date)
: recurrence(r), year(date.year()), month(date.month()), day(date.day()), count(-1)
{ if ((daysPerMonth = r->countMonthlyPosDays()) > 0)
count = daysPerMonth * r->rYearNums.count();
varies = (daysPerMonth < 0);
}
- const QValueList<int>* dayList() const {
+ const Q3ValueList<int>* dayList() const {
QDate startOfMonth(year, month, 1);
recurrence->getMonthlyPosDays(days, startOfMonth.daysInMonth(), startOfMonth.dayOfWeek());
return &days;
}
int yearMonth() const { return year*12 + month - 1; }
void addMonths(int diff) { month += diff - 1; year += month / 12; month = month % 12 + 1; }
QDate date() const { return QDate(year, month, day); }
};
int Recurrence::yearlyPosCalc(PeriodFunc func, QDate &enddate) const
{
if (rYearNums.isEmpty() || rMonthPositions.isEmpty())
@@ -2419,30 +2422,30 @@ int Recurrence::yearlyPosCalc(PeriodFunc func, QDate &enddate) const
case COUNT_TO_DATE:
return yearlyPosCalcToDate(enddate, data);
case NEXT_AFTER_DATE:
return yearlyPosCalcNextAfter(enddate, data);
}
return 0;
}
int Recurrence::yearlyPosCalcEndDate(QDate &enddate, YearlyPosData &data) const
{
uint countTogo = rDuration + mRecurExDatesCount;
int countGone = 0;
- QValueList<int>::ConstIterator id;
- const QValueList<int>* days;
+ Q3ValueList<int>::ConstIterator id;
+ const Q3ValueList<int>* days;
if (data.month > 1 || data.day > 1) {
// Check what remains of the start year
- for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) {
+ for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
if (*im.current() >= data.month) {
// Check what remains of the start month
if (data.day > 1 || data.varies
|| static_cast<uint>(data.daysPerMonth) >= countTogo) {
data.month = *im.current();
days = data.dayList();
for (id = days->begin(); id != days->end(); ++id) {
if (*id >= data.day) {
++countGone;
if (--countTogo == 0) {
data.month = *im.current();
data.day = *id;
@@ -2457,25 +2460,25 @@ int Recurrence::yearlyPosCalcEndDate(QDate &enddate, YearlyPosData &data) const
countTogo -= data.daysPerMonth;
countGone += data.daysPerMonth;
}
}
}
data.month = 1;
data.year += rFreq;
}
if (data.varies) {
// The number of recurrences varies from year to year.
for ( ; ; ) {
- for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) {
+ for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
data.month = *im.current();
days = data.dayList();
int n = days->count();
if (static_cast<uint>(n) >= countTogo) {
// Check the last month in the recurrence
for (id = days->begin(); id != days->end(); ++id) {
++countGone;
if (--countTogo == 0) {
data.day = *id;
goto ex;
}
}
@@ -2487,25 +2490,25 @@ int Recurrence::yearlyPosCalcEndDate(QDate &enddate, YearlyPosData &data) const
}
} else {
// The number of recurrences is the same every year,
// so skip the year-by-year check.
// Skip the remaining whole years, but leave at least
// 1 recurrence remaining, in order to get its date.
int wholeYears = (countTogo - 1) / data.count;
data.year += wholeYears * rFreq;
countGone += wholeYears * data.count;
countTogo -= wholeYears * data.count;
// Check the last year in the recurrence.
- for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) {
+ for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
if (static_cast<uint>(data.daysPerMonth) >= countTogo) {
// Check the last month in the recurrence
data.month = *im.current();
days = data.dayList();
for (id = days->begin(); id != days->end(); ++id) {
++countGone;
if (--countTogo == 0) {
data.day = *id;
goto ex;
}
}
}
@@ -2522,30 +2525,30 @@ ex:
int Recurrence::yearlyPosCalcToDate(const QDate &enddate, YearlyPosData &data) const
{
int countGone = 0;
int countMax = (rDuration > 0) ? rDuration + mRecurExDatesCount : INT_MAX;
int endYear = enddate.year();
int endMonth = enddate.month();
int endDay = enddate.day();
if (endDay < data.day && --endMonth == 0) {
endMonth = 12;
--endYear;
}
int endYearMonth = endYear*12 + endMonth;
- QValueList<int>::ConstIterator id;
- const QValueList<int>* days;
+ Q3ValueList<int>::ConstIterator id;
+ const Q3ValueList<int>* days;
if (data.month > 1 || data.day > 1) {
// Check what remains of the start year
- for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) {
+ for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
if (*im.current() >= data.month) {
data.month = *im.current();
if (data.yearMonth() > endYearMonth)
return countGone;
// Check what remains of the start month
bool lastMonth = (data.yearMonth() == endYearMonth);
if (lastMonth || data.day > 1 || data.varies) {
days = data.dayList();
if (lastMonth || data.day > 1) {
for (id = days->begin(); id != days->end(); ++id) {
if (*id >= data.day) {
if (lastMonth && *id > endDay)
@@ -2567,25 +2570,25 @@ int Recurrence::yearlyPosCalcToDate(const QDate &enddate, YearlyPosData &data) c
if (countGone >= countMax)
return countMax;
}
}
}
data.month = 1;
data.year += rFreq;
}
if (data.varies) {
// The number of recurrences varies from year to year.
for ( ; ; ) {
- for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) {
+ for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
data.month = *im.current();
days = data.dayList();
if (data.yearMonth() >= endYearMonth) {
if (data.yearMonth() > endYearMonth)
return countGone;
// Check the last month in the recurrence
for (id = days->begin(); id != days->end(); ++id) {
if (*id > endDay)
return countGone;
if (++countGone >= countMax)
return countMax;
}
@@ -2602,25 +2605,25 @@ int Recurrence::yearlyPosCalcToDate(const QDate &enddate, YearlyPosData &data) c
// so skip the year-by-year check.
// Skip the remaining whole years, but leave at least
// 1 recurrence remaining, in order to get its date.
int wholeYears = endYear - data.year;
countGone += (wholeYears / rFreq) * data.count;
if (countGone >= countMax)
return countMax;
if (wholeYears % rFreq)
return countGone; // end year isn't a recurrence year
data.year = endYear;
// Check the last year in the recurrence.
- for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) {
+ for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
data.month = *im.current();
if (data.month >= endMonth) {
if (data.month > endMonth)
return countGone;
// Check the last month in the recurrence
days = data.dayList();
for (id = days->begin(); id != days->end(); ++id) {
if (*id > endDay)
return countGone;
if (++countGone >= countMax)
return countMax;
}
@@ -2637,32 +2640,32 @@ int Recurrence::yearlyPosCalcToDate(const QDate &enddate, YearlyPosData &data) c
int Recurrence::yearlyPosCalcNextAfter(QDate &enddate, YearlyPosData &data) const
{
uint countTogo = (rDuration > 0) ? rDuration + mRecurExDatesCount : UINT_MAX;
int countGone = 0;
int endYear = enddate.year();
int endMonth = enddate.month();
int endDay = enddate.day();
if (endDay < data.day && --endMonth == 0) {
endMonth = 12;
--endYear;
}
int endYearMonth = endYear*12 + endMonth;
- QValueList<int>::ConstIterator id;
- const QValueList<int>* days;
+ Q3ValueList<int>::ConstIterator id;
+ const Q3ValueList<int>* days;
if (data.varies) {
// The number of recurrences varies from year to year.
for ( ; ; ) {
// Check the next year
- for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) {
+ for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
if (*im.current() >= data.month) {
// Check the next month
data.month = *im.current();
int ended = data.yearMonth() - endYearMonth;
days = data.dayList();
if (ended >= 0 || data.day > 1) {
// This is the start or end month, so check each day
for (id = days->begin(); id != days->end(); ++id) {
if (*id >= data.day) {
++countGone;
if (ended > 0 || (ended == 0 && *id > endDay)) {
data.day = *id;
@@ -2680,25 +2683,25 @@ int Recurrence::yearlyPosCalcNextAfter(QDate &enddate, YearlyPosData &data) cons
countGone += n;
}
data.day = 1; // we've checked the start month now
}
}
data.month = 1; // we've checked the start year now
data.year += rFreq;
}
} else {
// The number of recurrences is the same every year.
if (data.month > 1 || data.day > 1) {
// Check what remains of the start year
- for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) {
+ for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
if (*im.current() >= data.month) {
// Check what remains of the start month
data.month = *im.current();
int ended = data.yearMonth() - endYearMonth;
if (ended >= 0 || data.day > 1) {
// This is the start or end month, so check each day
days = data.dayList();
for (id = days->begin(); id != days->end(); ++id) {
if (*id >= data.day) {
++countGone;
if (ended > 0 || (ended == 0 && *id > endDay)) {
data.day = *id;
@@ -2725,25 +2728,25 @@ int Recurrence::yearlyPosCalcNextAfter(QDate &enddate, YearlyPosData &data) cons
&& *rYearNums.getLast() <= endMonth)
++recurYears; // required year is after endYear
if (recurYears) {
int n = recurYears * data.count;
if (static_cast<uint>(n) > countTogo)
return 0; // reached end of recurrence
countTogo -= n;
countGone += n;
data.year += recurYears * rFreq;
}
// Check the last year in the recurrence
- for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) {
+ for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
data.month = *im.current();
int ended = data.yearMonth() - endYearMonth;
if (ended >= 0) {
// This is the end month, so check each day
days = data.dayList();
for (id = days->begin(); id != days->end(); ++id) {
++countGone;
if (ended > 0 || (ended == 0 && *id > endDay)) {
data.day = *id;
goto ex;
}
if (--countTogo == 0)
@@ -2799,25 +2802,25 @@ int Recurrence::yearlyDayCalc(PeriodFunc func, QDate &enddate) const
}
return 0;
}
int Recurrence::yearlyDayCalcEndDate(QDate &enddate, YearlyDayData &data) const
{
uint countTogo = rDuration + mRecurExDatesCount;
int countGone = 0;
if (data.day > 1) {
// Check what remains of the start year
bool leapOK = data.isMaxDayCount();
- for (QPtrListIterator<int> it(rYearNums); it.current(); ++it) {
+ for (Q3PtrListIterator<int> it(rYearNums); it.current(); ++it) {
int d = *it.current();
if (d >= data.day && (leapOK || d < 366)) {
++countGone;
if (--countTogo == 0) {
data.day = d;
goto ex;
}
}
}
data.day = 1;
data.year += rFreq;
}
@@ -2837,48 +2840,48 @@ int Recurrence::yearlyDayCalcEndDate(QDate &enddate, YearlyDayData &data) const
// The number of recurrences is the same every year,
// so skip the year-by-year check.
// Skip the remaining whole years, but leave at least
// 1 recurrence remaining, in order to get its date.
int daysPerYear = rYearNums.count();
int wholeYears = (countTogo - 1) / daysPerYear;
data.year += wholeYears * rFreq;
countGone += wholeYears * daysPerYear;
countTogo -= wholeYears * daysPerYear;
}
if (countTogo) {
// Check the last year in the recurrence
- for (QPtrListIterator<int> it(rYearNums); it.current(); ++it) {
+ for (Q3PtrListIterator<int> it(rYearNums); it.current(); ++it) {
++countGone;
if (--countTogo == 0) {
data.day = *it.current();
break;
}
}
}
ex:
enddate = data.date();
return countGone;
}
int Recurrence::yearlyDayCalcToDate(const QDate &enddate, YearlyDayData &data) const
{
int countGone = 0;
int countMax = (rDuration > 0) ? rDuration + mRecurExDatesCount : INT_MAX;
int endYear = enddate.year();
int endDay = enddate.dayOfYear();
if (data.day > 1) {
// Check what remains of the start year
bool leapOK = data.isMaxDayCount();
- for (QPtrListIterator<int> it(rYearNums); it.current(); ++it) {
+ for (Q3PtrListIterator<int> it(rYearNums); it.current(); ++it) {
int d = *it.current();
if (d >= data.day && (leapOK || d < 366)) {
if (data.year == endYear && d > endDay)
return countGone;
if (++countGone >= countMax)
return countMax;
}
}
data.day = 1;
data.year += rFreq;
}
@@ -2899,45 +2902,45 @@ int Recurrence::yearlyDayCalcToDate(const QDate &enddate, YearlyDayData &data) c
// Skip the remaining whole years.
int wholeYears = endYear - data.year;
countGone += (wholeYears / rFreq) * rYearNums.count();
if (countGone >= countMax)
return countMax;
if (wholeYears % rFreq)
return countGone; // end year isn't a recurrence year
data.year = endYear;
}
if (data.year <= endYear) {
// Check the last year in the recurrence
- for (QPtrListIterator<int> it(rYearNums); it.current(); ++it) {
+ for (Q3PtrListIterator<int> it(rYearNums); it.current(); ++it) {
if (*it.current() > endDay)
return countGone;
if (++countGone >= countMax)
return countMax;
}
}
return countGone;
}
int Recurrence::yearlyDayCalcNextAfter(QDate &enddate, YearlyDayData &data) const
{
uint countTogo = (rDuration > 0) ? rDuration + mRecurExDatesCount : UINT_MAX;
int countGone = 0;
int endYear = enddate.year();
int endDay = enddate.dayOfYear();
if (data.day > 1) {
// Check what remains of the start year
bool leapOK = data.isMaxDayCount();
- for (QPtrListIterator<int> it(rYearNums); it.current(); ++it) {
+ for (Q3PtrListIterator<int> it(rYearNums); it.current(); ++it) {
int d = *it.current();
if (d >= data.day && (leapOK || d < 366)) {
++countGone;
if (data.year == endYear && d > endDay) {
data.day = d;
goto ex;
}
if (--countTogo == 0)
return 0;
}
}
data.day = 1;
@@ -2968,49 +2971,49 @@ int Recurrence::yearlyDayCalcNextAfter(QDate &enddate, YearlyDayData &data) cons
++recurYears; // required year is after endYear
if (recurYears) {
int n = recurYears * daysPerYear;
if (static_cast<uint>(n) > countTogo)
return 0; // reached end of recurrence
countTogo -= n;
countGone += n;
data.year += recurYears * rFreq;
}
}
// Check the last year in the recurrence
- for (QPtrListIterator<int> it(rYearNums); it.current(); ++it) {
+ for (Q3PtrListIterator<int> it(rYearNums); it.current(); ++it) {
++countGone;
int d = *it.current();
if (data.year > endYear || d > endDay) {
data.day = d;
break;
}
if (--countTogo == 0)
return 0;
}
ex:
enddate = data.date();
return countGone;
}
// Get the days in this month which recur, in numerical order.
// Parameters: daysInMonth = number of days in this month
// startDayOfWeek = day of week for first day of month.
-void Recurrence::getMonthlyPosDays(QValueList<int> &list, int daysInMonth, int startDayOfWeek) const
+void Recurrence::getMonthlyPosDays(Q3ValueList<int> &list, int daysInMonth, int startDayOfWeek) const
{
list.clear();
int endDayOfWeek = (startDayOfWeek + daysInMonth - 2) % 7 + 1;
// Go through the list, compiling a bit list of actual day numbers
Q_UINT32 days = 0;
- for (QPtrListIterator<rMonthPos> pos(rMonthPositions); pos.current(); ++pos) {
+ for (Q3PtrListIterator<rMonthPos> pos(rMonthPositions); pos.current(); ++pos) {
int weeknum = pos.current()->rPos - 1; // get 0-based week number
QBitArray &rdays = pos.current()->rDays;
if (pos.current()->negative) {
// nth days before the end of the month
for (uint i = 1; i <= 7; ++i) {
if (rdays.testBit(i - 1)) {
int day = daysInMonth - weeknum*7 - (endDayOfWeek - i + 7) % 7;
if (day > 0)
days |= 1 << (day - 1);
}
}
} else {
@@ -3030,25 +3033,25 @@ void Recurrence::getMonthlyPosDays(QValueList<int> &list, int daysInMonth, int s
if (days & mask)
list.append(i + 1);
}
}
// Get the number of days in the month which recur.
// Reply = -1 if the number varies from month to month.
int Recurrence::countMonthlyPosDays() const
{
int count = 0;
Q_UINT8 positive[5] = { 0, 0, 0, 0, 0 };
Q_UINT8 negative[4] = { 0, 0, 0, 0 };
- for (QPtrListIterator<rMonthPos> pos(rMonthPositions); pos.current(); ++pos) {
+ for (Q3PtrListIterator<rMonthPos> pos(rMonthPositions); pos.current(); ++pos) {
int weeknum = pos.current()->rPos;
Q_UINT8* wk;
if (pos.current()->negative) {
// nth days before the end of the month
if (weeknum > 4)
return -1; // days in 5th week are often missing
wk = &negative[4 - weeknum];
} else {
// nth days after the start of the month
if (weeknum > 4)
return -1; // days in 5th week are often missing
wk = &positive[weeknum - 1];
@@ -3063,30 +3066,30 @@ int Recurrence::countMonthlyPosDays() const
}
// Check for any possible days which could be duplicated by
// a positive and a negative position.
for (int i = 0; i < 4; ++i) {
if (negative[i] & (positive[i] | positive[i+1]))
return -1;
}
return count;
}
// Get the days in this month which recur, in numerical order.
// Reply = true if day numbers varies from month to month.
-bool Recurrence::getMonthlyDayDays(QValueList<int> &list, int daysInMonth) const
+bool Recurrence::getMonthlyDayDays(Q3ValueList<int> &list, int daysInMonth) const
{
list.clear();
bool variable = false;
Q_UINT32 days = 0;
- for (QPtrListIterator<int> it(rMonthDays); it.current(); ++it) {
+ for (Q3PtrListIterator<int> it(rMonthDays); it.current(); ++it) {
int day = *it.current();
if (day > 0) {
// date in the month
if (day <= daysInMonth)
days |= 1 << (day - 1);
if (day > 28 && day <= 31)
variable = true; // this date does not appear in some months
} else if (day < 0) {
// days before the end of the month
variable = true; // this date varies depending on the month length
day = daysInMonth + day; // zero-based day of month
if (day >= 0)
@@ -3097,30 +3100,30 @@ bool Recurrence::getMonthlyDayDays(QValueList<int> &list, int daysInMonth) const
Q_UINT32 mask = 1;
for (int i = 0; i < daysInMonth; mask <<= 1, ++i) {
if (days & mask)
list.append(i + 1);
}
return variable;
}
// 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.
// Reply = true if February 29th also recurs.
-bool Recurrence::getYearlyMonthMonths(int day, QValueList<int> &list, QValueList<int> &leaplist) const
+bool Recurrence::getYearlyMonthMonths(int day, Q3ValueList<int> &list, Q3ValueList<int> &leaplist) const
{
list.clear();
leaplist.clear();
bool feb29 = false;
- for (QPtrListIterator<int> it(rYearNums); it.current(); ++it) {
+ for (Q3PtrListIterator<int> it(rYearNums); it.current(); ++it) {
int month = *it.current();
if (month == 2) {
if (day <= 28) {
list.append(month); // date appears in February
leaplist.append(month);
}
else if (day == 29) {
// February 29th
leaplist.append(month);
switch (mFeb29YearlyType) {
case rFeb28:
case rMar1:
@@ -3178,94 +3181,94 @@ int Recurrence::getLastDayInWeek(int endDay, bool useWeekStart) const
/* From the recurrence monthly day number list or monthly day of week/week of
* month list, get the earliest day in the specified month which is >= the
* earliestDate.
*/
QDate Recurrence::getFirstDateInMonth(const QDate &earliestDate) const
{
int earliestDay = earliestDate.day();
int daysInMonth = earliestDate.daysInMonth();
switch (recurs) {
case rMonthlyDay: {
int minday = daysInMonth + 1;
- for (QPtrListIterator<int> it(rMonthDays); it.current(); ++it) {
+ for (Q3PtrListIterator<int> it(rMonthDays); it.current(); ++it) {
int day = *it.current();
if (day < 0)
day = daysInMonth + day + 1;
if (day >= earliestDay && day < minday)
minday = day;
}
if (minday <= daysInMonth)
return earliestDate.addDays(minday - earliestDay);
break;
}
case rMonthlyPos:
case rYearlyPos: {
QDate monthBegin(earliestDate.addDays(1 - earliestDay));
- QValueList<int> dayList;
+ Q3ValueList<int> dayList;
getMonthlyPosDays(dayList, daysInMonth, monthBegin.dayOfWeek());
- for (QValueList<int>::ConstIterator id = dayList.begin(); id != dayList.end(); ++id) {
+ for (Q3ValueList<int>::ConstIterator id = dayList.begin(); id != dayList.end(); ++id) {
if (*id >= earliestDay)
return monthBegin.addDays(*id - 1);
}
break;
}
}
return QDate();
}
/* From the recurrence monthly day number list or monthly day of week/week of
* month list, get the latest day in the specified month which is <= the
* latestDate.
*/
QDate Recurrence::getLastDateInMonth(const QDate &latestDate) const
{
int latestDay = latestDate.day();
int daysInMonth = latestDate.daysInMonth();
switch (recurs) {
case rMonthlyDay: {
int maxday = -1;
- for (QPtrListIterator<int> it(rMonthDays); it.current(); ++it) {
+ for (Q3PtrListIterator<int> it(rMonthDays); it.current(); ++it) {
int day = *it.current();
if (day < 0)
day = daysInMonth + day + 1;
if (day <= latestDay && day > maxday)
maxday = day;
}
if (maxday > 0)
return QDate(latestDate.year(), latestDate.month(), maxday);
break;
}
case rMonthlyPos:
case rYearlyPos: {
QDate monthBegin(latestDate.addDays(1 - latestDay));
- QValueList<int> dayList;
+ Q3ValueList<int> dayList;
getMonthlyPosDays(dayList, daysInMonth, monthBegin.dayOfWeek());
- for (QValueList<int>::ConstIterator id = dayList.fromLast(); id != dayList.end(); --id) {
+ for (Q3ValueList<int>::ConstIterator id = dayList.fromLast(); id != dayList.end(); --id) {
if (*id <= latestDay)
return monthBegin.addDays(*id - 1);
}
break;
}
}
return QDate();
}
/* From the recurrence yearly month list or yearly day list, get the earliest
* month or day in the specified year which is >= the earliestDate.
* Note that rYearNums is sorted in numerical order.
*/
QDate Recurrence::getFirstDateInYear(const QDate &earliestDate) const
{
- QPtrListIterator<int> it(rYearNums);
+ Q3PtrListIterator<int> it(rYearNums);
switch (recurs) {
case rYearlyMonth: {
int day = recurStart().date().day();
int earliestYear = earliestDate.year();
int earliestMonth = earliestDate.month();
int earliestDay = earliestDate.day();
if (earliestDay > day) {
// The earliest date is later in the month than the recurrence date,
// so skip to the next month before starting to check
if (++earliestMonth > 12)
return QDate();
}
@@ -3283,34 +3286,34 @@ QDate Recurrence::getFirstDateInYear(const QDate &earliestDate) const
if (earliestDay <= 28)
return QDate(earliestYear, 2, 28);
break;
case rFeb29:
break;
}
}
}
}
break;
}
case rYearlyPos: {
- QValueList<int> dayList;
+ Q3ValueList<int> dayList;
int earliestYear = earliestDate.year();
int earliestMonth = earliestDate.month();
int earliestDay = earliestDate.day();
for ( ; it.current(); ++it) {
int month = *it.current();
if (month >= earliestMonth) {
QDate monthBegin(earliestYear, month, 1);
getMonthlyPosDays(dayList, monthBegin.daysInMonth(), monthBegin.dayOfWeek());
- for (QValueList<int>::ConstIterator id = dayList.begin(); id != dayList.end(); ++id) {
+ for (Q3ValueList<int>::ConstIterator id = dayList.begin(); id != dayList.end(); ++id) {
if (*id >= earliestDay)
return monthBegin.addDays(*id - 1);
}
earliestDay = 1;
}
}
break;
}
case rYearlyDay: {
int earliestDay = earliestDate.dayOfYear();
for ( ; it.current(); ++it) {
int day = *it.current();
@@ -3320,25 +3323,25 @@ QDate Recurrence::getFirstDateInYear(const QDate &earliestDate) const
break;
}
}
return QDate();
}
/* From the recurrence yearly month list or yearly day list, get the latest
* month or day in the specified year which is <= the latestDate.
* Note that rYearNums is sorted in numerical order.
*/
QDate Recurrence::getLastDateInYear(const QDate &latestDate) const
{
- QPtrListIterator<int> it(rYearNums);
+ Q3PtrListIterator<int> it(rYearNums);
switch (recurs) {
case rYearlyMonth: {
int day = recurStart().date().day();
int latestYear = latestDate.year();
int latestMonth = latestDate.month();
if (latestDate.day() > day) {
// The latest date is earlier in the month than the recurrence date,
// so skip to the previous month before starting to check
if (--latestMonth <= 0)
return QDate();
}
for (it.toLast(); it.current(); --it) {
@@ -3355,34 +3358,34 @@ QDate Recurrence::getLastDateInYear(const QDate &latestDate) const
break;
case rFeb28:
return QDate(latestYear, 2, 28);
case rFeb29:
break;
}
}
}
}
break;
}
case rYearlyPos: {
- QValueList<int> dayList;
+ Q3ValueList<int> dayList;
int latestYear = latestDate.year();
int latestMonth = latestDate.month();
int latestDay = latestDate.day();
for (it.toLast(); it.current(); --it) {
int month = *it.current();
if (month <= latestMonth) {
QDate monthBegin(latestYear, month, 1);
getMonthlyPosDays(dayList, monthBegin.daysInMonth(), monthBegin.dayOfWeek());
- for (QValueList<int>::ConstIterator id = dayList.fromLast(); id != dayList.end(); --id) {
+ for (Q3ValueList<int>::ConstIterator id = dayList.fromLast(); id != dayList.end(); --id) {
if (*id <= latestDay)
return monthBegin.addDays(*id - 1);
}
latestDay = 31;
}
}
break;
}
case rYearlyDay: {
int latestDay = latestDate.dayOfYear();
for (it.toLast(); it.current(); --it) {
int day = *it.current();