26 #include <tqwhatsthis.h>
28 #include <tdelocale.h>
33 #include "timeselector.moc"
36 TimeSelector::TimeSelector(
const TQString& selectText,
const TQString& postfix,
const TQString& selectWhatsThis,
37 const TQString& valueWhatsThis,
bool allowHourMinute, TQWidget* parent,
const char* name)
38 : TQFrame(parent, name),
42 setFrameStyle(TQFrame::NoFrame);
43 TQVBoxLayout* topLayout =
new TQVBoxLayout(
this, 0, KDialog::spacingHint());
44 TQHBoxLayout* layout =
new TQHBoxLayout(topLayout, KDialog::spacingHint());
45 mSelect =
new CheckBox(selectText,
this);
46 mSelect->setFixedSize(mSelect->sizeHint());
47 connect(mSelect, TQ_SIGNAL(toggled(
bool)), TQ_SLOT(selectToggled(
bool)));
48 TQWhatsThis::add(mSelect, selectWhatsThis);
49 layout->addWidget(mSelect);
51 TQHBox* box =
new TQHBox(
this);
52 box->setSpacing(KDialog::spacingHint());
53 layout->addWidget(box);
54 mPeriod =
new TimePeriod(allowHourMinute, box);
55 mPeriod->setFixedSize(mPeriod->sizeHint());
56 mPeriod->setSelectOnStep(
false);
57 connect(mPeriod, TQ_SIGNAL(valueChanged(
int)), TQ_SLOT(periodChanged(
int)));
58 mSelect->setFocusWidget(mPeriod);
59 mPeriod->setEnabled(
false);
61 if (!postfix.isEmpty())
63 mLabel =
new TQLabel(postfix, box);
64 TQWhatsThis::add(box, valueWhatsThis);
65 mLabel->setEnabled(
false);
72 void TimeSelector::setReadOnly(
bool ro)
74 if ((
int)ro != (
int)mReadOnly)
77 mSelect->setReadOnly(mReadOnly);
78 mPeriod->setReadOnly(mReadOnly);
82 bool TimeSelector::isChecked()
const
84 return mSelect->isChecked();
87 void TimeSelector::setChecked(
bool on)
89 if (on != mSelect->isChecked())
91 mSelect->setChecked(on);
92 emit valueChanged(minutes());
96 void TimeSelector::setMaximum(
int hourmin,
int days)
98 mPeriod->setMaximum(hourmin, days);
101 void TimeSelector::setDateOnly(
bool dateOnly)
103 mPeriod->setDateOnly(dateOnly);
110 int TimeSelector::minutes()
const
112 return mSelect->isChecked() ? mPeriod->minutes() : 0;
121 void TimeSelector::setMinutes(
int minutes,
bool dateOnly, TimePeriod::Units defaultUnits)
123 mSelect->setChecked(minutes);
124 mPeriod->setEnabled(minutes);
126 mLabel->setEnabled(minutes);
127 mPeriod->setMinutes(minutes, dateOnly, defaultUnits);
133 void TimeSelector::setFocusOnCount()
135 mPeriod->setFocusOnCount();
141 void TimeSelector::selectToggled(
bool on)
143 mPeriod->setEnabled(on);
145 mLabel->setEnabled(on);
149 emit valueChanged(minutes());
155 void TimeSelector::periodChanged(
int minutes)
157 if (mSelect->isChecked())
158 emit valueChanged(minutes);