-rw-r--r-- | libkcal/recurrence.cpp | 187 |
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 @@ -26,12 +26,15 @@ #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; @@ -53,13 +56,13 @@ Recurrence::Recurrence(Incidence *parent, int compatVersion) 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), @@ -67,25 +70,25 @@ Recurrence::Recurrence(const Recurrence &r, Incidence *parent) 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 ); @@ -121,52 +124,52 @@ bool Recurrence::operator==( const Recurrence& r2 ) const 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: @@ -354,13 +357,13 @@ QDateTime Recurrence::endDateTime() const { 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: @@ -503,23 +506,23 @@ QString Recurrence::endDateStr(bool shortfmt) const 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) { @@ -756,13 +759,13 @@ void Recurrence::setYearlyByDate(Feb29Type type, int _rFreq, const QDate &_rEndD 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 @@ -1044,19 +1047,19 @@ bool Recurrence::recursMonthly(const QDate &qd) const // 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 } } @@ -1098,13 +1101,13 @@ bool Recurrence::recursYearlyByMonth(const QDate &qd) const 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; } } } } @@ -1124,18 +1127,18 @@ bool Recurrence::recursYearlyByPos(const QDate &qd) const // 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; } } } } @@ -1154,13 +1157,13 @@ bool Recurrence::recursYearlyByDay(const QDate &qd) const 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; @@ -1546,13 +1549,13 @@ int Recurrence::recurCalc(PeriodFunc func, QDate &enddate) const } 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; } @@ -1790,30 +1793,30 @@ 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; } @@ -1841,14 +1844,14 @@ int Recurrence::monthlyCalc(PeriodFunc func, QDate &enddate) const } 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; @@ -1907,14 +1910,14 @@ 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) @@ -1966,14 +1969,14 @@ 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; @@ -2049,23 +2052,23 @@ struct Recurrence::YearlyMonthData { 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()) @@ -2085,14 +2088,14 @@ int Recurrence::yearlyMonthCalc(PeriodFunc func, QDate &enddate) const // 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; @@ -2196,14 +2199,14 @@ int Recurrence::yearlyMonthCalcToDate(const QDate &enddate, YearlyMonthData &dat } 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) @@ -2267,14 +2270,14 @@ int Recurrence::yearlyMonthCalcNextAfter(QDate &enddate, YearlyMonthData &data) 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; @@ -2387,21 +2390,21 @@ struct Recurrence::YearlyPosData { 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; } @@ -2425,18 +2428,18 @@ int Recurrence::yearlyPosCalc(PeriodFunc func, QDate &enddate) const } 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(); @@ -2463,13 +2466,13 @@ int Recurrence::yearlyPosCalcEndDate(QDate &enddate, YearlyPosData &data) const 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) { @@ -2493,13 +2496,13 @@ int Recurrence::yearlyPosCalcEndDate(QDate &enddate, YearlyPosData &data) const 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; @@ -2528,18 +2531,18 @@ int Recurrence::yearlyPosCalcToDate(const QDate &enddate, YearlyPosData &data) c 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); @@ -2573,13 +2576,13 @@ int Recurrence::yearlyPosCalcToDate(const QDate &enddate, YearlyPosData &data) c 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 @@ -2608,13 +2611,13 @@ int Recurrence::yearlyPosCalcToDate(const QDate &enddate, YearlyPosData &data) c 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(); @@ -2643,20 +2646,20 @@ int Recurrence::yearlyPosCalcNextAfter(QDate &enddate, YearlyPosData &data) cons 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) { @@ -2686,13 +2689,13 @@ int Recurrence::yearlyPosCalcNextAfter(QDate &enddate, YearlyPosData &data) cons 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 @@ -2731,13 +2734,13 @@ int Recurrence::yearlyPosCalcNextAfter(QDate &enddate, YearlyPosData &data) cons 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) { @@ -2805,13 +2808,13 @@ 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; @@ -2843,13 +2846,13 @@ int Recurrence::yearlyDayCalcEndDate(QDate &enddate, YearlyDayData &data) const 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; } } @@ -2866,13 +2869,13 @@ int Recurrence::yearlyDayCalcToDate(const QDate &enddate, YearlyDayData &data) c 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; @@ -2905,13 +2908,13 @@ int Recurrence::yearlyDayCalcToDate(const QDate &enddate, YearlyDayData &data) c 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; } } @@ -2925,13 +2928,13 @@ int Recurrence::yearlyDayCalcNextAfter(QDate &enddate, YearlyDayData &data) cons 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; @@ -2974,13 +2977,13 @@ int Recurrence::yearlyDayCalcNextAfter(QDate &enddate, YearlyDayData &data) cons 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; } @@ -2992,19 +2995,19 @@ ex: 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)) { @@ -3036,13 +3039,13 @@ void Recurrence::getMonthlyPosDays(QValueList<int> &list, int daysInMonth, int s // 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 @@ -3069,18 +3072,18 @@ int Recurrence::countMonthlyPosDays() const } 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) @@ -3103,18 +3106,18 @@ bool Recurrence::getMonthlyDayDays(QValueList<int> &list, int daysInMonth) 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. // 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); } @@ -3184,13 +3187,13 @@ 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; } @@ -3198,15 +3201,15 @@ QDate Recurrence::getFirstDateInMonth(const QDate &earliestDate) const 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; } } @@ -3221,13 +3224,13 @@ 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; } @@ -3235,15 +3238,15 @@ QDate Recurrence::getLastDateInMonth(const QDate &latestDate) const 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; } } @@ -3253,13 +3256,13 @@ QDate Recurrence::getLastDateInMonth(const QDate &latestDate) const /* 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(); @@ -3289,22 +3292,22 @@ QDate Recurrence::getFirstDateInYear(const QDate &earliestDate) const } } } 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; } } @@ -3326,13 +3329,13 @@ QDate Recurrence::getFirstDateInYear(const QDate &earliestDate) const /* 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) { @@ -3361,22 +3364,22 @@ QDate Recurrence::getLastDateInYear(const QDate &latestDate) const } } } 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; } } |