dateedit.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <kglobal.h>
00026 #include <klocale.h>
00027 #include <kmessagebox.h>
00028
00029 #include "dateedit.moc"
00030
00031
00032
00033 bool DateEdit::validate(const QDate& newDate)
00034 {
00035 if (!newDate.isValid())
00036 return false;
00037 if (minDate.isValid() && newDate < minDate)
00038 {
00039 QString minString;
00040 if (minDate == QDate::currentDate())
00041 minString = i18n("today");
00042 else
00043 minString = KGlobal::locale()->formatDate(minDate, true);
00044 KMessageBox::sorry(this, i18n("Date cannot be earlier than %1").arg(minString));
00045 return false;
00046 }
00047 return true;
00048 }
00049
00050 #if QT_VERSION < 300
00051 void DateEdit::mousePressEvent(QMouseEvent *e)
00052 {
00053 if ( e->button() != LeftButton )
00054 return;
00055 QRect editRect = style().comboButtonRect(0, 0, width(), height());
00056 int xborder = editRect.left();
00057 int yborder = editRect.top();
00058 int left = editRect.width() + xborder;
00059 QRect arrowRect(left, 0, width() - left, height());
00060 if (arrowRect.contains(e->pos()))
00061 popup();
00062 }
00063 #endif
This file is part of the documentation for kdelibs Version 3.1.4.