summaryrefslogtreecommitdiffabout
path: root/libkdepim/kdatepicker.h
authorzautrix <zautrix>2004-06-26 19:01:18 (UTC)
committer zautrix <zautrix>2004-06-26 19:01:18 (UTC)
commitb9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff)
tree2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /libkdepim/kdatepicker.h
downloadkdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2
Initial revision
Diffstat (limited to 'libkdepim/kdatepicker.h') (more/less context) (show whitespace changes)
-rw-r--r--libkdepim/kdatepicker.h181
1 files changed, 181 insertions, 0 deletions
diff --git a/libkdepim/kdatepicker.h b/libkdepim/kdatepicker.h
new file mode 100644
index 0000000..6625357
--- a/dev/null
+++ b/libkdepim/kdatepicker.h
@@ -0,0 +1,181 @@
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 MICROKDE_KDATEPICKER_H
21#define MICROKDE_KDATEPICKER_H
22#include <qdatetime.h>
23#include <qframe.h>
24#include <qevent.h>
25
26class QLineEdit;
27class QToolButton;
28class KDateValidator;
29class KDateTable;
30class KDateEdit;
31
32/**
33 * Provides a widget for calendar date input.
34 *
35 * Different from the
36 * previous versions, it now emits two types of signals, either
37 * @ref dateSelected() or @ref dateEntered() (see documentation for both
38 * signals).
39 *
40 * A line edit has been added in the newer versions to allow the user
41 * to select a date directly by entering numbers like 19990101
42 * or 990101.
43 *
44 * @image kdatepicker.png KDatePicker
45 *
46 * @version $Id$
47 * @author Tim Gilman, Mirko Boehm
48 *
49 * @short A date selection widget.
50 **/
51class KDatePicker: public QFrame
52{
53 Q_OBJECT
54public:
55 /** The usual constructor. The given date will be displayed
56 * initially.
57 **/
58 KDatePicker(QWidget *parent=0,
59 QDate=QDate::currentDate(),
60 const char *name=0);
61 /**
62 * The destructor.
63 **/
64 virtual ~KDatePicker();
65
66 /** The size hint for date pickers. The size hint recommends the
67 * minimum size of the widget so that all elements may be placed
68 * without clipping. This sometimes looks ugly, so when using the
69 * size hint, try adding 28 to each of the reported numbers of
70 * pixels.
71 **/
72 QSize sizeHint() const;
73
74 /**
75 * Sets the date.
76 *
77 * @returns @p false and does not change anything
78 * if the date given is invalid.
79 **/
80 bool setDate(const QDate&);
81
82 /**
83 * Returns the selected date.
84 * @deprecated
85 **/
86 const QDate& getDate() const;
87
88 /**
89 * @returns the selected date.
90 */
91 const QDate &date() const;
92
93 /**
94 * Enables or disables the widget.
95 **/
96 void setEnabled(bool);
97
98 /**
99 * Sets the font size of the widgets elements.
100 **/
101 void setFontSize(int);
102 /**
103 * Returns the font size of the widget elements.
104 */
105 int fontSize() const
106 { return fontsize; }
107protected:
108 /// the resize event
109 void resizeEvent(QResizeEvent*);
110 /// the year forward button
111 QToolButton *yearForward;
112 /// the year backward button
113 QToolButton *yearBackward;
114 /// the month forward button
115 QToolButton *monthForward;
116 /// the month backward button
117 QToolButton *monthBackward;
118 /// the button for selecting the month directly
119 QToolButton *selectMonth;
120 /// the button for selecting the year directly
121 QToolButton *selectYear;
122 /// the line edit to enter the date directly
123 //QLineEdit *line;
124 KDateEdit *lineDate;
125 /// the validator for the line edit:
126 KDateValidator *val;
127 /// the date table
128 KDateTable *table;
129 /// the size calculated during resize events
130 // QSize sizehint;
131 /// the widest month string in pixels:
132 QSize maxMonthRect;
133protected slots:
134 void dateChangedSlot(QDate);
135 void tableClickedSlot();
136 void monthForwardClicked();
137 void monthBackwardClicked();
138 void yearForwardClicked();
139 void yearBackwardClicked();
140 void selectMonthClicked();
141 void selectYearClicked();
142 void lineEnterPressed();
143 void slotSetDate(QDate);
144signals:
145 /** This signal is emitted each time the selected date is changed.
146 * Usually, this does not mean that the date has been entered,
147 * since the date also changes, for example, when another month is
148 * selected.
149 * @see dateSelected
150 */
151 void dateChanged(QDate);
152 /** This signal is emitted each time a day has been selected by
153 * clicking on the table (hitting a day in the current month). It
154 * has the same meaning as dateSelected() in older versions of
155 * KDatePicker.
156 */
157 void dateSelected(QDate);
158 /** This signal is emitted when enter is pressed and a VALID date
159 * has been entered before into the line edit. Connect to both
160 * dateEntered() and dateSelected() to receive all events where the
161 * user really enters a date.
162 */
163 void dateEntered(QDate);
164 /** This signal is emitted when the day has been selected by
165 * clicking on it in the table.
166 */
167 void tableClicked();
168
169private:
170 /// the font size for the widget
171 int fontsize;
172
173protected:
174 virtual void virtual_hook( int id, void* data );
175private:
176 class KDatePickerPrivate;
177 KDatePickerPrivate *d;
178 void keyPressEvent ( QKeyEvent * ) ;
179};
180
181#endif // KDATEPICKER_H