Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
tdepim/kalarm/lib/dateedit.h

92 linhas
3.7 KiB

/*
* dateedit.h - date entry widget
* Program: kalarm
* Copyright © 2002-2007 by David Jarvie <software@astrojar.org.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef DATEEDIT_H
#define DATEEDIT_H
#include <libtdepim/kdateedit.h>
/**
* @short Date edit widget with range limits.
*
* The DateEdit class provides a date editor with the ability to set limits on the
* dates which can be entered.
*
* Minimum and/or maximum permissible dates may be set, together with corresponding
* error messages. If the user tries to enter a date outside the allowed range, the
* appropriate error message (if any) is output using KMessageBox::sorry().
*
* @author David Jarvie <software@astrojar.org.uk>
*/
class DateEdit : public KDateEdit
{
Q_OBJECT
TQ_OBJECT
public:
/** Constructor.
* @param parent The parent object of this widget.
* @param name The name of this widget.
*/
explicit DateEdit(TQWidget* parent = 0, const char* name = 0);
/** Returns true if the widget contains a valid date. */
bool isValid() const { return date().isValid(); }
/** Returns the earliest date which can be entered.
* If there is no minimum date, returns an invalid date.
*/
const TQDate& minDate() const { return mMinDate; }
/** Returns the latest date which can be entered.
* If there is no maximum date, returns an invalid date.
*/
const TQDate& maxDate() const { return mMaxDate; }
/** Sets the earliest date which can be entered.
* @param date Earliest date allowed. If invalid, any minimum limit is removed.
* @param errorDate Error message to be displayed when a date earlier than
* @p date is entered. Set to TQString() to use the default error message.
*/
void setMinDate(const TQDate& date, const TQString& errorDate = TQString());
/** Sets the latest date which can be entered.
* @param date Latest date allowed. If invalid, any maximum limit is removed.
* @param errorDate Error message to be displayed when a date later than
* @p date is entered. Set to TQString() to use the default error message.
*/
void setMaxDate(const TQDate& date, const TQString& errorDate = TQString());
/** Sets the date held in the widget to an invalid date. */
void setInvalid();
protected:
virtual void mousePressEvent(TQMouseEvent*);
virtual void mouseReleaseEvent(TQMouseEvent*);
virtual void mouseMoveEvent(TQMouseEvent*);
virtual void keyPressEvent(TQKeyEvent*);
virtual void keyReleaseEvent(TQKeyEvent*);
private slots:
void newDateEntered(const TQDate&);
private:
void pastLimitMessage(const TQDate& limit, const TQString& error, const TQString& defaultError);
TQDate mMinDate; // minimum allowed date, or invalid for no minimum
TQDate mMaxDate; // maximum allowed date, or invalid for no maximum
TQString mMinDateErrString; // error message when entered date < mMinDate
TQString mMaxDateErrString; // error message when entered date > mMaxDate
};
#endif // DATEEDIT_H