summaryrefslogtreecommitdiffabout
path: root/microkde/kdatepickernew.h
Unidiff
Diffstat (limited to 'microkde/kdatepickernew.h') (more/less context) (show whitespace changes)
-rw-r--r--microkde/kdatepickernew.h253
1 files changed, 253 insertions, 0 deletions
diff --git a/microkde/kdatepickernew.h b/microkde/kdatepickernew.h
new file mode 100644
index 0000000..9ea909d
--- a/dev/null
+++ b/microkde/kdatepickernew.h
@@ -0,0 +1,253 @@
1/* -*- C++ -*-
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 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20#ifndef KDATEPICKER_H
21#define KDATEPICKER_H
22#include <qdatetime.h>
23#include <qframe.h>
24#include <kdemacros.h>
25
26class QLineEdit;
27class QToolButton;
28class KDateValidator;
29class KDateTable;
30
31/**
32 * Provides a widget for calendar date input.
33 *
34 * Different from the
35 * previous versions, it now emits two types of signals, either
36 * dateSelected() or dateEntered() (see documentation for both
37 * signals).
38 *
39 * A line edit has been added in the newer versions to allow the user
40 * to select a date directly by entering numbers like 19990101
41 * or 990101.
42 *
43 * \image html kdatepicker.png "KDE Date Widget"
44 *
45 * @version $Id$
46 * @author Tim Gilman, Mirko Boehm
47 *
48 * @short A date selection widget.
49 **/
50class KDatePicker: public QFrame
51{
52 Q_OBJECT
53 Q_PROPERTY( QDate date READ date WRITE setDate)
54 Q_PROPERTY( bool closeButton READ hasCloseButton WRITE setCloseButton )
55 Q_PROPERTY( int fontSize READ fontSize WRITE setFontSize )
56
57public:
58 /** The usual constructor. The given date will be displayed
59 * initially.
60 **/
61 KDatePicker(QWidget *parent=0,
62 QDate=QDate::currentDate(),
63 const char *name=0);
64
65 /** The usual constructor. The given date will be displayed
66 * initially.
67 * @since 3.1
68 **/
69 KDatePicker(QWidget *parent,
70 QDate,
71 const char *name,
72 WFlags f); // ### KDE 4.0: Merge
73
74 /**
75 * Standard qt widget constructor. The initial date will be the
76 * current date.
77 * @since 3.1
78 */
79 KDatePicker( QWidget *parent, const char *name );
80
81 /**
82 * The destructor.
83 **/
84 virtual ~KDatePicker();
85
86 /** The size hint for date pickers. The size hint recommends the
87 * minimum size of the widget so that all elements may be placed
88 * without clipping. This sometimes looks ugly, so when using the
89 * size hint, try adding 28 to each of the reported numbers of
90 * pixels.
91 **/
92 QSize sizeHint() const;
93
94 /**
95 * Sets the date.
96 *
97 * @returns @p false and does not change anything
98 * if the date given is invalid.
99 **/
100 bool setDate(const QDate&);
101
102 /**
103 * Returns the selected date.
104 * @deprecated
105 **/
106 const QDate& getDate() const KDE_DEPRECATED;
107
108 /**
109 * @returns the selected date.
110 */
111 const QDate &date() const;
112
113 /**
114 * Enables or disables the widget.
115 **/
116 void setEnabled(bool);
117
118 /**
119 * @returns the KDateTable widget child of this KDatePicker
120 * widget.
121 * @since 3.2
122 */
123 KDateTable *dateTable() const { return table; };
124
125 /**
126 * Sets the font size of the widgets elements.
127 **/
128 void setFontSize(int);
129 /**
130 * Returns the font size of the widget elements.
131 */
132 int fontSize() const
133 { return fontsize; }
134
135 /**
136 * By calling this method with @p enable = true, KDatePicker will show
137 * a little close-button in the upper button-row. Clicking the
138 * close-button will cause the KDatePicker's topLevelWidget()'s close()
139 * method being called. This is mostly useful for toplevel datepickers
140 * without a window manager decoration.
141 * @see hasCloseButton
142 * @since 3.1
143 */
144 void setCloseButton( bool enable );
145
146 /**
147 * @returns true if a KDatePicker shows a close-button.
148 * @see setCloseButton
149 * @since 3.1
150 */
151 bool hasCloseButton() const;
152
153protected:
154 /// to catch move keyEvents when QLineEdit has keyFocus
155 virtual bool eventFilter(QObject *o, QEvent *e );
156 /// the resize event
157 virtual void resizeEvent(QResizeEvent*);
158 /// the year forward button
159 QToolButton *yearForward;
160 /// the year backward button
161 QToolButton *yearBackward;
162 /// the month forward button
163 QToolButton *monthForward;
164 /// the month backward button
165 QToolButton *monthBackward;
166 /// the button for selecting the month directly
167 QToolButton *selectMonth;
168 /// the button for selecting the year directly
169 QToolButton *selectYear;
170 /// the line edit to enter the date directly
171 QLineEdit *line;
172 /// the validator for the line edit:
173 KDateValidator *val;
174 /// the date table
175 KDateTable *table;
176 /// the size calculated during resize events
177 // QSize sizehint;
178 /// the widest month string in pixels:
179 QSize maxMonthRect;
180protected slots:
181 void dateChangedSlot(QDate);
182 void tableClickedSlot();
183 void monthForwardClicked();
184 void monthBackwardClicked();
185 void yearForwardClicked();
186 void yearBackwardClicked();
187 /**
188 * @since 3.1
189 * @deprecated in 3.2
190 */
191 void selectWeekClicked() KDE_DEPRECATED;
192 /**
193 * @since 3.1
194 */
195 void selectMonthClicked();
196 /**
197 * @since 3.1
198 */
199 void selectYearClicked();
200 /**
201 * @since 3.1
202 */
203 void lineEnterPressed();
204 /**
205 * @since 3.2
206 */
207 void todayButtonClicked();
208 /**
209 * @since 3.2
210 */
211 void weekSelected(int);
212
213signals:
214 // ### KDE 4.0 Make all QDate parameters const references
215
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
219 * selected.
220 * @see dateSelected
221 */
222 void dateChanged(QDate);
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
226 * KDatePicker.
227 */
228 void dateSelected(QDate);
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.
233 */
234 void dateEntered(QDate);
235 /** This signal is emitted when the day has been selected by
236 * clicking on it in the table.
237 */
238 void tableClicked();
239
240private:
241 /// the font size for the widget
242 int fontsize;
243
244protected:
245 virtual void virtual_hook( int id, void* data );
246private:
247 void init( const QDate &dt );
248 void fillWeeksCombo(const QDate &date);
249 class KDatePickerPrivate;
250 KDatePickerPrivate *d;
251};
252
253#endif // KDATEPICKER_H