-rw-r--r-- | korganizer/kdatenavigator.h | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h new file mode 100644 index 0000000..3ae1648 --- a/dev/null +++ b/korganizer/kdatenavigator.h | |||
@@ -0,0 +1,148 @@ | |||
1 | /* | ||
2 | This file is part of KOrganizer. | ||
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | #ifndef KDATENAVIGATOR_H | ||
24 | #define KDATENAVIGATOR_H | ||
25 | |||
26 | #include <qframe.h> | ||
27 | #include <qdatetime.h> | ||
28 | #include <qlabel.h> | ||
29 | |||
30 | #include <libkcal/calendar.h> | ||
31 | |||
32 | #include "kodaymatrix.h" | ||
33 | |||
34 | class QPushButton; | ||
35 | class QTimer; | ||
36 | |||
37 | class KCalendarSystem; | ||
38 | |||
39 | class NavigatorBar; | ||
40 | |||
41 | class KDateNavigator: public QFrame | ||
42 | { | ||
43 | Q_OBJECT | ||
44 | public: | ||
45 | KDateNavigator( QWidget *parent = 0, Calendar *calendar = 0, | ||
46 | bool show_week_numbers = false, const char *name = 0, | ||
47 | QDate date = QDate::currentDate() ); | ||
48 | ~KDateNavigator(); | ||
49 | |||
50 | /** The DateNavigator automatically checks for | ||
51 | * the passage of midnight. If rollover type is | ||
52 | * set to None, no signals are emitted and no | ||
53 | * processing is done. With rollover set to | ||
54 | * FollowDay, the day highlighter changes at | ||
55 | * midnight and dayPassed() is emitted. | ||
56 | * With FollowMonth, it has the same effect | ||
57 | * as FollowDay but also adjusts the month that is | ||
58 | * visible and emits monthPassed() when the month changes. | ||
59 | */ | ||
60 | enum RolloverType { None, FollowDay, FollowMonth } ; | ||
61 | void enableRollover( RolloverType ); | ||
62 | |||
63 | void setShowWeekNums( bool enabled ); | ||
64 | |||
65 | public slots: | ||
66 | void selectDates( const KCal::DateList & ); | ||
67 | void updateView(); | ||
68 | void updateConfig(); | ||
69 | void updateDayMatrix(); | ||
70 | |||
71 | signals: | ||
72 | void datesSelected( const KCal::DateList & ); | ||
73 | void eventDropped( Event * ); | ||
74 | void weekClicked( const QDate &); | ||
75 | |||
76 | void goPrevious(); | ||
77 | void goNext(); | ||
78 | |||
79 | void goNextMonth(); | ||
80 | void goPrevMonth(); | ||
81 | void goNextYear(); | ||
82 | void goPrevYear(); | ||
83 | void monthSelected( int ); | ||
84 | |||
85 | // Signals emitted at midnight carrying the new date. | ||
86 | void dayPassed( QDate ); | ||
87 | void monthPassed( QDate ); | ||
88 | |||
89 | protected slots: | ||
90 | |||
91 | /** | ||
92 | * Called regularly to see if we need to update the view | ||
93 | * wrt. the today box and the month box. Only important | ||
94 | * if you leave KOrganizer idle for long periods of time. | ||
95 | * | ||
96 | * Until we have a reliable way of setting QTimers to go | ||
97 | * off at a particular wall-clock time, we need this, | ||
98 | * which calls passedMidnight() at the right moments. | ||
99 | */ | ||
100 | void possiblyPastMidnight(); | ||
101 | |||
102 | /** handles updating the view when midnight has come by due to idle time. | ||
103 | * | ||
104 | */ | ||
105 | void passedMidnight(); | ||
106 | |||
107 | protected: | ||
108 | void updateDates(); | ||
109 | |||
110 | void wheelEvent (QWheelEvent *); | ||
111 | |||
112 | bool eventFilter (QObject *,QEvent *); | ||
113 | |||
114 | private: | ||
115 | NavigatorBar *mNavigatorBar; | ||
116 | |||
117 | QFrame *headingSep; | ||
118 | QFrame *weeknumSep; | ||
119 | QLabel *headings[7]; | ||
120 | QLabel *weeknos[7]; | ||
121 | KODayMatrix *daymatrix; | ||
122 | |||
123 | KCal::DateList mSelectedDates; | ||
124 | QDate m_MthYr; | ||
125 | int m_fstDayOfWk; | ||
126 | bool m_bShowWeekNums; | ||
127 | |||
128 | int dayNum(int row, int col); | ||
129 | int dayToIndex(int dayNum); | ||
130 | |||
131 | Calendar *mCalendar; | ||
132 | KCalendarSystem *mCalendarSystem; | ||
133 | |||
134 | const QString *curHeaders; | ||
135 | |||
136 | /** used to update the day view periodically, in particular every | ||
137 | * midnight to move the "today" rectangle. | ||
138 | */ | ||
139 | QTimer *updateTimer; | ||
140 | QDate lastDayChecked; | ||
141 | RolloverType updateRollover; | ||
142 | |||
143 | // Disabling copy constructor and assignment operator | ||
144 | KDateNavigator(const KDateNavigator & ); | ||
145 | KDateNavigator &operator=(const KDateNavigator &); | ||
146 | }; | ||
147 | |||
148 | #endif | ||