kalarm/lib

dateedit.h

00001 /*
00002  *  dateedit.h  -  date entry widget
00003  *  Program:  kalarm
00004  *  Copyright © 2002-2007 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 along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 #ifndef DATEEDIT_H
00021 #define DATEEDIT_H
00022 
00023 #include <libkdepim/kdateedit.h>
00024 
00037 class DateEdit : public KDateEdit
00038 {
00039         Q_OBJECT
00040     public:
00045         explicit DateEdit(TQWidget* parent = 0, const char* name = 0);
00047         bool         isValid() const              { return date().isValid(); }
00051         const TQDate& minDate() const              { return mMinDate; }
00055         const TQDate& maxDate() const              { return mMaxDate; }
00061         void         setMinDate(const TQDate& date, const TQString& errorDate = TQString::null);
00067         void         setMaxDate(const TQDate& date, const TQString& errorDate = TQString::null);
00069         void         setInvalid();
00070 
00071     protected:
00072         virtual void mousePressEvent(TQMouseEvent*);
00073         virtual void mouseReleaseEvent(TQMouseEvent*);
00074         virtual void mouseMoveEvent(TQMouseEvent*);
00075         virtual void keyPressEvent(TQKeyEvent*);
00076         virtual void keyReleaseEvent(TQKeyEvent*);
00077 
00078     private slots:
00079         void         newDateEntered(const TQDate&);
00080 
00081     private:
00082         void         pastLimitMessage(const TQDate& limit, const TQString& error, const TQString& defaultError);
00083 
00084         TQDate        mMinDate;             // minimum allowed date, or invalid for no minimum
00085         TQDate        mMaxDate;             // maximum allowed date, or invalid for no maximum
00086         TQString      mMinDateErrString;    // error message when entered date < mMinDate
00087         TQString      mMaxDateErrString;    // error message when entered date > mMaxDate
00088 };
00089 
00090 #endif // DATEEDIT_H