kalarm Library API Documentation

dateedit.cpp

00001 /*
00002  *  dateedit.cpp  -  date entry widget
00003  *  Program:  kalarm
00004  *  (C) 2002 by David Jarvie  software@astrojar.org.uk
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *
00020  *  As a special exception, permission is given to link this program
00021  *  with any edition of Qt, and distribute the resulting executable,
00022  *  without including the source code for Qt in the source distribution.
00023  */
00024 
00025 #include <kglobal.h>
00026 #include <klocale.h>
00027 #include <kmessagebox.h>
00028 
00029 #include "dateedit.moc"
00030 
00031 
00032 // Check a new date against any minimum date.
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
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:26 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001