Commit 55f1775b authored by David Jarvie's avatar David Jarvie
Browse files

Deprecate isWorkingTime() in favour of excludedByWorkTimeOrHoliday()

This is to replace a misleading method name by a more intuitive one.
parent d4b06693
Pipeline #49767 passed with stage
in 9 minutes and 58 seconds
......@@ -188,7 +188,7 @@ public:
}
DateTime deferralLimit(KAEvent::DeferLimitType * = nullptr) const;
KAEvent::Flags flags() const;
bool isWorkingTime(const KADateTime &) const;
bool excludedByWorkTimeOrHoliday(const KADateTime &dt) const;
bool setRepetition(const Repetition &);
bool occursAfter(const KADateTime &preDateTime, bool includeRepetitions) const;
KAEvent::OccurType nextOccurrence(const KADateTime &preDateTime, DateTime &result, KAEvent::OccurOption = KAEvent::IGNORE_REPETITION) const;
......@@ -2586,25 +2586,30 @@ bool KAEvent::workTimeOnly() const
}
/******************************************************************************
* Check whether a date/time is during working hours and/or holidays, depending
* on the flags set for the specified event.
* Check whether a date/time conflicts with working hours and/or holiday
* restrictions for the alarm.
*/
bool KAEvent::excludedByWorkTimeOrHoliday(const KADateTime &dt) const
{
return d->excludedByWorkTimeOrHoliday(dt);
}
bool KAEvent::isWorkingTime(const KADateTime &dt) const
{
return d->isWorkingTime(dt);
return !excludedByWorkTimeOrHoliday(dt);
}
bool KAEventPrivate::isWorkingTime(const KADateTime &dt) const
bool KAEventPrivate::excludedByWorkTimeOrHoliday(const KADateTime &dt) const
{
if ((mWorkTimeOnly && !mWorkDays.testBit(dt.date().dayOfWeek() - 1))
|| (mExcludeHolidays && holidays()->isHoliday(dt.date()))) {
return false;
return true;
}
if (!mWorkTimeOnly) {
return true;
return false;
}
return dt.isDateOnly()
|| (dt.time() >= mWorkDayStart && dt.time() < mWorkDayEnd);
return !dt.isDateOnly()
&& (dt.time() < mWorkDayStart || dt.time() >= mWorkDayEnd);
}
/******************************************************************************
......@@ -4342,7 +4347,7 @@ void KAEventPrivate::calcTriggerTimes() const
// unless it falls during working hours.
if ((!mWorkTimeOnly && !excludeHolidays)
|| !recurs
|| isWorkingTime(mMainTrigger.kDateTime())) {
|| !excludedByWorkTimeOrHoliday(mMainTrigger.kDateTime())) {
// It only occurs once, or it complies with any working hours/holiday
// restrictions.
mMainWorkTrigger = mMainTrigger;
......@@ -4370,7 +4375,7 @@ void KAEventPrivate::calcTriggerTimes() const
if (!nextTrigger.isValid()) {
break;
}
if (isWorkingTime(nextTrigger.kDateTime())) {
if (!excludedByWorkTimeOrHoliday(nextTrigger.kDateTime())) {
const int reminder = (mReminderMinutes > 0) ? mReminderMinutes : 0; // only interested in reminders BEFORE the alarm
mMainWorkTrigger = nextTrigger;
mAllWorkTrigger = (type & KAEvent::OCCURRENCE_REPEAT) ? mMainWorkTrigger : mMainWorkTrigger.addMins(-reminder);
......
......@@ -1070,14 +1070,28 @@ public:
bool workTimeOnly() const;
/** Check whether a date/time is during working hours and/or holidays, depending
* on the flags set for the specified event. */
bool isWorkingTime(const KADateTime &dt) const;
* on the flags set for the specified event.
* @deprecated Use !excludedByWorkTimeOrHoliday() instead.
*/
KALARMCAL_DEPRECATED bool isWorkingTime(const KADateTime &dt) const;
/** Check whether a date/time conflicts with working hours and/or holiday
* restrictions for the alarm.
* @return true if the alarm is disabled from occurring at time @p dt
* because @p dt is outside working hours (if the alarm is
* working time only) or is during a holiday (if the alarm is
* disabled on holidays);
* false if the alarm is permitted to occur at time @p dt. (But
* note that no check is made as to whether the alarm is
* actually scheduled to occur at time @p dt.)
*/
bool excludedByWorkTimeOrHoliday(const KADateTime &dt) const;
/** Set working days and times, to be used by all KAEvent instances.
* @param days bits set to 1 for each working day. Array element 0 = Monday ... 6 = Sunday.
* @param start start time in working day.
* @param end end time in working day.
* @see setWorkTimeOnly(), isWorkingTime()
* @see setWorkTimeOnly(), excludedByWorkTimeOrHoliday()
*/
static void setWorkTime(const QBitArray &days, const QTime &start, const QTime &end);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment