summaryrefslogtreecommitdiffabout
path: root/libkcal/recurrence.cpp
authorzautrix <zautrix>2004-07-10 17:03:16 (UTC)
committer zautrix <zautrix>2004-07-10 17:03:16 (UTC)
commitcf2f3f98a4811668f9e9d0d5f44ea5b51d268cef (patch) (side-by-side diff)
tree963322cd4c539c084feb43dfde5eabe52ae4385f /libkcal/recurrence.cpp
parent8cc6d456812b5a9a386e81c9e46baccd56029537 (diff)
downloadkdepimpi-cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef.zip
kdepimpi-cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef.tar.gz
kdepimpi-cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef.tar.bz2
Fixed some problems with the recurrence
Diffstat (limited to 'libkcal/recurrence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/recurrence.cpp17
1 files changed, 15 insertions, 2 deletions
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))