25 #include <tdeglobal.h>
26 #include <tdelocale.h>
27 #include <tdemessagebox.h>
30 #include <libkcal/event.h>
31 #include <libkcal/recurrence.h>
33 #include "alarmcalendar.h"
35 #include "alarmtimewidget.h"
39 #include "deferdlg.moc"
42 DeferAlarmDlg::DeferAlarmDlg(
const TQString& caption,
const DateTime& initialDT,
43 bool cancelButton, TQWidget* parent,
const char* name)
44 : KDialogBase(parent, name, true, caption, Ok|Cancel|User1, Ok, false, i18n(
"Cancel &Deferral"))
47 showButton(User1,
false);
49 TQWidget* page =
new TQWidget(
this);
51 TQVBoxLayout* layout =
new TQVBoxLayout(page, 0, spacingHint());
53 mTimeWidget =
new AlarmTimeWidget(AlarmTimeWidget::DEFER_TIME, page,
"timeGroup");
54 mTimeWidget->setDateTime(initialDT);
55 mTimeWidget->setMinDateTimeIsCurrent();
56 connect(mTimeWidget, TQ_SIGNAL(pastMax()), TQ_SLOT(slotPastLimit()));
57 layout->addWidget(mTimeWidget);
58 layout->addSpacing(spacingHint());
60 setButtonWhatsThis(Ok, i18n(
"Defer the alarm until the specified time."));
61 setButtonWhatsThis(User1, i18n(
"Cancel the deferred alarm. This does not affect future recurrences."));
68 void DeferAlarmDlg::slotOk()
70 mAlarmDateTime = mTimeWidget->getDateTime(&mDeferMinutes);
71 if (!mAlarmDateTime.isValid())
73 KAEvent::DeferLimitType limitType;
75 if (!mLimitEventID.isEmpty())
78 const KCal::Event* kcalEvent = AlarmCalendar::getEvent(mLimitEventID);
82 endTime =
event.deferralLimit(&limitType);
87 endTime = mLimitDateTime;
88 limitType = mLimitDateTime.isValid() ? KAEvent::LIMIT_MAIN : KAEvent::LIMIT_NONE;
90 if (endTime.isValid() && mAlarmDateTime > endTime)
95 case KAEvent::LIMIT_REPETITION:
96 text = i18n(
"Cannot defer past the alarm's next sub-repetition (currently %1)");
98 case KAEvent::LIMIT_RECURRENCE:
99 text = i18n(
"Cannot defer past the alarm's next recurrence (currently %1)");
101 case KAEvent::LIMIT_REMINDER:
102 text = i18n(
"Cannot defer past the alarm's next reminder (currently %1)");
104 case KAEvent::LIMIT_MAIN:
105 text = i18n(
"Cannot defer reminder past the main alarm time (%1)");
107 case KAEvent::LIMIT_NONE:
110 KMessageBox::sorry(
this, text.arg(endTime.formatLocale()));
119 void DeferAlarmDlg::setDeferMinutes(
int minutes)
121 mTimeWidget->selectTimeFromNow(minutes);
127 void DeferAlarmDlg::slotPastLimit()
129 enableButtonOK(
false);
136 void DeferAlarmDlg::setLimit(
const DateTime& limit)
138 mLimitEventID = TQString();
139 mLimitDateTime = limit;
140 mTimeWidget->setMaxDateTime(mLimitDateTime);
147 DateTime DeferAlarmDlg::setLimit(
const TQString& eventID)
149 mLimitEventID = eventID;
150 const KCal::Event* kcalEvent = AlarmCalendar::getEvent(mLimitEventID);
154 mLimitDateTime =
event.deferralLimit();
157 mLimitDateTime = DateTime();
158 mTimeWidget->setMaxDateTime(mLimitDateTime);
159 return mLimitDateTime;
165 void DeferAlarmDlg::slotUser1()
167 mAlarmDateTime = DateTime();
174 void DeferAlarmDlg::slotCancel()
represents calendar alarms and events
KAEvent corresponds to a KCal::Event instance.
the KAlarm application object