author | zautrix <zautrix> | 2004-10-17 16:06:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-17 16:06:42 (UTC) |
commit | d92f58ffa1937af8a4240b9d235da15f5f352769 (patch) (unidiff) | |
tree | 48768599988f33c7f20017a76d05e919fa77ac51 /libkcal | |
parent | 711c4c06a7d1a52b97fd24efa3586543f46cc6d7 (diff) | |
download | kdepimpi-d92f58ffa1937af8a4240b9d235da15f5f352769.zip kdepimpi-d92f58ffa1937af8a4240b9d235da15f5f352769.tar.gz kdepimpi-d92f58ffa1937af8a4240b9d235da15f5f352769.tar.bz2 |
KDE sync fixes
-rw-r--r-- | libkcal/calendar.cpp | 16 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index a3977d7..eeb5f48 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -1,441 +1,457 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | #include <time.h> | 23 | #include <time.h> |
24 | 24 | ||
25 | #include <kdebug.h> | 25 | #include <kdebug.h> |
26 | #include <kglobal.h> | 26 | #include <kglobal.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | #include "exceptions.h" | 29 | #include "exceptions.h" |
30 | #include "calfilter.h" | 30 | #include "calfilter.h" |
31 | 31 | ||
32 | #include "calendar.h" | 32 | #include "calendar.h" |
33 | #include "syncdefines.h" | 33 | #include "syncdefines.h" |
34 | 34 | ||
35 | using namespace KCal; | 35 | using namespace KCal; |
36 | 36 | ||
37 | Calendar::Calendar() | 37 | Calendar::Calendar() |
38 | { | 38 | { |
39 | 39 | ||
40 | init(); | 40 | init(); |
41 | setTimeZoneId( i18n (" 00:00 Europe/London(UTC)") ); | 41 | setTimeZoneId( i18n (" 00:00 Europe/London(UTC)") ); |
42 | } | 42 | } |
43 | 43 | ||
44 | Calendar::Calendar( const QString &timeZoneId ) | 44 | Calendar::Calendar( const QString &timeZoneId ) |
45 | { | 45 | { |
46 | 46 | ||
47 | init(); | 47 | init(); |
48 | setTimeZoneId(timeZoneId); | 48 | setTimeZoneId(timeZoneId); |
49 | } | 49 | } |
50 | 50 | ||
51 | void Calendar::init() | 51 | void Calendar::init() |
52 | { | 52 | { |
53 | mObserver = 0; | 53 | mObserver = 0; |
54 | mNewObserver = false; | 54 | mNewObserver = false; |
55 | 55 | ||
56 | mModified = false; | 56 | mModified = false; |
57 | 57 | ||
58 | // Setup default filter, which does nothing | 58 | // Setup default filter, which does nothing |
59 | mDefaultFilter = new CalFilter; | 59 | mDefaultFilter = new CalFilter; |
60 | mFilter = mDefaultFilter; | 60 | mFilter = mDefaultFilter; |
61 | mFilter->setEnabled(false); | 61 | mFilter->setEnabled(false); |
62 | 62 | ||
63 | // initialize random numbers. This is a hack, and not | 63 | // initialize random numbers. This is a hack, and not |
64 | // even that good of one at that. | 64 | // even that good of one at that. |
65 | // srandom(time(0)); | 65 | // srandom(time(0)); |
66 | 66 | ||
67 | // user information... | 67 | // user information... |
68 | setOwner(i18n("Unknown Name")); | 68 | setOwner(i18n("Unknown Name")); |
69 | setEmail(i18n("unknown@nowhere")); | 69 | setEmail(i18n("unknown@nowhere")); |
70 | 70 | ||
71 | #if 0 | 71 | #if 0 |
72 | tmpStr = KOPrefs::instance()->mTimeZone; | 72 | tmpStr = KOPrefs::instance()->mTimeZone; |
73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; | 73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; |
74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; | 74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; |
75 | extern long int timezone; | 75 | extern long int timezone; |
76 | struct tm *now; | 76 | struct tm *now; |
77 | time_t curtime; | 77 | time_t curtime; |
78 | curtime = time(0); | 78 | curtime = time(0); |
79 | now = localtime(&curtime); | 79 | now = localtime(&curtime); |
80 | int hourOff = - ((timezone / 60) / 60); | 80 | int hourOff = - ((timezone / 60) / 60); |
81 | if (now->tm_isdst) | 81 | if (now->tm_isdst) |
82 | hourOff += 1; | 82 | hourOff += 1; |
83 | QString tzStr; | 83 | QString tzStr; |
84 | tzStr.sprintf("%.2d%.2d", | 84 | tzStr.sprintf("%.2d%.2d", |
85 | hourOff, | 85 | hourOff, |
86 | abs((timezone / 60) % 60)); | 86 | abs((timezone / 60) % 60)); |
87 | 87 | ||
88 | // if no time zone was in the config file, write what we just discovered. | 88 | // if no time zone was in the config file, write what we just discovered. |
89 | if (tmpStr.isEmpty()) { | 89 | if (tmpStr.isEmpty()) { |
90 | // KOPrefs::instance()->mTimeZone = tzStr; | 90 | // KOPrefs::instance()->mTimeZone = tzStr; |
91 | } else { | 91 | } else { |
92 | tzStr = tmpStr; | 92 | tzStr = tmpStr; |
93 | } | 93 | } |
94 | 94 | ||
95 | // if daylight savings has changed since last load time, we need | 95 | // if daylight savings has changed since last load time, we need |
96 | // to rewrite these settings to the config file. | 96 | // to rewrite these settings to the config file. |
97 | if ((now->tm_isdst && !dstSetting) || | 97 | if ((now->tm_isdst && !dstSetting) || |
98 | (!now->tm_isdst && dstSetting)) { | 98 | (!now->tm_isdst && dstSetting)) { |
99 | KOPrefs::instance()->mTimeZone = tzStr; | 99 | KOPrefs::instance()->mTimeZone = tzStr; |
100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; | 100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; |
101 | } | 101 | } |
102 | 102 | ||
103 | setTimeZone(tzStr); | 103 | setTimeZone(tzStr); |
104 | #endif | 104 | #endif |
105 | 105 | ||
106 | // KOPrefs::instance()->writeConfig(); | 106 | // KOPrefs::instance()->writeConfig(); |
107 | } | 107 | } |
108 | 108 | ||
109 | Calendar::~Calendar() | 109 | Calendar::~Calendar() |
110 | { | 110 | { |
111 | delete mDefaultFilter; | 111 | delete mDefaultFilter; |
112 | } | 112 | } |
113 | 113 | ||
114 | const QString &Calendar::getOwner() const | 114 | const QString &Calendar::getOwner() const |
115 | { | 115 | { |
116 | return mOwner; | 116 | return mOwner; |
117 | } | 117 | } |
118 | 118 | ||
119 | void Calendar::setOwner(const QString &os) | 119 | void Calendar::setOwner(const QString &os) |
120 | { | 120 | { |
121 | int i; | 121 | int i; |
122 | mOwner = os; | 122 | mOwner = os; |
123 | i = mOwner.find(','); | 123 | i = mOwner.find(','); |
124 | if (i != -1) | 124 | if (i != -1) |
125 | mOwner = mOwner.left(i); | 125 | mOwner = mOwner.left(i); |
126 | 126 | ||
127 | setModified( true ); | 127 | setModified( true ); |
128 | } | 128 | } |
129 | 129 | ||
130 | void Calendar::setTimeZone(const QString & tz) | 130 | void Calendar::setTimeZone(const QString & tz) |
131 | { | 131 | { |
132 | bool neg = FALSE; | 132 | bool neg = FALSE; |
133 | int hours, minutes; | 133 | int hours, minutes; |
134 | QString tmpStr(tz); | 134 | QString tmpStr(tz); |
135 | 135 | ||
136 | if (tmpStr.left(1) == "-") | 136 | if (tmpStr.left(1) == "-") |
137 | neg = TRUE; | 137 | neg = TRUE; |
138 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") | 138 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") |
139 | tmpStr.remove(0, 1); | 139 | tmpStr.remove(0, 1); |
140 | hours = tmpStr.left(2).toInt(); | 140 | hours = tmpStr.left(2).toInt(); |
141 | if (tmpStr.length() > 2) | 141 | if (tmpStr.length() > 2) |
142 | minutes = tmpStr.right(2).toInt(); | 142 | minutes = tmpStr.right(2).toInt(); |
143 | else | 143 | else |
144 | minutes = 0; | 144 | minutes = 0; |
145 | mTimeZone = (60*hours+minutes); | 145 | mTimeZone = (60*hours+minutes); |
146 | if (neg) | 146 | if (neg) |
147 | mTimeZone = -mTimeZone; | 147 | mTimeZone = -mTimeZone; |
148 | mLocalTime = false; | 148 | mLocalTime = false; |
149 | 149 | ||
150 | setModified( true ); | 150 | setModified( true ); |
151 | } | 151 | } |
152 | 152 | ||
153 | QString Calendar::getTimeZoneStr() const | 153 | QString Calendar::getTimeZoneStr() const |
154 | { | 154 | { |
155 | if (mLocalTime) | 155 | if (mLocalTime) |
156 | return ""; | 156 | return ""; |
157 | QString tmpStr; | 157 | QString tmpStr; |
158 | int hours = abs(mTimeZone / 60); | 158 | int hours = abs(mTimeZone / 60); |
159 | int minutes = abs(mTimeZone % 60); | 159 | int minutes = abs(mTimeZone % 60); |
160 | bool neg = mTimeZone < 0; | 160 | bool neg = mTimeZone < 0; |
161 | 161 | ||
162 | tmpStr.sprintf("%c%.2d%.2d", | 162 | tmpStr.sprintf("%c%.2d%.2d", |
163 | (neg ? '-' : '+'), | 163 | (neg ? '-' : '+'), |
164 | hours, minutes); | 164 | hours, minutes); |
165 | return tmpStr; | 165 | return tmpStr; |
166 | } | 166 | } |
167 | 167 | ||
168 | void Calendar::setTimeZone(int tz) | 168 | void Calendar::setTimeZone(int tz) |
169 | { | 169 | { |
170 | mTimeZone = tz; | 170 | mTimeZone = tz; |
171 | mLocalTime = false; | 171 | mLocalTime = false; |
172 | 172 | ||
173 | setModified( true ); | 173 | setModified( true ); |
174 | } | 174 | } |
175 | 175 | ||
176 | int Calendar::getTimeZone() const | 176 | int Calendar::getTimeZone() const |
177 | { | 177 | { |
178 | return mTimeZone; | 178 | return mTimeZone; |
179 | } | 179 | } |
180 | 180 | ||
181 | void Calendar::setTimeZoneId(const QString &id) | 181 | void Calendar::setTimeZoneId(const QString &id) |
182 | { | 182 | { |
183 | mTimeZoneId = id; | 183 | mTimeZoneId = id; |
184 | mLocalTime = false; | 184 | mLocalTime = false; |
185 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); | 185 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); |
186 | if ( mTimeZone > 1000) | 186 | if ( mTimeZone > 1000) |
187 | setLocalTime(); | 187 | setLocalTime(); |
188 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); | 188 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); |
189 | setModified( true ); | 189 | setModified( true ); |
190 | } | 190 | } |
191 | 191 | ||
192 | QString Calendar::timeZoneId() const | 192 | QString Calendar::timeZoneId() const |
193 | { | 193 | { |
194 | return mTimeZoneId; | 194 | return mTimeZoneId; |
195 | } | 195 | } |
196 | 196 | ||
197 | void Calendar::setLocalTime() | 197 | void Calendar::setLocalTime() |
198 | { | 198 | { |
199 | //qDebug("Calendar::setLocalTime() "); | 199 | //qDebug("Calendar::setLocalTime() "); |
200 | mLocalTime = true; | 200 | mLocalTime = true; |
201 | mTimeZone = 0; | 201 | mTimeZone = 0; |
202 | mTimeZoneId = ""; | 202 | mTimeZoneId = ""; |
203 | 203 | ||
204 | setModified( true ); | 204 | setModified( true ); |
205 | } | 205 | } |
206 | 206 | ||
207 | bool Calendar::isLocalTime() const | 207 | bool Calendar::isLocalTime() const |
208 | { | 208 | { |
209 | return mLocalTime; | 209 | return mLocalTime; |
210 | } | 210 | } |
211 | 211 | ||
212 | const QString &Calendar::getEmail() | 212 | const QString &Calendar::getEmail() |
213 | { | 213 | { |
214 | return mOwnerEmail; | 214 | return mOwnerEmail; |
215 | } | 215 | } |
216 | 216 | ||
217 | void Calendar::setEmail(const QString &e) | 217 | void Calendar::setEmail(const QString &e) |
218 | { | 218 | { |
219 | mOwnerEmail = e; | 219 | mOwnerEmail = e; |
220 | 220 | ||
221 | setModified( true ); | 221 | setModified( true ); |
222 | } | 222 | } |
223 | 223 | ||
224 | void Calendar::setFilter(CalFilter *filter) | 224 | void Calendar::setFilter(CalFilter *filter) |
225 | { | 225 | { |
226 | mFilter = filter; | 226 | mFilter = filter; |
227 | } | 227 | } |
228 | 228 | ||
229 | CalFilter *Calendar::filter() | 229 | CalFilter *Calendar::filter() |
230 | { | 230 | { |
231 | return mFilter; | 231 | return mFilter; |
232 | } | 232 | } |
233 | 233 | ||
234 | QPtrList<Incidence> Calendar::incidences() | 234 | QPtrList<Incidence> Calendar::incidences() |
235 | { | 235 | { |
236 | QPtrList<Incidence> incidences; | 236 | QPtrList<Incidence> incidences; |
237 | 237 | ||
238 | Incidence *i; | 238 | Incidence *i; |
239 | 239 | ||
240 | QPtrList<Event> e = events(); | 240 | QPtrList<Event> e = events(); |
241 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 241 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
242 | 242 | ||
243 | QPtrList<Todo> t = todos(); | 243 | QPtrList<Todo> t = todos(); |
244 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 244 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
245 | 245 | ||
246 | QPtrList<Journal> j = journals(); | 246 | QPtrList<Journal> j = journals(); |
247 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 247 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
248 | 248 | ||
249 | return incidences; | 249 | return incidences; |
250 | } | 250 | } |
251 | |||
252 | void Calendar::resetPilotStat() | ||
253 | { | ||
254 | QPtrList<Incidence> incidences; | ||
255 | |||
256 | Incidence *i; | ||
257 | |||
258 | QPtrList<Event> e = rawEvents(); | ||
259 | for( i = e.first(); i; i = e.next() ) i->setPilotId( 0 ); | ||
260 | |||
261 | QPtrList<Todo> t = rawTodos(); | ||
262 | for( i = t.first(); i; i = t.next() ) i->setPilotId( 0 ); | ||
263 | |||
264 | QPtrList<Journal> j = journals(); | ||
265 | for( i = j.first(); i; i = j.next() ) i->setPilotId( 0 ); | ||
266 | } | ||
251 | void Calendar::resetTempSyncStat() | 267 | void Calendar::resetTempSyncStat() |
252 | { | 268 | { |
253 | QPtrList<Incidence> incidences; | 269 | QPtrList<Incidence> incidences; |
254 | 270 | ||
255 | Incidence *i; | 271 | Incidence *i; |
256 | 272 | ||
257 | QPtrList<Event> e = rawEvents(); | 273 | QPtrList<Event> e = rawEvents(); |
258 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 274 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
259 | 275 | ||
260 | QPtrList<Todo> t = rawTodos(); | 276 | QPtrList<Todo> t = rawTodos(); |
261 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 277 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
262 | 278 | ||
263 | QPtrList<Journal> j = journals(); | 279 | QPtrList<Journal> j = journals(); |
264 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 280 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
265 | } | 281 | } |
266 | QPtrList<Incidence> Calendar::rawIncidences() | 282 | QPtrList<Incidence> Calendar::rawIncidences() |
267 | { | 283 | { |
268 | QPtrList<Incidence> incidences; | 284 | QPtrList<Incidence> incidences; |
269 | 285 | ||
270 | Incidence *i; | 286 | Incidence *i; |
271 | 287 | ||
272 | QPtrList<Event> e = rawEvents(); | 288 | QPtrList<Event> e = rawEvents(); |
273 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 289 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
274 | 290 | ||
275 | QPtrList<Todo> t = rawTodos(); | 291 | QPtrList<Todo> t = rawTodos(); |
276 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 292 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
277 | 293 | ||
278 | QPtrList<Journal> j = journals(); | 294 | QPtrList<Journal> j = journals(); |
279 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 295 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
280 | 296 | ||
281 | return incidences; | 297 | return incidences; |
282 | } | 298 | } |
283 | 299 | ||
284 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) | 300 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) |
285 | { | 301 | { |
286 | QPtrList<Event> el = rawEventsForDate(date,sorted); | 302 | QPtrList<Event> el = rawEventsForDate(date,sorted); |
287 | mFilter->apply(&el); | 303 | mFilter->apply(&el); |
288 | return el; | 304 | return el; |
289 | } | 305 | } |
290 | 306 | ||
291 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) | 307 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) |
292 | { | 308 | { |
293 | QPtrList<Event> el = rawEventsForDate(qdt); | 309 | QPtrList<Event> el = rawEventsForDate(qdt); |
294 | mFilter->apply(&el); | 310 | mFilter->apply(&el); |
295 | return el; | 311 | return el; |
296 | } | 312 | } |
297 | 313 | ||
298 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, | 314 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, |
299 | bool inclusive) | 315 | bool inclusive) |
300 | { | 316 | { |
301 | QPtrList<Event> el = rawEvents(start,end,inclusive); | 317 | QPtrList<Event> el = rawEvents(start,end,inclusive); |
302 | mFilter->apply(&el); | 318 | mFilter->apply(&el); |
303 | return el; | 319 | return el; |
304 | } | 320 | } |
305 | 321 | ||
306 | QPtrList<Event> Calendar::events() | 322 | QPtrList<Event> Calendar::events() |
307 | { | 323 | { |
308 | QPtrList<Event> el = rawEvents(); | 324 | QPtrList<Event> el = rawEvents(); |
309 | mFilter->apply(&el); | 325 | mFilter->apply(&el); |
310 | return el; | 326 | return el; |
311 | } | 327 | } |
312 | 328 | ||
313 | 329 | ||
314 | bool Calendar::addIncidence(Incidence *i) | 330 | bool Calendar::addIncidence(Incidence *i) |
315 | { | 331 | { |
316 | Incidence::AddVisitor<Calendar> v(this); | 332 | Incidence::AddVisitor<Calendar> v(this); |
317 | 333 | ||
318 | return i->accept(v); | 334 | return i->accept(v); |
319 | } | 335 | } |
320 | void Calendar::deleteIncidence(Incidence *in) | 336 | void Calendar::deleteIncidence(Incidence *in) |
321 | { | 337 | { |
322 | if ( in->type() == "Event" ) | 338 | if ( in->type() == "Event" ) |
323 | deleteEvent( (Event*) in ); | 339 | deleteEvent( (Event*) in ); |
324 | else if ( in->type() =="Todo" ) | 340 | else if ( in->type() =="Todo" ) |
325 | deleteTodo( (Todo*) in); | 341 | deleteTodo( (Todo*) in); |
326 | else if ( in->type() =="Journal" ) | 342 | else if ( in->type() =="Journal" ) |
327 | deleteJournal( (Journal*) in ); | 343 | deleteJournal( (Journal*) in ); |
328 | } | 344 | } |
329 | 345 | ||
330 | Incidence* Calendar::incidence( const QString& uid ) | 346 | Incidence* Calendar::incidence( const QString& uid ) |
331 | { | 347 | { |
332 | Incidence* i; | 348 | Incidence* i; |
333 | 349 | ||
334 | if( (i = todo( uid )) != 0 ) | 350 | if( (i = todo( uid )) != 0 ) |
335 | return i; | 351 | return i; |
336 | if( (i = event( uid )) != 0 ) | 352 | if( (i = event( uid )) != 0 ) |
337 | return i; | 353 | return i; |
338 | if( (i = journal( uid )) != 0 ) | 354 | if( (i = journal( uid )) != 0 ) |
339 | return i; | 355 | return i; |
340 | 356 | ||
341 | return 0; | 357 | return 0; |
342 | } | 358 | } |
343 | 359 | ||
344 | QPtrList<Todo> Calendar::todos() | 360 | QPtrList<Todo> Calendar::todos() |
345 | { | 361 | { |
346 | QPtrList<Todo> tl = rawTodos(); | 362 | QPtrList<Todo> tl = rawTodos(); |
347 | mFilter->apply( &tl ); | 363 | mFilter->apply( &tl ); |
348 | return tl; | 364 | return tl; |
349 | } | 365 | } |
350 | 366 | ||
351 | // When this is called, the todo have already been added to the calendar. | 367 | // When this is called, the todo have already been added to the calendar. |
352 | // This method is only about linking related todos | 368 | // This method is only about linking related todos |
353 | void Calendar::setupRelations( Incidence *incidence ) | 369 | void Calendar::setupRelations( Incidence *incidence ) |
354 | { | 370 | { |
355 | QString uid = incidence->uid(); | 371 | QString uid = incidence->uid(); |
356 | //qDebug("Calendar::setupRelations "); | 372 | //qDebug("Calendar::setupRelations "); |
357 | // First, go over the list of orphans and see if this is their parent | 373 | // First, go over the list of orphans and see if this is their parent |
358 | while( Incidence* i = mOrphans[ uid ] ) { | 374 | while( Incidence* i = mOrphans[ uid ] ) { |
359 | mOrphans.remove( uid ); | 375 | mOrphans.remove( uid ); |
360 | i->setRelatedTo( incidence ); | 376 | i->setRelatedTo( incidence ); |
361 | incidence->addRelation( i ); | 377 | incidence->addRelation( i ); |
362 | mOrphanUids.remove( i->uid() ); | 378 | mOrphanUids.remove( i->uid() ); |
363 | } | 379 | } |
364 | 380 | ||
365 | // Now see about this incidences parent | 381 | // Now see about this incidences parent |
366 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { | 382 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { |
367 | // This incidence has a uid it is related to, but is not registered to it yet | 383 | // This incidence has a uid it is related to, but is not registered to it yet |
368 | // Try to find it | 384 | // Try to find it |
369 | Incidence* parent = this->incidence( incidence->relatedToUid() ); | 385 | Incidence* parent = this->incidence( incidence->relatedToUid() ); |
370 | if( parent ) { | 386 | if( parent ) { |
371 | // Found it | 387 | // Found it |
372 | incidence->setRelatedTo( parent ); | 388 | incidence->setRelatedTo( parent ); |
373 | parent->addRelation( incidence ); | 389 | parent->addRelation( incidence ); |
374 | } else { | 390 | } else { |
375 | // Not found, put this in the mOrphans list | 391 | // Not found, put this in the mOrphans list |
376 | mOrphans.insert( incidence->relatedToUid(), incidence ); | 392 | mOrphans.insert( incidence->relatedToUid(), incidence ); |
377 | mOrphanUids.insert( incidence->uid(), incidence ); | 393 | mOrphanUids.insert( incidence->uid(), incidence ); |
378 | } | 394 | } |
379 | } | 395 | } |
380 | } | 396 | } |
381 | 397 | ||
382 | // If a task with subtasks is deleted, move it's subtasks to the orphans list | 398 | // If a task with subtasks is deleted, move it's subtasks to the orphans list |
383 | void Calendar::removeRelations( Incidence *incidence ) | 399 | void Calendar::removeRelations( Incidence *incidence ) |
384 | { | 400 | { |
385 | // qDebug("Calendar::removeRelations "); | 401 | // qDebug("Calendar::removeRelations "); |
386 | QString uid = incidence->uid(); | 402 | QString uid = incidence->uid(); |
387 | 403 | ||
388 | QPtrList<Incidence> relations = incidence->relations(); | 404 | QPtrList<Incidence> relations = incidence->relations(); |
389 | for( Incidence* i = relations.first(); i; i = relations.next() ) | 405 | for( Incidence* i = relations.first(); i; i = relations.next() ) |
390 | if( !mOrphanUids.find( i->uid() ) ) { | 406 | if( !mOrphanUids.find( i->uid() ) ) { |
391 | mOrphans.insert( uid, i ); | 407 | mOrphans.insert( uid, i ); |
392 | mOrphanUids.insert( i->uid(), i ); | 408 | mOrphanUids.insert( i->uid(), i ); |
393 | i->setRelatedTo( 0 ); | 409 | i->setRelatedTo( 0 ); |
394 | i->setRelatedToUid( uid ); | 410 | i->setRelatedToUid( uid ); |
395 | } | 411 | } |
396 | 412 | ||
397 | // If this incidence is related to something else, tell that about it | 413 | // If this incidence is related to something else, tell that about it |
398 | if( incidence->relatedTo() ) | 414 | if( incidence->relatedTo() ) |
399 | incidence->relatedTo()->removeRelation( incidence ); | 415 | incidence->relatedTo()->removeRelation( incidence ); |
400 | 416 | ||
401 | // Remove this one from the orphans list | 417 | // Remove this one from the orphans list |
402 | if( mOrphanUids.remove( uid ) ) | 418 | if( mOrphanUids.remove( uid ) ) |
403 | // This incidence is located in the orphans list - it should be removed | 419 | // This incidence is located in the orphans list - it should be removed |
404 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { | 420 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { |
405 | // Removing wasn't that easy | 421 | // Removing wasn't that easy |
406 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { | 422 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { |
407 | if( it.current()->uid() == uid ) { | 423 | if( it.current()->uid() == uid ) { |
408 | mOrphans.remove( it.currentKey() ); | 424 | mOrphans.remove( it.currentKey() ); |
409 | break; | 425 | break; |
410 | } | 426 | } |
411 | } | 427 | } |
412 | } | 428 | } |
413 | } | 429 | } |
414 | 430 | ||
415 | void Calendar::registerObserver( Observer *observer ) | 431 | void Calendar::registerObserver( Observer *observer ) |
416 | { | 432 | { |
417 | mObserver = observer; | 433 | mObserver = observer; |
418 | mNewObserver = true; | 434 | mNewObserver = true; |
419 | } | 435 | } |
420 | 436 | ||
421 | void Calendar::setModified( bool modified ) | 437 | void Calendar::setModified( bool modified ) |
422 | { | 438 | { |
423 | if ( mObserver ) mObserver->calendarModified( modified, this ); | 439 | if ( mObserver ) mObserver->calendarModified( modified, this ); |
424 | if ( modified != mModified || mNewObserver ) { | 440 | if ( modified != mModified || mNewObserver ) { |
425 | mNewObserver = false; | 441 | mNewObserver = false; |
426 | // if ( mObserver ) mObserver->calendarModified( modified, this ); | 442 | // if ( mObserver ) mObserver->calendarModified( modified, this ); |
427 | mModified = modified; | 443 | mModified = modified; |
428 | } | 444 | } |
429 | } | 445 | } |
430 | 446 | ||
431 | void Calendar::setLoadedProductId( const QString &id ) | 447 | void Calendar::setLoadedProductId( const QString &id ) |
432 | { | 448 | { |
433 | mLoadedProductId = id; | 449 | mLoadedProductId = id; |
434 | } | 450 | } |
435 | 451 | ||
436 | QString Calendar::loadedProductId() | 452 | QString Calendar::loadedProductId() |
437 | { | 453 | { |
438 | return mLoadedProductId; | 454 | return mLoadedProductId; |
439 | } | 455 | } |
440 | 456 | ||
441 | //#include "calendar.moc" | 457 | //#include "calendar.moc" |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index c45d81f..d5294eb 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -1,325 +1,326 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef CALENDAR_H | 22 | #ifndef CALENDAR_H |
23 | #define CALENDAR_H | 23 | #define CALENDAR_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qptrlist.h> | 28 | #include <qptrlist.h> |
29 | #include <qdict.h> | 29 | #include <qdict.h> |
30 | 30 | ||
31 | #include "customproperties.h" | 31 | #include "customproperties.h" |
32 | #include "event.h" | 32 | #include "event.h" |
33 | #include "todo.h" | 33 | #include "todo.h" |
34 | #include "journal.h" | 34 | #include "journal.h" |
35 | #include "calfilter.h" | 35 | #include "calfilter.h" |
36 | 36 | ||
37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ | 37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ |
38 | 38 | ||
39 | class KConfig; | 39 | class KConfig; |
40 | 40 | ||
41 | namespace KCal { | 41 | namespace KCal { |
42 | 42 | ||
43 | 43 | ||
44 | /** | 44 | /** |
45 | This is the main "calendar" object class for KOrganizer. It holds | 45 | This is the main "calendar" object class for KOrganizer. It holds |
46 | information like all appointments/events, user information, etc. etc. | 46 | information like all appointments/events, user information, etc. etc. |
47 | one calendar is associated with each CalendarView (@see calendarview.h). | 47 | one calendar is associated with each CalendarView (@see calendarview.h). |
48 | This is an abstract base class defining the interface to a calendar. It is | 48 | This is an abstract base class defining the interface to a calendar. It is |
49 | implemented by subclasses like @see CalendarLocal, which use different | 49 | implemented by subclasses like @see CalendarLocal, which use different |
50 | methods to store and access the data. | 50 | methods to store and access the data. |
51 | 51 | ||
52 | Ownership of events etc. is handled by the following policy: As soon as an | 52 | Ownership of events etc. is handled by the following policy: As soon as an |
53 | event (or any other subclass of IncidenceBase) object is added to the | 53 | event (or any other subclass of IncidenceBase) object is added to the |
54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes | 54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes |
55 | care of deleting it. All Events returned by the query functions are returned | 55 | care of deleting it. All Events returned by the query functions are returned |
56 | as pointers, that means all changes to the returned events are immediately | 56 | as pointers, that means all changes to the returned events are immediately |
57 | visible in the Calendar. You shouldn't delete any Event object you get from | 57 | visible in the Calendar. You shouldn't delete any Event object you get from |
58 | Calendar. | 58 | Calendar. |
59 | */ | 59 | */ |
60 | class Calendar : public QObject, public CustomProperties, | 60 | class Calendar : public QObject, public CustomProperties, |
61 | public IncidenceBase::Observer | 61 | public IncidenceBase::Observer |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | Calendar(); | 65 | Calendar(); |
66 | Calendar(const QString &timeZoneId); | 66 | Calendar(const QString &timeZoneId); |
67 | virtual ~Calendar(); | 67 | virtual ~Calendar(); |
68 | void deleteIncidence(Incidence *in); | 68 | void deleteIncidence(Incidence *in); |
69 | void resetTempSyncStat(); | 69 | void resetTempSyncStat(); |
70 | void resetPilotStat(); | ||
70 | /** | 71 | /** |
71 | Clears out the current calendar, freeing all used memory etc. | 72 | Clears out the current calendar, freeing all used memory etc. |
72 | */ | 73 | */ |
73 | virtual void close() = 0; | 74 | virtual void close() = 0; |
74 | 75 | ||
75 | /** | 76 | /** |
76 | Sync changes in memory to persistant storage. | 77 | Sync changes in memory to persistant storage. |
77 | */ | 78 | */ |
78 | virtual void save() = 0; | 79 | virtual void save() = 0; |
79 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 80 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
80 | virtual bool isSaving() { return false; } | 81 | virtual bool isSaving() { return false; } |
81 | 82 | ||
82 | /** | 83 | /** |
83 | Return the owner of the calendar's full name. | 84 | Return the owner of the calendar's full name. |
84 | */ | 85 | */ |
85 | const QString &getOwner() const; | 86 | const QString &getOwner() const; |
86 | /** | 87 | /** |
87 | Set the owner of the calendar. Should be owner's full name. | 88 | Set the owner of the calendar. Should be owner's full name. |
88 | */ | 89 | */ |
89 | void setOwner( const QString &os ); | 90 | void setOwner( const QString &os ); |
90 | /** | 91 | /** |
91 | Return the email address of the calendar owner. | 92 | Return the email address of the calendar owner. |
92 | */ | 93 | */ |
93 | const QString &getEmail(); | 94 | const QString &getEmail(); |
94 | /** | 95 | /** |
95 | Set the email address of the calendar owner. | 96 | Set the email address of the calendar owner. |
96 | */ | 97 | */ |
97 | void setEmail( const QString & ); | 98 | void setEmail( const QString & ); |
98 | 99 | ||
99 | /** | 100 | /** |
100 | Set time zone from a timezone string (e.g. -2:00) | 101 | Set time zone from a timezone string (e.g. -2:00) |
101 | */ | 102 | */ |
102 | void setTimeZone( const QString &tz ); | 103 | void setTimeZone( const QString &tz ); |
103 | /** | 104 | /** |
104 | Set time zone from a minutes value (e.g. -60) | 105 | Set time zone from a minutes value (e.g. -60) |
105 | */ | 106 | */ |
106 | void setTimeZone( int tz ); | 107 | void setTimeZone( int tz ); |
107 | /** | 108 | /** |
108 | Return time zone as offest in minutes. | 109 | Return time zone as offest in minutes. |
109 | */ | 110 | */ |
110 | int getTimeZone() const; | 111 | int getTimeZone() const; |
111 | /** | 112 | /** |
112 | Compute an ISO 8601 format string from the time zone. | 113 | Compute an ISO 8601 format string from the time zone. |
113 | */ | 114 | */ |
114 | QString getTimeZoneStr() const; | 115 | QString getTimeZoneStr() const; |
115 | /** | 116 | /** |
116 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal | 117 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal |
117 | values). | 118 | values). |
118 | */ | 119 | */ |
119 | void setTimeZoneId( const QString & ); | 120 | void setTimeZoneId( const QString & ); |
120 | /** | 121 | /** |
121 | Return time zone id. | 122 | Return time zone id. |
122 | */ | 123 | */ |
123 | QString timeZoneId() const; | 124 | QString timeZoneId() const; |
124 | /** | 125 | /** |
125 | Use local time, not UTC or a time zone. | 126 | Use local time, not UTC or a time zone. |
126 | */ | 127 | */ |
127 | void setLocalTime(); | 128 | void setLocalTime(); |
128 | /** | 129 | /** |
129 | Return whether local time is being used. | 130 | Return whether local time is being used. |
130 | */ | 131 | */ |
131 | bool isLocalTime() const; | 132 | bool isLocalTime() const; |
132 | 133 | ||
133 | /** | 134 | /** |
134 | Add an incidence to calendar. | 135 | Add an incidence to calendar. |
135 | 136 | ||
136 | @return true on success, false on error. | 137 | @return true on success, false on error. |
137 | */ | 138 | */ |
138 | virtual bool addIncidence( Incidence * ); | 139 | virtual bool addIncidence( Incidence * ); |
139 | /** | 140 | /** |
140 | Return filtered list of all incidences of this calendar. | 141 | Return filtered list of all incidences of this calendar. |
141 | */ | 142 | */ |
142 | virtual QPtrList<Incidence> incidences(); | 143 | virtual QPtrList<Incidence> incidences(); |
143 | 144 | ||
144 | /** | 145 | /** |
145 | Return unfiltered list of all incidences of this calendar. | 146 | Return unfiltered list of all incidences of this calendar. |
146 | */ | 147 | */ |
147 | virtual QPtrList<Incidence> rawIncidences(); | 148 | virtual QPtrList<Incidence> rawIncidences(); |
148 | 149 | ||
149 | /** | 150 | /** |
150 | Adds a Event to this calendar object. | 151 | Adds a Event to this calendar object. |
151 | @param anEvent a pointer to the event to add | 152 | @param anEvent a pointer to the event to add |
152 | 153 | ||
153 | @return true on success, false on error. | 154 | @return true on success, false on error. |
154 | */ | 155 | */ |
155 | virtual bool addEventNoDup( Event *event ) = 0; | 156 | virtual bool addEventNoDup( Event *event ) = 0; |
156 | virtual bool addAnniversaryNoDup( Event *event ) = 0; | 157 | virtual bool addAnniversaryNoDup( Event *event ) = 0; |
157 | virtual bool addEvent( Event *anEvent ) = 0; | 158 | virtual bool addEvent( Event *anEvent ) = 0; |
158 | /** | 159 | /** |
159 | Delete event from calendar. | 160 | Delete event from calendar. |
160 | */ | 161 | */ |
161 | virtual void deleteEvent( Event * ) = 0; | 162 | virtual void deleteEvent( Event * ) = 0; |
162 | /** | 163 | /** |
163 | Retrieves an event on the basis of the unique string ID. | 164 | Retrieves an event on the basis of the unique string ID. |
164 | */ | 165 | */ |
165 | virtual Event *event( const QString &UniqueStr ) = 0; | 166 | virtual Event *event( const QString &UniqueStr ) = 0; |
166 | virtual Event *event( QString, QString ) = 0; | 167 | virtual Event *event( QString, QString ) = 0; |
167 | /** | 168 | /** |
168 | Builds and then returns a list of all events that match for the | 169 | Builds and then returns a list of all events that match for the |
169 | date specified. useful for dayView, etc. etc. | 170 | date specified. useful for dayView, etc. etc. |
170 | The calendar filter is applied. | 171 | The calendar filter is applied. |
171 | */ | 172 | */ |
172 | QPtrList<Event> events( const QDate &date, bool sorted = false); | 173 | QPtrList<Event> events( const QDate &date, bool sorted = false); |
173 | /** | 174 | /** |
174 | Get events, which occur on the given date. | 175 | Get events, which occur on the given date. |
175 | The calendar filter is applied. | 176 | The calendar filter is applied. |
176 | */ | 177 | */ |
177 | QPtrList<Event> events( const QDateTime &qdt ); | 178 | QPtrList<Event> events( const QDateTime &qdt ); |
178 | /** | 179 | /** |
179 | Get events in a range of dates. If inclusive is set to true, only events | 180 | Get events in a range of dates. If inclusive is set to true, only events |
180 | are returned, which are completely included in the range. | 181 | are returned, which are completely included in the range. |
181 | The calendar filter is applied. | 182 | The calendar filter is applied. |
182 | */ | 183 | */ |
183 | QPtrList<Event> events( const QDate &start, const QDate &end, | 184 | QPtrList<Event> events( const QDate &start, const QDate &end, |
184 | bool inclusive = false); | 185 | bool inclusive = false); |
185 | /** | 186 | /** |
186 | Return filtered list of all events in calendar. | 187 | Return filtered list of all events in calendar. |
187 | */ | 188 | */ |
188 | virtual QPtrList<Event> events(); | 189 | virtual QPtrList<Event> events(); |
189 | /** | 190 | /** |
190 | Return unfiltered list of all events in calendar. | 191 | Return unfiltered list of all events in calendar. |
191 | */ | 192 | */ |
192 | virtual QPtrList<Event> rawEvents() = 0; | 193 | virtual QPtrList<Event> rawEvents() = 0; |
193 | 194 | ||
194 | /** | 195 | /** |
195 | Add a todo to the todolist. | 196 | Add a todo to the todolist. |
196 | 197 | ||
197 | @return true on success, false on error. | 198 | @return true on success, false on error. |
198 | */ | 199 | */ |
199 | virtual bool addTodo( Todo *todo ) = 0; | 200 | virtual bool addTodo( Todo *todo ) = 0; |
200 | virtual bool addTodoNoDup( Todo *todo ) = 0; | 201 | virtual bool addTodoNoDup( Todo *todo ) = 0; |
201 | /** | 202 | /** |
202 | Remove a todo from the todolist. | 203 | Remove a todo from the todolist. |
203 | */ | 204 | */ |
204 | virtual void deleteTodo( Todo * ) = 0; | 205 | virtual void deleteTodo( Todo * ) = 0; |
205 | virtual void deleteJournal( Journal * ) = 0; | 206 | virtual void deleteJournal( Journal * ) = 0; |
206 | /** | 207 | /** |
207 | Return filterd list of todos. | 208 | Return filterd list of todos. |
208 | */ | 209 | */ |
209 | virtual QPtrList<Todo> todos(); | 210 | virtual QPtrList<Todo> todos(); |
210 | /** | 211 | /** |
211 | Searches todolist for an event with this unique string identifier, | 212 | Searches todolist for an event with this unique string identifier, |
212 | returns a pointer or null. | 213 | returns a pointer or null. |
213 | */ | 214 | */ |
214 | virtual Todo *todo( const QString &uid ) = 0; | 215 | virtual Todo *todo( const QString &uid ) = 0; |
215 | virtual Todo *todo( QString, QString ) = 0; | 216 | virtual Todo *todo( QString, QString ) = 0; |
216 | /** | 217 | /** |
217 | Returns list of todos due on the specified date. | 218 | Returns list of todos due on the specified date. |
218 | */ | 219 | */ |
219 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; | 220 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; |
220 | /** | 221 | /** |
221 | Return unfiltered list of todos. | 222 | Return unfiltered list of todos. |
222 | */ | 223 | */ |
223 | virtual QPtrList<Todo> rawTodos() = 0; | 224 | virtual QPtrList<Todo> rawTodos() = 0; |
224 | 225 | ||
225 | /** | 226 | /** |
226 | Add a Journal entry to calendar. | 227 | Add a Journal entry to calendar. |
227 | 228 | ||
228 | @return true on success, false on error. | 229 | @return true on success, false on error. |
229 | */ | 230 | */ |
230 | virtual bool addJournal( Journal * ) = 0; | 231 | virtual bool addJournal( Journal * ) = 0; |
231 | /** | 232 | /** |
232 | Return Journal for given date. | 233 | Return Journal for given date. |
233 | */ | 234 | */ |
234 | virtual Journal *journal( const QDate & ) = 0; | 235 | virtual Journal *journal( const QDate & ) = 0; |
235 | /** | 236 | /** |
236 | Return Journal with given UID. | 237 | Return Journal with given UID. |
237 | */ | 238 | */ |
238 | virtual Journal *journal( const QString &UID ) = 0; | 239 | virtual Journal *journal( const QString &UID ) = 0; |
239 | /** | 240 | /** |
240 | Return list of all Journal entries. | 241 | Return list of all Journal entries. |
241 | */ | 242 | */ |
242 | virtual QPtrList<Journal> journals() = 0; | 243 | virtual QPtrList<Journal> journals() = 0; |
243 | 244 | ||
244 | /** | 245 | /** |
245 | Searches all incidence types for an incidence with this unique | 246 | Searches all incidence types for an incidence with this unique |
246 | string identifier, returns a pointer or null. | 247 | string identifier, returns a pointer or null. |
247 | */ | 248 | */ |
248 | Incidence* incidence( const QString&UID ); | 249 | Incidence* incidence( const QString&UID ); |
249 | 250 | ||
250 | /** | 251 | /** |
251 | Setup relations for an incidence. | 252 | Setup relations for an incidence. |
252 | */ | 253 | */ |
253 | virtual void setupRelations( Incidence * ); | 254 | virtual void setupRelations( Incidence * ); |
254 | /** | 255 | /** |
255 | Remove all relations to an incidence | 256 | Remove all relations to an incidence |
256 | */ | 257 | */ |
257 | virtual void removeRelations( Incidence * ); | 258 | virtual void removeRelations( Incidence * ); |
258 | 259 | ||
259 | /** | 260 | /** |
260 | Set calendar filter, which filters events for the events() functions. | 261 | Set calendar filter, which filters events for the events() functions. |
261 | The Filter object is owned by the caller. | 262 | The Filter object is owned by the caller. |
262 | */ | 263 | */ |
263 | void setFilter( CalFilter * ); | 264 | void setFilter( CalFilter * ); |
264 | /** | 265 | /** |
265 | Return calendar filter. | 266 | Return calendar filter. |
266 | */ | 267 | */ |
267 | CalFilter *filter(); | 268 | CalFilter *filter(); |
268 | virtual QDateTime nextAlarm( int daysTo ) = 0; | 269 | virtual QDateTime nextAlarm( int daysTo ) = 0; |
269 | virtual QString nextSummary( ) const = 0; | 270 | virtual QString nextSummary( ) const = 0; |
270 | virtual void reInitAlarmSettings() = 0; | 271 | virtual void reInitAlarmSettings() = 0; |
271 | virtual QDateTime nextAlarmEventDateTime() const = 0; | 272 | virtual QDateTime nextAlarmEventDateTime() const = 0; |
272 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; | 273 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; |
273 | /** | 274 | /** |
274 | Return all alarms, which ocur in the given time interval. | 275 | Return all alarms, which ocur in the given time interval. |
275 | */ | 276 | */ |
276 | virtual Alarm::List alarms( const QDateTime &from, | 277 | virtual Alarm::List alarms( const QDateTime &from, |
277 | const QDateTime &to ) = 0; | 278 | const QDateTime &to ) = 0; |
278 | 279 | ||
279 | class Observer { | 280 | class Observer { |
280 | public: | 281 | public: |
281 | virtual void calendarModified( bool, Calendar * ) = 0; | 282 | virtual void calendarModified( bool, Calendar * ) = 0; |
282 | }; | 283 | }; |
283 | 284 | ||
284 | void registerObserver( Observer * ); | 285 | void registerObserver( Observer * ); |
285 | 286 | ||
286 | void setModified( bool ); | 287 | void setModified( bool ); |
287 | 288 | ||
288 | /** | 289 | /** |
289 | Set product id returned by loadedProductId(). This function is only | 290 | Set product id returned by loadedProductId(). This function is only |
290 | useful for the calendar loading code. | 291 | useful for the calendar loading code. |
291 | */ | 292 | */ |
292 | void setLoadedProductId( const QString & ); | 293 | void setLoadedProductId( const QString & ); |
293 | /** | 294 | /** |
294 | Return product id taken from file that has been loaded. Returns | 295 | Return product id taken from file that has been loaded. Returns |
295 | QString::null, if no calendar has been loaded. | 296 | QString::null, if no calendar has been loaded. |
296 | */ | 297 | */ |
297 | QString loadedProductId(); | 298 | QString loadedProductId(); |
298 | 299 | ||
299 | signals: | 300 | signals: |
300 | void calendarChanged(); | 301 | void calendarChanged(); |
301 | void calendarSaved(); | 302 | void calendarSaved(); |
302 | void calendarLoaded(); | 303 | void calendarLoaded(); |
303 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 304 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
304 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 305 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
305 | 306 | ||
306 | protected: | 307 | protected: |
307 | /** | 308 | /** |
308 | Get unfiltered events, which occur on the given date. | 309 | Get unfiltered events, which occur on the given date. |
309 | */ | 310 | */ |
310 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; | 311 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; |
311 | /** | 312 | /** |
312 | Get unfiltered events, which occur on the given date. | 313 | Get unfiltered events, which occur on the given date. |
313 | */ | 314 | */ |
314 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, | 315 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, |
315 | bool sorted = false ) = 0; | 316 | bool sorted = false ) = 0; |
316 | /** | 317 | /** |
317 | Get events in a range of dates. If inclusive is set to true, only events | 318 | Get events in a range of dates. If inclusive is set to true, only events |
318 | are returned, which are completely included in the range. | 319 | are returned, which are completely included in the range. |
319 | */ | 320 | */ |
320 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 321 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
321 | bool inclusive = false ) = 0; | 322 | bool inclusive = false ) = 0; |
322 | Incidence *mNextAlarmIncidence; | 323 | Incidence *mNextAlarmIncidence; |
323 | 324 | ||
324 | private: | 325 | private: |
325 | void init(); | 326 | void init(); |