41 #include <kalarmcal/kaevent.h>
42 #include <kalarmcal/karecurrence.h>
45 #include <kcalcore/event.h>
46 using namespace KCalCore;
48 #include <kcal/event.h>
54 #include <kcalendarsystem.h>
55 #include <kiconloader.h>
57 #include <kmessagebox.h>
59 #include <kdatecombobox.h>
61 #include <QPushButton>
63 #include <QStackedWidget>
64 #include <QListWidget>
66 #include <QGridLayout>
67 #include <QHBoxLayout>
68 #include <QVBoxLayout>
69 #include <QtAlgorithms>
76 virtual QSize sizeHint()
const {
return minimumSizeHint(); }
93 mRuleButtonType(INVALID_RECUR),
98 mNoEmitTypeChanged(true),
104 topLayout->
setSpacing(KDialog::spacingHint());
113 QGroupBox* recurGroup =
new QGroupBox(i18nc(
"@title:group",
"Recurrence Rule"),
this);
116 hlayout->
setMargin(KDialog::marginHint());
131 mNoneButton->
setWhatsThis(i18nc(
"@info:whatsthis",
"Do not repeat the alarm"));
132 mRuleButtonGroup->
addButton(mNoneButton);
139 "<para>Trigger the alarm at the specified date/time and at every login until then.</para>"
140 "<para>Note that it will also be triggered any time <application>KAlarm</application> is restarted.</para>"));
141 mRuleButtonGroup->
addButton(mAtLoginButton);
147 mSubDailyButton->
setWhatsThis(i18nc(
"@info:whatsthis",
"Repeat the alarm at hourly/minutely intervals"));
148 mRuleButtonGroup->
addButton(mSubDailyButton);
154 mDailyButton->
setWhatsThis(i18nc(
"@info:whatsthis",
"Repeat the alarm at daily intervals"));
155 mRuleButtonGroup->
addButton(mDailyButton);
161 mWeeklyButton->
setWhatsThis(i18nc(
"@info:whatsthis",
"Repeat the alarm at weekly intervals"));
162 mRuleButtonGroup->
addButton(mWeeklyButton);
168 mMonthlyButton->
setWhatsThis(i18nc(
"@info:whatsthis",
"Repeat the alarm at monthly intervals"));
169 mRuleButtonGroup->
addButton(mMonthlyButton);
175 mYearlyButton->
setWhatsThis(i18nc(
"@info:whatsthis",
"Repeat the alarm at annual intervals"));
176 mRuleButtonGroup->
addButton(mYearlyButton);
181 mSubRepetition =
new RepetitionButton(i18nc(
"@action:button",
"Sub-Repetition"),
true, recurGroup);
185 "Set up a repetition within the recurrence, to trigger the alarm multiple times each time the recurrence is due."));
204 mNoRule =
new NoRule(mRuleStack);
205 mSubDailyRule =
new SubDailyRule(mReadOnly, mRuleStack);
206 mDailyRule =
new DailyRule(mReadOnly, mRuleStack);
207 mWeeklyRule =
new WeeklyRule(mReadOnly, mRuleStack);
208 mMonthlyRule =
new MonthlyRule(mReadOnly, mRuleStack);
209 mYearlyRule =
new YearlyRule(mReadOnly, mRuleStack);
233 mRangeButtonBox =
new QGroupBox(i18nc(
"@title:group",
"Recurrence End"),
this);
235 mRangeButtonGroup =
new ButtonGroup(mRangeButtonBox);
240 vlayout->
setMargin(KDialog::marginHint());
242 mNoEndDateButton =
new RadioButton(i18nc(
"@option:radio",
"No end"), mRangeButtonBox);
245 mNoEndDateButton->
setWhatsThis(i18nc(
"@info:whatsthis",
"Repeat the alarm indefinitely"));
246 mRangeButtonGroup->
addButton(mNoEndDateButton);
247 vlayout->
addWidget(mNoEndDateButton, 1, Qt::AlignLeft);
253 mRepeatCountButton =
new RadioButton(i18nc(
"@option:radio",
"End after:"), mRangeButtonBox);
255 mRepeatCountButton->
setWhatsThis(i18nc(
"@info:whatsthis",
"Repeat the alarm for the number of times specified"));
256 mRangeButtonGroup->
addButton(mRepeatCountButton);
257 mRepeatCountEntry =
new SpinBox(1, 9999, mRangeButtonBox);
259 mRepeatCountEntry->setSingleShiftStep(10);
260 mRepeatCountEntry->setSelectOnStep(
false);
262 mRepeatCountEntry->
setWhatsThis(i18nc(
"@info:whatsthis",
"Enter the total number of times to trigger the alarm"));
263 connect(mRepeatCountEntry, SIGNAL(valueChanged(
int)), SLOT(repeatCountChanged(
int)));
266 mRepeatCountLabel =
new QLabel(i18nc(
"@label",
"occurrence(s)"), mRangeButtonBox);
278 mEndDateButton =
new RadioButton(i18nc(
"@option:radio",
"End by:"), mRangeButtonBox);
281 i18nc(
"@info:whatsthis",
"<para>Repeat the alarm until the date/time specified.</para>"
282 "<para><note>This applies to the main recurrence only. It does not limit any sub-repetition which will occur regardless after the last main recurrence.</note></para>"));
283 mRangeButtonGroup->
addButton(mEndDateButton);
284 mEndDateEdit =
new KDateComboBox(mRangeButtonBox);
285 mEndDateEdit->setOptions(mReadOnly ? KDateComboBox::Options(0) : KDateComboBox::EditDate | KDateComboBox::SelectDate | KDateComboBox::DatePicker);
286 static const QString tzText = i18nc(
"@info/plain",
"This uses the same time zone as the start time.");
287 mEndDateEdit->setWhatsThis(i18nc(
"@info:whatsthis",
288 "<para>Enter the last date to repeat the alarm.</para><para>%1</para>", tzText));
291 mEndTimeEdit =
new TimeEdit(mRangeButtonBox);
292 mEndTimeEdit->setFixedSize(mEndTimeEdit->sizeHint());
294 mEndTimeEdit->setWhatsThis(i18nc(
"@info:whatsthis",
297 mEndAnyTimeCheckBox =
new CheckBox(i18nc(
"@option:check",
"Any time"), mRangeButtonBox);
300 mEndAnyTimeCheckBox->
setWhatsThis(i18nc(
"@info:whatsthis",
"Stop repeating the alarm after your first login on or after the specified end date"));
301 connect(mEndAnyTimeCheckBox, SIGNAL(toggled(
bool)), SLOT(slotAnyTimeToggled(
bool)));
318 mExceptionGroup =
new QGroupBox(i18nc(
"@title:group",
"Exceptions"),
this);
322 hlayout->
setMargin(KDialog::marginHint());
328 mExceptionDateList =
new ListWidget(mExceptionGroup);
329 mExceptionDateList->
setWhatsThis(i18nc(
"@info:whatsthis",
"The list of exceptions, i.e. dates/times excluded from the recurrence"));
330 connect(mExceptionDateList, SIGNAL(currentRowChanged(
int)), SLOT(enableExceptionButtons()));
335 mExceptionDateEdit = 0;
336 mChangeExceptionButton = 0;
337 mDeleteExceptionButton = 0;
344 mExceptionDateEdit =
new KDateComboBox(mExceptionGroup);
345 mExceptionDateEdit->setOptions(mReadOnly ? KDateComboBox::Options(0) : KDateComboBox::EditDate | KDateComboBox::SelectDate | KDateComboBox::DatePicker);
346 mExceptionDateEdit->setDate(KDateTime::currentLocalDate());
347 mExceptionDateEdit->setWhatsThis(i18nc(
"@info:whatsthis",
348 "Enter a date to insert in the exceptions list. "
349 "Use in conjunction with the Add or Change button below."));
350 vlayout->
addWidget(mExceptionDateEdit, 0, Qt::AlignLeft);
356 button->
setWhatsThis(i18nc(
"@info:whatsthis",
"Add the date entered above to the exceptions list"));
357 connect(button, SIGNAL(clicked()), SLOT(addException()));
360 mChangeExceptionButton =
new QPushButton(i18nc(
"@action:button",
"Change"), mExceptionGroup);
361 mChangeExceptionButton->
setWhatsThis(i18nc(
"@info:whatsthis",
362 "Replace the currently highlighted item in the exceptions list with the date entered above"));
363 connect(mChangeExceptionButton, SIGNAL(clicked()), SLOT(changeException()));
364 hlayout->
addWidget(mChangeExceptionButton);
366 mDeleteExceptionButton =
new QPushButton(i18nc(
"@action:button",
"Delete"), mExceptionGroup);
367 mDeleteExceptionButton->
setWhatsThis(i18nc(
"@info:whatsthis",
"Remove the currently highlighted item from the exceptions list"));
368 connect(mDeleteExceptionButton, SIGNAL(clicked()), SLOT(deleteException()));
369 hlayout->
addWidget(mDeleteExceptionButton);
374 mExcludeHolidays =
new CheckBox(i18nc(
"@option:check",
"Exclude holidays"), mExceptionGroup);
377 "<para>Do not trigger the alarm on holidays.</para>"
378 "<para>You can specify your holiday region in the Configuration dialog.</para>"));
382 mWorkTimeOnly =
new CheckBox(i18nc(
"@option:check",
"Only during working time"), mExceptionGroup);
385 "<para>Only execute the alarm during working hours, on working days.</para>"
386 "<para>You can specify working days and hours in the Configuration dialog.</para>"));
391 mNoEmitTypeChanged =
false;
400 mExceptionGroup->
show();
402 mExceptionGroup->
hide();
414 const_cast<RecurrenceEdit*
>(
this)->mCurrStartDateTime = startDateTime;
419 bool noTime = !mEndTimeEdit->isEnabled();
420 QDate endDate = mEndDateEdit->date();
421 if (endDate < startDateTime.date())
422 errWidget = mEndDateEdit;
423 else if (!noTime &&
QDateTime(endDate, mEndTimeEdit->
time()) < startDateTime.dateTime())
424 errWidget = mEndTimeEdit;
427 errorMessage = noTime
428 ? i18nc(
"@info",
"End date is earlier than start date")
429 : i18nc(
"@info",
"End date/time is earlier than start date/time");
435 return mRule->
validate(errorMessage);
444 bool none = (button == mNoneButton);
445 bool atLogin = (button == mAtLoginButton);
446 bool subdaily = (button == mSubDailyButton);
460 mRule = mSubDailyRule;
463 else if (button == mDailyButton)
466 mRuleButtonType =
DAILY;
469 else if (button == mWeeklyButton)
475 else if (button == mMonthlyButton)
477 mRule = mMonthlyRule;
479 mMonthlyShown =
true;
481 else if (button == mYearlyButton)
490 if (mRuleButtonType != oldType)
495 mExceptionGroup->
setEnabled(!(none || atLogin));
503 mSubRepetition->
setEnabled(!(none || atLogin));
504 if (!mNoEmitTypeChanged)
509 void RecurrenceEdit::slotAnyTimeToggled(
bool on)
512 mEndTimeEdit->setEnabled((button == mAtLoginButton && !on)
513 || (button == mSubDailyButton && mEndDateButton->
isChecked()));
519 void RecurrenceEdit::rangeTypeClicked()
521 bool endDate = mEndDateButton->
isChecked();
522 mEndDateEdit->setEnabled(endDate);
523 mEndTimeEdit->setEnabled(endDate
526 bool repeatCount = mRepeatCountButton->
isChecked();
560 switch (mRuleButtonType)
570 maxDuration =
event.longestRecurrenceInterval().asSeconds()/60 - reminderMinutes - 1;
590 void RecurrenceEdit::repeatCountChanged(
int value)
592 if (value > 0 && mRepeatCountEntry->
minimum() == 0)
600 void RecurrenceEdit::addException()
602 if (!mExceptionDateEdit || !mExceptionDateEdit->date().isValid())
605 DateList::Iterator it;
608 for (it = mExceptionDates.
begin(); it != mExceptionDates.
end(); ++index, ++it)
612 insert = (date != *it);
618 mExceptionDates.
insert(it, date);
623 enableExceptionButtons();
630 void RecurrenceEdit::changeException()
632 if (!mExceptionDateEdit || !mExceptionDateEdit->date().isValid())
637 int index = mExceptionDateList->
row(item);
638 QDate olddate = mExceptionDates[index];
639 QDate newdate = mExceptionDateEdit->date();
640 if (newdate != olddate)
643 mExceptionDateList->
takeItem(index);
653 void RecurrenceEdit::deleteException()
658 int index = mExceptionDateList->
row(item);
660 mExceptionDateList->
takeItem(index);
662 enableExceptionButtons();
670 void RecurrenceEdit::enableExceptionButtons()
674 if (mDeleteExceptionButton)
676 if (mChangeExceptionButton)
680 mExceptionDateList->
setFocusPolicy(mExceptionDateList->
count() ? Qt::WheelFocus : Qt::NoFocus);
690 setRuleDefaults(start);
693 mEndDateEdit->setMinimumDate(today);
694 if (mExceptionDateEdit)
695 mExceptionDateEdit->setMinimumDate(today);
699 const QString startString = i18nc(
"@info",
"Date cannot be earlier than start date");
700 mEndDateEdit->setMinimumDate(start, startString);
701 if (mExceptionDateEdit)
702 mExceptionDateEdit->setMinimumDate(start, startString);
713 mEndDateEdit->setDate(end);
718 KDateTime edt = end.toTimeSpec(mCurrStartDateTime.timeSpec());
719 mEndDateEdit->setDate(edt.date());
721 mEndTimeEdit->setEnabled(!end.isDateOnly());
722 mEndAnyTimeCheckBox->
setChecked(end.isDateOnly());
728 return KDateTime(mEndDateEdit->date(), mCurrStartDateTime.timeSpec());
729 return KDateTime(mEndDateEdit->date(), mEndTimeEdit->
time(), mCurrStartDateTime.timeSpec());
737 mCurrStartDateTime =
from;
738 QDate fromDate = from.date();
747 setRuleDefaults(fromDate);
751 mEndDateEdit->setDate(fromDate);
753 mNoEmitTypeChanged =
true;
755 switch (Preferences::defaultRecurPeriod())
757 case AT_LOGIN: button = mAtLoginButton;
break;
758 case ANNUAL: button = mYearlyButton;
break;
759 case MONTHLY: button = mMonthlyButton;
break;
760 case WEEKLY: button = mWeeklyButton;
break;
761 case DAILY: button = mDailyButton;
break;
762 case SUBDAILY: button = mSubDailyButton;
break;
764 default: button = mNoneButton;
break;
767 mNoEmitTypeChanged =
false;
769 enableExceptionButtons();
778 void RecurrenceEdit::setRuleDefaults(
const QDate& fromDate)
780 int day = fromDate.
day();
782 int month = fromDate.
month();
786 mWeeklyRule->
setDay(dayOfWeek);
809 if (event.repeatAtLogin())
816 KARecurrence* recurrence =
event.recurrence();
819 KARecurrence::Type rtype = recurrence->type();
822 case KARecurrence::MINUTELY:
826 case KARecurrence::DAILY:
831 for (
int i = 0; i < 7 && !
set; ++i)
839 case KARecurrence::WEEKLY:
846 case KARecurrence::MONTHLY_POS:
849 int i = posns.
first().pos();
857 for (
int i = 0, end = posns.
count(); i < end; ++i)
860 rDays.
setBit(posns[i].day() - 1, 1);
869 case KARecurrence::MONTHLY_DAY:
873 int day = (rmd.
isEmpty()) ? event.mainDateTime().date().day() : rmd.
first();
877 case KARecurrence::ANNUAL_DATE:
878 case KARecurrence::ANNUAL_POS:
880 if (rtype == KARecurrence::ANNUAL_DATE)
883 const QList<int> rmd = recurrence->monthDays();
884 int day = (rmd.
isEmpty()) ? event.mainDateTime().date().day() : rmd.
first();
888 else if (rtype == KARecurrence::ANNUAL_POS)
894 mYearlyRule->
setMonths(recurrence->yearMonths());
904 KDateTime endtime = mCurrStartDateTime;
905 int duration = recurrence->duration();
911 mRepeatCountEntry->
setValue(duration);
916 endtime = recurrence->endDateTime();
917 mEndTimeEdit->
setValue(endtime.time());
919 mEndDateEdit->setDate(endtime.date());
922 mExceptionDates =
event.recurrence()->exDates();
923 qSort(mExceptionDates);
924 mExceptionDateList->
clear();
925 for (
int i = 0, iend = mExceptionDates.
count(); i < iend; ++i)
926 new QListWidgetItem(KGlobal::locale()->formatDate(mExceptionDates[i]), mExceptionDateList);
927 enableExceptionButtons();
928 mExcludeHolidays->
setChecked(event.holidaysExcluded());
929 mWorkTimeOnly->
setChecked(event.workTimeOnly());
932 mSubRepetition->
set(event.repetition());
952 else if (mRepeatCountButton->
isChecked())
953 repeatCount = mRepeatCountEntry->
value();
957 endDate = mEndDateEdit->date();
958 endTime = mEndTimeEdit->
time();
962 event.startChanges();
964 event.setRepeatAtLogin(button == mAtLoginButton);
965 int frequency = mRule ? mRule->
frequency() : 0;
966 if (button == mSubDailyButton)
968 KDateTime
endDateTime(endDate, endTime, mCurrStartDateTime.timeSpec());
969 event.setRecurMinutely(frequency, repeatCount,
endDateTime);
971 else if (button == mDailyButton)
973 event.setRecurDaily(frequency, mDailyRule->
days(), repeatCount, endDate);
975 else if (button == mWeeklyButton)
977 event.setRecurWeekly(frequency, mWeeklyRule->
days(), repeatCount, endDate);
979 else if (button == mMonthlyButton)
984 KAEvent::MonthPos
pos;
985 pos.days.fill(
false);
986 pos.days.setBit(mMonthlyRule->
dayOfWeek() - 1);
987 pos.weeknum = mMonthlyRule->
week();
989 event.setRecurMonthlyByPos(frequency, poses, repeatCount, endDate);
994 int daynum = mMonthlyRule->
date();
996 event.setRecurMonthlyByDate(frequency, daynums, repeatCount, endDate);
999 else if (button == mYearlyButton)
1005 KAEvent::MonthPos
pos;
1006 pos.days.fill(
false);
1007 pos.days.setBit(mYearlyRule->
dayOfWeek() - 1);
1008 pos.weeknum = mYearlyRule->
week();
1010 event.setRecurAnnualByPos(frequency, poses, months, repeatCount, endDate);
1015 event.setRecurAnnualByDate(frequency, months, mYearlyRule->
date(),
1016 mYearlyRule->
feb29Type(), repeatCount, endDate);
1025 if (!event.recurs())
1031 event.setFirstRecurrence();
1035 event.setRepetition((mRuleButtonType <
SUBDAILY) ? Repetition() : mSubRepetition->
repetition());
1038 event.recurrence()->setExDates(mExceptionDates);
1039 event.setWorkTimeOnly(mWorkTimeOnly->
isChecked());
1040 event.setExcludeHolidays(mExcludeHolidays->
isChecked());
1048 void RecurrenceEdit::saveState()
1054 if (mSavedRangeButton == mRepeatCountButton)
1055 mSavedRecurCount = mRepeatCountEntry->
value();
1056 else if (mSavedRangeButton == mEndDateButton)
1058 mSavedEndDateTime = KDateTime(
QDateTime(mEndDateEdit->date(), mEndTimeEdit->
time()), mCurrStartDateTime.timeSpec());
1059 mSavedEndDateTime.setDateOnly(mEndAnyTimeCheckBox->
isChecked());
1061 mSavedExceptionDates = mExceptionDates;
1062 mSavedWorkTimeOnly = mWorkTimeOnly->
isChecked();
1063 mSavedExclHolidays = mExcludeHolidays->
isChecked();
1064 mSavedRepetition = mSubRepetition->
repetition();
1076 if (mSavedRangeButton == mRepeatCountButton
1077 && mSavedRecurCount != mRepeatCountEntry->
value())
1079 if (mSavedRangeButton == mEndDateButton)
1081 KDateTime edt(
QDateTime(mEndDateEdit->date(), mEndTimeEdit->
time()), mCurrStartDateTime.timeSpec());
1082 edt.setDateOnly(mEndAnyTimeCheckBox->
isChecked());
1083 if (mSavedEndDateTime != edt)
1086 if (mSavedExceptionDates != mExceptionDates
1087 || mSavedWorkTimeOnly != mWorkTimeOnly->
isChecked()
1088 || mSavedExclHolidays != mExcludeHolidays->
isChecked()
1089 || mSavedRepetition != mSubRepetition->
repetition())
1108 freqBox->setMargin(0);
1109 mLayout->
addWidget(freqBox, 0, Qt::AlignLeft);
1112 box->setSpacing(KDialog::spacingHint());
1114 QLabel* label =
new QLabel(i18nc(
"@label:spinbox",
"Recur e&very"), box);
1119 mSpinBox = mTimeSpinBox =
new TimeSpinBox(1, 5999, box);
1126 mSpinBox = mIntSpinBox =
new SpinBox(1, 999, box);
1133 label =
new QLabel(freqText, box);
1136 box->setWhatsThis(freqWhatsThis);
1139 freqBox->setFixedHeight(freqBox->sizeHint().height());
1140 freqBox->setFocusProxy(mSpinBox);
1146 return mIntSpinBox->
value();
1148 return mTimeSpinBox->
value();
1173 return (mSavedFrequency !=
frequency());
1183 :
Rule(i18nc(
"@label Time units for user-entered numbers",
"hours:minutes"),
1184 i18nc(
"@info:whatsthis",
"Enter the number of hours and minutes between repetitions of the alarm"),
1185 true, readOnly, parent)
1195 bool readOnly,
QWidget* parent)
1196 :
Rule(freqText, freqWhatsThis, false, readOnly, parent),
1204 QLabel* label =
new QLabel(i18nc(
"@label On: Tuesday",
"O&n:"),
this);
1206 grid->
addWidget(label, 0, 0, Qt::AlignRight | Qt::AlignTop);
1215 const KCalendarSystem* calendar = KGlobal::locale()->calendar();
1216 for (
int i = 0; i < 7; ++i)
1219 mDayBox[i] =
new CheckBox(calendar->weekDayName(day), box);
1223 dgrid->
addWidget(mDayBox[i], i%4, i/4, Qt::AlignLeft);
1227 grid->
addWidget(box, 0, 2, Qt::AlignLeft);
1239 for (
int i = 0; i < 7; ++i)
1240 if (mDayBox[i]->isChecked())
1250 for (
int i = 0; i < 7; ++i)
1251 mDayBox[i]->setChecked(tick);
1259 for (
int i = 0; i < 7; ++i)
1271 for (
int i = 0; i < 7; ++i)
1272 mDayBox[i]->setChecked(
false);
1273 if (dayOfWeek > 0 && dayOfWeek <= 7)
1282 for (
int i = 0; i < 7; ++i)
1283 if (mDayBox[i]->isChecked())
1285 errorMessage = i18nc(
"@info",
"No day selected");
1295 mSavedDays =
days();
1304 || mSavedDays !=
days());
1314 :
DayWeekRule(i18nc(
"@label Time unit for user-entered number",
"day(s)"),
1315 i18nc(
"@info:whatsthis",
"Enter the number of days between repetitions of the alarm"),
1316 i18nc(
"@info:whatsthis",
"Select the days of the week on which the alarm is allowed to occur"),
1327 :
DayWeekRule(i18nc(
"@label Time unit for user-entered number",
"week(s)"),
1328 i18nc(
"@info:whatsthis",
"Enter the number of weeks between repetitions of the alarm"),
1329 i18nc(
"@info:whatsthis",
"Select the days of the week on which to repeat the alarm"),
1340 bool readOnly,
QWidget* parent)
1341 :
Rule(freqText, freqWhatsThis, false, readOnly, parent),
1342 mEveryWeek(allowEveryWeek)
1350 mDayButton =
new RadioButton(i18nc(
"@option:radio On day number in the month",
"O&n day"),
this);
1354 mDayButton->
setWhatsThis(i18nc(
"@info:whatsthis",
"Repeat the alarm on the selected day of the month"));
1358 mDayCombo->setEditable(
false);
1359 mDayCombo->setMaxVisibleItems(11);
1360 for (
int i = 0; i < 31; ++i)
1362 mDayCombo->addItem(i18nc(
"@item:inlistbox Last day of month",
"Last"));
1363 mDayCombo->setFixedSize(mDayCombo->sizeHint());
1365 mDayCombo->setWhatsThis(i18nc(
"@info:whatsthis",
"Select the day of the month on which to repeat the alarm"));
1367 connect(mDayCombo, SIGNAL(activated(
int)), SLOT(slotDaySelected(
int)));
1368 connect(mDayCombo, SIGNAL(currentIndexChanged(
int)), SIGNAL(
changed()));
1369 boxLayout->
addWidget(mDayCombo, 0, 1, 1, 2, Qt::AlignLeft);
1372 mPosButton =
new RadioButton(i18nc(
"@option:radio On the 1st Tuesday",
"On t&he"),
this);
1376 mPosButton->
setWhatsThis(i18nc(
"@info:whatsthis",
"Repeat the alarm on one day of the week, in the selected week of the month"));
1380 mWeekCombo->setEditable(
false);
1381 mWeekCombo->addItem(i18nc(
"@item:inlistbox",
"1st"));
1382 mWeekCombo->addItem(i18nc(
"@item:inlistbox",
"2nd"));
1383 mWeekCombo->addItem(i18nc(
"@item:inlistbox",
"3rd"));
1384 mWeekCombo->addItem(i18nc(
"@item:inlistbox",
"4th"));
1385 mWeekCombo->addItem(i18nc(
"@item:inlistbox",
"5th"));
1386 mWeekCombo->addItem(i18nc(
"@item:inlistbox Last Monday in March",
"Last"));
1387 mWeekCombo->addItem(i18nc(
"@item:inlistbox",
"2nd Last"));
1388 mWeekCombo->addItem(i18nc(
"@item:inlistbox",
"3rd Last"));
1389 mWeekCombo->addItem(i18nc(
"@item:inlistbox",
"4th Last"));
1390 mWeekCombo->addItem(i18nc(
"@item:inlistbox",
"5th Last"));
1393 mWeekCombo->addItem(i18nc(
"@item:inlistbox Every (Monday...) in month",
"Every"));
1394 mWeekCombo->setMaxVisibleItems(11);
1396 mWeekCombo->setWhatsThis(i18nc(
"@info:whatsthis",
"Select the week of the month in which to repeat the alarm"));
1397 mWeekCombo->setFixedSize(mWeekCombo->sizeHint());
1400 connect(mWeekCombo, SIGNAL(currentIndexChanged(
int)), SIGNAL(
changed()));
1403 mDayOfWeekCombo =
new ComboBox(
this);
1404 mDayOfWeekCombo->setEditable(
false);
1405 const KCalendarSystem* calendar = KGlobal::locale()->calendar();
1406 for (
int i = 0; i < 7; ++i)
1409 mDayOfWeekCombo->addItem(calendar->weekDayName(day));
1412 mDayOfWeekCombo->setWhatsThis(i18nc(
"@info:whatsthis",
"Select the day of the week on which to repeat the alarm"));
1413 connect(mDayOfWeekCombo, SIGNAL(currentIndexChanged(
int)), SIGNAL(
changed()));
1414 boxLayout->
addWidget(mDayOfWeekCombo, 1, 2, Qt::AlignLeft);
1436 mDayCombo->setCurrentIndex(dayOfMonth);
1437 mWeekCombo->setCurrentIndex(dayOfMonth / 7);
1443 int daynum = mDayCombo->currentIndex() + 1;
1444 return (daynum <= 31) ? daynum : 31 - daynum;
1449 int weeknum = mWeekCombo->currentIndex() + 1;
1450 return (weeknum <= 5) ? weeknum : (weeknum == 11) ? 0 : 5 - weeknum;
1461 mDayCombo->setCurrentIndex(dayOfMonth > 0 ? dayOfMonth - 1 : dayOfMonth < 0 ? 30 - dayOfMonth : 0);
1467 mWeekCombo->setCurrentIndex((week > 0) ? week - 1 : (week < 0) ? 4 - week : mEveryWeek ? 10 : 0);
1471 void MonthYearRule::enableSelection(DayPosType type)
1473 bool date = (type ==
DATE);
1474 mDayCombo->setEnabled(date);
1475 mWeekCombo->setEnabled(!date);
1476 mDayOfWeekCombo->setEnabled(!date);
1481 enableSelection(button == mDayButton ?
DATE :
POS);
1484 void MonthYearRule::slotDaySelected(
int index)
1486 daySelected(index <= 30 ? index + 1 : 30 - index);
1495 mSavedType =
type();
1496 if (mSavedType ==
DATE)
1500 mSavedWeek =
week();
1511 || mSavedType !=
type())
1513 if (mSavedType ==
DATE)
1515 if (mSavedDay !=
date())
1520 if (mSavedWeek !=
week()
1534 :
MonthYearRule(i18nc(
"@label Time unit for user-entered number",
"month(s)"),
1535 i18nc(
"@info:whatsthis",
"Enter the number of months between repetitions of the alarm"),
1536 false, readOnly, parent)
1546 :
MonthYearRule(i18nc(
"@label Time unit for user-entered number",
"year(s)"),
1547 i18nc(
"@info:whatsthis",
"Enter the number of years between repetitions of the alarm"),
1548 true, readOnly, parent)
1554 QLabel* label =
new QLabel(i18nc(
"@label List of months to select",
"Months:"),
this);
1556 hlayout->
addWidget(label, 0, Qt::AlignLeft | Qt::AlignTop);
1560 hlayout->
addWidget(w, 1, Qt::AlignLeft);
1564 const KCalendarSystem* calendar = KGlobal::locale()->calendar();
1565 int year = KDateTime::currentLocalDate().year();
1566 for (
int i = 0; i < 12; ++i)
1568 mMonthBox[i] =
new CheckBox(calendar->monthName(i + 1, year, KCalendarSystem::ShortName), w);
1572 grid->
addWidget(mMonthBox[i], i%3, i/3, Qt::AlignLeft);
1574 connect(mMonthBox[1], SIGNAL(toggled(
bool)), SLOT(enableFeb29()));
1576 w->
setWhatsThis(i18nc(
"@info:whatsthis",
"Select the months of the year in which to repeat the alarm"));
1580 f29box->setMargin(0);
1584 box->setSpacing(KDialog::spacingHint());
1585 mFeb29Label =
new QLabel(i18nc(
"@label:listbox",
"February 2&9th alarm in non-leap years:"), box);
1588 mFeb29Combo->setEditable(
false);
1589 mFeb29Combo->addItem(i18nc(
"@item:inlistbox No date",
"None"));
1590 mFeb29Combo->addItem(i18nc(
"@item:inlistbox 1st March (short form)",
"1 Mar"));
1591 mFeb29Combo->addItem(i18nc(
"@item:inlistbox 28th February (short form)",
"28 Feb"));
1592 mFeb29Combo->setFixedSize(mFeb29Combo->sizeHint());
1594 connect(mFeb29Combo, SIGNAL(currentIndexChanged(
int)), SIGNAL(
changed()));
1595 mFeb29Label->
setBuddy(mFeb29Combo);
1596 box->setFixedSize(box->sizeHint());
1597 box->setWhatsThis(i18nc(
"@info:whatsthis",
"Select which date, if any, the February 29th alarm should trigger in non-leap years"));
1599 f29box->setFixedHeight(f29box->sizeHint().height());
1606 for (
int i = 0; i < 12; ++i)
1607 mMonthBox[i]->setChecked(i == month);
1619 for (
int i = 0; i < 12; ++i)
1620 if (mMonthBox[i]->isChecked() && mMonthBox[i]->
isEnabled())
1631 for (
int i = 0; i < 12; ++i)
1633 for (
int i = 0, end = mnths.
count(); i < end; ++i)
1634 checked[mnths[i] - 1] =
true;
1635 for (
int i = 0; i < 12; ++i)
1636 mMonthBox[i]->setChecked(checked[i]);
1645 if (mFeb29Combo->isEnabled())
1647 switch (mFeb29Combo->currentIndex())
1649 case 1:
return KARecurrence::Feb29_Mar1;
1650 case 2:
return KARecurrence::Feb29_Feb28;
1654 return KARecurrence::Feb29_None;
1666 case KARecurrence::Feb29_None: index = 0;
break;
1667 case KARecurrence::Feb29_Mar1: index = 1;
break;
1668 case KARecurrence::Feb29_Feb28: index = 2;
break;
1670 mFeb29Combo->setCurrentIndex(index);
1678 for (
int i = 0; i < 12; ++i)
1679 if (mMonthBox[i]->isChecked() && mMonthBox[i]->
isEnabled())
1681 errorMessage = i18nc(
"@info",
"No month selected");
1682 return mMonthBox[0];
1702 bool enable = (day != 31);
1714 void YearlyRule::enableFeb29()
1718 mFeb29Combo->setEnabled(enable);
1737 || mSavedMonths !=
months()
1740 #include "moc_recurrenceedit.cpp"
1741 #include "moc_recurrenceedit_p.cpp"
QFrame(QWidget *parent, QFlags< Qt::WindowType > f)
virtual void setReadOnly(bool readOnly)
virtual QWidget * validate(QString &errorMessage)
static QString i18n_combo_AtLogin()
DailyRule(bool readOnly, QWidget *parent)
virtual bool stateChanged() const
void append(const T &value)
virtual void setReadOnly(bool readOnly)
void updateEvent(KAEvent &, bool adjustStart)
Write recurrence settings into an event.
virtual void clicked(QAbstractButton *)
void setStartDate(const QDate &, const QDate &today)
WeeklyRule(bool readOnly, QWidget *parent)
virtual QSize sizeHint() const
virtual bool stateChanged() const
int localeDayInWeek_to_weekDay(int index)
virtual bool stateChanged() const
DayWeekRule(const QString &freqText, const QString &freqWhatsThis, const QString &daysWhatsThis, bool readOnly, QWidget *parent)
YearlyRule(bool readOnly, QWidget *parent)
void setFrameStyle(int style)
void addSpacing(int size)
virtual QSize sizeHint() const
QVector< int > months() const
virtual void daySelected(int)
virtual bool stateChanged() const
static QString i18n_combo_NoRecur()
KDateTime endDateTime() const
void setSpacing(int spacing)
Rule(const QString &freqText, const QString &freqWhatsThis, bool time, bool readOnly, QWidget *parent)
void typeChanged(int recurType)
void setBuddy(QWidget *buddy)
void setDefaultValues(int dayOfMonth, int dayOfWeek)
the KAlarm application object
QString number(int n, int base)
int count(const T &value) const
static QString i18n_combo_Daily()
RecurrenceEdit(bool readOnly, QWidget *parent=0)
void setRowStretch(int row, int stretch)
virtual QSize sizeHint() const
void showMoreOptions(bool)
virtual void setReadOnly(bool readOnly)
virtual void clicked(QAbstractButton *)
void setFeb29Type(KARecurrence::Feb29Type)
void setDefaultValues(int dayOfMonth, int dayOfWeek, int month)
Repetition subRepetition() const
static QString i18n_combo_HourlyMinutely()
void setMonths(const QList< int > &months)
SubDailyRule(bool readOnly, QWidget *parent)
virtual void setFrequencyFocus()
void setDay(int dayOfWeek)
void setMargin(int margin)
virtual void setReadOnly(bool readOnly)
static QString i18n_combo_Monthly()
bool stateChanged() const
MonthlyRule(bool readOnly, QWidget *parent)
virtual void setValue(int minutes)
virtual QWidget * validate(QString &)
void setDefaults(const KDateTime &from)
Set widgets to default values.
void activateSubRepetition()
virtual QSize sizeHint() const
void addStretch(int stretch)
QSize expandedTo(const QSize &otherSize) const
virtual void setValue(int minutes)
void insert(int i, const T &value)
void setColumnStretch(int column, int stretch)
void repeatNeedsInitialisation()
void setRepeatAtLogin()
Initialise with repeat-at-login selected, instead of calling set().
DayPosType buttonType(QAbstractButton *b) const
QVBoxLayout * layout() const
virtual QWidget * validate(QString &errorMessage)
void setColumnMinimumWidth(int column, int minSize)
int weekDay_to_localeDayInWeek(int weekDay)
virtual QSize sizeHint() const
virtual void daySelected(int day)
QWidget * checkData(const KDateTime &startDateTime, QString &errorMessage) const
bool fill(bool value, int size)
void setDefaultEndDate(const QDate &)
static QString shiftWhatsThis()
KARecurrence::Feb29Type feb29Type() const
static QString i18n_combo_Yearly()
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
static QString i18n_combo_Weekly()
bool testBit(int i) const
virtual bool event(QEvent *e)
MonthYearRule(const QString &freqText, const QString &freqWhatsThis, bool allowEveryWeek, bool readOnly, QWidget *parent)
void setDate(int dayOfMonth)
bool setStretchFactor(QWidget *widget, int stretch)
void setSpacing(int spacing)
void set(const KAEvent &)
Initialise according to a specified event.
virtual void showEvent(QShowEvent *)
void addLayout(QLayout *layout, int stretch)
void setSubRepetition(int reminderMinutes, bool dateOnly)
void setEndDateTime(const KDateTime &)
void setPosition(int week, int dayOfWeek)