21 #include <tdeglobal.h>
22 #include <tdelocale.h>
23 #include <tdemessagebox.h>
25 #include "dateedit.moc"
31 connect(
this, TQ_SIGNAL(
dateEntered(
const TQDate&)), TQ_SLOT(newDateEntered(
const TQDate&)));
39 mMinDateErrString = errorDate;
47 mMaxDateErrString = errorDate;
56 void DateEdit::newDateEntered(
const TQDate& newDate)
58 if (newDate.isValid())
60 if (mMinDate.isValid() && newDate < mMinDate)
62 pastLimitMessage(mMinDate, mMinDateErrString,
63 i18n(
"Date cannot be earlier than %1"));
66 else if (mMaxDate.isValid() && newDate > mMaxDate)
68 pastLimitMessage(mMaxDate, mMaxDateErrString,
69 i18n(
"Date cannot be later than %1"));
75 void DateEdit::pastLimitMessage(
const TQDate& limit,
const TQString& error,
const TQString& defaultError)
77 TQString errString = error;
78 if (errString.isNull())
80 if (limit == TQDate::currentDate())
81 errString = i18n(
"today");
83 errString = TDEGlobal::locale()->formatDate(limit,
true);
84 errString = defaultError.arg(errString);
86 KMessageBox::sorry(
this, errString);
89 void DateEdit::mousePressEvent(TQMouseEvent *e)
94 if (e->button() == TQt::LeftButton)
97 KDateEdit::mousePressEvent(e);
100 void DateEdit::mouseReleaseEvent(TQMouseEvent* e)
103 KDateEdit::mouseReleaseEvent(e);
106 void DateEdit::mouseMoveEvent(TQMouseEvent* e)
109 KDateEdit::mouseMoveEvent(e);
112 void DateEdit::keyPressEvent(TQKeyEvent* e)
115 KDateEdit::keyPressEvent(e);
118 void DateEdit::keyReleaseEvent(TQKeyEvent* e)
121 KDateEdit::keyReleaseEvent(e);
bool isValid() const
Returns true if the widget contains a valid date.
void setMaxDate(const TQDate &date, const TQString &errorDate=TQString())
Sets the latest date which can be entered.
void setInvalid()
Sets the date held in the widget to an invalid date.
DateEdit(TQWidget *parent=0, const char *name=0)
Constructor.
void setMinDate(const TQDate &date, const TQString &errorDate=TQString())
Sets the earliest date which can be entered.
void setDate(const TQDate &date)
void dateEntered(const TQDate &date)