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