-rw-r--r-- | libkcal/calendarlocal.h | 216 |
1 files changed, 216 insertions, 0 deletions
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h new file mode 100644 index 0000000..a17cf11 --- a/dev/null +++ b/libkcal/calendarlocal.h | |||
@@ -0,0 +1,216 @@ | |||
1 | /* | ||
2 | This file is part of libkcal. | ||
3 | |||
4 | Copyright (c) 1998 Preston Brown | ||
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | ||
6 | |||
7 | This library is free software; you can redistribute it and/or | ||
8 | modify it under the terms of the GNU Library General Public | ||
9 | License as published by the Free Software Foundation; either | ||
10 | version 2 of the License, or (at your option) any later version. | ||
11 | |||
12 | This library is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | Library General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU Library General Public License | ||
18 | along with this library; see the file COPYING.LIB. If not, write to | ||
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
20 | Boston, MA 02111-1307, USA. | ||
21 | */ | ||
22 | #ifndef KCAL_CALENDARLOCAL_H | ||
23 | #define KCAL_CALENDARLOCAL_H | ||
24 | |||
25 | #include "calendar.h" | ||
26 | |||
27 | namespace KCal { | ||
28 | |||
29 | class CalFormat; | ||
30 | |||
31 | /** | ||
32 | This class provides a calendar stored as a local file. | ||
33 | */ | ||
34 | class CalendarLocal : public Calendar | ||
35 | { | ||
36 | public: | ||
37 | /** | ||
38 | Constructs a new calendar, with variables initialized to sane values. | ||
39 | */ | ||
40 | CalendarLocal(); | ||
41 | /** | ||
42 | Constructs a new calendar, with variables initialized to sane values. | ||
43 | */ | ||
44 | CalendarLocal( const QString &timeZoneId ); | ||
45 | ~CalendarLocal(); | ||
46 | |||
47 | /** | ||
48 | Loads a calendar on disk in vCalendar or iCalendar format into the current | ||
49 | calendar. Any information already present is lost. | ||
50 | @return true, if successfull, false on error. | ||
51 | @param fileName the name of the calendar on disk. | ||
52 | */ | ||
53 | bool load( const QString &fileName ); | ||
54 | /** | ||
55 | Writes out the calendar to disk in the specified \a format. | ||
56 | CalendarLocal takes ownership of the CalFormat object. | ||
57 | @return true, if successfull, false on error. | ||
58 | @param fileName the name of the file | ||
59 | */ | ||
60 | bool save( const QString &fileName, CalFormat *format = 0 ); | ||
61 | |||
62 | /** | ||
63 | Clears out the current calendar, freeing all used memory etc. etc. | ||
64 | */ | ||
65 | void close(); | ||
66 | |||
67 | void save() {} | ||
68 | |||
69 | /** | ||
70 | Add Event to calendar. | ||
71 | */ | ||
72 | bool addEventNoDup( Event *event ); | ||
73 | bool addEvent( Event *event ); | ||
74 | /** | ||
75 | Deletes an event from this calendar. | ||
76 | */ | ||
77 | void deleteEvent( Event *event ); | ||
78 | |||
79 | /** | ||
80 | Retrieves an event on the basis of the unique string ID. | ||
81 | */ | ||
82 | Event *event( const QString &uid ); | ||
83 | /** | ||
84 | Return unfiltered list of all events in calendar. | ||
85 | */ | ||
86 | QPtrList<Event> rawEvents(); | ||
87 | |||
88 | /** | ||
89 | Add a todo to the todolist. | ||
90 | */ | ||
91 | bool addTodo( Todo *todo ); | ||
92 | bool addTodoNoDup( Todo *todo ); | ||
93 | /** | ||
94 | Remove a todo from the todolist. | ||
95 | */ | ||
96 | void deleteTodo( Todo * ); | ||
97 | /** | ||
98 | Searches todolist for an event with this unique string identifier, | ||
99 | returns a pointer or null. | ||
100 | */ | ||
101 | Todo *todo( const QString &uid ); | ||
102 | /** | ||
103 | Return list of all todos. | ||
104 | */ | ||
105 | QPtrList<Todo> rawTodos(); | ||
106 | /** | ||
107 | Returns list of todos due on the specified date. | ||
108 | */ | ||
109 | QPtrList<Todo> todos( const QDate &date ); | ||
110 | /** | ||
111 | Return list of all todos. | ||
112 | |||
113 | Workaround because compiler does not recognize function of base class. | ||
114 | */ | ||
115 | QPtrList<Todo> todos() { return Calendar::todos(); } | ||
116 | |||
117 | /** | ||
118 | Add a Journal entry to calendar. | ||
119 | */ | ||
120 | bool addJournal( Journal * ); | ||
121 | /** | ||
122 | Remove a Journal from the calendar. | ||
123 | */ | ||
124 | void deleteJournal( Journal * ); | ||
125 | /** | ||
126 | Return Journal for given date. | ||
127 | */ | ||
128 | Journal *journal( const QDate & ); | ||
129 | /** | ||
130 | Return Journal with given UID. | ||
131 | */ | ||
132 | Journal *journal( const QString &uid ); | ||
133 | /** | ||
134 | Return list of all Journals stored in calendar. | ||
135 | */ | ||
136 | QPtrList<Journal> journals(); | ||
137 | |||
138 | /** | ||
139 | Return all alarms, which ocur in the given time interval. | ||
140 | */ | ||
141 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); | ||
142 | |||
143 | /** | ||
144 | Return all alarms, which ocur before given date. | ||
145 | */ | ||
146 | Alarm::List alarmsTo( const QDateTime &to ); | ||
147 | |||
148 | QDateTime nextAlarm( int daysTo ) ; | ||
149 | QDateTime nextAlarmEventDateTime() const; | ||
150 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; | ||
151 | void registerAlarm(); | ||
152 | void deRegisterAlarm(); | ||
153 | QString getAlarmNotification(); | ||
154 | QString nextSummary() const ; | ||
155 | /** | ||
156 | This method should be called whenever a Event is modified directly | ||
157 | via it's pointer. It makes sure that the calendar is internally | ||
158 | consistent. | ||
159 | */ | ||
160 | void update( IncidenceBase *incidence ); | ||
161 | |||
162 | /** | ||
163 | Builds and then returns a list of all events that match for the | ||
164 | date specified. useful for dayView, etc. etc. | ||
165 | */ | ||
166 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); | ||
167 | /** | ||
168 | Get unfiltered events for date \a qdt. | ||
169 | */ | ||
170 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); | ||
171 | /** | ||
172 | Get unfiltered events in a range of dates. If inclusive is set to true, | ||
173 | only events are returned, which are completely included in the range. | ||
174 | */ | ||
175 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | ||
176 | bool inclusive = false ); | ||
177 | Todo *CalendarLocal::todo( int uid ); | ||
178 | Event *CalendarLocal::event( int uid ); | ||
179 | |||
180 | |||
181 | |||
182 | protected: | ||
183 | |||
184 | // Event* mNextAlarmEvent; | ||
185 | QString mNextSummary; | ||
186 | QString mNextAlarmEventDateTimeString; | ||
187 | QString mLastAlarmNotificationString; | ||
188 | QDateTime mNextAlarmEventDateTime; | ||
189 | QDateTime mNextAlarmDateTime; | ||
190 | void reInitAlarmSettings(); | ||
191 | |||
192 | /** Notification function of IncidenceBase::Observer. */ | ||
193 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } | ||
194 | |||
195 | /** inserts an event into its "proper place" in the calendar. */ | ||
196 | void insertEvent( Event *event ); | ||
197 | |||
198 | /** Append alarms of incidence in interval to list of alarms. */ | ||
199 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, | ||
200 | const QDateTime &from, const QDateTime &to ); | ||
201 | |||
202 | /** Append alarms of recurring events in interval to list of alarms. */ | ||
203 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, | ||
204 | const QDateTime &from, const QDateTime &to ); | ||
205 | |||
206 | private: | ||
207 | void init(); | ||
208 | |||
209 | QPtrList<Event> mEventList; | ||
210 | QPtrList<Todo> mTodoList; | ||
211 | QPtrList<Journal> mJournalList; | ||
212 | }; | ||
213 | |||
214 | } | ||
215 | |||
216 | #endif | ||