-rw-r--r-- | libkdepim/kdateedit.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libkdepim/kdateedit.h b/libkdepim/kdateedit.h index 2d8c452..38eacde 100644 --- a/libkdepim/kdateedit.h +++ b/libkdepim/kdateedit.h | |||
@@ -1,143 +1,146 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | 3 | ||
4 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef KDATEEDIT_H | 24 | #ifndef KDATEEDIT_H |
25 | #define KDATEEDIT_H | 25 | #define KDATEEDIT_H |
26 | 26 | ||
27 | #include <qhbox.h> | 27 | #include <q3hbox.h> |
28 | #include <qvbox.h> | 28 | #include <q3vbox.h> |
29 | #include <qdatetime.h> | 29 | #include <qdatetime.h> |
30 | #include <qmap.h> | 30 | #include <qmap.h> |
31 | //Added by qt3to4: | ||
32 | #include <QKeyEvent> | ||
33 | #include <QEvent> | ||
31 | 34 | ||
32 | class QLineEdit; | 35 | class QLineEdit; |
33 | class QPushButton; | 36 | class QPushButton; |
34 | class QObject; | 37 | class QObject; |
35 | class QEvent; | 38 | class QEvent; |
36 | class KDatePicker; | 39 | class KDatePicker; |
37 | class KDateValidator; | 40 | class KDateValidator; |
38 | 41 | ||
39 | /** | 42 | /** |
40 | * A date editing widget that consists of a line edit followed by | 43 | * A date editing widget that consists of a line edit followed by |
41 | * a small push button. The line edit contains the date in text form, | 44 | * a small push button. The line edit contains the date in text form, |
42 | * and the push button will display a 'popup' style date picker. | 45 | * and the push button will display a 'popup' style date picker. |
43 | * | 46 | * |
44 | * This widget also supports advanced features like allowing the user | 47 | * This widget also supports advanced features like allowing the user |
45 | * to type in the day name to get the date. The following keywords | 48 | * to type in the day name to get the date. The following keywords |
46 | * are supported (in the native language): tomorrow, yesturday, today, | 49 | * are supported (in the native language): tomorrow, yesturday, today, |
47 | * monday, tuesday, wednesday, thursday, friday, saturday, sunday. | 50 | * monday, tuesday, wednesday, thursday, friday, saturday, sunday. |
48 | * | 51 | * |
49 | * @author Cornelius Schumacher <schumacher@kde.org> | 52 | * @author Cornelius Schumacher <schumacher@kde.org> |
50 | * @author Mike Pilone <mpilone@slac.com> | 53 | * @author Mike Pilone <mpilone@slac.com> |
51 | */ | 54 | */ |
52 | class KDateEdit : public QHBox | 55 | class KDateEdit : public Q3HBox |
53 | { | 56 | { |
54 | Q_OBJECT | 57 | Q_OBJECT |
55 | public: | 58 | public: |
56 | KDateEdit(QWidget *parent=0, const char *name=0, bool withoutDP = false ); | 59 | KDateEdit(QWidget *parent=0, const char *name=0, bool withoutDP = false ); |
57 | virtual ~KDateEdit(); | 60 | virtual ~KDateEdit(); |
58 | 61 | ||
59 | /** @return True if the date in the text edit is valid, | 62 | /** @return True if the date in the text edit is valid, |
60 | * false otherwise. This will not modify the display of the date, | 63 | * false otherwise. This will not modify the display of the date, |
61 | * but only check for validity. | 64 | * but only check for validity. |
62 | */ | 65 | */ |
63 | bool inputIsValid(); | 66 | bool inputIsValid(); |
64 | 67 | ||
65 | /** @return The date entered. This will not | 68 | /** @return The date entered. This will not |
66 | * modify the display of the date, but only return it. | 69 | * modify the display of the date, but only return it. |
67 | */ | 70 | */ |
68 | QDate date() const; | 71 | QDate date() const; |
69 | 72 | ||
70 | /** @param handleInvalid If true the date edit accepts invalid dates | 73 | /** @param handleInvalid If true the date edit accepts invalid dates |
71 | * and displays them as the empty ("") string. It also returns an invalid date. | 74 | * and displays them as the empty ("") string. It also returns an invalid date. |
72 | * If false (default) invalid dates are not accepted and instead the date | 75 | * If false (default) invalid dates are not accepted and instead the date |
73 | * of today will be returned. | 76 | * of today will be returned. |
74 | */ | 77 | */ |
75 | void setHandleInvalid(bool handleInvalid); | 78 | void setHandleInvalid(bool handleInvalid); |
76 | 79 | ||
77 | /** Checks for a focus out event. The display of the date is updated | 80 | /** Checks for a focus out event. The display of the date is updated |
78 | * to display the proper date when the focus leaves. | 81 | * to display the proper date when the focus leaves. |
79 | */ | 82 | */ |
80 | virtual bool eventFilter(QObject *o, QEvent *e); | 83 | virtual bool eventFilter(QObject *o, QEvent *e); |
81 | void toggleDateFormat(); | 84 | void toggleDateFormat(); |
82 | void clear(); | 85 | void clear(); |
83 | signals: | 86 | signals: |
84 | /** This signal is emitted whenever the user modifies the date. This | 87 | /** This signal is emitted whenever the user modifies the date. This |
85 | * may not get emitted until the user presses enter in the line edit or | 88 | * may not get emitted until the user presses enter in the line edit or |
86 | * focus leaves the widget (ie: the user confirms their selection). | 89 | * focus leaves the widget (ie: the user confirms their selection). |
87 | */ | 90 | */ |
88 | void dateChanged(QDate); | 91 | void dateChanged(QDate); |
89 | void returnPressed(); | 92 | void returnPressed(); |
90 | void setTimeTo( QTime ); | 93 | void setTimeTo( QTime ); |
91 | public slots: | 94 | public slots: |
92 | /** Sets the date. | 95 | /** Sets the date. |
93 | * | 96 | * |
94 | * @param date The new date to display. This date must be valid or | 97 | * @param date The new date to display. This date must be valid or |
95 | * it will not be displayed. | 98 | * it will not be displayed. |
96 | */ | 99 | */ |
97 | void setDate(QDate date); | 100 | void setDate(QDate date); |
98 | // set Date with key_up key_down to relation of cursor Position | 101 | // set Date with key_up key_down to relation of cursor Position |
99 | // and set selection from begin to end of single date | 102 | // and set selection from begin to end of single date |
100 | void setDate(QDate, int *cpos, const int, const bool); | 103 | void setDate(QDate, int *cpos, const int, const bool); |
101 | 104 | ||
102 | /** Sets the date edit to be enabled or disabled (grayed out) | 105 | /** Sets the date edit to be enabled or disabled (grayed out) |
103 | * | 106 | * |
104 | * @param on Enabled if true, disabled if false | 107 | * @param on Enabled if true, disabled if false |
105 | */ | 108 | */ |
106 | void setEnabled(bool on); | 109 | void setEnabled(bool on); |
107 | 110 | ||
108 | protected slots: | 111 | protected slots: |
109 | void toggleDatePicker(); | 112 | void toggleDatePicker(); |
110 | void lineEnterPressed(); | 113 | void lineEnterPressed(); |
111 | void textChanged(const QString &); | 114 | void textChanged(const QString &); |
112 | void goToNow(); | 115 | void goToNow(); |
113 | 116 | ||
114 | private: | 117 | private: |
115 | /** Reads the text from the line edit. If the text is a keyword, the | 118 | /** Reads the text from the line edit. If the text is a keyword, the |
116 | * word will be translated to a date. If the text is not a keyword, the | 119 | * word will be translated to a date. If the text is not a keyword, the |
117 | * text will be interpreted as a date. | 120 | * text will be interpreted as a date. |
118 | */ | 121 | */ |
119 | QDate readDate() const; | 122 | QDate readDate() const; |
120 | 123 | ||
121 | /** Maps the text that the user can enter to the offset in days from | 124 | /** Maps the text that the user can enter to the offset in days from |
122 | * today. For example, the text 'tomorrow' is mapped to +1. | 125 | * today. For example, the text 'tomorrow' is mapped to +1. |
123 | */ | 126 | */ |
124 | QMap<QString, int> mKeywordMap; | 127 | QMap<QString, int> mKeywordMap; |
125 | bool mTextChanged; | 128 | bool mTextChanged; |
126 | bool mHandleInvalid; | 129 | bool mHandleInvalid; |
127 | 130 | ||
128 | QPushButton *mDateButton; | 131 | QPushButton *mDateButton; |
129 | QLineEdit *mDateEdit; | 132 | QLineEdit *mDateEdit; |
130 | KDatePicker *mDatePicker; | 133 | KDatePicker *mDatePicker; |
131 | QVBox *mDateFrame; | 134 | Q3VBox *mDateFrame; |
132 | int maxDay; | 135 | int maxDay; |
133 | bool withoutDp; | 136 | bool withoutDp; |
134 | 137 | ||
135 | protected: | 138 | protected: |
136 | virtual void keyPressEvent(QKeyEvent *qke); | 139 | virtual void keyPressEvent(QKeyEvent *qke); |
137 | void setSelect ( int, int ); | 140 | void setSelect ( int, int ); |
138 | bool dateFormShort; | 141 | bool dateFormShort; |
139 | char lengthMonthName; | 142 | char lengthMonthName; |
140 | 143 | ||
141 | }; | 144 | }; |
142 | 145 | ||
143 | #endif | 146 | #endif |