author | zautrix <zautrix> | 2004-07-10 17:03:16 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-10 17:03:16 (UTC) |
commit | cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef (patch) (unidiff) | |
tree | 963322cd4c539c084feb43dfde5eabe52ae4385f /libkcal/recurrence.cpp | |
parent | 8cc6d456812b5a9a386e81c9e46baccd56029537 (diff) | |
download | kdepimpi-cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef.zip kdepimpi-cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef.tar.gz kdepimpi-cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef.tar.bz2 |
Fixed some problems with the recurrence
-rw-r--r-- | libkcal/recurrence.cpp | 17 |
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) | |||
645 | int monthsAhead = (mCompatDuration-1+mRecurExDatesCount) * rFreq; | 645 | int monthsAhead = (mCompatDuration-1+mRecurExDatesCount) * rFreq; |
646 | int month = mRecurStart.date().month() - 1 + monthsAhead; | 646 | int month = mRecurStart.date().month() - 1 + monthsAhead; |
647 | QDate end(mRecurStart.date().year() + month/12, month%12 + 1, 31); | 647 | QDate end(mRecurStart.date().year() + month/12, month%12 + 1, 31); |
648 | rDuration = INT_MAX; // ensure that recurCalc() does its job correctly | 648 | rDuration = INT_MAX; // ensure that recurCalc() does its job correctly |
649 | rDuration = recurCalc(COUNT_TO_DATE, end); | 649 | rDuration = recurCalc(COUNT_TO_DATE, end); |
650 | } | 650 | } |
651 | 651 | ||
652 | if (mParent) mParent->updated(); | 652 | if (mParent) mParent->updated(); |
653 | } | 653 | } |
654 | 654 | ||
655 | void Recurrence::addMonthlyDay(short _rDay) | 655 | void Recurrence::addMonthlyDay(short _rDay) |
656 | { | 656 | { |
657 | if (mRecurReadOnly || recurs != rMonthlyDay | 657 | if (mRecurReadOnly || (recurs != rMonthlyDay && recurs != rYearlyMonth) |
658 | || _rDay == 0 || _rDay > 31 || _rDay < -31) // invalid day number | 658 | || _rDay == 0 || _rDay > 31 || _rDay < -31) // invalid day number |
659 | return; | 659 | return; |
660 | for (int* it = rMonthDays.first(); it; it = rMonthDays.next()) { | 660 | for (int* it = rMonthDays.first(); it; it = rMonthDays.next()) { |
661 | if (_rDay == *it) | 661 | if (_rDay == *it) |
662 | return; // this day is already in the list - avoid duplication | 662 | return; // this day is already in the list - avoid duplication |
663 | } | 663 | } |
664 | int *tmpDay = new int; | 664 | int *tmpDay = new int; |
665 | *tmpDay = _rDay; | 665 | *tmpDay = _rDay; |
666 | rMonthDays.append(tmpDay); | 666 | rMonthDays.append(tmpDay); |
667 | 667 | ||
668 | if (mCompatVersion < 310 && mCompatDuration > 0) { | 668 | if (mCompatVersion < 310 && mCompatDuration > 0) { |
669 | // Backwards compatibility for KDE < 3.1. | 669 | // Backwards compatibility for KDE < 3.1. |
@@ -716,25 +716,38 @@ void Recurrence::setYearlyByDate(Feb29Type type, int _rFreq, const QDate &_rEndD | |||
716 | } | 716 | } |
717 | 717 | ||
718 | void Recurrence::addYearlyMonthPos(short _rPos, const QBitArray &_rDays) | 718 | void Recurrence::addYearlyMonthPos(short _rPos, const QBitArray &_rDays) |
719 | { | 719 | { |
720 | if (recurs == rYearlyPos) | 720 | if (recurs == rYearlyPos) |
721 | addMonthlyPos_(_rPos, _rDays); | 721 | addMonthlyPos_(_rPos, _rDays); |
722 | } | 722 | } |
723 | 723 | ||
724 | const QPtrList<int> &Recurrence::yearNums() const | 724 | const QPtrList<int> &Recurrence::yearNums() const |
725 | { | 725 | { |
726 | return rYearNums; | 726 | return rYearNums; |
727 | } | 727 | } |
728 | 728 | void Recurrence::addYearlyMonth(short _rPos ) | |
729 | { | ||
730 | if (mRecurReadOnly || recurs != rYearlyMonth) // invalid day/month number | ||
731 | return; | ||
732 | rMonthPos *tmpPos = new rMonthPos; | ||
733 | if ( _rPos > 0) { | ||
734 | tmpPos->rPos = _rPos; | ||
735 | tmpPos->negative = false; | ||
736 | } else { | ||
737 | tmpPos->rPos = -_rPos; // take abs() | ||
738 | tmpPos->negative = true; | ||
739 | } | ||
740 | rMonthPositions.append(tmpPos); | ||
741 | } | ||
729 | void Recurrence::addYearlyNum(short _rNum) | 742 | void Recurrence::addYearlyNum(short _rNum) |
730 | { | 743 | { |
731 | if (mRecurReadOnly | 744 | if (mRecurReadOnly |
732 | || (recurs != rYearlyMonth && recurs != rYearlyDay && recurs != rYearlyPos) | 745 | || (recurs != rYearlyMonth && recurs != rYearlyDay && recurs != rYearlyPos) |
733 | || _rNum <= 0) // invalid day/month number | 746 | || _rNum <= 0) // invalid day/month number |
734 | return; | 747 | return; |
735 | 748 | ||
736 | if (mCompatVersion < 310 && mCompatRecurs == rYearlyDay) { | 749 | if (mCompatVersion < 310 && mCompatRecurs == rYearlyDay) { |
737 | // Backwards compatibility for KDE < 3.1. | 750 | // Backwards compatibility for KDE < 3.1. |
738 | // Dates were stored as day numbers, with a fiddle to take account of leap years. | 751 | // Dates were stored as day numbers, with a fiddle to take account of leap years. |
739 | // Convert the day number to a month. | 752 | // Convert the day number to a month. |
740 | if (_rNum <= 0 || _rNum > 366 || (_rNum == 366 && mRecurStart.date().daysInYear() < 366)) | 753 | if (_rNum <= 0 || _rNum > 366 || (_rNum == 366 && mRecurStart.date().daysInYear() < 366)) |