27 #include "reminder.moc"
30 #include <kcalcore/duration.h>
31 using namespace KCalCore;
33 #include <kcal/duration.h>
40 #include <kdatetime.h>
43 #include <QVBoxLayout>
44 #include <QHBoxLayout>
51 #define i18n_in_advance i18nc("@item:inlistbox", "in advance")
55 const QString& beforeAfterWhatsThis,
bool allowHourMinute,
56 bool showOnceOnly,
QWidget* parent)
59 mOnceOnlyEnabled(showOnceOnly)
61 QVBoxLayout* topLayout =
new QVBoxLayout(
this);
62 topLayout->setMargin(0);
63 topLayout->setSpacing(KDialog::spacingHint());
65 mTime =
new TimeSelector(i18nc(
"@option:check",
"Reminder:"), reminderWhatsThis,
66 valueWhatsThis, allowHourMinute,
this);
69 mTimeSignCombo->addItem(i18nc(
"@item:inlistbox",
"afterwards"));
70 mTimeSignCombo->setWhatsThis(beforeAfterWhatsThis);
71 mTimeSignCombo->setCurrentIndex(0);
72 mTime->setFixedSize(mTime->sizeHint());
73 connect(mTime, SIGNAL(toggled(
bool)), SLOT(slotReminderToggled(
bool)));
75 connect(mTime, SIGNAL(valueChanged(KCalCore::Duration)), SIGNAL(
changed()));
77 connect(mTime, SIGNAL(valueChanged(KCal::Duration)), SIGNAL(
changed()));
79 connect(mTimeSignCombo, SIGNAL(currentIndexChanged(
int)), SIGNAL(
changed()));
80 topLayout->addWidget(mTime, 0, Qt::AlignLeft);
84 QHBoxLayout* layout =
new QHBoxLayout();
86 layout->addSpacing(3*KDialog::spacingHint());
87 topLayout->addLayout(layout);
89 mOnceOnly->setFixedSize(mOnceOnly->sizeHint());
90 connect(mOnceOnly, SIGNAL(toggled(
bool)), SIGNAL(
changed()));
91 mOnceOnly->setWhatsThis(i18nc(
"@info:whatsthis",
"Display the reminder only for the first time the alarm is scheduled"));
92 layout->addWidget(mOnceOnly);
104 if (afterOnly && mTimeSignCombo->count() == 2)
105 mTimeSignCombo->removeItem(0);
106 else if (!afterOnly && mTimeSignCombo->count() == 1)
115 if ((
int)ro != (
int)mReadOnly)
131 return mOnceOnly && mOnceOnly->isEnabled() && mOnceOnly->isChecked();
137 mOnceOnly->setChecked(onceOnly);
147 mOnceOnlyEnabled = enable;
148 mOnceOnly->setEnabled(enable && mTime->
isChecked());
166 int index = mTimeSignCombo->currentIndex();
167 if (mTimeSignCombo->count() == 1)
169 int sign = index ? -1 : 1;
170 return mTime->
period().asSeconds() * sign / 60;
178 bool neg = (minutes < 0);
179 minutes = abs(minutes);
181 if (minutes % (24*60))
182 period = Duration(minutes * 60, Duration::Seconds);
184 period = Duration(minutes / (24*60), Duration::Days);
186 mTimeSignCombo->setCurrentIndex(neg ? 1 : 0);
208 void Reminder::slotReminderToggled(
bool on)
211 mOnceOnly->setEnabled(on && mOnceOnlyEnabled);
225 if (KDateTime::currentDateTime(dt.timeSpec()).daysTo(dt) < 7)
virtual void setReadOnly(bool readOnly)
void setMaximum(int hourmin, int days)
void setAfterOnly(bool after)
void setUnits(TimePeriod::Units units)
TimePeriod::Units units() const
static QString i18n_chk_FirstRecurrenceOnly()
void setDateOnly(bool dateOnly)
void setMinutes(int minutes, bool dateOnly)
void setDefaultUnits(const KDateTime &)
static TimePeriod::Units defaultReminderUnits()
Get Reminder units.
void setDateOnly(bool dateOnly=true)
void setPeriod(const KCal::Duration &, bool dateOnly, TimePeriod::Units defaultUnits)
void setMaximum(int hourmin, int days)
void enableOnceOnly(bool enable)
ComboBox * createSignCombo()
Reminder(const QString &reminderWhatsThis, const QString &valueWhatsThis, const QString &beforeAfterWhatsThis, bool allowHourMinute, bool showOnceOnly, QWidget *parent)
KCal::Duration period() const