-rw-r--r-- | library/datebookmonth.h | 210 |
1 files changed, 210 insertions, 0 deletions
diff --git a/library/datebookmonth.h b/library/datebookmonth.h new file mode 100644 index 0000000..6cd1ac5 --- a/dev/null +++ b/library/datebookmonth.h | |||
@@ -0,0 +1,210 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #ifndef DATEBOOKMONTH | ||
21 | #define DATEBOOKMONTH | ||
22 | |||
23 | #include <qpe/event.h> | ||
24 | |||
25 | #include <qvbox.h> | ||
26 | #include <qhbox.h> | ||
27 | #include <qdatetime.h> | ||
28 | #include <qvaluelist.h> | ||
29 | #include <qtable.h> | ||
30 | #include <qpushbutton.h> | ||
31 | |||
32 | #include "calendar.h" | ||
33 | #include "timestring.h" | ||
34 | |||
35 | class QToolButton; | ||
36 | class QComboBox; | ||
37 | class QSpinBox; | ||
38 | class Event; | ||
39 | class DateBookDB; | ||
40 | |||
41 | class DateBookMonthHeaderPrivate; | ||
42 | class DateBookMonthHeader : public QHBox | ||
43 | { | ||
44 | Q_OBJECT | ||
45 | |||
46 | public: | ||
47 | DateBookMonthHeader( QWidget *parent = 0, const char *name = 0 ); | ||
48 | ~DateBookMonthHeader(); | ||
49 | void setDate( int year, int month ); | ||
50 | |||
51 | signals: | ||
52 | void dateChanged( int year, int month ); | ||
53 | |||
54 | protected slots: | ||
55 | void keyPressEvent(QKeyEvent *e ) { | ||
56 | e->ignore(); | ||
57 | } | ||
58 | |||
59 | private slots: | ||
60 | void updateDate(); | ||
61 | void firstMonth(); | ||
62 | void lastMonth(); | ||
63 | void monthBack(); | ||
64 | void monthForward(); | ||
65 | |||
66 | private: | ||
67 | QToolButton *begin, *back, *next, *end; | ||
68 | QComboBox *month; | ||
69 | QSpinBox *year; | ||
70 | DateBookMonthHeaderPrivate *d; | ||
71 | }; | ||
72 | |||
73 | class DayItemMonthPrivate; | ||
74 | class DayItemMonth : public QTableItem | ||
75 | { | ||
76 | public: | ||
77 | DayItemMonth( QTable *table, EditType et, const QString &t ); | ||
78 | ~DayItemMonth(); | ||
79 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); | ||
80 | void setDay( int d ) { dy = d; } | ||
81 | void setEvents( const QValueList<Event> &events ) { daysEvents = events; }; | ||
82 | void setEvents( const QValueList<EffectiveEvent> &effEvents ); | ||
83 | void clearEvents() { daysEvents.clear(); }; | ||
84 | void clearEffEvents(); | ||
85 | int day() const { return dy; } | ||
86 | void setType( Calendar::Day::Type t ); | ||
87 | Calendar::Day::Type type() const { return typ; } | ||
88 | |||
89 | private: | ||
90 | QBrush back; | ||
91 | QColor forg; | ||
92 | int dy; | ||
93 | Calendar::Day::Type typ; | ||
94 | QValueList<Event> daysEvents; // not used anymore... | ||
95 | DayItemMonthPrivate *d; | ||
96 | }; | ||
97 | |||
98 | class DateBookMonthTablePrivate; | ||
99 | class DateBookMonthTable : public QTable | ||
100 | { | ||
101 | Q_OBJECT | ||
102 | |||
103 | public: | ||
104 | DateBookMonthTable( QWidget *parent = 0, const char *name = 0, | ||
105 | DateBookDB *newDb = 0 ); | ||
106 | ~DateBookMonthTable(); | ||
107 | void setDate( int y, int m, int d ); | ||
108 | void redraw(); | ||
109 | |||
110 | QSize minimumSizeHint() const { return sizeHint(); } | ||
111 | QSize minimumSize() const { return sizeHint(); } | ||
112 | void getDate( int& y, int &m, int &d ) const {y=selYear;m=selMonth;d=selDay;} | ||
113 | void setWeekStart( bool onMonday ); | ||
114 | signals: | ||
115 | void dateClicked( int year, int month, int day ); | ||
116 | |||
117 | protected: | ||
118 | void viewportMouseReleaseEvent( QMouseEvent * ); | ||
119 | |||
120 | protected slots: | ||
121 | |||
122 | void keyPressEvent(QKeyEvent *e ) { | ||
123 | e->ignore(); | ||
124 | } | ||
125 | |||
126 | private slots: | ||
127 | void dayClicked( int row, int col ); | ||
128 | void dragDay( int row, int col ); | ||
129 | |||
130 | private: | ||
131 | void setupTable(); | ||
132 | void setupLabels(); | ||
133 | |||
134 | void findDay( int day, int &row, int &col ); | ||
135 | void getEvents(); | ||
136 | void changeDaySelection( int row, int col ); | ||
137 | |||
138 | int year, month, day; | ||
139 | int selYear, selMonth, selDay; | ||
140 | QValueList<Event> monthsEvents; // not used anymore... | ||
141 | DateBookDB *db; | ||
142 | DateBookMonthTablePrivate *d; | ||
143 | }; | ||
144 | |||
145 | class DateBookMonthPrivate; | ||
146 | class DateBookMonth : public QVBox | ||
147 | { | ||
148 | Q_OBJECT | ||
149 | |||
150 | public: | ||
151 | DateBookMonth( QWidget *parent = 0, const char *name = 0, bool ac = FALSE, | ||
152 | DateBookDB *data = 0 ); | ||
153 | ~DateBookMonth(); | ||
154 | QDate selectedDate() const; | ||
155 | |||
156 | signals: | ||
157 | void dateClicked( int year, int month, int day ); | ||
158 | |||
159 | public slots: | ||
160 | void setDate( int y, int m ); | ||
161 | void setDate( int y, int m, int d ); | ||
162 | void setDate( QDate ); | ||
163 | void redraw(); | ||
164 | void slotWeekChange( bool ); | ||
165 | |||
166 | protected slots: | ||
167 | virtual void keyPressEvent(QKeyEvent *e); | ||
168 | |||
169 | private slots: | ||
170 | void forwardDateClicked( int y, int m, int d ) { emit dateClicked( y, m, d ); } | ||
171 | void finalDate(int, int, int); | ||
172 | |||
173 | private: | ||
174 | DateBookMonthHeader *header; | ||
175 | DateBookMonthTable *table; | ||
176 | int year, month, day; | ||
177 | bool autoClose; | ||
178 | class DateBookMonthPrivate *d; | ||
179 | }; | ||
180 | |||
181 | class DateButton : public QPushButton | ||
182 | { | ||
183 | Q_OBJECT | ||
184 | |||
185 | public: | ||
186 | DateButton( bool longDate, QWidget *parent, const char * name = 0 ); | ||
187 | QDate date() const { return currDate; } | ||
188 | |||
189 | signals: | ||
190 | void dateSelected( int year, int month, int day ); | ||
191 | |||
192 | public slots: | ||
193 | void setDate( int y, int m, int d ); | ||
194 | void setDate( QDate ); | ||
195 | void setWeekStartsMonday( int ); | ||
196 | void setDateFormat( DateFormat ); | ||
197 | |||
198 | private slots: | ||
199 | void pickDate(); | ||
200 | void gotHide(); | ||
201 | |||
202 | private: | ||
203 | bool longFormat; | ||
204 | bool weekStartsMonday; | ||
205 | QDate currDate; | ||
206 | DateFormat df; | ||
207 | }; | ||
208 | |||
209 | |||
210 | #endif | ||