23 #include <tdeglobal.h> 24 #include <tdelocale.h> 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, TQT_SIGNAL(
valueChanged(
int)), TQT_SLOT(slotValueChanged(
int)));
46 mAmPm->setFixedSize(mAmPm->sizeHint());
47 connect(mAmPm, TQT_SIGNAL(highlighted(
int)), TQT_SLOT(slotAmPmChanged(
int)));
64 return mSpinBox->
value();
79 bool oldValid = mSpinBox->
isValid();
80 if ((valid && !oldValid) || (!valid && oldValid))
84 mAmPm->setCurrentItem(0);
95 int i = (minutes >= 720) ? mPmIndex : mAmIndex;
96 mAmPm->setCurrentItem(i >= 0 ? i : 0);
124 setAmPmCombo((minutes < 720 ? 1 : 0), -1);
131 setAmPmCombo(-1, (minutes < 720 ? 0 : 1));
138 void 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);
155 void TimeEdit::slotAmPmChanged(
int item)
160 if (item == mPmIndex && value < 720)
162 else if (item != mPmIndex && value >= 720)
170 void 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);
TimeEdit(TQWidget *parent=0, const char *name=0)
Constructor.
void setValid(bool)
Sets the spin box as holding a valid or invalid value.
Hours/minutes time entry widget.
virtual void setReadOnly(bool readOnly)
Sets whether the widget is read-only for the user.
virtual void setMaxValue(int minutes)
Sets the maximum value which can be held in the spin box.
virtual void setWrapping(bool on)
Sets whether it is possible to step the value from the highest value to the lowest value and vice ver...
void setMaxValue(int minutes)
Sets the maximum value of the widget.
bool isValid() const
Returns true if the spin box holds a valid value.
virtual void setReadOnly(bool readOnly)
Sets whether the spin box can be changed by the user.
int value() const
Returns the current value of the spin box.
int minValue() const
Returns the minimum value of the widget in minutes.
int minValue() const
Returns the minimum value of the spin box.
virtual void setMinValue(int minutes)
Sets the maximum value which can be held in the spin box.
bool wrapping() const
Returns whether it is possible to step the value from the highest value to the lowest value and vice ...
void setMinValue(int minutes)
Sets the minimum value of the widget.
virtual void setReadOnly(bool readOnly)
Sets whether the combo box is read-only for the user.
int maxValue() const
Returns the maximum value of the widget in minutes.
void setWrapping(bool on)
Sets whether it is possible to step the value from the highest value to the lowest value and vice ver...
bool wrapping() const
Returns true if it is possible to step the value from the highest value to the lowest value and vice ...
virtual void setValue(int minutes)
Sets the value of the spin box.
void valueChanged(int minutes)
This signal is emitted every time the value of the widget changes (for whatever reason).
int maxValue() const
Returns the maximum value of the spin box.
virtual void setValue(int minutes)
Sets the value of the widget.
int value() const
Returns the entered time as a value in minutes.
void setValid(bool valid)
Sets whether the edit value is valid.
A TQComboBox with read-only option.
bool isValid() const
Returns true if the widget contains a valid value.