2 This file is part of the KDE libraries
3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
4 (C) 1998-2001 Mirko Boehm (mirko@kde.org)
5 (C) 2004 Jason Harris (jharris@30doradus.org)
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.
22 #ifndef EXTDATEPICKER_H
23 #define EXTDATEPICKER_H
26 #include "extdatetime.h"
30 class ExtDateValidator
;
34 * Provides a widget for calendar date input.
37 * previous versions, it now emits two types of signals, either
38 * dateSelected() or dateEntered() (see documentation for both
41 * A line edit has been added in the newer versions to allow the user
42 * to select a date directly by entering numbers like 19990101
45 * \image html kdatepicker.png "KDE Date Widget"
48 * @author Tim Gilman, Mirko Boehm
50 * @short A date selection widget.
52 class KDE_EXPORT ExtDatePicker
: public QFrame
55 // Q_PROPERTY( ExtDate date READ date WRITE setDate)
56 Q_PROPERTY( bool closeButton READ hasCloseButton WRITE setCloseButton
)
57 Q_PROPERTY( int fontSize READ fontSize WRITE setFontSize
)
60 /** The usual constructor. The given date will be displayed
63 ExtDatePicker(QWidget
*parent
=0,
64 ExtDate
=ExtDate::currentDate(),
67 /** The usual constructor. The given date will be displayed
71 ExtDatePicker(QWidget
*parent
,
74 WFlags f
); // ### KDE 4.0: Merge
77 * Standard qt widget constructor. The initial date will be the
81 ExtDatePicker( QWidget
*parent
, const char *name
);
86 virtual ~ExtDatePicker();
88 /** The size hint for date pickers. The size hint recommends the
89 * minimum size of the widget so that all elements may be placed
90 * without clipping. This sometimes looks ugly, so when using the
91 * size hint, try adding 28 to each of the reported numbers of
94 QSize
sizeHint() const;
99 * @returns @p false and does not change anything
100 * if the date given is invalid.
102 bool setDate(const ExtDate
&);
105 * Returns the selected date.
108 const ExtDate
& getDate() const KDE_DEPRECATED
;
111 * @returns the selected date.
113 const ExtDate
&date() const;
116 * Enables or disables the widget.
118 void setEnabled(bool);
121 * @returns the ExtDateTable widget child of this ExtDatePicker
125 ExtDateTable
*dateTable() const { return table
; };
128 * Sets the font size of the widgets elements.
130 void setFontSize(int);
132 * Returns the font size of the widget elements.
138 * By calling this method with @p enable = true, ExtDatePicker will show
139 * a little close-button in the upper button-row. Clicking the
140 * close-button will cause the ExtDatePicker's topLevelWidget()'s close()
141 * method being called. This is mostly useful for toplevel datepickers
142 * without a window manager decoration.
143 * @see hasCloseButton
146 void setCloseButton( bool enable
);
149 * @returns true if a ExtDatePicker shows a close-button.
150 * @see setCloseButton
153 bool hasCloseButton() const;
156 /// to catch move keyEvents when QLineEdit has keyFocus
157 virtual bool eventFilter(QObject
*o
, QEvent
*e
);
159 virtual void resizeEvent(QResizeEvent
*);
160 /// the year forward button
161 QToolButton
*yearForward
;
162 /// the year backward button
163 QToolButton
*yearBackward
;
164 /// the month forward button
165 QToolButton
*monthForward
;
166 /// the month backward button
167 QToolButton
*monthBackward
;
168 /// the button for selecting the month directly
169 QToolButton
*selectMonth
;
170 /// the button for selecting the year directly
171 QToolButton
*selectYear
;
172 /// the line edit to enter the date directly
174 /// the validator for the line edit:
175 ExtDateValidator
*val
;
178 /// the size calculated during resize events
180 /// the widest month string in pixels:
183 void dateChangedSlot(const ExtDate
&);
184 void tableClickedSlot();
185 void monthForwardClicked();
186 void monthBackwardClicked();
187 void yearForwardClicked();
188 void yearBackwardClicked();
193 void selectWeekClicked();
197 void selectMonthClicked();
201 void selectYearClicked();
205 void lineEnterPressed();
209 void todayButtonClicked();
213 void weekSelected(int);
216 /** This signal is emitted each time the selected date is changed.
217 * Usually, this does not mean that the date has been entered,
218 * since the date also changes, for example, when another month is
222 void dateChanged(const ExtDate
&);
223 /** This signal is emitted each time a day has been selected by
224 * clicking on the table (hitting a day in the current month). It
225 * has the same meaning as dateSelected() in older versions of
228 void dateSelected(const ExtDate
&);
229 /** This signal is emitted when enter is pressed and a VALID date
230 * has been entered before into the line edit. Connect to both
231 * dateEntered() and dateSelected() to receive all events where the
232 * user really enters a date.
234 void dateEntered(const ExtDate
&);
235 /** This signal is emitted when the day has been selected by
236 * clicking on it in the table.
241 /// the font size for the widget
245 virtual void virtual_hook( int id
, void* data
);
247 void init( const ExtDate
&dt
);
248 void fillWeeksCombo(const ExtDate
&date
);
249 class ExtDatePickerPrivate
;
250 ExtDatePickerPrivate
*d
;
253 #endif // EXTDATEPICKER_H