kalarm
reminder.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "kalarm.h"
00022
00023 #include <qlayout.h>
00024 #include <qwhatsthis.h>
00025
00026 #include <kglobal.h>
00027 #include <klocale.h>
00028 #include <kdialog.h>
00029 #include <kdebug.h>
00030
00031 #include "preferences.h"
00032 #include "checkbox.h"
00033 #include "timeselector.h"
00034 #include "reminder.moc"
00035
00036
00037
00038
00039 QString Reminder::i18n_first_recurrence_only() { return i18n("Reminder for first recurrence only"); }
00040 QString Reminder::i18n_u_first_recurrence_only() { return i18n("Reminder for first rec&urrence only"); }
00041
00042
00043 Reminder::Reminder(const QString& caption, const QString& reminderWhatsThis, const QString& valueWhatsThis,
00044 bool allowHourMinute, bool showOnceOnly, QWidget* parent, const char* name)
00045 : QFrame(parent, name),
00046 mReadOnly(false),
00047 mOnceOnlyEnabled(showOnceOnly)
00048 {
00049 setFrameStyle(QFrame::NoFrame);
00050 QVBoxLayout* topLayout = new QVBoxLayout(this, 0, KDialog::spacingHint());
00051
00052 mTime = new TimeSelector(caption, i18n("in advance"), reminderWhatsThis,
00053 valueWhatsThis, allowHourMinute, this, "timeOption");
00054 mTime->setFixedSize(mTime->sizeHint());
00055 connect(mTime, SIGNAL(toggled(bool)), SLOT(slotReminderToggled(bool)));
00056 topLayout->addWidget(mTime);
00057
00058 if (showOnceOnly)
00059 {
00060 QBoxLayout* layout = new QHBoxLayout(topLayout, KDialog::spacingHint());
00061 layout->addSpacing(3*KDialog::spacingHint());
00062 mOnceOnly = new CheckBox(i18n_u_first_recurrence_only(), this);
00063 mOnceOnly->setFixedSize(mOnceOnly->sizeHint());
00064 QWhatsThis::add(mOnceOnly, i18n("Display the reminder only before the first time the alarm is scheduled"));
00065 layout->addWidget(mOnceOnly);
00066 layout->addStretch();
00067 }
00068 else
00069 mOnceOnly = 0;
00070 }
00071
00072
00073
00074
00075 void Reminder::setReadOnly(bool ro)
00076 {
00077 if ((int)ro != (int)mReadOnly)
00078 {
00079 mReadOnly = ro;
00080 mTime->setReadOnly(mReadOnly);
00081 if (mOnceOnly)
00082 mOnceOnly->setReadOnly(mReadOnly);
00083 }
00084 }
00085
00086 bool Reminder::isReminder() const
00087 {
00088 return mTime->isChecked();
00089 }
00090
00091 bool Reminder::isOnceOnly() const
00092 {
00093 return mOnceOnly && mOnceOnly->isEnabled() && mOnceOnly->isChecked();
00094 }
00095
00096 void Reminder::setOnceOnly(bool onceOnly)
00097 {
00098 if (mOnceOnly)
00099 mOnceOnly->setChecked(onceOnly);
00100 }
00101
00102
00103
00104
00105 void Reminder::enableOnceOnly(bool enable)
00106 {
00107 if (mOnceOnly)
00108 {
00109 mOnceOnlyEnabled = enable;
00110 mOnceOnly->setEnabled(enable && mTime->isChecked());
00111 }
00112 }
00113
00114 void Reminder::setMaximum(int hourmin, int days)
00115 {
00116 mTime->setMaximum(hourmin, days);
00117 }
00118
00119
00120
00121
00122
00123 int Reminder::minutes() const
00124 {
00125 return mTime->minutes();
00126 }
00127
00128
00129
00130
00131 void Reminder::setMinutes(int minutes, bool dateOnly)
00132 {
00133 mTime->setMinutes(minutes, dateOnly, Preferences::defaultReminderUnits());
00134 }
00135
00136
00137
00138
00139 void Reminder::setDateOnly(bool dateOnly)
00140 {
00141 mTime->setDateOnly(dateOnly);
00142 }
00143
00144
00145
00146
00147 void Reminder::setFocusOnCount()
00148 {
00149 mTime->setFocusOnCount();
00150 }
00151
00152
00153
00154
00155 void Reminder::slotReminderToggled(bool on)
00156 {
00157 if (mOnceOnly)
00158 mOnceOnly->setEnabled(on && mOnceOnlyEnabled);
00159 }
|