summaryrefslogtreecommitdiffabout
path: root/microkde/kdatetbl.h
Unidiff
Diffstat (limited to 'microkde/kdatetbl.h') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdatetbl.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/microkde/kdatetbl.h b/microkde/kdatetbl.h
index 87808df..2d3d2cf 100644
--- a/microkde/kdatetbl.h
+++ b/microkde/kdatetbl.h
@@ -1,372 +1,378 @@
1/* -*- C++ -*- 1/* -*- C++ -*-
2 This file is part of the KDE libraries 2 This file is part of the KDE libraries
3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) 3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
4 (C) 1998-2001 Mirko Boehm (mirko@kde.org) 4 (C) 1998-2001 Mirko Boehm (mirko@kde.org)
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 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 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, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef KDATETBL_H 20#ifndef KDATETBL_H
21#define KDATETBL_H 21#define KDATETBL_H
22 22
23#include <qvalidator.h> 23#include <qvalidator.h>
24#include <qgridview.h> 24#include <q3gridview.h>
25#include <qlineedit.h> 25#include <qlineedit.h>
26#include <qdatetime.h> 26#include <qdatetime.h>
27//Added by qt3to4:
28#include <QResizeEvent>
29#include <QMouseEvent>
30#include <Q3Frame>
31#include <QKeyEvent>
32#include <QFocusEvent>
27 33
28/** 34/**
29* A table containing month names. It is used to pick a month directly. 35* A table containing month names. It is used to pick a month directly.
30* @internal 36* @internal
31* @version $Id$ 37* @version $Id$
32* @author Tim Gilman, Mirko Boehm 38* @author Tim Gilman, Mirko Boehm
33*/ 39*/
34class KDateInternalMonthPicker : public QGridView 40class KDateInternalMonthPicker : public Q3GridView
35{ 41{
36 Q_OBJECT 42 Q_OBJECT
37protected: 43protected:
38 /** 44 /**
39 * Store the month that has been clicked [1..12]. 45 * Store the month that has been clicked [1..12].
40 */ 46 */
41 int result; 47 int result;
42 /** 48 /**
43 * the cell under mouse cursor when LBM is pressed 49 * the cell under mouse cursor when LBM is pressed
44 */ 50 */
45 short int activeCol; 51 short int activeCol;
46 short int activeRow; 52 short int activeRow;
47 /** 53 /**
48 * Contains the largest rectangle needed by the month names. 54 * Contains the largest rectangle needed by the month names.
49 */ 55 */
50 QRect max; 56 QRect max;
51signals: 57signals:
52 /** 58 /**
53 * This is send from the mouse click event handler. 59 * This is send from the mouse click event handler.
54 */ 60 */
55 void closeMe(int); 61 void closeMe(int);
56public: 62public:
57 /** 63 /**
58 * The constructor. 64 * The constructor.
59 */ 65 */
60 KDateInternalMonthPicker(QWidget* parent, const char* name=0); 66 KDateInternalMonthPicker(QWidget* parent, const char* name=0);
61 /** 67 /**
62 * The size hint. 68 * The size hint.
63 */ 69 */
64 QSize sizeHint() const; 70 QSize sizeHint() const;
65 /** 71 /**
66 * Return the result. 0 means no selection (reject()), 1..12 are the 72 * Return the result. 0 means no selection (reject()), 1..12 are the
67 * months. 73 * months.
68 */ 74 */
69 int getResult() const; 75 int getResult() const;
70protected: 76protected:
71 /** 77 /**
72 * Set up the painter. 78 * Set up the painter.
73 */ 79 */
74 void setupPainter(QPainter *p); 80 void setupPainter(QPainter *p);
75 /** 81 /**
76 * The resize event. 82 * The resize event.
77 */ 83 */
78 void viewportResizeEvent(QResizeEvent*); 84 void viewportResizeEvent(QResizeEvent*);
79 /** 85 /**
80 * Paint a cell. This simply draws the month names in it. 86 * Paint a cell. This simply draws the month names in it.
81 */ 87 */
82 virtual void paintCell(QPainter* painter, int row, int col); 88 virtual void paintCell(QPainter* painter, int row, int col);
83 /** 89 /**
84 * Catch mouse click and move events to paint a rectangle around the item. 90 * Catch mouse click and move events to paint a rectangle around the item.
85 */ 91 */
86 void contentsMousePressEvent(QMouseEvent *e); 92 void contentsMousePressEvent(QMouseEvent *e);
87 void contentsMouseMoveEvent(QMouseEvent *e); 93 void contentsMouseMoveEvent(QMouseEvent *e);
88 /** 94 /**
89 * Emit monthSelected(int) when a cell has been released. 95 * Emit monthSelected(int) when a cell has been released.
90 */ 96 */
91 void contentsMouseReleaseEvent(QMouseEvent *e); 97 void contentsMouseReleaseEvent(QMouseEvent *e);
92 98
93private: 99private:
94 class KDateInternalMonthPrivate; 100 class KDateInternalMonthPrivate;
95 KDateInternalMonthPrivate *d; 101 KDateInternalMonthPrivate *d;
96}; 102};
97 103
98/** Year selection widget. 104/** Year selection widget.
99* @internal 105* @internal
100* @version $Id$ 106* @version $Id$
101* @author Tim Gilman, Mirko Boehm 107* @author Tim Gilman, Mirko Boehm
102*/ 108*/
103class KDateInternalYearSelector : public QLineEdit 109class KDateInternalYearSelector : public QLineEdit
104{ 110{
105 Q_OBJECT 111 Q_OBJECT
106protected: 112protected:
107 QIntValidator *val; 113 QIntValidator *val;
108 int result; 114 int result;
109public slots: 115public slots:
110 void yearEnteredSlot(); 116 void yearEnteredSlot();
111signals: 117signals:
112 void closeMe(int); 118 void closeMe(int);
113public: 119public:
114 KDateInternalYearSelector(int fontsize, 120 KDateInternalYearSelector(int fontsize,
115 QWidget* parent=0, 121 QWidget* parent=0,
116 const char* name=0); 122 const char* name=0);
117 int getYear(); 123 int getYear();
118 void setYear(int year); 124 void setYear(int year);
119 125
120private: 126private:
121 class KDateInternalYearPrivate; 127 class KDateInternalYearPrivate;
122 KDateInternalYearPrivate *d; 128 KDateInternalYearPrivate *d;
123}; 129};
124 130
125/** 131/**
126 * Frame with popup menu behaviour. 132 * Frame with popup menu behaviour.
127 * @author Tim Gilman, Mirko Boehm 133 * @author Tim Gilman, Mirko Boehm
128 * @version $Id$ 134 * @version $Id$
129 */ 135 */
130class KPopupFrame : public QFrame 136class KPopupFrame : public Q3Frame
131{ 137{
132 Q_OBJECT 138 Q_OBJECT
133protected: 139protected:
134 /** 140 /**
135 * The result. It is returned from exec() when the popup window closes. 141 * The result. It is returned from exec() when the popup window closes.
136 */ 142 */
137 int result; 143 int result;
138 /** 144 /**
139 * Catch key press events. 145 * Catch key press events.
140 */ 146 */
141 void keyPressEvent(QKeyEvent* e); 147 void keyPressEvent(QKeyEvent* e);
142 /** 148 /**
143 * The only subwidget that uses the whole dialog window. 149 * The only subwidget that uses the whole dialog window.
144 */ 150 */
145 QWidget *main; 151 QWidget *main;
146public slots: 152public slots:
147 /** 153 /**
148 * Close the popup window. This is called from the main widget, usually. 154 * Close the popup window. This is called from the main widget, usually.
149 * @p r is the result returned from exec(). 155 * @p r is the result returned from exec().
150 */ 156 */
151 void close(int r); 157 void close(int r);
152public: 158public:
153 /** 159 /**
154 * The contructor. Creates a dialog without buttons. 160 * The contructor. Creates a dialog without buttons.
155 */ 161 */
156 KPopupFrame(QWidget* parent=0, const char* name=0); 162 KPopupFrame(QWidget* parent=0, const char* name=0);
157 /** 163 /**
158 * Set the main widget. You cannot set the main widget from the constructor, 164 * Set the main widget. You cannot set the main widget from the constructor,
159 * since it must be a child of the frame itselfes. 165 * 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 166 * 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 167 * set the main widgets correct size before setting it as the main
162 * widget. 168 * widget.
163 */ 169 */
164 void setMainWidget(QWidget* m); 170 void setMainWidget(QWidget* m);
165 /** 171 /**
166 * The resize event. Simply resizes the main widget to the whole 172 * The resize event. Simply resizes the main widget to the whole
167 * widgets client size. 173 * widgets client size.
168 */ 174 */
169 void resizeEvent(QResizeEvent*); 175 void resizeEvent(QResizeEvent*);
170 /** 176 /**
171 * Open the popup window at position pos. 177 * Open the popup window at position pos.
172 */ 178 */
173 void popup(const QPoint &pos); 179 void popup(const QPoint &pos);
174 /** 180 /**
175 * Execute the popup window. 181 * Execute the popup window.
176 */ 182 */
177 int exec(QPoint p); 183 int exec(QPoint p);
178 /** 184 /**
179 * Dito. 185 * Dito.
180 */ 186 */
181 int exec(int x, int y); 187 int exec(int x, int y);
182 188
183private: 189private:
184 190
185 virtual bool close(bool alsoDelete) { return QFrame::close(alsoDelete); } 191 virtual bool close(bool alsoDelete) { return Q3Frame::close(alsoDelete); }
186protected: 192protected:
187 virtual void virtual_hook( int id, void* data ); 193 virtual void virtual_hook( int id, void* data );
188private: 194private:
189 class KPopupFramePrivate; 195 class KPopupFramePrivate;
190 KPopupFramePrivate *d; 196 KPopupFramePrivate *d;
191}; 197};
192 198
193/** 199/**
194* Validates user-entered dates. 200* Validates user-entered dates.
195*/ 201*/
196class KDateValidator : public QValidator 202class KDateValidator : public QValidator
197{ 203{
198public: 204public:
199 KDateValidator(QWidget* parent=0, const char* name=0); 205 KDateValidator(QWidget* parent=0, const char* name=0);
200 virtual State validate(QString&, int&) const; 206 virtual State validate(QString&, int&) const;
201 virtual void fixup ( QString & input ) const; 207 virtual void fixup ( QString & input ) const;
202 State date(const QString&, QDate&) const; 208 State date(const QString&, QDate&) const;
203}; 209};
204 210
205/** 211/**
206 * Date selection table. 212 * Date selection table.
207 * This is a support class for the KDatePicker class. It just 213 * This is a support class for the KDatePicker class. It just
208 * draws the calender table without titles, but could theoretically 214 * draws the calender table without titles, but could theoretically
209 * be used as a standalone. 215 * be used as a standalone.
210 * 216 *
211 * When a date is selected by the user, it emits a signal: 217 * When a date is selected by the user, it emits a signal:
212 * dateSelected(QDate) 218 * dateSelected(QDate)
213 * 219 *
214 * @internal 220 * @internal
215 * @version $Id$ 221 * @version $Id$
216 * @author Tim Gilman, Mirko Boehm 222 * @author Tim Gilman, Mirko Boehm
217 */ 223 */
218class KDateTable : public QGridView 224class KDateTable : public Q3GridView
219{ 225{
220 Q_OBJECT 226 Q_OBJECT
221public: 227public:
222 /** 228 /**
223 * The constructor. 229 * The constructor.
224 */ 230 */
225 KDateTable(QWidget *parent=0, 231 KDateTable(QWidget *parent=0,
226 QDate date=QDate::currentDate(), 232 QDate date=QDate::currentDate(),
227 const char* name=0, WFlags f=0); 233 const char* name=0, Qt::WFlags f=0);
228 /** 234 /**
229 * Returns a recommended size for the widget. 235 * Returns a recommended size for the widget.
230 * To save some time, the size of the largest used cell content is 236 * To save some time, the size of the largest used cell content is
231 * calculated in each paintCell() call, since all calculations have 237 * calculated in each paintCell() call, since all calculations have
232 * to be done there anyway. The size is stored in maxCell. The 238 * to be done there anyway. The size is stored in maxCell. The
233 * sizeHint() simply returns a multiple of maxCell. 239 * sizeHint() simply returns a multiple of maxCell.
234 */ 240 */
235 virtual QSize sizeHint() const; 241 virtual QSize sizeHint() const;
236 /** 242 /**
237 * Set the font size of the date table. 243 * Set the font size of the date table.
238 */ 244 */
239 void setFontSize(int size); 245 void setFontSize(int size);
240 /** 246 /**
241 * Select and display this date. 247 * Select and display this date.
242 */ 248 */
243 bool setDate(const QDate&); 249 bool setDate(const QDate&);
244 const QDate& getDate() const; 250 const QDate& getDate() const;
245 251
246 252
247protected: 253protected:
248 bool mMarkCurrent; 254 bool mMarkCurrent;
249 /** 255 /**
250 * Paint a cell. 256 * Paint a cell.
251 */ 257 */
252 virtual void paintCell(QPainter*, int, int); 258 virtual void paintCell(QPainter*, int, int);
253 /** 259 /**
254 * Handle the resize events. 260 * Handle the resize events.
255 */ 261 */
256 virtual void viewportResizeEvent(QResizeEvent *); 262 virtual void viewportResizeEvent(QResizeEvent *);
257 /** 263 /**
258 * React on mouse clicks that select a date. 264 * React on mouse clicks that select a date.
259 */ 265 */
260 virtual void contentsMousePressEvent(QMouseEvent *); 266 virtual void contentsMousePressEvent(QMouseEvent *);
261 virtual void keyPressEvent( QKeyEvent *e ); 267 virtual void keyPressEvent( QKeyEvent *e );
262 virtual void focusInEvent( QFocusEvent *e ); 268 virtual void focusInEvent( QFocusEvent *e );
263 virtual void focusOutEvent( QFocusEvent *e ); 269 virtual void focusOutEvent( QFocusEvent *e );
264 /** 270 /**
265 * The font size of the displayed text. 271 * The font size of the displayed text.
266 */ 272 */
267 int fontsize; 273 int fontsize;
268 /** 274 /**
269 * The currently selected date. 275 * The currently selected date.
270 */ 276 */
271 QDate date; 277 QDate date;
272 /** 278 /**
273 * The day of the first day in the month [1..7]. 279 * The day of the first day in the month [1..7].
274 */ 280 */
275 int firstday; 281 int firstday;
276 /** 282 /**
277 * The number of days in the current month. 283 * The number of days in the current month.
278 */ 284 */
279 int numdays; 285 int numdays;
280 /** 286 /**
281 * The number of days in the previous month. 287 * The number of days in the previous month.
282 */ 288 */
283 int numDaysPrevMonth; 289 int numDaysPrevMonth;
284 /** 290 /**
285 * unused 291 * unused
286 */ 292 */
287 bool unused_hasSelection; 293 bool unused_hasSelection;
288 /** 294 /**
289 * Save the size of the largest used cell content. 295 * Save the size of the largest used cell content.
290 */ 296 */
291 QRect maxCell; 297 QRect maxCell;
292signals: 298signals:
293 /** 299 /**
294 * The selected date changed. 300 * The selected date changed.
295 */ 301 */
296 void dateChanged(QDate); 302 void dateChanged(QDate);
297 /** 303 /**
298 * A date has been selected by clicking on the table. 304 * A date has been selected by clicking on the table.
299 */ 305 */
300 void tableClicked(); 306 void tableClicked();
301 307
302protected: 308protected:
303 virtual void virtual_hook( int id, void* data ); 309 virtual void virtual_hook( int id, void* data );
304private: 310private:
305 class KDateTablePrivate; 311 class KDateTablePrivate;
306 KDateTablePrivate *d; 312 KDateTablePrivate *d;
307}; 313};
308 314
309#endif // KDATETBL_H 315#endif // KDATETBL_H
310class KDateInternalWeekPicker : public QGridView 316class KDateInternalWeekPicker : public Q3GridView
311{ 317{
312 Q_OBJECT 318 Q_OBJECT
313protected: 319protected:
314 /** 320 /**
315 * Store the month that has been clicked [1..12]. 321 * Store the month that has been clicked [1..12].
316 */ 322 */
317 int result; 323 int result;
318 /** 324 /**
319 * the cell under mouse cursor when LBM is pressed 325 * the cell under mouse cursor when LBM is pressed
320 */ 326 */
321 short int activeCol; 327 short int activeCol;
322 short int activeRow; 328 short int activeRow;
323 /** 329 /**
324 * Contains the largest rectangle needed by the month names. 330 * Contains the largest rectangle needed by the month names.
325 */ 331 */
326 QRect max; 332 QRect max;
327signals: 333signals:
328 /** 334 /**
329 * This is send from the mouse click event handler. 335 * This is send from the mouse click event handler.
330 */ 336 */
331 void closeMe(int); 337 void closeMe(int);
332public: 338public:
333 /** 339 /**
334 * The constructor. 340 * The constructor.
335 */ 341 */
336 KDateInternalWeekPicker(QWidget* parent, const char* name=0); 342 KDateInternalWeekPicker(QWidget* parent, const char* name=0);
337 /** 343 /**
338 * The size hint. 344 * The size hint.
339 */ 345 */
340 QSize sizeHint() const; 346 QSize sizeHint() const;
341 /** 347 /**
342 * Return the result. 0 means no selection (reject()), 1..12 are the 348 * Return the result. 0 means no selection (reject()), 1..12 are the
343 * months. 349 * months.
344 */ 350 */
345 int getResult() const; 351 int getResult() const;
346protected: 352protected:
347 /** 353 /**
348 * Set up the painter. 354 * Set up the painter.
349 */ 355 */
350 void setupPainter(QPainter *p); 356 void setupPainter(QPainter *p);
351 /** 357 /**
352 * The resize event. 358 * The resize event.
353 */ 359 */
354 void viewportResizeEvent(QResizeEvent*); 360 void viewportResizeEvent(QResizeEvent*);
355 /** 361 /**
356 * Paint a cell. This simply draws the month names in it. 362 * Paint a cell. This simply draws the month names in it.
357 */ 363 */
358 virtual void paintCell(QPainter* painter, int row, int col); 364 virtual void paintCell(QPainter* painter, int row, int col);
359 /** 365 /**
360 * Catch mouse click and move events to paint a rectangle around the item. 366 * Catch mouse click and move events to paint a rectangle around the item.
361 */ 367 */
362 void contentsMousePressEvent(QMouseEvent *e); 368 void contentsMousePressEvent(QMouseEvent *e);
363 void contentsMouseMoveEvent(QMouseEvent *e); 369 void contentsMouseMoveEvent(QMouseEvent *e);
364 /** 370 /**
365 * Emit monthSelected(int) when a cell has been released. 371 * Emit monthSelected(int) when a cell has been released.
366 */ 372 */
367 void contentsMouseReleaseEvent(QMouseEvent *e); 373 void contentsMouseReleaseEvent(QMouseEvent *e);
368 374
369private: 375private:
370 class KDateInternalMonthPrivate; 376 class KDateInternalMonthPrivate;
371 KDateInternalMonthPrivate *d; 377 KDateInternalMonthPrivate *d;
372}; 378};