Diffstat (limited to 'core/pim/datebook/datebookweek.h') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweek.h | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/core/pim/datebook/datebookweek.h b/core/pim/datebook/datebookweek.h new file mode 100644 index 0000000..6e675f1 --- a/dev/null +++ b/core/pim/datebook/datebookweek.h | |||
@@ -0,0 +1,152 @@ | |||
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 DATEBOOKWEEK | ||
21 | #define DATEBOOKWEEK | ||
22 | |||
23 | #include <qpe/event.h> | ||
24 | |||
25 | #include <qlist.h> | ||
26 | #include <qscrollview.h> | ||
27 | #include <qstring.h> | ||
28 | #include <qvaluelist.h> | ||
29 | |||
30 | class DateBookDB; | ||
31 | class DateBookWeekHeader; | ||
32 | class QDate; | ||
33 | class QLabel; | ||
34 | class QResizeEvent; | ||
35 | class QSpinBox; | ||
36 | class QTimer; | ||
37 | class QHeader; | ||
38 | |||
39 | class DateBookWeekItem | ||
40 | { | ||
41 | public: | ||
42 | DateBookWeekItem( const EffectiveEvent e ); | ||
43 | |||
44 | void setGeometry( int x, int y, int w, int h ); | ||
45 | QRect geometry() const { return r; } | ||
46 | |||
47 | const QColor &color() const { return c; } | ||
48 | const EffectiveEvent event() const { return ev; } | ||
49 | |||
50 | private: | ||
51 | const EffectiveEvent ev; | ||
52 | QRect r; | ||
53 | QColor c; | ||
54 | }; | ||
55 | |||
56 | class DateBookWeekView : public QScrollView | ||
57 | { | ||
58 | Q_OBJECT | ||
59 | public: | ||
60 | DateBookWeekView( bool ampm, bool weekOnMonday, QWidget *parent = 0, | ||
61 | const char *name = 0 ); | ||
62 | |||
63 | bool whichClock() const; | ||
64 | void showEvents( QValueList<EffectiveEvent> &ev ); | ||
65 | void moveToHour( int h ); | ||
66 | void setStartOfWeek( bool bOnMonday ); | ||
67 | |||
68 | signals: | ||
69 | void showDay( int d ); | ||
70 | void signalShowEvent( const EffectiveEvent & ); | ||
71 | void signalHideEvent(); | ||
72 | |||
73 | protected slots: | ||
74 | void keyPressEvent(QKeyEvent *); | ||
75 | |||
76 | private slots: | ||
77 | void slotChangeClock( bool ); | ||
78 | void alterDay( int ); | ||
79 | |||
80 | private: | ||
81 | void positionItem( DateBookWeekItem *i ); | ||
82 | DateBookWeekItem *intersects( const DateBookWeekItem * ); | ||
83 | void drawContents( QPainter *p, int cx, int cy, int cw, int ch ); | ||
84 | void contentsMousePressEvent( QMouseEvent * ); | ||
85 | void contentsMouseReleaseEvent( QMouseEvent * ); | ||
86 | void resizeEvent( QResizeEvent * ); | ||
87 | void initNames(); | ||
88 | |||
89 | private: | ||
90 | bool ampm; | ||
91 | bool bOnMonday; | ||
92 | QHeader *header; | ||
93 | QList<DateBookWeekItem> items; | ||
94 | int rowHeight; | ||
95 | bool showingEvent; | ||
96 | }; | ||
97 | |||
98 | class DateBookWeek : public QWidget | ||
99 | { | ||
100 | Q_OBJECT | ||
101 | |||
102 | public: | ||
103 | DateBookWeek( bool ampm, bool weekOnMonday, DateBookDB *newDB, | ||
104 | QWidget *parent = 0, const char *name = 0 ); | ||
105 | void setDate( int y, int m, int d ); | ||
106 | void setDate( QDate d ); | ||
107 | QDate date() const; | ||
108 | DateBookWeekView *weekView() const { return view; } | ||
109 | void setStartViewTime( int startHere ); | ||
110 | int startViewTime() const; | ||
111 | int week() const { return _week; }; | ||
112 | void setTotalWeeks( int totalWeeks ); | ||
113 | int totalWeeks() const; | ||
114 | QDate weekDate() const; | ||
115 | |||
116 | public slots: | ||
117 | void redraw(); | ||
118 | void slotWeekChanged( bool bStartOnMonday ); | ||
119 | void slotClockChanged( bool a ); | ||
120 | |||
121 | signals: | ||
122 | void showDate( int y, int m, int d ); | ||
123 | |||
124 | protected slots: | ||
125 | void keyPressEvent(QKeyEvent *); | ||
126 | |||
127 | private slots: | ||
128 | void showDay( int day ); | ||
129 | void dateChanged( int y, int w ); | ||
130 | void slotShowEvent( const EffectiveEvent & ); | ||
131 | void slotHideEvent(); | ||
132 | void slotYearChanged( int ); | ||
133 | |||
134 | private: | ||
135 | void getEvents(); | ||
136 | int year; | ||
137 | int _week; | ||
138 | int dow; | ||
139 | DateBookWeekHeader *header; | ||
140 | DateBookWeekView *view; | ||
141 | DateBookDB *db; | ||
142 | QLabel *lblDesc; | ||
143 | QTimer *tHide; | ||
144 | int startTime; | ||
145 | bool ampm; | ||
146 | bool bStartOnMonday; | ||
147 | }; | ||
148 | |||
149 | |||
150 | bool calcWeek( const QDate &d, int &week, int &year, | ||
151 | bool startOnMonday = false ); | ||
152 | #endif | ||