-rw-r--r-- | libkdepim/kdateedit.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/libkdepim/kdateedit.h b/libkdepim/kdateedit.h index cf3b90a..2d8c452 100644 --- a/libkdepim/kdateedit.h +++ b/libkdepim/kdateedit.h | |||
@@ -1,141 +1,143 @@ | |||
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 <qhbox.h> |
28 | #include <qvbox.h> | 28 | #include <qvbox.h> |
29 | #include <qdatetime.h> | 29 | #include <qdatetime.h> |
30 | #include <qmap.h> | 30 | #include <qmap.h> |
31 | 31 | ||
32 | class QLineEdit; | 32 | class QLineEdit; |
33 | class QPushButton; | 33 | class QPushButton; |
34 | class QObject; | 34 | class QObject; |
35 | class QEvent; | 35 | class QEvent; |
36 | class KDatePicker; | 36 | class KDatePicker; |
37 | class KDateValidator; | 37 | class KDateValidator; |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * A date editing widget that consists of a line edit followed by | 40 | * 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, | 41 | * 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. | 42 | * and the push button will display a 'popup' style date picker. |
43 | * | 43 | * |
44 | * This widget also supports advanced features like allowing the user | 44 | * This widget also supports advanced features like allowing the user |
45 | * to type in the day name to get the date. The following keywords | 45 | * to type in the day name to get the date. The following keywords |
46 | * are supported (in the native language): tomorrow, yesturday, today, | 46 | * are supported (in the native language): tomorrow, yesturday, today, |
47 | * monday, tuesday, wednesday, thursday, friday, saturday, sunday. | 47 | * monday, tuesday, wednesday, thursday, friday, saturday, sunday. |
48 | * | 48 | * |
49 | * @author Cornelius Schumacher <schumacher@kde.org> | 49 | * @author Cornelius Schumacher <schumacher@kde.org> |
50 | * @author Mike Pilone <mpilone@slac.com> | 50 | * @author Mike Pilone <mpilone@slac.com> |
51 | */ | 51 | */ |
52 | class KDateEdit : public QHBox | 52 | class KDateEdit : public QHBox |
53 | { | 53 | { |
54 | Q_OBJECT | 54 | Q_OBJECT |
55 | public: | 55 | public: |
56 | KDateEdit(QWidget *parent=0, const char *name=0, bool withoutDP = false ); | 56 | KDateEdit(QWidget *parent=0, const char *name=0, bool withoutDP = false ); |
57 | virtual ~KDateEdit(); | 57 | virtual ~KDateEdit(); |
58 | 58 | ||
59 | /** @return True if the date in the text edit is valid, | 59 | /** @return True if the date in the text edit is valid, |
60 | * false otherwise. This will not modify the display of the date, | 60 | * false otherwise. This will not modify the display of the date, |
61 | * but only check for validity. | 61 | * but only check for validity. |
62 | */ | 62 | */ |
63 | bool inputIsValid(); | 63 | bool inputIsValid(); |
64 | 64 | ||
65 | /** @return The date entered. This will not | 65 | /** @return The date entered. This will not |
66 | * modify the display of the date, but only return it. | 66 | * modify the display of the date, but only return it. |
67 | */ | 67 | */ |
68 | QDate date() const; | 68 | QDate date() const; |
69 | 69 | ||
70 | /** @param handleInvalid If true the date edit accepts invalid dates | 70 | /** @param handleInvalid If true the date edit accepts invalid dates |
71 | * and displays them as the empty ("") string. It also returns an invalid date. | 71 | * 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 | 72 | * If false (default) invalid dates are not accepted and instead the date |
73 | * of today will be returned. | 73 | * of today will be returned. |
74 | */ | 74 | */ |
75 | void setHandleInvalid(bool handleInvalid); | 75 | void setHandleInvalid(bool handleInvalid); |
76 | 76 | ||
77 | /** Checks for a focus out event. The display of the date is updated | 77 | /** Checks for a focus out event. The display of the date is updated |
78 | * to display the proper date when the focus leaves. | 78 | * to display the proper date when the focus leaves. |
79 | */ | 79 | */ |
80 | virtual bool eventFilter(QObject *o, QEvent *e); | 80 | virtual bool eventFilter(QObject *o, QEvent *e); |
81 | void toggleDateFormat(); | 81 | void toggleDateFormat(); |
82 | void clear(); | 82 | void clear(); |
83 | signals: | 83 | signals: |
84 | /** This signal is emitted whenever the user modifies the date. This | 84 | /** 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 | 85 | * 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). | 86 | * focus leaves the widget (ie: the user confirms their selection). |
87 | */ | 87 | */ |
88 | void dateChanged(QDate); | 88 | void dateChanged(QDate); |
89 | void returnPressed(); | 89 | void returnPressed(); |
90 | void setTimeTo( QTime ); | ||
90 | public slots: | 91 | public slots: |
91 | /** Sets the date. | 92 | /** Sets the date. |
92 | * | 93 | * |
93 | * @param date The new date to display. This date must be valid or | 94 | * @param date The new date to display. This date must be valid or |
94 | * it will not be displayed. | 95 | * it will not be displayed. |
95 | */ | 96 | */ |
96 | void setDate(QDate date); | 97 | void setDate(QDate date); |
97 | // set Date with key_up key_down to relation of cursor Position | 98 | // set Date with key_up key_down to relation of cursor Position |
98 | // and set selection from begin to end of single date | 99 | // and set selection from begin to end of single date |
99 | void setDate(QDate, int *cpos, const int, const bool); | 100 | void setDate(QDate, int *cpos, const int, const bool); |
100 | 101 | ||
101 | /** Sets the date edit to be enabled or disabled (grayed out) | 102 | /** Sets the date edit to be enabled or disabled (grayed out) |
102 | * | 103 | * |
103 | * @param on Enabled if true, disabled if false | 104 | * @param on Enabled if true, disabled if false |
104 | */ | 105 | */ |
105 | void setEnabled(bool on); | 106 | void setEnabled(bool on); |
106 | 107 | ||
107 | protected slots: | 108 | protected slots: |
108 | void toggleDatePicker(); | 109 | void toggleDatePicker(); |
109 | void lineEnterPressed(); | 110 | void lineEnterPressed(); |
110 | void textChanged(const QString &); | 111 | void textChanged(const QString &); |
112 | void goToNow(); | ||
111 | 113 | ||
112 | private: | 114 | private: |
113 | /** Reads the text from the line edit. If the text is a keyword, the | 115 | /** Reads the text from the line edit. If the text is a keyword, the |
114 | * word will be translated to a date. If the text is not a keyword, the | 116 | * word will be translated to a date. If the text is not a keyword, the |
115 | * text will be interpreted as a date. | 117 | * text will be interpreted as a date. |
116 | */ | 118 | */ |
117 | QDate readDate() const; | 119 | QDate readDate() const; |
118 | 120 | ||
119 | /** Maps the text that the user can enter to the offset in days from | 121 | /** Maps the text that the user can enter to the offset in days from |
120 | * today. For example, the text 'tomorrow' is mapped to +1. | 122 | * today. For example, the text 'tomorrow' is mapped to +1. |
121 | */ | 123 | */ |
122 | QMap<QString, int> mKeywordMap; | 124 | QMap<QString, int> mKeywordMap; |
123 | bool mTextChanged; | 125 | bool mTextChanged; |
124 | bool mHandleInvalid; | 126 | bool mHandleInvalid; |
125 | 127 | ||
126 | QPushButton *mDateButton; | 128 | QPushButton *mDateButton; |
127 | QLineEdit *mDateEdit; | 129 | QLineEdit *mDateEdit; |
128 | KDatePicker *mDatePicker; | 130 | KDatePicker *mDatePicker; |
129 | QVBox *mDateFrame; | 131 | QVBox *mDateFrame; |
130 | int maxDay; | 132 | int maxDay; |
131 | bool withoutDp; | 133 | bool withoutDp; |
132 | 134 | ||
133 | protected: | 135 | protected: |
134 | virtual void keyPressEvent(QKeyEvent *qke); | 136 | virtual void keyPressEvent(QKeyEvent *qke); |
135 | void setSelect ( int, int ); | 137 | void setSelect ( int, int ); |
136 | bool dateFormShort; | 138 | bool dateFormShort; |
137 | char lengthMonthName; | 139 | char lengthMonthName; |
138 | 140 | ||
139 | }; | 141 | }; |
140 | 142 | ||
141 | #endif | 143 | #endif |