-rw-r--r-- | libkcal/icalformatimpl.cpp | 8 | ||||
-rw-r--r-- | libkcal/recurrence.cpp | 17 | ||||
-rw-r--r-- | libkcal/recurrence.h | 6 |
3 files changed, 24 insertions, 7 deletions
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index 32a1337..964ffe3 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp @@ -1383,25 +1383,25 @@ void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurre int frequ = r.freq; int interv = r.interval; // preprocessing for odd recurrence definitions if ( r.freq == ICAL_MONTHLY_RECURRENCE ) { if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { interv = 12; } } if ( r.freq == ICAL_YEARLY_RECURRENCE ) { if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) { frequ = ICAL_MONTHLY_RECURRENCE; - interv = 12; + interv = 12* r.interval; } } switch (frequ) { case ICAL_MINUTELY_RECURRENCE: if (!icaltime_is_null_time(r.until)) { recur->setMinutely(interv,readICalDateTime(r.until)); } else { if (r.count == 0) recur->setMinutely(interv,-1); else recur->setMinutely(interv,r.count); @@ -1490,38 +1490,40 @@ void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurre recur->setMonthly(Recurrence::rMonthlyDay,interv,-1); else recur->setMonthly(Recurrence::rMonthlyDay,interv,r.count); } while((day = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { // kdDebug(5800) << "----b " << day << endl; recur->addMonthlyDay(day); } } break; case ICAL_YEARLY_RECURRENCE: if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { + qDebug(" YEARLY DAY OF YEAR"); if (!icaltime_is_null_time(r.until)) { recur->setYearly(Recurrence::rYearlyDay,interv, readICalDate(r.until)); } else { if (r.count == 0) recur->setYearly(Recurrence::rYearlyDay,interv,-1); else recur->setYearly(Recurrence::rYearlyDay,interv,r.count); } while((day = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { recur->addYearlyNum(day); } } else if ( true /*r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX*/) { if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { + qDebug("YEARLY POS NOT SUPPORTED BY GUI"); if (!icaltime_is_null_time(r.until)) { recur->setYearly(Recurrence::rYearlyPos,interv, readICalDate(r.until)); } else { if (r.count == 0) recur->setYearly(Recurrence::rYearlyPos,interv,-1); else recur->setYearly(Recurrence::rYearlyPos,interv,r.count); } bool useSetPos = false; short pos = 0; while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { @@ -1534,43 +1536,45 @@ void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurre recur->addYearlyMonthPos(pos,ba); } else { qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 useSetPos = true; } } if (useSetPos) { if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { recur->addYearlyMonthPos(r.by_set_pos[0],qba); } } } else { + qDebug("YEARLY MONTH "); if (!icaltime_is_null_time(r.until)) { recur->setYearly(Recurrence::rYearlyMonth,interv, readICalDate(r.until)); } else { if (r.count == 0) recur->setYearly(Recurrence::rYearlyMonth,interv,-1); else recur->setYearly(Recurrence::rYearlyMonth,interv,r.count); } - } if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX ) { index = 0; while((day = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { recur->addYearlyNum(day); } } else { recur->addYearlyNum(incidence->dtStart().date().month()); } } + + } break; default: ; break; } } void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence) { //kdDebug(5800) << "Read alarm for " << incidence->summary() << endl; Alarm* ialarm = incidence->newAlarm(); diff --git a/libkcal/recurrence.cpp b/libkcal/recurrence.cpp index 5fc5d1f..dd74e10 100644 --- a/libkcal/recurrence.cpp +++ b/libkcal/recurrence.cpp @@ -645,25 +645,25 @@ void Recurrence::addMonthlyPos_(short _rPos, const QBitArray &_rDays) int monthsAhead = (mCompatDuration-1+mRecurExDatesCount) * rFreq; int month = mRecurStart.date().month() - 1 + monthsAhead; QDate end(mRecurStart.date().year() + month/12, month%12 + 1, 31); rDuration = INT_MAX; // ensure that recurCalc() does its job correctly rDuration = recurCalc(COUNT_TO_DATE, end); } if (mParent) mParent->updated(); } void Recurrence::addMonthlyDay(short _rDay) { - if (mRecurReadOnly || recurs != rMonthlyDay + if (mRecurReadOnly || (recurs != rMonthlyDay && recurs != rYearlyMonth) || _rDay == 0 || _rDay > 31 || _rDay < -31) // invalid day number return; for (int* it = rMonthDays.first(); it; it = rMonthDays.next()) { if (_rDay == *it) return; // this day is already in the list - avoid duplication } int *tmpDay = new int; *tmpDay = _rDay; rMonthDays.append(tmpDay); if (mCompatVersion < 310 && mCompatDuration > 0) { // Backwards compatibility for KDE < 3.1. @@ -716,25 +716,38 @@ 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 { 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 { + tmpPos->rPos = -_rPos; // take abs() + tmpPos->negative = true; + } + rMonthPositions.append(tmpPos); +} void Recurrence::addYearlyNum(short _rNum) { if (mRecurReadOnly || (recurs != rYearlyMonth && recurs != rYearlyDay && recurs != rYearlyPos) || _rNum <= 0) // invalid day/month number return; if (mCompatVersion < 310 && mCompatRecurs == rYearlyDay) { // Backwards compatibility for KDE < 3.1. // Dates were stored as day numbers, with a fiddle to take account of leap years. // Convert the day number to a month. if (_rNum <= 0 || _rNum > 366 || (_rNum == 366 && mRecurStart.date().daysInYear() < 366)) diff --git a/libkcal/recurrence.h b/libkcal/recurrence.h index a0f6d84..b13d14f 100644 --- a/libkcal/recurrence.h +++ b/libkcal/recurrence.h @@ -279,30 +279,32 @@ class Recurrence */ void addYearlyMonthPos(short _rPos, const QBitArray &_rDays); /** Returns positions of days or months in year. */ const QPtrList<int> &yearNums() const; /** Returns list of day positions in months, for a recursYearlyPos recurrence rule. */ const QPtrList<rMonthPos> &yearMonthPositions() const; /** Returns how yearly recurrences of February 29th are handled. */ Feb29Type feb29YearlyType() const { return mFeb29YearlyType; } /** Sets the default method for handling yearly recurrences of February 29th. */ static void setFeb29YearlyTypeDefault(Feb29Type t) { mFeb29YearlyDefaultType = t; } /** Returns the default method for handling yearly recurrences of February 29th. */ static Feb29Type setFeb29YearlyTypeDefault() { return mFeb29YearlyDefaultType; } - + void addYearlyMonth(short _rPos ); // added LR /** Debug output. */ void dump() const; QString recurrenceText() const; + bool getYearlyMonthMonths(int day, QValueList<int>&, + QValueList<int> &leaplist) const; protected: enum PeriodFunc { END_DATE_AND_COUNT, COUNT_TO_DATE, NEXT_AFTER_DATE }; struct MonthlyData; friend struct MonthlyData; struct YearlyMonthData; friend struct YearlyMonthData; struct YearlyPosData; friend struct YearlyPosData; struct YearlyDayData; friend struct YearlyDayData; 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; @@ -337,26 +339,24 @@ class Recurrence 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; int countMonthlyPosDays() const; void getMonthlyPosDays(QValueList<int>&, int daysInMonth, int startDayOfWeek) const; bool getMonthlyDayDays(QValueList<int>&, int daysInMonth) const; - bool getYearlyMonthMonths(int day, QValueList<int>&, - QValueList<int> &leaplist) const; int getFirstDayInWeek(int startDay, bool useWeekStart = true) const; int getLastDayInWeek(int endDay, bool useWeekStart = true) const; QDate getFirstDateInMonth(const QDate& earliestDate) const; QDate getLastDateInMonth(const QDate& latestDate) const; QDate getFirstDateInYear(const QDate& earliestDate) const; QDate getLastDateInYear(const QDate& latestDate) const; private: // Prohibit copying Recurrence(const Recurrence&); Recurrence &operator=(const Recurrence&); |