27#include "timespinbox.h"
28#include "timeedit.moc"
32 : TQHBox(parent, name),
38 bool use12hour = TDEGlobal::locale()->use12Clock();
40 mSpinBox->setFixedSize(mSpinBox->sizeHint());
41 connect(mSpinBox, TQ_SIGNAL(
valueChanged(
int)), TQ_SLOT(slotValueChanged(
int)));
46 mAmPm->setFixedSize(mAmPm->sizeHint());
47 connect(mAmPm, TQ_SIGNAL(highlighted(
int)), TQ_SLOT(slotAmPmChanged(
int)));
56 mSpinBox->setReadOnly(ro);
58 mAmPm->setReadOnly(ro);
64 return mSpinBox->value();
69 return mSpinBox->isValid();
79 bool oldValid = mSpinBox->isValid();
80 if ((valid && !oldValid) || (!valid && oldValid))
82 mSpinBox->setValid(valid);
84 mAmPm->setCurrentItem(0);
95 int i = (minutes >= 720) ? mPmIndex : mAmIndex;
96 mAmPm->setCurrentItem(i >= 0 ? i : 0);
98 mSpinBox->setValue(minutes);
103 return mSpinBox->wrapping();
108 mSpinBox->setWrapping(on);
113 return mSpinBox->minValue();
118 return mSpinBox->maxValue();
124 setAmPmCombo((minutes < 720 ? 1 : 0), -1);
125 mSpinBox->setMinValue(minutes);
131 setAmPmCombo(-1, (minutes < 720 ? 0 : 1));
132 mSpinBox->setMaxValue(minutes);
138void TimeEdit::slotValueChanged(
int value)
142 bool pm = (mAmPm->currentItem() == mPmIndex);
143 if (pm &&
value < 720)
144 mAmPm->setCurrentItem(mAmIndex);
145 else if (!pm &&
value >= 720)
146 mAmPm->setCurrentItem(mPmIndex);
155void TimeEdit::slotAmPmChanged(
int item)
159 int value = mSpinBox->value();
160 if (item == mPmIndex &&
value < 720)
161 mSpinBox->setValue(
value + 720);
162 else if (item != mPmIndex &&
value >= 720)
163 mSpinBox->setValue(
value - 720);
170void TimeEdit::setAmPmCombo(
int am,
int pm)
172 if (am > 0 && mAmIndex < 0)
176 mAmPm->insertItem(TDEGlobal::locale()->translate(
"am"), mAmIndex);
179 mAmPm->setCurrentItem(mPmIndex >= 0 ? mPmIndex : mAmIndex);
181 else if (am == 0 && mAmIndex >= 0)
184 mAmPm->removeItem(mAmIndex);
188 mAmPm->setCurrentItem(mPmIndex);
191 if (pm > 0 && mPmIndex < 0)
194 mPmIndex = mAmIndex + 1;
195 mAmPm->insertItem(TDEGlobal::locale()->translate(
"pm"), mPmIndex);
197 mAmPm->setCurrentItem(mPmIndex);
199 else if (pm == 0 && mPmIndex >= 0)
202 mAmPm->removeItem(mPmIndex);
204 mAmPm->setCurrentItem(mAmIndex);
A TQComboBox with read-only option.
void setMinValue(int minutes)
Sets the minimum value of the widget.
virtual void setValue(int minutes)
Sets the value of the widget.
bool wrapping() const
Returns true if it is possible to step the value from the highest value to the lowest value and vice ...
void setWrapping(bool on)
Sets whether it is possible to step the value from the highest value to the lowest value and vice ver...
virtual void setReadOnly(bool readOnly)
Sets whether the widget is read-only for the user.
void setValid(bool valid)
Sets whether the edit value is valid.
void setMaxValue(int minutes)
Sets the maximum value of the widget.
int value() const
Returns the entered time as a value in minutes.
int maxValue() const
Returns the maximum value of the widget in minutes.
TimeEdit(TQWidget *parent=0, const char *name=0)
Constructor.
bool isValid() const
Returns true if the widget contains a valid value.
void valueChanged(int minutes)
This signal is emitted every time the value of the widget changes (for whatever reason).
int minValue() const
Returns the minimum value of the widget in minutes.
Hours/minutes time entry widget.