kalarm/lib

dateedit.h
1/*
2 * dateedit.h - date entry widget
3 * Program: kalarm
4 * Copyright © 2002-2007 by David Jarvie <software@astrojar.org.uk>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20#ifndef DATEEDIT_H
21#define DATEEDIT_H
22
23#include <libtdepim/kdateedit.h>
24
37class DateEdit : public KDateEdit
38{
39 TQ_OBJECT
40
41 public:
46 explicit DateEdit(TQWidget* parent = 0, const char* name = 0);
48 bool isValid() const { return date().isValid(); }
52 const TQDate& minDate() const { return mMinDate; }
56 const TQDate& maxDate() const { return mMaxDate; }
62 void setMinDate(const TQDate& date, const TQString& errorDate = TQString());
68 void setMaxDate(const TQDate& date, const TQString& errorDate = TQString());
70 void setInvalid();
71
72 protected:
73 virtual void mousePressEvent(TQMouseEvent*);
74 virtual void mouseReleaseEvent(TQMouseEvent*);
75 virtual void mouseMoveEvent(TQMouseEvent*);
76 virtual void keyPressEvent(TQKeyEvent*);
77 virtual void keyReleaseEvent(TQKeyEvent*);
78
79 private slots:
80 void newDateEntered(const TQDate&);
81
82 private:
83 void pastLimitMessage(const TQDate& limit, const TQString& error, const TQString& defaultError);
84
85 TQDate mMinDate; // minimum allowed date, or invalid for no minimum
86 TQDate mMaxDate; // maximum allowed date, or invalid for no maximum
87 TQString mMinDateErrString; // error message when entered date < mMinDate
88 TQString mMaxDateErrString; // error message when entered date > mMaxDate
89};
90
91#endif // DATEEDIT_H
Date edit widget with range limits.
Definition: dateedit.h:38
bool isValid() const
Returns true if the widget contains a valid date.
Definition: dateedit.h:48
void setMaxDate(const TQDate &date, const TQString &errorDate=TQString())
Sets the latest date which can be entered.
Definition: dateedit.cpp:42
const TQDate & maxDate() const
Returns the latest date which can be entered.
Definition: dateedit.h:56
void setInvalid()
Sets the date held in the widget to an invalid date.
Definition: dateedit.cpp:50
const TQDate & minDate() const
Returns the earliest date which can be entered.
Definition: dateedit.h:52
DateEdit(TQWidget *parent=0, const char *name=0)
Constructor.
Definition: dateedit.cpp:28
void setMinDate(const TQDate &date, const TQString &errorDate=TQString())
Sets the earliest date which can be entered.
Definition: dateedit.cpp:34
TQDate date() const