-rw-r--r-- | microkde/kdatetbl.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/microkde/kdatetbl.h b/microkde/kdatetbl.h index b4d3e16..2efa532 100644 --- a/microkde/kdatetbl.h +++ b/microkde/kdatetbl.h | |||
@@ -54,256 +54,319 @@ signals: | |||
54 | */ | 54 | */ |
55 | void closeMe(int); | 55 | void closeMe(int); |
56 | public: | 56 | public: |
57 | /** | 57 | /** |
58 | * The constructor. | 58 | * The constructor. |
59 | */ | 59 | */ |
60 | KDateInternalMonthPicker(int fontsize, QWidget* parent, const char* name=0); | 60 | KDateInternalMonthPicker(int fontsize, QWidget* parent, const char* name=0); |
61 | /** | 61 | /** |
62 | * The size hint. | 62 | * The size hint. |
63 | */ | 63 | */ |
64 | QSize sizeHint() const; | 64 | QSize sizeHint() const; |
65 | /** | 65 | /** |
66 | * Return the result. 0 means no selection (reject()), 1..12 are the | 66 | * Return the result. 0 means no selection (reject()), 1..12 are the |
67 | * months. | 67 | * months. |
68 | */ | 68 | */ |
69 | int getResult() const; | 69 | int getResult() const; |
70 | protected: | 70 | protected: |
71 | /** | 71 | /** |
72 | * Set up the painter. | 72 | * Set up the painter. |
73 | */ | 73 | */ |
74 | void setupPainter(QPainter *p); | 74 | void setupPainter(QPainter *p); |
75 | /** | 75 | /** |
76 | * The resize event. | 76 | * The resize event. |
77 | */ | 77 | */ |
78 | void viewportResizeEvent(QResizeEvent*); | 78 | void viewportResizeEvent(QResizeEvent*); |
79 | /** | 79 | /** |
80 | * Paint a cell. This simply draws the month names in it. | 80 | * Paint a cell. This simply draws the month names in it. |
81 | */ | 81 | */ |
82 | virtual void paintCell(QPainter* painter, int row, int col); | 82 | virtual void paintCell(QPainter* painter, int row, int col); |
83 | /** | 83 | /** |
84 | * Catch mouse click and move events to paint a rectangle around the item. | 84 | * Catch mouse click and move events to paint a rectangle around the item. |
85 | */ | 85 | */ |
86 | void contentsMousePressEvent(QMouseEvent *e); | 86 | void contentsMousePressEvent(QMouseEvent *e); |
87 | void contentsMouseMoveEvent(QMouseEvent *e); | 87 | void contentsMouseMoveEvent(QMouseEvent *e); |
88 | /** | 88 | /** |
89 | * Emit monthSelected(int) when a cell has been released. | 89 | * Emit monthSelected(int) when a cell has been released. |
90 | */ | 90 | */ |
91 | void contentsMouseReleaseEvent(QMouseEvent *e); | 91 | void contentsMouseReleaseEvent(QMouseEvent *e); |
92 | 92 | ||
93 | private: | 93 | private: |
94 | class KDateInternalMonthPrivate; | 94 | class KDateInternalMonthPrivate; |
95 | KDateInternalMonthPrivate *d; | 95 | KDateInternalMonthPrivate *d; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | /** Year selection widget. | 98 | /** Year selection widget. |
99 | * @internal | 99 | * @internal |
100 | * @version $Id$ | 100 | * @version $Id$ |
101 | * @author Tim Gilman, Mirko Boehm | 101 | * @author Tim Gilman, Mirko Boehm |
102 | */ | 102 | */ |
103 | class KDateInternalYearSelector : public QLineEdit | 103 | class KDateInternalYearSelector : public QLineEdit |
104 | { | 104 | { |
105 | Q_OBJECT | 105 | Q_OBJECT |
106 | protected: | 106 | protected: |
107 | QIntValidator *val; | 107 | QIntValidator *val; |
108 | int result; | 108 | int result; |
109 | public slots: | 109 | public slots: |
110 | void yearEnteredSlot(); | 110 | void yearEnteredSlot(); |
111 | signals: | 111 | signals: |
112 | void closeMe(int); | 112 | void closeMe(int); |
113 | public: | 113 | public: |
114 | KDateInternalYearSelector(int fontsize, | 114 | KDateInternalYearSelector(int fontsize, |
115 | QWidget* parent=0, | 115 | QWidget* parent=0, |
116 | const char* name=0); | 116 | const char* name=0); |
117 | int getYear(); | 117 | int getYear(); |
118 | void setYear(int year); | 118 | void setYear(int year); |
119 | 119 | ||
120 | private: | 120 | private: |
121 | class KDateInternalYearPrivate; | 121 | class KDateInternalYearPrivate; |
122 | KDateInternalYearPrivate *d; | 122 | KDateInternalYearPrivate *d; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | /** | 125 | /** |
126 | * Frame with popup menu behaviour. | 126 | * Frame with popup menu behaviour. |
127 | * @author Tim Gilman, Mirko Boehm | 127 | * @author Tim Gilman, Mirko Boehm |
128 | * @version $Id$ | 128 | * @version $Id$ |
129 | */ | 129 | */ |
130 | class KPopupFrame : public QFrame | 130 | class KPopupFrame : public QFrame |
131 | { | 131 | { |
132 | Q_OBJECT | 132 | Q_OBJECT |
133 | protected: | 133 | protected: |
134 | /** | 134 | /** |
135 | * The result. It is returned from exec() when the popup window closes. | 135 | * The result. It is returned from exec() when the popup window closes. |
136 | */ | 136 | */ |
137 | int result; | 137 | int result; |
138 | /** | 138 | /** |
139 | * Catch key press events. | 139 | * Catch key press events. |
140 | */ | 140 | */ |
141 | void keyPressEvent(QKeyEvent* e); | 141 | void keyPressEvent(QKeyEvent* e); |
142 | /** | 142 | /** |
143 | * The only subwidget that uses the whole dialog window. | 143 | * The only subwidget that uses the whole dialog window. |
144 | */ | 144 | */ |
145 | QWidget *main; | 145 | QWidget *main; |
146 | public slots: | 146 | public slots: |
147 | /** | 147 | /** |
148 | * Close the popup window. This is called from the main widget, usually. | 148 | * Close the popup window. This is called from the main widget, usually. |
149 | * @p r is the result returned from exec(). | 149 | * @p r is the result returned from exec(). |
150 | */ | 150 | */ |
151 | void close(int r); | 151 | void close(int r); |
152 | public: | 152 | public: |
153 | /** | 153 | /** |
154 | * The contructor. Creates a dialog without buttons. | 154 | * The contructor. Creates a dialog without buttons. |
155 | */ | 155 | */ |
156 | KPopupFrame(QWidget* parent=0, const char* name=0); | 156 | KPopupFrame(QWidget* parent=0, const char* name=0); |
157 | /** | 157 | /** |
158 | * Set the main widget. You cannot set the main widget from the constructor, | 158 | * Set the main widget. You cannot set the main widget from the constructor, |
159 | * since it must be a child of the frame itselfes. | 159 | * since it must be a child of the frame itselfes. |
160 | * Be careful: the size is set to the main widgets size. It is up to you to | 160 | * Be careful: the size is set to the main widgets size. It is up to you to |
161 | * set the main widgets correct size before setting it as the main | 161 | * set the main widgets correct size before setting it as the main |
162 | * widget. | 162 | * widget. |
163 | */ | 163 | */ |
164 | void setMainWidget(QWidget* m); | 164 | void setMainWidget(QWidget* m); |
165 | /** | 165 | /** |
166 | * The resize event. Simply resizes the main widget to the whole | 166 | * The resize event. Simply resizes the main widget to the whole |
167 | * widgets client size. | 167 | * widgets client size. |
168 | */ | 168 | */ |
169 | void resizeEvent(QResizeEvent*); | 169 | void resizeEvent(QResizeEvent*); |
170 | /** | 170 | /** |
171 | * Open the popup window at position pos. | 171 | * Open the popup window at position pos. |
172 | */ | 172 | */ |
173 | void popup(const QPoint &pos); | 173 | void popup(const QPoint &pos); |
174 | /** | 174 | /** |
175 | * Execute the popup window. | 175 | * Execute the popup window. |
176 | */ | 176 | */ |
177 | int exec(QPoint p); | 177 | int exec(QPoint p); |
178 | /** | 178 | /** |
179 | * Dito. | 179 | * Dito. |
180 | */ | 180 | */ |
181 | int exec(int x, int y); | 181 | int exec(int x, int y); |
182 | 182 | ||
183 | private: | 183 | private: |
184 | 184 | ||
185 | virtual bool close(bool alsoDelete) { return QFrame::close(alsoDelete); } | 185 | virtual bool close(bool alsoDelete) { return QFrame::close(alsoDelete); } |
186 | protected: | 186 | protected: |
187 | virtual void virtual_hook( int id, void* data ); | 187 | virtual void virtual_hook( int id, void* data ); |
188 | private: | 188 | private: |
189 | class KPopupFramePrivate; | 189 | class KPopupFramePrivate; |
190 | KPopupFramePrivate *d; | 190 | KPopupFramePrivate *d; |
191 | }; | 191 | }; |
192 | 192 | ||
193 | /** | 193 | /** |
194 | * Validates user-entered dates. | 194 | * Validates user-entered dates. |
195 | */ | 195 | */ |
196 | class KDateValidator : public QValidator | 196 | class KDateValidator : public QValidator |
197 | { | 197 | { |
198 | public: | 198 | public: |
199 | KDateValidator(QWidget* parent=0, const char* name=0); | 199 | KDateValidator(QWidget* parent=0, const char* name=0); |
200 | virtual State validate(QString&, int&) const; | 200 | virtual State validate(QString&, int&) const; |
201 | virtual void fixup ( QString & input ) const; | 201 | virtual void fixup ( QString & input ) const; |
202 | State date(const QString&, QDate&) const; | 202 | State date(const QString&, QDate&) const; |
203 | }; | 203 | }; |
204 | 204 | ||
205 | /** | 205 | /** |
206 | * Date selection table. | 206 | * Date selection table. |
207 | * This is a support class for the KDatePicker class. It just | 207 | * This is a support class for the KDatePicker class. It just |
208 | * draws the calender table without titles, but could theoretically | 208 | * draws the calender table without titles, but could theoretically |
209 | * be used as a standalone. | 209 | * be used as a standalone. |
210 | * | 210 | * |
211 | * When a date is selected by the user, it emits a signal: | 211 | * When a date is selected by the user, it emits a signal: |
212 | * dateSelected(QDate) | 212 | * dateSelected(QDate) |
213 | * | 213 | * |
214 | * @internal | 214 | * @internal |
215 | * @version $Id$ | 215 | * @version $Id$ |
216 | * @author Tim Gilman, Mirko Boehm | 216 | * @author Tim Gilman, Mirko Boehm |
217 | */ | 217 | */ |
218 | class KDateTable : public QGridView | 218 | class KDateTable : public QGridView |
219 | { | 219 | { |
220 | Q_OBJECT | 220 | Q_OBJECT |
221 | public: | 221 | public: |
222 | /** | 222 | /** |
223 | * The constructor. | 223 | * The constructor. |
224 | */ | 224 | */ |
225 | KDateTable(QWidget *parent=0, | 225 | KDateTable(QWidget *parent=0, |
226 | QDate date=QDate::currentDate(), | 226 | QDate date=QDate::currentDate(), |
227 | const char* name=0, WFlags f=0); | 227 | const char* name=0, WFlags f=0); |
228 | /** | 228 | /** |
229 | * Returns a recommended size for the widget. | 229 | * Returns a recommended size for the widget. |
230 | * To save some time, the size of the largest used cell content is | 230 | * To save some time, the size of the largest used cell content is |
231 | * calculated in each paintCell() call, since all calculations have | 231 | * calculated in each paintCell() call, since all calculations have |
232 | * to be done there anyway. The size is stored in maxCell. The | 232 | * to be done there anyway. The size is stored in maxCell. The |
233 | * sizeHint() simply returns a multiple of maxCell. | 233 | * sizeHint() simply returns a multiple of maxCell. |
234 | */ | 234 | */ |
235 | virtual QSize sizeHint() const; | 235 | virtual QSize sizeHint() const; |
236 | /** | 236 | /** |
237 | * Set the font size of the date table. | 237 | * Set the font size of the date table. |
238 | */ | 238 | */ |
239 | void setFontSize(int size); | 239 | void setFontSize(int size); |
240 | /** | 240 | /** |
241 | * Select and display this date. | 241 | * Select and display this date. |
242 | */ | 242 | */ |
243 | bool setDate(const QDate&); | 243 | bool setDate(const QDate&); |
244 | const QDate& getDate() const; | 244 | const QDate& getDate() const; |
245 | 245 | ||
246 | 246 | ||
247 | protected: | 247 | protected: |
248 | bool mMarkCurrent; | 248 | bool mMarkCurrent; |
249 | /** | 249 | /** |
250 | * Paint a cell. | 250 | * Paint a cell. |
251 | */ | 251 | */ |
252 | virtual void paintCell(QPainter*, int, int); | 252 | virtual void paintCell(QPainter*, int, int); |
253 | /** | 253 | /** |
254 | * Handle the resize events. | 254 | * Handle the resize events. |
255 | */ | 255 | */ |
256 | virtual void viewportResizeEvent(QResizeEvent *); | 256 | virtual void viewportResizeEvent(QResizeEvent *); |
257 | /** | 257 | /** |
258 | * React on mouse clicks that select a date. | 258 | * React on mouse clicks that select a date. |
259 | */ | 259 | */ |
260 | virtual void contentsMousePressEvent(QMouseEvent *); | 260 | virtual void contentsMousePressEvent(QMouseEvent *); |
261 | virtual void keyPressEvent( QKeyEvent *e ); | 261 | virtual void keyPressEvent( QKeyEvent *e ); |
262 | virtual void focusInEvent( QFocusEvent *e ); | 262 | virtual void focusInEvent( QFocusEvent *e ); |
263 | virtual void focusOutEvent( QFocusEvent *e ); | 263 | virtual void focusOutEvent( QFocusEvent *e ); |
264 | /** | 264 | /** |
265 | * The font size of the displayed text. | 265 | * The font size of the displayed text. |
266 | */ | 266 | */ |
267 | int fontsize; | 267 | int fontsize; |
268 | /** | 268 | /** |
269 | * The currently selected date. | 269 | * The currently selected date. |
270 | */ | 270 | */ |
271 | QDate date; | 271 | QDate date; |
272 | /** | 272 | /** |
273 | * The day of the first day in the month [1..7]. | 273 | * The day of the first day in the month [1..7]. |
274 | */ | 274 | */ |
275 | int firstday; | 275 | int firstday; |
276 | /** | 276 | /** |
277 | * The number of days in the current month. | 277 | * The number of days in the current month. |
278 | */ | 278 | */ |
279 | int numdays; | 279 | int numdays; |
280 | /** | 280 | /** |
281 | * The number of days in the previous month. | 281 | * The number of days in the previous month. |
282 | */ | 282 | */ |
283 | int numDaysPrevMonth; | 283 | int numDaysPrevMonth; |
284 | /** | 284 | /** |
285 | * unused | 285 | * unused |
286 | */ | 286 | */ |
287 | bool unused_hasSelection; | 287 | bool unused_hasSelection; |
288 | /** | 288 | /** |
289 | * Save the size of the largest used cell content. | 289 | * Save the size of the largest used cell content. |
290 | */ | 290 | */ |
291 | QRect maxCell; | 291 | QRect maxCell; |
292 | signals: | 292 | signals: |
293 | /** | 293 | /** |
294 | * The selected date changed. | 294 | * The selected date changed. |
295 | */ | 295 | */ |
296 | void dateChanged(QDate); | 296 | void dateChanged(QDate); |
297 | /** | 297 | /** |
298 | * A date has been selected by clicking on the table. | 298 | * A date has been selected by clicking on the table. |
299 | */ | 299 | */ |
300 | void tableClicked(); | 300 | void tableClicked(); |
301 | 301 | ||
302 | protected: | 302 | protected: |
303 | virtual void virtual_hook( int id, void* data ); | 303 | virtual void virtual_hook( int id, void* data ); |
304 | private: | 304 | private: |
305 | class KDateTablePrivate; | 305 | class KDateTablePrivate; |
306 | KDateTablePrivate *d; | 306 | KDateTablePrivate *d; |
307 | }; | 307 | }; |
308 | 308 | ||
309 | #endif // KDATETBL_H | 309 | #endif // KDATETBL_H |
310 | class KDateInternalWeekPicker : public QGridView | ||
311 | { | ||
312 | Q_OBJECT | ||
313 | protected: | ||
314 | /** | ||
315 | * Store the month that has been clicked [1..12]. | ||
316 | */ | ||
317 | int result; | ||
318 | /** | ||
319 | * the cell under mouse cursor when LBM is pressed | ||
320 | */ | ||
321 | short int activeCol; | ||
322 | short int activeRow; | ||
323 | /** | ||
324 | * Contains the largest rectangle needed by the month names. | ||
325 | */ | ||
326 | QRect max; | ||
327 | signals: | ||
328 | /** | ||
329 | * This is send from the mouse click event handler. | ||
330 | */ | ||
331 | void closeMe(int); | ||
332 | public: | ||
333 | /** | ||
334 | * The constructor. | ||
335 | */ | ||
336 | KDateInternalWeekPicker(int fontsize, QWidget* parent, const char* name=0); | ||
337 | /** | ||
338 | * The size hint. | ||
339 | */ | ||
340 | QSize sizeHint() const; | ||
341 | /** | ||
342 | * Return the result. 0 means no selection (reject()), 1..12 are the | ||
343 | * months. | ||
344 | */ | ||
345 | int getResult() const; | ||
346 | protected: | ||
347 | /** | ||
348 | * Set up the painter. | ||
349 | */ | ||
350 | void setupPainter(QPainter *p); | ||
351 | /** | ||
352 | * The resize event. | ||
353 | */ | ||
354 | void viewportResizeEvent(QResizeEvent*); | ||
355 | /** | ||
356 | * Paint a cell. This simply draws the month names in it. | ||
357 | */ | ||
358 | virtual void paintCell(QPainter* painter, int row, int col); | ||
359 | /** | ||
360 | * Catch mouse click and move events to paint a rectangle around the item. | ||
361 | */ | ||
362 | void contentsMousePressEvent(QMouseEvent *e); | ||
363 | void contentsMouseMoveEvent(QMouseEvent *e); | ||
364 | /** | ||
365 | * Emit monthSelected(int) when a cell has been released. | ||
366 | */ | ||
367 | void contentsMouseReleaseEvent(QMouseEvent *e); | ||
368 | |||
369 | private: | ||
370 | class KDateInternalMonthPrivate; | ||
371 | KDateInternalMonthPrivate *d; | ||
372 | }; | ||