|
Lines 531-536
void RecurrenceEdit::activateSubRepetition()
Link Here
|
| 531 |
} |
531 |
} |
| 532 |
|
532 |
|
| 533 |
/****************************************************************************** |
533 |
/****************************************************************************** |
|
|
534 |
* For weekly, monthly and yearly recurrence, checks that the specified date |
| 535 |
* matches the days allowed. For the other recurrence simply return true. |
| 536 |
*/ |
| 537 |
bool RecurrenceEdit::validateDate(const DateTime &date) const |
| 538 |
{ |
| 539 |
if (mRuleButtonType == RecurrenceEdit::DAILY) |
| 540 |
{ |
| 541 |
TQBitArray selectedDays = mDailyRule->days(); |
| 542 |
if (!selectedDays[date.date().dayOfWeek()-1]) |
| 543 |
return false; |
| 544 |
} |
| 545 |
else if (mRuleButtonType == RecurrenceEdit::WEEKLY) |
| 546 |
{ |
| 547 |
TQBitArray selectedDays = mWeeklyRule->days(); |
| 548 |
if (!selectedDays[date.date().dayOfWeek()-1]) |
| 549 |
return false; |
| 550 |
} |
| 551 |
else if (mRuleButtonType == RecurrenceEdit::MONTHLY) |
| 552 |
{ |
| 553 |
if (mMonthlyRule->type() == MonthYearRule::DATE) |
| 554 |
{ |
| 555 |
// on the nth day of the month |
| 556 |
int comboDate = mMonthlyRule->date(); |
| 557 |
if ((comboDate > 0 && date.date().day() != comboDate) || |
| 558 |
(comboDate <=0 && date.date().day() != date.date().daysInMonth())) |
| 559 |
return false; |
| 560 |
} |
| 561 |
else |
| 562 |
{ |
| 563 |
// on the nth weekday (i.e. Monday) of the month |
| 564 |
if (date.date().dayOfWeek() != mMonthlyRule->dayOfWeek()) |
| 565 |
return false; |
| 566 |
|
| 567 |
int monthDay = date.date().day(); |
| 568 |
int weekNum = mMonthlyRule->week(); |
| 569 |
int minDay = 0, maxDay = 0; |
| 570 |
if (weekNum > 0 ) |
| 571 |
{ |
| 572 |
minDay = (weekNum-1) * 7; |
| 573 |
maxDay = weekNum * 7; |
| 574 |
} |
| 575 |
else if (weekNum < 0) |
| 576 |
{ |
| 577 |
int dim = date.date().daysInMonth(); |
| 578 |
minDay = dim + weekNum * 7; |
| 579 |
maxDay = dim + (weekNum+1) * 7; |
| 580 |
} |
| 581 |
if (monthDay <= minDay || monthDay > maxDay) |
| 582 |
return false; |
| 583 |
} |
| 584 |
} |
| 585 |
else if (mRuleButtonType == RecurrenceEdit::ANNUAL) |
| 586 |
{ |
| 587 |
TQValueList<int> months = mYearlyRule->months(); |
| 588 |
if (!months.contains(date.date().month())) |
| 589 |
return false; |
| 590 |
|
| 591 |
if (mYearlyRule->type() == MonthYearRule::DATE) |
| 592 |
{ |
| 593 |
// on the nth day of the month |
| 594 |
int comboDate = mYearlyRule->date(); |
| 595 |
if ((comboDate > 0 && date.date().day() != comboDate) || |
| 596 |
(comboDate <=0 && date.date().day() != date.date().daysInMonth())) |
| 597 |
return false; |
| 598 |
} |
| 599 |
else |
| 600 |
{ |
| 601 |
// on the nth weekday (i.e. Monday) of the month |
| 602 |
if (date.date().dayOfWeek() != mYearlyRule->dayOfWeek()) |
| 603 |
return false; |
| 604 |
|
| 605 |
int monthDay = date.date().day(); |
| 606 |
int weekNum = mYearlyRule->week(); |
| 607 |
int minDay = 0, maxDay = 0; |
| 608 |
if (weekNum > 0 ) |
| 609 |
{ |
| 610 |
minDay = (weekNum-1) * 7; |
| 611 |
maxDay = weekNum * 7; |
| 612 |
} |
| 613 |
else if (weekNum < 0) |
| 614 |
{ |
| 615 |
int dim = date.date().daysInMonth(); |
| 616 |
minDay = dim + weekNum * 7; |
| 617 |
maxDay = dim + (weekNum+1) * 7; |
| 618 |
} |
| 619 |
if (monthDay <= minDay || monthDay > maxDay) |
| 620 |
return false; |
| 621 |
} |
| 622 |
} |
| 623 |
return true; |
| 624 |
} |
| 625 |
|
| 626 |
/****************************************************************************** |
| 534 |
* Called when the value of the repeat count field changes, to reset the |
627 |
* Called when the value of the repeat count field changes, to reset the |
| 535 |
* minimum value to 1 if the value was 0. |
628 |
* minimum value to 1 if the value was 0. |
| 536 |
*/ |
629 |
*/ |