8#include "incidencerecurrence.h"
11#include "incidencedatetime.h"
12#include "ui_dialogdesktop.h"
14#include "incidenceeditor_debug.h"
17using namespace IncidenceEditorNG;
21 RecurrenceEndNever = 0,
44 ComboIndexMonthlyDay = 0,
45 ComboIndexMonthlyDayInverted,
47 ComboIndexMonthlyPosInverted
52 ComboIndexYearlyMonth = 0,
53 ComboIndexYearlyMonthInverted,
55 ComboIndexYearlyPosInverted,
67 for (
const auto &e : exDates) {
71 r->setExDateTimes(dts);
74IncidenceRecurrence::IncidenceRecurrence(IncidenceDateTime *dateTime, Ui::EventOrTodoDesktop *ui)
77 , mMonthlyInitialType(0)
78 , mYearlyInitialType(0)
80 setObjectName(
"IncidenceRecurrence"_L1);
82 mUi->mRecurrenceTypeCombo->setCurrentIndex(RecurrenceTypeNone);
83 mUi->mRecurrenceEndCombo->setCurrentIndex(RecurrenceEndNever);
84 mUi->mRecurrenceEndStack->setCurrentIndex(0);
85 mUi->mRepeatStack->setCurrentIndex(0);
86 mUi->mEndDurationEdit->setValue(1);
87 handleEndAfterOccurrencesChange(1);
88 toggleRecurrenceWidgets(RecurrenceTypeNone);
90 const QList<QLineEdit *> lineEdits{mUi->mExceptionDateEdit->lineEdit(), mUi->mRecurrenceEndDate->lineEdit()};
93 lineEdit->setClearButtonEnabled(
false);
97 connect(mDateTime, &IncidenceDateTime::startDateTimeToggled,
this, &IncidenceRecurrence::handleDateTimeToggle);
99 connect(mDateTime, &IncidenceDateTime::startDateChanged,
this, &IncidenceRecurrence::handleStartDateChange);
120 connect(mUi->mThisAndFutureCheck, &QCheckBox::checkStateChanged,
this, &IncidenceRecurrence::checkDirtyStatus);
128 "In several of the messages below, "
129 "an ordinal number is substituted into the message. "
130 "Translate this as \"0\" if English ordinal suffixes "
131 "should be added (1st, 22nd, 123rd); "
132 "translate this as \"1\" if just the number itself "
133 "should be substituted (1, 22, 123).",
136 const QString ordinal = numberToString(number);
137 return text.
subs(ordinal);
139 return text.
subs(number);
159 if (mLoadedIncidence->hasRecurrenceId()) {
160 handleRecurrenceTypeChange(RecurrenceTypeException);
161 mUi->mThisAndFutureCheck->setChecked(mLoadedIncidence->thisAndFuture());
168 if (mLoadedIncidence->recurrenceType() != KCalendarCore::Recurrence::rNone) {
169 r = mLoadedIncidence->recurrence();
173 switch (mLoadedIncidence->recurrenceType()) {
174 case KCalendarCore::Recurrence::rNone:
175 mUi->mRecurrenceTypeCombo->setCurrentIndex(RecurrenceTypeNone);
176 handleRecurrenceTypeChange(RecurrenceTypeNone);
178 case KCalendarCore::Recurrence::rDaily:
179 mUi->mRecurrenceTypeCombo->setCurrentIndex(RecurrenceTypeDaily);
180 handleRecurrenceTypeChange(RecurrenceTypeDaily);
183 case KCalendarCore::Recurrence::rWeekly: {
184 mUi->mRecurrenceTypeCombo->setCurrentIndex(RecurrenceTypeWeekly);
185 handleRecurrenceTypeChange(RecurrenceTypeWeekly);
188 disableDays.setBit(currentDate().dayOfWeek() - 1,
true);
189 mUi->mWeekDayCombo->setDays(r->
days(), disableDays);
193 case KCalendarCore::Recurrence::rMonthlyPos:
194 case KCalendarCore::Recurrence::rMonthlyDay:
195 mUi->mRecurrenceTypeCombo->setCurrentIndex(RecurrenceTypeMonthly);
196 handleRecurrenceTypeChange(RecurrenceTypeMonthly);
197 selectMonthlyItem(r, mLoadedIncidence->recurrenceType());
200 case KCalendarCore::Recurrence::rYearlyMonth:
201 case KCalendarCore::Recurrence::rYearlyPos:
202 case KCalendarCore::Recurrence::rYearlyDay:
203 mUi->mRecurrenceTypeCombo->setCurrentIndex(RecurrenceTypeYearly);
204 handleRecurrenceTypeChange(RecurrenceTypeYearly);
205 selectYearlyItem(r, mLoadedIncidence->recurrenceType());
212 if (mLoadedIncidence->recurs() && r) {
215 mUi->mRecurrenceEndDate->setDate(r->
endDate());
219 r = mLoadedIncidence->recurrence();
221 setExceptionDates(r->exDates());
223 if (!r->exDateTimes().isEmpty()) {
224 setExceptionDateTimes(r->exDateTimes());
225 }
else if (!r->exDates().isEmpty()) {
228 setExceptionDates(r->exDates());
229 setExDateTimesFromExDates(r, r->exDates());
233 handleDateTimeToggle();
243 const RecurrenceType recurrenceType = currentRecurrenceType();
245 if (recurrenceType == RecurrenceTypeException) {
246 incidence->setThisAndFuture(mUi->mThisAndFutureCheck->isChecked());
250 if (recurrenceType == RecurrenceTypeNone || !mUi->mRecurrenceTypeCombo->isEnabled()) {
254 const int lDuration = duration();
256 if (lDuration == 0) {
257 endDate = mUi->mRecurrenceEndDate->date();
260 if (recurrenceType == RecurrenceTypeDaily) {
261 r->
setDaily(mUi->mFrequencyEdit->value());
262 }
else if (recurrenceType == RecurrenceTypeWeekly) {
263 r->
setWeekly(mUi->mFrequencyEdit->value(), mUi->mWeekDayCombo->days());
264 }
else if (recurrenceType == RecurrenceTypeMonthly) {
267 if (mUi->mMonthlyCombo->currentIndex() == ComboIndexMonthlyDay) {
270 }
else if (mUi->mMonthlyCombo->currentIndex() == ComboIndexMonthlyDayInverted) {
273 }
else if (mUi->mMonthlyCombo->currentIndex() == ComboIndexMonthlyPos) {
280 }
else if (recurrenceType == RecurrenceTypeYearly) {
281 r->
setYearly(mUi->mFrequencyEdit->value());
283 if (mUi->mYearlyCombo->currentIndex() == ComboIndexYearlyMonth) {
287 }
else if (mUi->mYearlyCombo->currentIndex() == ComboIndexYearlyMonthInverted) {
291 }
else if (mUi->mYearlyCombo->currentIndex() == ComboIndexYearlyPos) {
295 }
else if (mUi->mYearlyCombo->currentIndex() == ComboIndexYearlyPosInverted) {
306 if (lDuration == 0) {
311 r->setExDates(mExceptionDates);
313 setExDateTimesFromExDates(r, mExceptionDates);
320 mMonthlyInitialType = mUi->mMonthlyCombo->currentIndex();
321 mYearlyInitialType = mUi->mYearlyCombo->currentIndex();
324bool IncidenceRecurrence::isDirty()
const
326 const RecurrenceType recurrenceType = currentRecurrenceType();
327 if (mLoadedIncidence->recurs() && recurrenceType == RecurrenceTypeNone) {
331 if (recurrenceType == RecurrenceTypeException) {
332 return mLoadedIncidence->thisAndFuture() != mUi->mThisAndFutureCheck->isChecked();
335 if (!mLoadedIncidence->recurs() && recurrenceType != IncidenceEditorNG::RecurrenceTypeNone) {
341 if (recurrenceType == RecurrenceTypeNone) {
347 case KCalendarCore::Recurrence::rDaily:
348 if (recurrenceType != RecurrenceTypeDaily || mUi->mFrequencyEdit->value() != recurrence->
frequency()) {
353 case KCalendarCore::Recurrence::rWeekly:
354 if (recurrenceType != RecurrenceTypeWeekly || mUi->mFrequencyEdit->value() != recurrence->
frequency()
355 || mUi->mWeekDayCombo->days() != recurrence->
days()) {
359 case KCalendarCore::Recurrence::rMonthlyDay:
360 if (recurrenceType != RecurrenceTypeMonthly || mUi->mFrequencyEdit->value() != recurrence->
frequency()
361 || mUi->mMonthlyCombo->currentIndex() != mMonthlyInitialType) {
365 case KCalendarCore::Recurrence::rMonthlyPos:
366 if (recurrenceType != RecurrenceTypeMonthly || mUi->mFrequencyEdit->value() != recurrence->
frequency()
367 || mUi->mMonthlyCombo->currentIndex() != mMonthlyInitialType) {
371 case KCalendarCore::Recurrence::rYearlyDay:
372 if (recurrenceType != RecurrenceTypeYearly || mUi->mFrequencyEdit->value() != recurrence->
frequency()
373 || mUi->mYearlyCombo->currentIndex() != mYearlyInitialType) {
377 case KCalendarCore::Recurrence::rYearlyMonth:
378 if (recurrenceType != RecurrenceTypeYearly || mUi->mFrequencyEdit->value() != recurrence->
frequency()
379 || mUi->mYearlyCombo->currentIndex() != mYearlyInitialType) {
383 case KCalendarCore::Recurrence::rYearlyPos:
384 if (recurrenceType != RecurrenceTypeYearly || mUi->mFrequencyEdit->value() != recurrence->
frequency()
385 || mUi->mYearlyCombo->currentIndex() != mYearlyInitialType) {
393 if (recurrence->
duration() == -1 && mUi->mRecurrenceEndCombo->currentIndex() != RecurrenceEndNever) {
395 }
else if (recurrence->
duration() == 0) {
397 if (mUi->mRecurrenceEndCombo->currentIndex() != RecurrenceEndOn || recurrence->
endDate() != mUi->mRecurrenceEndDate->date()) {
400 }
else if (recurrence->
duration() > 0) {
401 if (mUi->mEndDurationEdit->value() != recurrence->
duration() || mUi->mRecurrenceEndCombo->currentIndex() != RecurrenceEndAfter) {
407 if (recurrence->
allDay()) {
408 if (mExceptionDates != recurrence->exDates()) {
413 for (
const auto &dt : recurrence->exDateTimes()) {
416 if (mExceptionDates != dates) {
424void IncidenceRecurrence::focusInvalidField()
429 if (mUi->mRecurrenceEndCombo->currentIndex() == RecurrenceEndOn && !mUi->mRecurrenceEndDate->date().isValid()) {
430 mUi->mRecurrenceEndDate->setFocus();
435bool IncidenceRecurrence::isValid()
const
437 mLastErrorString.
clear();
438 if (currentRecurrenceType() == IncidenceEditorNG::RecurrenceTypeException) {
457 ||
incidence->recurrence()->getNextDateTime(referenceDate).isValid())) {
458 mLastErrorString =
i18n(
459 "A recurring event or to-do must occur at least once. "
460 "Adjust the recurring parameters.");
461 qCDebug(INCIDENCEEDITOR_LOG) << mLastErrorString;
465 mLastErrorString =
i18n(
"The incidence's start date is invalid.");
466 qCDebug(INCIDENCEEDITOR_LOG) << mLastErrorString;
470 if (mUi->mRecurrenceEndCombo->currentIndex() == RecurrenceEndOn && !mUi->mRecurrenceEndDate->date().isValid()) {
471 mLastErrorString =
i18nc(
"@info",
"The recurrence end date is invalid.");
472 qCDebug(INCIDENCEEDITOR_LOG) << mLastErrorString;
480void IncidenceRecurrence::addException()
482 const QDate date = mUi->mExceptionDateEdit->date();
484 qCWarning(INCIDENCEEDITOR_LOG) <<
"Refusing to add invalid date";
490 mExceptionDates.
append(date);
491 mUi->mExceptionList->addItem(dateStr);
494 mUi->mExceptionAddButton->setEnabled(
false);
498void IncidenceRecurrence::fillCombos()
500 if (!currentDate().isValid()) {
510 const int currentMonthlyIndex = mUi->mMonthlyCombo->currentIndex();
511 mUi->mMonthlyCombo->clear();
512 const QDate date = mDateTime->startDate();
515 mUi->mMonthlyCombo->addItem(item);
517 item = subsOrdinal(
ki18nc(
"example: the 4th to last day",
"the %1 to last day"), dayOfMonthFromEnd()).
toString();
518 mUi->mMonthlyCombo->addItem(item);
520 item = subsOrdinal(
ki18nc(
"example: the 5th Wednesday",
"the %1 %2"), monthWeekFromStart())
523 mUi->mMonthlyCombo->addItem(item);
525 if (monthWeekFromEnd() == 1) {
528 item = subsOrdinal(
ki18nc(
"example: the 5th to last Wednesday",
"the %1 to last %2"), monthWeekFromEnd())
532 mUi->mMonthlyCombo->addItem(item);
533 mUi->mMonthlyCombo->setCurrentIndex(currentMonthlyIndex == -1 ? 0 : currentMonthlyIndex);
541 const int currentYearlyIndex = mUi->mYearlyCombo->currentIndex();
542 mUi->mYearlyCombo->clear();
544 item = subsOrdinal(
ki18nc(
"example: the 5th of June",
"the %1 of %2"), date.
day()).
subs(longMonthName).
toString();
545 mUi->mYearlyCombo->addItem(item);
547 item = subsOrdinal(
ki18nc(
"example: the 3rd to last day of June",
"the %1 to last day of %2"), dayOfMonthFromEnd()).
subs(longMonthName).
toString();
548 mUi->mYearlyCombo->addItem(item);
550 item = subsOrdinal(
ki18nc(
"example: the 4th Wednesday of June",
"the %1 %2 of %3"), monthWeekFromStart())
554 mUi->mYearlyCombo->addItem(item);
556 if (monthWeekFromEnd() == 1) {
557 item =
ki18nc(
"example: the last Wednesday of June",
"the last %1 of %2")
562 item = subsOrdinal(
ki18nc(
"example: the 4th to last Wednesday of June",
"the %1 to last %2 of %3 "), monthWeekFromEnd())
567 mUi->mYearlyCombo->addItem(item);
569 item = subsOrdinal(
ki18nc(
"example: the 15th day of the year",
"the %1 day of the year"), date.
dayOfYear()).
toString();
570 mUi->mYearlyCombo->addItem(item);
571 mUi->mYearlyCombo->setCurrentIndex(currentYearlyIndex == -1 ? 0 : currentYearlyIndex);
574void IncidenceRecurrence::handleDateTimeToggle()
578 parent->setEnabled(mDateTime->startDateTimeEnabled());
582void IncidenceRecurrence::handleEndAfterOccurrencesChange(
int currentValue)
584 mUi->mRecurrenceOccurrencesLabel->setText(
i18ncp(
"Recurrence ends after n occurrences",
"occurrence",
"occurrences", currentValue));
587void IncidenceRecurrence::handleExceptionDateChange(
const QDate ¤tDate)
589 const QDate date = mUi->mExceptionDateEdit->date();
592 mUi->mExceptionAddButton->setEnabled(currentDate >= mDateTime->startDate() && mUi->mExceptionList->findItems(dateStr,
Qt::MatchExactly).isEmpty());
595void IncidenceRecurrence::handleFrequencyChange()
597 handleRecurrenceTypeChange(currentRecurrenceType());
600void IncidenceRecurrence::handleRecurrenceTypeChange(
int currentIndex)
602 toggleRecurrenceWidgets(currentIndex);
605 int frequency = mUi->mFrequencyEdit->value();
606 switch (currentIndex) {
608 labelFreq =
i18ncp(
"repeat every N >weeks<",
"week",
"weeks", frequency);
612 labelFreq =
i18ncp(
"repeat every N >months<",
"month",
"months", frequency);
616 labelFreq =
i18ncp(
"repeat every N >years<",
"year",
"years", frequency);
620 labelFreq =
i18ncp(
"repeat every N >days<",
"day",
"days", frequency);
625 "repeat >every< N years/months/...; "
626 "dynamic context 'type': 'd' days, 'w' weeks, "
627 "'m' months, 'y' years",
631 .
inContext(QStringLiteral(
"type"), freqKey)
633 mUi->mFrequencyLabel->setText(labelEvery);
634 mUi->mRecurrenceRuleLabel->setText(labelFreq);
636 Q_EMIT recurrenceChanged(
static_cast<RecurrenceType
>(currentIndex));
639void IncidenceRecurrence::removeExceptions()
643 const int row = mUi->mExceptionList->row(selectedException);
645 delete mUi->mExceptionList->takeItem(row);
648 handleExceptionDateChange(mUi->mExceptionDateEdit->date());
652void IncidenceRecurrence::updateRemoveExceptionButton()
654 mUi->mExceptionRemoveButton->setEnabled(!mUi->mExceptionList->selectedItems().isEmpty());
657void IncidenceRecurrence::updateWeekDays(
const QDate &newStartDate)
659 const int oldStartDayIndex = mUi->mWeekDayCombo->weekdayIndex(mCurrentDate);
660 const int newStartDayIndex = mUi->mWeekDayCombo->weekdayIndex(newStartDate);
662 if (oldStartDayIndex >= 0) {
663 mUi->mWeekDayCombo->setItemCheckState(oldStartDayIndex,
Qt::Unchecked);
664 mUi->mWeekDayCombo->setItemEnabled(oldStartDayIndex,
true);
667 if (newStartDayIndex >= 0) {
668 mUi->mWeekDayCombo->setItemCheckState(newStartDayIndex,
Qt::Checked);
669 mUi->mWeekDayCombo->setItemEnabled(newStartDayIndex,
false);
673 mCurrentDate = newStartDate;
677short IncidenceRecurrence::dayOfMonthFromStart()
const
679 return currentDate().
day();
682short IncidenceRecurrence::dayOfMonthFromEnd()
const
688short IncidenceRecurrence::dayOfYearFromStart()
const
693int IncidenceRecurrence::duration()
const
695 if (mUi->mRecurrenceEndCombo->currentIndex() == RecurrenceEndNever) {
697 }
else if (mUi->mRecurrenceEndCombo->currentIndex() == RecurrenceEndAfter) {
698 return mUi->mEndDurationEdit->value();
705short IncidenceRecurrence::monthWeekFromStart()
const
707 const QDate date = currentDate();
725short IncidenceRecurrence::monthWeekFromEnd()
const
727 const QDate date = currentDate();
745QString IncidenceRecurrence::numberToString(
int number)
const
750 static QString _numSuffixes[] = {QStringLiteral(
"th"),
751 QStringLiteral(
"st"),
752 QStringLiteral(
"nd"),
753 QStringLiteral(
"rd"),
754 QStringLiteral(
"th"),
755 QStringLiteral(
"th"),
756 QStringLiteral(
"th"),
757 QStringLiteral(
"th"),
758 QStringLiteral(
"th"),
759 QStringLiteral(
"th")};
762 int j = (i > 10 && i < 20) ? 0 : (
number % 10);
768 Q_ASSERT(recurenceType == KCalendarCore::Recurrence::rMonthlyPos || recurenceType == KCalendarCore::Recurrence::rMonthlyDay);
770 if (recurenceType == KCalendarCore::Recurrence::rMonthlyPos) {
776 if (rmp.
first().pos() > 0) {
780 mUi->mMonthlyCombo->setCurrentIndex(ComboIndexMonthlyPos);
786 mUi->mMonthlyCombo->setCurrentIndex(ComboIndexMonthlyPosInverted);
791 const int day = recurrence->
monthDays().isEmpty() ? currentDate().
day() : recurrence->
monthDays().at(0);
796 if (day > 0 && day <= 31) {
797 mUi->mMonthlyCombo->setCurrentIndex(ComboIndexMonthlyDay);
798 }
else if (day < 0) {
799 mUi->mMonthlyCombo->setCurrentIndex(ComboIndexMonthlyDayInverted);
804 mMonthlyInitialType = mUi->mMonthlyCombo->currentIndex();
809 Q_ASSERT(recurenceType == KCalendarCore::Recurrence::rYearlyDay || recurenceType == KCalendarCore::Recurrence::rYearlyMonth
810 || recurenceType == KCalendarCore::Recurrence::rYearlyPos);
812 if (recurenceType == KCalendarCore::Recurrence::rYearlyDay) {
818 mUi->mYearlyCombo->setCurrentIndex(ComboIndexYearlyDay);
819 }
else if (recurenceType == KCalendarCore::Recurrence::rYearlyMonth) {
820 const int day = recurrence->
yearDates().isEmpty() ? currentDate().
day() : recurrence->
yearDates().at(0);
832 mUi->mYearlyCombo->setCurrentIndex(ComboIndexYearlyMonth);
834 mUi->mYearlyCombo->setCurrentIndex(ComboIndexYearlyMonthInverted);
845 int count = (currentDate().
day() - 1) / 7;
853 mUi->mYearlyCombo->setCurrentIndex(ComboIndexYearlyPos);
855 mUi->mYearlyCombo->setCurrentIndex(ComboIndexYearlyPosInverted);
860 mYearlyInitialType = mUi->mYearlyCombo->currentIndex();
863void IncidenceRecurrence::setDefaults()
865 mUi->mRecurrenceEndCombo->setCurrentIndex(RecurrenceEndNever);
866 mUi->mRecurrenceEndDate->setDate(currentDate());
867 mUi->mRecurrenceTypeCombo->setCurrentIndex(RecurrenceTypeNone);
872 const int day = currentDate().
dayOfWeek() - 1;
875 checkDays.setBit(day);
878 disableDays.setBit(day);
880 mUi->mWeekDayCombo->setDays(checkDays, disableDays);
882 mUi->mMonthlyCombo->setCurrentIndex(0);
883 mUi->mYearlyCombo->setCurrentIndex(0);
886void IncidenceRecurrence::setDuration(
int duration)
888 if (duration == -1) {
889 mUi->mRecurrenceEndCombo->setCurrentIndex(RecurrenceEndNever);
890 mUi->mRecurrenceEndStack->setCurrentIndex(0);
891 }
else if (duration == 0) {
892 mUi->mRecurrenceEndCombo->setCurrentIndex(RecurrenceEndOn);
893 mUi->mRecurrenceEndStack->setCurrentIndex(1);
895 mUi->mRecurrenceEndCombo->setCurrentIndex(RecurrenceEndAfter);
896 mUi->mRecurrenceEndStack->setCurrentIndex(2);
897 mUi->mEndDurationEdit->setValue(duration);
903 mUi->mExceptionList->clear();
904 mExceptionDates.
clear();
905 for (
const auto &d : dates) {
907 mExceptionDates.
append(d);
913 mUi->mExceptionList->clear();
914 mExceptionDates.
clear();
915 for (
const auto &dt : dateTimes) {
918 mExceptionDates.
append(date);
922void IncidenceRecurrence::setFrequency(
int frequency)
928 mUi->mFrequencyEdit->setValue(frequency);
931void IncidenceRecurrence::toggleRecurrenceWidgets(
int recurrenceType)
933 bool enable = (recurrenceType != RecurrenceTypeNone) && (recurrenceType != RecurrenceTypeException);
934 mUi->mRecurrenceTypeCombo->setVisible(recurrenceType != RecurrenceTypeException);
935 mUi->mRepeatLabel->setVisible(recurrenceType != RecurrenceTypeException);
936 mUi->mRecurrenceEndLabel->setVisible(enable);
937 mUi->mOnLabel->setVisible(enable && recurrenceType != RecurrenceTypeDaily);
940 mUi->mRepeatLabel->setMinimumSize(mUi->mExceptionsLabel->sizeHint());
943 mUi->mFrequencyLabel->setVisible(enable);
944 mUi->mFrequencyEdit->setVisible(enable);
945 mUi->mRecurrenceRuleLabel->setVisible(enable);
946 mUi->mRepeatStack->setVisible(enable && recurrenceType != RecurrenceTypeDaily);
947 mUi->mRepeatStack->setCurrentIndex(recurrenceType);
948 mUi->mRecurrenceEndCombo->setVisible(enable);
949 mUi->mEndDurationEdit->setVisible(enable);
950 mUi->mRecurrenceEndStack->setVisible(enable);
953 mUi->mExceptionsLabel->setVisible(enable);
954 mUi->mExceptionDateEdit->setVisible(enable);
955 mUi->mExceptionAddButton->setVisible(enable);
956 mUi->mExceptionAddButton->setEnabled(mUi->mExceptionDateEdit->date() >= currentDate());
957 mUi->mExceptionRemoveButton->setVisible(enable);
958 mUi->mExceptionRemoveButton->setEnabled(!mUi->mExceptionList->selectedItems().isEmpty());
959 mUi->mExceptionList->setVisible(enable);
960 mUi->mThisAndFutureCheck->setVisible(recurrenceType == RecurrenceTypeException);
963QBitArray IncidenceRecurrence::weekday()
const
967 days.setBit(currentDate().dayOfWeek() - 1,
true);
971int IncidenceRecurrence::weekdayCountForMonth(
const QDate &date)
const
993RecurrenceType IncidenceRecurrence::currentRecurrenceType()
const
995 if (mLoadedIncidence && mLoadedIncidence->hasRecurrenceId()) {
996 return RecurrenceTypeException;
999 const int currentIndex = mUi->mRecurrenceTypeCombo->currentIndex();
1000 Q_ASSERT_X(currentIndex >= 0 && currentIndex < RecurrenceTypeUnknown,
"currentRecurrenceType",
"Keep the combo-box values in sync with the enum");
1001 return static_cast<RecurrenceType
>(currentIndex);
1004void IncidenceRecurrence::handleStartDateChange(
const QDate &date)
1006 if (currentDate().isValid()) {
1008 updateWeekDays(date);
1009 mUi->mExceptionDateEdit->setDate(date);
1013QDate IncidenceRecurrence::currentDate()
const
1015 return mDateTime->startDate();
1018#include "moc_incidencerecurrence.cpp"
void checkDirtyStatus()
Checks if the dirty status has changed until last check and emits the dirtyStatusChanged signal if ne...
QSharedPointer< IncidenceT > incidence() const
Convenience method to get a pointer for a specific const Incidence Type.
ushort recurrenceType() const
QList< RecurrenceRule::WDayPos > yearPositions() const
QList< int > yearDates() const
void addYearlyDay(int day)
void setWeekly(int freq, const QBitArray &days, int weekStart=1)
void setMonthly(int freq)
QList< int > monthDays() const
void addYearlyMonth(short _rNum)
void addMonthlyPos(short pos, const QBitArray &days)
void addYearlyDate(int date)
void addYearlyPos(short pos, const QBitArray &days)
QDateTime startDateTime() const
void setEndDate(const QDate &endDate)
void addMonthlyDate(short day)
QList< RecurrenceRule::WDayPos > monthPositions() const
void setDuration(int duration)
void dateChanged(const QDate &date)
KLocalizedString inContext(const QString &key, const QString &value) const
KLocalizedString subs(const KLocalizedString &a, int fieldWidth=0, QChar fillChar=QLatin1Char(' ')) const
void checkedItemsChanged(const QStringList &items)
Q_SCRIPTABLE Q_NOREPLY void start()
QString i18nc(const char *context, const char *text, const TYPE &arg...)
KLocalizedString KI18N_EXPORT ki18ncp(const char *context, const char *singular, const char *plural)
KLocalizedString KI18N_EXPORT ki18nc(const char *context, const char *text)
QString i18n(const char *text, const TYPE &arg...)
QString i18ncp(const char *context, const char *singular, const char *plural, const TYPE &arg...)
char * toString(const EngineQuery &query)
KIOCORE_EXPORT QString number(KIO::filesize_t size)
void currentIndexChanged(int index)
QDate addDays(qint64 ndays) const const
int dayOfWeek() const const
int dayOfYear() const const
bool isValid(int year, int month, int day)
bool isValid() const const
QTimeZone timeZone() const const
QDateTime toLocalTime() const const
QDateTime toTimeZone(const QTimeZone &timeZone) const const
void append(QList< T > &&value)
qsizetype count() const const
bool isEmpty() const const
void removeAt(qsizetype i)
void reserve(qsizetype size)
QString monthName(int month, FormatType type) const const
QString toString(QDate date, FormatType format) const const
QObject * parent() const const
QString number(double n, char format, int precision)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)