You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
151 lines
4.4 KiB
151 lines
4.4 KiB
15 years ago
|
/*
|
||
13 years ago
|
This file is part of libtdepim.
|
||
15 years ago
|
|
||
|
Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
|
||
|
Copyright (c) 2002 David Jarvie <software@astrojar.org.uk>
|
||
|
Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library 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
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#ifndef KDATEEDIT_H
|
||
|
#define KDATEEDIT_H
|
||
|
|
||
15 years ago
|
#include <tqcombobox.h>
|
||
|
#include <tqdatetime.h>
|
||
|
#include <tqmap.h>
|
||
15 years ago
|
|
||
13 years ago
|
#include <tdepimmacros.h>
|
||
15 years ago
|
|
||
|
#include "kdatepickerpopup.h"
|
||
|
|
||
15 years ago
|
class TQEvent;
|
||
15 years ago
|
|
||
|
/**
|
||
|
A date editing widget that consists of an editable combo box.
|
||
14 years ago
|
The combo box contains the date in text form, and clicking the combo
|
||
15 years ago
|
box arrow will display a 'popup' style date picker.
|
||
|
|
||
|
This widget also supports advanced features like allowing the user
|
||
|
to type in the day name to get the date. The following keywords
|
||
|
are supported (in the native language): tomorrow, yesturday, today,
|
||
|
monday, tuesday, wednesday, thursday, friday, saturday, sunday.
|
||
|
|
||
|
@image html kdateedit.png "This is how it looks"
|
||
|
|
||
|
@author Cornelius Schumacher <schumacher@kde.org>
|
||
|
@author Mike Pilone <mpilone@slac.com>
|
||
|
@author David Jarvie <software@astrojar.org.uk>
|
||
|
@author Tobias Koenig <tokoe@kde.org>
|
||
|
*/
|
||
14 years ago
|
class KDE_EXPORT KDateEdit : public TQComboBox
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
14 years ago
|
TQ_OBJECT
|
||
15 years ago
|
|
||
|
public:
|
||
13 years ago
|
KDateEdit( TQWidget *parent = 0, const char *name = 0 );
|
||
15 years ago
|
virtual ~KDateEdit();
|
||
|
|
||
|
/**
|
||
|
@return The date entered. This date could be invalid,
|
||
|
you have to check validity yourself.
|
||
|
*/
|
||
15 years ago
|
TQDate date() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
Sets whether the widget is read-only for the user. If read-only,
|
||
|
the date picker pop-up is inactive, and the displayed date cannot be edited.
|
||
|
|
||
|
@param readOnly True to set the widget read-only, false to set it read-write.
|
||
|
*/
|
||
|
void setReadOnly( bool readOnly );
|
||
|
|
||
|
/**
|
||
|
@return True if the widget is read-only, false if read-write.
|
||
|
*/
|
||
|
bool isReadOnly() const;
|
||
|
|
||
|
virtual void popup();
|
||
|
|
||
|
signals:
|
||
|
/**
|
||
|
This signal is emitted whenever the user has entered a new date.
|
||
|
When the user changes the date by editing the line edit field,
|
||
|
the signal is not emitted until focus leaves the line edit field.
|
||
|
The passed date can be invalid.
|
||
|
*/
|
||
15 years ago
|
void dateEntered( const TQDate &date );
|
||
15 years ago
|
|
||
|
/**
|
||
|
This signal is emitted whenever the user modifies the date.
|
||
|
The passed date can be invalid.
|
||
|
*/
|
||
15 years ago
|
void dateChanged( const TQDate &date );
|
||
15 years ago
|
|
||
|
public slots:
|
||
|
/**
|
||
|
Sets the date.
|
||
|
|
||
|
@param date The new date to display. This date must be valid or
|
||
|
it will not be set
|
||
|
*/
|
||
15 years ago
|
void setDate( const TQDate &date );
|
||
15 years ago
|
|
||
|
protected slots:
|
||
|
void lineEnterPressed();
|
||
15 years ago
|
void slotTextChanged( const TQString& );
|
||
|
void dateSelected( TQDate );
|
||
15 years ago
|
|
||
|
protected:
|
||
15 years ago
|
virtual bool eventFilter( TQObject*, TQEvent* );
|
||
|
virtual void mousePressEvent( TQMouseEvent* );
|
||
15 years ago
|
|
||
|
/**
|
||
|
Sets the date, without altering the display.
|
||
|
This method is used internally to set the widget's date value.
|
||
|
As a virtual method, it allows derived classes to perform additional validation
|
||
|
on the date value before it is set. Derived classes should return true if
|
||
15 years ago
|
TQDate::isValid(@p date) returns false.
|
||
15 years ago
|
|
||
|
@param date The new date to set.
|
||
|
@return True if the date was set, false if it was considered invalid and
|
||
|
remains unchanged.
|
||
|
*/
|
||
15 years ago
|
virtual bool assignDate( const TQDate &date );
|
||
15 years ago
|
|
||
|
/**
|
||
|
Fills the keyword map. Reimplement it if you want additional
|
||
|
keywords.
|
||
|
*/
|
||
|
void setupKeywords();
|
||
|
|
||
|
private:
|
||
15 years ago
|
TQDate parseDate( bool* = 0 ) const;
|
||
15 years ago
|
void updateView();
|
||
|
|
||
|
KDatePickerPopup *mPopup;
|
||
|
|
||
15 years ago
|
TQDate mDate;
|
||
15 years ago
|
bool mReadOnly;
|
||
|
bool mTextChanged;
|
||
|
bool mDiscardNextMousePress;
|
||
|
|
||
15 years ago
|
TQMap<TQString, int> mKeywordMap;
|
||
15 years ago
|
};
|
||
|
|
||
|
#endif
|